function checkForm(objForm, arrFields, arrPlainText)
{
	//alert(arrFields);
	//alert(arrPlainText);

	//Create arrays of the incoming parameters
	theFields = new String(arrFields);
	//Trim any spaces after the delimiter or the array isn't recognized
	trimTheFields = new String(theFields.replace('| ', '|'))
	arrTheFields = trimTheFields.split("|");

	thePlainText = new String(arrPlainText);
	trimThePlainText = new String(thePlainText.replace('| ', '|'))
	arrThePlainText = trimThePlainText.split("|");
	
	// Enter name of mandatory fields
	var fieldRequired = arrTheFields;
	// Enter field description to appear in the dialog box
	var fieldDescription = arrThePlainText;
	// dialog message
//	alert(fieldRequired);
//	alert(fieldDescription);

	var alertMsg = "Please complete the following fields:\n\n";
	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++)
	{
		
		var obj = objForm.elements[fieldRequired[i]];
		if (obj) 
		{
//			alert(obj.type);
		
			switch(obj.type) 
			{
			case "select-one":
//				alert(obj.selectedIndex);
//				alert(obj.options[obj.selectedIndex].text);
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" || obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == "select one")
				{
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1)
				{
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
//				alert(obj.value);
				if (obj.value == "" || obj.value == null)
				{
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "textarea":
				if (obj.value == "" || obj.value == null)
				{
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "checkbox":
				var blnchecked = false;
				if (document.getElementById(fieldRequired[i]).checked == true)
				{
					blnchecked = true;
				}
				
				if (!blnchecked)
				{
					document.getElementById(fieldRequired[i]).value = "0";
					alertMsg += " - " + fieldDescription[i] + "\n";
				}	
			default:
			}
		}
	}
	
	if (alertMsg.length == l_Msg)
	{
		return true;
	}
	else
	{
		alert(alertMsg);
		return false;
	}
}

//The form validation, uses checkForm() above
function doValidation(theForm, theButton, arrFields, arrPlainText) {
	
	//alert(checkForm(theForm, arrFields, arrPlainText));
	
	if (checkForm(theForm, arrFields, arrPlainText)) 
		{
		//alert(checkForm(theForm, arrFields, arrPlainText));
		theButton.disabled=true;
		theButton.value='Updating...';
		return true;
		}
	else {
	return false;
	}
}

function checkBlanks(theField, theIndicator, theExclusions, theMin, theMax){
	//Check all funding source, except the exclusions
	for (var i=theMin; i <= theMax ; i++){
//		alert('theIndicator+i ='+theIndicator+i);
//		alert('theField+i='+theField+i);
		if(document.getElementById(theIndicator+i).checked==true) {
			if(document.getElementById(theField+i).value == "") {
			alert('if you check a box, the corresponding field must be filled out.')
			return false;
			break;
			}
		}	
	}
}

