menuHover = function() {
	var menuEls = document.getElementById("mainmenu").getElementsByTagName("li");
	for (var i=0; i<menuEls.length; ++i) {
		menuEls[i].onmouseover=function() {
			clearTimeout(this.timer);
			if(this.className.indexOf(" mouseover") == -1)
				this.className+=" mouseover";
		}
		menuEls[i].onmouseout=function() {
			this.timer = setTimeout(menuHoverOut.bind(this), 20);
		}
	}
}

function menuHoverOut() {
	clearTimeout(this.timer);
	this.className=this.className.replace(new RegExp(" mouseover\\b"), "");
}

if (window.attachEvent) window.attachEvent("onload", menuHover);