// ANIMATION DU BAS DE PAGE

i = 585;
function animfooter() {
 if(i < 670)
 {
  document.getElementById("footer").style.top = i+"px";
  i++; i++;
  window.setTimeout("animfooter()",10);
 }
}



// ANIMATION DES LIENS

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

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

		function fadeBGColMem() {
			if (!this.currentbgRGB) this.currentbgRGB = [53,58,62]; //if no mem is set, set it first;
			doBGFadeMem(this,this.currentbgRGB,[147,21,21],12,20,1);
			}

		function fadeBGColRestore() {
			if (!this.currentbgRGB) return;	//avoid error if mouseout an element occurs before the mouseover
												//(e.g. the pointer already in the object when onload)
			doBGFadeMem(this,this.currentbgRGB,[53,58,62],12,20,1);
			}
	}

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

function doBGFadeMem(elem,startRGB,endRGB,steps,intervals,powr) {
//BG Fader with Memory by www.hesido.com
	if (elem.bgFadeMemInt) window.clearInterval(elem.bgFadeMemInt);
	var actStep = 0;
	elem.bgFadeMemInt = window.setInterval(
		function() {
			elem.currentbgRGB = [
				easeInOut(startRGB[0],endRGB[0],steps,actStep,powr),
				easeInOut(startRGB[1],endRGB[1],steps,actStep,powr),
				easeInOut(startRGB[2],endRGB[2],steps,actStep,powr)
				];
			elem.style.backgroundColor = "rgb("+
				elem.currentbgRGB[0]+","+
				elem.currentbgRGB[1]+","+
				elem.currentbgRGB[2]+")";
			actStep++;
			if (actStep > steps) window.clearInterval(elem.bgFadeMemInt);
		}
		,intervals)
}

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

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)
}



// ANIMATION DU CORPS DE PAGE

position = 0;
anim = 0;

function defile(dir,limit, calque)
{
 if (dir > 0)  // defilement vers le bas
 {
  if(position > limit) {position--;position--;position--;}
 }
 else
 {
  if(position < limit) {position++;position++;position++;}
 }
 document.getElementById(calque).style.top = position+"px";
 anim = window.setTimeout("defile("+dir+","+limit+",'"+calque+"')",5);
}



// MISE A JOUR DES CADEAUX

function updatelist(cadeau, names) 
{
 file('requete.php?update='+cadeau+'&names='+names);
}



// GESTION DES PROCEDURES AJAX

function file(fichier)
{
 if(window.XMLHttpRequest) // FIREFOX
 xhr_object = new XMLHttpRequest();
 else if(window.ActiveXObject) // IE
 xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
 else
 return(false);
 xhr_object.open("GET", fichier, false);
 xhr_object.send(null);
 if(xhr_object.readyState == 4 && xhr_object.responseText != "") alert(xhr_object.responseText);
 else return(false);
}
