$(function() {
	$('.error').hide();
	$(".button").click(function(){
		//validate process from here
		
		$('.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 phone = $("input#phone").val();
			if (phone == "") {
			$("label#phone_error").show();
			$("input#phone").focus();
			return false;
			}
			
			var subject = $("input#subject").val();
			if (subject == "") {
			$("label#subject_error").show();
			$("input#subject").focus();
			return false;
			}
			
			var comment = $("textarea#comment").val();
			if (comment == "") {
			$("label#comment_error").show();
			$("textarea#comment").focus();
			return false;
			}
				
		var dataString = 'name=' + name + '&email=' + email + '&phone=' + phone + '&subject=' + subject + '&comment=' + comment;
		//alert (dataString);return false;
		$.ajax ({
			type: "POST",
			url: "mailer.php",
			data: dataString,
			success: function()	{
				$('#contact_form').html("<div id='message'></div>");
				$('#message').html("<h2>Message Sent.</h2>")
				.append("<p>I will be in touch soon</p>")
				.hide()
				.fadeIn(1500, function()	{
					$('#message').append("");
				});
			}
		});
		return false;
		
	});
});
