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 lastname = false;
	var phone = false;
	var email = false;
	
	
	$('#txtfirstname').blur(function(){
		if ($('#txtfirstname').val() == '')
		{
			$('#alertfirstname').append('<p class="red">* merci de préciser votre prénom</p>');
			firstname = false;
		}
		else {
			$('#alertfirstname').append('<p class="green">*  OK</p>');	
			firstname = true;
		}		

		if (firstname && lastname && address1 && postcode && city && phone && email)
		{
			$('#submit .button').unbind('click', returnFalse);
		}		
	});	


	$('#txtlastname').blur(function(){
		if ($('#txtlastname').val() == '')
		{
			$('#alertlastname').append('<p class="red">* merci de préciser votre nom</p>');
			lastname = false;
		}
		else {
			$('#alertlastname').append('<p class="green">*  OK</p>');	
			lastname = true;
		}		

		if (firstname && lastname && address1 && postcode && city && phone && email)
		{
			$('#submit .button').unbind('click', returnFalse);
		}		
	});
	

	$('#txtaddress1').blur(function(){
		if ($('#txtaddress1').val() == '')
		{
			$('#alertaddress1').append('<p class="red">* merci de préciser votre adresse</p>');	
			address1 = false;
		}
		else {
			$('#alertaddress1').append('<p class="green">* OK</p>');	
			address1 = true;
		}		

		if (firstname && lastname && address1 && postcode && city && phone && email)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});


	$('#txtpostcode').blur(function(){
		if ($('#txtpostcode').val() == '')
		{
			$('#alertpostcode').append('<p class="red">* merci de préciser votre code postal</p>');	
			postcode = false;
		}
		else {
			$('#alertpostcode').append('<p class="green">* OK</p>');	
			postcode = true;
		}		

		if (firstname && lastname && address1 && postcode && city && phone && email)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});


	$('#txtcity').blur(function(){
		if ($('#txtcity').val() == '')
		{
			$('#alertcity').append('<p class="red">* merci de préciser votre ville</p>');	
			city = false;
		}
		else {
			$('#alertcity').append('<p class="green">* OK</p>');	
			city = true;
		}		

		if (firstname && lastname && address1 && postcode && city && phone && email)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});


	$('#txtphone').blur(function(){
		if ($('#txtphone').val() == '')
		{
			$('#alertphone').append('<p class="red">* merci de préciser votre téléphone</p>');	
			phone = false;
		}
		else {
			$('#alertphone').append('<p class="green">* OK</p>');	
			phone = true;
		}		

		if (firstname && lastname && address1 && postcode && city && phone && email)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});





	var filter=/^.+@.+\..{2,3}$/;
	$('#txtemail').blur(function(){
		if ($('#txtemail').val() == '')
		{
			$('#alertemail').append('<p class="red">* merci de préciser votre e-mail</p>');	
			email = false;
		}
		else if (filter.test($('#txtemail').val())) {
			$('#alertemail').append('<p class="green">*  OK</p>');	
			email = true;
		}
		else {
			$('#alertemail').append('<p class="orange">* merci de saisir une adresse e-mail valide</p>');	
			emailfrom = false;
		}		
		
		if (firstname && lastname && address1 && postcode && city && phone && email)
		{
			$('#submit .button').unbind('click', returnFalse);
		
		}	
	});


	$('#txtfirstname').focus(function(){
		$('#alertfirstname').empty();	
	});		

	$('#txtlastname').focus(function(){
		$('#alertlastname').empty();	
	});	
	
	$('#txtaddress1').focus(function(){
		$('#alertaddress1').empty();	
	});		

	$('#txtpostcode').focus(function(){
		$('#alertpostcode').empty();	
	});		

	$('#txtcity').focus(function(){
		$('#alertcity').empty();	
	});		

	$('#txtphone').focus(function(){
		$('#alertphone').empty();	
	});		

	$('#txtemail').focus(function(){
		$('#alertemail').empty();	
	});	

	$('#submit .button').click(function(){
	  if (firstname && lastname && address1 && postcode && city && phone && email)
	  {
	 	$('#submit .button').unbind('click', returnFalse);
	  }
	 
	});	
				  

});


