$(document).ready(function() {
  $("form#contact_us").submit(function(){
	var hasError = false;
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var process_type = $("input#process_type").val();
	var contact_name = $("input#contact_name").val();
	if(contact_name == '') {
		$("#contact_name_error").html('Please enter your name.');
		hasError = true;
	} else {
		$("#contact_name_error").html('');
	}
	var contact_email_address = $("input#contact_email_address").val();
	if(contact_email_address == '') {
		$("#contact_email_address_error").html('Please enter a valid e-mail address.');
		hasError = true;
	} else if(!emailReg.test(contact_email_address)) {	
		$("#contact_email_address_error").html('Please enter a valid e-mail address.');
		hasError = true;
	} else {
		$("#contact_email_address_error").html('');
	}
	var contact_comments = $("textarea#contact_comments").val();
	if(contact_comments == '') {
		$("#contact_comments_error").html('Please enter your question or comment.');
		hasError = true;
	} else {
		$("#contact_comments_error").html('');
	}
	if(hasError == false) {
		$("#form_message").html('Submitting form...');
		$.post("../../../includes/process.php",{ process_type: process_type, contact_name: contact_name, contact_email_address: contact_email_address, contact_comments: contact_comments }, function() { $("#contact_form").slideUp("normal", function() { $("#contact_form").before('<h2>Thank You! <span class="red">&raquo;</span></h2><p>We have received your comments.</p><p>You will be contacted by xclntDesign very shortly.</p></div>' )} )} );
	}
    return false;
  });
});
