
function initPullDownLists() {
	var menus = document.getElementsByName('pulldown');
	for(var i=0;i<menus.length;i++) {
		initPullDownList(menus[i]);
	}
}

function initPullDownList(button) {
	var max_width = 0;
	button.list = document.getElementById("l" + button.id);
	var links = button.list.getElementsByTagName('a');
	button.list.style.visibility = 'hidden';
	button.list.style.display = 'block';
	for(var i=0; i<links.length;i++) {
		if(links[i].offsetWidth > max_width) {
			max_width = links[i].offsetWidth;
		}
	}
	button.list.style.display = 'none';
	button.list.style.visibility = 'visible';
	
	button.delay = {
		"show": 0,
		"hide": 300
	}
	
	if(button.list != "undefined") {

		button.list.style.top = button.offsetTop + button.offsetHeight + "px";
		button.list.style.width = max_width + "px";
		button.list.button = button;	
		
		button.list.switchState = function() {
			if (this.timeout) clearTimeout(this.timeout);
			if(this.style.display == 'block') {
				this.hide();
			} else {
				this.show();
			}
		}
		
		button.list.show = function() {
			this.style.display = 'block';
		}
		
		button.list.hide = function() {
			this.style.display = 'none';
		}
		
		button.list.onmouseover = function() {
			if (this.button.timeout) clearTimeout(this.button.timeout);
		}
		
		button.list.onmouseout = function() {
			this.button.onmouseout();
		}
		
		button.onclick = function() {
			this.list.switchState();
			return false;
		}
		
		button.onmouseover = function() {
			if (this.timeout) clearTimeout(this.timeout);
			this.list.show();
		}
		
		button.onmouseout = function() {
			if (this.timeout) clearTimeout(this.timeout);
			this.timeout = setTimeout(function(button) { return function() { button.list.hide() } } (this), this.delay.hide);
		}
		
	} else {
		button.onclick = function() {
			return false;
		}
	}
	
}