
<!--

/*function noenter() {
  return !(window.event && window.event.keyCode == 13); }

function setFocus(formName, elementName) {
  for (var i=0; i<formName.elements.length; i++) {
    if (formName.elements[i].name == elementName) {
               formName.elements[i].focus();
}}}

function blankMessage(formName, elementName) {
  for (var i=0; i<formName.elements.length; i++) {
    if (formName.elements[i].name == elementName) {
               formName.elements[i].value = "";
}}}*/
//Form Validation functions
// Set some global variables
var msg = "";  // an output message
var missing = ""; // for missing fields
var invEmail = ""; // for invalid email addresses
var invPhone = "";

//the main validation function

function validate(frm)
{		
	var counter = 0;
        for(i = 0; i< frm.elements.length; i++)
        {
                var el = frm.elements[i];
		 
		if (el.name== "UserTel" && el.value.length != 0)
                {
                        if (invalidPhone(el) || el.value.length > 12)
                        {
                                 missing += "\n   - " + el.value + " is not a valid phone number. Be sure to include an area code.";
                        }
                }
		
        if (el.name== "UserFAX" && el.value.length != 0)
                {
                        if (invalidPhone(el) || el.value.length > 12)
                        {
                                 missing += "\n   - " + el.value + " is not a valid FAX number. Be sure to include an area code.";
                        }
                }
		 if (el.required)
           {
                if (isEmpty(el))
                { 
                        missing += "\n   - " + el.name + " is a required field";
                }
		        if (el.UserEmail)
				{
						if (emailCheck(el.value)) {}
						else
						{invEmail = "Invalid";}
				}   
           } 
           
        }

           //build output message
           if (missing.length != 0 || invEmail !=0 )
              {
               if (missing.length != 0)
                  {
                   msg +="\n\n";
                  msg += "The following required fields are missing or in error:";
                  msg += missing;
                  }
               
             errMsg(msg); //call the output function
                   msg = ""; missing = ""; invEmail="";
                   return false;
               }
                   else
                   return true;
           }


               //All sub-functions follow
			    function invalidPhone(field)
               {
               newStr = stripNonDigits(field.value);
               if (newStr.length == 10)
                   {
                       return false;
                   }
                       return true;
               }
 				function stripNonDigits(str)
               {
                       newStr = "";
                       for (j=0;j<str.length;j++)
                       {
                               c = str.charAt(j)
                               if (c >= "0" && c <= "9")
                               {
                                       newStr += c;
                               }
                       }
                       return newStr;
               }
				


               function isEmpty(field)
               {
               str = field.value;
               if (str == (""))
                         // no space between quotes
                  {
                       return true;
                  }
                       else
                  {
                       for (j = 0;j<str.length;j++)
                       {
                       if  (str.charAt(j) != " ")
                       // make sure space between quotes
                               {
                               return false;
                               }
                       }
                  }
                  return true;
               }    

                function errMsg(msg)
                {
                        var theMsg = "You entered some incorrect values into the form. ";
                        theMsg += "Please correct your entries and re-submit the form. \n";
                        theMsg += "__________________________________________________";
                        theMsg += msg;
                        theMsg += "\n__________________________________________________";
                        alert(theMsg);
                }
				function emailCheck(emailStr)
				 {
				var checkTLD=1;
				var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
				var emailPat=/^(.+)@(.+)$/;
				var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
				var validChars="\[^\\s" + specialChars + "\]";
				var quotedUser="(\"[^\"]*\")";
				var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
				var atom=validChars + '+';
				var word="(" + atom + "|" + quotedUser + ")";
				var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
				var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
				var matchArray=emailStr.match(emailPat);
				if (matchArray==null) {
				  //msg +="\n\n";
                 // msg += "Your email address is incorrectly spelled (check @ and .'s) or missing.";
				  missing += "\n   -"+"Your email address is incorrectly spelled (check @ and .'s) or missing.";
				  invEmail = "Invalid";
				//alert("Your email address is incorrectly spelled (check @ and .'s)");
				return false;
				}
				var user=matchArray[1];
				var domain=matchArray[2];
				for (i=0; i<user.length; i++) {
				if (user.charCodeAt(i)>127) {
				//msg +="\n\n";
                //msg += "Your email address contains invalid characters.";
				missing += "\n   -"+"Your email address contains invalid characters.";
				return false;
				   }
				}
				for (i=0; i<domain.length; i++) {
				if (domain.charCodeAt(i)>127) {
				//msg +="\n\n";
                //msg += "Your email domain name contains invalid characters.";				
				missing += "\n   -"+"Your email domain name contains invalid characters.";
			
				return false;
				   }
				}
				if (user.match(userPat)==null) {
				//msg +="\n\n";
                //msg += "Your email does not seem to be valid - check your spelling.";				
				missing += "\n   -"+"Your email domain name contains invalid characters.";
				return false;
				}
				var IPArray=domain.match(ipDomainPat);
				if (IPArray!=null) {
				for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
				//msg +="\n\n";
                //msg += "Destination IP address is invalid!";				
				missing += "\n   -"+"Destination IP address is invalid!";
				return false;
				   }
				}
				return true;
				}
				var atomPat=new RegExp("^" + atom + "$");
				var domArr=domain.split(".");
				var len=domArr.length;
				for (i=0;i<len;i++) {
				if (domArr[i].search(atomPat)==-1) {
				//msg +="\n\n";
               // msg += "Your email address does not seem to be valid - check your spelling, including wrong use of commas, or a period [.] at the end of the address .";				
				missing += "\n   -"+"Your email address does not seem to be valid - check your spelling, including wrong use of commas, or a period [.] at the end of the address .";
				return false;
				   }
				}
				if (checkTLD && domArr[domArr.length-1].length!=2 && 
				domArr[domArr.length-1].search(knownDomsPat)==-1) {
				//msg +="\n\n";
                //msg += "Your email address must end in a well-known domain or two letter " + "country.";				
				missing += "\n   -"+"Your email address must end in a well-known domain or two letter " + "country.";
				return false;
				}
				if (len<2) {
				//msg +="\n\n";
                //msg += "Your email address is missing a hostname - check spelling. Or you may have added a blank space at the end of the address - backspace to remove this.";				
				missing += "\n   -"+"Your email address is missing a hostname - check spelling. Or you may have added a blank space at the end of the address - backspace to remove this.";
				return false;
				}
				return true;
				}


//-->