function menuInit() {
	if (!document.getElementById || !document.getElementById('menu')) {
		return false;
	}
	
	var aC = document.getElementById('menu').childNodes;
	
	for (var i in aC) {
		if (aC[i].tagName && aC[i].tagName.toUpperCase() == 'UL' && aC[i].className && aC[i].className == 'mainmenu') {
			var aC2 = aC[i].childNodes;
			
			for (var j in aC2) {
				if (aC2[j].tagName && aC2[j].tagName.toUpperCase() == 'LI') {
					//aC2[j].onmouseover = menuMouseOver;
					aC2[j].onmouseover = function () {this.className = this.className + ' hover';};
					//aC2[j].onmouseout  = menuMouseOut;
					aC2[j].onmouseout  = function () {this.className = this.className.replace(/\s*hover$/g, '')};
				}
			}
		}
	}
	
	/*
	// The last <span class="div"></span> gets a unique classname
	var cDividers = document.getElementById('menu').getElementsByTagName("span");
	var currDivider = null;
	for (var i = 0, ii = cDividers.length; i < ii; i++) {
		if ("div" == cDividers[i].getAttribute((document.all) ? "className" : "class") && !cDividers[i].innerHTML.length) {
			currDivider = cDividers[i];
		}
	}
	if (currDivider) {
//			currDivider.parentNode.removeChild(currDivider);
		currDivider.className += " lastdiv";
	}
	*/
	
	// The rightmost dropdown menu layer gets a unique classname
	var cMenuLayers = document.getElementById('menu').getElementsByTagName("div");
	var currLyr = null;
	for (var i = 0, ii = cMenuLayers.length; i < ii; i++) {
		if ("submenu" == cMenuLayers[i].getAttribute((document.all) ? "className" : "class")) {
			currLyr = cMenuLayers[i];
		}
	}
	if (currLyr) {
		currLyr.className += " lastsubmenu";
	}

	// Change the spaces in menu texts to &nbsp;
	var cA = document.getElementById("menu").getElementsByTagName("a");
	for (var i = 0, ii = cA.length; i < ii; i++) {
		cA[i].innerHTML = cA[i].innerHTML.replace(/\s/g, "&nbsp;");
	}
}

/*
function menuMouseOver() {
	this.className = this.className + ' hover';
}
function menuMouseOut() {
	this.className = this.className.replace(/\s*hover$/g, '');
}
*/


if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", menuInit, false);
} else {
	window.attachEvent("onload", menuInit);
}
// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)

document.write("<script id='__ie_onloadMENU' defer='defer' src='EMPTY.js'><\/script>");
var script = document.getElementById("__ie_onloadMENU");

script.onreadystatechange = function() {
	if (this.readyState == "complete") {
		menuInit(); // call the onload handler
	}
};
/*@end @*/
