var DisableExitLog = false;



function trim(Form){
	for (var i = 0; i < Form.elements.length; i++) {
		if ((Form.elements[i].type == "text") || (Form.elements[i].type == "password") || (Form.elements[i].type == "textarea")) {
			Form.elements[i].value = Form.elements[i].value.replace(/\s+$|^\s*/g, "")
		}
	}
}



function validateSSN(SSN) {
	if (SSN.search(/^\d{3}-\d{2}-\d{4}$|^\d{9}$/) == -1) {return false}
	return true;
}


		
function validateDate(month, day, year) {
	if ((month == "") || (day == "") || (year == "")) {return false}
	if ((month == 2) && (day > 29)) {return false}
	else if ((month == 2) && (day == 29) && (year % 4 != 0)) {return false}
	else if (((month == 4) || (month == 6) || (month == 9) || (month == 11)) && (day > 30)) {return false}
	return true;
}




function validateZIP (ZIP) {
	if ((ZIP.search(/^\d{5}$/) == -1) && (ZIP.search(/^\d{5}-\d{4}$/) == -1) && (ZIP.search(/^\d{9}$/) == -1)) {return false}
	else {return true}
}




function validateEmail (Email) {
	if (Email.search(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/) == -1) {return false}
	else {return true}
}



function getInputArray (NamePattern, Container) {
	var temp = new Array(0);
	for (i = 0; i < Container.elements.length; i++) {
		if (Container.elements[i].name.search(NamePattern) != -1) {
			temp[temp.length] = Container.elements[i];
		}
	}
	return temp;
}



function confirmDelete() {
	return confirm("Delete?");
}



function logExit()
{
	/*
	if (DisableExitLog) {return}
	var Port = document.location.port;
	var TargetURL = "http://" + document.location.hostname;
	if (Port != "")
	{
		TargetURL += ":" + Port;
	}
	TargetURL += "/LogExit.aspx";
	window.open(TargetURL, "", "width=200, height=100, status=yes, menubar=no, toolbar=no, scrollbars=yes, resizable=yes");
	*/
}



function logAppCompleted()
{
	var Port = document.location.port;
	var TargetURL = "http://" + document.location.hostname;
	if (Port != "")
	{
		TargetURL += ":" + Port;
	}
	TargetURL += "/LogAppCompleted.aspx";
	window.open(TargetURL, "", "width=10, height=10, status=no, menubar=no, toolbar=no, resizable=yes");
	window.focus();
}



function submitForm(EventTarget)
{
	if (event.keyCode == 13 && typeof(Page_ClientValidate) == 'function')
	{
		if (Page_ClientValidate())
		{
			doPostBack(EventTarget, '');
		}
	}
}



function doPostBack(eventTarget, eventArgument) {
	var theform;
	theform = document.forms[0];
	theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
	theform.__EVENTARGUMENT.value = eventArgument;
	theform.submit();
}