var scrollSpeed = 10;
var scrollSteps = 10;
function initAnimatedMenu(menuID){
		//alert("init: " + menuID.id + ", H:" + parseInt(menuID.offsetHeight));
		menuID.value = parseInt(menuID.offsetHeight);
		//menuID.style.height = 1;
		return ;
	}

  function collapseMenu(menuID){
	  menuID.style.height = 1;
	//var h;
	//h = parseInt(menuID.style.height.replace(/px/i,""));
	//if(h > 1){
	//	menuID.style.height = (h-scrollSteps);
	//	window.setTimeout("collapseMenu(" + menuID.id + ");", scrollSpeed);
	//	}
	}

//  function expandMenu(menuID){
// 	menuID.style.height = menuID.value;
//	//var h;
//	//h = parseInt(menuID.style.height.replace(/px/i,""));
//	//alert("Expand Menu ID:" + menuID.id + ", H:" + h);
//	//if(h < menuID.value ){
//	//	menuID.style.height = h + scrollSteps;
//	//	window.setTimeout("expandMenu(" + menuID.id + ");", scrollSpeed);
//	//	}
//	}

  function expandMenu(menuID){
  	// Open it all at once
  	//menuID.style.height = menuID.value;
	
	// Open it gradually
	//var h;
	//h = parseInt(menuID.style.height.replace(/px/i,""));
	//alert("Expand Menu ID:" + menuID.id + ", H:" + h);
	//if(h < menuID.value ){
	//	menuID.style.height = h + scrollSteps;
	//	window.setTimeout("expandMenu(" + menuID.id + ");", scrollSpeed);
	//	}
	
	// Open it gradually with weight
	var h;
	h = parseInt(menuID.style.height.replace(/px/i,""));
	//alert("Expand Menu ID:" + menuID.id + ", H:" + h);
	// Expand incrementally while the current height is less than 90% of the total height
	if(h < (menuID.value * 0.9) ){
		menuID.style.height = (menuID.value - h) / 2 + h;
		window.setTimeout("expandMenu(" + menuID.id + ");", scrollSpeed);
	}else{ // If it crossed the 90% boundry then open it totally
		menuID.style.height = menuID.value;
	}
}

function toggleMenu(menuID){
	//alert("toggle: " + menuID.id + ", H:" + parseInt(menuID.style.height));
	if(parseInt(menuID.style.height.replace(/px/i,"")) > 1){
		collapseMenu(menuID);
	}else{
		//for(i=0;i<listMenus.length;i++){
		//	collapseMenu(listMenus[i]);
		//}
		expandMenu(menuID);
	}
}