/* 



Example Javascript Animation Techniques by Hesido.com;

4 different, reusable examples



*/

if (document.getElementById && document.getElementsByTagName) {

if (window.addEventListener) window.addEventListener('load', initAnims, false);

else if (window.attachEvent) window.attachEvent('onload', initAnims);

}



function initAnims() {



	//	Init fade animation without memory, single direction

		var animElements = document.getElementById("fadercontainer").getElementsByTagName("li");

		for(var i=0; i<animElements.length; i++) {

			animElements[i].onmouseover = fadeBGCol;

			}

			

		function fadeBGCol() {

			doBGFade(this,[153,153,153],[51,51,51],'rgb(102,102,102)',20,20,1);

			}



		

	

			

	

	

	

		

		

	}



//*******************



function doBGFade(elem,startRGB,endRGB,finalColor,steps,intervals,powr) {

//BG Fader by www.hesido.com

	if (elem.bgFadeInt) window.clearInterval(elem.bgFadeInt);

	var actStep = 0;

	elem.bgFadeInt = window.setInterval(

		function() {

			elem.style.backgroundColor = "rgb("+

				easeInOut(startRGB[0],endRGB[0],steps,actStep,powr)+","+

				easeInOut(startRGB[1],endRGB[1],steps,actStep,powr)+","+

				easeInOut(startRGB[2],endRGB[2],steps,actStep,powr)+")";

			actStep++;

			if (actStep > steps) {

			elem.style.backgroundColor = finalColor;

			window.clearInterval(elem.bgFadeInt);

			}

		}

		,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)

}
