var map = null;
var geocoder = null;
var map2 = null;
var geocoder2 = null;

function load() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map2"));
    //map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    geocoder = new GClientGeocoder();
    portlandDesc = "<b>Portland Office</b><br />1331 NW Lovejoy, Suite 720<br />Portland, OR 97209";
    showAddress("1331 NW Lovejoy, Portland, OR 97209", map, geocoder, portlandDesc);

    map2 = new GMap2(document.getElementById("map"));
    geocoder2 = new GClientGeocoder();
    menloDesc = "<b>Menlo Office</b><br />640 Oak Grove Avenue<br />Menlo Park, CA 94025";
    showAddress("640 Oak Grove Avenue, Menlo Park, CA 94025", map2, geocoder2, menloDesc);
  }
}

function showAddress(address, map, geocoder, htmlString) {
  if (geocoder) {
      geocoder.getLatLng(
      address,
      function(point) {
          if (!point) {
              alert(address + " not found");
          } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              GEvent.addListener(marker, "click", function(latlng) { marker.openInfoWindowHtml(htmlString); });
              map.addOverlay(marker);
              map.setZoom(15);
              //map.zoomIn();
              marker.openInfoWindowHtml(htmlString);
          }
      }
    );
  }
}
