var RouteBrowser=new Class({Implements:Options,options:{center:null,feedURI:null,container:null,zoomLevel:6},initialize:function(b){this.setOptions(b);this.activeMarkers=[];var a={center:new google.maps.LatLng(this.options.center.lat,this.options.center.lng),zoom:this.options.zoomLevel,mapTypeId:google.maps.MapTypeId.ROADMAP};this.map=new google.maps.Map($(this.options.container),a);this.clusterer=new MarkerClusterer(this.map);this.clusterer.setMaxZoom(10);this.loadMarkers()},addMarker:function(a){this.clusterer.addMarker(a)},addMarkers:function(a){this.clusterer.addMarkers(a)},loadMarkers:function(){var a=new Request.JSON({method:"GET",url:this.options.feedURI,onComplete:this.handleLoadMarkers.bind(this)});a.get()},handleLoadMarkers:function(d){if(d){var e=[];for(var c=0;c<d.length;c++){var b={position:new google.maps.LatLng(d[c].lat,d[c].lng),title:d[c].title,icon:new google.maps.MarkerImage("/style/icon_fietsroute.png",new google.maps.Size(34,32),new google.maps.Point(0,0),new google.maps.Point(17,16))};var a=new google.maps.Marker(b);google.maps.event.addListener(a,"click",this.loadPage.bind(this,d[c].id));e.push(a)}this.clusterer.addMarkers(e)}},loadPage:function(a){window.location.href=a}});function MarkerClusterer(e,a,d){this.extend(MarkerClusterer,google.maps.OverlayView);this.map_=e;this.markers_=[];this.clusters_=[];this.sizes=[53,56,66,78,90];this.styles_=[];this.ready_=false;var b=d||{};this.gridSize_=b.gridSize||60;this.maxZoom_=b.maxZoom||null;this.styles_=b.styles||[];this.imagePath_=b.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_;this.imageExtension_=b.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_;this.zoomOnClick_=b.zoomOnClick||true;this.setupStyles_();this.setMap(e);this.prevZoom_=this.map_.getZoom();var c=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var f=c.map_.mapTypes[c.map_.getMapTypeId()].maxZoom;var g=c.map_.getZoom();if(g<0||g>f){return}if(c.prevZoom_!=g){c.prevZoom_=c.map_.getZoom();c.resetViewport()}});google.maps.event.addListener(this.map_,"bounds_changed",function(){c.redraw()});if(a&&a.length){this.addMarkers(a,false)}}MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m";MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png";MarkerClusterer.prototype.extend=function(b,a){return(function(c){for(property in c.prototype){this.prototype[property]=c.prototype[property]}return this}).apply(b,[a])};MarkerClusterer.prototype.onAdd=function(){this.setReady_(true)};MarkerClusterer.prototype.idle=function(){};MarkerClusterer.prototype.draw=function(){};MarkerClusterer.prototype.setupStyles_=function(){for(var b=0,a;a=this.sizes[b];b++){this.styles_.push({url:this.imagePath_+(b+1)+"."+this.imageExtension_,height:a,width:a})}};MarkerClusterer.prototype.setStyles=function(a){this.styles_=a};MarkerClusterer.prototype.getStyles=function(){return this.styles_};MarkerClusterer.prototype.isZoomOnClick=function(){return this.zoomOnClick_};MarkerClusterer.prototype.getMarkers=function(){return this.markers_};MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_};MarkerClusterer.prototype.setMaxZoom=function(a){this.maxZoom_=a};MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_||this.map_.mapTypes[this.map_.getMapTypeId()].maxZoom};MarkerClusterer.prototype.calculator_=function(e,d){var a=0;var c=e.length;var b=c;while(b!==0){b=parseInt(b/10,10);a++}a=Math.min(a,d);return{text:c,index:a}};MarkerClusterer.prototype.setCalculator=function(a){this.calculator_=a};MarkerClusterer.prototype.getCalculator=function(){return this.calculator_};MarkerClusterer.prototype.addMarkers=function(d,c){for(var b=0,a;a=d[b];b++){this.pushMarkerTo_(a)}if(!c){this.redraw()}};MarkerClusterer.prototype.pushMarkerTo_=function(a){a.setVisible(false);a.setMap(null);a.isAdded=false;if(a.draggable){var b=this;google.maps.event.addListener(a,"dragend",function(){a.isAdded=false;b.resetViewport();b.redraw()})}this.markers_.push(a)};MarkerClusterer.prototype.addMarker=function(a,b){this.pushMarkerTo_(a);if(!b){this.redraw()}};MarkerClusterer.prototype.removeMarker=function(b){var c=-1;if(this.markers_.indexOf){c=this.markers_.indexOf(b)}else{for(var d=0,a;a=this.markers_[d];d++){if(a==b){c=d;continue}}}if(c==-1){return false}this.markers_.splice(c,1);b.setVisible(false);b.setMap(null);this.resetViewport();this.redraw();return true};MarkerClusterer.prototype.setReady_=function(a){if(!this.ready_){this.ready_=a;this.createClusters_()}};MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length};MarkerClusterer.prototype.getMap=function(){return this.map_};MarkerClusterer.prototype.setMap=function(a){this.map_=a};MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_};MarkerClusterer.prototype.setGridSize=function(a){this.gridSize_=a};MarkerClusterer.prototype.getExtendedBounds=function(e){var c=this.getProjection();var f=new google.maps.LatLng(e.getNorthEast().lat(),e.getNorthEast().lng());var h=new google.maps.LatLng(e.getSouthWest().lat(),e.getSouthWest().lng());var d=c.fromLatLngToDivPixel(f);d.x+=this.gridSize_;d.y-=this.gridSize_;var b=c.fromLatLngToDivPixel(h);b.x-=this.gridSize_;b.y+=this.gridSize_;var g=c.fromDivPixelToLatLng(d);var a=c.fromDivPixelToLatLng(b);e.extend(g);e.extend(a);return e};MarkerClusterer.prototype.isMarkerInBounds_=function(a,b){return b.contains(a.getPosition())};MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport();this.markers_=[]};MarkerClusterer.prototype.resetViewport=function(){for(var c=0,a;a=this.clusters_[c];c++){a.remove()}for(var c=0,b;b=this.markers_[c];c++){b.isAdded=false;b.setMap(null);b.setVisible(false)}this.clusters_=[]};MarkerClusterer.prototype.redraw=function(){this.createClusters_()};MarkerClusterer.prototype.createClusters_=function(){if(!this.ready_){return}var c=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast());var g=this.getExtendedBounds(c);for(var e=0,b;b=this.markers_[e];e++){var f=false;if(!b.isAdded&&this.isMarkerInBounds_(b,g)){for(var d=0,a;a=this.clusters_[d];d++){if(!f&&a.getCenter()&&a.isMarkerInClusterBounds(b)){f=true;a.addMarker(b);break}}if(!f){var a=new Cluster(this);a.addMarker(b);this.clusters_.push(a)}}}};function Cluster(a){this.markerClusterer_=a;this.map_=a.getMap();this.gridSize_=a.getGridSize();this.center_=null;this.markers_=[];this.bounds_=null;this.clusterIcon_=new ClusterIcon(this,a.getStyles(),a.getGridSize())}Cluster.prototype.isMarkerAlreadyAdded=function(b){if(this.markers_.indexOf){return this.markers_.indexOf(b)!=-1}else{for(var c=0,a;a=this.markers_[c];c++){if(a==b){return true}}}return false};Cluster.prototype.addMarker=function(a){if(this.isMarkerAlreadyAdded(a)){return false}if(!this.center_){this.center_=a.getPosition();this.calculateBounds_()}if(this.markers_.length==0){a.setMap(this.map_);a.setVisible(true)}else{if(this.markers_.length==1){this.markers_[0].setMap(null);this.markers_[0].setVisible(false)}}a.isAdded=true;this.markers_.push(a);this.updateIcon();return true};Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_};Cluster.prototype.getBounds=function(){this.calculateBounds_();return this.bounds_};Cluster.prototype.remove=function(){this.clusterIcon_.remove();delete this.markers_};Cluster.prototype.getCenter=function(){return this.center_};Cluster.prototype.calculateBounds_=function(){var a=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(a)};Cluster.prototype.isMarkerInClusterBounds=function(a){return this.bounds_.contains(a.getPosition())};Cluster.prototype.getMap=function(){return this.map_};Cluster.prototype.updateIcon=function(){var e=this.map_.getZoom();var f=this.markerClusterer_.getMaxZoom();if(e>f){for(var c=0,a;a=this.markers_[c];c++){a.setMap(this.map_);a.setVisible(true)}return}if(this.markers_.length<2){this.clusterIcon_.hide();return}var d=this.markerClusterer_.getStyles().length;var b=this.markerClusterer_.getCalculator()(this.markers_,d);this.clusterIcon_.setCenter(this.center_);this.clusterIcon_.setSums(b);this.clusterIcon_.show()};function ClusterIcon(a,c,b){a.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView);this.styles_=c;this.padding_=b||0;this.cluster_=a;this.center_=null;this.map_=a.getMap();this.div_=null;this.sums_=null;this.visible_=false;this.setMap(this.map_)}ClusterIcon.prototype.triggerClusterClick=function(){var a=this.cluster_.getMarkerClusterer();google.maps.event.trigger(a,"clusterclick",[this.cluster_]);if(a.isZoomOnClick()){this.map_.panTo(this.cluster_.getCenter());this.map_.fitBounds(this.cluster_.getBounds())}};ClusterIcon.prototype.onAdd=function(){this.div_=document.createElement("DIV");if(this.visible_){var c=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(c);this.div_.innerHTML=this.sums_.text}var a=this.getPanes();a.overlayImage.appendChild(this.div_);var b=this;google.maps.event.addDomListener(this.div_,"click",function(){b.triggerClusterClick()})};ClusterIcon.prototype.getPosFromLatLng_=function(b){var a=this.getProjection().fromLatLngToDivPixel(b);a.x-=parseInt(this.width_/2,10);a.y-=parseInt(this.height_/2,10);return a};ClusterIcon.prototype.draw=function(){if(this.visible_){var a=this.getPosFromLatLng_(this.center_);this.div_.style.top=a.y+"px";this.div_.style.left=a.x+"px"}};ClusterIcon.prototype.hide=function(){if(this.div_){this.div_.style.display="none"}this.visible_=false};ClusterIcon.prototype.show=function(){if(this.div_){var a=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(a);this.div_.style.display=""}this.visible_=true};ClusterIcon.prototype.remove=function(){this.setMap(null)};ClusterIcon.prototype.onRemove=function(){if(this.div_&&this.div_.parentNode){this.hide();this.div_.parentNode.removeChild(this.div_);this.div_=null}};ClusterIcon.prototype.setSums=function(a){this.sums_=a;this.text_=a.text;this.index_=a.index;if(this.div_){this.div_.innerHTML=a.text}this.useStyle()};ClusterIcon.prototype.useStyle=function(){var a=Math.max(0,this.sums_.index-1);a=Math.min(this.styles_.length-1,a);var b=this.styles_[a];this.url_=b.url;this.height_=b.height;this.width_=b.width;this.textColor_=b.opt_textColor;this.anchor=b.opt_anchor;this.textSize_=b.opt_textSize};ClusterIcon.prototype.setCenter=function(a){this.center_=a};ClusterIcon.prototype.createCss=function(d){var c=[];if(document.all){c.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="'+this.url_+'");')}else{c.push("background:url("+this.url_+");")}if(typeof this.anchor_==="object"){if(typeof this.anchor_[0]==="number"&&this.anchor_[0]>0&&this.anchor_[0]<this.height_){c.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;")}else{c.push("height:"+this.height_+"px; line-height:"+this.height_+"px;")}if(typeof this.anchor_[1]==="number"&&this.anchor_[1]>0&&this.anchor_[1]<this.width_){c.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;")}else{c.push("width:"+this.width_+"px; text-align:center;")}}else{c.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;")}var a=this.textColor_?this.textColor_:"black";var b=this.textSize_?this.textSize_:11;c.push("cursor:pointer; top:"+d.y+"px; left:"+d.x+"px; color:"+a+"; position:absolute; font-size:"+b+"px; font-family:Arial,sans-serif; font-weight:bold");return c.join("")};window.MarkerClusterer=MarkerClusterer;MarkerClusterer.prototype.addMarker=MarkerClusterer.prototype.addMarker;MarkerClusterer.prototype.addMarkers=MarkerClusterer.prototype.addMarkers;MarkerClusterer.prototype.clearMarkers=MarkerClusterer.prototype.clearMarkers;MarkerClusterer.prototype.getCalculator=MarkerClusterer.prototype.getCalculator;MarkerClusterer.prototype.getGridSize=MarkerClusterer.prototype.getGridSize;MarkerClusterer.prototype.getMap=MarkerClusterer.prototype.getMap;MarkerClusterer.prototype.getMarkers=MarkerClusterer.prototype.getMarkers;MarkerClusterer.prototype.getMaxZoom=MarkerClusterer.prototype.getMaxZoom;MarkerClusterer.prototype.getStyles=MarkerClusterer.prototype.getStyles;MarkerClusterer.prototype.getTotalClusters=MarkerClusterer.prototype.getTotalClusters;MarkerClusterer.prototype.getTotalMarkers=MarkerClusterer.prototype.getTotalMarkers;MarkerClusterer.prototype.redraw=MarkerClusterer.prototype.redraw;MarkerClusterer.prototype.removeMarker=MarkerClusterer.prototype.removeMarker;MarkerClusterer.prototype.resetViewport=MarkerClusterer.prototype.resetViewport;MarkerClusterer.prototype.setCalculator=MarkerClusterer.prototype.setCalculator;MarkerClusterer.prototype.setGridSize=MarkerClusterer.prototype.setGridSize;MarkerClusterer.prototype.onAdd=MarkerClusterer.prototype.onAdd;MarkerClusterer.prototype.draw=MarkerClusterer.prototype.draw;MarkerClusterer.prototype.idle=MarkerClusterer.prototype.idle;ClusterIcon.prototype.onAdd=ClusterIcon.prototype.onAdd;ClusterIcon.prototype.draw=ClusterIcon.prototype.draw;ClusterIcon.prototype.onRemove=ClusterIcon.prototype.onRemove;var Gallery=new Class({initialize:function(b){this.images=[];this.current=0;this.intervalTimer=null;this.views=[];var d=$(b);if(d&&d.hasClass("gallery")){var a=d.getElements("li a");for(var c=0;c<a.length;c++){this.images.push({src:a[c].get("href"),title:a[c].get("text")})}}this.container=new Element("div",{"class":"gallery"});this.container.replaces(d);d.destroy();if(this.images.length>1){this.views.push(new GalleryThumbnails(this))}this.views.push(new GalleryImages(this));this.jumpto(0);if(this.images.length>1){this.start()}},start:function(){this.intervalTimer=this.next.periodical(5000,this)},stop:function(){$clear(this.intervalTimer)},next:function(){if(this.current+1<this.images.length){this.current++}else{this.current=0}this.signal()},jumpto:function(a){if(a<this.images.length&&a>=0){this.current=a;this.signal()}},signal:function(){for(var a=0;a<this.views.length;a++){this.views[a].update()}}});var GalleryImages=new Class({initialize:function(c){this.model=c;this.images=[];this.container=new Element("div",{"class":"images clear"});this.container.inject(this.model.container);for(var d=0;d<this.model.images.length;d++){var e=new Element("div",{"class":"image",styles:{display:"none"}});var b=new Element("span",{"class":"label",text:this.model.images[d].title});b.inject(e);var a=new Image();a.set({title:this.model.images[d].title,styles:{opacity:0},events:{load:function(){this.tween("opacity",[0,1])}.bind(a)}});this.images.push({container:e,image:a});a.inject(e);e.inject(this.container)}},update:function(){for(var a=0;a<this.images.length;a++){if(a==this.model.current){this.images[a].container.setStyle("display","block");if(this.images[a].image.src==""){this.images[a].image.src="/images/content550"+this.model.images[a].src}}else{this.images[a].container.setStyle("display","none")}}}});var GalleryThumbnails=new Class({initialize:function(c){this.model=c;this.thumbs=[];this.container=new Element("div",{"class":"thumbnails clear"});this.container.inject(this.model.container,"top");for(var d=0;d<this.model.images.length;d++){var b=new Element("div",{"class":"thumb"});if(d==this.model.current){b.addClass("selected")}var a=new Image();a.set("src","/images/thumb50"+this.model.images[d].src);a.set("title",this.model.images[d].title);a.inject(b);b.inject(this.container);this.thumbs.push(b);b.addEvent("mouseenter",this.focus.bindWithEvent(this,b));b.addEvent("mouseleave",this.blur.bind(this))}},update:function(){for(var a=0;a<this.thumbs.length;a++){if(this.thumbs[a].hasClass("selected")){this.thumbs[a].removeClass("selected")}}this.thumbs[this.model.current].addClass("selected")},focus:function(b,a){this.model.stop();this.model.jumpto(this.thumbs.indexOf(a))},blur:function(a){this.model.start()}});var BikeRoute=new Class({Implements:Options,options:{debug:true,distanceMarkers:true,markerDistance:10000,container:"bikeroute"},initialize:function(b){this.setOptions(b);this.distance=0;this.markerIndex=0;this.markers={poi:{},distance:[]};this.segments=[];this.container=$(this.options.container);var c=new Element("div",{"class":"header clear"});this.distanceLabel=new Element("div",{"class":"distance"});c.grab(this.distanceLabel);this.container.grab(c);var a=new Element("div",{id:"map_canvas",styles:{height:"500px"}});this.container.grab(a);this.map=new google.maps.Map(a,{mapTypeId:google.maps.MapTypeId.ROADMAP});this.directions=new Element("div",{"class":"directions"});this.container.grab(this.directions);google.maps.event.addListener(this.map,"click",this.testMagnetic.bind(this))},centerMap:function(a){this.map.fitBounds(a)},addSegment:function(c,b){var a=new RouteSegment({path:c,type:b!=null?b:RouteSegment.type.BIKE,map:this.map});this.segments.push(a);this.distance+=a.length;this.updateDistanceLabel()},addPOI:function(b){var a=new RoutePoi({position:new google.maps.LatLng(b.lat,b.lng),map:this.map,type:b.type,title:$defined(b.title)?b.title:"",description:$defined(b.description)?b.description:"",photo:$defined(b.photo)?b.photo:null});if([RoutePoi.type.START,RoutePoi.type.FINISH,RoutePoi.type.TURNLEFT,RoutePoi.type.TURNRIGHT].contains(b.type)){var c=new RouteDirections(a);this.directions.grab(c.container)}if([RoutePoi.type.TURNLEFT,RoutePoi.type.TURNRIGHT].contains(b.type)){a.set("visible",false)}},addDistanceMarker:function(b,e){var d=Math.floor(e/this.options.markerDistance);var c=new google.maps.Marker({position:b,map:this.map,icon:"/style/icon_distance_"+d+".png"});this.markers.distance.push(c)},updateDistanceLabel:function(){var a=this.distance/1000;this.distanceLabel.set("text",a.toFixed(2)+" km")},testMagnetic:function(f){var g=new google.maps.Circle({map:this.map,center:f.latLng,radius:50});for(var e=0;e<this.segments.length;e++){if(this.segments[e].bounds.intersects(g.getBounds())){var a=null;var k=50;for(var c=0;c<this.segments[e].path.length;c++){if(g.getBounds().contains(this.segments[e].path[c])){var h=RouteSegment.getPointDistance(this.segments[e].path[c],f.latLng);if(h<k){k=h;a=this.segments[e].path[c]}}}if(a!=null){var b=new google.maps.Marker({map:this.map,position:a});break}}}g=null}});if($defined(window.google)){var RouteDirections=new Class({Implements:google.maps.MVCObject,initialize:function(a){this.container=new Element("div",{"class":"step clear"});this.poi=a;this.bindTo("title",this.poi);this.bindTo("type",this.poi);if(this.poi.title!=null&&this.poi.title!=""){this.titleContainer=new Element("h2",{text:this.poi.title});this.container.grab(this.titleContainer)}if(this.poi.photo!=null&&this.poi.photo!=""){this.container.setStyle("background-image",'url("'+this.poi.photo+'")')}else{this.container.setStyle("background-image",'url("/style/icon_'+this.poi.type+'.png")')}if(this.poi.description!=null&&this.poi.description!=""){this.descriptionContainer=new Element("p",{text:this.poi.description});this.container.grab(this.descriptionContainer)}this.container.addEvent("mouseenter",this.showPoi.bind(this));this.container.addEvent("mouseleave",this.hidePoi.bind(this))},showPoi:function(){this.poi.set("visible",true);this.poi.map.panTo(this.poi.position)},hidePoi:function(){if(this.poi.type==RoutePoi.type.TURNLEFT||this.poi.type==RoutePoi.type.TURNRIGHT){this.poi.set("zIndex",1);this.poi.set("visible",false)}}})}var RouteEditor=new Class({icons:{uitzichtpunt:{url:"/style/icon_uitzichtpunt.png",size:[20,20],origin:[0,0],anchor:[10,10]},museum:{url:"/style/icon_uitzichtpunt.png",size:[20,20],origin:[0,0],anchor:[10,10]},restaurant:{url:"/style/icon_restaurant.png",size:[24,24],origin:[0,0],anchor:[12,12]},stoplicht:{url:"/style/icon_stoplicht.png",size:[24,40],origin:[0,0],anchor:[12,30]},spoorweg:{url:"/style/icon_spoorweg.png",size:[23,21],origin:[0,0],anchor:[12,21]},brug:{url:"/style/icon_brug.png",size:[24,21],origin:[0,0],anchor:[12,20]}},initialize:function(a,b){var c={center:new google.maps.LatLng(52.0161890334619,4.33402061462402),zoom:9,mapTypeId:google.maps.MapTypeId.ROADMAP,draggableCursor:"crosshair"};this.map=new google.maps.Map($(a),c);this.infowindow=new google.maps.InfoWindow();google.maps.event.addListener(this.infowindow,"closeclick",this.saveChanges.bind(this));this.controls=$(b);var d=new Element("button",{text:"save"});d.addEvent("click",this.exportPOIs.bind(this));this.controls.grab(d);this.form=new Element("form");var f=new Element("div",{"class":"formfield"});this.form.grab(f);f.grab(new Element("label",{text:"type"}));var e=new Element("select",{name:"type"});for(key in this.icons){e.grab(new Element("option",{text:key}))}f.grab(e);f=new Element("div",{"class":"formfield"});f.grab(new Element("label",{text:"naam"}));f.grab(new Element("input",{name:"name",type:"text",styles:{width:"300px"}}));this.form.grab(f);f=new Element("div",{"class":"formfield"});f.grab(new Element("label",{text:"omschrijving"}));f.grab(new Element("textarea",{name:"description",rows:5,styles:{width:"300px"}}));this.form.grab(f);this.infowindow.setContent(this.form);this.POIs=[];this.activeMarker=null;google.maps.event.addListener(this.map,"click",this.addPOI.bind(this))},addPOI:function(c){var b={draggable:true,position:c.latLng,map:this.map};var a=new google.maps.Marker(b);google.maps.event.addListener(a,"type_changed",this.updateIcon.bindWithEvent(this,a));google.maps.event.addListener(a,"click",this.showInfoWindow.bindWithEvent(this,a));a.set("type","uitzichtpunt");this.showInfoWindow(null,a);this.POIs.push(a)},showInfoWindow:function(b,a){if(this.activeMarker!=null){this.saveChanges()}this.activeMarker=a;this.updateForm();this.infowindow.open(this.map,a)},closeInfoWindow:function(){this.saveChanges();this.infowindow.close()},updateIcon:function(b,a){var d=a.get("type");var c=new google.maps.MarkerImage(this.icons[d].url,new google.maps.Size(this.icons[d].size[0],this.icons[d].size[0]),new google.maps.Point(this.icons[d].origin[0],this.icons[d].origin[0]),new google.maps.Point(this.icons[d].anchor[0],this.icons[d].anchor[0]));a.setIcon(c)},updateForm:function(){var b=this.activeMarker.get("type");for(var a=0;a<this.form.type.length;a++){if(b==this.form.type.options[a].value){this.form.type.selectedIndex=a;break}}this.form.name.value=$defined(this.activeMarker.get("name"))?this.activeMarker.get("name"):"";this.form.description.value=$defined(this.activeMarker.get("description"))?this.activeMarker.get("description"):""},saveChanges:function(){if(this.activeMarker!=null){this.activeMarker.set("type",this.form.type.options[this.form.type.selectedIndex].value);this.activeMarker.set("name",this.form.name.value);this.activeMarker.set("description",this.form.description.value);this.activeMarker=null}},exportPOIs:function(){var a=[];var b=new XML("<gpx/>");for(var c=0;c<this.POIs.length;c++){var e=this.POIs[c];var f=<wpt lat={e.getPosition().lat()} lng={e.getPosition().lng()}>
                  <name>{e.get("name")}</name>
                  <desc>{e.get("description")}</desc>
                  <type>{e.get("type")}</type>
                </wpt>;b.appendChild(f);a.push({lat:e.getPosition().lat(),lng:e.getPosition().lng(),type:e.get("type"),name:e.get("name"),description:e.get("description")})}console.log(b.toXMLString());var d=new Request({url:"/api/routes.php",method:"post"});d.send({data:JSON.encode(a)})}});if($defined(window.google)){var RoutePhoto=new Class({Implements:google.maps.MVCObject,initialize:function(a){this.set("marker",new google.maps.Marker());this.marker.bindTo("map",this);this.marker.bindTo("title",this);this.marker.bindTo("position",this);this.marker.bindTo("visible",this);this.marker.bindTo("draggable",this);this.marker.setShadow(new google.maps.MarkerImage("/style/balloon_50.png",new google.maps.Size(64,64),new google.maps.Point(0,0),new google.maps.Point(27,59)));google.maps.event.addListener(this,"thumb_changed",this.thumbChanged.bind(this));this.setValues(a)},thumbChanged:function(){this.marker.setIcon(new google.maps.MarkerImage(this.thumb,new google.maps.Size(50,50),new google.maps.Point(0,0),new google.maps.Point(23,55)))}})}if($defined(window.google)){var RoutePoi=new Class({Implements:google.maps.MVCObject,initialize:function(a){this.set("marker",new google.maps.Marker());this.set("description","");this.set("photo",null);this.marker.bindTo("map",this);this.marker.bindTo("title",this);this.marker.bindTo("position",this);this.marker.bindTo("visible",this);this.marker.bindTo("draggable",this);this.marker.bindTo("zIndex",this);google.maps.event.addListener(this,"type_changed",this.typeChanged.bind(this));google.maps.event.addListener(this,"photo_changed",this.photoChanged.bind(this));this.setValues(a)},typeChanged:function(){var a=null;if(this.photo==null){switch(this.type){case RoutePoi.type.START:a=new google.maps.MarkerImage("/style/icon_start.png",new google.maps.Size(23,25),new google.maps.Point(0,0),new google.maps.Point(0,22));break;case RoutePoi.type.FINISH:a=new google.maps.MarkerImage("/style/icon_finish.png",new google.maps.Size(20,24),new google.maps.Point(0,0),new google.maps.Point(0,24));break;case RoutePoi.type.TRAFFICLIGHT:a="/style/icon_trafficlight.png";break;case RoutePoi.type.RAILCROSSING:a="/style/icon_railcrossing.png";break;case RoutePoi.type.BRIDGE:a="/style/icon_bridge.png";break;case RoutePoi.type.WARNING:a="/style/icon_warning.png";break;case RoutePoi.type.RESTAURANT:a="/style/icon_restaurant.png";break;case RoutePoi.type.VIEWPOINT:a=new google.maps.MarkerImage("/style/icon_viewpoint.png",new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(10,10));break;case RoutePoi.type.TURNLEFT:a=new google.maps.MarkerImage("/style/icon_left.png",new google.maps.Size(16,16),new google.maps.Point(0,0),new google.maps.Point(8,8));break;case RoutePoi.type.TURNRIGHT:a=new google.maps.MarkerImage("/style/icon_right.png",new google.maps.Size(16,16),new google.maps.Point(0,0),new google.maps.Point(8,8));break;default:a=""}this.marker.setIcon(a)}},photoChanged:function(){if(this.photo!=null&&this.photo!=""){this.marker.setIcon(new google.maps.MarkerImage(this.photo,new google.maps.Size(32,32),new google.maps.Point(0,0),new google.maps.Point(16,37)))}}});RoutePoi.type={START:"start",FINISH:"finish",TRAFFICLIGHT:"trafficlight",RAILCROSSING:"railcrossing",BRIDGE:"bridge",WARNING:"warning",RESTAURANT:"restaurant",VIEWPOINT:"uitzichtpunt",TURNRIGHT:"right",TURNLEFT:"left"}}if($defined(window.google)){var RoutePoiEditor=new Class({Implements:google.maps.MVCObject,initialize:function(a){this.set("infowindow",new google.maps.Infowindow());this.form=new Element("form");var c=new Element("div",{"class":"formfield"});this.form.grab(c);c.grab(new Element("label",{text:"type"}));var b=new Element("select",{name:"type"});for(key in RoutePoi.type){b.grab(new Element("option",{text:RoutePoi.type[key]}))}c.grab(b);c=new Element("div",{"class":"formfield"});c.grab(new Element("label",{text:"naam"}));c.grab(new Element("input",{name:"name",type:"text",styles:{width:"300px"}}));this.form.grab(c);c=new Element("div",{"class":"formfield"});c.grab(new Element("label",{text:"omschrijving"}));c.grab(new Element("textarea",{name:"description",rows:5,styles:{width:"300px"}}));this.form.grab(c);this.infowindow.setContent(this.form)}})}if($defined(window.google)){var RouteSegment=new Class({Implements:google.maps.MVCObject,initialize:function(a){this.length=0;this.distanceOffset=0;this.type=RouteSegment.type.BIKE;this.styles={alternative:{color:"#0072ff",weight:5,opacity:0.4},foot:{color:"#0072ff",weight:5,opacity:0.8},bike:{color:"#0072ff",weight:5,opacity:0.8}};this.polyline=new google.maps.Polyline();this.polyline.bindTo("map",this);this.polyline.bindTo("clickable",this);this.bounds=null;google.maps.event.addListener(this,"path_changed",this.calculateLength.bind(this));google.maps.event.addListener(this,"type_changed",this.updateStyles.bind(this));this.setValues(a)},calculateLength:function(){var e=0;var d=this.path[0].lat();var a=this.path[0].lng();var f=this.path[0].lat();var b=this.path[0].lng();for(var c=0;c<this.path.length-1;c++){e+=RouteSegment.getPointDistance(this.path[c],this.path[c+1]);d=this.path[c+1].lat()<d?this.path[c+1].lat():d;a=this.path[c+1].lng()<a?this.path[c+1].lng():a;f=this.path[c+1].lat()>f?this.path[c+1].lat():f;b=this.path[c+1].lng()>b?this.path[c+1].lng():b}this.bounds=new google.maps.LatLngBounds(new google.maps.LatLng(d,a),new google.maps.LatLng(f,b));this.length=e;this.polyline.setPath(this.path)},updateStyles:function(){this.polyline.set("strokeColor",this.styles[this.type].color);this.polyline.set("strokeWeight",this.styles[this.type].weight);this.polyline.set("strokeOpacity",this.styles[this.type].opacity)}});RouteSegment.type={ALTERNATIVE:"alternative",BIKE:"bike",FOOT:"foot"};RouteSegment.getPointDistance=function(i,e){var g=6378137;var d=(e.lat()-i.lat())*Math.PI/180;var f=(e.lng()-i.lng())*Math.PI/180;var b=Math.sin(d/2)*Math.sin(d/2)+Math.cos(i.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(f/2)*Math.sin(f/2);var h=2*Math.atan2(Math.sqrt(b),Math.sqrt(1-b));return g*h}}var TweetFeed=new Class({Implements:Options,options:{count:5,autoRefresh:false,refreshInterval:300,containerID:"TweetFeed",username:"",feedURI:""},initialize:function(a){this.setOptions(a);if(this.options.username!=""&&this.options.feedURI!=""){document.write('<div id="'+this.options.containerID+'"></div>');this.container=$(this.options.containerID);this.tweets={};this.requestHandler=new Request.JSON({method:"GET",url:this.options.feedURI,onComplete:this.handleTweetUpdate.bind(this)});if(this.options.autoRefresh){}this.updateTweets()}},updateTweets:function(){this.requestHandler.get({username:this.options.username,count:this.options.count})},handleTweetUpdate:function(b){if(b){var e=[];for(var a=0;a<b.length;a++){if(this.tweets[b[a].id]==null){var d=new Element("div",{"class":"tweet"});var c=b[a].text;c=this.linkifyTweet(c);if(Browser.Engine.trident){date=Date.parse(b[a].created_at.replace(/( \+)/," UTC$1"))}else{date=new Date(b[a].created_at)}c+='<br><span class="date_posted">posted '+this.getRelativeDate(new Date(b[a].created_at))+"</span>";d.innerHTML=c;this.tweets[b[a].id]=d;e.unshift(d)}}while(e.length>0){var d=e.shift();d.inject(this.container,"top")}}},getRelativeDate:function(d){var b=new Date();var c=b-d;var i=1000,f=i*60,e=f*60,h=e*24,a=h*7,g=h*365;if(isNaN(c)||c<0){return""}if(c<f){return Math.floor(c/i)+" seconds ago"}if(c<f*2){return"about 1 minute ago"}if(c<e){return Math.floor(c/f)+" minutes ago"}if(c<e*2){return"about 1 hour ago"}if(c<h){return Math.floor(c/e)+" hours ago"}if(c>h&&c<h*2){return"yesterday"}if(c<a){return Math.floor(c/h)+" days ago"}if(c>a&&c<a*2){"about 1 week ago"}if(c>a*2&&c<g){return Math.floor(c/a)+" weeks ago"}if(c>g){return"over a year ago"}},linkifyTweet:function(a){a=a.replace(/\b(((https*\:\/\/)|www\.).+?)(([!?,.\)]+)?(\s|$))/g,function(b,f,j,k,l){var i=j.match(/w/)?"http://":"";return'<a href="'+i+f+'">'+f+"</a>"+l});a=a.replace(/\B\@([a-zA-Z0-9_]{1,20})/g,function(e,b){return'<a href="http://twitter.com/'+b+'">@'+b+"</a>"});return a}});function orientationChanged(){if($chk(window.orientation)){if(window.orientation==0){document.body.addClass("upright");document.body.removeClass("flipped")}else{document.body.addClass("flipped");document.body.removeClass("upright")}}}function hideUrlBar(){window.scrollTo(0,1)}window.addEvent("domready",function(){$$(".gallery").each(function(a){new Gallery(a)})});if(Browser.Platform.ipod){window.addEvent("domready",orientationChanged);window.addEvent("orientationchange",orientationChanged);window.addEvent("load",hideUrlBar)};
