function init_menu(){
	var links = document.getElementById("menu").getElementsByTagName("div");
	for (var i = 0; i < links.length; i++) {
		if (links[i].className != "current_page") {
			links[i].onmouseover = function(){
				this.style.backgroundColor = "#346633";
				this.style.color = "#9B9966";
				this.style.cursor = "pointer";
				if (this.getElementsByTagName("a")[0]) {
					this.getElementsByTagName("a")[0].style.color = "#9B9966";
				}
			}
			links[i].onmouseout = function(){
				this.style.backgroundColor = "#9B9966";
				this.style.color = "#346633";
				this.style.cursor = "auto";
				if (this.getElementsByTagName("a")[0]) {
					this.getElementsByTagName("a")[0].style.color = "#346633";
				}
			}
			if (links[i].getElementsByTagName("a")[0]) {
				links[i].onclick = function(){
					make_cookie();
					location.href = this.getElementsByTagName("a")[0].href;
				}
				links[i].getElementsByTagName("a")[0].onclick = function (event) {
					make_cookie();
				}
			}
			else {
				links[i].onclick = function(){
					document.getElementById("sub" + this.id).style.display = (document.getElementById("sub" + this.id).style.display == "block") ? "none" : "block";
				}
			}
		}
	}
	links = document.getElementById("menu").getElementsByTagName("li");
	for (var i=0; i<links.length; i++){
		if (links[i].className != "current_page") {
			links[i].onmouseover = function(){
				this.style.backgroundColor = "#346633";
				this.style.color = "#CCCC99";
				this.style.cursor = "pointer";
				this.getElementsByTagName("a")[0].style.color = "#CCCC99";
			}
			links[i].onmouseout = function(){
				this.style.backgroundColor = "#CCCC99";
				this.style.color = "#346633";
				this.style.cursor = "auto";
				this.getElementsByTagName("a")[0].style.color = "#346633";
			}
			links[i].onclick = function(){
				make_cookie();
				location.href = this.getElementsByTagName("a")[0].href;
			}
			links[i].getElementsByTagName("a")[0].onclick = function (event) {
				make_cookie();
			}
		}
	}
}

function make_cookie(){
	var menus = document.getElementById("menu").getElementsByTagName("ul");
	for (var i = 0; i < menus.length; i++){
		if (menus[i].style.display == "block"){
			document.cookie = menus[i].id + "=disp; path=/";
		}
		else {
			document.cookie = menus[i].id + "=nodisp; expires=0; path=/";
		}
	}
}

addEventHandler(window, "load", init_menu);
