$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#222222"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#351f1f"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#222222"});
  });

  $(".button").click(function() {
    $('.error').hide();
		
	var name = $("input#name").val();
	if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
	var phone = $("input#phone").val();
	if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
	var email = $("input#email").val();
	if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }

	var projet = $("input#projet").val();
	var details = $("input#details").val();

	var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&projet=' + projet + '&details=' + details;
	//alert (dataString);return false;
		
	$.ajax({
      type: "POST",
      url: "form/bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<strong>Votre message a &eacute;t&eacute; envoy&eacute; avec succ&egrave;s !</strong>")
        .append("<p>Nous serons en contact tr&egrave;s prochainement.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img src='images/check.png' />");
        });
      }
     });
    return false;
	});
});
/*runOnLoad(function(){
  $("input#name").select().focus();
});*/

