// JavaScript Document
// JavaScript Document
function checkEmail()
 {
 var strEmail, strError, countAtRate, countDot, i; 
 var checkAtRate, checkDot;
 var ValidChars,CountValidChars;
 ValidChars="abcdefghijklmnopqrstuvwxyz0123456789_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
 strEmail = checkEmail.arguments[0];
 countAtRate=0;
 countDot=0;
 CountValidChars=0;
 if (strEmail.length >= 7)
  {  
  for(i=0;i<strEmail.length;i++)
   {
   if(strEmail.charAt(i)=="@")
    countAtRate++;
   if(strEmail.charAt(i)==".")
    countDot++;
   CountValidChars=0;
   for(j=0;j<ValidChars.length;j++)
    {
    if(strEmail.charAt(i)==ValidChars.charAt(j))
     {
     CountValidChars++;
     }
    }
   if(CountValidChars==0)
    {
    strError=0;
    break;
    }       
   }
  }
 checkAtRate=strEmail.indexOf("@",1);
 checkDot=strEmail.indexOf(".",1);
 for(i=1;i<countDot;i++)
  checkDot=strEmail.indexOf(".",checkDot+1);
 if(countAtRate==1 && countDot > 0 && strEmail.length >=7 && strError != 0)
  strError=1;
 else
  strError=0;
 if(checkDot>=strEmail.length-2)
  strError=0;
 if(strEmail.charAt(0)=="@" || strEmail.charAt(strEmail.length-1)=="@")
  strError=0;
 if(strEmail.charAt(0)=="." || strEmail.charAt(strEmail.length-1)==".")
  strError=0;
 if(checkDot < checkAtRate)
  strError=0; 
 
 return strError;
}

function validate_signup()
{
	var dm = document.frm;
 	var strError="";
  	if(dm.txtfname.value=="")
	  strError+="\nFirst Name";
  	if(dm.txtlname.value=="")
	  strError+="\nLast Name";

	if (checkEmail(dm.txtemail.value)==0)
	  strError+="\nValid Email";

	if(strError!="")
	{
	 alert("Please check the missing field(s)\n=================="+strError);	
	 return false;
	}
}

