// Set Global Variables
var theSpaces = / /g;
var theChars = /\D/g;
var theNums = /\d/g;
var newWindow;

// Give Focus
function giveFocus(theForm, theField) {
	eval("document.forms[" + theForm + "]." + theField + ".focus()");
}

// Write Email
function writeEmail(theUser, theDomain) {
var theAddress = theUser + "@" + theDomain
	document.write("<A HREF=\"mailto:" + theAddress + "\">" + theAddress + "</A>");
}

// Check Email
function checkEmail(theField) {
var theInvalidChars = /[^A-Za-z0-9._@]/g;
	theField.value = theField.value.replace(theInvalidChars, "");
var theLength = theField.value.length;
var theAt = theField.value.indexOf("@");
var thePeriod = theField.value.lastIndexOf(".");
if (!(theLength < 8 || theAt < 2 || (thePeriod > theLength - 3 || thePeriod < theLength - 5) || theAt > thePeriod - 3)) {
	return true;
	}
}

// Check Password
function checkPassword(theField) {
var theInvalidChars = /[-=;']/g;
	theField.value = theField.value.replace(theSpaces, "");
	theField.value = theField.value.replace(theInvalidChars, "");
if (theField.value.length >= 8 && theField.value.length <= 20) {
	for (i = 0; i <= 9; i++) {
		if (theField.value.indexOf(i) != -1) {
			return true;
			}
		}
	}
}

// Show Error
function showError(theID, theClass, theError) {
if (document.getElementById || document.all) {
	if (document.getElementById) {
		document.getElementById(theID).className = theClass;
		document.getElementById(theID).innerHTML = theError;
		}
	else if (document.all) {
		document.all[theID].className = theClass;
		document.all[theID].innerHTML = theError;
		}
	else {
		alert(theError);
		}
		return false;
	}
}

// Left Trim
function leftTrim(theString) {
	return theString.replace(/^\s*/, "");
}

// Right Trim
function rightTrim(theString) {
	return theString.replace(/\s*$/, "");
}

// Confirm Delete
function confirmDelete(theURL) {
if (confirm("Are you sure you wish to delete this item?\nThis action cannot be undone.")) {
	location.href = theURL;
	}
}