// JavaScript Document

function submitForm()
{
	$("#contactform").ajaxSubmit(
										  {											 
											  clearForm : false,
											  success : function( data, msg ) { 
											              $("#contactform").hide();
											              $("#response").hide().html( data ).fadeIn(200);
															  reinitScrollPane();
															  } 
										  }
										);
}
function contactusInit()
{
	 var d = new Date();
	 $("#date").val( "{0}/{1}/{2}".format( d.getMonth(), d.getDate(), d.getFullYear() ) );
	 //$("#contactform").ajaxForm();
	 $("#contactform").validate( 
										  {											  
											  rules: {
													  name: "required",
													  phone : { required : false, phoneUS : true },														       
													  returnemail: {
														 required: true,
														 email: true
													  }
													},
											  messages: {
												  name: "Please enter your name",
												  phone: {  phoneUS: "Please format your phone number with (xxx) yyy-zzzz" },
												  returnemail : {
													 required: "We need your email address to respond",
													 email: "Your email address must be in the format of name@domain.com"
												  }
												},
											   errorClass: "invalid",
												submitHandler: function(form) {
													submitForm();
													return false;
												}
										  }
										);
}

$contentReady.add( contactusInit );
