/*
functions: 
uf_goto_insurance()
uf_check_findval(tform)
isValid(evt)
isValid_whgt(evt)
isValidEmail(address) 
*/

function uf_check_fields_br(tform)  // for the branch
{
	if (tform.txtCity_what.value=='')
	{
		window.alert ("Please provide the city where you want to put up a branch at before you proceed");
		tform.txtCity_what.focus();
	}else
	{
		if (tform.sltstate_what.value=='')
		{
			window.alert ("Please provide the state where you want to put up a branch at before you proceed");
			tform.sltstate_what.focus();
		}else 
		{
			if (tform.txtfname.value=='')
			{
				    window.alert ("Please provide the first name  before you proceed");
					tform.txtfname.focus();
			}
			else
			{
			if (tform.txtlname.value=='')
				{
					   window.alert ("Please provide the last name  before you proceed");
						tform.txtlname.focus();
				}else
				{
					if (tform.txtCity.value=='')
					{
						window.alert ("Please provide the city  before you proceed");
						tform.txtCity.focus();
					}else
					{
						if (tform.sltstate.value=='')
						{
								window.alert ("Please provide the state  before you proceed");
								tform.sltstate.focus();
						}
						else
						{
							if (tform.txtZip.value=='')
							{
								window.alert ("Please provide the zip code  before you proceed");
								tform.txtZip.focus();
							}
							else
							{
								if (tform.txtphone1.value=='')
								{
									window.alert ("Please provide the phone number  before you proceed");
									tform.txtphone1.focus();
								}
								else
								{
									if (tform.txtEmail.value=='')
									{
										window.alert ("Please provide the email address  before you proceed");
										tform.txtEmail.focus();
									}else
									{
										if (isValidEmail(tform.txtEmail.value) )
										{
										tform.action = 'scripts/subagent.php';
										tform.submit()
										}
										else
										{
											window.alert ("Please provide a valid email address  before you proceed");
											tform.txtEmail.focus();
										} // end if (isValidEmail(tform.txtEmail.value) )
									} // end if (tform.txtEmail.value=='')	
								} // end if (tform.txtphone1.value=='')	
							} // end if (tform.txtZip.value=='')			
						} // end if if (tform.sltstate.value=='')
					} // end if if (tform.txtCity.value=='')
				} // end if (tform.txtlname.value=='')
			} // end if (tform.txtfname.value=='')
		} // end if if (tform.sltstate_what.value=='')
	} // end if  (tform.txtCity_what.value=='')
} // end function uf_check_fields(tform)  for the branch



function uf_check_fields(tform)  // for agent
{
	
	if (tform.txtfname.value=='')
	{
		   window.alert ("Please provide the first name  before you proceed");
			tform.txtfname.focus();
	}else
	{
		
			if (tform.txtlname.value=='')
				{
					   window.alert ("Please provide the last name  before you proceed");
						tform.txtlname.focus();
				}else
				{
					if (tform.txtCity.value=='')
					{
						window.alert ("Please provide the city  before you proceed");
						tform.txtCity.focus();
					}else
					{
						if (tform.sltstate.value=='')
						{
								window.alert ("Please provide the state  before you proceed");
								tform.sltstate.focus();
						}
						else
						{
							if (tform.txtZip.value=='')
							{
								window.alert ("Please provide the zip code  before you proceed");
								tform.txtZip.focus();
							}
							else
							{
								if (tform.txtphone1.value=='')
								{
									window.alert ("Please provide the phone number  before you proceed");
									tform.txtphone1.focus();
								}
								else
								{
									if (tform.txtEmail.value=='')
									{
										window.alert ("Please provide the email address  before you proceed");
										tform.txtEmail.focus();
									}else
									{
										if (isValidEmail(tform.txtEmail.value) )
										{
										tform.action = 'scripts/subagent.php';
										tform.submit()
										}
										else
										{
											window.alert ("Please provide a valid email address  before you proceed");
											tform.txtEmail.focus();
										} // end if (isValidEmail(tform.txtEmail.value) )
									} // end if (tform.txtEmail.value=='')	
								} // end if (tform.txtphone1.value=='')	
							} // end if (tform.txtZip.value=='')			
						} // end if if (tform.sltstate.value=='')
					} // end if if (tform.txtCity.value=='')
				} // end if (tform.txtlname.value=='')
		} // end if (tform.txtfname.value=='')
} // end function uf_check_fields(tform)  for the agent




function uf_goto_insurance(tform)
{
			tform.action = "select_insur.php";
			tform.submit();
} // end if uf_goto_insurance()




