//variables globals per definir el menu
var distanciaX=198;
var distanciaY=80;
var the_timeout;
navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("li");
	//alert(lis.length);
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
			this.style.zIndex = 20;
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
var tempX=0;
var tempXanterior=0;
function posXRatoli(e){
	var IE = document.all?true:false;
	if (IE) { // grab the x-y pos.s if browser is IE
		try {
			tempX =	parseInt(event.clientX) + parseInt(document.body.scrollLeft);
	  	 }catch(Exception){	tempX=tempXanterior; }
	} else {  // grab the x-y pos.s if browser is NS
	    	tempX = e.pageX;
	}  
	if (tempX < 0){tempX = 0}
	//document.Show.MouseX.value = tempX
	return tempX;
}
var maximDesplacamentEsquerre=0;
function mouCapa(){
	id_Div="capaMoviment";
	if (document.getElementById(""+id_Div+"")){
		capa = eval('document.getElementById("' + id_Div + '")');
		id_Div="capaGlobal";
		if (document.getElementById(""+id_Div+"")){
			capa2 = eval('document.getElementById("'+id_Div+'")');
			ratoliX=posXRatoli();
			//198 es la distancia on comença el menu
			ratoliX=ratoliX-distanciaX;
			midaMenu=parseInt(capa2.style.width);
			XfraccioLent=parseInt(capa2.style.width)/4;
			XfraccioRapid=parseInt(capa2.style.width)/6;
			if (ratoliX<(XfraccioRapid))	{
		 		if (parseInt(capa.style.marginLeft)<0){
					capa.style.marginLeft=parseInt(capa.style.marginLeft) + 10;
				}
			}else if (ratoliX<XfraccioLent)	{
		  		if (parseInt(capa.style.marginLeft)<0){
					capa.style.marginLeft=parseInt(capa.style.marginLeft) + 1;
				}
			} else	if (maximDesplacamentEsquerre-midaMenu>Math.abs(parseInt(capa.style.marginLeft))){
				if (ratoliX>midaMenu-XfraccioRapid)	{
					capa.style.marginLeft=parseInt(capa.style.marginLeft) - 10;
				}else if (ratoliX>midaMenu-XfraccioLent)	{
					capa.style.marginLeft=parseInt(capa.style.marginLeft) - 1;
				}
			}else if (capa.style.marginLeft>0){capa.style.marginLeft=0}
			the_timeout = setTimeout('mouCapa()', 10);
			tempXanterior=ratoliX+distanciaX;
		}
	}
}
function paraCapa(){
	clearTimeout(the_timeout);
}
if (window.attachEvent) window.attachEvent("onload", navHover);
