/*Div 1 */
var idDiv1="taxAlert1";
var idContent1 = "mainContent1";
var idMainTitle1 = "titleContainer1";
var widthDiv1;
var heightDiv1;
var marginTopDiv1;
var marginLeftDiv1;
var zIndexDiv1;
var sizeContent1;

/*Div 2 */
var idDiv2="taxAlert2";
var idContent2 = "mainContent2";
var idMainTitle2 = "titleContainer2";
var widthDiv2;
var heightDiv2;
var marginTopDiv2;
var marginLeftDiv2;
var zIndexDiv2;
var sizeContent2;

/*Div 3 */
var idDiv3="taxAlert3";
var idContent3 = "mainContent3";
var idMainTitle3 = "titleContainer3";
var widthDiv3;
var heightDiv3;
var marginTopDiv3;
var marginLeftDiv3;
var zIndexDiv3;
var sizeContent3;

/*Div 4 */
var idDiv4="taxAlert4";
var idContent4 = "mainContent4";
var idMainTitle4 = "titleContainer4";
var widthDiv4;
var heightDiv4;
var marginTopDiv4;
var marginLeftDiv4;
var zIndexDiv4;
var sizeContent4;


/*Div Temp */
var idDivTemp;
var idContentTemp;
var idMainTitleTemp;


var zIndexMax = 4;
var duree = 0.1;

function defilement ( id )
{
	
	
	if ( zIndexMax == $(id).style.zIndex )
		defiler();
	else
	{
		var iMax = parseInt(zIndexMax)- parseInt($(id).style.zIndex);
		
		for ( var i=0; i < iMax; i++ )
		{
			setTimeout ( "defiler()", (i*150));
		}
	}	


}




