// JavaScript Document
function validform(control)
{
  if(control.fname.value=="")
  {
    alert("First name cannot be blank.");
	control.fname.focus();
	return false;
  }
  if(control.lname.value=="")
  {
    alert("Last name cannot be blank.");
	control.lname.focus();
	return false;
  }
  
  if(control.address.value=="")
  {
    alert("Address name cannot be blank.");
	control.address.focus();
	return false;
  }
  
  if(control.city.value=="")
  {
    alert("City name cannot be blank.");
	control.city.focus();
	control.city.select();
	return false;
  }
  
  if(control.state.value=="")
  {
    alert("Please select your state.");
	control.state.focus();
	return false;
  }
  
  if(control.zip.value=="")
  {
    alert("Please specify zip code.");
	control.zip.focus();
	return false;
  }
  if(control.zip.value!="")
   {
     if(isNaN(control.zip.value))
	   {
	    alert("Zip code should be numeric.");
		control.zip.focus();
	    control.zip.select();
		return false;
	   }
	 if(control.zip.value.length!=5)
	   {
	    alert("Zip code should be five digit.");
		control.zip.focus();
	    control.zip.select();
		return false;
	   }
   }
   
  if(control.homephone.value=="")
  {
    alert("Please specify Your homephone.");
	control.homephone.focus();
	return false;
  }
  
  if(control.homephone.value!="")
  {
    if(isNaN(control.homephone.value))
	   {
	     alert("Homephone should be numeric.");
	     control.homephone.focus();
		 control.homephone.select();
	     return false;
	   }
	if(control.homephone.value.length!=10)
	  {
	    alert("Please check your homephone.");
		control.homephone.focus();
		control.homephone.select();
	    return false;
	  }   
  }
  
  if(control.email.value=="")
	{
	  alert("Please specify your email address.");
	  control.email.focus();
      return false;
	}
	else
	{
	 check=ChkEmail("frm","email");
	 if(check==false)
	   {
	      control.email.focus();
		  control.email.select();
		  return false;
	   }
	}
	
  if(control.occupation.value=="")
	{
	  alert("Please specify your occupation.");
	  control.occupation.focus();
      return false;
	}
	
  if(control.annualincome.value=="")
	{
	  alert("Please specify your annual income.");
	  control.annualincome.focus();
      return false;
	}
	
 if(control.networth.value=="")
	{
	  alert("Please specify your networth.");
	  control.networth.focus();
      return false;
	}
	
 if(control.geointerest1.value=="")
	{
	  alert("Please select your graphical interest.");
	  control.geointerest1.focus();
      return false;
	}
	
   if((control.partner[0].checked==false)&&(control.partner[1].checked==false))
	{
	  alert("Please specify will you have a financial or managing partner.");
      return false;
	}						
}

function check(control)
 {
   if(isNaN(control.value))
    {
	  alert("Please enter correctly");
	  control.value="";
	}  
 }
// function for checking mail
function ChkEmail(frmName,strEmail){
		var FormName;
		var FldName;
		FormName=frmName;
		FldName=strEmail;
	    var str=eval("document."+FormName+"."+FldName+".value");
				
		if (str.indexOf("@",1) == -1)
		{
			alert("Please provide an accurate email address.");
			return false;
		}
		if (str.indexOf("@",1)== 0)
		{
			alert("Please provide an accurate email address.");
			return false;
		}
		if (str.indexOf(".")== 0)
		{
			alert("Please provide an accurate email address.");
			return false;
		}
		if (str.indexOf(".",1) == -1)
		{
			alert("Please provide an accurate email address.");
			return false;
		}
		
		// extra validation
		var posat=str.indexOf("@");
		var posdot=str.indexOf(".");
		var rposdot=str.lastIndexOf(".");
		if(rposdot==posdot)
		if((posdot < posat) || (posdot-posat < 3))
		{
			alert("Please provide an accurate email address.");
			return false;
		}
		if(str.charAt(str.length-1)==".")
		{
			alert("Please provide an accurate email address.");
			return false;
		}
		if(str.charAt(str.length-1)=="@")
		{
			alert("Please provide an accurate email address.");
			return false;
		}
		var j=0;
		for( var i=0;i<str.length;i++)
		{
		if(str.charAt(i) == "@")
		j++;
		}
		if(j > 1)
		{
			alert("Please provide an accurate email address.");
			return false;
		}
		return true;	
}
