﻿var map = null;
var geocoder = null;
    
function GoogleMapLoad()
{
    var hidGoogleMapAddress;
    
    hidGoogleMapLongitude = document.getElementById('hidGoogleMapLongitude');
    hidGoogleMapLatitude = document.getElementById('hidGoogleMapLatitude');

    if (GBrowserIsCompatible)
    {
        if (GBrowserIsCompatible())
        {
            var divGoogleMap = document.getElementById("divGoogleMap");
                        
            if (divGoogleMap != undefined)
            {
                map = new GMap2(divGoogleMap);
                
                if (map != null)
                {
		            map.addControl(new GSmallMapControl());
		            map.addControl(new GMapTypeControl());
		            geocoder = new GClientGeocoder();
	            }

                GoogleMapShowAddress(hidGoogleMapLongitude.value, hidGoogleMapLatitude.value);
            }
        }
    }
}

function GoogleMapUnload()
{
    var divGoogleMap = document.getElementById("divGoogleMap");
    if (divGoogleMap != undefined && GUnload) GUnload();
}

function GoogleMapShowAddress(longitude, latitude)
{
    var divGoogleMap = document.getElementById("divGoogleMap");
    
    if (geocoder)
    {                
        var point = new GLatLng(latitude, longitude);
        map.setCenter(point, 14);
        var marker = new GMarker(point);
        map.addOverlay(marker);        
    }
}