function validateField(checkElement) {
	var sValue = checkElement.value;
	while (sValue.charAt(0) == " ")
		sValue = sValue.substr(1, sValue.length-1);
	if  (sValue=="")
	{
		checkElement.style.backgroundColor = "red";
		checkElement.style.color = "white";
		checkElement.focus();
		return false;
	}
	else
	{
		checkElement.style.backgroundColor  = "";
		checkElement.style.color = "";
	}
	checkElement.value = sValue;
	return true;
}

function ValidateForm(form)
{
	var ok = true;

	// These need to be in reverse order, so the topmost invalid field will get the focus
	// since focus() is called in every failed validateField() call.
	for (var i = arguments.length - 1; i > 0; i--)
		if (!validateField(document.getElementById(arguments[i])))
			ok = false;

	if (!ok) {
		alert ("You did not correctly complete the required fields. Please fill out all required fields.");
	}

	return ok;
}