$(function(){
	$('.error').hide();
	$(".button").click(function(){
		// validate and process form
		
		$('.error').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 comments = $("textarea#comments").val();
			if(comments == ""){
				$("label#comments_error").show();
				$("textarea#comments").focus();
				return false;
			}
			
			var dataString = 'name=' + name + '&email=' + email + '&comments=' + comments;

			$.ajax({
				type: "POST",
				url: "bin/process.php",
				data: dataString,
				success: function() {
					$('#form').html("<div id='submitMessage'></div>");
					$('#submitMessage').html("<h2>Contact Form Submitted!</h2>")
					.append("<p>We will be in touch soon.</p>")
					.hide()
					.fadeIn(1500, function() {
				  });
				}
			  });
			  return false;  
  
			
	});
});
