// JavaScript Document
 var whitespace = " \t\n\r";
function isEmpty(s) {
	return ((s == null) || (s.length == 0));
}
          
          function isWhitespace (s) {

		var i;

		// Is s empty?
		if (isEmpty(s)) return true;

		// Search through string's characters one by one
		// until we find a non-whitespace character.
		// When we do, return false; if we don't, return true.
		for (i = 0; i < s.length; i++)
		{
				// Check that current character isnt whitespace.
				var c = s.charAt(i);

				if (whitespace.indexOf(c) == -1) return false;
		}

		// All characters are whitespace.
		return true;
}
function checkEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		     return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}


function is_numeric(s)
{
var numericExpression = /^[0-9]+$/;
	if(s.match(numericExpression)){
	return true;
	}
	else
	{
	return false;
	}
}

function performvalid(theform)
{

    if(theform.Fname.value=="")
    {
         alert("Please enter your first name");
         theform.Fname.focus();
		theform.Fname.value='';
         return(false);
    }
    if(theform.Lname.value=="")
    {
         alert("Please enter your last name");
         theform.Lname.focus();
		 theform.Lname.value='';
         return(false);
    }
	if(theform.Organisation.value=="")
    {
         alert("Please enter your organization's name");
         theform.Organisation.focus();
		 theform.Lname.value='';
         return(false);
    }
	if(theform.Designation.value=="")
    {
         alert("Please enter your Designation");
         theform.Designation.focus();
		 theform.Designation.value='';
         return(false);
    }
	if(theform.Qualification.value=="")
    {
         alert("Please enter your qualifiction name");
         theform.Qualification.focus();
		 theform.Qualification.value='';
         return(false);
    }
    if(theform.txtdob.value=="")
    {
         alert("Please enter your Birth date");
         theform.txtdob.focus();
		 theform.txtdob.value='';
         return(false);
    }
    
    if(theform.ResStreet.value=="")
    {
         alert("Please enter your street name");
         theform.ResStreet.focus();
		 theform.ResStreet.value='';
         return(false);
    }
    if(theform.ResCity.value=="")
    {
         alert("Please enter your city name");
         theform.ResCity.focus();
		 theform.ResCity.value='';
         return(false);
    }

    if(theform.ResState.value=="")
    {
         alert("Please enter your state name");
         theform.ResState.focus();
		 theform.ResState.value='';
         return(false);
     }
      if(theform.ResCountry.value=="")
    {
         alert("Please enter Your country name");
         theform.ResCountry.focus();
		 theform.ResCountry.value='';
         return(false);
     }
	 
	 if(theform.ResZip.value=="" || (!is_numeric(theform.ResZip.value)))
    {
         alert("Please enter your Zip number");
         theform.ResZip.focus();
		 theform.ResZip.value='';
         return(false);
    }
	 
	  if(theform.ResPhone.value=="" || (!is_numeric(theform.ResPhone.value)))
    {
         alert("Please enter correct phone number");
         theform.ResPhone.focus();
		 theform.ResPhone.value='';
         return(false);
    }
	 if(!checkEmail(theform.Email.value)) 
    {
		alert("Please enter correct e-mail address");
		theform.Email.focus();
		theform.Email.value='';
		return false;
	} 
	if(theform.Mobile.value=="" || (!is_numeric(theform.ResPhone.value)))
    {
         alert("Please enter correct mobile number");
         theform.Mobile.focus();
		 theform.Mobile.value='';
         return(false);
    }
	 
	 if(theform.Password.value=="")
    {
         alert("Please enter password");
         theform.Password.focus();
		 theform.Password.value='';
         return(false);
     } 
	 if(theform.CPassword.value=="" ||(theform.CPassword.value != theform.Password.value))
    {
         alert("Your password and confirm password field are not matching");
         theform.CPassword.focus();
		 theform.CPassword.value='';
         return(false);
     } 
   	return true;
  }
