window.addEvent('domready' , function () {
	
	// Drapeau FR
	if ( $('drpFR') )
	{
		var imageFR = $('drpFR').getElement('img');
		var defautlImgFr = imageFR.src;
		$('drpFR').addEvent('mouseenter' , function () {
			 imageFR.src = 'IMG-love/drapeau-fr-B.png';
		});
		$('drpFR').addEvent('mouseleave' , function () {
			 imageFR.src = defautlImgFr;
		});
	}
	
	// Drapeau EN
	if ( $('drpEN') )
	{
		var imageEN = $('drpEN').getElement('img');
		var defautlImgEn = imageEN.src;
		$('drpEN').addEvent('mouseenter' , function () {
			 imageEN.src = 'IMG-love/drapeau-english-B.png';
		});
		$('drpEN').addEvent('mouseleave' , function () {
			 imageEN.src = defautlImgEn;
		});
	}
	
	// Activeur de sous menu
	var tabMenu = new Array();
	var i = 0;
	$$('div.sousMenuActiveur').each( function (el) {
	
		tabMenu[i] = new Fx.Morph( el.getElement('div div') , {link:'cancel' , duration:'short'});
		el.store('caseTabMenu' , i);
		
		el.addEvent('mouseenter' , function () { 
				var caseTabMenu = el.retrieve('caseTabMenu');
				tabMenu[caseTabMenu].start( {'height':'25px'} );
		});
		el.addEvent('mouseleave' , function () { 
				var caseTabMenu = el.retrieve('caseTabMenu');
				tabMenu[caseTabMenu].start( {'height':'0px'} );
		});
		
		i++;
	});
	
	// Accueil news mouvantes
	if ($('newsMove1'))
	{
			var effet1 = new Fx.Morph( $('newsMove1') , {link:'cancel' , duration:'1500' , transition:'expo:out'});
			var effet2 = new Fx.Morph( $('newsMove2') , {link:'cancel' , duration:'1500' , transition:'expo:out'});
			var effet3 = new Fx.Morph( $('newsMove3') , {link:'cancel' , duration:'1500' , transition:'expo:out'});
		( function () {
			effet1.start( { 'margin-top':'0px' } );
		} ).delay(1000);
		( function () {
			effet2.start( { 'margin-top':'0px' } );
		} ).delay(2000);
		( function () {
			effet3.start( { 'margin-top':'0px' } );
		} ).delay(3000);
		( function () {
			effet1.start( { 'margin-top':'150px' } );
		} ).delay(10000);
		( function () {
			effet2.start( { 'margin-top':'150px' } );
		} ).delay(9000);
		( function () {
			effet3.start( { 'margin-top':'150px' } );
		} ).delay(8000);
		
		$('monter1').addEvent('mouseenter' , function () { effet1.start( { 'margin-top':'0px' } ); });
		$('monter1').addEvent('mouseleave' , function () { effet1.start( { 'margin-top':'150px' } ); });
		$('monter2').addEvent('mouseenter' , function () { effet2.start( { 'margin-top':'0px' } ); });
		$('monter2').addEvent('mouseleave' , function () { effet2.start( { 'margin-top':'150px' } ); });
		$('monter3').addEvent('mouseenter' , function () { effet3.start( { 'margin-top':'0px' } ); });
		$('monter3').addEvent('mouseleave' , function () { effet3.start( { 'margin-top':'150px' } ); });
		$('monter21').addEvent('mouseenter' , function () { effet1.start( { 'margin-top':'0px' } ); });
		$('monter21').addEvent('mouseleave' , function () { effet1.start( { 'margin-top':'150px' } ); });
		$('monter22').addEvent('mouseenter' , function () { effet2.start( { 'margin-top':'0px' } ); });
		$('monter22').addEvent('mouseleave' , function () { effet2.start( { 'margin-top':'150px' } ); });
		$('monter23').addEvent('mouseenter' , function () { effet3.start( { 'margin-top':'0px' } ); });
		$('monter23').addEvent('mouseleave' , function () { effet3.start( { 'margin-top':'150px' } ); });
	}
	
	// opacité titre news accueil
	if ($('titreNewsBas'))
	{
		$('titreNewsBas').setStyle('opacity' , '0.8');
	}
	
	// Diaporama
	if ( $('diaporama-js') )
	{
		var FxAcc = new Fx.Morph( $('premierSlide') , {link:'chain'} );
		var minMarg = 0;
		var position = 0;
		$$('div.slider').each( function (el) { minMarg += 950; } );
		minMarg = (minMarg-950) * -1;
		
		$('activites-suivant-a').addEvents({
											'mouseenter' : function () {
												if (parseInt(position) > minMarg)
												{
													position = position - 950;
													var newMarg = position;
													FxAcc.start( {'margin-left':newMarg} );
												}
												else
												{
													position = 0;
													var newMarg = position;
													FxAcc.start( {'margin-left':newMarg} );
												}
												return false;									  
											},
											'click' : function () {
												if (parseInt(position) > minMarg)
												{
													position = position - 950;
													var newMarg = position;
													FxAcc.start( {'margin-left':newMarg} );
												}
												else
												{
													position = 0;
													var newMarg = position;
													FxAcc.start( {'margin-left':newMarg} );
												}
												return false;									  
											}
		});
		$('activites-precedent-a').addEvents({
										   'mouseenter' : function () {  
												if (parseInt(position) != 0)
												{
													position = position + 950;
													var newMarg = position;
													FxAcc.start( {'margin-left':newMarg} );
												}
												return false;										  
											},
										   'click' : function () {  
												if (parseInt(position) != 0)
												{
													position = position + 950;
													var newMarg = position;
													FxAcc.start( {'margin-left':newMarg} );
												}
												return false;										  
											}
		});
		
	}
	
});
