//<SCRIPT LANGUAGE=javascript>
<!--
function checkTextForNullValue(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
		
	if (objFormElement.value == '') {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}


function checkTextForLen6Value(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
		
	if (objFormElement.value.length < 6) {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}

function checkTextForValidUsername(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
		
	if (!valid_username(objFormElement.value)) {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}




function checkSelectForNullValue(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
	
	if (objFormElement.options[objFormElement.selectedIndex].value == '') {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}

function checkTextForNumericValue(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
		
	if (! IsNumber(objFormElement.value)) {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}

function checkTextForInterestRateValue(objFormElement, strClass, strClassError) {
	var rc;
		
	if (! IsNumber(objFormElement.value)) {
		objFormElement.className = strClassError;
		rc = '\n    Enter a numerical value for the\n    interest rate.';
	} else {
		if (parseInt(objFormElement.value) < .01 || parseInt(objFormElement.value) > 20) {
			objFormElement.className = strClassError;
			rc = '\n    Enter a positive value for the\n    interest rate below 20%.';
		} else {
			objFormElement.className = strClass;
			rc = '';
		}
	}
	return rc;
}


function checkTextForEmailAddr(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
		
	if (!IsEmail(objFormElement.value)) {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}

function IsNumber(Expression) {
	Expression = Expression.toLowerCase();
	RefString = "0123456789.-";

	if (Expression.length < 1) 
		return (false);

	for (var i = 0; i < Expression.length; i++) 
	{
		var ch = Expression.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a == -1)
			return (false);
	}
	return(true);
}

function IsEmail(Expression)
	{
		if (Expression == null)
			return (false);

		var supported = 0;
		if (window.RegExp)
		{
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported) 
			return (Expression.indexOf(".") > 2) && (Expression.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(Expression) && r2.test(Expression));
	}

//-->
//</SCRIPT>
