
function initializeGMap() {
	var map_container = document.getElementById('gmap_container');
	if (map_container && GBrowserIsCompatible()) {
		var map = new GMap2(map_container);
		if (gmapCenter && gmapCenter.length) {
			map.setCenter(new GLatLng(gmapCenter[0],gmapCenter[1]), gmapCenter[2]);
		} else {
			map.setCenter(new GLatLng(50.061106,19.906883), 12);
		}
		map.setUIToDefault();
		if (gmapMarkerData && gmapMarkerData.length) {
			var icon = new GIcon(G_DEFAULT_ICON);
			
			icon.image = '/static/img/icomap_img.png';
			icon.shadow = '/static/img/icomap_shd.png';
			icon.transparent = '/static/img/icomap_empty.png';
			icon.iconSize = new GSize(55, 50);
			icon.shadowSize = new GSize(55, 50);
			icon.iconAnchor = new GPoint(21, 48);
			icon.infoWindowAnchor = new GPoint(20, 20);
			icon.imageMap = [0,0,41,0,41,38,32,38,21,47,9,38,0,38];
			
			for (var i=0, l=gmapMarkerData.length; i<l; i++) {
				map.addOverlay(createMarker(
					gmapMarkerData[i][0],
					gmapMarkerData[i][1],
					gmapMarkerData[i][2], 
					gmapMarkerData[i][3], 
					icon
				));
			}
		}
	}
}

function createMarker(lat, lng, title, html, icon) {
	var opts = {};
	if (icon) opts.icon = icon;
	var marker = new GMarker(new GLatLng(lat, lng), opts);
	if (html.length) html = '<div class="gmap_html_txt">' + html + '</div>';
	if (title.length) html = '<div class="gmap_html_title">' + title + '</div>' + html;
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html, {"maxWidth": 150});
	});
	return marker;
}

