//JQUERY FORM
$(document).ready(function() { 
// bind 'myForm' and provide a simple callback function 
	$('#contact').ajaxForm({
		target: "#contact_form", //div we output message to	

        // 'success' identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
		success: function() { 
			$('#contact').slideUp();
			$('#contact_form').css('border','none');
	    	$('#success').fadeIn();
		}
    }); 
}); 

//VALIDATE FORM
$(document).ready(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"});
  });

  $("#contact_form .button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var firstname = $("input#firstname").val();
		if (firstname == "") {
      $("label#firstname_error").show();
      $("input#firstname").focus();
      return false;
    }

	  var lastname = $("input#lastname").val();
		if (lastname == "") {
      $("label#lastname_error").show();
      $("input#lastname").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;
    }

	});
});

