﻿/// Static Class

/// ASSERT: GBrowserIsCompatible() is true
B4TGeoMap = function(){};
B4TGeoMap._id = "B4TGeoMap";
B4TGeoMap._geocoder = null;
B4TGeoMap.get_geocoder = function ()
{
    if(!this._geocoder)
        this._geocoder = new GClientGeocoder();            
    return this._geocoder;     
};
B4TGeoMap.LoadMap = function (elementId, address, addressHtml)
{
    var tempGeocoder = B4TGeoMap.get_geocoder();
    
    if(tempGeocoder)
    {
        var map = new GMap2(document.getElementById(elementId));
        
        tempGeocoder.getLatLng(
            address,
            function(point) {
                if (!point) {
                    //jQuery('#map_canvas')[0].style.display = "none";
                    //jQuery('#_lblAddr')[0].style.display = "inline";
                    //alert(address + " not found");
                } else {
                    map.setCenter(point, 13);
                    map.addControl(new GSmallZoomControl());
                    var marker = new GMarker(point);
                    map.addOverlay(marker);   
                    
                    if(addressHtml)
                    {
                        GEvent.addListener(marker, "click", function() {  marker.openInfoWindowHtml(addressHtml);} );
                        marker.openInfoWindowHtml(addressHtml);
                    }
                }    
            }
        );
    }
};