(function(){mxn.activatePolluteMode();NewMind.mapping=function(){var B={};var A=0;return{DEBUG:false,DEBUG_OUTPUT_DIV:null,DEFAULT_MAP_PROVIDER:"multimap",configure:function(C){for(var D in C){if(C.hasOwnProperty(D)){this[D]=C[D]}}},debugWrite:function(C){if(this.DEBUG&&this.DEBUG_OUTPUT_DIV){this.DEBUG_OUTPUT_DIV.innerHTML+=C+"<br/>"}},addMap:function(C,D){NewMind.mapping.debugWrite("Adding map "+C);B[C]=new NewMind.mapping.Map(C,D);return B[C]},getMap:function(C){if(typeof (C)=="string"){return B[C]||null}return C},getMapID:function(C){for(var D in B){if(B[D]===C){return D}}throw"Matching map object not found, object not created with addMap?"},getMapIDList:function(){var D=[];for(var C in B){if(B.hasOwnProperty(C)){D.push(C)}}return D},getNextInteger:function(){return ++A},addMarkerOkToShowDelegate:function(D,C){if(!("okToShowDelegates" in D)){D.okToShowDelegates=[];D.show=NewMind.mapping.markerShow}D.okToShowDelegates.push(C)},markerShow:function(){var D=true;for(var C=0;C<this.okToShowDelegates.length;C++){if(!this.okToShowDelegates[C].call(null,this)){D=false;break}}if(D){this.constructor.prototype.show.call(this)}else{this.hide()}}}}();NewMind.mapping.Map=function(K,F){var H=true;var C={};var L=0;var G={};var M=0;var J=F||NewMind.mapping.DEFAULT_MAP_PROVIDER;this.mapstractionMap=new Mapstraction(K,J,NewMind.mapping.DEBUG);this.getLoadingMessageClone=function(N){if((typeof (N)==="undefined")||(N!==true)){N=false}var O=document.createElement("div");O.className="loadingMessage";O.innerHTML="Loading...";O.style.display=N?"block":"none";this.mapstractionMap.currentElement.appendChild(O);return O};var D=this.getLoadingMessageClone();this.zoomChanged=new NewMind.CustomEvent("zoomChanged",this);this.infoBoxOpened=new NewMind.CustomEvent("infoBoxOpened",this);this.beforeUpdate=new NewMind.CustomEvent("beforeUpdate",this);this.afterUpdate=new NewMind.CustomEvent("afterUpdate",this);this.addOverlay=function(O,N){NewMind.mapping.debugWrite("Adding overlay "+O);if(!(O in C)){N.parentMap=this;N.OverlayID=O;N.init();C[O]=N;if(arguments.length>2&&arguments[2]===true){this.updateView()}}else{throw new Error("Overlay already exists with ID "+O)}};this.getOverlay=function(N){return C[N]||null};this.getOverlayList=function(){var N=[];for(var O in C){if(C.hasOwnProperty(O)){N.push(O)}}return N};this.getContainerID=function(){return K};var I=function(P){var Q=this.mapstractionMap.getCenter();var N=this.mapstractionMap.getZoom();NewMind.mapping.DebugOutput("NewMind.mapping.MaponMapMove: "+Q.toString());var O=true;if(NewMind.mapping.DISABLE_STORE_POS_IN_HASH===true){O=false}if(O){window.location.hash="mapx="+NewMind.correctFloatError(Q.lon)+"&mapy="+NewMind.correctFloatError(Q.lat)+"&mapz="+N}if(M!=N){this.zoomChanged.fire(N-M)}M=N;this.updateView()};var E=function(O,N){this.cancelAllTrans()};var B=function(N){};var A=function(N){this.infoBoxOpened.fire(N.marker)};this.updateView=function(){if(H){var N="d"+NewMind.mapping.getNextInteger().toString();G[N]=0;this.beforeUpdate.fire();this.showLoadingMessage();var P=this.mapstractionMap.getBounds();NewMind.mapping.debugWrite("Updating view "+P.toString()+" -- "+this.mapstractionMap.getZoom());for(var O in C){if(!C[O].updateView(N,P)){G[N]++}}if(G[N]===0){this.updateDone(N)}this.afterUpdate.fire()}};this.showLoadingMessage=function(){D.style.display="block"};this.hideLoadingMessage=function(){D.style.display="none"};this.updateDone=function(N){if(N in G){G[N]--;if(G[N]<=0){delete G[N]}}if(NewMind.countProps(G)===0){this.hideLoadingMessage()}};this.cancelTran=function(N){if(N in G){for(var O in C){C[O].cancelTran(N)}G[N]=0;this.updateDone(N)}};this.cancelAllTrans=function(){for(var N in G){this.cancelTran(N)}};this.toggleVisibility=function(){H=!H;if(H){this.updateView()}};this.mapstractionMap.addEventListener("moveend",I,this);this.mapstractionMap.addEventListener("click",B,this);this.mapstractionMap.addEventListener("openinfobox",A,this);this.zoomChanged.subscribe(E)};NewMind.mapping.Overlay=function(){var A=true;this.AreaCovered=[];this.TileSize=new LatLonPoint(0.018,0.025);this.toggleShowHide=new NewMind.CustomEvent("toggleShowHide",this);this.OverlayID=undefined;this.parentMap=undefined;this.Active=true;this.IsDynamic=false;this.Data=undefined;this.DataSource=undefined;this.showHideCheckbox=undefined;this.DoneInitialLoad=false;this.waitingOnTiles={};this.waitingOn=0;this.show=function(){if(A===false){A=true;if(this.showHideCheckbox){this.showHideCheckbox.checked=true}this.toggleShowHide.fire(true)}};this.hide=function(){if(A===true){A=false;if(this.showHideCheckbox){this.showHideCheckbox.checked=false}this.toggleShowHide.fire(false)}};this.getShowing=function(){return A}};NewMind.mapping.Overlay.prototype={updateView:function(B,D){var C;if(this.IsDynamic){NewMind.mapping.debugWrite("Updating dynamic overlay "+this.OverlayID+" - "+B);var A=this.getDataTileRequired(D);if(A!==null){C=this.DataSource.getData(B,A);if(C.complete){if(C.error===0){this.render(C.data)}NewMind.mapping.debugWrite("Updating done "+this.OverlayID+" - "+B);return true}else{this.waitingOnTiles[B]=A;NewMind.mapping.debugWrite("Updating not done "+this.OverlayID+" - "+B);return false}}NewMind.mapping.debugWrite("No update to do "+this.OverlayID+" - "+B)}else{if(this.DataSource!==undefined&&!this.DoneInitialLoad){C=this.DataSource.getData();this.Data=C.data;this.render(this.Data);this.DoneInitialLoad=true}else{if(!this.IsDynamic&&!this.DoneInitialLoad){this.render(this.Data);this.DoneInitialLoad=true}}}return true},dataReady:function(A){NewMind.mapping.debugWrite("Data returned for "+A.tranid);if(this.getTranValid(A.tranid)){if(A.error===0){try{this.render(A.data)}catch(C){if(NewMind.mapping.DEBUG){throw C}}var B=this.waitingOnTiles[A.tranid];this.AreaCovered.push(B)}delete this.waitingOnTiles[A.tranid];this.parentMap.updateDone.call(this.parentMap,A.tranid)}},cancelTran:function(A){if(A in this.waitingOnTiles){NewMind.mapping.debugWrite("Overlay update cancelled "+this.OverlayID+" - "+A);delete this.waitingOnTiles[A];this.parentMap.updateDone.call(this.parentMap,A)}},getTranValid:function(A){return A in this.waitingOnTiles},getDataTileBoundingBox:function(A){var C=Math.floor((A.lat+2e-7)/this.TileSize.lat);var B=Math.floor((A.lon+2e-7)/this.TileSize.lon);return new BoundingBox(NewMind.correctFloatError(C*this.TileSize.lat),NewMind.correctFloatError(B*this.TileSize.lon),NewMind.correctFloatError((C+1)*this.TileSize.lat),NewMind.correctFloatError((B+1)*this.TileSize.lon))},getCorrectedBoundingBox:function(E){var A=E.getSouthWest();var G=E.getNorthEast();var D=this.getDataTileBoundingBox(A);var C=this.getDataTileBoundingBox(G);var B=D.getSouthWest();var F=C.getNorthEast();return new BoundingBox(B.lat,B.lon,F.lat,F.lon)},getDataTileRequired:function(C){var B=this.getCorrectedBoundingBox(C);var D=B.getSouthWest();var A=B.getNorthEast();if(this.doneThisBoundingBox(B)){B=null}return B},doneThisBoundingBox:function(D){var B=D.getSouthWest();var A=D.getNorthEast();for(var C=0;C<this.AreaCovered.length;C++){if(this.AreaCovered[C].contains(B)&&this.AreaCovered[C].contains(A)){return true}}return false},getShowHideCheckbox:function(){if(!this.showHideCheckbox){this.showHideCheckbox=document.createElement("input");this.showHideCheckbox.type="checkbox";this.showHideCheckbox.id="chk-overlayshowhide-"+this.OverlayID;this.showHideCheckbox.className="chk-overlayshowhide";this.showHideCheckbox.checked=this.getShowing();NewMind.dom.addEventListener(this.showHideCheckbox,"click",NewMind.bind(this.showHideClickHandler,this))}return this.showHideCheckbox},showHideClickHandler:function(A){var B=NewMind.dom.getEventSource(A);if(B.checked){this.show()}else{this.hide()}},setDataSource:function(A){if(A&&A.isDynamic!==undefined&&A.overlay!==undefined&&typeof (A.getData)=="function"){this.DataSource=A;this.DataSource.overlay=this;this.IsDynamic=this.DataSource.isDynamic;this.DataSource.init()}else{this.Data=A}},init:function(){throw"Cannot call init on abstract NewMind.mapping.Overlay"},render:function(){throw"Cannot call render on abstract NewMind.mapping.Overlay"},reset:function(){this.DoneInitialLoad=false;this.AreaCovered=[]}};NewMind.mapping.MarkerOverlay=function(A){this.superclass.prototype.constructor.call(this);var B=null;this.setFilterPane=function(C){B=C};this.getFilterPane=function(){return B};this.LoadedMarkers=[];this.ImageOverlays=[];this.Decluttering=false;this.DeclutteringOptions={};this.markerAdded=new NewMind.CustomEvent("markerAdded",this);this.setDataSource(A)};NewMind.extend(NewMind.mapping.MarkerOverlay,NewMind.mapping.Overlay);NewMind.mapping.MarkerOverlay.prototype.init=function(){this.parentMap.zoomChanged.subscribe(this.handleZoomChanged,this,true);this.toggleShowHide.subscribe(this.onToggleShowHide,this,true);if(this.Decluttering){if(!("groupName" in this.DeclutteringOptions)){this.DeclutteringOptions.groupName=this.OverlayID}this.parentMap.mapstractionMap.declutterMarkers(this.DeclutteringOptions)}};NewMind.mapping.MarkerOverlay.prototype.render=function(A){if(A){this.addMarkers(A)}else{}};NewMind.mapping.MarkerOverlay.prototype.onToggleShowHide=function(C,B,D){for(var A=0;A<this.LoadedMarkers.length;A++){if(B[0]){this.LoadedMarkers[A].show()}else{this.LoadedMarkers[A].hide()}}for(var E=0;E<this.ImageOverlays.length;E++){if(B[0]){this.ImageOverlays[E].style.display="block"}else{this.ImageOverlays[E].style.display="none"}}};NewMind.mapping.MarkerOverlay.prototype.reset=function(){while(this.LoadedMarkers.length>0){var A=this.LoadedMarkers.pop();this.parentMap.mapstractionMap.removeMarker(A)}while(this.ImageOverlays.length>0){var B=this.ImageOverlays.pop();B.style.display="none"}this.superclass.prototype.reset.call(this)};NewMind.mapping.MarkerOverlay.prototype.handleZoomChanged=function(B,A,C){};NewMind.mapping.MarkerOverlay.prototype.addMarkers=function(D){for(var G=0;G<D.length;G++){markerData=D[G];markerData.groupName=this.OverlayID;var A=new LatLonPoint(markerData.lat,markerData.lon);var C=new Marker(A);C.addData(markerData);this.LoadedMarkers.push(C);if(markerData.showProximity){var F=mxn.fn.metresToLon(5000,A.lat);var E=mxn.fn.metresToLon(5000,0);var B="overlay_"+NewMind.mapping.getNextInteger();if(NewMind.env.platform.type==="enterprise"){strGraphicsPath="/engine"}else{strGraphicsPath="/sitebuilder"}this.parentMap.mapstractionMap.addImageOverlay(B,strGraphicsPath+"/shared_gfx/radius.png",30,A.lon-F,A.lat-E,A.lon+F,A.lat+E);if(typeof (correctPNG)!="undefined"){correctPNG()}this.ImageOverlays.push(document.getElementById(B))}this.parentMap.mapstractionMap.addMarker(C);this.markerAdded.fire(C)}};NewMind.mapping.PolylineOverlay=function(A){this.superclass.prototype.constructor.call(this);this.Polyline=undefined;this.LoadedMarkers=[];this.ImageOverlays=[];this.setDataSource(A)};NewMind.extend(NewMind.mapping.PolylineOverlay,NewMind.mapping.Overlay);NewMind.mapping.PolylineOverlay.prototype.init=function(){this.toggleShowHide.subscribe(this.onToggleShowHide,this,true)};NewMind.mapping.PolylineOverlay.prototype.onToggleShowHide=function(C,B,D){if(B[0]){this.parentMap.mapstractionMap.addPolyline(this.Polyline)}else{this.parentMap.mapstractionMap.removePolyline(this.Polyline)}for(var A=0;A<this.LoadedMarkers.length;A++){if(B[0]){this.LoadedMarkers[A].show()}else{this.LoadedMarkers[A].hide()}}};NewMind.mapping.PolylineOverlay.prototype.render=function(){if(this.Data){var G=[];var C=[];var B=null;if(this.Data.documentElement){var F=this.Data.documentElement.getElementsByTagName("rtept");for(var A=0;A<F.length;A++){G.push(new LatLonPoint(F[A].getAttribute("lat"),F[A].getAttribute("lon")));var D=F[A].getElementsByTagName("desc");if(D.length>0&&D[0].firstChild&&(D[0].firstChild.nodeName=="#text"||D[0].firstChild.nodeName=="#cdata-section")){C.push({lat:F[A].getAttribute("lat"),lon:F[A].getAttribute("lon"),label:D[0].firstChild.nodeValue,infoBubble:D[0].firstChild.nodeValue})}}}else{for(var E=0;E<this.Data.points.length;E++){G.push(new LatLonPoint(this.Data.points[E].lat,this.Data.points[E].lon))}B=this.Data}this.Polyline=new Polyline(G);if(B){this.Polyline.addData(B)}this.parentMap.mapstractionMap.addPolyline(this.Polyline);this.addMarkers(C);if(!this.getShowing()){this.toggleShowHide.fire(false)}}else{throw"No data"}};NewMind.mapping.PolylineOverlay.prototype.addMarkers=function(D){for(var G=0;G<D.length;G++){markerData=D[G];markerData.groupName=this.OverlayID;var A=new LatLonPoint(markerData.lat,markerData.lon);var C=new Marker(A);C.addData(markerData);this.LoadedMarkers.push(C);if(markerData.showProximity){var F=metresToLon(8047,A.lat);var E=metresToLon(8047,0);var B="overlay_"+NewMind.mapping.getNextInteger();if(NewMind.env.platform.type==="enterprise"){strGraphicsPath="/engine"}else{strGraphicsPath="/sitebuilder"}this.parentMap.mapstractionMap.addImageOverlay(B,strGraphicsPath+"/shared_gfx/radius.png",30,A.lon-F,A.lat-E,A.lon+F,A.lat+E);if(typeof (correctPNG)!="undefined"){correctPNG()}this.ImageOverlays.push(document.getElementById(B))}this.parentMap.mapstractionMap.addMarker(C)}};NewMind.mapping.PolylineOverlay.prototype.show=function(){for(var A=0;A<this.LoadedMarkers.length;A++){this.LoadedMarkers[A].show()}for(var B=0;B<this.ImageOverlays.length;B++){this.ImageOverlays[B].style.display="block"}};NewMind.mapping.PolylineOverlay.prototype.hide=function(){for(var A=0;A<this.LoadedMarkers.length;A++){this.LoadedMarkers[A].hide()}for(var B=0;B<this.ImageOverlays.length;B++){this.ImageOverlays[B].style.display="none"}};NewMind.mapping.MapDataSource=function(){};NewMind.mapping.MapDataSource.prototype={isDynamic:false,overlay:null,init:function(){},getData:function(){throw"Cannot call getData on abstract NewMind.mapping.MapDataSource"},getMarkerIcon:function(E,H){var D=null;if(typeof (E)==="string"){D=E}else{if((typeof (E)==="object")&&(E.product)&&(E.product.product_key)){D=E.product.product_key}}if(typeof (H)==="undefined"){H="def"}var C=((NewMind.env)&&(NewMind.env.platform)&&(NewMind.env.platform)&&(NewMind.env.platform.type==="enterprise"));if(C){var B="/engine"}else{var B="/sitebuilder"}var G=["acco","attr","cate","even"];var F=null;if(D!==null){D=String(D).toLowerCase();for(var A=0;A<G.length;A++){if(D===G[A].toLowerCase()){F=D.toLowerCase();break}}}return{iconUrl:B+"/shared_gfx/mkr-"+H+(F===null?"":"-"+F)+".png",iconSize:[23,26],iconAnchor:[12,0]}}};NewMind.mapping.DebugOutput=function(E){if(!NewMind.mapping.DEBUG){return }var D="DebugOutput";var A=document.getElementById(D);if(!A){var A=document.createElement("div");A.id=D;var B=document.body;if(B.childNodes.length===0){B.appendChild(B)}else{B.insertBefore(A,B.childNodes[0])}}A.innerHTML+="["+C(new Date())+"] "+E.replace(/\n/g,"<br/>")+"<br/>";function C(G){var H=new Date();return F(H.getHours(),2)+":"+F(H.getMinutes(),2)+":"+F(H.getSeconds(),2)+"."+F(H.getMilliseconds(),3);function F(J,I){var K=String(J);while(K.length<I){K="0"+K}return K}}};NewMind.mapping.DebugOutputObject=function(E,A,D,B){var I;if(E===null){I="null"}else{if(typeof (E)!=="object"){I="DebugOutputObject - not an object: ["+typeof (E)+"] "+E}else{if(!A){A=[]}else{if(typeof (A)==="string"){A=[A]}}if(D!==true){D=false}if(B!==true){B=false}I="";var G;for(i in E){G=false;if((D)&&!E.hasOwnProperty(i)){G=true}else{var F=String(typeof (E[i])).toUpperCase();for(var H=0;H<A.length;H++){var C=String(A[H]).toUpperCase();if(C===F){G=true;break}}}if(!G){I+="["+typeof (E[i])+"] "+i;if(!B){I+=": "+E[i]}I+="\n"}}}}NewMind.mapping.DebugOutput(I)}})();
