// DON'T REUSE:
// this script doesn't work on IE with forms that
// are formatted using tables: when you use
// the 'elements' property - it will return crap like
// 'table'-s or 'tr'-s instead of 'input' nodes.

function validateForm(thisForm) {
	// alert("validating...");
	if (!document.getElementById) {
		return true;
	}
	
	thisForm = document.getElementById("appr_form");
	if (!thisForm) {
		return true;
	}
	
	if (thisForm) {
		// alert("found form");
		
		for (var i=0; i<thisForm.elements.length; i++) {
			var field = thisForm[i];
			
			if (field.getAttribute("class") == "required") {
				// alert (field + " is req-d");
				if (!field.value || field.value == "") {
					if (field.name == "customer_name") {
						alert ("Please enter your name.");
					} else if (field.name == "customer_phone") {
						alert ("Please enter your telephone number.");
					} else {
						alert("You missed a required field (or fields).\n" +
							"See the boxes that are marked with a star.");
						// field.style.color = "red";
					}
					return false;
				}
			}
		}
	}
}