// Copyright information must stay intact
// FormCheck v1.02
// Copyright NavSurf.com 2002, all rights reserved
// For more scripts, visit NavSurf.com at http://navsurf.com

function formCheck(formobj){
	// name of mandatory fields
	var fieldRequired = Array("Passcode", "Name", "Kind", "Fees", "Address1", "City", "State", "Zip", "Phone", "Email", "Description");
	// field description to appear in the dialog box
	var fieldDescription = Array("Password", "Organization Name", "Kind", "Fees", "Address 1", "City", "State", "Zip", "Phone", "Email", "Description");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	var defaultColor = "#FFFFFF"
	var errorColor = "#FFCCCC"
	
	var l_Msg = alertMsg.length;
var x = 0;	
for (var i = 0; i < formobj.elements.length; i++) {
	var obj = formobj.elements[i];
	if (obj.name.indexOf(fieldRequired[x]) > -1 && obj.type.indexOf("hidden") == -1) {
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[x] + "\n";
					obj.style.backgroundColor = errorColor;
				}
				else {obj.style.backgroundColor = defaultColor}
				break;
			case "select-multiple":
				if (obj.selectedIndex == 0){
					alertMsg += " - " + fieldDescription[x] + "\n";
					obj.style.backgroundColor = errorColor;
				}
				else {obj.style.backgroundColor = defaultColor}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[x] + "\n";
					obj.style.backgroundColor = errorColor;
				}
				else if (obj.name.indexOf("Email") > -1) {
					if (obj.value.indexOf("@") == -1 || obj.value.indexOf(".") == -1) {
						alertMsg += " - " + fieldDescription[x] + " requires a valid email address." + "\n";
						obj.style.backgroundColor = errorColor;
					}
					else {obj.style.backgroundColor = defaultColor}
				}
				else {obj.style.backgroundColor = defaultColor}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[x] + "\n";
					obj.style.backgroundColor = errorColor;
				}
				else {obj.style.backgroundColor = defaultColor}
			}
		}
		x++;
	}
}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}