function validate_fields(tform)
{
//  window.alert(tform.hdpage.value) ;
  if (( tform.hdinsr.value == 35 ) && ( tform.txtcompany.value == '' ))
  {
		window.alert ("Please provide the company name before you proceed");
    	tform.txtcompany.focus();
  }
  else
  {
  if (tform.txtCity.value=='')
  {
    window.alert ("Please provide the city before you proceed");
    tform.txtCity.focus();
  }
  else
  {
    if (tform.txtfname.value=='')
    {
      window.alert ("Please provide the first name  before you proceed");
      tform.txtfname.focus();
    }
    else
    {
      if (tform.txtlname.value=='')
      {
        window.alert ("Please provide the last name  before you proceed");
	tform.txtlname.focus();
      }
      else
      {
	if (tform.txtAdd.value=='')
	{
 	  window.alert ("Please provide the address  before you proceed");
	  tform.txtAdd.focus();
	}
	else
	{
	  if (tform.txtCity.value=='')
	  {
	    window.alert ("Please provide the city  before you proceed");
	    tform.txtCity.focus();
	  }
	  else
	  {
	    if (tform.sltstate.value=='')
	    {
		window.alert ("Please select a state from the list before you proceed");
		tform.sltstate.focus();
	    }
	    else
	    {
		if (tform.txtZip.value=='')
		{
		  window.alert ("Please provide the zip code before you proceed");
		  tform.txtZip.focus();
		}
		else
		{
		  if (tform.txtPhone1.value=='') 
		  {
		    window.alert ("Please provide the phone number (day) before you proceed");
		    tform.txtPhone1.focus();
		  }else
		  {
		    if (tform.txtPhone2.value=='') 
		    {
			window.alert ("Please provide the phone number (evening) before you proceed");
			tform.txtPhone2.focus();
		    }else
		    {
			//submit here 
			//tform.action = "scripts/"+tform.hdpage.value;
			tform.action = "scripts/" + tform.hdpage.value ;
			tform.submit();
		    } // end if txtPhone2
		  } // end if tform.txtPhone1.value=='')
		} // end if (tform.txtZip.value=='')
	      }	 // end if (tform.sltstate.value=='')
	    }	// end if tform.txtCity.value=='')
	  } // end if (tform.txtAdd.value=='')
	} // end if tform.txtlname.value=='')
      } // end if tform.txtfname.value==''
    } // end if (tform.txtCity_what.value=='')
  }//(( tform.hdinsr.value == 35 ) && ( tform.txtcompany.value == '' ))
} // end function validate_fields(tform)




function isValid(evt)
{
	if (navigator.appName == 'Netscape') {
    	window.captureEvents(Event.KEYPRESS);
   	if ((evt.which>= 45) &&  (evt.which <= 96) || (evt.which == 8) || (evt.which == 0) || (evt.which == 40) || (evt.which == 41) || (evt.which == 98))
    	return true;
    	else
    	return false;
	}else
	{
	if ((window.event.keyCode >= 46) &&  (window.event.keyCode <= 98) || (window.event.keyCode==8) || (window.event.keyCode==0) || (window.event.keyCode==40) || (window.event.keyCode==41) || (window.event.keyCode==98))
		return true;
		else
		return false;
	} // end if check navigator
} // end function 

function isValid_whgt(evt)
{
	if (navigator.appName == 'Netscape') {
    	window.captureEvents(Event.KEYPRESS);
   	if ((evt.which>= 45) &&  (evt.which <= 96) || (evt.which == 8) || (evt.which == 0) || (evt.which == 40) || (evt.which == 41) || (evt.which == 98) || (evt.which == 39) || (evt.which == 34))
    	return true;
    	else
    	return false;
	}else
	{
	if ((window.event.keyCode >= 46) &&  (window.event.keyCode <= 98) || (window.event.keyCode==8) || (window.event.keyCode==0) || (window.event.keyCode==40) || (window.event.keyCode==41) || (window.event.keyCode==98) || (window.event.keyCode==39) || (window.event.keyCode==34))
		return true;
		else
		return false;
	} // end if check navigator
} // end function 


function isValidEmail(address) 
{
	if (address.indexOf('@') < 2) return false;
	var name = address.substring(0, address.indexOf('@'));
	var domain = address.substring(address.indexOf('@') + 1);
	if (name.indexOf('(') != -1 || name.indexOf(')') != -1 || name.indexOf('<') != -1 || name.indexOf('>') != -1 || name.indexOf(',') != -1 || name.indexOf(';') != -1 || name.indexOf(':') != -1 || name.indexOf('\\') != -1 || name.indexOf('"') != -1 || name.indexOf('[') != -1 || name.indexOf(']') != -1 || name.indexOf(' ') != -1) return false;
	if (domain.indexOf('(') != -1 || domain.indexOf(')') != -1 || domain.indexOf('<') != -1 || domain.indexOf('>') != -1 || domain.indexOf(',') != -1 || domain.indexOf(';') != -1 || domain.indexOf(':') != -1 || domain.indexOf('\\') != -1 || domain.indexOf('"') != -1 || domain.indexOf('[') != -1 || domain.indexOf(']') != -1 || domain.indexOf(' ') != -1) return false;
	return true;
} // end function isValidEmail(address) 

//function validate_alert(tform)
//{
//  window.alert(tform.hdpage.value) ;
//}
