function getid(id){
	if(typeof id=="string") return document.getElementById(id);
	return id;
}
function getNext(startBrother){
	  endBrother=startBrother.nextSibling;
	  while(endBrother.nodeType!=1){
	    endBrother = endBrother.nextSibling;
	  }
	  return endBrother;
}
function getPrev(startBrother){
	  endBrother=startBrother.previousSibling;
	  while(endBrother.nodeType!=1){
	    endBrother = endBrother.previousSibling;
	  }
	  return endBrother;
}

function hoverpmenu(id){
	var obj=id.parentNode.parentNode;
	getPrev(obj).className="leftmenu";
	getNext(obj).className="rightmenu";
	obj.className="centermenu";
}

function hidepmenu(id){
	var obj=id.parentNode.parentNode;
	getPrev(obj).className="nobackmenu";
	getNext(obj).className="nobackmenu";
	obj.className="nobackmenucenter";
}
function checkpmenu(id){
	var obj=id.parentNode.parentNode;
		
	
		if(obj.className=="nobackmenucenter"){
			return false;
		}else{
			return true;
		}
	
}

function exprokachu(fromleft,where){
	var divmenu=getid("submenu");
	var newpos;
if(where==1){
	var posnow=parseInt(divmenu.style.left);
			if(posnow<fromleft){
				tmenu=setTimeout('exprokachu('+fromleft+',1)',timer);
				newpos=parseInt(divmenu.style.left)+speed;
				divmenu.style.left=newpos+'px';
				posnow=parseInt(divmenu.style.left);
				if((fromleft-posnow)<30){
					timer=timer+1;
					
					speed=2;
				}
				
			}
		}
}


function showmenu(id){
	
	    
	
	var ParLeft=id.getBoundingClientRect().left;
	var ParRight=id.getBoundingClientRect().right;
	var ParMiddle=Math.floor((ParRight-ParLeft)/2+ParLeft);
	var myids=parseInt(id.id);
	
	if(menuarr[myids]){
		mydiv=getid("menulist");
		mydiv.innerHTML="";
		for(i=0;i<menuarr[myids].length;i++){
			mimg=document.createElement("img");
			mimg.width=9;
			mimg.height=9;
			mimg.src=menuarrow.src;
			mhref=document.createElement("a");
			mhref.href="/"+menuarr[myids][i][1]+"/";
			mhref.innerHTML=menuarr[myids][i][0];
			mydiv.appendChild(mimg);
			mydiv.appendChild(mhref);
		}
		
	}else{
		getid("menulist").innerHTML="";
	}
	
	var divmenu=getid("submenu");
	var tablemenu=getid("submenutable");
		if((divmenu.offsetWidth+30+7)<=ParRight){
			var DivLeft=ParRight-divmenu.offsetWidth;
			var DivCursor=tablemenu.offsetWidth-Math.round(id.offsetWidth/2)-8;
		}else{
			var DivLeft=30;
			var DivCursor=(ParLeft-30)+Math.round(id.offsetWidth/2)-8;
		}
		
		if(DivCursor<7)DivCursor=7;
		
		clearTimeout(tmenu);
		var leftnow=0-divmenu.offsetWidth;
		divmenu.style.left=leftnow+'px';
	
	
	getid("menucursor").style.left=DivCursor+'px';
	
	
	
	timer=1;
	speed=15;
	exprokachu(DivLeft,1);
		
}
function checkmenu(id){
	
if(arguments[1]){
		
		if(arguments[1]!=pressed){
			if(pressed!=0){hidepmenu(getid(pressed));}
			pressed=arguments[1];
			if(!arguments[2]){
			hoverpmenu(id);
			showmenu(id);
			}else{
			hoverpmenu(id);	
			}
		}
		
	}else{
	if(checkpmenu(id) && pressed!=id.id){
		hidepmenu(id);
	}else{
		hoverpmenu(id);
	}
	}
}
function retheight(){
	var Hsize=document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	var Dbottom=getid('spdim').getBoundingClientRect().top+101;
	var Dheight=Hsize-Dbottom;
	if(navigator.userAgent.toLowerCase().indexOf("msie")>0){
		Dheight=Dheight+50;
	}
	if(parseInt(Dheight)>0){getid('resizer').style.height=Dheight+"px";}
}
