function returnFalse() { return false; };
$(document).ready(function(){	
	// +-+-+-+-+-+- LIST PAGE

			$('.textItem').hide();
			$('#item1').slideDown('slow');
			$('#items h3').click(function() {

				if ($(this).next('.textItem:visible').length != 0)
				{
					$(this).next('.textItem').stop().slideUp('slow');
				}			
				else 
				{
					$('.textItem').slideUp('slow');
					$(this).next('.textItem').stop().slideDown('slow');
				}
			});

			$('#items h3').mouseover(function(){
				$(this).stop().fadeTo('fast', 0.9);								  
			});
			
			$('#items h3').mouseout(function(){
				$(this).stop().fadeTo('slow', 1);								  
			});

	// ***** PROMO BOX
	
	$('.promoBox').mouseover(function(){
		$(this).stop().fadeTo('slow', 0.8);								  
	});
	
	$('.promoBox').mouseout(function(){
		$(this).stop().fadeTo('slow', 1);								  
	});


	$('.toFade').bind('mouseenter', function(){
		$(this).fadeTo('normal', 0.8);
	});
	
	$('.toFade').bind('mouseleave', function(){
			$(this).fadeTo('normal', 1);			
	});


	/* -++-+-+-+-+-+-+- CONTACT FORM +-+-+-++-+-+- */
	
	$('#submit .button').bind('click', returnFalse);
	var nom = false;
	var postal = false;
	var emailFrom = false;
	
	$('#txtName').blur(function(){
		if ($('#txtName').val() == '')
		{
			$('#alertName').append('<p class="red">* Veuillez indiquer vos nom et prénom </p>');
			nom = false;
		}
		else {
			$('#alertName').append('<p class="green">* Champ nom et prénom valide </p>');	
			nom = true;
		}		

		if (emailFrom && nom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});


	$('#txtPostal').blur(function(){
		if ($('#txtPostal').val() == '')
		{
			$('#alertPostal').append('<p class="red">* Veuillez indiquer le code postal</p>');	
			postal = false;
		}
		else {
			$('#alertPostal').append('<p class="green">* Champ code postal valide</p>');	
			postal = true;
		}		

		if (emailFrom && nom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});


	var filter=/^.+@.+\..{2,3}$/;
	$('#txtEmailFrom').blur(function(){
		if ($('#txtEmailFrom').val() == '')
		{
			$('#alertEmailFrom').append('<p class="red">* Veuillez indiquer votre email</p>');	
			emailFrom = false;
		}
		else if (filter.test($('#txtEmailFrom').val())) {
			$('#alertEmailFrom').append('<p class="green">*  Champ email complet</p>');	
			emailFrom = true;
		}
		else {
			$('#alertEmailFrom').append('<p class="orange">* Rentrer une adresse email valide svp</p>');	
			emailFrom = false;
		}		
		
		if (emailFrom && nom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});

	$('#txtEmailFrom').focus(function(){
		$('#alertEmailFrom').empty();	
	});	
	
	$('#txtName').focus(function(){
		$('#alertName').empty();	
	});		

	$('#txtPostal').focus(function(){
		$('#alertPostal').empty();	
	});	


	$('#submit .button').click(function(){
		if (emailFrom && nom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	 
	});	
	
	/* -+-+-+-+-+-+-+ FIN CONTACT -+-+-+-+-+-+-+ */	
			

// +-+-+-+-+-+-+-+- GALLERY IMAGE 	
	var currentGalleryImage = $('#imageGalleryImage01');
	var direction = 'next';
	var timerTwo = setInterval (function () {
		if (currentGalleryImage.attr('id') != undefined )
		{
		
		if ((currentGalleryImage.next('.imageGalleryImage').attr('class') == undefined) || ((direction == 'previous') && (currentGalleryImage.prev('.imageGalleryImage').attr('class') != undefined)))
		{
			
			currentGalleryImage = currentGalleryImage.prev('.imageGalleryImage'); 
			currentGalleryImage.show(function(){currentGalleryImage.fadeTo('slow', 1);});
			direction = 'previous';
		}
		else
		{
			currentGalleryImage.fadeTo('slow', 0, function(){/*$(this).hide();*/});
			currentGalleryImage = currentGalleryImage.next('.imageGalleryImage');
			direction = 'next'; 
			
		}	
		
		}
		
	}, 4000 ); 


// ++-+-+-+- HORIZONTAL && VERTICAL BOXES

	$('.boxContainer').mouseover(function(){$(this).stop().fadeTo('fast',0.7)});
	$('.boxContainer').mouseout(function(){$(this).stop().fadeTo('slow',1)});


// ++-+-+-+- MAIN MENU

	// $('.sousMenu').stop().fadeTo(1,0);

	$('.MMlink').mouseover(function(){								  
		id = $(this).attr('id');
		id= id.substring(id.length - 2, id.length);	 
		$('#MMulLink'+id).stop().animate({top: '-5px'},{queue:false, duration:200, easing: 'easeInOutExpo'});
		$('#MMulLink'+id).stop().animate({top: '-5px'},{queue:false, duration:200, easing: 'easeInOutExpo'});				
		//$('#sousMlink'+id).stop().fadeTo('slow',0.7);	// SOUS MENU							
		$(this).attr('src','medias/mainMenu/white.png');
	});
	$('.MMlink').mouseout(function(){								  
		$(this).stop().animate({top: '0px'},{queue:false, duration:200, easing: 'easeInOutExpo'});
		id = $(this).attr('id');
		id= id.substring(id.length - 2, id.length);	 
		$('#MMulLink'+id).stop().animate({top: '0px'},{queue:false, duration:200, easing: 'easeInOutExpo'});				
		//$('#sousMlink'+id).stop().fadeTo('slow',0);	// SOUS MENU							
		$(this).attr('src','medias/mainMenu/white.png');		
	});
	
	$('.MMliLink').mouseover(function(){								  
		id = $(this).attr('id');
		id= id.substring(id.length - 2, id.length);	 
		$('#MMulLink'+id).stop().animate({top: '-5px'},{queue:false, duration:200, easing: 'easeInOutExpo'});
		$('#MMlink'+id).stop().animate({top: '-5px'},{queue:false, duration:200, easing: 'easeInOutExpo'});				
		//$('#sousMlink'+id).stop().fadeTo('slow',0.7);	// SOUS MENU							
	});
	
	$('.MMliLink').mouseout(function(){								  
		id = $(this).attr('id');
		id= id.substring(id.length - 2, id.length);	 
		$('#MMulLink'+id).stop().animate({top: '-0px'},{queue:false, duration:200, easing: 'easeInOutExpo'});
		$('#MMlink'+id).stop().animate({top: '0px'},{queue:false, duration:200, easing: 'easeInOutExpo'});				
		//$('#sousMlink'+id).stop().fadeTo('slow',0);	// SOUS MENU							
	});
	
	$('.MMliLink').mouseenter(function(){
		$('.sousMenu').css('display','none');
	});

	$('.MMliLink').mouseover(function(){								  
		id = $(this).attr('id');
		id= id.substring(id.length - 2, id.length);	 
		$('#sousMlink'+id).css('display','block');
	});
	
	/* $('.sousMenu').mouseleave(function(){								  
		id = $(this).attr('id');
		id= id.substring(id.length - 2, id.length);	 
		$(this).css('display','none');
	}); */
	
	idee=1;
	$('#leftArrow a').click(function(){								  
		
		if (idee > 1)
		{
			idee--;	
			$('#mainTopImage').stop().animate({marginLeft: '+=490px'},{queue:false, duration:1500, easing: 'easeInOutQuint'});	
		}
		//$('#MMlink'+id).children('img').stop().animate({top: '120px'},{queue:false, duration:200, easing: 'easeInOutExpo'});	
		return false;
	});
	$('#rightArrow a').click(function(){								  
		
		if (idee < 3)
		{	
			idee++;
			$('#mainTopImage').stop().animate({marginLeft: '-=490px'},{queue:false, duration:1500, easing: 'easeInOutQuint'});	
		}
		return false;
	});	
	
	

	$('#legende div').fadeTo('fast',0);
	$('#legendeSmall div').fadeTo('fast',0);
	$('#legende01').fadeTo('slow', 1);
	currentTopImage = $('#photoRightTop01');
	direction = 'next';	

	idee=1;	
	recto = true;
	var timerThree = setInterval (function () {		
		if (!recto)
		{
			idee--;	
			$('#mainTopImage').stop().animate({marginLeft: '+=490px'},{queue:false, duration:1500, easing: 'easeInOutQuint'});
			if (idee == 1)
			{
				recto = true;	
			}			
		}
		else
		{	
			idee++;
			$('#mainTopImage').stop().animate({marginLeft: '-=490px'},{queue:false, duration:1500, easing: 'easeInOutQuint'});
			if (idee == 2)
			{
				recto = false;	
			}
		}	

			// DIAPORAMA DROITE
			if (currentTopImage.attr('id') != undefined )
			{		
			//alert('here Index');
			if (currentTopImage.next('.photoRightTop').attr('class') == undefined)
			{
				$('.photoRightTop').fadeTo('fast', 1, function(){$(this).show();});
				$('#legende div').fadeTo('fast',0);
				$('#legendeSmall div').fadeTo('fast',0);
				$('#legende01').fadeTo('slow', 1);
				currentTopImage = $('#photoRightTop01');
				direction = 'next';
			}
			else
			{
	
				currentTopImage.fadeTo(500, 0, function(){$(this).hide();});
				currentTopImage = currentTopImage.next('.photoRightTop');
				id = currentTopImage.attr('id');
				id= id.substring(id.length - 2, id.length);
				$('#legende div').fadeTo('fast', 0);
				$('#legendeSmall div').fadeTo('fast', 0);
				$('#legende'+id).fadeTo('fast', 1);
				direction = 'next'; 
				
				
			}
			}

	}, 4000 );
	
	var positionTopH1 = $('#footer').offset().top - 15;
	$('h1#topH1').css('margin-top', positionTopH1+'px')
	

/*
	ideeNotIndex=1;	
	rectoNotIndex = true;
	var timerThree = setInterval (function () {		
		if (!rectoNotIndex)
		{
			ideeNotIndex--;	
			$('#mainTopImage-notIndex').stop().animate({marginLeft: '+=490px'},{queue:false, duration:1500, easing: 'easeInOutQuint'});
			if (ideeTwo == 1)
			{
				rectoNotIndex = true;	
			}			
		}
		else
		{	
			ideeNotIndex++;
			$('#mainTopImage-notIndex').stop().animate({marginLeft: '-=490px'},{queue:false, duration:1500, easing: 'easeInOutQuint'});
			if (ideeNotIndex == 3)
			{
				rectoNotIndex = false;	
			}
		}	
		
	}, 2000 );

*/

});





