
function MapManager(idMapContainer, hideControls)
{
  this.idMapContainer = idMapContainer;
  this.zoomLevel = 13;
  this.map = null;
  
  this.getMap = function(){
    if( this.map != null )
      return this.map;
    if (GBrowserIsCompatible()) 
    {
      this.map = new GMap2($(this.idMapContainer));
      if( hideControls==null || hideControls==false)
      {
        this.map.addControl(new GLargeMapControl3D());
        this.map.addControl(new GMapTypeControl());
      }
      return this.map;
    }
    else
    {
      alert("Sorry, the Google Maps API is not compatible with this browser");
      return  null;
    }
  }
  
  this.show = function(latitude, longitude, zoomLevel){
    var currentMap = this.getMap();
    if( zoomLevel != null )
      this.zoomLevel = zoomLevel;
    currentMap.setCenter(new GLatLng(latitude, longitude), this.zoomLevel);
  }
  //----------------------------------------------------------------
  this.createMarker = function(latitude, longitude, html){
    var marker = new GMarker(new GLatLng(latitude, longitude));
    if( html != null )
    {
      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(html);
        }
      );
    }
    return marker;
  }
  //----------------------------------------------------------------
  this.addNewMarker = function(latitude, longitude, html) {
    var marker = this.createMarker(latitude, longitude, html);
    var currentMap = this.getMap();
    currentMap.addOverlay(marker);
    return marker;
  }
  //----------------------------------------------------------------
  this.addMarker = function(marker) {
    var currentMap = this.getMap();
    currentMap.addOverlay(marker);
  }
  //----------------------------------------------------------------
  this.setMarkerAjaxContent = function(marker, url, urlParams) {
    GEvent.addListener(marker, "click", function() {
      var options = {
        onSuccess:function(t){
          marker.openInfoWindowHtml(t.responseText);
          },
        parameters: urlParams,
        asynchronous:true
      };
      new Ajax.Request(url, options);
      }
    );
  }
      
  //----------------------------------------------------------------
}  
  
  
  
  
  
  
  
  
  
   
