// allow only numbers to be entered in a field
function AllowOnlyNumeric() {

	// Get the ASCII value of the key that the user entered
	var key = window.event.keyCode;

	// Verify if the key entered was a numeric character (0-9)
	if (key > 47 && key < 58) {

		// If it was, then allow the entry to continue
		return;

	} else {
	
		// If it was not, then dispose the key and continue with entry
		window.event.returnValue = null;
	}
}

// allow numbers and decimal point to be entered in a field
function AllowCurrency() {

	// Get the ASCII value of the key that the user entered
	var key = window.event.keyCode;

	// Verify if the key entered was a numeric character (0-9)
	if ((key > 47 && key < 58) || key == 46) {

		// If it was, then allow the entry to continue
		return;

	} else {

		// If it was not, then dispose the key and continue with entry
		window.event.returnValue = null;
	}
}

// trim a string
function trim(strIn) { 
	var i = 0;
	for (i=0;i<strIn.length;i++) {
		if ((strIn.charCodeAt(i)  != 32) && (strIn.charCodeAt(i)  != 10) && (strIn.charCodeAt(i)  != 13)) break;
	}
	strIn = strIn.slice(i);
	for (i=strIn.length-1;i>=0;i--) {
		if ((strIn.charCodeAt(i)  != 32) && (strIn.charCodeAt(i)  != 10) && (strIn.charCodeAt(i)  != 13)) break;
	}
	strIn = strIn.slice(0,i+1);
	return strIn;
}


// make sure only numbers entered in a field
function isInt(strWorkIn) {
	for (i=0; i < strWorkIn.length; i++) {
		if (strWorkIn.charAt(i) >= '0' && strWorkIn.charAt(i) <= '9') {
		} else {
			return false;
		}
	}
	return true;
}

// validate an email address (returns true or false)
function checkEMail (strEMail) {
	var locAt;
	var locPeriod;
	var okEmail;
	
	locAt = strEMail.indexOf('@');
	okEmail = ((locAt != -1) &&
		(locAt != 0) &&
		(locAt != (strEMail.length - 1)) &&
		(strEMail.indexOf('@', locAt + 1 == -1)));
	if (okEmail) {
		locPeriod = strEMail.indexOf('.');
		okEmail = ((locPeriod != -1) && (locPeriod != (strEMail.length)));
	}
	return okEmail;	
}