// JavaScript Document
function GiveAlert(){
alert("All fields are required");
}
	function echeck(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 E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
 		 return true
	}
function CheckInput()
{
var me = document.fr;
  if(me.lat_username.value==""){
    GiveAlert();
    me.lat_username.focus();
    return false;
   }
  if(me.lat_password.value==""){
    alert('ERROR: Empty password.');
    me.lat_password.focus();
    return false;
   }
  if(me.lat_passwordconfirm.value==""){
    alert('ERROR: Empty password.');
    me.lat_passwordconfirm.focus();
    return false;
   }
  if(me.lat_password.value != me.lat_passwordconfirm.value){
    alert('ERROR: Password do  not match!...');
    me.lat_password.focus();
    return false;
   }
   if(me.lat_lastname.value==""){
    GiveAlert();
    me.lat_lastname.focus();
    return false;
   }
  if(me.lat_firstname.value==""){
    GiveAlert();
    me.lat_firstname.focus();
    return false;
   }
  if(me.lat_email.value==""){
    GiveAlert();
    me.lat_email.focus();
    return false;
   }
   
  if(me.lat_address.value==""){
    GiveAlert();
    me.lat_address.focus();
    return false;
   }
  if(me.lat_city.value==""){
    GiveAlert();
    me.lat_city.focus();
    return false;
   }
if(me.lat_state.value==""){
    GiveAlert();
    me.lat_state.focus();
    return false;
   }
  if(me.lat_country.value==""){
    GiveAlert();
    me.lat_country.focus();
    return false;
   }
   
  if(me.lat_companyname.value==""){
    GiveAlert();
    me.coy_name.focus();
    return false;
   }
  if(me.lat_companynamephone.value==""){
    GiveAlert();
    me.lat_companynamephone.focus();
    return false;
   }
  if(me.lat_companynamefax.value==""){
    GiveAlert();
    me.lat_companynamefax.focus();
    return false;
   }
if (echeck(me.lat_email.value)==false)
   {
	me.lat_email.value=""
	me.lat_email.focus();
	return false
  }
return true;
}

function check_login(session){
	if(session=="")
	 {
	 alert("Please login to access this page ");
	 window.location='index.php?Access=FORBIDDEN';
	 return false;	
	 }
	return true;
	}
	
 
function validate_forget(){
 var me = document.fr2;
	 if(me.usr.value==""){
		 alert('ERROR: Empty username');
		 me.usr.focus();
		 return false;
		 }
	 if(me.lat_email.value==""){
		 alert('ERROR: Empty email');
		 me.lat_email.focus();
		 return false;
		 }
if (echeck(me.lat_email.value)==false)
   {
	me.lat_email.value=""
	me.lat_email.focus();
	return false
  }	 
return true	 
}
function vali_ref(){
 var me = document.fr3;
	 if(me.lat_email_subscribe.value==""){
		 alert("ERROR: Empty email");
		 me.lat_email_subscribe.focus();
		 return false; 
		 }
		if (echeck(me.lat_email_subscribe.value)==false)
		   {
			me.lat_email_subscribe.value=""
			me.lat_email_subscribe.focus();
			return false
		  }	 
		return true	 
	}
	
function vali_login()
    {
    var me = document.fr2;
	 if(me.usr.value==""){
		 alert("ERROR: Empty username");
		 me.usr.focus();
		 return false;
		 }
	 if(me.pwd.value==""){
		 alert("ERROR: Empty password");
		 me.pwd.focus();
		 return false;
		 }
	}


