var map = null;
var geocoder = null;

    function load(address, pname, setlink) {
      if (GBrowserIsCompatible()) {
			delete map;
		map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        delete geocoder;
		geocoder = new GClientGeocoder();
		showAddress(address, pname, setlink) 
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl()); 
		}
    }

    function showAddress(address, pname, setlink) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 14);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              if (setlink)
			  	marker.openInfoWindowHtml('<div style = "color:black;"><b>' + pname + '</b><br/>' + address + '<br/><a href = "javascript:document.location.submit();">Set Location</a></div>');
			  else
			  	marker.openInfoWindowHtml('<b>' + pname + '</b><br/>' + address);
            }
          }
        );
      }
    }
