function fSetFocus() 
{
 if (document.getElementById) 
 {
   document.getElementById("zip").focus();
 }
 else
 {
  if (document.all) 
  {
   document.forms(0).item(0).focus();
  }
 }
}

function fValidateZip(xstr) 
{
 var x;
 var y;
 var validChars = "1234567890";
	
 if (xstr.length!=5)
 {
  return(false);
 }

 for (x=0; x < xstr.length; x++)
 {
  y = xstr.charAt(x);
  if (validChars.indexOf(y) == -1)
  {
   return(false);
  }
 }
  return(true);
}

function fValidateCity(xstr) 
{
 var x;
 var y;
 var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
 for (x=0; x<xstr.length; x++)
 {
  y = xstr.charAt(x);
  if (validChars.indexOf(y) == -1)
  {
   return(false);
  }
 }
 return(true);
}

function validate_form(frm)
{
 if (frm.zip.value!="") 
 {
  if ((frm.city.value=="") && (frm.state.value==""))
  {  
   if (fValidateZip(frm.zip.value)==false)
   {
    alert('Invalid zip code entered');
    frm.zip.focus();   
    return(false);  
   }
   return(true);    
  }
  else
  {     
   alert('Values entered for both zip code and city/state - please enter value for either zip code or city/state');
   frm.zip.focus();   
   return(false);    
  }
 }
 else
 {
  if ((frm.city.value=="") && (frm.state.value==""))
  {     
   alert('No value entered - please enter value for either zip code or city/state');
   frm.zip.focus();   
   return(false);    
  }
  if (frm.city.value=="")
  {     
   alert('Please enter city');
   frm.city.focus();   
   return(false);    
  }
  if ((frm.city.value!="") && (frm.state.value==""))
  {     
   alert('Please select state');
   frm.state.focus();   
   return(false);    
  }
  if (fValidateCity(frm.city.value)==false)
  {
   alert('Invalid city entered');
   frm.city.focus();   
   return(false);  
  }
 }
 return(true);
}
