
function checkForm(oForm, sFields) {
// check to see if all required fields are entered and correct
// returns true or false
// Correctness is determined from checkField function, which should be declared in page script.
// checkField receives a reference to field object to test. It should return true/false.
// If function is not declared in page script then correctness is not tested
// oForm = form object to be examined
// sFields = string of required field names (ids) separated with comma

	var i, ok = true, aFields = sFields.split(",");
	
	with (oForm) {
		for (i in aFields) {
			if (oForm[aFields[i]] != null) {
				if (eval(aFields[i]).value == "") {
					alert("Please complete all required fields!");
					ok = false; break;
				}
				if (window.checkField != null)
					ok = checkField(eval(aFields[i]));
				else
					ok = true;
				if (!ok) break;
			}
		}
		if (ok) return true;
		else {
			eval(aFields[i]).focus();
			if (eval(aFields[i]).tagName != "SELECT") eval(aFields[i]).select();
			return false;
		}
	}	
}
