    var map = [];
    var geocoder = [];
    var marker = [];
    var google_address='';
	var cur_divid = '';

    function initialize(divid, mapAddress) {
      if (GBrowserIsCompatible()) {
        map[divid] = new GMap2(document.getElementById(divid));
        map[divid].checkResize();
        map[divid].setCenter(new GLatLng(0, 0), 13);
        geocoder[divid] = new GClientGeocoder();
        showAddress(divid, mapAddress);
        map[divid].addControl(new GSmallMapControl());
      }
    }

    function showAddress(divid, address) {
      if (geocoder) {
        geocoder[divid].getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map[divid].setCenter(point, 13);
              marker[divid] = new GMarker(point);
              map[divid].addOverlay(marker[divid]);
              GEvent.addListener(marker[divid], 'click', function(){this.openInfoWindowHtml(decodeURIComponent(address.replace(/, /,"<br/>")).replace(/\+/g," ")+"<br /><a class=\"direction_link\" href=\"javascript: show_gm_directions('" + divid + "');\">Get directions</a>")});
              GEvent.trigger(marker[divid], "click");
            }
          }
        );
      }
    }

    function show_gm_directions(divid) {
        document.getElementById(divid + '_directions_form').style.display='block';
    }


    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.");
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.");
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.");

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.");
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. ");

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.");
	    
	   else alert("An unknown error occurred.");
	   
	}

    function setDirections(fromAddress, toAddress, locale, divid) {
	  gdir = new GDirections(map[divid], document.getElementById(divid+"_directions"));
	  GEvent.addListener(gdir, "error", handleErrors); 
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }