function verify(f) {
	var msg = "";
	var empty_fields = "";

	for(var i = 0; i < f.length; i++) {
		var e = f.elements[i];
		if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {
		
			// first check if the field is empty
			if ((e.value == null) || (e.value == "")) {
				if ((!e.id) || (e.id=="")) { empty_fields = e.name; }
				else { empty_fields = e.name; }
				break;
			}
		}
		else if ((e.type == "select-one") && (!e.optional)) {
			// Check drop down lists
			if ((e.value == null) || (e.value == "")) {
				if ((!e.id) || (e.id=="")) { empty_fields = e.name; }
				else { empty_fields = e.name; }
				break;
			}
		}
	}

	// Now, if there were any errors, display the messages, and
	// return false to prevent the form from being submitted.
	// Otherwise return true.
	if (!empty_fields) return true;

	if (empty_fields) {
		msg = "You forgot to fill out a required field.";
		//msg += "The following required field is empty: " + empty_fields;
		e.focus();
	}
	alert(msg);
	return false;
}

