// JavaScript Document
<!--

function checkEmail(email) {
var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
return (filter.test(email)) ;
}


function validate(doc)
{
	var message = "The form has the following errors:\n"
	var errors = false;
	var form = doc.getElementById("contact_form")
	if(!checkEmail(form.email.value))
	{
		errors = true;
		message +="Your email adress needs to be in the form name@example.com\n"
	}

	if(form.address.value == "")
	{
		errors = true;
		message +="You must provide a Street Address\n"
	}
	if(form.city.value == "")
	{
		errors = true;
		message +="You must provide a City\n"
	}
	if(form.state.value == "")
	{
		errors = true;
		message +="You must provide a State or Province or Region\n"
	}
	if(form.zip.value == "")
	{
		errors = true;
		message +="You must provide a Zip or Postal Code\n"
	}
		if(form.username.value != "") //honeypot
	{
		errors = true;
		message +="\n"
	}

	//resopnd to failure by printing error and return false
	if(errors)
	{
    	window.alert (message);
		return false;
	}
	else
		return true;
	
}



function  validate_and_submit(doc)
{
	if(validate(doc))
	{
		var form = doc.getElementById("contact_form");
		var form_holder = doc.getElementById("form_holder");
		var st = "<form id='contact_form' action='contact_submit.php' method='post'><div class='form_description'> <p class='black'>"
		+" <strong class='instructions'>Please verify your information and click Send.</strong></p></div> "
		+"<label class='info_verify'>Name: </label> "+
		 form.first.value +" "+ form.last.value 
		 +"<br/><br/><label class='info_verify'>Address: </label> <br/>"
		+ form.address.value
		+"<br/>"+form.address2.value
		+"<br/>"+form.city.value
		+"<br/>"+form.state.value
		+"<br/>"+form.zip.value
		+"<br/><br/><label class='info_verify'>Phone: </label>"
		+form.area_code.value+" - "+form.phone_prefix.value+" - "+form.phone_suffix.value
		+"<br/><br/><label class='info_verify'>Email: </label>"
		+form.email.value
		+"<br/><br/> <label class='info_verify'>Your Message: </label> <br />"
		+form.contact_message.value
		+"<input type='hidden' name='first' value='"+form.first.value+"'>"
		+"<input type='hidden' name='last' value='"+form.last.value+"'>"
		+"<input type='hidden' name='address' value='"+form.address.value+"'>"
		+"<input type='hidden' name='address2' value='"+form.address2.value+"'>"
		+"<input type='hidden' name='city' value='"+form.city.value+"'>"
		+"<input type='hidden' name='state' value='"+form.state.value+"'>"
		+"<input type='hidden' name='zip' value='"+form.zip.value+"'>"
		+"<input type='hidden' name='email' value='"+form.email.value+"'>"
		+"<input type='hidden' name='phone_prefix' value='"+form.phone_prefix.value+"'>"
		+"<input type='hidden' name='phone_suffix' value='"+form.phone_suffix.value+"'>"
		+"<input type='hidden' name='area_code' value='"+form.area_code.value+"'>"
		+"<input type='hidden' name='contact_message' value='"+form.contact_message.value+"'><br/>"
		
     +"<p class='instructions'>Please click the 'Send' button only once. Depending upon the speed of your internet connection, it may take a few second to process your submission.</p>"
	 +"<input type='submit' value='Send' ><input type='button' value='Go Back' onclick='revert_form()'></form><br/><br/>";
	 form_holder.innerHTML = st;
	 window.scroll(0,0);
	}
	
}

function send_form(){
	var form = document.getElementById("contact_form");
	form.submit();
}

function revert_form(){
window.location.reload();
}

-->