function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
  marker.openInfoWindowHtml(html);
});
return marker;
}

// ====== Geocoding ======
function getAddress(search) {
	
// ====== Maps for locations ======
var map=new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl()) ;
map.addControl(new GMapTypeControl()) ;
map.setCenter(new GLatLng(0,0),10);

// ====== Create a Client Geocoder ======
var geoGeocoder = new GClientGeocoder();

								
// ====== Array for decoding the failure codes ======
var reasons=[];
reasons[G_GEO_SUCCESS]            = "Success";
reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
reasons[403]                      = "Error 403: Probably an incorrect error caused by a bug in the handling of invalid JSON.";

// ======= Global variables to remind us what to do next
var nextAddress = 0;
var markers;
var lastsearch = ""; 
var geoResult;	
	
geoGeocoder.getLocations(search, function (result)
  { 
    // If that was successful
    if (result.Status.code == G_GEO_SUCCESS) {
      map.clearOverlays(); 
      //document.getElementById("control").innerHTML = "Input: "+lastsearch+" "; 
      geoResult = result;

      // Loop through the results
      for (var i=0; i<result.Placemark.length; i++) {
        var p = result.Placemark[i].Point.coordinates;
        var lat=p[1];
        var lng=p[0];
        var point = new GLatLng(lat,lng); 
        map.addOverlay(new GMarker(point));
        if (i==0) {
          map.setCenter(point);
        }
      }
    }
    // ====== Decode the error status ======
    else {
      var reason="Error code "+result.Status.code;
      if (reasons[result.Status.code]) {
        reason = reasons[result.Status.code]
      }
      alert(reason);
    }
  }
);
}