$(document).ready(function(){MapHandler.init()});$(document).unload(function(){GUnload()});$.getScript=function(b,c,a){$.ajax({type:"GET",url:b,success:c,dataType:"script",cache:a})};var MapMarkerType={SELECTED:"selected",HOTEL:"hotel",OV:"ov",BZW:"bzw"};var MapHandler={defaultLocation:{lat:null,lon:null,zoom:null},markers:[],markerSetHandlers:[],markerSets:[],loadedMarkerSets:0,map:null,init:function(){if(GBrowserIsCompatible()&&typeof(MapMarkerSets)!=="undefined"){this.renderGoogleMap();this.getMarkerSetHandlers();this.getMarkerSets();this.addExternalMarkerSetsResources();this.updateGoogleMap()}},addExternalMarkerSetsResources:function(){if(typeof(ExternalMapMarkerSetLocations)!=="undefined"){for(var a=0;ExternalMapMarkerSetLocations[a]!==undefined;a++){$.getScript(ExternalMapMarkerSetLocations[a],function(){setTimeout("MapHandler.getMarkerSetsResource()",500)},true)}}},getMarkerSetsResource:function(){this.getMarkerSets();this.updateGoogleMap()},getMarkerSets:function(){for(var b=this.markerSets.length;MapMarkerSets[b]!==undefined;b++){var a=new MarkerSet(MapMarkerSets[b]);this.linkMarkerSetToMarkerSetHandler(a);this.markerSets.push(a)}},linkMarkerSetToMarkerSetHandler:function(a){for(var b=0;this.markerSetHandlers[b]!==undefined;b++){if(a.type==this.markerSetHandlers[b].type){this.markerSetHandlers[b].setRelatedMarkerSet(a)}}},getMarkerSetHandlers:function(){for(var a=0;MapMarkerSetHandlers[a]!==undefined;a++){this.markerSetHandlers.push(new MarkerSetHandler(MapMarkerSetHandlers[a]))}},renderGoogleMap:function(){var a=document.getElementById("map");if(a){this.map=new GMap2(a);this.map.addControl(new GLargeMapControl());this.map.addControl(new GMapTypeControl());this.map.addControl(new GOverviewMapControl());this.map.addControl(new GScaleControl())}if(this.map){this.panToDefaultLocation();GEvent.bind(this.map,"moveend",this,this.refreshMarkers)}},updateGoogleMap:function(){this.renderMarkerSetHandlers();this.initMarkers();this.refreshMarkers()},panToDefaultLocation:function(){this.map.setCenter(new GLatLng(this.defaultLocation.lat,this.defaultLocation.lon),this.defaultLocation.zoom)},renderMarkerSetHandlers:function(){for(var a=0;this.markerSetHandlers[a]!==undefined;a++){this.markerSetHandlers[a].append()}},initMarkers:function(){for(var a=0;this.markerSets[a]!==undefined;a++){this.markerSets[a].initMarkers()}},refreshMarkers:function(){var a=this.map.getBounds();for(var b=0;this.markerSets[b]!==undefined;b++){if(this.markerSets[b].maxVisible>0){var c=this.getMarkersWithinBounds(this.markerSets[b],a);c=this.getMaxVisibleMarkers(this.markerSets[b].maxVisible,c);this.markerSets[b].refreshMarkers(c)}else{this.markerSets[b].addMarkers()}}},getMarkersWithinBounds:function(d,b){var c=[];for(var a=0;d.markers[a]!==undefined;a++){if(d.markers[a].inBounds(b)){c.push(d.markers[a])}}return c},getMaxVisibleMarkers:function(a,b){if(b.length>a){return b.splice(0,a-1)}return b},isUniqueMarker:function(a){if(!this.markers[a]){this.markers[a]=true;return true}return false}};function MarkerSetHandler(a){this.id="markerset_"+a.type;this.type=a.type;this.text=a.text;this.icon=a.icon;this.checkbox=null;this.indicator=null;this.relatedMarkerSet=null}MarkerSetHandler.prototype.disable=function(){var a=document.getElementById(this.id);$(a).css({opacity:0.33});this.checkbox.setAttribute("disabled","disabled");this.indicator=document.createElement("img");this.indicator.setAttribute("src","/static/img/loader.gif");this.indicator.className="loadingIndicator";a.appendChild(this.indicator)};MarkerSetHandler.prototype.enable=function(){var a=document.getElementById(this.id);if(a){$(a).fadeTo("slow",1);if(this.checkbox!=null){this.checkbox.removeAttribute("disabled")}if(this.indicator!=null){$(this.indicator).fadeTo("slow",0)}}};MarkerSetHandler.prototype.setRelatedMarkerSet=function(a){this.relatedMarkerSet=a;this.enable()};MarkerSetHandler.prototype.append=function(){if(!document.getElementById(this.id)){var f=document.createElement("li");f.id=this.id;var d=document.createElement("span");d.className="markersettoggle";if(this.type!=MapMarkerType.SELECTED){this.checkbox=document.createElement("input");this.checkbox.setAttribute("type","checkbox");this.checkbox.id="toggle_"+this.type;var c=this;$(this.checkbox).click(function(){c.toggleMarkers()});d.appendChild(this.checkbox)}var b=document.createElement("img");b.setAttribute("src",this.icon);b.setAttribute("alt","");var e=null;if(this.type!=MapMarkerType.SELECTED){e=document.createElement("label");e.setAttribute("for","toggle_"+this.type)}else{e=document.createElement("span")}e.className="markersetlabel";e.innerHTML=this.text;f.appendChild(d);f.appendChild(b);f.appendChild(e);var a=document.getElementById("markersets");if(this.type!=MapMarkerType.SELECTED){a.appendChild(f)}else{a.insertBefore(f,a.firstChild)}if(this.type!=MapMarkerType.SELECTED){this.checkbox.setAttribute("checked","checked")}if(this.relatedMarkerSet==null){this.disable()}}};MarkerSetHandler.prototype.toggleMarkers=function(){if(this.relatedMarkerSet!=null){this.relatedMarkerSet.toggleMarkers(this.checkbox.checked)}};function MarkerSet(a){this.type=a.type;this.image=a.image;this.shadow=a.shadow;this.template=a.template;this.maxVisible=a.maxVisible;this.sortBy=a.sortBy;this.markerOptions=this.getMarkerOptions();this.markers=[];this.markersAdded=false;for(var b=0;a.items[b]!==undefined;b++){if(MapHandler.isUniqueMarker(a.items[b].id)){this.markers.push(new Marker(a.items[b],this.markerOptions,this.type,this.template))}}this.sortMarkers()}MarkerSet.prototype.sortMarkers=function(){var a=this.sortBy;if(typeof(this.sortBy)!="undefined"){this.markers.sort(function(d,c){return c.data[a]-d.data[a]})}};MarkerSet.prototype.getMarkerOptions=function(){var a=new GIcon();a.image=this.image.src;a.iconSize=new GSize(this.image.width,this.image.height);a.shadow=this.shadow.src;a.shadowSize=new GSize(this.shadow.width,this.shadow.height);a.iconAnchor=new GPoint(this.image.width,this.image.height);a.infoWindowAnchor=new GPoint(this.image.width-10,this.image.height-10);return{icon:a}};MarkerSet.prototype.toggleMarkers=function(b){for(var a=0;this.markers[a]!==undefined;a++){this.markers[a].allowVisible=b;this.markers[a].toggle()}};MarkerSet.prototype.initMarkers=function(){for(var a=0;this.markers[a]!==undefined;a++){this.markers[a].init()}};MarkerSet.prototype.refreshMarkers=function(b){for(var a=0;this.markers[a]!==undefined;a++){if(this.isAllowedMarker(this.markers[a].id,b)){this.markers[a].add()}else{this.markers[a].remove()}}};MarkerSet.prototype.isAllowedMarker=function(c,b){for(var a=0;b[a]!==undefined;a++){if(c==b[a].id){return true}}return false};MarkerSet.prototype.addMarkers=function(){if(!this.markersAdded){this.markersAdded=true;for(var a=0;this.markers[a]!==undefined;a++){this.markers[a].add()}}};function Marker(b,c,a,d){this.data=b;this.id=this.data.id;this.type=a;this.options=c;this.template=d;this.location=new GLatLng(this.data.lat,this.data.lon);this.gMarker=null;this.html=null;this.allowVisible=true;this.alreadyAdded=false}Marker.prototype.init=function(){if(this.gMarker==null){this.gMarker=new GMarker(this.location,this.options);GEvent.bind(this.gMarker,"click",this,this.expand)}};Marker.prototype.toggle=function(){if(this.allowVisible){this.gMarker.show()}else{this.gMarker.hide();this.gMarker.closeInfoWindow()}};Marker.prototype.add=function(){if(!this.alreadyAdded){this.alreadyAdded=true;MapHandler.map.addOverlay(this.gMarker);this.toggle()}};Marker.prototype.remove=function(){MapHandler.map.removeOverlay(this.gMarker);this.alreadyAdded=false;this.gMarker.closeInfoWindow()};Marker.prototype.expand=function(){if(this.html==null){this.html=this.getHTMLFromTemplate()}this.gMarker.openInfoWindowHtml(this.html)};Marker.prototype.inBounds=function(a){return a.containsLatLng(this.location)};Marker.prototype.getHTMLFromTemplate=function(){var a=this.template;for(var d in this.data){var b=new RegExp("%"+d+"%","g");var c=this.data[d];a=a.replace(b,c)}return a};
