// See if search type is zip, citystate, or state
function chkSearchType()
{
  var theForm = document.forms.providersearch ;
  var selectedradio = radioValue(theForm.searchby) ;

  if (selectedradio == 'zip')
  {
    // Enable Zip and maxdistance Boxes
    theForm.zip.disabled = false ;
    theForm.zip.style.backgroundColor = "#FFFFFF" ;

    theForm.maxdistance.disabled = false ;
    theForm.maxdistance.style.backgroundColor = "#FFFFFF" ;

    // Place focus on zip code box.
    theForm.zip.focus() ;

    // Disable City and State Boxes
    theForm.city.disabled = true ;
    theForm.city.style.backgroundColor = "#CCCCCC";

    theForm.state.disabled = true ;
    theForm.state.style.backgroundColor = "#CCCCCC" ;
  }

  if (selectedradio == 'state')
  {
    // Enable the State Box
    theForm.state.disabled = false ;
    theForm.state.style.backgroundColor = "#FFFFFF" ;
 
    // Place focus on state list
    theForm.state.focus() ;

    // Disable City, State, and maxdistance Boxes
    theForm.city.disabled = true ;
    theForm.city.style.backgroundColor = "#CCCCCC" ;

    theForm.zip.disabled = true ;
    theForm.zip.style.backgroundColor = "#CCCCCC" ;

    theForm.maxdistance.disabled = true ;
    theForm.maxdistance.style.backgroundColor = "#CCCCCC" ;
  }

  if (selectedradio == 'citystate')
  {
    // Enable City, State, and maxdistance Boxes
    theForm.city.disabled = false ;
    theForm.city.style.backgroundColor = "#FFFFFF" ;

    theForm.state.disabled = false ;
    theForm.state.style.backgroundColor = "#FFFFFF" ;

    theForm.maxdistance.disabled = false ;
    theForm.maxdistance.style.backgroundColor = "#FFFFFF" ;

    // Place focus on city box
    theForm.city.focus() ;

    // Disable Zip box
    theForm.zip.disabled = true ;
    theForm.zip.style.backgroundColor = "#CCCCCC" ;
  }
}

// Make sure all required fields have been filled in.
function validateForm()
{
  var theForm = document.forms.providersearch ;

  // Make sure provider type is selected.
  if (theForm.spc.value == '0')
  {
    alert("Please select a Provider Type") ;
    theForm.spc.focus() ;
    return false ;
  }

  // Make sure a location has been selected.
  
  var selectedradio = radioValue(theForm.searchby) ;

  if (selectedradio == 'zip')
  {
    if (trim(theForm.zip.value) == '')
    {
      alert ("Please enter a zip code") ;
      theForm.zip.focus() ;
      return false ;
    }
  }

  if (selectedradio == 'citystate')
  {
    if (trim(theForm.city.value) == '' || trim(theForm.state.value) == '0')
    {
      alert ("Please enter a city and state") ;
      theForm.city.focus() ;
      return false ;
    }
  }

  if (selectedradio == 'state')
  {
    if (trim(theForm.state.value) == '0')
    {
      alert ("Please select a state") ;
      theForm.state.focus() ;
      return false ;
    }
  }

  return true ;
}
