var decimalPointDelimiter = "."
var defaultEmptyOK = false

function fnNumberCheck(i_Number,c_Field)
{
var i_Countflg
	i_Countflg=0
var	i_Count
var i_Length
i_Length = i_Number.length

	if(i_Number != "") 
	{
					
			for(i_Count=0;i_Count<i_Length;i_Count=i_Count + 1)
			{
			if(isNaN(parseInt(i_Number.substring(i_Count,i_Count+1))))
			{
				
				i_Countflg=i_Countflg + 1
				
				
			}
			}
			
			 if(i_Countflg==1 && i_Number.substring(0,1)=="-")
			{
				alert(c_Field + " can not be negative")
				return 0
			}
			else if(i_Countflg >= 1)
			{
				alert(c_Field + " should be a positive non-decimal Number")
					return 0
			}	
			else
			{
				return 1
			}
		
	}
	else  
	{
		alert(c_Field + " can not be blank")
		return 0
	}
}



function fnIsNumeric(sPassedValue,c_Field)
{
var rRe = new RegExp("[^0-9|\.]")

if(sPassedValue=="")
	{	if(c_Field !="")
		{
			alert(c_Field + " can not be null")
		}
		return false;
	}
if (rRe.test(sPassedValue))
	{
		if(c_Field !="")
		{
			alert(c_Field + " should be a non negative number")
		}
	return false;
	
	}
return true;
}

function fnCheckEmpty(FieldVal)
{
	FieldVal = fnTrim(FieldVal," ");
	if(FieldVal == "")
		return true;
	return false;
}

// Trims all the occurrence of mDelim from mStr 
// in its left
// For Example
// if mStr = "      LTrim" and mDelim = " "
// The Return value will be "LTrim"

function fnLTrim(mStr,mDelim)
{
var sTemp
var rReBeginning
var rReBeginning = new RegExp("^" + mDelim)

sTemp = mStr 

if (mDelim == "")
	return(mStr);

while (rReBeginning.test(sTemp))
	{
	 sTemp=sTemp.replace(rReBeginning,"")
	}
mStr=sTemp ;
return(mStr);	
}

// Trims all the occurrence of mDelim from mStr 
// in its Right
// For Example
// if mStr = "RTrim       " and mDelim = " "
// The Return value will be "RTrim"

function fnRTrim(mStr,mDelim)
{
var sTemp
var rReEnding = new RegExp(mDelim + "$")

sTemp = mStr 
if (mDelim == "")
	return(mStr);
while (rReEnding.test(sTemp))
	{
	 sTemp=sTemp.replace(rReEnding,"")
	}
mStr=sTemp ;
return(mStr);	
}

//Checks whether  sPassedValue is numeric or not



// Trims all the occurrence of mDelim from mStr 
// in both left and right.
// The multiple occurences of mDelim in the middle
// of the string is replaced by one occurrence
// For Example
// if mStr = "  Trim   This       " and mDelim = " "
// The Return value will be "Trim This"

function fnTrim(mStr,mDelim)
{
if (mDelim == "")
	return(mStr);
mStr = fnLTrim(mStr,mDelim)
mStr = fnRTrim(mStr,mDelim)
return(mStr)

/*
code to replace multiple occurrences in the middle with single
occurence
while (rRe.test(mStr))
	{
	mStr = mStr.replace(rRe,mDelim)
	}
*/

}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  // alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		  //  alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true
	}




