$(function() {
  $('.error').hide();

  $("#submit").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  	var name = $("#name").val();
		if (name == "") {
	  $("label#nameError").show();
	  $("#name").focus();
	  return false;
	}
		var phone = $("#phone").val();
		if (phone == "") {
	  $("label#phoneError").show();
	  $("#phone").focus();
	  return false;
	}
		var email = $("#email").val();
		if (email == "") {
      $("label#emailError").show();
      $("#email").focus();
      return false;
    }
		var person = $("#person").val();
		if (person == "") {
      $("label#personError").show();
      $("#person").focus();
      return false;
    }
		var message = $("#message").val();
		if (message == "") {
      $("label#messageError").show();
      $("#message").focus();
      return false;
    }
	  	var name = $("#name").val();
		if (name == "Name") {
	  $("label#nameError").show();
	  $("#name").focus();
	  return false;
	}
		var phone = $("#phone").val();
		if (phone == "Phone") {
	  $("label#phoneError").show();
	  $("#phone").focus();
	  return false;
	}
		var email = $("#email").val();
		if (email == "Email") {
      $("label#emailError").show();
      $("#email").focus();
      return false;
    }
		var Person = $("#person").val();
		if (person == "Person") {
      $("label#personError").show();
      $("#person").focus();
      return false;
    }
		var message = $("#message").val();
		if (message == "Message") {
      $("label#messageError").show();
      $("#message").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&phone=' + phone + '&email=' + email + '&person=' + person + '&message=' + message;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "http://lakesidetitle.com/php/process.php",
      data: dataString,
      success: function() {
		$('#contact-form fieldset').fadeOut(1000, function() {  // when submit is clicked, fadeout form's fields
			$('#success').fadeIn(2000);
		});
      }
     });
    return false;
	});
});
