$(function() {
  $('.error').hide();
  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		
		var dataString = '&email=' + email;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "process.php",
      data: dataString,
      success: function() {
        $('#newsForm').html("<div id='message'></div>");
        $('#message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(600, function() {
          $('#message').append("<img id='checkmark' width='21' height='21' src='imgs/check.png' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#email").select().focus();
});
