document.documentElement.className="js";

function addHoverFunc(el)
{
	
	var thisElement,nextElement;
	var step=0;
	function howeron()
	{
		nextElement=this;
		var n=++step;
		if (!thisElement || !thisElement.hul) {
			shide();
			return;
		}
		setTimeout(function() {
			if (n==step) shide();
			},30);
	}
	
	function howeroff()
	{
		nextElement=null;
		var n=++step;
		if (!thisElement || !thisElement.hul) {
			shide();
			return;
		}
		setTimeout(function() {
			if (n==step) shide();
			},30);
	}
	
	function shide()
	{
		if (nextElement == thisElement) return;
		if (thisElement) thisElement.className = thisElement.className.replace(/( ?hower)/g,'');
		if (nextElement) nextElement.className += " hower";
		thisElement=nextElement;
	}
	
	function fokus()
	{
		nextElement = this.linea;
		this.className += " hower";
		step++;
		shide();
	}
	
	function unfokus()
	{
		nextElement = null;
		this.className = this.className.replace(/( ?hower)/g,'');
		step++;
		shide();
	}
	
	function fadd(li)
	{
		var el=li,i;
		var as=el.getElementsByTagName('a');
		for (i=0;i<as.length;i++) {
			as[i].linea=el;
			as[i].onfocus=fokus 
			as[i].onblur=unfokus;
		}
	}
	
	el=document.getElementById(el);
	var li;
	for (li=el.firstChild;li;li=li.nextSibling) {
		if (li.nodeName.toLowerCase()=='li') {
			li.onmouseover=howeron;
			li.onmouseout=howeroff;
			var s=li.getElementsByTagName('ul');
			if (s.length) li.hul=true;
			fadd(li);
		}
	}
}
