function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

function checkQuoteForm() {
	var errors = 0;
	var theForm = document.forms.quoteForm;
	var alertMessage = "";
	
	if (theForm.Name.value.length < 1) {
		alertMessage += "Please enter your Name.\n";
		errors++;
	}
	
	if (theForm.Email.value.length < 1) {
		alertMessage += "Please enter your Email address.\n";
		errors++;
	} else if (theForm.Email.value.length >= 1) {
		emailAddy = theForm.Email.value
		AtPos = emailAddy.indexOf("@")
		StopPos = emailAddy.lastIndexOf(".")
		if (AtPos == -1 || StopPos == -1) {
			alertMessage += "Please enter a valid Email address.\n";
			errors++;
		}
	}
	if (theForm.Phone.value.length < 1 && theForm.Mobile.value.length < 1) {
		alertMessage += "Please enter either a Mobile or landline Phone Number.\n";
		errors++;
	}
	if (theForm.Phone.value.length > 1 && theForm.Area.value.length != 2) {
		alertMessage += "Please enter your Area Code.\n";
		errors++;
	}
	if (theForm.Area.value.length > 1 && IsNumeric(theForm.Area.value) == false) {
		alertMessage += "Your Area Code can only contain numbers.\n";
		errors++;
	}
	
	if (theForm.Phone.value.length > 1 && theForm.Area.value.length == 2 && theForm.Phone.value.length != 8) {
		alertMessage += "Your Phone Number must contain eight digits.\n";
		errors++;
	}
	if (theForm.Phone.value.length > 1 && IsNumeric(theForm.Phone.value) == false) {
		alertMessage += "Your Phone Number can only contain numbers.\n";
		errors++;
	}

	if (theForm.Mobile.value.length > 1 && theForm.Mobile.value.length != 10) {
		alertMessage += "Your Mobile Number must contain ten digits.\n";
		errors++;
	}
	if (theForm.Mobile.value.length > 1 && IsNumeric(theForm.Mobile.value) == false) {
		alertMessage += "Your Mobile Number can only contain numbers.\n";
		errors++;
	}

	if (theForm.captcha_code.value.length < 1) {
		alertMessage += "Please enter the security code shown in the image.\n";
		errors++;
	}

	if (theForm.captcha_code.value.length > 1 && theForm.captcha_code.value.length < 5) {
		alertMessage += "The security code must contain five characters.\n";
		errors++;
	}

	if (theForm.captcha_code.value.length > 5) {
		alertMessage += "The security code must only contain five characters.\n";
		errors++;
	}
	
	
	if (errors == 0) {
		theForm.submit();
	} else {
		alert(alertMessage);
	}
}
