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;
}

function validate_email(emailEl) {
	if (emailEl.value.length == 0) { 
		emailEl.focus(); 
		alert("Please enter your email."); 
		return false; 
	}
	if (-1 == emailEl.value.indexOf("@")) {
		emailEl.focus(); 
		alert("Your email must have a '@'."); 
		return false; 
	}
	if (-1 != emailEl.value.indexOf(",")) { 
		emailEl.focus(); 
		alert("Your email must not have a ',' in it"); 
		return false; 
	}
	if (-1 != emailEl.value.indexOf("#")) { 
		emailEl.focus(); 
		alert("Your email must not have an '#' in it."); 
		return false; 
	}
	if (-1 != emailEl.value.indexOf("!")) { 
		emailEl.focus(); 
		alert("Your email must not have a '!' in it." ); 
		return false; 
	}
	if (-1 != emailEl.value.indexOf(" ")) { 
		emailEl.focus(); 
		alert("Your email must not have a space in it." ); 
		return false; 
	}
	if (emailEl.value.length == (emailEl.value.indexOf("@")+1)) {
		emailEl.focus();
		alert("Your email must have a domain name after the '@'.");
		return false;
	}
	return true;
}