function InitMenu(){
	var nav = document.getElementById("navigation");
	var buttons = nav.getElementsByTagName("a");
	for(var i=0;i<buttons.length;i++){
		if(buttons[i].parentNode.parentNode.parentNode != nav) continue;
		if(buttons[i].parentNode.className == "selected") buttons[i].parentNode.persistent = true;
		buttons[i].onmouseover = menu_mouseover;
		buttons[i].onmouseout = menu_mouseout;
	}
}

var SHOWMENU = null, TIMER = null;
function menu_mouseover(){
	hideMenu();
	if(!this.parentNode.className) this.parentNode.className = "selected";
	if (!this.nextSibling || !this.nextSibling.nextSibling) return;
	var menu = this.nextSibling.nextSibling;
	menu.style.display = "block";
	SHOWMENU = menu;
	
	menu.onmouseover = function(){
		clearTimeout(TIMER);
		var button = this.previousSibling.previousSibling;
		if(!button.parentNode.className) button.parentNode.className = "selected";
	}
	menu.onmouseout = function(){
		TIMER = setTimeout("hideMenu()", 300);
	}
	
}

function menu_mouseout(){
	if(this.className == "selected" && !this.persistent) this.className = ""
	TIMER = setTimeout("hideMenu()", 10);
}

function hideMenu(){
	clearTimeout(TIMER);
	if(!SHOWMENU) return;
	SHOWMENU.style.display = "none";

	var button = SHOWMENU.previousSibling.previousSibling;
	if(button.parentNode.className == "selected" && !button.parentNode.persistent) button.parentNode.className = "";
	SHOWMENU = null;
}
