$(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"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var first_name = $("input#first_name").val();
		if (first_name == "") {
      $("label#first_name_error").show();
      $("input#first_name").focus();
      return false;
    }
		var last_name = $("input#last_name").val();
		if (last_name == "") {
      $("label#last_name_error").show();
      $("input#last_name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		
		var dataString = 'first_name='+ first_name + '&last_name=' + last_name + '&email=' + email;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "../../temp/bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Your reservations have been submitted!</h2>")
        .append("<p>Looking forward to seeing you.</p><p>Please stay tuned for further information.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='../../temp/images/check.png' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#first_name").select().focus();
});
