// JavaScript Document
<!-- Begin

	function checkForm () {

	var valCheck; 	
	var valNum = "01234567890";
	var valChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var valNameChars = " -.\'";
	var valSpecChars = " -.,\'\&\#\*";
	var invalChars = "!\@\$\%\^\?\<\>\:\;\\\{\}\[\]\|\/\~\`";

	if (document.mailinglist.name.value == "") {
			alert("Please fill in your first name.")
			document.mailinglist.name.focus();
			return false;
		} else {
				// VERIFIES THAT NAME FIELD CONTAINS ONLY LETTERS
				var valChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- \'";
			
				for (var i = 0; i < document.mailinglist.name.value.length; i++) {
				   if (valChars.indexOf(document.mailinglist.name.value.charAt(i)) == -1) {
					alert ("Please enter a valid \"Name\".")
					document.mailinglist.name.focus();
					return false;
					}
				}
			}



	if (document.mailinglist.email.value == "") {
			alert("Please fill in your E-mail address.")
			document.mailinglist.email.focus();
			return false; 
	} else {

			emailStr = document.mailinglist.email.value

			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) {
			
			alert("Email address seems incorrect (check @ and .'s)");
			document.mailinglist.email.focus();
			return false;
			}
			var user=matchArray[1];
			var domain=matchArray[2];

			for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
			alert("Ths username contains invalid characters.");
			document.mailinglist.email.focus();
			return false;
			   }
			}
			for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
			alert("Ths domain name contains invalid characters.");
			document.mailinglist.email.focus();
			return false;
			   }
			}
			
			if (user.match(userPat)==null) {
			
			// user is not valid
			
			alert("The username doesn't seem to be valid.");
			document.mailinglist.email.focus();
			return false;
			}

			var IPArray=domain.match(ipDomainPat);
			if (IPArray!=null) {

			for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
			alert("Destination IP address is invalid!");
			document.mailinglist.email.focus();
			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) {
			alert("The domain name does not seem to be valid.");
			document.mailinglist.email.focus();
			return false;
			   }
			}

			if (checkTLD && domArr[domArr.length-1].length!=2 && 
			domArr[domArr.length-1].search(knownDomsPat)==-1) {
			alert("The address must end in a well-known domain or two letter " + "country.");
			document.mailinglist.email.focus();
			return false;
			}

			if (len<2) {
			alert("This address is missing a hostname!");
			document.mailinglist.email.focus();
			return false;
			}

			}

			if (document.mailinglist.state.value == "") {
					alert("Please enter your \"State\".");
					document.mailinglist.state.focus();
					return false
			} else {
					// VERIFIES THAT STATE FIELD CONTAINS 2 Characters
					if (document.mailinglist.state.value.length != 2) {
						alert ("Please enter 2 letters into the State field.")
						document.mailinglist.state.focus();
						return false;
					}
						var chars = valChars;
						for (var i = 0; i < document.mailinglist.state.value.length; i++) {
						   if (chars.indexOf(document.mailinglist.state.value.charAt(i)) == -1) {
							alert ("Please enter only letters into the State field.")
							document.mailinglist.state.focus();
							return false;
							}
						}	
					
				} // end State check
		
			if (document.mailinglist.birthmonth.value == "") {
					alert("Please select your \"Birthmonth\".");
					document.mailinglist.birthmonth.focus();
					return false
			}
		
			if (document.mailinglist.birthdate.value == "") {
					alert("Please select your \"Birthdate\".");
					document.mailinglist.birthdate.focus();
					return false
			}
		
			if (document.mailinglist.birthyear.value == "") {
					alert("Please select your \"Birthyear\".");
					document.mailinglist.birthyear.focus();
					return false
			}
			
			var genderCheck = -1
		
			for (var i=0;i<document.mailinglist.gender.length;i++) {
				if (document.mailinglist.gender[i].checked) {
					var genderCheck = 1
					}
				}
				if (genderCheck == -1) {
				 alert ("Please tell us what ya are.");
							document.mailinglist.gender[0].focus();
				 return false
				}
			
		}
// -->
