//Copyright(c) 1999-2006 Lending, Universe Inc.
//PURPOSE: client-side form field validation code
//	This set of function are general includes for validation
//	They are designed in pairs the validation and the event function
//	the event function will call the validation with the event src
//PARAMETERS:    
//CALLED FROM:
//CREATED:                   
//MODIFIED: 12/21/99    new email check and added validCurrency()
//MODIFIED: 01/27/99    modified all
// 04/20/2000	- min pass length is now 6chars
// 10/04/2000 - ValidPhone()
// 11/09/2000 - ValidPhone() modified to allow "+" characters	
// 11/30/2000 - new function ValidState_Country()
// 01/31/2001 - bug fix in ValidCurrency() and ValidNumeric() functions
// 03/07/2001 - changes to ensure compatibility with WebTV browsers:
//            - replaced extended properties "Trim" and "toSimpleForm"
//   because WebTV does not support "Object.prototype()"
// 04/27/2001 - added NoQuotes() function
// 06/05/2001 - modified ValidPhone() function to allow "x" and "X"
// 06/27/2001 - modified ValidCurrency() and ValidNumber() to give more
//   instructions to users
// 07/10/2001 - ValidCurrency() - check if value fits the range allowed 
//   for money data type
// 11/12/2001 - changed "must not" to "may NOT" in alerts
// 01/04/2001 - modified ValidEmail() function to prevent users from 
//   entering "," and ";" characters
// 01/10/2002 - modified ValidEmail() function to prevent users from 
//   entering ">" and "<" characters
// 03/27/2002 - modified ValidPhone() to say "Phone may contain only 
//   numbers 0 to 9 and ()/-+xX"
// 04/26/2002 - added ValidLastName() function
// 06/27/2002 - changed the warning messsage:
//                “XXX must be at most Y characters long.” to:
//                “XXX may not be more than Y characters long.”
// 12/16/2002 - added ValidUsername and ValidPassword functions
// 06/26/2003 - added ValidZip_USA() function
// 07/24/2003 - modifed ValidState_Country() to use new state_region_code
// 09/08/2003 - bug fixed in ValidCountryStateRegionSelection()
// 02/15/2005 - added ValidWebPageName() function
// 03/09/2006 - added IsTooLong() function

/////////////////////////////////////////////////////////////////////
// DefaultValue
/////////////////////////////////////////////////////////////////////
function DefaultValue(item) {
	var strDefault = item.defaultValue;
	if (strDefault==null || strDefault=="") {
		strDefault="";
	}	
	return strDefault;
}
/////////////////////////////////////////////////////////////////////
// TrimString
/////////////////////////////////////////////////////////////////////
function TrimString(strValue) {
	var ichar, icount;
	ichar = strValue.length - 1;
	icount = -1;
	while (strValue.charAt(ichar)==' ' && ichar > icount)
		--ichar;
	if (ichar!=(strValue.length-1))
		strValue = strValue.slice(0,ichar+1);
	ichar = 0;
	icount = strValue.length - 1;
	while (strValue.charAt(ichar)==' ' && ichar < icount)
		++ichar;
	if (ichar!=0)
		strValue = strValue.slice(ichar,strValue.length);
	return strValue;
}
/////////////////////////////////////////////////////////////////////
// DateToSimpleForm
/////////////////////////////////////////////////////////////////////
function DateToSimpleForm(dtItem) {
	var toSimpleForm = new String;
	toSimpleForm = dtItem.toLocaleString();
	toSimpleForm = toSimpleForm.substring(0,toSimpleForm.indexOf(' '));
	return toSimpleForm;
}
/////////////////////////////////////////////////////////////////////
// NonBlank
/////////////////////////////////////////////////////////////////////
function NonBlank(item, item_name) {
	var strErrorMsg = item_name + " must have a non-blank value.";
	item.value = TrimString(item.value);
	if (item.value.length==0) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	return true;
}

/////////////////////////////////////////////////////////////////////
// IsStringTooLong
/////////////////////////////////////////////////////////////////////
function IsStringTooLong(item, max_len, item_name) {
	var sErrorMsg = item_name + " may not be more than " + max_len + " characters long.";

 	if (item.value.length>max_len) {
		item.focus();
		alert(sErrorMsg);
		return true;
	}
		
	return false;
}

