
/********************************************************************************************************************************************************
	ANIMATION
*********************************************************************************************************************************************************/

function playShadowStart() {

	new Fx.Morph('playShadow', {duration: 0}).start({'opacity': 0});
	
	(function wait() {
	
		$('playShadow').style.display = 'inline';
	
	}).delay(100);

}

function playShadow(d) {
	
	if(d == 1) {
	
		new Fx.Morph('playShadow', {duration: 250}).start({'opacity': 1});
	
	} else {
	
		new Fx.Morph('playShadow', {duration: 150}).start({'opacity': 0});
	
	}

}

function playAnim() {
	
	new Fx.Morph('slogan', {duration: 350}).start({'opacity': [1,0]});
	
	new Fx.Morph('iconsContainerBG', {duration: 350}).start({'opacity': [1,0]});
	
	new Fx.Morph('bigBloc1', {duration: 350}).start({'opacity': [1,0]});
	
	new Fx.Morph('bigBloc2', {duration: 350}).start({'opacity': [1,0]});
	
	/* ------------ */
	
	$('flashBGContainer2').style.display = 'inline';
	
	$('flashBloc2').style.display = 'inline';
	
	new Fx.Morph('flashBloc1', {duration: 0}).start({'opacity': 0});
	
	new Fx.Morph('flashBloc2', {duration: 0}).start({'opacity': 0});
	
	(function wait() {
	
		new Fx.Morph('flashBloc1', {duration: 350}).start({'opacity': 1, 'margin-top': '0px'});
		
		(function wait() {
		
			new Fx.Morph('flashBloc2', {duration: 350}).start({'opacity': 1, 'margin-top': '-62px'});
		
		}).delay(300);
		
		(function wait() {
		
			$('flashLoader').style.display = 'none';
			
			new Request({
			url: 'homeFlash.php', 
			onComplete: function(response) {
			    	
			    	$('iFrameContainer').set('html', response);
			    
			}}).send();
						
		}).delay(1200);
	
	}).delay(100);

}

function replayAnim() {
	
	$('iFrameContainer').empty();
	
	$('iFrameContainer').set('html','<div id="flashLoader"></div>');
	
	(function wait() {
	
			$('flashLoader').style.display = 'none';
			
			new Request({
			url: 'homeFlash.php', 
			onComplete: function(response) {
			    	
			    	$('iFrameContainer').set('html', response);
			    
			}}).send();
	
	}).delay(1000);

}				

function closeAnim() {

	new Fx.Morph('slogan', {duration: 350}).start({'opacity': 1});
	
	new Fx.Morph('iconsContainerBG', {duration: 350}).start({'opacity': 1});
	
	new Fx.Morph('bigBloc1', {duration: 350}).start({'opacity': 1});
	
	new Fx.Morph('bigBloc2', {duration: 350}).start({'opacity': 1});
	
	/* ------------ */
	
	$('iFrameContainer').empty();
	
	$('iFrameContainer').set('html','<div id="flashLoader"></div>');
	
	new Fx.Morph('flashBloc2', {duration: 350}).start({'opacity': 0, 'margin-top': '-120px'});
	
	(function wait() {
	
		new Fx.Morph('flashBloc1', {duration: 350}).start({'opacity': 0, 'margin-top': '-425px'});
	
	}).delay(300);
	
	(function wait() {
	
		$('flashBGContainer2').style.display = 'none';
	
	}).delay(650);

}

/********************************************************************************************************************************************************
	NEWS
*********************************************************************************************************************************************************/

stopNews = 0;

function news(i) {
	
	if(stopNews == 0) {
	
		var step = i * 18;
		
		var step2 = i * 330;
		
		moveItemX($('newsBan'),step,500);
		
		moveItemX($('newsMove'),-step2,500);
		
		new Fx.Morph('newsBanShadow', {duration: 1000}).start({'opacity': [1,0], 'margin-left': ''+step+'px'});
		
		var n = parseFloat(i)+1;
		
		$('newsNumber').set('text',n);
	
	}
	
}

function news2(i) {
	
	var step = i * 18;
		
	var step2 = i * 330;
		
	moveItemX($('newsBan'),step,500);
		
	moveItemX($('newsMove'),-step2,500);
		
	new Fx.Morph('newsBanShadow', {duration: 1000}).start({'opacity': [1,0], 'margin-left': ''+step+'px'});
		
	var n = parseFloat(i)+1;
		
	$('newsNumber').set('text',n);
	
}

