var PMap=new Class({initialize:function(gMap){this.gMap=gMap;this.gMap.addControl(new GMapTypeControl());this.gMap.addControl(new GLargeMapControl());this.gMap.addControl(new GScaleControl());this.gMap.setCenter(new GLatLng(53.0379,5.9079),9);this.gMap.setMapType(G_SATELLITE_MAP);this.locations=new Array();this.locationsUrl='/locations.xml';this.loadLocations()},loadLocations:function(){new Ajax(this.locationsUrl,{method:'get',onComplete:this.responseLoadLocations.bind(this)}).request()},responseLoadLocations:function(responseText,responseXml){var markers=$A(responseXml.documentElement.getElementsByTagName('marker'));this.locations=new Array(markers.length);markers.each(function(marker,i){var latitude=marker.getElementsByTagName('latitude')[0].firstChild.nodeValue;var longitude=marker.getElementsByTagName('longitude')[0].firstChild.nodeValue;var title=marker.getElementsByTagName('title')[0].firstChild.nodeValue;var linksSelector=marker.getElementsByTagName('linksSelector')[0].firstChild.nodeValue;var landingStage=marker.getElementsByTagName('landingStage')[0].firstChild.nodeValue;var parkOpportunities=marker.getElementsByTagName('parkOpportunities')[0].firstChild.nodeValue;var sailLocations=marker.getElementsByTagName('sailLocations')[0].firstChild.nodeValue;if(latitude&&longitude){this.locations[i]=new PLocationMarker(title,landingStage,parkOpportunities,sailLocations,new GLatLng(parseFloat(latitude),parseFloat(longitude)),linksSelector,this)}},this);this.addLocationsMarkers();this.initializeLocationsLinks($E('body'))},addLocationsMarkers:function(){this.locations.each(function(location){this.gMap.addOverlay(location.marker)},this)},initializeLocationsLinks:function(scope){this.locations.each(function(location){if(location.linksSelector){$ES(location.linksSelector,scope).each(function(link){link.addEvent('click',this.locationLinkClick.bind(location))},this)}},this)},locationLinkClick:function(e){new Event(e).stop();this.open()},openLocation:function(location){this.gMap.panTo(location.point);var myAjax=new Ajax('/ships.php',{method:'post',data:'location='+location.title,update:$('map_ships'),onComplete:this.responseOpenLocation.bind(this)}).request()},responseOpenLocation:function(responseText,responseXml){$('map_search_locations').setStyle('display','none');$('map_ships').setStyle('display','block');$ES('.map_locations_link',$('map_ships')).each(function(link){link.addEvent('click',Site.openLocations)})}});var PLocationMarker=new Class({initialize:function(title,landingStage,parkOpportunities,sailLocations,point,linksSelector,map){this.title=title;this.landingStage=landingStage;this.parkOpportunities=parkOpportunities;this.sailLocations=sailLocations;this.point=point;this.linksSelector=linksSelector;this.map=map;this.createMarker()},zoomIn:function(){this.map.gMap.zoomIn()},zoomOut:function(){this.map.gMap.zoomOut()},createMarker:function(){var marker=new GMarker(this.point);GEvent.addListener(marker,"click",this.open.bind(this));this.marker=marker},createInfoWindow:function(){var infoWindow=new Element('div',{'class':'location_info'});var title=new Element('h2').appendText(this.title);infoWindow.adopt(title);var label=new Element('span',{'class':'label'}).setHTML('Ligplaats:');infoWindow.adopt(label).appendText(' '+this.landingStage).adopt(new Element('br'));var label=new Element('span',{'class':'label'}).setHTML('Parkeermogelijkheden:');infoWindow.adopt(label).appendText(' '+this.parkOpportunities).adopt(new Element('br'));var label=new Element('span',{'class':'label'}).setHTML('Vaargebied:');infoWindow.adopt(label).appendText(' '+this.sailLocations).adopt(new Element('br'));var zoom=new Element('span',{'class':'zoom'});var zoomIn=new Element('a',{'href':'#zoom_in','class':'zoom_link'}).setHTML('in').addEvent('click',this.zoomIn.bind(this));var zoomOut=new Element('a',{'href':'#zoom_uit','class':'zoom_link'}).setHTML('uit').addEvent('click',this.zoomOut.bind(this));zoom.appendText('Zoom: ').adopt(zoomIn).appendText(' / ').adopt(zoomOut);infoWindow.adopt(zoom);return infoWindow},open:function(){this.marker.openInfoWindow(this.createInfoWindow());this.map.openLocation(this)}});var Site={start:function(){if(GBrowserIsCompatible()){var map=new PMap(new GMap2(document.getElementById("map")))}Site.openLocations();$ES('.more_locations_link').each(function(link){link.addEvent('click',Site.openMoreLocations)});$ES('.map_locations_link').each(function(link){link.addEvent('click',Site.openLocations)})},openMoreLocations:function(e){new Event(e).stop();$('map_search_locations').setStyle('display','none');$('map_more_locations').setStyle('display','block')},openLocations:function(e){$('map_search_locations').setStyle('display','block');$('map_ships').setStyle('display','none');$('map_more_locations').setStyle('display','none')}};window.addEvent('domready',Site.start);
