$(function() {
  $('.error').hide();
  $('input#email').css({backgroundColor:"#dae1da"});
  $('input#email').focus(function(){
    $(this).css({backgroundColor:"#c2d3c2"});
  });
  $('input#email').blur(function(){
    $(this).css({backgroundColor:"#dae1da"});
  });

  $(".formbutton").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		

var desabo = document.getElementById('desabo').checked;

		var email = $("input#email").val();
		if (email == "") {
      $("div#email_error").show();
      $("input#email").focus();
      return false;}
	  
	  if ((email.indexOf('@',0)==-1) || (email.indexOf('.',0)==-1)) {
      $("div#email_arobase_error").show();
      $("input#email").focus();
      return false;
	  
    }


		var dataString = 'desabo='+ desabo + '&email=' + email;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "AjaxInputEmail.php",
      data: dataString,
      success: function() {
        $('#newsletter').html("<div id='message'></div>");
        $('#message').html("<h2 style='text-align:center'><img id='checkmark' src='habillage/check.png' /><br />Votre demande a bien &eacute;t&eacute; enregistr&eacute;e</h2>")
        .hide()
        .fadeIn(1500, function() {
          
        });
      }
     });
    return false;
	});
});


