$(function() {
  $('.error1').hide();
  $('.error2').hide();  
  $('input.text-input').css({backgroundColor:"#011D33"});
  $('textarea.text-input').css({backgroundColor:"#011D33"});  
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#011D33"});
  });
  $('textarea.text-input').focus(function(){
    $(this).css({backgroundColor:"#011D33"});
  });  
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#011D33"});
  });
  $('textarea.text-input').blur(function(){
    $(this).css({backgroundColor:"#011D33"});
  });  

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error1').hide();
    $('.error2').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 message = $("textarea#message").val();
		if (message == "") {
      $("label#message_error").show();
      $("textarea#message").focus();
      return false;
    }	

		
		var dataString = '&name=' + name + '&email=' + email + '&message=' + message;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "scripts/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message0'></div>");
        $('#message0').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message0').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});

