var menu_t=[];
var prec=Array();
var ok_=[];

function _$(a){
	b=document.getElementById(a);
	return (b?b:document.getElementsByName(a)[0]);
}

for (var i in menu_id){
	/*
	alert(document.getElementById("l_"+menu_id[i]));
	$("#l_"+menu_id[i]).mouseover(function(){z(this)});
	$("#l_"+menu_id[i]).mouseout(function(){z_prec(this,true)});
	*/
	ok_[menu_id[i]]=false;
}

function t(a_,b){
	try{
		var a=document.getElementById(a_);
		a.style.opacity=b/100;
		a.style.MozOpacity=b/100;
		a.style.KhtmlOpacity=b/100;
		a.style.filter="alpha(opacity="+b+")";
		if (b==0)
			a.style.display="none";
	}catch (e){
	}
}

function z(a){
	var id=parseInt((""+a.id).substring(2),10);

	if (ok_[id]==false){
		var id=parseInt((""+a.id).substring(2),10);
		var l=gXY(document.getElementById("l_"+id))[0];

		//$("#m_"+id).css({"display":"block", "left":l+"px", "opacity":"0"});
		t("m_"+id, 0);
		_$("m_"+id).style.left=l+"px";
		_$("m_"+id).style.display="block";

		try{
			for (var i in prec[id])
				clearTimeout(prec[id][i]);
			
			prec[id]=Array();
		}catch (e){
		}
		
		ok_[id]=true;
		
		for (var i=10;i<=100;i+=10)
			setTimeout('t("m_"+'+id+','+i+')',(i+1)*2);
	}else{
		try{
			clearTimeout(menu_t[id]);
		}catch (e){
		}
	}
}

function z_prec_f(id){
	prec[id]=Array();
	ok_[id]=false;
	for (var i=90;i>=0;i-=10)
		prec[id].push(setTimeout('t("m_"+'+id+','+i+')',(100-i+1)*2));
}

function z_prec(a, b){
	var id=parseInt((""+a.id).substring(2),10);
	try{
		clearTimeout(menu_t[id]);
	}catch (e){
	}
	
	if (b)
		menu_t[id]=setTimeout("z_prec_f("+id+")",250);
}

function gXY(o){
	var xy=[0,0];
	if (o.offsetParent){
		xy[0]=o.offsetLeft;
		xy[1]=o.offsetTop;

		while (o=o.offsetParent){
			if (!o.id || o.id != "main") {
				xy[0]+=o.offsetLeft;
				xy[1]+=o.offsetTop;
			}
        }
	}
	
	return xy;
}

var wX=wY=0;
document.onmousemove = getMouseXY;

function getMouseXY(e) {
  if (document.all){
    wX=event.clientX+document.body.scrollLeft;
    wY=event.clientY+document.body.scrollTop;
  }else{
    wX=e.pageX;
    wY=e.pageY;
  }  
  
  if (wX<0)
	wX=0;
	
	if (wY<0)
		wY=0;

	return true;
}
