function FormCheck() {
	this.checkFields = new Array();
	this.checkboxGroups = new Array();
	this.fieldLookup = new Array();
		
	this.AddCheckField = AddCheckField
	this.AddCheckboxGroup = AddCheckboxGroup;
	this.ValidateForm = ValidateForm;
}

function AddCheckField(fieldName, fieldDescription) {
	this.checkFields.push(fieldName)
	this.fieldLookup[fieldName] = fieldDescription;
}

function AddCheckboxGroup(groupName, groupDescription) {
	this.checkboxGroups.push(groupName)
	this.fieldLookup[groupName] = groupDescription;
}

function ValidateForm(formObject, buttonObject, sendMessage) {
	var i, j, x, inputList, inputChecked;
	var errorMessage = '';
	
	if (this.checkboxGroups.length > 0) {
		inputList = formObject.getElementsByTagName('INPUT');
		for (j = 0; j < this.checkboxGroups.length; j++) {
			fieldName = this.checkboxGroups[j];
			inputChecked = false;
			for (x = 0; x < inputList.length; x++) {
				if (inputList[x].type == 'checkbox') {
					if (inputList[x].checked) inputChecked = true;
				}
			}
			if (!inputChecked) errorMessage += "\n"+this.fieldLookup[fieldName];
		}
	}
	
	if (this.checkFields.length > 0) {
		for (i = 0; i < this.checkFields.length; i++) {
			fieldName = this.checkFields[i];
			if (formObject[fieldName].value == '') {
				errorMessage += "\n"+this.fieldLookup[fieldName];
			}
		}
	}
	
	if (errorMessage == '') {
		if (buttonObject && sendMessage) {
			buttonObject.style.display = 'none';
			document.getElementById(sendMessage).style.display = '';
		}
		formObject.submit();
	} else {
		alert("The following fields have not been completed:\n"+errorMessage);	
	}
}
