function getAbsoluteLeft(objectId) {
	o = document.getElementById("m"+objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	return oLeft
}


var cacher = 0;

function hidemenu(men)
{
 cacher = setTimeout("propRestore2('"+men+"')",500);
}

if (document.getElementById && document.getElementsByTagName) {
if (window.addEventListener) window.addEventListener('load', initAnims, false);
else if (window.attachEvent) window.attachEvent('onload', initAnims);
}

	//	Hauteur des menus horizontaux

		function propChange2(lay) {
			lg = lay.substr(1,1);
			lg++;
			if(document.getElementById("m"+lg))
		    {
			 gauche = getAbsoluteLeft(lg);
			 gauche -= 180;
			}
			else
			{
			 gauche = getAbsoluteLeft("aster");
			 gauche += 820;
			}
			lay = document.getElementById("sub"+lay);
			if(lay) {
			if (!lay.currentProp) lay.currentProp = 0; //if no mem is set, set it first;
			lay.style.left = gauche+"px";
			doChangeMem(lay,lay.currentProp,200,50,30,0.5,"height");
			}}

		function propRestore2(lay) {
			lay = document.getElementById("sub"+lay);
			if(lay) {
			if (!lay.currentProp) return;	//avoid error if mouseout an element occurs before the mouseover
											//(e.g. the pointer already in the object when onload)
			doChangeMem(lay,lay.currentProp,0,10,10,0.5,"height");
			}}
			
			
function initAnims() {

	//	Couleur de fond des menus de gauche
		var animElements = document.getElementById("header").getElementsByTagName("a");
		for(var i=0; i<animElements.length; i++) {
			if(animElements[i].className != "ok")
			{
			 animElements[i].onmouseover = fadeBGColMem;
			 animElements[i].onmouseout = fadeBGColRestore;
			}
			}

		function fadeBGColMem() {
			clearTimeout(cacher);
			for(i=0;i<10;i++)
			{
			 propRestore2("m"+i);
			}
			propChange2(this.id);
			}

		function fadeBGColRestore() {
			cacher = setTimeout('propRestore2("'+this.id+'")',500);
			}
	}

//*******************

function doChangeMem(elem,start,end,steps,intervals,powr,prop) {
	if (elem.propChangeMemInt) window.clearInterval(elem.propChangeMemInt);
	var actStep = 0;
	elem.propChangeMemInt = window.setInterval(
		function() {
			elem.currentProp = easeInOut(start,end,steps,actStep,powr);
			eval("elem.style."+prop+" = elem.currentProp+'px'");
			actStep++;
			if (actStep > steps) window.clearInterval(elem.propChangeMemInt);
		}
		,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)
}
