var map;
    var geocoder;
    var theAddress;

    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
        map.addOverlay(marker);
        map.setCenter(point, 15);
        var visibleAddress = place.AddressDetails.Country.AdministrativeArea;
        //marker.openInfoWindowHtml( visibleAddress.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName + '<br>' +
        //                           visibleAddress.SubAdministrativeArea.Locality.LocalityName + ', ' +
        //                           visibleAddress.AdministrativeAreaName + ' ' +
        //                           visibleAddress.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber);
      }
    }

    // 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.forms[0].q.value;
      geocoder.getLocations(address, addAddressToMap);
    }

   // findLocation() is used to enter the sample addresses into the form.
    function findLocation(address) {
      document.forms[0].q.value = address;
      showLocation();
    }

    function loadGoogleMaps(addr) {
      map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(40.74, -73.98), 13);
      geocoder = new GClientGeocoder();
      theAddress = addr;
      geocoder.getLocations(theAddress, addAddressToMap);
    }