// JavaScript Document

function validateForm(objForm,strRequired,strLabels) {
	arrRequired = strRequired.split(",");
	arrLabels = strLabels.split(",");
	strError = "";
	for (i=0;i<arrRequired.length;i++) {
		// alert("objForm.name: "+objForm.name);
		// alert("objForm.elements.length: "+objForm.elements.length);
		if (!(objForm.elements[arrRequired[i]])) {alert(arrRequired[i]+" does not exist.");}
		if (objForm.elements[arrRequired[i]].name == "strPassword" && objForm.elements[arrRequired[i]].value != "") {
			if (objForm.elements["strPassword"].value != objForm.elements["strPassword2"].value) {
			if (strError != "") {strError = strError + ", ";}
			strError = strError + "Passwords do not match";
			objForm.elements["strPassword"].value = "";
			objForm.elements["strPassword2"].value = "";
			}			
		} else if (objForm.elements[arrRequired[i]].value == "") {
			if (strError != "") {strError = strError + ", ";}
			strError = strError + arrLabels[i];
		}
	}
	if (strError == "") {
		objForm.submit();
	} else {
		alert("You must enter values for the following fields:\n"+strError);
	}
}

function updateCheckBox(objCheckBox,objHidden) {
	if (objCheckBox.checked==true) {objHidden.value="True";} else {objHidden.value="False";}
}

function doAllCheckBoxes(objForm,strName,bValue) {
	for (i=0;i<objForm.elements.length;i++) {if (objForm.elements[i].name == strName) {objForm.elements[i].checked = bValue;}}
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}