function check_form() {
	var msg = "";
	var em_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("name","phone","subject","message");
		// 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 == "") {
				fld_disp = fields_to_check[i];
				switch(fld_disp) {
					case "name":
						em_txt = "Name\n";
						break;
					case "phone":
						em_txt = "Phone\n";
						break;
					case "subject":
						em_txt = "Subject\n";
						break;
					case "message":
						em_txt = "Message\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='#abbfd9'");
				}
			}
		}
	}
	
	if (!isEmail(document.form1.email.value)) {
		em_msg = em_msg + "Your email address is not formatted properly\n";
		bg = eval("document.form1.email.style.backgroundColor='#abbfd9'");
	} else {
		em_msg = em_msg;
	}
	
	if ( (msg == "") && (em_msg == "") ){
		return true;
	} else { 
		msg = "The following information was missing or incorrect:\n\n" + msg + em_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;
}
