
var last_id = "";
var timerID ="";
var speed=0;
var step=3;


function show(id)
{
    // if allready rolledout then rollin
    if (last_id != ""){
   // alert("last_id: " + last_id  +"; uid:" +id);
	var height = document.getElementById(last_id).getElementsByTagName('ul')[0].offsetHeight;
	epull_up (last_id , 0, height, height);
    }
      
    if (last_id != id){  
    	showid(id);
    	last_id =id;
    }
    else {  
    	last_id = "";    	
    }
    
}

function setLast(menuid){
	var lis = document.getElementById(menuid).getElementsByTagName('li');

	for (var i = 0; i < lis.length; i++) {
   		if(lis[i].className == 'act') {
   			last_id = lis[i].id;
   			break;   			
   		}
   			
 	}
	
}

function showid(id){
	var height= document.getElementById(id).getElementsByTagName('ul')[0].offsetHeight;
	epull_down (id, height, 0);
	  
	document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'visible';
	document.getElementById(id).getElementsByTagName('ul')[0].style['position'] = 'static';
}

function epull_down(id,to,nowv) {
	
	nowv = ((to-nowv) < step)? to : (nowv+step);
	
	var menu = document.getElementById(id).getElementsByTagName('ul')[0];
	menu.style['height'] = nowv +"px";
	menu.style['position'] = 'static';
 
	if(nowv < to) 
		timerID = setTimeout("epull_down('"+id+"',"+to+","+nowv+")",speed);
	else {
		timerID = ""; 
	}
}

function epull_up(id,to,nowv, height) {
	nowv = (nowv < step)? 0 : (nowv-step);
	var menu = document.getElementById(id).getElementsByTagName('ul')[0];
	menu.style['height'] = nowv +"px";
	//menu.style['position'] = 'static';
 
	if(nowv > to) 
		timerID = setTimeout("epull_up('"+id+"',"+to+","+nowv+","+height+")",speed);
	else {
		timerID = ""; 
		menu.style['visibility'] = 'hidden';
		menu.style['position'] = 'absolute';
		menu.style['height'] = height + "px";
		//alert("set_height " + height);
		
		//menu.offsetHeight= height;		    	
	}
}
