
function CheckNum_Alpha(sString)
{
var nAsciCode, sInputString
sInputString = sString.toString()

for (var i=0; i < sInputString.length; i++)
{
nAsciCode = sInputString.charCodeAt(i)
if (i==0 )
{
 if (nAsciCode <65 || nAsciCode >90 )
 {
  if (nAsciCode <97 || nAsciCode >122 )
  { return false
  }
 }
}
else
{
if (nAsciCode < 48 || nAsciCode >57 ) 
{
  if (nAsciCode <65 || nAsciCode >90 )
  {
   if (nAsciCode !=95)
   {
    if (nAsciCode <97 || nAsciCode >122 )
    {
		
		return false
	}
   }
  }
}
}
}

return true
}


function CheckNum_Zip(sString)
{
var nAsciCode, sInputString

sInputString = sString.toString()
for (var i=0; i < sInputString.length; i++)
{
nAsciCode = sInputString.charCodeAt(i)
if (nAsciCode < 48 || nAsciCode >57 ) 
{
  return false
}

}

return true
}


function CheckTel_NPANXX(sString)
{
var nAsciCode, sInputString, nLength

sInputString = sString.toString()
nLength = (sInputString.length) * 1
for (var i=0; i < sInputString.length; i++)
{

nAsciCode = sInputString.charCodeAt(i)
if (i==0)
{
  if (nLength <=3) 
  { // check for first digit only in case of NPA or NXX
    // do not force this check if it is the last 4 digit
  	if (nAsciCode <= 48 || nAsciCode >57 ) 
  	{ // 0 not allowed as first digit
    	return false
  	}
  } 
}
else
{
 if (nAsciCode < 48 || nAsciCode >57 ) 
 {
  return false
 }
}
}

return true
}


function CheckEmail(sString)
{
var nAsciCode, sInputString
sInputString = sString.toString()

for (var i=0; i < sInputString.length; i++)
{
nAsciCode = sInputString.charCodeAt(i)
if (i==0 )
{
 if (nAsciCode <65 || nAsciCode >90 )
 {
  if (nAsciCode <97 || nAsciCode >122 )
  { return false
  }
 }
}
else
{
 if (nAsciCode < 45 || nAsciCode >46 ) 
 {
  if (nAsciCode < 48 || nAsciCode >57 ) 
  {
   if (nAsciCode <64 || nAsciCode >90 )
   {
    if (nAsciCode !=95)
    {
     if (nAsciCode <97 || nAsciCode >122 )
     {
		return false
	 } // end 97
    } // end 95
   } // end 65
  } // end 48
 } // end 45
} // end else
} // end for


sInputString = sInputString.toLowerCase()

if (sInputString.lastIndexOf(".com")== -1 )
{ 
 if (sInputString.lastIndexOf(".gov") == -1 )
 { 
   if (sInputString.lastIndexOf(".us") == -1 )
   {
    if (sInputString.lastIndexOf(".net")== -1 )
    { 
     if (sInputString.lastIndexOf(".org") == -1 )
     { 
      if (sInputString.lastIndexOf(".edu") == -1 )
      {
       
        return false
      } // edu
     } // end .org
    }// end .net
   } // end .us
 }// end .gov
} // end .com


return true
}




// extract front part of string prior to searchString 
function getFront(mainStr,searchStr)
{ 
 foundOffset = mainStr.indexOf(searchStr) 
 if (foundOffset == -1) 
 { return null 
 } 
 return mainStr.substring(0,foundOffset) 
} 

// extract back end of string after searchString 
function getEnd(mainStr,searchStr) 
{ 
 foundOffset = mainStr.indexOf(searchStr) 
 if (foundOffset == -1) 
 { return null 
 } 
 return mainStr.substring(foundOffset+searchStr.length,mainStr.length) 
} 

// insert insertString immediately before searchString 
function insertString(mainStr,searchStr,insertStr) 
{ 
 var front = getFront(mainStr,searchStr) 
 var end = getEnd(mainStr,searchStr) 
 if (front != null && end != null) 
 { return front + insertStr + searchStr + end 
 } 
 return null 
} 

// remove deleteString 
function deleteString(mainStr,deleteStr) 
{ 
 return replaceString(mainStr,deleteStr,"") 
} 

// replace searchString with replaceString 
function replaceString(mainStr,searchStr,replaceStr) 
{ 
 var front = getFront(mainStr,searchStr) 
 var end = getEnd(mainStr,searchStr) 
 if (front != null && end != null) 
 { return front + replaceStr + end 
 } 
 return null 
} 



