function emailValidate(emailStr)
{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@._-";
  var checkStr = emailStr;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
     {
       if (ch == checkOK.charAt(j))
        break;
       if (ch == " ")
        break;
     }
     if (j == checkOK.length)
     {
      allValid = false;
      break;
     }
  }
  if (!allValid)
  {
    return ("Please enter only valid characters in the \"Email-Id\" field.");
  }
  checkStr = emailStr;
  allValid = false;
  var space = true;
  var ctr = 0;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == "@" )
		{
			if (!(i==0) && !(i==emailStr.length-1))
			{
				allValid = true;
				break;
			}
		}
  }
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == " " )
		{
			space = false;
			break;
		}
  }
  if (!allValid)
  {
    return ("Please enter a valid email id");
  }
  if (!space)
  {
    return ("Please enter a valid email id");
  }
  var ctr = 0;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == "@")
		{
			ctr++;
		}
  }
  if (ctr >= 2)
  {
    return ("Please enter a valid email id");
  }
  checkStr = emailStr;
  allValid = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == ".")
    {
			if (!(i==0) && !(i==emailStr.length-1))
			{
  			allValid = true;
				break;
      }
    }
  }
  if (!allValid)
  {
      return ("Please enter a valid email");
  }
  return ("");
}

function emailValidateRegExp(emailStr)
{
		var retval=false;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(emailStr))
		{
			retval=true;
		}
		else
		{
			retval=false;
		}
		return (retval);
}
