function validEmail(email) {
     invalidChars = " /:,;"
     if (email == "") {
                return (false);
     }
     for (i=0; i<invalidChars.length; i++) {
          badChar = invalidChars.charAt(i)
          if (email.indexOf(badChar,0) != -1) {
                return (false);
                }
    }
    atPos = email.indexOf("@",1)
    if (atPos == -1) {
                return (false);
    }
    if (email.indexOf("@",atPos+1) != -1) {
                return (false);
    }
    periodPos = email.indexOf(".",atPos)
    if (periodPos == -1) {
                return (false);
    }
    if (periodPos+3 > email.length) {
                return (false);
    }
    return (true);
}

function isNum(passedSerial) {
	if (passedSerial == "") {
		return (true);
	}
	for (i=0; i<passedSerial.length; i++) {
		if (passedSerial.charAt(i) < "0") {
			return (false);
		}
		if (passedSerial.charAt(i) > "9") {
			return (false);
		}
	}
	return (true);
}
		
function validSerial(inSerial) {
 	if (inSerial == "") {
 		return (false);
	}
	if (isNum(inSerial)) {
			return (true);
		}
		return (false);
	}		



function Validator(theForm) {

  if (theForm.firstname.value == "") {
      alert("Please enter a value for the \"first name\" field.");
      theForm.firstname.focus();
      return (false);
  }

  if (theForm.lastname.value == "") {
      alert("Please enter a value for the \"last name\" field.");
      theForm.lastname.focus();
      return (false);
  }
  
  if (theForm.emailaddr.value == "") {
      alert("Please enter a value for the \"email address\" field.");
      theForm.emailaddr.focus();
      return (false);
  }
  
 if (theForm.emailaddr.value != "") {
     if (!validEmail(theForm.emailaddr.value)) {
         alert("Please enter a valid email address");
         theForm.emailaddr.focus();
         theForm.emailaddr.select();
         return (false);
     }
 }
  
 if (theForm.phone.value == "") {
     alert("Please enter a value for the \"phone number\" field.");
     theForm.phone.focus();
     return (false);
 }
  
 if (theForm.zip.value == "") {
     alert("Please enter a value for the \"zip code\" field.");
     theForm.zip.focus();
     return (false);
 }
 
 
 if ((theForm.timeframe[0].checked == false) && (theForm.timeframe[1].checked == false) && (theForm.timeframe[2].checked == false) && (theForm.timeframe[3].checked == false)) {
      alert ("Please choose when you are choosing to purchase.");
      theForm.timeframe[0].focus();
      return (false);
 }
 
 if ((theForm.financingby[0].checked == false) && (theForm.financingby[1].checked == false)) {
       alert ("Please choose means of financing at top of the form.");
       theForm.financingby[0].focus();
       return (false);
 }
 
 if ((theForm.financingby[0].checked == false) && (theForm.financing[0].checked == false) && (theForm.financing[1].checked == false)) {
       alert ("Please choose approval status at top of the form.");
       theForm.financing[0].focus();
       return (false);
 }
  
  return (true);
}