function validateForm(formControls)
{
	var errorMessages = new Array();
	var firstControl = null;

	for(var i=0, l=formControls.length; i<l; i++)
	{
		var control = formControls[i];
		var parsedControl = $(control.id);
		if (parsedControl == null) continue;
		
		// If radio or checkbox, need to look at all of them
		var hasValue = false;
		if (parsedControl.type == "radio" || parsedControl.type == "checkbox")
		{
			var ipts = $(parsedControl.form).getInputs(parsedControl.type, control.id);
			for (var j=0; j<ipts.length; j++)
			{
				if (ipts[j].checked)
				{
					hasValue = true;
					break;
				}
			}
		}
		else
		{
			var val = $F(control.id);
			if (val && val.strip)
			{
				val = val.strip();
			}
			hasValue = (val && val.length > 0);
		}

		if (control.isMandatory && !hasValue)
		{
			errorMessages[errorMessages.length] = " - \"" + control.caption + "\" is required.";
			if (firstControl == null)
				firstControl = $(control.id);
		}
		
		if (hasValue && control.dataType != null && !control.dataType.test(val))
		{
			errorMessages[errorMessages.length] = " - " + (control.message ? control.message : "\"" + control.caption + "\" is not valid.");
			if (firstControl == null)
				firstControl = $(control.id);
		}
		
		var dateValue;
		if (hasValue && (control.minDate || control.maxDate))
		{
			// Get the value as a date
			try { dateValue = new Date(val); }
			catch (e) { errorMessages[errorMessages.length] = " - \"" + control.caption + "\" must be a valid date."; }
		}
		if (dateValue)
		{
			if (control.minDate && control.maxDate && (dateValue < control.minDate || dateValue > control.maxDate))
			{
				errorMessages[errorMessages.length] = " - \"" + control.caption + "\" must be between " + control.minDateFriendly + " and " + control.maxDateFriendly + ".";
			}
			else if (control.minDate && dateValue < control.minDate)
			{
				errorMessages[errorMessages.length] = " - \"" + control.caption + "\" must be at least " + control.minDateFriendly + ".";
			}
			else if (control.maxDate && dateValue > control.maxDate)
			{
				errorMessages[errorMessages.length] = " - \"" + control.caption + "\" must not be later than " + control.maxDateFriendly + ".";
			}
		}
	}
	if (errorMessages.length == 0) return true;

	// Set focus to the first element
	if (firstControl != null) firstControl.activate();

	alert("The following problems were found when attempting to submit the form:\n\n" + errorMessages.join("\n"));
	return false;
}
