$(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").css({backgroundColor:"#ee4036"});
      	$("input#name").focus();
      	return false;
    }
	var email = $("input#email").val();
	if (email == "") {
      	$("label#email_error").show();
		$("input#email").css({backgroundColor:"#ee4036"});
      	$("input#email").focus();
      	return false;
    }
	var email_body = $("#email_body").val();
	if (email_body == "") {
      	$("label#email_body_error").show();
		$("#email_body").css({backgroundColor:"#ee4036"});
      	$("#email_body").focus();
      	return false;
    }
		
	  $('#contact_form').html("<div id='sending'><img src='http://www.tratoz.com/Include/contact/images/ajax-loader.gif' alt='Sending' /><h3>Sending...</h3></div>");
		
	  var dataString = 'name='+ name + '&email=' + email + '&email_body=' + email_body;
	  //alert (dataString);return false;
		
	  $.ajax({
      type: "POST",
      url: "Include/contact/includes/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<div id=\"ConfirmationCont\"><strong>Your message have been sent.</strong></div>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<br />");
        });
      }
     });
    return false;
	});
});
/* runOnLoad(function(){
  $("input#name").select().focus();
}); */
