function form_validate(theForm)
{
if (theForm.first_name.value == "")
  {
    alert("Please enter a value for the \"First name required.\" field.");
    theForm.first_name.focus();
    return (false);
  }

  if (theForm.last_name.value == "")
  {
    alert("Please enter a value for the \"Last name required.\" field.");
    theForm.last_name.focus();
    return (false);
  }

  if (theForm.iama.selectedIndex == 0)
  {
    alert("Select Broker, Agent, Affiliate, or Other options.");
    theForm.iama.focus();
    return (false);
  }

if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"Company name required.\" field.");
    theForm.company.focus();
    return (false);
  }

  if (theForm.main_phone.value == "")
  {
    alert("Please enter a value for the \"Phone number required.\" field.");
    theForm.main_phone.focus();
    return (false);
  }

  if (theForm.main_phone.value.length < 7)
  {
    alert("Please enter at least 7 characters in the \"Phone number required.\" field.");
    theForm.main_phone.focus();
    return (false);
  }

  if (theForm.main_phone.value.length > 9999)
  {
    alert("Please enter at most 9999 characters in the \"Phone number required.\" field.");
    theForm.main_phone.focus();
    return (false);
  }

if(!ValidateNo(theForm.main_phone.value,"1234567890-(). "))
  {
    alert("Not a valid Phone format field.");
    theForm.main_phone.focus();
    return (false);
  }



  if (theForm.home_phone.value == "")
  {
    alert("Please enter a value for the \"Home Phone number required.\" field.");
    theForm.home_phone.focus();
    return (false);
  }

  if (theForm.home_phone.value.length < 7)
  {
    alert("Please enter at least 7 characters in the \"Home Phone number required.\" field.");
    theForm.home_phone.focus();
    return (false);
  }

  if (theForm.home_phone.value.length > 9999)
  {
    alert("Please enter at most 9999 characters in the \"Phone number required.\" field.");
    theForm.home_phone.focus();
    return (false);
  }
if(!ValidateNo(theForm.home_phone.value,"1234567890-(). "))
  {
    alert("Not a valid Phone format field.");
    theForm.home_phone.focus();
    return (false);
  }
function ValidateNo(NumStr, String)
{
for(var Idx=0; Idx<NumStr.length; Idx++)
{
var Char = NumStr.charAt(Idx);
var Match = false;
for(var Idx1=0; Idx1<String.length; Idx1++)
{
if(Char == String.charAt (Idx1))
 Match = true;
}
if (!Match)
return false;
}
return true;
} 	



if (theForm.streetname.value == "")
  {
    alert("Please enter a value for the \"Address required.\" field.");
    theForm.streetname.focus();
    return (false);
  }


if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"City required.\" field.");
    theForm.city.focus();
    return (false);
  }
  
  if (theForm.county.value == "")
  {
    alert("Please enter a value for the \"County required.\" field.");
    theForm.County.focus();
    return (false);
  }

if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \"Zip required.\" field.");
    theForm.zip.focus();
    return (false);
  }

  
if (theForm.user_email.value == "")
  {
    alert("Please enter a value for the \"E-mail address required.\" field.");
    theForm.user_email.focus();
    return (false);
  }

  if (theForm.user_email.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"E-mail adress required.\" field.");
    theForm.user_email.focus();
    return (false);
  }

  if (theForm.user_email.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"E-mail adress required.\" field.");
    theForm.user_email.focus();
    return (false);
  }
  
  if (echeck(theForm.user_email.value)==false)
  {
  theForm.user_email.value=""
		theForm.user_email.focus()
		return (false);
  }
  
  if (theForm.agree.checked == false)
  {
    alert("Please check if you read the TALB By-Laws.\" field.");
    theForm.agree.focus();
    return (false);
  }
  


  
  
  if (theForm.edit_user_pass2.value == "")
  {
    alert("Code cannot be blank");
    theForm.edit_user_pass2.focus();
    return (false);
  }
  
  if (BothFieldsIdenticalCaseSensitive(theForm.edit_user_pass.value, theForm.edit_user_pass2.value)==false)
  {  
  theForm.edit_user_pass2.value=""
		theForm.edit_user_pass2.focus()
		return (false);
  } 
  
  
 } 
 
  
  

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);
		 }					
	}
	
	function BothFieldsIdenticalCaseSensitive(str1, str2)
	 {
var one = str1;
var another = str2;
if(one != another) { 
alert("Oops, both codes must be identical.");
return (false);
}
}


