

//Version 1.2
//Delay with nice menu can be achieved with this version
//settimeout function value is set to 500 here. You can change to what ever delay you want.


Function.prototype.bind = function(obj) {
	var me = this;
	return function() { me.apply(obj) }
}

function createHandler(o)  {
	return function() {
		prevele=this;
		timer=setTimeout(
			function() {
					this.className = "menuparent";
			}.bind(o)
			,500
		)
	}
}

function IEHoverPseudo() {
	var ulNodes = getElementsByClass("nice-menu");
	var j = 0;
	out=1;
	timer=0;
	prevele=0;	//used to track the previous element.
	var liNodes = null;
	for(var i = 0; i < ulNodes.length; i++) {
		liNodes = ulNodes[i].getElementsByTagName("li");
		for(j = 0; j < liNodes.length; j++) {

			if(liNodes[j].className == "menuparent") {
				out=1;
				liNodes[j].onmouseover=function()
				{
					if(timer){
						prevele.className= "menuparent";
						clearTimeout(timer);
					}
					this.className += " over";
				}

				liNodes[j].onmouseout=createHandler(liNodes[j]);

			}

			if(liNodes[j].className == ""){
			}

		    }
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

window.onload = IEHoverPseudo;