



function isNum(passedVal) {					// Is this a number?
	if (passedVal == "") {
		return false
	}
	for (i=0; i<passedVal.length; i++) {
		if (passedVal.charAt(i) < "0") {
			return false
		}
		if (passedVal.charAt(i) > "9") {
			return false
		}
	}
	return true
}

function validZip(inZip) {					// Is this a valid Zip code?
	if (inZip == "") {
		return true
	}
//	if (isNum(inZip)) {						// Check if Zip is numeric
//		return true
//	}
//	return false
    return true
}


function Form1_Validator(theForm)
{
		// remove the next var lines for direct mail
		//var codestr = location.search.substring(1, location.search.length);
		//alert("The content of code is " + codestr)
		
		//alert(codestr.indexOf('='));
		//alert(codestr.length);
		//var code = codestr.substring(codestr.indexOf('=')+1, codestr.length);
		//alert(code);
	
  		if (theForm.Name.value == "")
  		{
    		alert("Please enter a value for the \"Name\" field.");
    		theForm.Name.focus();
    		return (false);
  		}
  	
	

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


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

 

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



		if (theForm.EmailAddr.value == "")
  		{
    		alert("Please enter a valid email for the \"Email\" field.");
    		theForm.EmailAddr.focus();
    		return (false);
  		}

		var checkEmail = "@.";
		var checkStr = theForm.EmailAddr.value;
		var EmailValid = false;
		var EmailAt = false;
		var EmailPeriod = false;
		for (i = 0;  i < checkStr.length;  i++)
		{
		  ch = checkStr.charAt(i);
		  for (j = 0;  j < checkEmail.length;  j++)
		  {
		   if (ch == checkEmail.charAt(j) && ch == "@")
		     EmailAt = true;
		   if (ch == checkEmail.charAt(j) && ch == ".")
		     EmailPeriod = true;
	 	   if (EmailAt && EmailPeriod)
		     break;
	 	   if (j == checkEmail.length)
		     break;
		  }
		  // if both the @ and . were in the string
		  if (EmailAt && EmailPeriod)
		  {
			EmailValid = true
			break;
		  }
		}
		if (!EmailValid)
		{
		  alert("The \"email\" field is invalid, please try again. It must contain an \"@\" and a \".\".");
		  theForm.EmailAddr.focus();
		  return (false);
		}

		
	

 
 
	return (true);
	
}




	


