function check_form() {
	var msg = "";
	var p=false;
	var d=false;
	with(document.form1) {
		// reset the form bg color
		for(f=0;f<document.form1.length;f++) {
			t = eval("elements["+f+"].type");
			if (t != "checkbox") {
				rbg = eval("elements["+f+"].style.backgroundColor='#FFFFFF'");
			}
		}
		// fields to chck
		fields_to_check = new Array("sweeps_firstnm","sweeps_lastnm","sweeps_email1","sweeps_zip","sweeps_agebox");
		// check the fields in the array
		for(i=0;i<fields_to_check.length;i++) {
			//alert(fields_to_check[i]);
			fld = eval(fields_to_check[i]+".value");
			// missing data -- append to msg variable
			if (fld == "") {
				if (fields_to_check[i] == "sweeps_email1") {
					if (!isEmail(fld)) {
						msg += "Your email address is not formatted properly\n";
						bg = eval(fields_to_check[i]+".style.backgroundColor='#B48A62'");
					}
				} else {
					fld_disp = fields_to_check[i];
					switch(fld_disp) {
						case "sweeps_firstnm":
							em_txt = "First Name\n";
							break;
						case "sweeps_lastnm":
							em_txt = "Last Name\n";
							break;
						case "sweeps_zip":
							em_txt = "Zip\n";
							break;
						case "sweeps_agebox":
							em_txt = "U.S. citizenship and age verification.\n";
							break;
						default:
							em_txt = "";
					}
					msg += em_txt;
					// set the background to a lovely peach color
					t = eval(fields_to_check[i]+".type");
					if (t != "checkbox") {
						bg = eval(fields_to_check[i]+".style.backgroundColor='#B48A62'");
					}
				}
			}
		}
		if (sweeps_agebox.checked){
			ca_msg = ""
		} else {
			ca_msg = "\nYou must verify U.S. citizenship and age to continue.\n";

		}
	}
	if (document.form1.sweeps_email1.value != document.form1.sweeps_email2.value) {
		em_msg = "Please correctly verify your email address.\n";
		bg = eval("document.form1.sweeps_email1.style.backgroundColor='#B48A62'");
		bg = eval("document.form1.sweeps_email2.style.backgroundColor='#B48A62'");
	} else {
		em_msg = "";
	}
	
	if ( (msg == "") && (ca_msg == "")  && (em_msg == "") ){
		return true;
	} else { 
		msg = "The following information was missing or incorrect:\n\n" + msg + em_msg + ca_msg;
		alert(msg);
		return false;
	}
}

function isEmail(email){
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	return re.test(email)
}

function IsNumeric(strString){
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;

	if (strString.length < 9) return false;

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			blnResult = false;
		}
	}
	return blnResult;
}