var timeout1=null;
var interval1=null;
var subMenuId=null;
var subMenuHeight=0;
var timeStep=0;
var totalTimeSteps=12;
var direction=0;
function toggleSubMenu(id){
	while(!isDomReady){
		//retry in 0.5 sec:
		timeout1=setTimeout("toggleSubMenu('"+id+"')",500);
	}
	if(interval1!=null)return;
	//alert(document.getElementById(id).offsetHeight);

	subMenuId=id;
	subMenuHeight=document.getElementById(id).firstChild.offsetHeight;
	if(document.getElementById(id).offsetHeight>0){
		direction=-1;
		document.getElementById(id).style.height=subMenuHeight+"px";
	}
	else {
		direction=1;
		document.getElementById(id).style.height="0";
	}
	document.getElementById(id).firstChild.style.position="absolute";
	document.getElementById(id).firstChild.style.bottom="0";
	totalTimeSteps=Math.round(subMenuHeight/15);
	interval1=setInterval("subMenuMove()",50);
	timeStep=0;
	subMenuMove();
}
function subMenuMove(){
	timeStep++;
	if(direction==-1) var h=Math.round(Math.sin(((totalTimeSteps-timeStep)/totalTimeSteps)*(Math.PI/2))*subMenuHeight);
	else var h=Math.round(Math.sin((timeStep/totalTimeSteps)*(Math.PI/2))*subMenuHeight);
	if(timeStep>=totalTimeSteps){
		clearInterval(interval1);
		interval1=null;
	}
	document.getElementById(subMenuId).style.height=h+"px";
}
