$(function() {
  $('.error').hide();
 
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  
  
  $('.textarea-input').css({backgroundColor:"#FFFFFF"});
  $('.textarea-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('.textarea-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  
  $(".button").click(function() {
	$('.error').hide();
	$('#submit_btn').attr("value", "Sending..."); 
	$('#submit_btn').attr("disabled", true); 

	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;
	}
	
	var phone = $("input#phone").val();
	if (phone == "") {
		$("label#phone_error").show();
		$("input#phone").focus();
		return false;
	}

	var enquiry = $("#enquiry").val();

	var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&enquiry=' + enquiry;
	//alert (dataString);return false;
		
	$.ajax({
		type: "POST",
		url: "/include/scripts/process.php?" + dataString,
		data: dataString,
		success: function() {
			$('#contact_form').html("<div id='message' style='height:240px;'></div>");
			$('#message').html("<h2>Your Enquiry was submitted successfully!</h2>")
				.append("<p>I will be in touch within the next 24 hours.</p>")
				.hide()
				.fadeIn(800, function() {
					$('#message').append("<div id='checkmark'>&nbsp;</div>");
				});
			}
		});
		return false;
	});
});
 
runOnLoad(function(){
  $("input#name").select().focus();
});