function checkOptOutForm(formname)
{
	// Checks for illegal characters in each text field
	for (i=0; i < eval('document.' + formname + '.length') ; i++)
	{
		if (eval('document.' + formname + '.elements[' + i + '].type') == "text" || eval('document.' + formname + '.elements[' + i + '].type') == "textarea")
		{
	        stringer = eval('document.' + formname + '.elements[' + i + '].value');
		}
		else
		{
			stringer = "";
		}
	
		if ((stringer.indexOf("<") != -1)||(stringer.indexOf(">") != -1))
		{
			alert('Sorry, but you have entered illegal characters (< or >) into this form.');
			eval('document.' + formname + '.elements[' + i + '].focus()');
			return false;
		}
		if ((stringer.indexOf("'") != -1)||(stringer.indexOf("\"") != -1))
		{
			alert('Please do not enter single or double quotes into this form.');
			eval('document.' + formname + '.elements[' + i + '].focus()');
			return false;
		}	
		if ((stringer.indexOf("(") != -1)||(stringer.indexOf(")") != -1))
		{
			alert('Please do not enter parenthesis into this form.');
			eval('document.' + formname + '.elements[' + i + '].focus()');
			return false;
		}	
	}
	
	// Checks to make sure the first name field isn't blank and accepts only letters
	var firstname = eval('document.' + formname + '.firstname.value');
	if (firstname == "")
	{
		alert("Please enter your First Name.");
		eval('document.' + formname + '.firstname.focus()');
		return false;
	}	
	else {
	for (i=1;i<firstname.length;++i) {
			if (!isNaN(firstname.charAt(i)) && firstname.charAt(i) != " ") {
				alert("Your first name cannot contain numeric values. Please complete or correct the information.");
				eval('document.' + formname + '.firstname.focus()');
				return false;
			}
			
		}	
	}
	
	
	// Checks to make sure the last name field isn't blank and accepts only letters
	var lastname = eval('document.' + formname + '.lastname.value');
	if (lastname == "")
	{
		alert("Please enter your Last Name.");
		eval('document.' + formname + '.lastname.focus()');
		return false;
	}
	else {
	for (i=1;i<lastname.length;++i) {
			if (!isNaN(lastname.charAt(i)) && lastname.charAt(i) != " ") {
				alert("Your last name cannot contain numeric values. Please complete or correct the information.");
				eval('document.' + formname + '.lastname.focus()');
				return false;
			}
			
		}	
	}
	
	
	// Checks to make sure the email address is valid and not blank	
	var email = eval('document.' + formname + '.email.value');
	if (email == "")
	{
		alert("Please enter your Email address");
		eval('document.' + formname + '.email.focus()');
		return false;
	}

	var emailStr =  document.outform.email.value;
	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 (emailStr == "")
	{
		alert("Please complete or correct your email address. (Fix any symbols or spaces.)");
		document.outform.email.focus();
		return false;
	}
	
	// check for @ and .
	if (matchArray == null)
	{
		alert("Please complete or correct your email address. (Fix any symbols or spaces.)")
		document.outform.email.focus();
		return false;
	}
	
	var user = matchArray[1]
	var domain = matchArray[2]
	var IPArray = domain.match(ipDomainPat)
	
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++)
		{
		if (IPArray[i]>255)
			{
		    alert("Please complete or correct your email address. (Fix any symbols or spaces.)")
			document.outform.email.focus();
			return false;
		    }
		}
		return 
	}
	
	var domainArray=domain.match(domainPat)
	
	if (domainArray==null)
	{
		alert("Please complete or correct your email address. (Fix any symbols or spaces.)")
		document.outform.email.focus();
	    return false;
	}
	
	// checking for valid .com, .org, etc.
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
	{
		alert("Please complete or correct your email address. (Fix any symbols or spaces.)")
		document.outform.email.focus();
		return false;
	}
	
	if (len<2)
	{
		var errStr="This address is missing a hostname."
		alert("Please complete or correct your email address. (Fix any symbols or spaces.)")
		document.outform.email.focus();	
		return false;
	}	
	
	
	
}

