$(document).ready(function() {
    if (GBrowserIsCompatible()) {
		if($("#map_canvas").length){
			var map = new GMap2(document.getElementById("map_canvas"));
			map.addControl(new GSmallMapControl());
			map.disableScrollWheelZoom();
			var geocoder = new GClientGeocoder();
		}
        if($("#location_address").length) {
            var address = $("#location_address").text();
            geocoder.getLatLng(
                address,
                function(point) {
                    map.clearOverlays();
                    if (!point) {
                        $("#map_block").hide();
                        $("#map_canvas").hide("fast");
                    } else {
                        map.setCenter(point, 15);
                        var marker = new GMarker(point);
                        map.addOverlay(marker);
                      //  GEvent.addListener(marker, "click", function() {
                        //    map.openInfoWindowHtml(point, address);
                        //});
                       // map.openInfoWindowHtml(point, address);
                    }
                });
        } else
        if($("#place").length) {
            geocodePlace = function(){
                address = $("input#place").val();
                geocoder.getLatLng(
                    address,
                    function(point) {
                        map.clearOverlays();
                        if (!point) {
                            $("#map_canvas").hide("fast");
                        } else {
                            $("#map_canvas").show("fast");
                            map.setCenter(point, 15);
                            var marker = new GMarker(point);
                            map.addOverlay(marker);
                            GEvent.addListener(marker, "click", function() {
                                map.openInfoWindowHtml(point, address);
                            });
                            map.openInfoWindowHtml(point, address);
                        }
                    });
                }
            geocodePlace();
        } else
            $("#map_block").hide();
    }
});