
    var map = null;
    var geocoder2 = null;
    var gdir;
    var addressMarker;


var map;
var geocoder2;

geocoder2 = new GClientGeocoder();


    // showLocation() is called when you click on the Search button
    // in the form.  It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation() {
      var address = document.SearchForm.q.value;
      geocoder2.getLocations(address, showAddress);
    }

    function showLocationSubmit() {
      var address = document.SearchForm.q.value;
      geocoder2.getLocations(address, showAddressSubmit);
      //alert('boogidy');
    }

   // findLocation() is used to enter the sample addresses into the form.
    function findLocation(address) {
      document.SearchForm.q.value = address;
      showLocation();
    }
    
    function showAddress(response) {
      if (!response || response.Status.code != 200) {
        //alert("Sorry, we were unable to geocode that address");
      } else {
        place = response.Placemark[0];
        placemark = response.Placemark[0];
        elem = placemark.AddressDetails;
        try {
          document.SearchForm.biggiesearch.value = place.address;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.country.value = "";
          document.SearchForm.country.value = place.AddressDetails.Country.CountryNameCode;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.state.value = "";
          document.SearchForm.state.value = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.county.value = "";
          document.SearchForm.county.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.city.value = "";
          document.SearchForm.city.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.address.value = "";
          document.SearchForm.address.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.zip.value = "";
          document.SearchForm.zip.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.coords.value = "";
          document.SearchForm.coords.value = place.Point.coordinates;
        }
        catch(err) {
        
        }
      }
    }
    
    function showAddressSubmit(response) {
      if (!response || response.Status.code != 200) {
        //alert("Sorry, we were unable to geocode that address");
      } else {
        place = response.Placemark[0];
        placemark = response.Placemark[0];
        elem = placemark.AddressDetails;
        try {
          document.SearchForm.biggiesearch.value = place.address;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.country.value = "";
          document.SearchForm.country.value = place.AddressDetails.Country.CountryNameCode;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.state.value = "";
          document.SearchForm.state.value = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.county.value = "";
          document.SearchForm.county.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.city.value = "";
          document.SearchForm.city.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.address.value = "";
          document.SearchForm.address.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.zip.value = "";
          document.SearchForm.zip.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
        }
        catch(err) {
        
        }
        try {
          document.SearchForm.coords.value = "";
          document.SearchForm.coords.value = place.Point.coordinates;
        }
        catch(err) {
        
        }
      }
      document.SearchForm.submit();
    }
    