function newsStart() {
	
	var nb = $('nbNews').value;
	
	var n = 8000;
		
	for(i=0;i<=nb;i++) {
	    	
	    var t = i*n;
	    	
	    if(i < nb) {
	    
	    	setTimeout('news('+i+')',t);
	    
	    } 
	    
	    if(i == nb) {
	     	
	    	setTimeout('newsStart()',t);
	    
	    }
	
	}

}

function newsMove(i) {
	
	if(stopNews == 0) {
	
		var step = i * 18;
	
		moveItemX($('newsBan'),step,500);
	
	}

}

function newsStop() {

	stopNews = 1;

}

function newsShow(id,img) {
	
	new Fx.Morph('slogan', {duration: 350}).start({'opacity': [1,0]});
	
	new Fx.Morph('iconsContainerBG', {duration: 350}).start({'opacity': [1,0]});
	
	new Fx.Morph('bigBloc1', {duration: 350}).start({'opacity': [1,0]});
	
	/* ------------- */
	
	if(img == 1) {
		
		new Fx.Morph('newsAjaxZone', {duration: 0}).start({'width': '623px','margin-left': '-249px'});
		
		newsIMG = 1;
	
	} else {
	
		new Fx.Morph('newsAjaxZone', {duration: 0}).start({'width': '742px','margin-left': '-368px'});
		
		newsIMG = 0;

	}
	
	newsCloseID = id;
	
	newsStop();
	
	/* ------------- */
	
	$('newsContent'+id).style.display = 'none';
	
	$('newsAjax'+id).style.display = 'inline';
	
	$('newsAjax'+id).set('html','<img src="images/ajaxLoader.gif" alt="ajaxLoader" width="32" height="29" style="margin-left:50px; margin-top:40px;"/>');
	
	new Fx.Morph('newsStep', {duration: 350}).start({'opacity': [1,0]});

	new Fx.Morph('newsBullContainer', {duration: 350}).start({'opacity': [1,0]});
	
	new Fx.Morph('newsAjaxZone', {duration: 350}).start({'opacity': 0});
	
	/* ------------- */
	
	$('newsCloseButton').style.display = 'inline';
	
	new Fx.Morph('newsZoneContainer', {duration: 350}).start({'margin-top': '0px'});
	
	new Fx.Morph('bContainer', {duration: 350}).start({'margin-left': '-409px','margin-top': '-185px'});
	
	new Fx.Morph('bMove', {duration: 350}).start({'width': '739px','height': '383'});
	
			new Request({
			url: 'newsAjax.php?id='+id+'', 
			evalScripts: true,
			onComplete: function(response) {
			    
			        $('newsAjaxZone').set('html', response);
			    
			}}).send();
			
	(function wait() {
	
		$('newsAjax'+id).empty();
		
		$('newsAjax'+id).style.display = 'none';
		
		$('newsAjaxZone').style.display = 'inline';
		
		new Fx.Morph('newsAjaxZone', {duration: 500}).start({'opacity': 1});
	
	}).delay(750);

}

function newsClose() {
	
	new Fx.Morph('slogan', {duration: 350}).start({'opacity': 1});
	
	new Fx.Morph('iconsContainerBG', {duration: 350}).start({'opacity': 1});
	
	new Fx.Morph('bigBloc1', {duration: 350}).start({'opacity': 1});
	
	/* ------------- */
	
	$('newsCloseButton').style.display = 'none';
	
	$('newsAjaxZone').empty();
		
	$('newsAjaxZone').style.display = 'none';
	
	$('newsAjax'+newsCloseID).style.display = 'inline';
	
	$('newsAjax'+newsCloseID).set('html','<img src="images/ajaxLoader.gif" alt="ajaxLoader" width="32" height="29" style="margin-left:50px; margin-top:40px;"/>');
	
	new Fx.Morph('newsZoneContainer', {duration: 350}).start({'margin-top': '22px'});
	
	new Fx.Morph('bContainer', {duration: 350}).start({'margin-left': '0px','margin-top': '0px'});
	
	new Fx.Morph('bMove', {duration: 350}).start({'width': '330px','height': '198'});
	
	new Fx.Morph('newsStep', {duration: 350}).start({'opacity': 1});

	new Fx.Morph('newsBullContainer', {duration: 350}).start({'opacity': 1});
	
	new Fx.Morph('newsContent'+newsCloseID, {duration: 0}).start({'opacity': 0});
	
	(function wait() {
		
		$('newsAjax'+newsCloseID).empty();
		
		$('newsAjax'+newsCloseID).style.display = 'none';
		
		$('newsContent'+newsCloseID).style.display = 'inline';
		
		new Fx.Morph('newsContent'+newsCloseID, {duration: 350}).start({'opacity': 1});
	
	}).delay(650);
	
}

