var test = document.getElementById("menu");
var stuff= setInterval("alert('lol')",1000000);
var stuff2= setInterval("alert('lol')",1000000);
var stuff3= setInterval("alert('lol')",1000000);
clearInterval(stuff);
clearInterval(stuff2);
clearInterval(stuff3);
var test2 = document.getElementById("undermenu");
var test3= document.getElementById("theundermenu");
test3.style.height="0px";
test2.style.height="35px";
var maxheight="35";
var loading = document.getElementById("loading");
var children = test.children;

var children2 = test2.children;
	for (i=0; i<children2.length; i++){
		children2[i].onclick = asdf2(children2[i],0);
		children2[i].onmouseover = asdf2(children2[i],1);
		children2[i].onmouseout = keepup();
	}
    for (i=0; i<children.length; i++){
		children[i].onclick = asdf(children[i],0);
		children[i].onmouseover = asdf(children[i],1);
		children[i].onmouseout = keepup();
	}
function getX( oElement )
{

var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetLeft;
oElement = oElement.offsetParent;
}
return iReturnValue;
}
function clearStuff(){
	return function () {
	clearInterval(stuff3);
	};
}
function keepup(){
	return function () {
	
	stuff3=setInterval("hidemenu()",300);
	};
}
function asdf(value,link) {
   return function () {
	
      clearInterval(stuff3);
   if(link==0){
		
   }
  
   for (i=0; i<children.length; i++){
			
			/*if(children[i].getAttribute("id")==value.getAttribute("id"))
				children[i].style.background="background:url(../images/hover2.png) repeat-x left;";
			else
				children[i].style.background="";*/
				
			
	}
	
	for (i=0; i<children2.length; i++){
	
				children2[i].style.background="";
		}
	 
   if(checkundermenu(value.getAttribute("name"))==1)showundermenu(value.getAttribute("name"),getX(value));else hidemenu();};
   
}; 
function asdf2(value,link) {
	return function () {
		
		clearInterval(stuff3);
		if(link==0){
		
		}
		for (i=0; i<children2.length; i++){
			if(children2[i].getAttribute("id")==value.getAttribute("id"))
				children2[i].style.background="background:url(../images/hovermenu.png) repeat-x left;";
			else
				children2[i].style.background="";
		}
	};

}; 
function checkundermenu(nr){
	for (i=0; i<children2.length; i++){
		if(children2[i].getAttribute("name")==nr){
			return 1;
		}
	}
	return 0;
}
function showundermenu(nr,getx){
	test3.style.left=getx+"px";
	displaymenu();
	var first=0;
	for (i=0; i<children2.length; i++){
		if(children2[i].getAttribute("name")==nr){
		children2[i].style.display="block";
		if(first==0){
			children2[i].setAttribute("class","menul");
			first++;
			}
		else
			children2[i].setAttribute("class","menul");
		}
		else
		children2[i].style.display="none";
	}
}
function displaymenu(){
	test3.style.display="block";
	test3.style.overflow="hidden";
	if(typeof(stuff2) != 'undefined'){
	clearInterval(stuff2);}
	if(typeof(stuff) != 'undefined'){
	clearInterval(stuff);}
	stuff =setInterval("animateup()",1);
}
function animateup(){
	if(typeof(stuff2) != 'undefined'){
	clearInterval(stuff2);}
	var currheight= test3.style.height.substr(0, test3.style.height.length - 2);	
	currheight=parseInt(currheight);
	
	if(currheight>34){
		test3.style.height="36px";
		//Stop interval;
		clearInterval(stuff);
	}
	else{
	/*	currheight++;
		alert(currheight);*/
		currheight+=5;
		
		test3.style.height=currheight+"px";
		//Keep interval;
	}
}
function animatedown(){
	if(typeof(stuff) != 'undefined'){
	clearInterval(stuff);}
	var currheight2= test3.style.height.substr(0, test3.style.height.length - 2);	
	currheight2=parseInt(currheight2);
	if(currheight2<2){
		test3.style.height="0px";
		test3.style.display="none";
		//Stop interval;
		clearInterval(stuff2);
	}
	else{
		currheight2-=5;
		test3.style.height=currheight2+"px";
		//Keep interval;
	}
}
function hidemenu(){
	clearInterval(stuff3);
	if(typeof(stuff2) != 'undefined'){
	clearInterval(stuff2);}
	if(typeof(stuff) != 'undefined'){
	clearInterval(stuff);}
	test3.style.display="block";
	test3.style.overflow="hidden";
	stuff2 =setInterval("animatedown()",1);
}

