$(function() {  
	$('.error').hide(); //get rid of validation notifications 
   

	$(".button").click(function() {  
		
     $('.error').hide(); //hide the validation even when the button gets clicked
	 
	 
	 
     var name = $("input#name").val(); //get the value of the field 
	 
     if (name == "") {  //check to see if its empty
	 
	   $("label#name_error").show();  //show the error message
       $("input#name").focus();  //put the curser inside the input field
       return false;  //page does not get sent
	   
     }
	 
	
	 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 phone = $("input#phone").val(); if (phone == "") { $("label#phone_error").show(); $("input#phone").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 = $('form').serialize();
     //alert (dataString);return false;
     $.ajax({  
      type: "POST",  
      url: "/js/contact_poster.php",  
      data: dataString,  
      success: function() {
	  
        $('#contact_form').html("<div id='message'></div>");  
        $('#message').html("<br /><br /><h2>Details Sent</h2>")  
       .append("<p><small>We will be in touch soon.</small></p>")  
       .hide()  
       .fadeIn(1500);
      }  
	 });  
     return false;  
		
	}); 

	
});  
