function MOhideAll() {
	MOnavRoot = document.getElementById("primary");
	for (i=0; i<MOnavRoot.childNodes.length; i++) {
		var MOnode = MOnavRoot.childNodes[i];
		if (MOnode.nodeName=="LI") {
			var MOulchildren = MOnode.getElementsByTagName("ul");
			if (MOulchildren.length > 0) {
				for (j=0; j < MOulchildren.length; j++) {
					MOulchildren[j].style.visibility = "hidden";
				}
			}
		}
	}
}

MOstartList = function() {
	var MOnavRoot = document.getElementById("primary");
	/* get the rightmost li's right-pixel */
	var MOrmliright = 0;
	for (i=0; i<MOnavRoot.childNodes.length; i++) {
		var MOnode = MOnavRoot.childNodes[i];
		if (MOnode.nodeName=="LI") {
			var MOlileft = MOnode.offsetLeft;
			var MOliwidth = MOnode.offsetWidth;
			MOrmliright = Math.max(MOlileft + MOliwidth, MOrmliright);
		}
	}
	for (i=0; i<MOnavRoot.childNodes.length; i++) {
		var MOnode = MOnavRoot.childNodes[i];
		if (MOnode.nodeName=="LI") {
			var MOtch = MOnode.getElementsByTagName("ul");
			if (MOtch.length > 0) {
				/* remove href for top-level with children */
				/* but remove only if the submenu is not spacer-only */
/*				if (	MOnode.childNodes.length == 3 &&
					MOnode.childNodes[2].childNodes.length == 1 &&
					MOnode.childNodes[2].childNodes[0].childNodes.length == 1 &&
					MOnode.childNodes[2].childNodes[0].childNodes[0].nodeName == "IMG") {
					// spacer only, don't remove link
				} else {
					// no spacer, remove link
					for (k=0; k<MOnode.childNodes.length; k++) {
						var MOanode = MOnode.childNodes[k];
						if (MOanode.nodeName=="A") {
							MOanode.href="#";
						}
					}
				} */
				/* get parent position and width */
				var MOparwidth = MOnode.offsetWidth;
				var MOparx = MOnode.offsetLeft;
				var MOparmiddle = MOnode.offsetLeft + MOnode.offsetWidth/2;
				/* set child position */
				for (j=0; j<MOtch.length; j++) {
					var MOxulx = MOparmiddle - MOtch[j].offsetWidth/2;
					/* make sure the element doesn't overflow the right border */
					if (MOxulx + MOtch[j].offsetWidth > MOrmliright) {
						MOxulx = Math.min(MOxulx, MOrmliright - MOtch[j].offsetWidth);
					}
					MOxulx = Math.max(0, MOxulx);
					MOtch[j].style.left = MOxulx + "px";
				}
				MOnode.onclick=function() {
					MOhideAll();
					/* set child-menu visible */
					MOxulchildren = this.getElementsByTagName("ul");
					for (j=0; j<MOxulchildren.length; j++) {
						/* calculate child position */
						MOxulchildren[j].style.visibility = "visible";
					}
				}
			}
		}
	}
}

var version="n3";