function checkForm(formname, count, form)
{
	// Checks for illegal characters in each text field
	for (i=0; i < eval('document.' + formname + '.length') ; i++)
	{
		if (eval('document.' + formname + '.elements[' + i + '].type') == "text" || eval('document.' + formname + '.elements[' + i + '].type') == "textarea")
		{
	        stringer = eval('document.' + formname + '.elements[' + i + '].value');
		}
		else
		{
			stringer = "";
		}
	
		if ((stringer.indexOf("<") != -1)||(stringer.indexOf(">") != -1))
		{
			var alertString = "Sorry, but you have entered illegal characters (< or >) into this form.";
			trackFormError(count, alertString, form);
			alert(alertString);
			eval('document.' + formname + '.elements[' + i + '].focus()');
			return false;
		}
		if ((stringer.indexOf("'") != -1)||(stringer.indexOf("\"") != -1))
		{
			var alertString = "Please do not enter single or double quotes into this form.";
			trackFormError(count, alertString, form);
			alert(alertString);
			eval('document.' + formname + '.elements[' + i + '].focus()');
			return false;
		}	
		if ((stringer.indexOf("(") != -1)||(stringer.indexOf(")") != -1))
		{
			var alertString = "Please do not enter parenthesis into this form.";
				trackFormError(count, alertString, form);
				alert(alertString);
			eval('document.' + formname + '.elements[' + i + '].focus()');
			return false;
		}	
	}
	
	// Checks to make sure the first name field isn't blank and accepts only letters
	var firstname = eval('document.' + formname + '.firstname.value');
	if (firstname == "")
	{
		var alertString = "Please enter your First Name.";
			trackFormError(count, alertString, form);
			alert(alertString);
		eval('document.' + formname + '.firstname.focus()');
		return false;
	}	
	else {
	for (i=1;i<firstname.length;++i) {
			if (!isNaN(firstname.charAt(i)) && firstname.charAt(i) != " ") {
				var alertString = "Your first name cannot contain numeric values. Please complete or correct the information.";
					trackFormError(count, alertString, form);
					alert(alertString);
				eval('document.' + formname + '.firstname.focus()');
				return false;
			}
			
		}	
	}

	// Checks to make sure the last name field isn't blank and accepts only letters
	var lastname = eval('document.' + formname + '.lastname.value');
	if (lastname == "")
	{
		var alertString = "Please enter your Last Name.";
			trackFormError(count, alertString, form);
			alert(alertString);
		eval('document.' + formname + '.lastname.focus()');
		return false;
	}
	else {
	for (i=1;i<lastname.length;++i) {
			if (!isNaN(lastname.charAt(i)) && lastname.charAt(i) != " ") {
				var alertString = "Your last name cannot contain numeric values. Please complete or correct the information.";
					trackFormError(count, alertString, form);
					alert(alertString);
				eval('document.' + formname + '.lastname.focus()');
				return false;
			}
			
		}	
	}
	
	var profession = eval('document.' + formname + '.profession.selectedIndex');
	if (profession == "0")
	{
		var alertString = "Please select your Profession.";
			trackFormError(count, alertString, form);
			alert(alertString);
		eval('document.' + formname + '.profession.focus()');
		return false;
	}
	
	var specialty = eval('document.' + formname + '.specialty.selectedIndex');
	if (specialty == "0")
	{
		var alertString = "Please select your Specialty.";
			trackFormError(count, alertString, form);
			alert(alertString);
		eval('document.' + formname + '.specialty.focus()');
		return false;
	}
	
	var institution = eval('document.' + formname + '.institution.value');
	if (institution == "")
	{
		var alertString = "Please enter your Institution.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.institution.focus()');
		return false;
	}

		 	
	// Checks to make sure the address field isn't blank
	var address1 = eval('document.' + formname + '.address.value');
	if (address1 == "")
	{
		var alertString = "Please enter your Address.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.address.focus()');
		return false;
	}	

	// Checks to make sure the city field isn't blank and accepts only letters
	var city = eval('document.' + formname + '.city.value');
	if (city == "")
	{
		var alertString = "Please enter your City.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.city.focus()');
		return false;
	}
	else {
	for (i=1;i<city.length;++i) {
			if (!isNaN(city.charAt(i)) && city.charAt(i) != " ") {
				var alertString = "Your city cannot contain numeric values. Please complete or correct the information.";
					trackFormError(count, alertString, form);
				alert();
				eval('document.' + formname + '.city.focus()');
				return false;
			}
			
		}	
	}

	// Checks to make sure the state field isn't blank
	var state = eval('document.' + formname + '.state.value');
	if (state == "")
	{
		var alertString = "Please select your State.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.state.focus()');
		return false;
	}
	
	// Checks to make sure the zip code field isn't blank
	var zip = eval('document.' + formname + '.zip.value');
	
	if (zip == "")
	{
		var alertString = "Please enter your Zip Code.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.zip.focus()');
		return false;
	}
	
	// Checks for a valid zip code
	if (zip != "")
	{
		var valid = "0123456789-";
		var hyphencount = 0;

		if (zip.length!=5 && zip.length!=10) {
		var alertString = "Please enter your 5 digit or 5 digit+4 zip code.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.zip.focus()');
		return false;
		}
		for (var i=0; i < zip.length; i++) {
		temp = "" + zip.substring(i, i+1);
		if (temp == "-") hyphencount++;

		if (valid.indexOf(temp) == "-1") {
		var alertString = "Invalid characters in your zip code.  Please try again.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.zip.focus()');
		return false;
		}

		if ((hyphencount > 1) || ((zip.length==10) && ""+zip.charAt(5)!="-")) {
		var alertString = "The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'. Please try again.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.zip.focus()');
		return false;
			}
		}
	}
	
	
	var area = eval('document.' + formname + '.area.value');
	if (area == "")
	{
		var alertString = "Please enter your area code.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.area.focus()');
		return false;
	}
	
	var valid = "0123456789";
	for (var i=0; i < area.length; i++) {
		temp = "" + area.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") {
			var alertString = "Your phone number cannot contain non-numeric values. Please complete or correct the information.";
				trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.area.focus()');
		return false;
		}
	}
	
	var exch = eval('document.' + formname + '.exch.value');
	var phone = eval('document.' + formname + '.phone.value');
	
	if ((exch == "") || (phone == ""))
	{
		var alertString = "Please enter your phone number.";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.exch.focus()');
		return false;
	}
	
	var valid = "0123456789";
	for (var i=0; i < exch.length; i++) {
		temp = "" + exch.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") {
			var alertString = "Your phone number cannot contain non-numeric values. Please complete or correct the information.";
				trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.exch.focus()');
		return false;
		}
	}

	var valid = "0123456789";
	for (var i=0; i < phone.length; i++) {
		temp = "" + phone.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") {
			var alertString = "Your phone number cannot contain non-numeric values. Please complete or correct the information.";
				trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.phone.focus()');
		return false;
		}
	}
	
	var phonenumber = area + exch + phone;
	if (phonenumber.length!=10)
	{
		var alertString = "Please correct your phone number.";
			trackFormError(count, alertString, form);
	 alert ();
	 eval('document.' + formname + '.area.focus()');
	 return false;
	}
		
	// Checks to make sure the email address is valid and not blank	
	var email = eval('document.' + formname + '.email.value');
	if (email == "")
	{
		var alertString = "Please enter your Email address";
			trackFormError(count, alertString, form);
		alert();
		eval('document.' + formname + '.email.focus()');
		return false;
	}

	var emailStr =  document.regform.email.value;
	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 (emailStr == "")
	{
		var alertString = "Please complete or correct your email address. (Fix any symbols or spaces.)";
			trackFormError(count, alertString, form);
		alert();
		document.regform.email.focus();
		return false;
	}
	
	// check for @ and .
	if (matchArray == null)
	{
		var alertString = "Please complete or correct your email address. (Fix any symbols or spaces.)";
			trackFormError(count, alertString, form);
		alert()
		document.regform.email.focus();
		return false;
	}
	
	var user = matchArray[1]
	var domain = matchArray[2]
	var IPArray = domain.match(ipDomainPat)
	
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++)
		{
		if (IPArray[i]>255)
			{
			var alertString = "Please complete or correct your email address. (Fix any symbols or spaces.)";
				trackFormError(count, alertString, form);
		    alert()
			document.regform.email.focus();
			return false;
		    }
		}
		return 
	}
	
	var domainArray=domain.match(domainPat)
	
	if (domainArray==null)
	{
		var alertString = "Please complete or correct your email address. (Fix any symbols or spaces.)"
			trackFormError(count, alertString, form);
		alert()
		document.regform.email.focus();
	    return false;
	}
	
	// checking for valid .com, .org, etc.
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
	{
		var alertString = "Please complete or correct your email address. (Fix any symbols or spaces.)";
			trackFormError(count, alertString, form);
		alert()
		document.regform.email.focus();
		return false;
	}
	
	if (len<2)
	{
		var alertString = "Please complete or correct your email address. (Fix any symbols or spaces.)";
			trackFormError(count, alertString, form);
		var errStr="This address is missing a hostname."
		alert()
		document.regform.email.focus();	
		return false;
	}	
}
