function validate(form) {
	invalid = [];			
	$A(form.getElementsByTagName('input')).each( 
		function(input) {
			if ($(input).hasClassName('required')) {
				// $F( ) does not work for checkboxes
				if ((input.type == 'checkbox' && !input.checked) || $F(input).blank()) {
					invalid.push(input);
					label = input.parentNode.getElementsByTagName('label');
					if (label.length != 1) { //if field has a label, add class to the label...
						$(input).addClassName('invalid');
					}
					//...otherwise, add to the input itself.
					else {
						$(label[0]).addClassName('invalid'); 
					}
				}
				else {
					$(input).removeClassName('invalid');
					label = input.parentNode.getElementsByTagName('label');
					$(label[0]).removeClassName('invalid');
				}
			}
		}
	); 
	if (invalid.length > 0)  { 
		alert("Please fill out the required form " + ((invalid.length ==1)?"field":"fields") + " highlighted in red before submitting the form.");	
		return false
	}
	else { return true; }
	
}
