	var emap;
	var unactiveMarkerOptions;
	var activeMarkerOptions;
	var lastMarker = null;
	var allMarkers = new Array();
	
	function mapInitialize(lat, long) {
		if (GBrowserIsCompatible()) {
			emap = new GMap2(document.getElementById("google_map"));
			emap.addControl(new GSmallZoomControl());
 			var center = new GLatLng(59.4375, 24.7546);
			emap.setCenter(center, 14);
			emap.disableDoubleClickZoom();

			GEvent.addListener(emap, "click", selectCarPark);

			var customUI = emap.getDefaultUI();
			customUI.controls.scalecontrol = false;
			customUI.controls.menumaptypecontrol = false;
			customUI.keyboard = false;
			customUI.doubleclick = false;
			customUI.scrollwheel = false;

			//Create unactive carparc icon
			var cpImage = new GIcon();
			cpImage.image = "img/cp.gif";
			cpImage.shadow = null;
			cpImage.iconSize = new GSize(20, 20);
			cpImage.shadowSize = null;
			cpImage.iconAnchor = new GPoint(10, 10);
			cpImage.infoWindowAnchor = new GPoint(10, 10);
			unactiveMarkerOptions = { icon:cpImage };

			//Create activeactive carparc icon
			var cpaImage = new GIcon();
			cpaImage.image = "img/cpa.gif";
			cpaImage.shadow = null;
			cpaImage.iconSize = new GSize(20, 20);
			cpaImage.shadowSize = null;
			cpaImage.iconAnchor = new GPoint(10, 10);
			cpaImage.infoWindowAnchor = new GPoint(10, 10);
			activeMarkerOptions = { icon:cpaImage };
				
			getPointsRequest();
		}
	}
	
	function changeCity(id, longitude, latitude, zoomlevel, name) {
		
		if(!zoomlevel) zoomlevel = 13;
		var center = new GLatLng(Number(longitude), Number(latitude));
		emap.setCenter(center, Number(zoomlevel));
		
		//change tabs
		$('#cities li').removeClass('selected');
		$('#tab_city_' + id ).addClass('selected');
		
		$('#parkinfo').hide();
		
		if(name == 'Pärnu') {
		
			var pfix = '';
			if(window.language && window.language == 'eng' ) {
				pfix = '-eng';
			}
			
			$.get("http://www.europark.ee/?page=parkimine-paernus" + pfix, function(str) {
				$('#zoneinfo').html(str).show();
			});
			
			
		} else {
		
			if(window.showZoneInfo) showZoneInfo(name);
		}

	}
	
	function selectCarPark(marker, latLng, overlayLatLng){
		if (marker == null)
			return;
		if (lastMarker != null){
			lastMarker.setImage("img/cp.gif");
		}
		marker.setImage("img/cpa.gif");
		lastMarker = marker;
		loadCarParkData(marker.value);
	}

	
	function showCarParks(points){
		var point;
		var marker;
		for (var i=0; i<points.length; i++){
			point = new GLatLng(points[i].latitude, points[i].longitude);
			marker = new GMarker(point, unactiveMarkerOptions);
			marker.value = points[i].parkingzone_id;
			allMarkers.push(marker);
			emap.addOverlay(marker);
		}
	}
