function returnFalse() { return false; };
$(document).ready(function(){	

  $(function() { $(".lavaLamp").lavaLamp({ fx: "easeOutExpo", speed: 700 })});

	// ***** PROMO BOX 1
	$('#promoOne a').children('.legende').slideUp(2, 'easeInExpo');
	
	$('#promoOne').mouseenter(function(){
		$('#promoOne a').children('.legende').slideDown('fast', 'easeOutExpo');							  
	});
	
	$('#promoOne').mouseleave(function(){
		$('#promoOne a').children('.legende').slideUp('fast', 'easeInExpo');							  
	});
	
	// ***** PROMO BOX 3
	$('#promoThree a').children('.legende').slideUp(2, 'easeInExpo');
	
	$('#promoThree').mouseenter(function(){
		$('#promoThree a').children('.legende').slideDown('fast', 'easeOutExpo');							  
	});
	
	$('#promoThree').mouseleave(function(){
		$('#promoThree a').children('.legende').slideUp('fast', 'easeInExpo');							  
	});
	
	// ***** PROMO BOX 2
	$('#promoTwo a').children('.legende').slideUp(2, 'easeInExpo');
	
	$('#promoTwo').mouseenter(function(){
		$('#promoTwo a').children('.legende').slideDown('fast', 'easeOutExpo');							  
	});
	
	$('#promoTwo').mouseleave(function(){
		$('#promoTwo a').children('.legende').slideUp('fast', 'easeInExpo');							  
	});	

	// ***** PROMO BOX 4
	$('#promoFour a').children('.legende').slideUp(2, 'easeInExpo');
	
	$('#promoFour').mouseenter(function(){
		$('#promoFour a').children('.legende').slideDown('fast', 'easeOutExpo');							  
	});
	
	$('#promoFour').mouseleave(function(){
		$('#promoFour a').children('.legende').slideUp('fast', 'easeInExpo');							  
	});	


	/* -++-+-+-+-+-+-+- CONTACT FORM +-+-+-++-+-+- */
	
	$('#submit .button').bind('click', returnFalse);
	var firstName = false;
	var lastName = false;
	var company = false;
	var emailFrom = false;
	
	$('#txtName').blur(function(){
		if ($('#txtName').val() == '')
		{
			$('#alertName').append('<p class="red">* Champ nom requis</p>');
			firstName = false;
		}
		else {
			$('#alertName').append('<p class="green">*  Champ nom complet</p>');	
			firstName = true;
		}		

		if (emailFrom && lastName && firstName && company)
		{
			$('#submit .button').unbind('click', returnFalse);
		}		
	});
	
	
	$('#txtFirstName').blur(function(){
		if ($('#txtName').val() == '')
		{
			$('#alertFirstName').append('<p class="red">* Champ prénom requis </i></p>');
			firstName = false;
		}
		else {
			$('#alertFirstName').append('<p class="green">*  Champ prénom complet</i></p>');	
			firstName = true;
		}		

		if (emailFrom && lastName && firstName && company)
		{
			$('#submit .button').unbind('click', returnFalse);
		}		
	});	

	$('#txtCompany').blur(function(){
		if ($('#txtCompany').val() == '')
		{
			$('#alertCompany').append('<p class="red">* Champ société requis</i></p>');	
			company = false;
		}
		else {
			$('#alertCompany').append('<p class="green">* Champ société complet</i></p>');	
			company = true;
		}		

		if (emailFrom && lastName && firstName && company)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});

	var filter=/^.+@.+\..{2,3}$/;
	$('#txtEmailFrom').blur(function(){
		if ($('#txtEmailFrom').val() == '')
		{
			$('#alertEmailFrom').append('<p class="red">* Champ email requis</p>');	
			emailFrom = false;
		}
		else if (filter.test($('#txtEmailFrom').val())) {
			$('#alertEmailFrom').append('<p class="green">*  Champ email incomplet/ <i>Email completed</i></p>');	
			emailFrom = true;
		}
		else {
			$('#alertEmailFrom').append('<p class="orange">* Rentrer une adresse email valide svp</p>');	
			emailFrom = false;
		}		
		
		if (emailFrom && lastName && firstName && company)
		{
			$('#submit .button').unbind('click', returnFalse);
		
		}	
	});


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

	$('#txtCompany').focus(function(){
		$('#alertCompany').empty();	
	});	
	
	$('#submit .button').click(function(){
	  if (emailFrom && lastName && firstName)
	  {
	 	$('#submit .button').unbind('click', returnFalse);
	  }
	 
	});	
				  

});


