function verify(form) {
	var msg = "";
	var empty_fields = "";
	var errors = "";

	required = new Array();
	required[0] = new Array("q01a", "1. First Name", 0);
	required[1] = new Array("q01c", "1. Last Name", 0);
	required[2] = new Array("q02", "2. Address", 0);
	required[3] = new Array("q03", "3. City", 0);
	required[4] = new Array("q04", "4. State", 0);
	required[5] = new Array("q05", "5. Zip", 0);
	required[6] = new Array("q06", "6. Primary Telephone", 0);
	required[7] = new Array("q08", "8. Primary Email", 1);
	required[8] = new Array("q14", "14. The school where I teach", 0);
	required[9] = new Array("q17", "17. Grade Level and Concentration Area", 0);
	required[10] = new Array("q23", "23. Attened TAA previously?", 0);
	required[11] = new Array("q24", "24. Area attended previously", 0);
	required[12] = new Array("q25", "25. Years attended", 0);
        
	for (i=0; i < required.length; i++) {
		var f = required[i][0];
		var l = required[i][1];
		var e = required[i][2];
		if (f == null) { continue; }
		var n = form[f]
		if (!(n)) {
			var bad_field_message = "invalid field: " + f;
			alert(bad_field_message);
			return false;
		}
		// Radio & Checkbox Groups
		if ((n[0] != null) && ((n[0].type == "radio") || (n[0].type == "checkbox"))) {
			var option = 0;
			for (j=0; j < n.length; j++) {
				if (n[j].checked == true) option = 1;
			}
			if (option == 0) { empty_fields += "\n     " + l; }
		}
		// Solitary Radio Buttons & Checkboxes
		if (((n.type == "radio") || (n.type == "checkbox")) && (n.checked == false)) {
			empty_fields += "\n     " + l;
		}
		if ((n.type == "select") || (n.type == "select-one") || (n.type == "select-multiple")) {
			if ((n.selectedIndex == 0) || (n.selectedIndex == -1)) { empty_fields += "\n     " + l; }
		}
		if ((n.type == "text") || (n.type == "textarea") || (n.type == "password")) {
			if ((n.value == null) || (n.value == "")) {
				empty_fields += "\n     " + l;
			}
		}
		if ((e == "1") && (n.value) && (bad_e(n.value))) { // check for invalid email fields.
			errors += "The field " + l + " must be a valid E-mail address.\n";
		}
	}
        if (!empty_fields && !errors) {
		pw1 = form.q08.value;
		pw2 = form.q08x.value;
		if (pw1 != pw2) {
			alert ("\nYou either did not enter the same Primary e-mail twice or the two e-mails do not match. Please re-enter your Primary e-mail twice and make certain both entries match.");
			return false;
		}
		return true;
        } else {
		if (empty_fields) { // if there are errors or empty fields, print the alert.
			msg = "You are required to fill the following field(s): " + empty_fields + "\n";
			if (errors) msg += "\n";
		}
		msg += errors;
		alert(msg);
		return false;
	}
}
function bad_e(input) {
	invalidChars = " /:,;"
	for (var i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (input.indexOf(badChar,0) > -1) return true;
	}
	atPos = input.indexOf("@",1)
	if (atPos == -1) return true;
	if (input.indexOf("@",atPos+1) != -1) return true;
	periodPos = input.indexOf(".",atPos)
	if (periodPos == -1) return true;
	if (periodPos+3 > input.length) return true;
	return false;
}
