// function to remove leading & trailing spaces from a string
function trim(strField)
{
   //Count Leading Spaces 
   for(loop = 0, space = 0; strField.substr(loop, 1) == " " && loop < strField.length; loop++, space++);
   //Remove Leading Spaces 
   strField = strField.substr(space, (strField.length-space));
	
   //Count Trailing Spaces 
   for(loop = strField.length, space = 0; strField.substr(loop-1, 1) == " " && loop > 0; loop--,space++);
   //Remove Trailing Spaces 
   strField = strField.substr(0, strField.length-space);

   //Return Trimed String
   return strField;
}
whitespace = "\t \n\r";
function isEmptyString(s)
{
   var i;
   if((s == null) || (s.length == 0)) return true;
   for(i=0;i < s.length;i++)
   {
      var currchar = s.charAt(i);
  	  if(whitespace.indexOf(currchar) == -1) return false;
   }
   return true;
}

function isEmail(strEmail)
{
  if ((strEmail==null) || (strEmail.length==0))
  {
	return true;
  }
  if (isEmptyString(strEmail)) return false;
  var i=1;
  var nLength=strEmail.length;
  while((parseInt(i) < parseInt(nLength)) && (strEmail.charAt(parseInt(i)) != '@'))
  {
	i++;
  }
  if ((parseInt(i) >= parseInt(nLength)) || (strEmail.charAt(i)!="@"))
  {
    return false;	
  }	
  else i+=2;
  while((i<nLength) && (strEmail.charAt(i)!="."))
  {
	i++;
  }
  if ((i>=nLength-1) || (strEmail.charAt(i)!="."))
  {
	return false;	
  }	
  else return true;		
}