// JavaScript Document

//Création du Prototype pour lanimation des menu, section Folio

//init Variable

actif = "aucun";
onwait = "aucun";
actif2 = "aucun"
running = "no";






function checkForResize(id,id2,height){
checkHeight = document.getElementById(id2).offsetHeight;


if (checkHeight < height){
maxheight = checkHeight;
}
else{
maxheight = height;
}
if(actif.id !== id){
		if(actif !== "aucun"){
			if (actif2 !== "aucun"){
				actif2 = "aucun"	
				}
			if (actif2 !== "aucun"){
				actif2 = "aucun"	
				}
	
		onWaitId = document.getElementById(id);
		if( running == "no"){
		running == "yes"
		getForResize(actif,'reduce')
		}
		}
		else{
			if (actif2 !== "aucun"){
				actif2 = "aucun"	
			}
		if( running == "no"){
		running == "yes"
		getForResize(id,'enlarge')
		}
		}
		if(actif == "aucun"){
			
		}
	}
	
}



function getForResize(id,operand){
	if(operand !== 'reduce'){
	monDiv = document.getElementById(id);
	currentHeight = monDiv.offsetHeight;
	animEnlarge();
	}
	else{
	monDiv = id;
	currentHeight = monDiv.offsetHeight;
	animReduce();
	}
}




function animEnlarge(){
	if (currentHeight < maxheight){
		
		monDiv.style.height =currentHeight+10+"px"
		currentHeight = monDiv.offsetHeight;
		window.setTimeout("animEnlarge()",5);
	}
	else{
	running == "no"
	actif =  monDiv
	}
}

function animReduce(){
	if (currentHeight > 0){
		monDiv.style.height =currentHeight-10+"px"
		currentHeight = monDiv.offsetHeight;
		window.setTimeout("animReduce()",5);
	}
	else{
	running == "no"
	//alert(actif.id)	
	//alert(onWaitId.id)
	monDiv = onWaitId
	animEnlarge()
	
	
	
	}
}



function animReduce2(){
	if (currentHeight > 0){
		monDiv.style.height =currentHeight-10+"px"
		currentHeight = monDiv.offsetHeight;
		window.setTimeout("animReduce2()",5);
	}
	else{
	running == "no"
	//alert(actif.id)	
	//alert(onWaitId.id)
	actif = "aucun";
	
	
	
	
	}
}













