var menu_id = "sub_menu"

initMenu = function() {

	//Open current location in menu
	/*
	var loc = window.location.toString().replace(window.location.hash, "");

	var menu_items = getElementsBySelector("#" + menu_id + " a");
	for(var i=0; i<menu_items.length; i++){
		var m = menu_items[i];
		if(m.href == loc && m.className.indexOf("skip") < 0){

			m.className += " selected";
			var p = m.parentNode;
			while(p.id != menu_id){
				if(p.tagName == "LI")
					p.className = "selected";
				p = p.parentNode;
			}
		}
	}*/

	//Set up dropdown/popout menu system

	var nav_items = getElementsBySelector("#" + menu_id + " li");
	for (i=0; i<nav_items.length; i++) {
		node = nav_items[i];
		if (node.nodeName=="LI" && node.getElementsByTagName("UL").length > 0) {
			
			for(var j=0; j<node.childNodes.length; j++){
				var n = node.childNodes[j];
				if(n.tagName=="A" || n.tagName=="STRONG")n.className += "has_sub";
				if(n.tagName=="UL")n.className += "sub";
			}
			
			if (document.all&&document.getElementById) {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		 }
	}
}

EventUtils.addEventListener(window,'load',initMenu);
