/* 

Example Javascript Animation Techniques by Hesido.com;
Modified by Bryan Duran at csswoes.com

*/

window.onload = function()
{
	initAnim();
}

function initAnim() 
{
	//set the id of the element that you want to apply drop down to
	idName = "dropmenu";
    
    //set the tags inside the element that you want to apply drop down to
    tagName = "div";
    
	var drop = document.getElementById(idName).getElementsByTagName(tagName);
	
	var initialHeight = 23; //put the initial height, in pixels, here
	var heights = [70,120]; //put the heights, in pixels, of the drop down menus in the order that they appear on the page
	
	var steps = 10;
	var interval = 10;
	
	for(var i=0; i< drop.length; i++) 
	{
		drop[i].onmouseover = heightChange;
		drop[i].onmouseout = heightRestore;
		drop[i].id = i;
	}
	
	function heightChange() 
	{
		height = heights[this.id];
		
		if (!this.currentHeight) this.currentHeight = initialHeight; //if no mem is set, set it first;
			doHeightChangeMem(this,this.currentHeight,height,steps,interval,0.9);
	}
	
	function heightRestore() 
	{
		if (!this.currentHeight) return;	//avoid error if mouseout an element occurs before the mouseover
													//(e.g. the pointer already in the object when onload)
			doHeightChangeMem(this,this.currentHeight,initialHeight,steps,interval,0.5);
		
	}
}

function doHeightChangeMem(elem,startHeight,endHeight,steps,intervals,powr) 
{
//Width changer with Memory by www.hesido.com
	if (elem.heightChangeMemInt) window.clearInterval(elem.heightChangeMemInt);
	var actStep = 0;
	elem.heightChangeMemInt = window.setInterval(
		function() 
		{
			elem.currentHeight = easeInOut(startHeight,endHeight,steps,actStep,powr);
			elem.style.height = elem.currentHeight+"px";
			actStep++;
			
			if (actStep > steps) 
			{
				window.clearInterval(elem.heightChangeMemInt);
				
				if(endHeight == 0)
					elem.style.display = "none";
			}
		}
		,intervals)
}

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) 
{
//Generic Animation Step Value Generator By www.hesido.com
	var delta = maxValue - minValue;
	var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
	return Math.ceil(stepp)
}