function validateEmailForm(someForm) {
	if (EFBrowser.ie || (EFBrowser.ns && !EFBrowser.ns4)) clearForm(someForm);
	currentErrorMessage = "";
	if (!window.allFields) allFields = createFieldsHash(someForm["all_fields"], "|");
	var reqFields = getRequiredFields(someForm);
	var badFields = getMissingReqs(reqFields);
	if (badFields.length) {
		currentErrorMessage = getErrorMessage(ERROR_ENTERREQUIREDDATA + "\n\n", badFields);
		if (EFBrowser.ie || (EFBrowser.ns && !EFBrowser.ns4)) changeFieldColor(badFields, yellow);
		alert(currentErrorMessage);
		if (badFields[0].focus) badFields[0].focus();
		return false;
	}
	if (window.dataValidation) badFields = _validate_GenericFieldData(someForm, dataValidation);
	if (badFields.length) {
		currentErrorMessage = getErrorMessage(ERROR_ENTERVALIDDATA + "\n\n", badFields);
		if (EFBrowser.ie || (EFBrowser.ns && !EFBrowser.ns4)) changeFieldColor(badFields, yellow);
		alert(currentErrorMessage);
		if (badFields[0].focus) badFields[0].focus();
		return false;
	}
	return true;
}

// create a hash of field names to labels from a comma delimited list:
// key, value, key, value, etc...
function createFieldsHash(field, delim) {
	var fieldHash = new Array();
	if (field) {
		var nameLabelList = field.value.split(delim);
		for (var i=0; i<nameLabelList.length; i+=2) fieldHash[nameLabelList[i]] = nameLabelList[i+1];
	}
	return fieldHash;
}
// this function includes support for the old 'required_fields' hidden input with a list of
// names and labels as well as support for a new list which only contains a comma delimited
// list of required field names
function getRequiredFields(someForm) {
	var reqFields = new Array();
	if (window.reqFieldNames) {
		for (var j=0; j<reqFieldNames.length; j++) {
			// pass along required form fields
			if (someForm[reqFieldNames[j]] && someForm[reqFieldNames[j]].type != "hidden") reqFields[reqFields.length] = someForm[reqFieldNames[j]];
			// pass along required collections of form fields too, as defined by createCollection();
			else if (window.minNumCollection && minNumCollection[reqFieldNames[j]]) reqFields[reqFields.length] = minNumCollection[reqFieldNames[j]];
		}
	} else if (someForm["required_fields"]) {
		var nameLabelList = someForm["required_fields"].value.split(",");
		for (var i=0; i<nameLabelList.length; i+=2) {
			// pass along required form fields
			if (someForm[nameLabelList[i]] && someForm[nameLabelList[i]].type != "hidden") reqFields[reqFields.length] = someForm[nameLabelList[i]];
			// pass along required collections of form fields too, as defined by createCollection();
			else if (window.minNumCollection && minNumCollection[nameLabelList[i]]) reqFields[reqFields.length] = minNumCollection[nameLabelList[i]];
		}
	}
	return reqFields;
}

function getErrorMessage(messageText, fieldList) {
	var pluralRE = new RegExp("\\{PLURAL\\}", "g");
	var esRE = new RegExp("\\{ES\\}", "g");
	var esontRE = new RegExp("\\{ESONT\\}", "g");
	var errMsg = (fieldList.length > 1) ? messageText.replace(pluralRE, "s") : messageText.replace(pluralRE, "");
	errMsg = (fieldList.length > 1) ? errMsg.replace(esRE, "es ") : errMsg.replace(esRE, "'");
	errMsg = (fieldList.length > 1) ? errMsg.replace(esontRE, "e sont") : errMsg.replace(esontRE, "'est");
	//this is a hack which executes if the allFields hash does not exist for some reason
	if (!window.allFields) return errMsg;
	//get nice names from allFields hash
	for (var i=0; i<fieldList.length; i++) {
		var fieldName = (typeof fieldList[i] == "string") ? fieldList[i] : ((fieldList[i].name) ? fieldList[i].name : ((fieldList[i].length) ? fieldList[i][0].name : "unknown"));
		errMsg += (allFields[fieldName]) ? "     * " + allFields[fieldName] + "\n" : "     * " + fieldName + "\n";
	}
	return errMsg;
}

// DEPRECATED, SEE BUG 36812 FOR MORE DETAILS
function onlyOne(clickedCheckbox, otherCheckbox) {
	if (!clickedCheckbox.checked) return;
	if (otherCheckbox && otherCheckbox.checked) otherCheckbox.checked = false;
}

// DEPRECATED, SEE BUG 36812 FOR MORE DETAILS
function validPrivacyPolicy(agreeCheckbox, optoutCheckbox) {
	if (!agreeCheckbox) return true;
	if (isChecked(agreeCheckbox)) return true;
	if (!optoutCheckbox) {
		alert(ERROR_PRIVACYPOLICYAGREE);
		return false;
	} else if (!isChecked(optoutCheckbox)) {
		alert(ERROR_PRIVACYPOLICYSELECT);
		return false;
	}
	return true;
}