$(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"});
  });

  $("#sendenquiry").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;
    }
		var phone = $("input#phone_number").val();
		if (phone == "") {
      $("label#phone_number_error").show();
      $("input#phone_number").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&phone_number=' + phone + '&message=' + $("#enquiry").val(); ;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "/index.php?mode=send_enquiry&go=true",
      data: dataString,
      success: function() {
        $('#formContainer').html("<h3>Thank you!</h3>")
        .append("<p>We will answer soon.</p>");
      }
     });
    return false;
	});
});