function defiler ()
{

	var zIndex = parseInt($(idDiv1).style.zIndex);


	/* //On se base par rapport au premier div qui est considere comme le plus gros au chargement de la page */
	switch ( zIndex )
	{/* //Si il est en derniere position */
		case 1:
		
			/*Div 1*/
			$(idDiv1).style.zIndex = this.zIndexDiv3;
			$(idContent1).style.fontSize = this.sizeContent3;
			$(idMainTitle1).style.display = "none";
			new Effect.Morph(idDiv1, {
			  style: 'width:'+this.widthDiv3+'; height:'+this.heightDiv3+'; margin-top:'+this.marginTopDiv3+'; margin-left:'+this.marginLeftDiv3+'; font-size:'+this.sizeContent3+';', 
			  duration: duree });
			
			
			
			/*Div 2*/
			replacerDerniereDiapo ( idDiv2, idContent2, idMainTitle2 );
			
			/*Div 3*/
			$(idMainTitle3).style.display = "block";
			$(idContent3).style.fontSize = this.sizeContent1;
			$(idDiv3).style.zIndex = this.zIndexDiv1;
			new Effect.Morph(idDiv3, {
			  style: 'width:'+this.widthDiv1+'; height:'+this.heightDiv1+'; margin-top:'+this.marginTopDiv1+'; margin-left:'+this.marginLeftDiv1+'; font-size:'+this.sizeContent1+'; ', 
			  duration: duree });
			

			/*Div 4*/
			$(idMainTitle4).style.display = "none";	
			$(idContent4).style.fontSize = this.sizeContent2;
			$(idDiv4).style.zIndex = this.zIndexDiv2;
			new Effect.Morph(idDiv4, {
			  style: 'width:'+this.widthDiv2+'; height:'+this.heightDiv2+'; margin-top:'+this.marginTopDiv2+'; margin-left:'+this.marginLeftDiv2+'; font-size:'+this.sizeContent2+'; ', 
			  duration: duree });
			
			
			
			
			
		break;
		
		/* //Si il est en avant derniere position */
		case 2:
		
			/*Div 1*/
			
			$(idMainTitle1).style.display = "none";
			$(idDiv1).style.zIndex = this.zIndexDiv2;
			$(idContent1).style.fontSize = this.sizeContent2;
			new Effect.Morph(idDiv1, {
			  style: 'width:'+this.widthDiv2+'; height:'+this.heightDiv2+'; margin-top:'+this.marginTopDiv2+'; margin-left:'+this.marginLeftDiv2+'; font-size:'+this.sizeContent2+'; ', 
			  duration: duree });
		
			/*Div 2*/
		
			$(idMainTitle2).style.display = "none";
			$(idDiv2).style.zIndex = this.zIndexDiv3;
			$(idContent2).style.fontSize = this.sizeContent3;
			new Effect.Morph(idDiv2, {
			  style: 'width:'+this.widthDiv3+'; height:'+this.heightDiv3+'; margin-top:'+this.marginTopDiv3+'; margin-left:'+this.marginLeftDiv3+'; font-size:'+this.sizeContent3+'; ', 
			  duration: duree });
			
			/*Div 3*/
		
			replacerDerniereDiapo ( idDiv3, idContent3, idMainTitle3 );
			
			/*Div 4*/
			
			$(idMainTitle4).style.display = "block";
			$(idDiv4).style.zIndex = this.zIndexDiv1;
			$(idContent4).style.fontSize = this.sizeContent1;
			new Effect.Morph(idDiv4, {
			  style: 'width:'+this.widthDiv1+'; height:'+this.heightDiv1+'; margin-top:'+this.marginTopDiv1+'; margin-left:'+this.marginLeftDiv1+'; font-size:'+this.sizeContent1+'; ', 
			  duration: duree });
			

		break;
		
		/* //Si il est en seconde position */
		case 3:
			
			/*Div 1*/
			
			$(idMainTitle1).style.display = "block";
			$(idDiv1).style.zIndex = this.zIndexDiv1;
			$(idContent1).style.fontSize = this.sizeContent1;
			new Effect.Morph(idDiv1, {
			  style: 'width:'+this.widthDiv1+'; height:'+this.heightDiv1+'; margin-top:'+this.marginTopDiv1+'; margin-left:'+this.marginLeftDiv1+'; font-size:'+this.sizeContent1+'; ', 
			  duration: duree });

			
			
			/*Div 2*/
			
			$(idMainTitle2).style.display = "none";
			$(idContent2).style.fontSize = this.sizeContent2;
			$(idDiv2).style.zIndex = this.zIndexDiv2;
			new Effect.Morph(idDiv2, {
			  style: 'width:'+this.widthDiv2+'; height:'+this.heightDiv2+'; margin-top:'+this.marginTopDiv2+'; margin-left:'+this.marginLeftDiv2+'; font-size:'+this.sizeContent2+';', 
			  duration: duree });

			
			
			
			
			/*Div 3*/
		
			$(idMainTitle3).style.display = "none";
			$(idContent3).style.fontSize = this.sizeContent3;
			$(idDiv3).style.zIndex = this.zIndexDiv3;
				new Effect.Morph(idDiv3, {
			  style: 'width:'+this.widthDiv3+'; height:'+this.heightDiv3+'; margin-top:'+this.marginTopDiv3+'; margin-left:'+this.marginLeftDiv3+'; font-size:'+this.sizeContent3+';', 
			  duration: duree });

			
			
			
			/*Div 4*/
			
			replacerDerniereDiapo ( idDiv4, idContent4, idMainTitle4 );

			
			
		
		break;
		
		/* //Si il est en premiere position */
		case 4:
		

			/*Div 1*/
			replacerDerniereDiapo ( idDiv1, idContent1, idMainTitle1 );
			
	
		
			
			
			
			/*Div 2*/
		
			$(idMainTitle2).style.display = "block";
			$(idContent2).style.fontSize = this.sizeContent1;
			$(idDiv2).style.zIndex = this.zIndexDiv1;
			new Effect.Morph(idDiv2, {
			  style: 'width:'+this.widthDiv1+'; height:'+this.heightDiv1+'; margin-top:'+this.marginTopDiv1+'; margin-left:'+this.marginLeftDiv1+'; font-size:'+this.sizeContent1+'; ', 
			  duration: duree });
			
			
			
			/*Div 3*/

			$(idMainTitle3).style.display = "none";
			$(idContent3).style.fontSize = this.sizeContent2;
			$(idDiv3).style.zIndex = this.zIndexDiv2;
			new Effect.Morph(idDiv3, {
			  style: 'width:'+this.widthDiv2+'; height:'+this.heightDiv2+'; margin-top:'+this.marginTopDiv2+'; margin-left:'+this.marginLeftDiv2+'; font-size:'+this.sizeContent2+';', 
			  duration: duree });
			
			
			
			/*Div 4*/

			$(idMainTitle4).style.display = "none";
			$(idContent4).style.fontSize = this.sizeContent3;
			$(idDiv4).style.zIndex = this.zIndexDiv3;
			new Effect.Morph(idDiv4, {
			  style: 'width:'+this.widthDiv3+'; height:'+this.heightDiv3+'; margin-top:'+this.marginTopDiv3+'; margin-left:'+this.marginLeftDiv3+'; font-size:'+this.sizeContent3+';', 
			  duration: duree });
			
			
		
		break;
	
	
	}
	


}

