function hideAllSubMenus() {
	menuList = document.getElementById("menu").getElementsByTagName("ul")[0];
	subMenus = menuList.getElementsByTagName("ul")
	for(m=0;m<subMenus.length;m++) {
		subMenuLink = subMenus[m].parentNode.getElementsByTagName("a")[0];
		// only hide the sub menu if the submenu's link is not contained in the current document.location
		if(document.location.toString().indexOf(subMenuLink.href) == -1) {
			hideSubMenu(subMenus[m], subMenuLink);
		} else {
			showSubMenu(subMenus[m], subMenuLink);
		}
		subMenuLink.onclick = function() {
			currSubMenu = this.parentNode.getElementsByTagName("ul")[0]
			if (currSubMenu.expanded == true) {
				// hide this submenu
				hideSubMenu(currSubMenu, this)
			} else {
				// hide all submenus
				hideAllSubMenus();
				// then show this one
				showSubMenu(currSubMenu, this);
			}
			return false;
		}
	}
}

function hideSubMenu(subMenu, subMenuLink) {
	// set the display of the current submenu to none
	subMenu.style.display = "none";
	subMenu.style.left = "-999em";
	subMenu.style.position = "absolute";
	// set the expanded of the submenu to false
	subMenu.expanded = false;
	// show the up arrow 
	subMenuLink.className = "menuhidden";
}

function showSubMenu(subMenu, subMenuLink) {
	// set the display of the current submenu to shown
	subMenu.style.display = "block";
	subMenu.style.left = "auto";
	subMenu.style.position = "static";
	// set the expanded of the submenu to true
	subMenu.expanded = true;
	// show the down arrow
	subMenuLink.className = "menushown";
}


// run functions on load
if (document.all&&window.attachEvent) {
	// IE-Win 
	window.attachEvent("onload", hideAllSubMenus);
} else if (window.addEventListener) {
	// Others
	window.addEventListener("load", hideAllSubMenus, false);
}



