function gotoReg(){

	if ((validateNames()==true) && (emailLength()==true) && (emailValid(document.popForm.usremail.value)==true) && (pvalid()==true)){
	return true;
}else{
	return false;
}

}


function validateNames(){
	var firstname=document.popForm.f_name.value;
	var lastname=document.popForm.l_name.value;
	
	if (firstname==null || firstname==""){
		alert ("Please enter your First Name");
		document.popForm.f_name.focus();
		return false;
	}

	if (lastname==null || lastname==""){
		alert ("Please enter your Last Name");
		document.popForm.l_name.focus();
		return false;
	}
	return true;
}

function emailLength()
{
  var emailID=document.popForm.usremail.value;

  if ((emailID==null)||(emailID==""))
  {
	  alert("Please enter your Email address.");
	  document.popForm.usremail.focus();
	  return false;
  }
  
  if ((emailID.length < 5))
  {
	  alert("Email address should be a valid one and more than 5 characters.");
	  document.popForm.usremail.focus();
	  return false;
  }
  return true;
}


function emailValid(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 Email address. Please try again.");
	   document.popForm.usremail.focus();
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid Email address. Please try again.");
		document.popForm.usremail.focus();
		return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid Email address. Please try again.");
		document.popForm.usremail.focus();
		return false;
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid Email address. Please try again.");
		document.popForm.usremail.focus();
		return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid Email address. Please try again.");
		document.popForm.usremail.focus();
		return false;
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid Email address. Please try again.");
		document.popForm.usremail.focus();
		return false;
	}
		
	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid Email address. Please try again.");
		document.popForm.usremail.focus();
		return false;
	}
	
	if (str.indexOf(dot)==lstr-1){
		alert("Invalid Email address. Please try again.");
		document.popForm.usremail.focus();
		return false;
	}
	
 	return true;
}


function pvalid()
{ 
  if ((document.popForm.usrpwd.value == null) || (document.popForm.usrpwd.value == ""))
  {
  	alert("Please enter your Password.");
	document.popForm.usrpwd.focus();
    return false;
  }
  
  if (document.popForm.usrpwd.value.length < 5)
  {
    alert("Password should be more than 5 characters. Please try again.");
    document.popForm.usrpwd.value=""
	document.popForm.usrpwd.focus();
    return false;
  }
  return true;
}