function replacerDerniereDiapo ( id, idContent, idMainTitle )
{
	$(id).style.width = this.widthDiv4;
	$(id).style.height = this.heightDiv4;
	$(id).style.marginTop = this.marginTopDiv4;
	$(id).style.marginLeft = this.marginLeftDiv4;
	$(id).style.zIndex = this.zIndexDiv4;
	$(idContent).style.fontSize = this.sizeContent4;
	$(idMainTitle).style.display = "none";


}

/*On recupere les parameteres de chaque image*/
function getParameters()
{

	/*Div 1*/
	this.widthDiv1 = $(idDiv1).style.width;
	this.heightDiv1 = $(idDiv1).style.height;
	
	if ( $(idDiv1).style.marginTop )
		this.marginTopDiv1 = $(idDiv1).style.marginTop;
	else
		this.marginTopDiv1 = "0px";
	
	if ( $(idDiv1).style.marginLeft )
		this.marginLeftDiv1 = $(idDiv1).style.marginLeft;
	else
		this.marginLeftDiv1 = "0px";
	
	this.zIndexDiv1 = $(idDiv1).style.zIndex;
	this.sizeContent1 = $(idContent1).style.fontSize;
	
	
	
	/*Div 2*/
	this.widthDiv2 = $(idDiv2).style.width;
	this.heightDiv2 = $(idDiv2).style.height;
	
	if ( $(idDiv2).style.marginTop )
		this.marginTopDiv2 = $(idDiv2).style.marginTop;
	else
		this.marginTopDiv2 = "0px";
		
	if ( $(idDiv2).style.marginLeft )		
		this.marginLeftDiv2 = $(idDiv2).style.marginLeft;
	else
		this.marginLeftDiv2 = "0px";
		
	this.zIndexDiv2 = $(idDiv2).style.zIndex;
	this.sizeContent2 = $(idContent2).style.fontSize;

	
	
	/*Div 3*/
	this.widthDiv3 = $(idDiv3).style.width;
	this.heightDiv3 = $(idDiv3).style.height;
	
	if ( $(idDiv3).style.marginTop )
		this.marginTopDiv3 = $(idDiv3).style.marginTop;
	else
		this.marginTopDiv3 = "0px";
		
	if ( $(idDiv3).style.marginLeft )	
		this.marginLeftDiv3 = $(idDiv3).style.marginLeft;
	else
		this.marginLeftDiv3 = "0px";
		
	this.zIndexDiv3 = $(idDiv3).style.zIndex;
	this.sizeContent3 = $(idContent3).style.fontSize;
	
	
	
	/*Div 4*/
	this.widthDiv4 = $(idDiv4).style.width;
	this.heightDiv4 = $(idDiv4).style.height;
	
	if ( $(idDiv4).style.marginTop )	
		this.marginTopDiv4 = $(idDiv4).style.marginTop;
	else
		this.marginTopDiv4 = "0px";
	
	if ( $(idDiv4).style.marginLeft )	
		this.marginLeftDiv4 = $(idDiv4).style.marginLeft;
	else
		this.marginLeftDiv4 = "0px";
		
	this.zIndexDiv4 = $(idDiv4).style.zIndex;
	this.sizeContent4 = $(idContent4).style.fontSize;
	
}


window.onload = getParameters;
