cb=function(A){eb="";for(var B in A){eb+=A[B]+" "}return eb};MLMakeRelativeURL=function(B,C){var A=B.lastIndexOf("\x2F");var D="";if(A>=0){D+=B.substring(0,A+1)}D+=C;return D};function MLData(){this.mapTitle="TITLE";this.userData=null;this.isLoaded=false;this.isEnabled=false}MLData.prototype.getBounds=function(){return null};MLTileData.prototype=new MLData();MLTileData.prototype.constructor=MLTileData;function MLTileData(){MLData.call(this);this.tileURL="";this.mapTitle="TITLE"}function MLTileData(D,B,C,E,F,G,H,A){MLData.call(this);this.mapTitle=B;this.mapBounds=C;this.maxZoomLevel=E;this.tileURL=F;this.colours=G;this.descriptions=H;this.userData=A;this.isLoaded=true;this.isEnabled=true}MLTileData.prototype.getBounds=function(){return this.mapBounds};MLTileData.prototype.getOverlay=function(){var A=new GTileLayer(this.copyrightCollection,0,17);A.baseUrl=this.tileURL;A.mapBounds=this.mapBounds;A.maxZoomLevel=this.maxZoomLevel;A.opacity=this.opacity;A.getTileUrl=function(M,L){if((!MLList.zoomPastLimit)&&(L>this.maxZoomLevel)){return this.baseUrl+"\x2Fblank-tile.png"}var J=Math.pow(2,L);var N=360/J*M.x-180;var K=180-360/J*M.y;var Q=N+360/J;var G=K-360/J;var P=N;var C=(2*Math.atan(Math.exp(K/180*Math.PI))-Math.PI/2)*180/Math.PI;var B=Q;var O=(2*Math.atan(Math.exp(G/180*Math.PI))-Math.PI/2)*180/Math.PI;var E=new GLatLngBounds(new GLatLng(O,P),new GLatLng(C,B));if(!E.intersects(this.mapBounds)){return this.baseUrl+"/blank-tile.png"}var I=M.x;var H=M.y;var F="t";for(var D=0;D<L;D++){J/=2;if(H<J){if(I<J){F+="q"}else{F+="r";I-=J}}else{if(I<J){F+="t";H-=J}else{F+="s";I-=J;H-=J}}}if(L>this.maxZoomLevel){return MLList.zoomPastWebService+"?z="+this.maxZoomLevel+"&t="+F+"&u="+this.baseUrl}return this.baseUrl+"\x2F"+F+".png"};A.isPng=function(){return false};A.getOpacity=function(){return this.opacity};return new GTileLayerOverlay(A)};MLTileData.prototype.getColourScaleHTML=function(){var D=this.mapTitle;var J="";var G="000000";if((this.colours!=null)&&(this.descriptions!=null)){for(var F=0;F<this.colours.length;F++){var C=this.colours[F]&16777215;var A=C.toString(16);A=G.substring(0,6-A.length)+A;J+='<tr><td bgcolor="#'+A+'" class="scale_colour">&nbsp;</td>';J+="<td>"+this.descriptions[F]+"</td></tr>"}}else{if(this.xmlURL.length>0){var H=GXmlHttp.create();H.open("GET",this.xmlURL,false);H.send(null);var I=GXml.parse(H.responseText);D=GXml.value(I.documentElement.getElementsByTagName("maptitle")[0]);var E=I.documentElement.getElementsByTagName("colourThreshold");for(var F=0;F<E.length;F++){var C=GXml.value(E[F].getElementsByTagName("colour")[0]);var B=GXml.value(E[F].getElementsByTagName("description")[0]);J+='<tr><td bgcolor="#'+C.substr(2)+'" class="scale_colour">&nbsp;</td>';J+="<td>"+B+"</td></tr>"}}}return"<p>"+D+"</p><table>"+J+"</table>"};MLKMLData.prototype=new MLData();MLKMLData.prototype.constructor=MLKMLData;function MLKMLData(A,B){MLData.call(this);this.overlay=null;this.KMLURL=A;this.mapTitle="TITLE";this.userData=B;this.isLoaded=true;this.isEnabled=true}MLKMLData.prototype.getBounds=function(){if(this.overlay){if(this.overlay.hasLoaded()){return this.overlay.getDefaultBounds()}}return null};MLKMLData.prototype.getOverlay=function(){return this.overlay};MLKMLData.prototype.getColourScaleHTML=function(){return""};MLMapDescriptorData.prototype=new MLTileData();MLMapDescriptorData.prototype.constructor=MLMapDescriptorData;function MLMapDescriptorData(C,E,B,D,F,G,A){MLTileData.call(this);this.mapTitle=C;this.mapBounds=E;this.renderServerPattern=B;this.mapDataDescriptorURL=D;this.colours=F;this.descriptions=G;this.userData=A;this.isLoaded=true;this.isEnabled=true}MLMapDescriptorData.prototype.getOverlay=function(){var A=new GTileLayer(this.copyrightCollection,0,17);A.tileRequestPattern=this.renderServerPattern.replace("\x7B0\x7D",this.mapDataDescriptorURL);A.opacity=this.opacity;A.getTileUrl=function(C,B){var H=Math.pow(2,B);var G=C.x;var F=C.y;var E="t";for(var D=0;D<B;D++){H/=2;if(F<H){if(G<H){E+="q"}else{E+="r";G-=H}}else{if(G<H){E+="t";F-=H}else{E+="s";G-=H;F-=H}}}return this.tileRequestPattern.replace("\x7B1\x7D",E)};A.isPng=function(){return false};A.getOpacity=function(){return this.opacity};return new GTileLayerOverlay(A)};function MLList(B){var A=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),0,'<a href="http:\x2F\x2Fwww.casa.ucl.ac.uk">CASA</a>');this.copyrightCollection=new GCopyrightCollection("GMapCreator");this.copyrightCollection.addCopyright(A);this.n_buttonText="Map";this.s_buttonText="Satellite";this.h_buttonText="Hybrid";this.p_buttonText="Terrain";this.gmap=B;this.xlayers=new Array()}MLList.zoomPastLimit=true;MLList.zoomPastWebService="ZoomInHandler.ashx";MLList.prototype.isTileLayer=function(A){if((A<0)||(A>=this.xlayers.length)){return false}return this.xlayers[A] instanceof MLTileData};MLList.prototype.isKMLLayer=function(A){if((A<0)||(A>=this.xlayers.length)){return false}return this.xlayers[A] instanceof MLKMLData};MLList.prototype.getNumLayers=function(){return this.xlayers.length};MLList.prototype.getIsLoaded=function(A){if((A<0)||(A>=this.xlayers.length)){return false}return this.xlayers[A].isLoaded};MLList.prototype.getIsEnabled=function(A){if((A<0)||(A>=this.xlayers.length)){return false}return this.xlayers[A].isEnabled};MLList.prototype.getOpacity=function(A){if((A<0)||(A>=this.xlayers.length)){return -1}return this.xlayers[A].opacity};MLList.prototype.getMapTitle=function(A){if((A<0)||(A>=this.xlayers.length)){return"Index "+A+" is out of bounds"}return this.xlayers[A].mapTitle};MLList.prototype.getMapBounds=function(A){if((A<0)||(A>=this.xlayers.length)){return null}return this.xlayers[A].getBounds()};MLList.prototype.getMaxZoomLevel=function(A){if((A<0)||(A>=this.xlayers.length)){return null}return this.xlayers[A].maxZoomLevel};MLList.prototype.getAllMaxZoomLevel=function(){if(this.zoomPastLimit){return this.gmap.getCurrentMapType().getMaximumResolution()}var B=0;for(var A=0;A<this.xlayers.length;A++){if(this.xlayers[A].maxZoomLevel>B){B=this.xlayers[A].maxZoomLevel}}return B};MLList.prototype.getColourScaleColours=function(A){if((A<0)||(A>=this.xlayers.length)){return null}return this.xlayers[A].colours};MLList.prototype.getColourScaleDescriptions=function(A){if((A<0)||(A>=this.xlayers.length)){return null}return this.xlayers[A].descriptions};MLList.prototype.getUserData=function(A){if((A<0)||(A>=this.xlayers.length)){return null}return this.xlayers[A].userData};MLList.prototype.setMapTitle=function(B,A){if((B<0)||(B>=this.xlayers.length)){return }this.xlayers[B].mapTitle=A};MLList.prototype.setIsEnabled=function(B,A){if((B<0)||(B>=this.xlayers.length)){return }if(this.xlayers[B].isEnabled==A){return }this.xlayers[B].isEnabled=A;this.rebuildGMap()};MLList.prototype.refreshOpacity=function(){for(var A=0;A<this.xlayers.length;A++){this.setOpacity(A,this.xlayers[A].opacity)}};MLList.prototype.setOpacity=function(I,C){if((I<0)||(I>=this.xlayers.length)){return }if(!this.xlayers[I] instanceof MLTileData){return }this.xlayers[I].opacity=C;var H=0;for(var D=0;D<this.xlayers.length;D++){if(this.xlayers[D] instanceof MLTileData){++H}}var F=this.gmap.getMapTypes();for(var D=0;D<F.length;D++){var B=this.gmap.getMapTypes()[D].getTileLayers()[H-I];if(B!=null){B.opacity=C}}var G;if(this.xlayers[I] instanceof MLMapDescriptorData){G=this.xlayers[I].mapDataDescriptorURL}else{G=this.xlayers[I].tileURL}var E=map.getContainer();var A=E.getElementsByTagName("img");for(var D=0;D<A.length;D++){if((A[D]!=null)&&(A[D].src.indexOf(G)>=0)){A[D].style.opacity=C;A[D].style.filter="alpha(opacity="+C*100+")"}}};MLList.prototype.setUserData=function(B,A){if((B<0)||(B>=this.xlayers.length)){return }this.xlayers.userData=A};MLList.prototype.getAllLayersBounds=function(){var B;for(var A=0;A<this.xlayers.length;A++){var C=this.xlayers[A].getBounds();if(C==null){continue}if(B==null){B=new GLatLngBounds(C.getSouthWest(),C.getNorthEast())}else{B.extend(C.getSouthWest());B.extend(C.getNorthEast())}}return B};MLList.prototype.getAllLayersCentre=function(){var A=this.getAllLayersBounds();if(A!=null){return A.getCenter()}return new GLatLng(51.52650545529106,-0.13102327732138574)};MLList.prototype.getInitialZoom=function(){var C=this.getAllLayersBounds();var D=6;if(C!=null){var A=C.toSpan();var B=Math.sqrt(A.lat()*A.lng());D=(Math.log(360)-Math.log(B))/Math.log(2)}return Math.floor(D)};MLList.prototype.add=function(A){this.xlayers.push(new MLData(A))};MLList.prototype.addWithData=function(G,B,I,F,C,A,H,E){var D=new MLTileData(G,B,I,F,C,A,H,E);this.xlayers.push(D)};MLList.prototype.addKML=function(C,A){var B=new MLKMLData(C,A);this.xlayers.push(B)};MLList.prototype.addMapDescriptor=function(C,F,B,E,G,H,A){var D=new MLMapDescriptorData(C,F,B,E,G,H,A);this.xlayers.push(D)};MLList.prototype.remove=function(A){};MLList.prototype.rebuildGMap=function(){this.gmap.clearOverlays();var K=0;var R=this.gmap.getCurrentMapType();var F=this.gmap.getMapTypes();if(R==undefined){K=-1}else{for(var N=1;N<F.length;N++){if(R==F[N]){K=N}}}var L=this.getAllMaxZoomLevel();for(var N=0;N<F.length;N++){var S=this.gmap.getMapTypes()[0].getName();if(S==G_NORMAL_MAP.getName()){var G=this.makeMultiLayer(G_NORMAL_MAP.getTileLayers()[0]);var M=this.gmap.getMapTypes()[0];this.gmap.removeMapType(M);var E;if(this.zoomPastLimit){E={yg:0,zg:"Data not available"}}else{E={$g:L,yg:0,zg:"Data not available"}}var A=new GMapType(G,new GMercatorProjection(G_SATELLITE_MAP.getMaximumResolution()+1),this.n_buttonText,E);this.gmap.addMapType(A)}else{if(S==G_SATELLITE_MAP.getName()){var O=this.makeMultiLayer(G_SATELLITE_MAP.getTileLayers()[0]);var B=this.gmap.getMapTypes()[0];this.gmap.removeMapType(B);var H=new GMapType(O,new GMercatorProjection(G_SATELLITE_MAP.getMaximumResolution()+1),this.s_buttonText,E);this.gmap.addMapType(H)}else{if(S==G_HYBRID_MAP.getName()){var P=this.makeMultiLayer(G_HYBRID_MAP.getTileLayers()[0]);P.push(G_HYBRID_MAP.getTileLayers()[1]);var C=this.gmap.getMapTypes()[0];this.gmap.removeMapType(C);var I=new GMapType(P,new GMercatorProjection(G_HYBRID_MAP.getMaximumResolution()+1),this.h_buttonText,E);this.gmap.addMapType(I)}else{if(S==G_PHYSICAL_MAP.getName()){var Q=this.makeMultiLayer(G_PHYSICAL_MAP.getTileLayers()[0]);var D=this.gmap.getMapTypes()[0];this.gmap.removeMapType(D);var J=new GMapType(Q,new GMercatorProjection(G_PHYSICAL_MAP.getMaximumResolution()+1),this.p_buttonText,E);this.gmap.addMapType(J)}}}}}if(K>=0){this.gmap.setMapType(this.gmap.getMapTypes()[K])}for(var N=this.xlayers.length-1;N>=0;--N){if(this.xlayers[N] instanceof MLKMLData){this.xlayers[N].overlay=new GGeoXml(this.xlayers[N].KMLURL);this.gmap.addOverlay(this.xlayers[N].overlay)}}};MLList.prototype.makeMultiLayer=function(C){var D=new Array();D.push(C);for(var B=this.xlayers.length-1;B>=0;B--){if(this.xlayers[B] instanceof MLKMLData){continue}if((this.xlayers[B].isEnabled)&&(this.xlayers[B].isLoaded)){var A=this.xlayers[B].getOverlay().getTileLayer();D.push(A)}}return D};MLList.prototype.moveUp=function(A){if(A==0){alert("You can't move the top layer up any more.");return }if((A<0)||(A>=this.xlayers.length)){return }var B=this.xlayers[A-1];this.xlayers[A-1]=this.xlayers[A];this.xlayers[A]=B;this.rebuildGMap()};MLList.prototype.moveDown=function(A){if(A==this.xlayers.length-1){alert("You can't move the bottom layer down any more.");return }if((A<0)||(A>=this.xlayers.length)){return }var B=this.xlayers[A+1];this.xlayers[A+1]=this.xlayers[A];this.xlayers[A]=B;this.rebuildGMap()};MLList.prototype.moveLayer=function(C,A){if((C<0)||(C>this.xlayers.length)){return }if((A<0)||(A>this.xlayers.length)){return }if(C==A){return }var B=this.xlayers.splice(C,1);this.xlayers.splice(A,0,B[0]);this.rebuildGMap()};MLList.prototype.getColourScaleHTML=function(A){if((A>=0)&&(A<this.xlayers.length)){return this.xlayers[A].getColourScaleHTML()}return""};MLList.prototype.containsKMLLayer=function(){for(var A=0;A<this.xlayers.length;A++){if(this.xlayers[A] instanceof MLKMLData){return true}}return false};MLList.prototype.scheduleMapDefaultView=function(){for(var B=0;B<this.xlayers.length;B++){if(this.xlayers[B] instanceof MLKMLData){var A=this.xlayers[B].overlay;var C=this;GEvent.addListener(A,"load",function(){var E=C.getAllLayersBounds();if(E!=null){var D=C.gmap.getBoundsZoomLevel(E);C.gmap.setCenter(E.getCenter(),D)}})}}};