function TrimString(str) {
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function isEmpty(TmpString) {
	if (!TmpString) {
		return true;
	}
	TmpString = TrimString(TmpString);
	if (TmpString.length <= 0) {
		return true;
	}
	return false;
}

function ShowError(Errors) {
	Errors = Errors.toLowerCase();
	alert("The following error(s) occurred:\n" + Errors.substring(Errors,Errors.length-1) + "\n\nSorry can not Process the form");
	return false;
}

function formControls() {
	if (document.getElementById("EmailAddress")) {
		email = document.getElementById("EmailAddress");
		email.onkeyup = new Function("checkEmailAddress()");
	}
}

function focusValues(formElement, val) {
	if (formElement.value == val) {
		formElement.value = "";
	}
}

function blurValues(formElement, val) {
	if (formElement.value == "") {
		formElement.value = val;
	}
}

function checkEmailAddress() {
	var outcome = false;
	var string = document.getElementById("EmailAddress").value;
	stringLength = string.length;
	if (stringLength >= 1) {
		whiteSpace = stringContains(string, " ");
		atSign = stringContains(string, "@");
		bullet = stringContains(string, ".");
		if ((stringLength >= 3) && (!whiteSpace) && (atSign) && (bullet)) {
			outcome = true;	
		}
		showFormResponse("Email", outcome);
	} else {
		showFormResponse("Email", "");
	}
}


function showFormResponse(errorElement,response) {
	responseBox = errorElement + "Result";
	responseText = "";
	validBox = "valid" + errorElement;
	document.getElementById(validBox).value = makeBool(response);
	if ((response === false) || (response === true)) {
		responseText = "<img src=\"images/icons/" + response + ".gif\" width=\"15\" height=\"15\" alt=\"" + response + "\" title=\"" + response + "\" />"
	}
	document.getElementById(responseBox).innerHTML = responseText;
}

function submitForm(FormName) {
	document.getElementById(FormName).submit();
}
