// JavaScript Document
function fnCheckMail(sFieldValue){
	var nAtPosition=0;            
    var nDotPosition=0;
    var nLength;
    var bValidFlag=false;
    var nLessPos=0;
	sFieldValue=fnTrim(sFieldValue);
	if (sFieldValue.indexOf("<") != -1){
		return true;
	}
	if (sFieldValue.indexOf(">") != -1){
		return true;
	}	
	if (sFieldValue.indexOf(" ") != -1){
		bValidFlag=true;
	}
	else{  
		if (sFieldValue.length<6){
			bValidFlag=true; 
		}
		else{
			nAtPosition=sFieldValue.indexOf("@");
			nDotPosition=sFieldValue.indexOf(".",nAtPosition);
                          
			if ((nAtPosition < 1) || (nDotPosition <=nAtPosition+1)|| (nDotPosition==sFieldValue.length-1)){
				bValidFlag=true; 
			}
		}
	}               
    return bValidFlag;
}

function fnCheckTeleFax(sFieldValue){
	var bValidFlag=false;
	var nLoop;
	sFieldValue=fnTrim(sFieldValue);
	if (sFieldValue.length==0 ){//|| sFieldValue.charAt(0)=="-"){
		return false;
	}
	else{	
		nLength=sFieldValue.length;   
		for(nLoop=0;nLoop<nLength;nLoop++){	
			cChar=sFieldValue.charAt(nLoop);
			if (((cChar>="0") && (cChar <="9")) || (cChar=="-") || (cChar=="+")){
				bValidFlag=false;
			}
			else{
				return true;
			}
		}
		return bValidFlag;
	}		
} // end of fnCheckTeleFax

function fnCheckLength(SFieldValue){
SFieldValue = fnTrim(SFieldValue)
	if (SFieldValue.length > 250)
	{
		return true;
	}
}
function fnCheckNumber(sFieldValue){
	var nLoop;	 
	var bValidFlag=false;
	sFieldValue=fnTrim(sFieldValue);
    if(sFieldValue.length != 0){
		for(nFunLoop=0;nFunLoop<sFieldValue.length;nFunLoop++){
          if ((sFieldValue.charAt(nFunLoop) < "0") || (sFieldValue.charAt(nFunLoop) > "9")){
			bValidFlag=true;
          }
		} 
	}
    else{
		bValidFlag=true;
	} 

    return bValidFlag;
}
function fnTrim(sFieldValue){
	var nLeft;
	var nRight;
	var nLength;
		
	if (sFieldValue.length==0){
		return sFieldValue;
	}
	else{
		nLeft=0;
		nLength=sFieldValue.length;
		while ( (sFieldValue.charAt(nLeft)==" ") && (nLeft < nLength)){
			nLeft=nLeft+1;
		}
		if (nLeft !=nLength){
			nRight=nLength-1;
			while ((sFieldValue.charAt(nRight)==" ") && (nRight > 0 )){
				nRight=nRight-1;
			}
			if (nRight > nLeft){
				nLength=nRight-nLeft+1;
				sFieldValue=sFieldValue.substr(nLeft,nLength);
			}
		}
		else{
			sFieldValue="";
		}
		return sFieldValue;
	}
} // end of fnTrim