// JavaScript Document
//=================================================================
function Replace(STRING,REPLACE_THIS,REPLACE_WITH){
while(STRING.indexOf(REPLACE_THIS) > -1){
STRING = STRING.replace(REPLACE_THIS,REPLACE_WITH);
}
return STRING;
}
//=================================================================
function ValidateForm()
{
if (document.theForm.ffirstname.value.length < 3)
   {
   alert("Please enter your first name");
   document.theForm.ffirstname.focus();
   return false;
   }
if (document.theForm.flastname.value.length < 3)
   {
   alert("Please enter your last name");
   document.theForm.flastname.focus();
   return false;
   }  
   
sAddr = "";   
if ( (document.theForm.faddr.value != "") || (document.theForm.fcity.value != "") || (document.theForm.fstate.value != "") || (document.theForm.fzip.value != ""))
   {
	for(var i = 0; i < document.theForm.faddrbutton.length; i++) 
      {
      if(document.theForm.faddrbutton[i].checked) 
         {
	     sAddr = document.theForm.faddrbutton[i].value;
	     }
      }
	if (sAddr == "")
	   {
	   alert("Please indicate if the address is a home or business address");
	   return false;
       }
   }
   
if ( (document.theForm.femail.value.indexOf(".") == -1) || (document.theForm.femail.value.indexOf("@") == -1) || (document.theForm.femail.value.length < 9))
   {
   alert("Please enter a valid email address");
   document.theForm.femail.focus();
   return false;
   }  
sEmail = "";
for(var i = 0; i < document.theForm.femailbutton.length; i++) 
   {
   if(document.theForm.femailbutton[i].checked) 
      {
      sEmail = (document.theForm.femailbutton[i].value);
	  }
   }
if (sEmail == "")
   {
   alert("Please indicate if the email address is a home or business email address")
   return false;
   }  
   
if (sAddr == "B")
   {
	document.theForm.dbfield_names.value = Replace(document.theForm.dbfield_names.value, "Home", "Bus")
   }
if (sAddr == "H")
   {
	document.theForm.dbfield_names.value = Replace(document.theForm.dbfield_names.value, "Bus", "Home")
   } 
if (sEmail == "B")
   {
	document.theForm.dbfield_names.value = Replace(document.theForm.dbfield_names.value, "HomeEmail", "BusEmail")
   }
if (sEmail == "H")
   {
	document.theForm.dbfield_names.value = Replace(document.theForm.dbfield_names.value, "BusEmail", "HomeEmail")
   }      
   
return true;   
}