var gWindows = [];
var gMarker = [];
var gVisible = [false, false, true, false];

function setMarkers(map, markers) {
	markers.each(
		function(item) {

			
			var infoWindow = new google.maps.InfoWindow({
				content : item.content,
				zIndex : 59
			});
			gWindows.push(infoWindow);
			var marker = new google.maps.Marker({
				map:map,
				position:item.position,
				title:item.title,
				icon:item.icon,
				type:item.type
			});
			marker.setVisible(gVisible[item.type]);
			gMarker.push(marker);
			google.maps.event.addListener(marker, 'click', function() {
				gWindows.each(function(item) {
					item.close();
				});
				infoWindow.open(map, marker);
			});
		}
	);
}


function prev(e) {

	if(window.event) { event.returnValue = false; } // IE
	if(e.cancelable) { e.preventDefault(); } // DOM-Standard

}

function fitMap(map, points ) {
   var bounds = new GLatLngBounds();
   for (var i=0; i< points.length; i++) {
      bounds.extend(points[i]);
   }
   map.setZoom(map.getBoundsZoomLevel(bounds));
   map.setCenter(bounds.getCenter());
}

function switchCategory (category ) {
	gVisible[category] = !gVisible[category];
	gMarker.each(function(item){
		
		if (item.getVisible() != gVisible[item.type])
			item.setVisible(gVisible[item.type]);
	});
}
