	var map;
	var zoom = 13;

	// FlyTo function - allows us to fly to certein point with slow nice move.
	function flyTo(iBusinessId) {
		function subGPoints(a,b) { return new GPoint(a.x-b.x, a.y-b.y); }
		//Pixel distance to the center of the map
		var CDivPixel = map.fromLatLngToDivPixel(map.getCenter());
		//Pixel distance from the marker point
		var pointDivPixel = map.fromLatLngToDivPixel(marker.getLatLng());
		//Difference between the above mentioned distances
		var fromCenter = subGPoints(pointDivPixel, CDivPixel);
		//Pan to the corrected location (the -40 and +215 sizes are the distances from my marker to the center of the infowindow
		map.panBy(new GSize((fromCenter.x*(-1))-50,(fromCenter.y*(-1))+90));
	}
		
	// Initialize Google Map
	function initializeGoogleMaps() {
		
		if (GBrowserIsCompatible()) {
			// create marker icon
			var baseIcon = new GIcon();
			baseIcon.image = "http://krakow-apartments.eu/logic_frontend/templates/site/images/googlemaps/marker.png";
			baseIcon.iconSize = new GSize(50, 43);
			baseIcon.iconAnchor = new GPoint(12, 41);
			baseIcon.infoWindowAnchor = new GPoint(12, 12);
			baseIcon.infoShadowAnchor = new GPoint(12, 12);
			// assign marker icon to marker
			var markerOptions = { icon:baseIcon };
			map = new GMap2(document.getElementById("map"));
			
			var baseIconMulti = new GIcon();
			baseIconMulti.image = "http://krakow-apartments.eu/logic_frontend/templates/site/images/googlemaps/multimarker.png";
			baseIconMulti.iconSize = new GSize(50, 43);
			baseIconMulti.iconAnchor = new GPoint(12, 41);
			baseIconMulti.infoWindowAnchor = new GPoint(12, 12);
			baseIconMulti.infoShadowAnchor = new GPoint(12, 12);
			// assign marker icon to marker
			var markerMultiOptions = { icon:baseIconMulti };
		
			//map.addControl(new GSmallMapControl());
			//map.addControl(new GMapTypeControl());
			
			
			// custom control buttons
			/* var zin = document.createElement('a');
			var zout = document.createElement('a');
			zin.id = 'zoom_in';
			zout.id = 'zoom_out';
			zin.href = ('javascript:;');
			zout.href = ('javascript:;');
			
			jQuery('#map_controls_zoomin').append(zin);
			jQuery('#map_controls_zoomout').append(zout);
			GEvent.addDomListener(zin, "click", function(){map.zoomIn();});
			GEvent.addDomListener(zout, "click", function(){map.zoomOut();});
			*/
			var l=0;
			// create autoCenter and autozoom
			var latlngbounds = new GLatLngBounds( );
			// create markers
			for(l=0; l<aiGoogleL.length;l++){			
				var point = new GLatLng(aiGoogleL[l][0], aiGoogleL[l][1]);
				if(aiGoogleL[l][3]==1){
					marker = new GMarker(point, markerMultiOptions);	
				}
				else{
					marker = new GMarker(point, markerOptions);
				}
				latlngbounds.extend(point);
				
				marker.bindInfoWindowHtml(aiGoogleL[l][2], {pixelOffset:new GSize(100,100)});
				//GEvent.addDomListener(marker,"infowindowopen",  function() {flyTo();});
				// place marker on a map
				map.addOverlay(marker);
			}
			map.setCenter( latlngbounds.getCenter( ), map.getBoundsZoomLevel( latlngbounds ) );
			map.setUIToDefault();
			map.disableScrollWheelZoom();
		}
	}
	
	jQuery(document).ready(function() { initializeGoogleMaps(); });