// JavaScript Document

var geo;
var map;
var show=false;

function hideMap(mapa) {
	document.getElementById(mapa).style.display="none";
	document.getElementById('a-'+mapa).innerHTML="Pokaż mapę dojazdową";			
	document.getElementById('a-'+mapa).name="show";						
}

	
function mapStartStop(mapa,name,address){
	if(GBrowserIsCompatible()){
		if(document.getElementById('a-'+mapa).name!='hide'){
			document.getElementById(mapa).style.display="block";
			document.getElementById('a-'+mapa).innerHTML="Schowaj mapę";			
			document.getElementById('a-'+mapa).name="hide";						
	
			map = new GMap2(document.getElementById(mapa));				
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(52, 19.4), 7);
			map.setUIToDefault();

			var ikona = new GIcon();   
			ikona.image = "img/maps_ico01.png";   
			ikona.iconSize = new GSize(39, 39);   
			ikona.infoWindowAnchor = new GPoint(20,20);   
			ikona.iconAnchor = new GPoint(20,20);   
		
			geo = new GClientGeocoder();
			geo.getLatLng(address,function(punkt){
				if (!punkt){
					alert("Przepraszamy. Wyszukany adres: " + address + " nie został znaleziony w mapach Google.");
				}
					else{
					map.setCenter(punkt, 15);
		
					var marker = new GMarker(punkt, ikona);
					map.addOverlay(marker);
		
					marker.openInfoWindowHtml('<div class="dymek"><span class="name">'+name+'</span><br /><span class="address">'+address+'</span></div>');
					}
				}
			);
		} else {
			hideMap(mapa);
		}	
	}
}


