// JavaScript Document
/**
 * This function checks to see if the email has a proper syntax.  If it does
 * it will return testResults = true, otherwise it will return testResult = false
 * and keep cursor in the email field.
 */
function checkEmail(){
   var testResults;
   var email=document.order.email.value;
   var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

   // Billing email
   if (filter.test(email))
      testRresults=true;
   else{
      alert("Please enter a complete email address in the form: yourname@yourdomain.com");
      order.email.focus();
			testResults=false;
   }
   return (testResults);
}

/**
 * This function is the entry for validating email
 */
function formValidation(){
   // Check form
	 var theForm = document.order;

	 //alert("theForm: " + theForm);

	 // Last Name
	 if(theForm.last_name.value == "") {
	    alert("Last Name is required");
      order.last_name.focus();
			return false;
	 }

	 // First Name
	 if(theForm.first_name.value == "") {
	    alert("First Name is required");
      order.first_name.focus();
			return false;
	 }

	 // Address
	 if(theForm.address.value == "") {
	    alert("Address is required");
      order.address.focus();
			return false;
	 }

	 // City
	 if(theForm.city.value == "") {
	    alert("City is required");
      order.city.focus();
			return false;
   }
   
	 // State
	 if(theForm.state.value == "") {
	    alert("State is required");
      order.state.focus();
			return false;
   }

	 // Postal Code
	 if(theForm.postal_code.value == "") {
	    alert("Postal Code is required");
      order.postal_code.focus();
			return false;
   }

	 // Phone Area Code
	 if(theForm.ph_area_code.value == "" ) {
	    alert("Complete Phone Number is required");
      order.ph_area_code.focus();
			return false;
	 }

	 // Phone Number Prefix
	 if(theForm.phone_1.value == "" ) {
	    alert("Complete Phone Number is required");
      order.phone_1.focus();
			return false;
	 }

	 // Phone Number Suffix
	 if(theForm.phone_2.value == "" ) {
	    alert("Complete Phone Number is required");
      order.phone_2.focus();
			return false;
	 }
	 
	 // Email
	 if(theForm.email.value == "" ) {
	    alert("Email is required");
      order.email.focus();
			return false;
	 }

	 // Check document
   if (document.layers||document.getElementById||document.all)
      if(theForm.email.value == "" )
	  return checkEmail();
      else return true;
}

/**
 * This function is to link to other pages
 */
function linkToPrice_onclick(){
    window.location.href("../pages/Price.htm");
}

/**
 * This function prompts warning before you leave the page
 */
function yesnoWarning(){
	question = confirm("Warning: You are about to leave the form!")
	if (question !="0"){
		window.location.href("../pages/Price.htm");
		
	}
}
