$(function() {
  $('.error').hide();
  $('.text-input').css({backgroundColor:"#FFFFFF"});
  /* $('.text-input').focus(function(){
    $(this).css({backgroundColor:"#ee4036"});
  }); */
  $('.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
			
	var name = $("input#name").val();
	if (name == "") {
    	$("label#name_error").show();
      	$("input#name").focus();
      	return false;
    }
	var email = $("input#email").val();
	if (email == "") {
      	$("label#email_error").show();
      	$("input#email").focus();
      	return false;
    }
		
	  $('#contact_form').html("<div id='sending'><img src='images/ajax-loader.gif' alt='Envoi en cours' /><h3>Envoi en cours...</h3></div>");
		
	  var dataString = 'name='+ name + '&email=' + email;
	  //alert (dataString);return false;
		
	  $.ajax({
      type: "POST",
      url: "includes/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Votre message a &eacute;t&eacute; envoy&eacute;!</h2>")
        .append("<br />")
        .hide()
		.fadeIn(1500, function() {
          $('#message').append("<br />");
        });
      }
     });
    return false;
	});
});
/* runOnLoad(function(){
  $("input#name").select().focus();
}); */
