var hotel_map;
var hotel_map_markers = [];
var hotel_map_infowindows = [];
var pin_icon;

function hotel_map_initialize() {
	
	    pin_icon = new google.maps.MarkerImage('fileadmin/templates/images/marker.png',
	        // This marker is 129 pixels wide by 42 pixels tall.
	        new google.maps.Size(37, 31),
	        // The origin for this image is 0,0.
	        new google.maps.Point(0,0),
	        // The anchor for this image is the base of the flagpole at 18,42.
	        new google.maps.Point(18, 42)
	    );
	
    myLatlng = new google.maps.LatLng(52.51209, 13.40859);
    var myOptions = {
    		disableDefaultUI: true,
      zoom: 12,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    hotel_map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
  
function hotel_map_addMarker(location,contentString) {
	
  var marker = new google.maps.Marker({
    position: location,
    map: hotel_map,
    icon: pin_icon,
    title: ''
  });
  
  if (contentString != '') {
	   var infowindow = new google.maps.InfoWindow({
	        content: '<div class="map_hotelinfo">'+contentString+'</div>',
	        maxWidth:700
	    });
  	
	    google.maps.event.addListener(marker, 'click', function() {
	    	
	    	for(infowindow_id in hotel_map_infowindows) {
	    		hotel_map_infowindows[infowindow_id].close();
	    	}
	    	
	      infowindow.open(hotel_map,marker);
	    });
  }
  
  hotel_map_infowindows.push(infowindow);
  hotel_map_markers.push(marker);
}

function hotel_map_addMarker_city(location,link_id) {
	
  var marker = new google.maps.Marker({
    position: location,
    map: hotel_map,
    icon: pin_icon,
    title: ''
  });

	google.maps.event.addListener(marker, 'click', function() {
		jQuery('#city_select #'+link_id).trigger('click');
	});

  hotel_map_markers.push(marker);
}

// Removes the overlays from the map, but keeps them in the array
function hotel_map_clearOverlays() {
  if (hotel_map_markers) {
    for (i in hotel_map_markers) {
    	hotel_map_markers[i].setMap(null);
    }
  }
}

// Shows any overlays currently in the array
function hotel_map_showOverlays() {
  if (hotel_map_markers) {
    for (i in hotel_map_markers) {
    	hotel_map_markers[i].setMap(map);
    }
  }
}

// Deletes all markers in the array by removing references to them
function hotel_map_deleteOverlays() {
  if (hotel_map_markers) {
    for (i in hotel_map_markers) {
    	hotel_map_markers[i].setMap(null);
    }
    hotel_map_markers.length = 0;
  }
}


