<!--
function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}

function checkForm() {
	var bgBad = "yellow";
  	var bgGood = "white";

	// check subject
	if (document.form1.thesubject.value == "") {
		alert ("Please select a topic.");
		return false;
	}

	// check name
	if (document.form1.fullname.value == "") {
		alert ("Please enter your full name.");
		document.form1.fullname.select();
		document.form1.fullname.focus();
		if (document.all) {setColor(form1.fullname, bgBad)}
		return false;
	}
	else {
		if (document.all) {setColor(form1.fullname, bgGood);}
	}

	// check company name
	if (document.form1.company.value == "") {
		alert ("Please enter your company affiliation.");
		document.form1.company.select();
		document.form1.company.focus();
		return false;
	}
	
	
	// check email
	if (!validateEmail(document.form1.email)) return false;


	// check how someone was referred
	if (document.form1.whatsworking.value == "") {
		alert ("Please let us know how you found us.");
		return false;
	}

	window.open ("thanks.html","thanks","scrollbars=no,resizable=no,toolbar=no,status=no,width=312,height=235")

}

function validatePhone(field,tempCountry) {
	// check for invalid characters
	var valid = "-0123456789"
	var ok = "yes";
	var temp;
	var dashes=0;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") {
		alert("Invalid entry!  Only numbers and dashes (optional) are accepted!");
		field.focus();
		field.select();
		return false;
	}
	// check for proper number of digits
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "0") dashes++;
	}
	var numbers=field.value.length-dashes;
	if ((tempCountry=="United States" || tempCountry=="Canada") && numbers!=10) {
		alert("Please check your US phone number");
		field.focus();
		field.select();
		return false;
	}
	return true;
}


function validateEmail(field) {

	emailStr=field.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 + ")"
	// The following pattern describes the structure of the user
	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)")
		field.focus();
		field.select();
		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.")
		field.focus();
		field.select();
	    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!")
		field.focus();
		field.select();
			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.")
		field.focus();
		field.select();
	    return false
	}
	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) {
	   // 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.")
		field.focus();
		field.select();
	   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)
		field.focus();
		field.select();
	   return false
	}

	return true;
}

//-->