/********************************************************************************************************************************************************
	Exemples
*********************************************************************************************************************************************************/
	
stopExemples = 0;
	
function exemples() {
	
	if(stopExemples == 0) {
	
		activeExemples = 0;
		
		moveItemX($('mediumBlocIconsMove'),0,500);
		
		moveItemX($('mediumBlocExTitleMove'),0,500);
		
		$('arrowGreenLeft1').style.backgroundImage = 'url(images/arrowGreenLeft2.png)';
		
		$('arrowGreenRight1').style.backgroundImage = 'url(images/arrowGreenRight1.png)';
		
		var nb = $('nbIconsExemples').value;
		
		max = nb-1;
		
		var n = 5000;
		
		for(i=0;i<nb;i++) {
				
				var t = (i*n)+n;
				
			if(i < nb-1) {
			
				setTimeout('exemplesMove('+i+')',t);
			
			} else {
			
				setTimeout('exemples()',t);
			
			}
		
		}
	
	}

}

function exemplesMove(i) {
	
	if(stopExemples == 0) {
		
		activeExemples = parseFloat(i)+1;
		
		var step = (i*40)+40;
		
		moveItemX($('mediumBlocIconsMove'),-step,500);
		
		var step2 = (i*220)+220;
			
		(function wait() {
		
			moveItemX($('mediumBlocExTitleMove'),-step2,500);
		
		}).delay(150);
		
		if(activeExemples > 0) {
		
			$('arrowGreenLeft1').style.backgroundImage = 'url(images/arrowGreenLeft1.png)';
		
		} else {
		
			$('arrowGreenLeft1').style.backgroundImage = 'url(images/arrowGreenLeft2.png)';
		
		}
		
		if(activeExemples < max) {
		
			$('arrowGreenRight1').style.backgroundImage = 'url(images/arrowGreenRight1.png)';
		
		} else {
		
			$('arrowGreenRight1').style.backgroundImage = 'url(images/arrowGreenRight2.png)';
		
		}
	
	}

}

function arrows(d) {
	
	stopExemples = 1;
	
	if(d == 'L') {
		
		if(activeExemples > 0) {
		
			var step = (activeExemples-1)*40;
			
			var step2 = (activeExemples-1)*220;
			
			moveItemX($('mediumBlocIconsMove'),-step,500);
			
			moveItemX($('mediumBlocExTitleMove'),-step2,500);
			
			activeExemples = activeExemples-1;
		
		}
		
		if(activeExemples < max) {
		
			$('arrowGreenRight1').style.backgroundImage = 'url(images/arrowGreenRight1.png)';
		
		}
		
		if(activeExemples == 0) {
		
			$('arrowGreenLeft1').style.backgroundImage = 'url(images/arrowGreenLeft2.png)';
		
		}
		
	}
	
	if(d == 'R') {
		
		if(activeExemples < max) {
		
			var step = (parseFloat(activeExemples)+1)*40;
			
			var step2 = (parseFloat(activeExemples)+1)*220;
			
			moveItemX($('mediumBlocIconsMove'),-step,500);
			
			moveItemX($('mediumBlocExTitleMove'),-step2,500);
			
			activeExemples = parseFloat(activeExemples)+1;
			
		}
		
		if(activeExemples == max) {
		
			$('arrowGreenRight1').style.backgroundImage = 'url(images/arrowGreenRight2.png)';
		
		}
		
		if(activeExemples > 0) {
		
			$('arrowGreenLeft1').style.backgroundImage = 'url(images/arrowGreenLeft1.png)';
		
		}
		
	}

}