function addOption(whichDD,name,value)
{
	// create a reference to the SELECT and the form
	var theDD=eval(whichDD);

    // create the new OPTION
    var newOption;
    newOption= new Option (name,value);

    // position
    var insertAt = theDD.options.length;

    // create the space
    theDD.options.length=theDD.options.length + 1;
      // add the option
    theDD.options[insertAt] = newOption;
}

function populateDD()
{
	// get the value
	var firstDD=document.theForm.state.value;

	// reset the dropdown
	document.theForm.county.length=0;

	// Populate the second DD
	switch (firstDD)
	{
	
			
			case 'Texas':
		    addOption('document.theForm.county','(Pick A County)','');
			addOption('document.theForm.county','Anderson','Anderson');
			addOption('document.theForm.county','Andrews','Andrews');
			addOption('document.theForm.county','Angelina','Angelina');
			addOption('document.theForm.county','Aransas','Aransas');
			addOption('document.theForm.county','Archer','Archer');
			addOption('document.theForm.county','Armstrong','Armstrong');
			addOption('document.theForm.county','Atascosa','Atascosa');
			addOption('document.theForm.county','Austin','Austin');
			addOption('document.theForm.county','Bailey','Bailey');
			addOption('document.theForm.county','Bandera','Bandera');
			addOption('document.theForm.county','Bastrop','Bastrop');
			addOption('document.theForm.county','Baylor','Baylor');
			addOption('document.theForm.county','Bee','Bee');
			addOption('document.theForm.county','Bell','Bell');
			addOption('document.theForm.county','Bexar','Bexar');
			addOption('document.theForm.county','Blanco','Blanco');
			addOption('document.theForm.county','Borden','Borden');
			addOption('document.theForm.county','Bosque','Bosque');
			addOption('document.theForm.county','Bowie','Bowie');
			addOption('document.theForm.county','Brazoria','Brazoria');
			addOption('document.theForm.county','Brazos','Brazos');
			addOption('document.theForm.county','Brewster','Brewster');
			addOption('document.theForm.county','Briscoe','Briscoe');
			addOption('document.theForm.county','Brooks','Brooks');
			addOption('document.theForm.county','Brown','Brown');
			addOption('document.theForm.county','Burleson','Burleson');
			addOption('document.theForm.county','Burnet','Burnet');
			addOption('document.theForm.county','Caldwell','Caldwell');
			addOption('document.theForm.county','Calhoun','Calhoun');
			addOption('document.theForm.county','Callahan','Callahan');
			addOption('document.theForm.county','Cameron','Cameron');
			addOption('document.theForm.county','Camp','Camp');
			addOption('document.theForm.county','Carson','Carson');
			addOption('document.theForm.county','Cass','Cass');
			addOption('document.theForm.county','Castro','Castro');
			addOption('document.theForm.county','Chambers','Chambers');
			addOption('document.theForm.county','Cherokee','Cherokee');
			addOption('document.theForm.county','Childress','Childress');
			addOption('document.theForm.county','Clay','Clay');
			addOption('document.theForm.county','Cochran','Cochran');
			addOption('document.theForm.county','Coke','Coke');
			addOption('document.theForm.county','Coleman','Coleman');
			addOption('document.theForm.county','Collin','Collin');
			addOption('document.theForm.county','Collingsworth','Collingsworth');
			addOption('document.theForm.county','Colorado','Colorado');
			addOption('document.theForm.county','Comal','Comal');
			addOption('document.theForm.county','Comanche','Comanche');
			addOption('document.theForm.county','Concho','Concho');
			addOption('document.theForm.county','Cooke','Cooke');
			addOption('document.theForm.county','Coryell','Coryell');
			addOption('document.theForm.county','Cottle','Cottle');
			addOption('document.theForm.county','Crane','Crane');
			addOption('document.theForm.county','Crockett','Crockett');
			addOption('document.theForm.county','Crosby','Crosby');
			addOption('document.theForm.county','Culberson','Culberson');
			addOption('document.theForm.county','Dallam','Dallam');
			addOption('document.theForm.county','Dallas','Dallas');
			addOption('document.theForm.county','Dawson','Dawson');
			addOption('document.theForm.county','Deaf Smith','Deaf Smith');
			addOption('document.theForm.county','Delta','Delta');
			addOption('document.theForm.county','Denton','Denton');
			addOption('document.theForm.county','DeWitt','DeWitt');
			addOption('document.theForm.county','Dickens','Dickens');
			addOption('document.theForm.county','Dimmit','Dimmit');
			addOption('document.theForm.county','Donley','Donley');
			addOption('document.theForm.county','Duval','Duval');
			addOption('document.theForm.county','Eastland','Eastland');
			addOption('document.theForm.county','Ector','Ector');
			addOption('document.theForm.county','Edwards','Edwards');
			addOption('document.theForm.county','Ellis','Ellis');
			addOption('document.theForm.county','El Paso','El Paso');
			addOption('document.theForm.county','Erath','Erath');
			addOption('document.theForm.county','Falls','Falls');
			addOption('document.theForm.county','Fannin','Fannin');
			addOption('document.theForm.county','Fayette','Fayette');
			addOption('document.theForm.county','Fisher','Fisher');
			addOption('document.theForm.county','Floyd','Floyd');
			addOption('document.theForm.county','Foard','Foard');
			addOption('document.theForm.county','Fort Bend','Fort Bend');
			addOption('document.theForm.county','Franklin','Franklin');
			addOption('document.theForm.county','Freestone','Freestone');
			addOption('document.theForm.county','Frio','Frio');
			addOption('document.theForm.county','Gaines','Gaines');
			addOption('document.theForm.county','Galveston','Galveston');
			addOption('document.theForm.county','Garza','Garza');
			addOption('document.theForm.county','Gillespie','Gillespie');
			addOption('document.theForm.county','Glasscock','Glasscock');
			addOption('document.theForm.county','Goliad','Goliad');
			addOption('document.theForm.county','Gonzales','Gonzales');
			addOption('document.theForm.county','Gray','Gray');
			addOption('document.theForm.county','Grayson','Grayson');
			addOption('document.theForm.county','Gregg','Gregg');
			addOption('document.theForm.county','Grimes','Grimes');
			addOption('document.theForm.county','Guadalupe','Guadalupe');
			addOption('document.theForm.county','Hale','Hale');
			addOption('document.theForm.county','Hall','Hall');
			addOption('document.theForm.county','Hamilton','Hamilton');
			addOption('document.theForm.county','Hansford','Hansford');
			addOption('document.theForm.county','Hardeman','Hardeman');
			addOption('document.theForm.county','Hardin','Hardin');
			addOption('document.theForm.county','Harris','Harris');
			addOption('document.theForm.county','Harrison','Harrison');
			addOption('document.theForm.county','Hartley','Hartley');
			addOption('document.theForm.county','Haskell','Haskell');
			addOption('document.theForm.county','Hays','Hays');
			addOption('document.theForm.county','Hemphill','Hemphill');
			addOption('document.theForm.county','Henderson','Henderson');
			addOption('document.theForm.county','Hidalgo','Hidalgo');
			addOption('document.theForm.county','Hill','Hill');
			addOption('document.theForm.county','Hockley','Hockley');
			addOption('document.theForm.county','Hood','Hood');
			addOption('document.theForm.county','Hopkins','Hopkins');
			addOption('document.theForm.county','Houston','Houston');
			addOption('document.theForm.county','Howard','Howard');
			addOption('document.theForm.county','Hudspeth','Hudspeth');
			addOption('document.theForm.county','Hunt','Hunt');
			addOption('document.theForm.county','Hutchinson','Hutchinson');
			addOption('document.theForm.county','Irion','Irion');
			addOption('document.theForm.county','Jack','Jack');
			addOption('document.theForm.county','Jackson','Jackson');
			addOption('document.theForm.county','Jasper','Jasper');
			addOption('document.theForm.county','Jeff Davis','Jeff Davis');
			addOption('document.theForm.county','Jefferson','Jefferson');
			addOption('document.theForm.county','Jim Hogg','Jim Hogg');
			addOption('document.theForm.county','Jim Wells','Jim Wells');
			addOption('document.theForm.county','Johnson','Johnson');
			addOption('document.theForm.county','Jones','Jones');
			addOption('document.theForm.county','Karnes','Karnes');
			addOption('document.theForm.county','Kaufman','Kaufman');
			addOption('document.theForm.county','Kendall','Kendall');
			addOption('document.theForm.county','Kenedy','Kenedy');
			addOption('document.theForm.county','Kent','Kent');
			addOption('document.theForm.county','Kerr','Kerr');
			addOption('document.theForm.county','Kimble','Kimble');
			addOption('document.theForm.county','King','King');
			addOption('document.theForm.county','Kinney','Kinney');
			addOption('document.theForm.county','Kleberg','Kleberg');
			addOption('document.theForm.county','Knox','Knox');
			addOption('document.theForm.county','Lamar','Lamar');
			addOption('document.theForm.county','Lamb','Lamb');
			addOption('document.theForm.county','Lampasas','Lampasas');
			addOption('document.theForm.county','La Salle','La Salle');
			addOption('document.theForm.county','Lavaca','Lavaca');
			addOption('document.theForm.county','Lee','Lee');
			addOption('document.theForm.county','Leon','Leon');
			addOption('document.theForm.county','Liberty','Liberty');
			addOption('document.theForm.county','Limestone','Limestone');
			addOption('document.theForm.county','Lipscomb','Lipscomb');
			addOption('document.theForm.county','Live Oak','Live Oak');
			addOption('document.theForm.county','Llano','Llano');
			addOption('document.theForm.county','Loving','Loving');
			addOption('document.theForm.county','Lubbock','Lubbock');
			addOption('document.theForm.county','Lynn','Lynn');
			addOption('document.theForm.county','McCulloch','McCulloch');
			addOption('document.theForm.county','McLennan','McLennan');
			addOption('document.theForm.county','McMullen','McMullen');
			addOption('document.theForm.county','Madison','Madison');
			addOption('document.theForm.county','Marion','Marion');
			addOption('document.theForm.county','Martin','Martin');
			addOption('document.theForm.county','Mason','Mason');
			addOption('document.theForm.county','Matagorda','Matagorda');
			addOption('document.theForm.county','Maverick','Maverick');
			addOption('document.theForm.county','Medina','Medina');
			addOption('document.theForm.county','Menard','Menard');
			addOption('document.theForm.county','Midland','Midland');
			addOption('document.theForm.county','Milam','Milam');
			addOption('document.theForm.county','Mills','Mills');
			addOption('document.theForm.county','Mitchell','Mitchell');
			addOption('document.theForm.county','Montague','Montague');
			addOption('document.theForm.county','Montgomery','Montgomery');
			addOption('document.theForm.county','Moore','Moore');
			addOption('document.theForm.county','Morris','Morris');
			addOption('document.theForm.county','Motley','Motley');
			addOption('document.theForm.county','Nacogdoches','Nacogdoches');
			addOption('document.theForm.county','Navarro','Navarro');
			addOption('document.theForm.county','Newton','Newton');
			addOption('document.theForm.county','Nolan','Nolan');
			addOption('document.theForm.county','Nueces','Nueces');
			addOption('document.theForm.county','Ochiltree','Ochiltree');
			addOption('document.theForm.county','Oldham','Oldham');
			addOption('document.theForm.county','Orange','Orange');
			addOption('document.theForm.county','Palo Pinto','Palo Pinto');
			addOption('document.theForm.county','Panola','Panola');
			addOption('document.theForm.county','Parker','Parker');
			addOption('document.theForm.county','Parmer','Parmer');
			addOption('document.theForm.county','Pecos','Pecos');
			addOption('document.theForm.county','Polk','Polk');
			addOption('document.theForm.county','Potter','Potter');
			addOption('document.theForm.county','Presidio','Presidio');
			addOption('document.theForm.county','Rains','Rains');
			addOption('document.theForm.county','Randall','Randall');
			addOption('document.theForm.county','Reagan','Reagan');
			addOption('document.theForm.county','Real','Real');
			addOption('document.theForm.county','Red River','Red River');
			addOption('document.theForm.county','Reeves','Reeves');
			addOption('document.theForm.county','Refugio','Refugio');
			addOption('document.theForm.county','Roberts','Roberts');
			addOption('document.theForm.county','Robertson','Robertson');
			addOption('document.theForm.county','Rockwall','Rockwall');
			addOption('document.theForm.county','Runnels','Runnels');
			addOption('document.theForm.county','Rusk','Rusk');
			addOption('document.theForm.county','Sabine','Sabine');
			addOption('document.theForm.county','San Augustine','San Augustine');
			addOption('document.theForm.county','San Jacinto','San Jacinto');
			addOption('document.theForm.county','San Patricio','San Patricio');
			addOption('document.theForm.county','San Saba','San Saba');
			addOption('document.theForm.county','Schleicher','Schleicher');
			addOption('document.theForm.county','Scurry','Scurry');
			addOption('document.theForm.county','Shackelford','Shackelford');
			addOption('document.theForm.county','Shelby','Shelby');
			addOption('document.theForm.county','Sherman','Sherman');
			addOption('document.theForm.county','Smith','Smith');
			addOption('document.theForm.county','Somervell','Somervell');
			addOption('document.theForm.county','Starr','Starr');
			addOption('document.theForm.county','Stephens','Stephens');
			addOption('document.theForm.county','Sterling','Sterling');
			addOption('document.theForm.county','Stonewall','Stonewall');
			addOption('document.theForm.county','Sutton','Sutton');
			addOption('document.theForm.county','Swisher','Swisher');
			addOption('document.theForm.county','Tarrant','Tarrant');
			addOption('document.theForm.county','Taylor','Taylor');
			addOption('document.theForm.county','Terrell','Terrell');
			addOption('document.theForm.county','Terry','Terry');
			addOption('document.theForm.county','Throckmorton','Throckmorton');
			addOption('document.theForm.county','Titus','Titus');
			addOption('document.theForm.county','Tom Green','Tom Green');
			addOption('document.theForm.county','Travis','Travis');
			addOption('document.theForm.county','Trinity','Trinity');
			addOption('document.theForm.county','Tyler','Tyler');
			addOption('document.theForm.county','Upshur','Upshur');
			addOption('document.theForm.county','Upton','Upton');
			addOption('document.theForm.county','Uvalde','Uvalde');
			addOption('document.theForm.county','Val Verde','Val Verde');
			addOption('document.theForm.county','Van Zandt','Van Zandt');
			addOption('document.theForm.county','Victoria','Victoria');
			addOption('document.theForm.county','Walker','Walker');
			addOption('document.theForm.county','Waller','Waller');
			addOption('document.theForm.county','Ward','Ward');
			addOption('document.theForm.county','Washington','Washington');
			addOption('document.theForm.county','Webb','Webb');
			addOption('document.theForm.county','Wharton','Wharton');
			addOption('document.theForm.county','Wheeler','Wheeler');
			addOption('document.theForm.county','Wichita','Wichita');
			addOption('document.theForm.county','Wilbarger','Wilbarger');
			addOption('document.theForm.county','Willacy','Willacy');
			addOption('document.theForm.county','Williamson','Williamson');
			addOption('document.theForm.county','Wilson','Wilson');
			addOption('document.theForm.county','Winkler','Winkler');
			addOption('document.theForm.county','Wise','Wise');
			addOption('document.theForm.county','Wood','Wood');
			addOption('document.theForm.county','Yoakum','Yoakum');
			addOption('document.theForm.county','Young','Young');
			addOption('document.theForm.county','Zapata','Zapata');
			addOption('document.theForm.county','Zavala','Zavala');
			break;
		
		
			
	}
}