/////////////////////////////////////////////////////////////////////
// NoSpaces
/////////////////////////////////////////////////////////////////////
function NoSpaces(item, item_name) {
	var strErrorMsg = item_name + " may NOT have spaces.";
	item.value=TrimString(item.value);
	
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == ' ') {
			item.focus();
			alert(strErrorMsg);
			return false;
		}}
  return true;
}
/////////////////////////////////////////////////////////////////////
// NoQuotes
/////////////////////////////////////////////////////////////////////
function NoQuotes(item, item_name) {
	var strErrorMsg = item_name + " may NOT have quotation-marks.";
	var strErrorMsg2 = item_name + " may NOT have ampersand (&) characters.";
	item.value=TrimString(item.value);
	
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "'" || item.value.charAt(intLoop) == '"') {
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}

	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "&") {
			item.focus();
			alert(strErrorMsg2);
			return false;
		}
	}
	  
  return true;
}
/////////////////////////////////////////////////////////////////////
// PasswordLenghtMin
/////////////////////////////////////////////////////////////////////	
function PasswordLenghtMin(item, item_name) {
	var strErrorMsg = item_name + " must be at least 6 characters long.";
	item.value=TrimString(item.value);
	if (item.value.length<6) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	return true;
}
/////////////////////////////////////////////////////////////////////
// PasswordLenghtMax
/////////////////////////////////////////////////////////////////////
function PasswordLenghtMax(item, item_name) {
	var strErrorMsg = item_name + " may not be more than 50 characters long.";
	item.value=TrimString(item.value);
	if (item.value.length>50) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidNumber
/////////////////////////////////////////////////////////////////////
function ValidNumber(item, item_name) {
	var strErrorMsg = item_name + " must be a valid numeric." +
	      "\nMake sure that you do not to use period(.) or comma(,) , enter just a number. For example 300000"; 
	
	var strDefault = DefaultValue(item);
	if (strDefault.length==0) {
		strDefault="0";
	}
	item.value=TrimString(item.value);
	if (item.value.length==0)
		item.value=0;
		
	var num = ".0123456789";
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (num.indexOf(item.value.charAt(intLoop)) == -1) {
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}
	if (item.value.indexOf(".")!=item.value.lastIndexOf(".")) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidHours
/////////////////////////////////////////////////////////////////////
function ValidHours(item, item_name) {
	var strErrorMsg = item_name;
	if (!ValidNumber(item, item_name))
		return false;
	var itemValue = new Number(item.value);
	if ((itemValue < 0 || itemValue > 80)) {
		item.focus();
		alert(strErrorMsg + " must have a value from 0 to 80 hours.");
		return false;
	}
	itemValue *= 4;
	if ((itemValue)!=Math.ceil(itemValue)) {
		item.focus();
		alert(strErrorMsg + " must be a valid quartely increment.");
		return false;
	}
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidDate
/////////////////////////////////////////////////////////////////////
function ValidDate(item, item_name) {
	var strErrorMsg = item_name;
	if (isNaN(Date.parse(item.value))) {
		item.focus();
		alert(strErrorMsg + " must be a valid Date.");
		return false;
	}
	var dtItem = new Date(Date.parse(item.value));
	item.value = DateToSimpleForm(dtItem);
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidDate2
/////////////////////////////////////////////////////////////////////
function ValidDate2(item, item_name) {
	var strErrorMsg = item_name;
	if (isNaN(Date.parse(item.value))) {
		item.focus();
		alert(strErrorMsg + " must be a valid Date.");
		return false;
	}
	var dtItem = new Date(Date.parse(item.value));
	item.value = DateToSimpleForm(dtItem);
	return true;
}
/////////////////////////////////////////////////////////////////////
// ItemSelected
/////////////////////////////////////////////////////////////////////
function ItemSelected(item, item_name) {
	var strErrorMsg = item_name + " must be a valid selection.";
	if (item.selectedIndex==0) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	return true;
}
/////////////////////////////////////////////////////////////////////
// IsChecked
/////////////////////////////////////////////////////////////////////
function IsChecked(item, item_name) {
	var iCount = 0;
	var sErrorMsg = "";
	if (item_name != "") sErrorMsg = item_name + " must be a valid selection.";
	
	for (var i = 0; i < item.length; i++) {
	 	if (item[i].checked == true) {
	 		iCount = iCount + 1;
		}
	}	
	
	if (iCount == 0) {
		if (sErrorMsg != "") alert(sErrorMsg);
		return false;
	}

	return true;
}
/////////////////////////////////////////////////////////////////////
// IsValueChecked
/////////////////////////////////////////////////////////////////////
function IsValueChecked(item, iValue) {
	var iCount = 0; 
	
	for (var i = 0; i < item.length; i++) {
	 	if ((item[i].checked == true) && (item[i].value == iValue)) {
	 		return true;
		}
	}	

	return false;;
}
/////////////////////////////////////////////////////////////////////
// GetCheckedValue
/////////////////////////////////////////////////////////////////////
function GetCheckedValue(item, default_value) {
	var iCount = 0; 
	var iValue = default_value;
	
	for (var i = 0; i < item.length; i++) {
	 	if (item[i].checked == true) {
	 		iCount = iCount + 1;
	 		iValue = item[i].value;
		}
	}	

	return iValue;
}
/////////////////////////////////////////////////////////////////////
// ValidState_Country
/////////////////////////////////////////////////////////////////////
function ValidState_Country(itemState, itemCountry) {
	var strErrorMsg = 'Please correct State/Province or Country.';
	var iState = itemState.options[itemState.selectedIndex].value;
	var iCountry = itemCountry.options[itemCountry.selectedIndex].value;
	
	var bIsStateRegionInUSA = false;
	var bIsStateRegionInCanada = false;

	if (iState >= 84000000 && iState <= 84099999) {
		bIsStateRegionInUSA = true;
	}
	if (iState >= 12400000 && iState <= 124999999) {
		bIsStateRegionInCanada = true;
	}

	// country = USA, region not in USA
	if (iCountry == 840 && bIsStateRegionInUSA == false) {
		itemState.focus();
		alert('State/Province is required for USA and Canada. ' + strErrorMsg);
		return false;
	}
	// country = Canada, region not in Canada
	if (iCountry == 124 && bIsStateRegionInCanada == false) {
		itemState.focus();
		alert('State/Province is required for USA and Canada. ' + strErrorMsg);
		return false;
	}
	// country != USA/Canada, region in USA/Canada
	if ((iCountry != 840 && iCountry != 124) && (bIsStateRegionInUSA || bIsStateRegionInCanada)) {
		itemState.focus();
		alert(strErrorMsg);
		return false;
	}

	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidZip
/////////////////////////////////////////////////////////////////////
function ValidZip(item, item_name) {
	var strErrorMsg = item_name + " must be of the form 99999-9999.";
	item.value = TrimString(item.value);
	if (item.value.length==0) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}

	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidZip_USA
/////////////////////////////////////////////////////////////////////
function ValidZip_USA(item, item_name) {
	var strErrorMsg = item_name + " must be a valid zip code.";
	
	item.value=TrimString(item.value);
	
	if (item.value.length < 3) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}
		
	var num = "0123456789";
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (num.indexOf(item.value.charAt(intLoop)) == -1) {
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}

	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidSSN
/////////////////////////////////////////////////////////////////////
function ValidSSN(item, item_name) {
	var strErrorMsg = item_name + " must be a valid SSN.";
	item.value = TrimString(item.value);
	if (item.value.length==0) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}

	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidEmail
/////////////////////////////////////////////////////////////////////
function ValidEmail(item, item_name) {
	var strErrorMsg = item_name + " is not a valid Email.";
	var i = 0;
	var iLen;
	var vTmp;
	
	item.value = TrimString(item.value);
	iLen = item.value.length;

	// it must be at least 5 characters long (x@x.x)
	if (iLen < 5)
	{
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	
	// check if there are any invalid characters
	for (i = 0; i < iLen; i++)
	{
		vTmp = item.value.charAt(i);
		if (vTmp == ' ' || vTmp == ',' || vTmp == ';' || vTmp == '<' || vTmp == '>')
		{
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}
	
	// "@" must exist and cannot be the first or the last character
	i = item.value.indexOf("@");
	if (i < 1 || i == (iLen - 1))
	{
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	
	if (item.value.substr(0,1)=="." || item.value.substr(i-1,1) == "." || item.value.substr(i+1,1) == "." || item.value.substr(iLen-1,1) == ".")
	{
		item.focus();
		alert(strErrorMsg);
		return false;
	}

	if (item.value.indexOf("..")>-1 || item.value.indexOf("@@") > -1)
	{
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidCurrency
/////////////////////////////////////////////////////////////////////
function ValidCurrency(item, item_name, minValue) {
	var minV = minValue;
	var cCURRENCY_MAX_ALLOWED = 922337203685477;
	var strErrorMsg = item_name + " must be a valid currency." +
	      "\nMake sure that you do not to use period(.) or comma(,) , enter just a number. For example 300000"; 
	      	
	if (minV != null) {
	   strErrorMsg = item_name + " must be a valid currency greater than " + minValue + "." +
			 "\nMake sure that you do not to use period(.) or comma(,) , enter just a number. For example 300000"; 
	}
	   
	var strDefault = DefaultValue(item);
	if (strDefault.length==0) {
		strDefault="0";
	}
	item.value=TrimString(item.value);
	if (item.value.length==0)
		item.value=0;
	// remove leading $ sign if exists
	if (item.value.charAt(0) == "$")  item.value = item.value.substr(1);	
	
	//remove separating commas
	var sTemp="";
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
	    sTemp += ((item.value.charAt(intLoop)!=',')?item.value.charAt(intLoop):"");
	}
	item.value=sTemp;
	
	var num = ".0123456789";
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (num.indexOf(item.value.charAt(intLoop)) == -1) {
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}
	if (item.value.indexOf(".")!=item.value.lastIndexOf(".")) {
		item.focus();
		alert(strErrorMsg);
		return false;
	}

	if (item.value > cCURRENCY_MAX_ALLOWED) {
		item.focus();
		alert(item_name + " is too large.\nThe maximum value allowed for " + item_name + " is " + cCURRENCY_MAX_ALLOWED + ".");
		return false;
	}
	
	if ((minV != null) && (item.value < minV)) {
		item.focus();
		alert(item_name + " must be a valid currency greater than " + minValue + ".")
		return false;
	}
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidPhone
/////////////////////////////////////////////////////////////////////
function ValidPhone(item, item_name) {
	var sTmp;
	var strErrorMsg = item_name + ' may contain only numbers 0 to 9 and ()/-+xX';
	
	var strDefault = DefaultValue(item);
	if (strDefault.length==0) {
		strDefault='';
	}

	item.value=TrimString(item.value);

	if (item.value.length==0)
		item.value=strDefault;
	
	var num = '0123456789()/-+xX';
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		sTmp = item.value.charAt(intLoop)
		if (num.indexOf(item.value.charAt(intLoop)) == -1 && sTmp != ' ')
		{
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}

	if (item.value.length<10) {
		alert(item_name + ' may not be less than 10 characters long.');
		return false;
	}
	
	return true;
}
/////////////////////////////////////////////////////////////////////
// G2Z
/////////////////////////////////////////////////////////////////////
function G2Z(item, item_name) {
	var strErrorMsg = item_name + " must be non zero value.";
	var strDefault = item.value;
	var fDefault = parseFloat(strDefault)
	
	if (!(fDefault>0.0)) {
		item.focus();
		alert(strErrorMsg);
		return false;	
	}
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidLastName
/////////////////////////////////////////////////////////////////////
function ValidLastName(item, item_name) {
	item.value = TrimString(item.value);

	if (item.value.length==0) {
		item.focus();
		alert(item_name + ' must have a non-blank value.');
		return false;
	}

	if (item.value.length<2) {
		item.focus();
		alert(item_name + ' must be at least 2 characters long.');
		return false;
	}

	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidUsername
/////////////////////////////////////////////////////////////////////
function ValidUsername(item, item_name) {
	var strErrorMsg = "";
	item.value=TrimString(item.value);

	// check is blank
	if (item.value.length==0) {
		strErrorMsg = item_name + " must have a non-blank value.";
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	
	// check for spaces	
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == ' ') {
			strErrorMsg = item_name + " may NOT have spaces.";
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}
		
	// check for quotes
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "'" || item.value.charAt(intLoop) == '"') {
			strErrorMsg = item_name + " may NOT have quotation-marks.";
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}

	// check for "&"
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "&") {
			strErrorMsg = item_name + " may NOT have ampersand (&) characters.";
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}
		
	// check for "()"
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "(" || item.value.charAt(intLoop) == ")") {
			strErrorMsg = item_name + " may NOT have brackets.";
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}
		
	if (item.value.length<6) {
		strErrorMsg = item_name + " must be at least 6 characters long.";
		item.focus();
		alert(strErrorMsg);
		return false;
	}

	if (item.value.length>50) {
		strErrorMsg = item_name + " may not be more than 50 characters long.";
		item.focus();
		alert(strErrorMsg);
		return false;
	}
			
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidPassword
/////////////////////////////////////////////////////////////////////
function ValidPassword(item, item_name) {
	var strErrorMsg = "";
	item.value=TrimString(item.value);

	// check is blank
	if (item.value.length==0) {
		strErrorMsg = item_name + " must have a non-blank value.";
		item.focus();
		alert(strErrorMsg);
		return false;
	}
	
	// check for spaces	
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == ' ') {
			strErrorMsg = item_name + " may NOT have spaces.";
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}
		
	// check for quotes
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "'" || item.value.charAt(intLoop) == '"') {
			strErrorMsg = item_name + " may NOT have quotation-marks.";
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}

	// check for "&"
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "&") {
			strErrorMsg = item_name + " may NOT have ampersand (&) characters.";
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}
		
	// check for "()"
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "(" || item.value.charAt(intLoop) == ")") {
			strErrorMsg = item_name + " may NOT have brackets.";
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}

	if (item.value.length<6) {
		strErrorMsg = item_name + " must be at least 6 characters long.";
		item.focus();
		alert(strErrorMsg);
		return false;
	}

	if (item.value.length>50) {
		strErrorMsg = item_name + " may not be more than 50 characters long.";
		item.focus();
		alert(strErrorMsg);
		return false;
	}
		
	return true;
}
/////////////////////////////////////////////////////////////////////
// ValidWebPageName
/////////////////////////////////////////////////////////////////////
function ValidWebPageName(item, item_name) {
	var strErrorMsg = item_name + ' cannot contain any of the following characters:\n \\ / | . : ; , ! ? " < > & = + * ( ) [ ] { } % # $ @';
	var bErrorExists = false;
	
	item.value=TrimString(item.value);
	
	for (var intLoop = 0; intLoop < item.value.length; intLoop++) {
		if (item.value.charAt(intLoop) == "\\")  bErrorExists = true
		if (item.value.charAt(intLoop) == "/")  bErrorExists = true
		if (item.value.charAt(intLoop) == "|")  bErrorExists = true
		if (item.value.charAt(intLoop) == ".")  bErrorExists = true
		if (item.value.charAt(intLoop) == ":")  bErrorExists = true
		if (item.value.charAt(intLoop) == ";")  bErrorExists = true
		if (item.value.charAt(intLoop) == ",")  bErrorExists = true
		if (item.value.charAt(intLoop) == "!")  bErrorExists = true
		if (item.value.charAt(intLoop) == "?")  bErrorExists = true
		if (item.value.charAt(intLoop) == "'" || item.value.charAt(intLoop) == '"') bErrorExists = true
		if (item.value.charAt(intLoop) == "<")  bErrorExists = true
		if (item.value.charAt(intLoop) == ">")  bErrorExists = true
		if (item.value.charAt(intLoop) == "&")  bErrorExists = true
		if (item.value.charAt(intLoop) == "=")  bErrorExists = true
		if (item.value.charAt(intLoop) == "+")  bErrorExists = true
		if (item.value.charAt(intLoop) == "*")  bErrorExists = true
		if (item.value.charAt(intLoop) == "(")  bErrorExists = true
		if (item.value.charAt(intLoop) == ")")  bErrorExists = true
		if (item.value.charAt(intLoop) == "[")  bErrorExists = true
		if (item.value.charAt(intLoop) == "]")  bErrorExists = true
		if (item.value.charAt(intLoop) == "{")  bErrorExists = true
		if (item.value.charAt(intLoop) == "}")  bErrorExists = true
		if (item.value.charAt(intLoop) == "%")  bErrorExists = true
		if (item.value.charAt(intLoop) == "#")  bErrorExists = true
		if (item.value.charAt(intLoop) == "$")  bErrorExists = true
		if (item.value.charAt(intLoop) == "@")  bErrorExists = true
	}

	if (bErrorExists == true)
	{
		item.focus();
		alert(strErrorMsg);
		return false;
	}		
	 
	return true;
}

