<!--
var letterexp = /[^a-z ]/i;
var nameexp = /^\w[^a-z \.,]/i;
var zipexp = /[^a-z\d ]/i;
var charexp = /[^a-z\d# _\-!:;?%$,&'"*\.]/i;
var telexp = /[^\d-. +]/
var urlexp = /[^a-z\d_\.]/i;
var numexp = /[^\d. ]/
var intexp = /[^\d ]/


function hasLetter(str) {
	return (!(letterexp.test(str) | str==''));
}

function hasName(str) {
	return (!(nameexp.test(str) | str==''));
}

function hasTel(str) {
	return (! (telexp.test(str) | str=='') );
}

function hasURL(str) {
	return (!(urlexp.test(str) | str==''));
}

function hasChar(str) {
	return (! (charexp.test(str) | str=='') );
}

function hasZip(str) {
	return (! (zipexp.test(str) | str=='') );
}

function isNumber(str) {
	return (! (numexp.test(str)) );
}

function isInt(str) {
	return (! (intexp.test(str)) );
}

function CheckRedHerringForm() {
 
	var temp = "";
	
	if (!hasName(document.forms[0].first_name.value)) {temp = temp + "\n   First Name"; }
	if (!hasName(document.forms[0].last_name.value)) {temp = temp + "\n   Last Name"; }
	if (!hasTel(document.forms[0].phone.value)) {temp = temp + "\n   Phone";}
	
	if (temp != "") {
		temp = "The following fields require valid entries: " + temp + ".";
		alert(temp);
		return false;
		}
	
		// update URL with appropriate parameters
	var name = document.forms[0].first_name.value + ' ' + document.forms[0].last_name.value
	var email = document.forms[0].email.value
	
	var url = document.forms[0].retURL.value + '?name=' + name + '&email=' + email + '&formtype=roi';
	
	//alert(url);
	document.forms[0].retURL.value = url;

	return true;
}

function CheckYankeeForm() {
 
	var temp = "";

	if (!hasName(document.contact.first_name.value)) {temp = temp + "\n   First Name"; }
	if (!hasName(document.contact.last_name.value)) {temp = temp + "\n   Last Name"; }
	if (!hasTel(document.contact.phone.value)) {temp = temp + "\n   Phone";}
	if (!emailCheck(document.contact.email.value)) {temp = temp + "\n   Email Address";	}
	
	if (temp != "") {
		temp = "The following fields require valid entries: " + temp + ".";
		alert(temp);
		return false;
		}
	
		// update URL with appropriate parameters
	var name = document.contact.first_name.value + ' ' + document.contact.last_name.value;
	var email = document.contact.email.value;
	
	var url = document.contact.retURL.value + '?name=' + name + '&email=' + email + '&formtype=yankee';
	
	//alert(url);
	document.contact.retURL.value = url;
	
	return true;
}

function CheckSecurityForm() {
 
	var temp = "";

	if (!hasName(document.forms[0].first_name.value)) {temp = temp + "\n   First Name"; }
	if (!hasName(document.forms[0].last_name.value)) {temp = temp + "\n   Last Name"; }
	if (!hasTel(document.forms[0].phone.value)) {temp = temp + "\n   Phone";}
	if (!emailCheck(document.forms[0].email.value)) {temp = temp + "\n   Email Address";	}
	
	if (temp != "") {
		temp = "The following fields require valid entries: " + temp + ".";
		alert(temp);
		return false;
		}
	
		// update URL with appropriate parameters
	var name = document.forms[0].first_name.value + ' ' + document.forms[0].last_name.value;
	var email = document.forms[0].email.value;
	
	var url = document.forms[0].retURL.value + '?name=' + name + '&email=' + email + '&formtype=security';
	
	//alert(url);
	document.forms[0].retURL.value = url;
	
	return true;
}

function CheckCommentForm() {
 
	var temp = "";
	
	if (!emailCheck(document.comment.email.value)) {temp = temp + "\n   Email Address";	}
	if (!hasChar(document.comment.description.value)) {temp = temp + "\n   Comment/Question"; }
	if (temp != "") {
		temp = "The following fields require valid entries: " + temp + ".";
		alert(temp);
		return false;
		}
			
		// update URL with appropriate parameters
	var email = document.comment.email.value;
	
	var url = document.comment.retURL.value + '&email=' + email + '&formtype=comment';
	
	//alert(url);
	document.comment.retURL.value = url;
	
	return true;

}

function CheckFormResellers() {
 
	var temp3 = "";
	var temp = "";
	var temp2 = "";
	
	if (!hasName(document.reseller.first_name.value)) {temp = temp + "\n   First Name"; }
	if (!hasName(document.reseller.last_name.value)) {temp = temp + "\n   Last Name"; }
	if (!hasChar(document.reseller.company.value)) {temp = temp + "\n   Company Name"; }
	if (!emailCheck(document.reseller.email.value)) {temp = temp + "\n   Email Address";	}
	if (!hasTel(document.reseller.phone.value)) {temp = temp + "\n   Phone";}

	if (temp != "" | temp3 != "") {
		if (temp != "") {temp = "The following fields require valid entries: " + temp + ".";}
		alert(temp3 + temp);
		return false;
		}
	
		// update URL with appropriate parameters
	var name = document.reseller.first_name.value + ' ' + document.reseller.last_name.value
	var email = document.reseller.email.value
	
	var url = document.reseller.retURL.value + '?name=' + name + '&email=' + email + '&formtype=reseller';
	
	//alert(url);
	document.reseller.retURL.value = url;
		return true;
}

function CheckFormSupport() {
 
 	var temp = "";

	if (!hasName(document.support.name.value)) {temp = temp + "\n   Contact Name"; }
	if (!hasChar(document.support.company.value)) {temp = temp + "\n   Company"; }
	if (!emailCheck(document.support.email.value)) {temp = temp + "\n   Email Address";	}
	if (!hasTel(document.support.phone.value)) {temp = temp + "\n   Phone";}
	if (!hasChar(document.support.subject.value)) {temp = temp + "\n   Subject"; }
	//if (!hasChar(document.support.description.value)) {temp = temp + "\n   Description"; }

	var temp_desc = document.support.description.value
	
	if (temp_desc.length == 0) {temp = temp + "\n   Description"; }
	
	if (temp != "") {
		temp = "The following fields require valid entries: " + temp + ".";
		alert(temp);
		return false;
		}
		
	return true;
}

function CheckQuoteForm() {
 
	var temp = "";
		
	if (!hasName(document.quote.first_name.value)) {temp = temp + "\n   First Name"; }
	if (!hasName(document.quote.last_name.value)) {temp = temp + "\n   Last Name"; }
	if (!hasTel(document.quote.phone.value)) {temp = temp + "\n   Phone";}
	if (!emailCheck(document.quote.email.value)) {temp = temp + "\n   Email Address";	}
	if (!hasChar(document.quote.title.value)) {temp = temp + "\n   Job Title"; }
	if (!hasChar(document.quote.company.value)) {temp = temp + "\n   Company"; }
	if (!hasChar(document.quote.city.value)) {temp = temp + "\n   City"; }
	if (!hasChar(document.quote.state.value)) {temp = temp + "\n   State"; }

	if (temp != "") {
		if (temp != "") {temp = "The following fields require valid entries: " + temp + ".";}
		alert(temp);
		return false;
		}
	
		// update URL with appropriate parameters
	var name = document.quote.first_name.value + ' ' + document.quote.last_name.value
	var email = document.quote.email.value
	
	var formtype = document.quote.formtype.value;
	
	var url = document.quote.retURL.value + '?name=' + name + '&email=' + email + '&formtype=quote';
	
	//alert(url);
	document.quote.retURL.value = url;
	return true;
}



function CheckContactForm() {
 
	var temp = "";
		
	if (!hasName(document.contact.first_name.value)) {temp = temp + "\n   First Name"; }
	if (!hasName(document.contact.last_name.value)) {temp = temp + "\n   Last Name"; }
	if (!hasTel(document.contact.phone.value)) {temp = temp + "\n   Phone";}
	if (!emailCheck(document.contact.email.value)) {temp = temp + "\n   Email Address";	}
	if (!hasChar(document.contact.title.value)) {temp = temp + "\n   Job Title"; }
	if (!hasChar(document.contact.company.value)) {temp = temp + "\n   Company"; }
	if (!hasChar(document.contact.city.value)) {temp = temp + "\n   City"; }
	if (!hasChar(document.contact.state.value)) {temp = temp + "\n   State"; }

	if (temp != "") {
		if (temp != "") {temp = "The following fields require valid entries: " + temp + ".";}
		alert(temp);
		return false;
		}
	
		// update URL with appropriate parameters
	var name = document.forms[0].first_name.value + ' ' + document.forms[0].last_name.value
	var email = document.forms[0].email.value
	
	var formtype = document.forms[0].formtype.value;
	
	var url = document.forms[0].retURL.value + '?name=' + name + '&email=' + email + '&formtype=' + formtype;
	
	//alert(url);
	document.forms[0].retURL.value = url;
	return true;
}

function CheckComdexForm() {
 
	var temp = "";
		
	if (!hasName(document.contact.first_name.value)) {temp = temp + "\n   First Name"; }
	if (!hasName(document.contact.last_name.value)) {temp = temp + "\n   Last Name"; }
	if (!hasTel(document.contact.phone.value)) {temp = temp + "\n   Phone";}
	if (!emailCheck(document.contact.email.value)) {temp = temp + "\n   Email Address";	}

	if (temp != "") {
		if (temp != "") {temp = "The following fields require valid entries: " + temp + ".";}
		alert(temp);
		return false;
		}
	
	return true;
}

function CheckUnsubscribeForm() {
 
	var temp = "";
		
	if (!hasName(document.contact.first_name.value)) {temp = temp + "\n   First Name"; }
	if (!hasName(document.contact.last_name.value)) {temp = temp + "\n   Last Name"; }
	if (!emailCheck(document.contact.email.value)) {temp = temp + "\n   Email Address";	}
	if (!hasChar(document.contact.company.value)) {temp = temp + "\n   Company"; }

	if (temp != "") {
		if (temp != "") {temp = "The following fields require valid entries: " + temp + ".";}
		alert(temp);
		return false;
		}
	
		// update URL with appropriate parameters
	var name = document.forms[0].first_name.value + ' ' + document.forms[0].last_name.value;
	var email = document.forms[0].email.value;
	
	var url = document.forms[0].retURL.value + '?name=' + name + '&email=' + email + '&formtype=unsubscribe';
	
	//alert(url);
	document.forms[0].retURL.value = url;
	return true;
}


function CheckNewsletterForm() {
 
	var temp = "";
		
	if (!emailCheck(document.EmailForm.email.value)) {temp = temp + "\n   Email Address";	}
	
	if (temp != "") {
		if (temp != "") {temp = "The following fields require valid entries: " + temp + ".";}
		alert(temp);
		return false;
		}
	return true;
}


function emailCheck(emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	/* alert("Email address seems incorrect (check @ and .'s)") */
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    /* alert("The username doesn't seem to be valid.") */
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        /* alert("Destination IP address is invalid!") */
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	/* alert("The domain name doesn't seem to be valid.") */
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
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>4) {
   // the address must end in a two letter or three letter word.
   /* alert("The address must end in a three-letter domain, or two letter country.") */
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   /* alert(errStr) */
   return false
}

// If we've gotten this far, everything's valid!
return true;
}
