var mdvLib;if(!mdvLib){mdvLib={}}mdvLib.$=function(){var c=[];for(var b=0;b<arguments.length;b++){var a=arguments[b];if(typeof a==="string"){a=document.getElementById(a)}if(arguments.length===1){return a}c.push(a)}return c};mdvLib.getElementPosition=function(d){var b=d.offsetLeft;var a=d.offsetTop;var c=d.offsetParent;while(c!==null){b+=c.offsetLeft;a+=c.offsetTop;c=c.offsetParent}return{left:b,top:a}};mdvLib.getMousePosition=function(b){var a=0;var c=0;var b=b||window.event;if(b.pageX||b.pageY){a=b.pageX;c=b.pageY}else{if(b.clientX||b.clientY){a=b.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);c=b.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)}}return{left:a,top:c}};mdvLib.style=function(b,e){if(mdvLib.typeOf(b)!=="array"){return false}for(var c=0;c<b.length;c++){for(var d in e){mdvLib.$(b[c]).style[d]=e[d]}}return true};mdvLib.typeOf=function(b){var a=typeof b;if(a==="object"){if(b){if(b instanceof Array){a="array"}}else{a="null"}}return a};mdvLib.createImg=function(b,d){var a=document.createElement("img");if(mdvLib.typeOf(d)==="object"){for(var c in d){a[c]=d[c]}}if(mdvLib.typeOf(b)==="object"){mdvLib.style([a],b)}return a};mdvLib.correctPNG=function(d,a){if(!document.body.filters||!a||!d){return}if(a.src==d.transparent.src){return true}if(mdvLib.typeOf(a)==="array"){for(var b=0;b<a.length;b++){c(a[b])}}else{c(a)}function c(f){var g=f.src;var e=f.runtimeStyle;e.width=f.offsetWidth+"px";e.height=f.offsetHeight+"px";e.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+g+"'), sizingMethod='crop'";f.src=d.transparent.src}};mdvLib.ajax=function(c){var j,g,a,f,b,i,h={};var d={host:"url",method:"type",asynchronous:"async",contentType:"contentType",encoding:"scriptCharset",parameters:"data",onComplete:"complete",onFailure:"error",onSuccess:"success"};var e={host:"url",method:"method",asynchronous:"async",contentType:"urlEncoded",encoding:"encoding",parameters:"data",onComplete:"onComplete",onFailure:"onFailure",onSuccess:"onSuccess",request:null};j=c||null;if(!j||j.host===undefined){return null}g=(typeof Prototype!=="undefined"&&Prototype.Version)?"PROTOTYPE":(typeof jQuery!=="undefined"&&jQuery.fn)?"JQUERY":(typeof MooTools!=="undefined"&&MooTools.version)?"MOOTOOLS":null;a=j.method||"post";a=a.toLowerCase();f=j.parameters||"";i=function(n,k){var m,l;for(m in n){if(n.hasOwnProperty(m)&&(!k||k[m]!==true)){l=g==="PROTOTYPE"?m:g==="JQUERY"?d[m]||m:g==="MOOTOOLS"?e[m]:m;h[l]=n[m]}}};b=function(){switch(g){case"PROTOTYPE":f=$H(f);f=f.toQueryString();h.parameters=f;h.method=a;i(j,{host:true,parameters:true});return new Ajax.Request(j.host,h);case"JQUERY":i(j);if(h.method===undefined){h.type=a}return jQuery.ajax(h);case"MOOTOOLS":i(j,{parameters:true});if(f!==""&&!f.length){f=new Hash(f);f=f.toQueryString()}e.request=new Request(h);return e.request.send(f);default:return null}};return b()};mdvLib.removeEvent=function(c,b,a){if(c.removeEventListener){c.removeEventListener(b,a,false)}else{if(c.detachEvent){c.detachEvent("on"+b,a)}}};function attachEventListener(e,c,d,b){var a;if(typeof e.addEventListener!="undefined"){e.addEventListener(c,d,b)}else{if(typeof e.attachEvent!="undefined"){e.attachEvent("on"+c,d)}else{c="on"+c;if(typeof e[c]=="function"){a=e[c];e[c]=function(){a();return d()}}else{e[c]=d}}}return true}if(typeof Function.prototype.bind!=="function"){Function.prototype.bind=function(b){var c=this,a=function(){return c.apply(b,arguments)};return a}}if(typeof String.prototype.trim!=="function"){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}function MDVMapCooTraPro(){this.ellipsoidParams=[];this.ellipsoidParams.AIRY_1830={a:6377563.396,divf:299.3249646};this.ellipsoidParams.AIRY_1830_GREAT_BRITAIN={a:6377563.396,divf:299.3249753};this.ellipsoidParams.MODIFIED_AIRY={a:6377340.189,divf:299.3249646};this.ellipsoidParams.AUSTRALIAN_1984={a:6378160,divf:298.25};this.ellipsoidParams.BESSEL_1841_NAMIBIA={a:6377483.865,divf:299.15281282};this.ellipsoidParams.BESSEL_1841={a:6377397.155,divf:299.15281282};this.ellipsoidParams.CLARKE_1866={a:6378206.4,divf:294.9786982};this.ellipsoidParams.CLARKE_1880={a:6378249.145,divf:293.465};this.ellipsoidParams.EVEREST_INDIA_1830={a:6377276.345,divf:300.8017};this.ellipsoidParams.EVEREST_SABAH_SARAWAK={a:6377298.556,divf:300.8017};this.ellipsoidParams.EVEREST_INDIA_1956={a:6377301.243,divf:300.8017};this.ellipsoidParams.EVEREST_MALAYSIA_1969={a:6377295.664,divf:300.8017};this.ellipsoidParams.EVEREST_MALAY_SING={a:6377304.063,divf:300.8017};this.ellipsoidParams.EVEREST_PAKISTAN={a:6377309.613,divf:300.8017};this.ellipsoidParams.MODIFIED_FISCHER_1960={a:6378155,divf:298.3};this.ellipsoidParams.HELMERT_1906={a:6378200,divf:298.3};this.ellipsoidParams.HOUGH_1960={a:6378270,divf:297};this.ellipsoidParams.IERS_1996={a:6378136.49,divf:298.25645};this.ellipsoidParams.INDONESIA_1974={a:6378160,divf:298.247};this.ellipsoidParams.HAYFORD_1924={a:6378388,divf:297};this.ellipsoidParams.KRASSOWSKIJ_1940={a:6378245,divf:298.3};this.ellipsoidParams.GRS_1980={a:6378137,divf:298.257222101};this.ellipsoidParams.WGS_1972={a:6378135,divf:298.26};this.ellipsoidParams.WGS_1984={a:6378137,divf:298.257223563};this.ellipsoidParams.SOUTH_AMERICAN_1969={a:6378160,divf:298.25};this.ellipsoidParams.UNKNOWN={a:0,divf:0};this.offset=new MDVPoint(0,5000000)}MDVMapCooTraPro.prototype.transform=function(b){var d=new MDVEllipsoid(this.ellipsoidParams.WGS_1984);var g=new MDVEllipsoid(this.ellipsoidParams.WGS_1984);var a=10;var f="NORTH";b.hemisphere=f;b.zone=a;if(d.params!=g.params){var c=null}if(b.mapName.indexOf("WGS")>=0){return this.toInternal(b,g)}else{return this.toWGS84(b,g)}};MDVMapCooTraPro.prototype.toInternal=function(a,e){var d=a.clone();if(!d||d.mapName.indexOf("WGS")<0){return null}var c=null;var b=new MDVProjectionUTM(e,d.zone);c=b.convertGeographicalToUTMCoordinate(d);if(this.offset.x>0){c.x=this.offset.x-c.x}if(this.offset.y>0){c.y=this.offset.y-c.y}return c};MDVMapCooTraPro.prototype.toWGS84=function(a,e){var d=a.clone();if(!d){return null}var c=null;if(this.offset.x>0){d.x=this.offset.x-d.x}if(this.offset.y>0){d.y=this.offset.y-d.y}var b=new MDVProjectionUTM(e,d.zone);c=b.convertUTMToGeographicalCoordinate(d);return c};function MDVEllipsoid(a){this.params=a}MDVEllipsoid.prototype.getEquatorialRadiusA=function(){return this.params.a};MDVEllipsoid.prototype.getPolarRadiusB=function(){var b=this.getEquatorialRadiusA();var c=this.getFlatteningF();return(b-c*b)};MDVEllipsoid.prototype.getFlatteningF=function(){return(1/this.params.divf)};MDVEllipsoid.prototype.getSecondEccentricityESquare=function(){var d=this.params.a;var c=this.getPolarRadiusB();return((d*d-c*c)/(c*c))};MDVEllipsoid.prototype.getPrimeVerticalRadiusN=function(d){var b=this.getEquatorialRadiusA();var c=this.getFirstEccentricityESquare();return(b/Math.sqrt(1-c*Math.pow(Math.sin(d),2)))};MDVEllipsoid.prototype.getFirstEccentricityESquare=function(){var d=this.params.a;var c=this.getPolarRadiusB();return((d*d-c*c)/(d*d))};function MDVProjectionUTM(b,a){this.MIN_LAT=-80.5;this.MAX_LAT=84.5;this.MIN_RAD_LAT=((this.MIN_LAT*Math.PI)/180);this.MAX_RAD_LAT=((this.MAX_LAT*Math.PI)/180);this.MIN_EASTING=-500000;this.MAX_EASTING=1500000;this.MIN_NORTHING=0;this.MAX_NORTHING=10000000;this.zone=a;this.ellipsoid=b}MDVProjectionUTM.prototype.convertUTMToGeographicalCoordinate=function(f){var b=0;var a=0;var i=500000;var d=0;var g=0.9996;var h=f.clone();h.mapName="WGS84[DD.ddddd]";if(f.zone>=31){a=(6*f.zone-183)}else{a=(6*f.zone+177)}if(f.hemisphere=="SOUTH"){d=10000000}var c=new MDVProjectionTransverseMercator(this.ellipsoid,b,a,i,d,g);var e=c.convertTransverseMercatorToGeographicalCoordinate(f);h.x=Math.floor(0.5+(e.x*100000))/100000;h.y=Math.floor(0.5+(e.y*100000))/100000;return h};MDVProjectionUTM.prototype.convertGeographicalToUTMCoordinate=function(k){var a=(k.y*Math.PI)/180;var c=(k.x*Math.PI)/180;var d=0;var b=0;var n=500000;var g=0;var l=0.9996;var f=-1;var m=k.clone();m.mapName="MTCV";if(c<0){c+=(2*Math.PI)+1e-10}if(c<Math.PI){f=(31+Math.floor(((c-1e-10)*180/Math.PI)/6))}else{f=(Math.floor(((c-1e-10)*180/Math.PI)/6)-29)}if(f>60){f=1}var j=parseInt(k.y);var i=parseInt(k.x);if((j>55)&&(j<64)&&(i>-1)&&(i<3)){f=31}if((j>55)&&(j<64)&&(i>2)&&(i<12)){f=32}if((j>71)&&(i>-1)&&(i<9)){f=31}if((j>71)&&(i>8)&&(i<21)){f=33}if((j>71)&&(i>20)&&(i<33)){f=35}if((j>71)&&(i>32)&&(i<42)){f=37}if((f==1)&&(this.zone==60)){f=this.zone}else{if((f==60)&&(this.zone==1)){f=this.zone}else{if(((f-1)<=this.zone)&&(this.zone<=(f+1))){f=this.zone}else{f=-1}}}if(this.zone<0){return null}if(f>=31){b=6*f-183}else{b=6*f+177}m.zone=f;if(a<0){g=10000000;m.hemisphere="SOUTH"}else{m.hemisphere="NORTH"}var e=new MDVProjectionTransverseMercator(this.ellipsoid,d,b,n,g,l);var h=e.convertGeographicalToTransverseMercatorCoordinate(k);m.x=Math.floor(0.5+h.x);m.y=Math.floor(0.5+h.y);return m};function MDVProjectionTransverseMercator(c,e,a,p,g,l){this.ellipsoid=c;this.radCentralMeridianLongitude=0;this.radOriginLatitude=0;this.falseEasting=0;this.falseNorthing=0;this.scaleFactor=1;this.ap=6367449.1458008;this.bp=16038.508696861;this.cp=16.832613334334;this.dp=0.021984404273757;this.ep=0.000031148371319283;this.radMaxDeltaLongitude=1.5707963267948966;this.radMaxLatitude=1.5706217938696971;this.deltaEasting=40000000;this.deltaNorthing=40000000;var m=(Math.PI*e)/180;var j=(Math.PI*a)/180;this.ellipsoid=c;var n=(this.ellipsoid.getEquatorialRadiusA()-this.ellipsoid.getPolarRadiusB())/(this.ellipsoid.getEquatorialRadiusA()+this.ellipsoid.getPolarRadiusB());var k=n*n;var i=k*n;var f=i*n;var d=f*n;this.ap=this.ellipsoid.getEquatorialRadiusA()*(1-n+5*(k-i)/4+81*(f-d)/64);this.bp=3*this.ellipsoid.getEquatorialRadiusA()*(n-k+7*(i-f)/8+55*d/64)/2;this.cp=15*this.ellipsoid.getEquatorialRadiusA()*(k-i+3*(f-d)/4)/16;this.dp=35*this.ellipsoid.getEquatorialRadiusA()*(i-f+11*d/16)/48;this.ep=315*this.ellipsoid.getEquatorialRadiusA()*(f-d)/512;var o=new MDVCoordinates("",90,89.99);var h=this.convertGeographicalToTransverseMercatorCoordinate(o);this.deltaNorthing=h.y;this.deltaEasting=h.x;var b=new MDVCoordinates("",90,0);var h=this.convertGeographicalToTransverseMercatorCoordinate(b);this.deltaEasting=h.x;this.deltaNorthing=0;this.radOriginLatitude=m;if(j>Math.PI){j-=(2*Math.PI)}this.radCentralMeridianLongitude=j;this.falseNorthing=g;this.falseEasting=p;this.scaleFactor=l}MDVProjectionTransverseMercator.prototype.convertTransverseMercatorToGeographicalCoordinate=function(D){var C=new MDVCoordinates("",0,0);var G;var F;var k;var h;var e;var d;var a;var l;var x;var n;var A;var r;var m;var j;var g;var B;var z;var y;var w;var u;var q;var p;var o;var b;var f;f=this.SPHTMD(this.ap,this.bp,this.cp,this.dp,this.ep,this.radOriginLatitude);b=f+(D.y-this.falseNorthing)/this.scaleFactor;r=this.SPHSR(this.ellipsoid.getEquatorialRadiusA(),this.ellipsoid.getFirstEccentricityESquare(),0);l=b/r;for(x=0;x<5;x++){B=this.SPHTMD(this.ap,this.bp,this.cp,this.dp,this.ep,l);r=this.SPHSR(this.ellipsoid.getEquatorialRadiusA(),this.ellipsoid.getFirstEccentricityESquare(),l);l=l+(b-B)/r}r=this.SPHSR(this.ellipsoid.getEquatorialRadiusA(),this.ellipsoid.getFirstEccentricityESquare(),l);A=this.ellipsoid.getPrimeVerticalRadiusN(l);n=Math.sin(l);G=Math.cos(l);m=Math.tan(l);j=m*m;g=j*j;h=this.ellipsoid.getSecondEccentricityESquare()*Math.pow(G,2);e=h*h;d=e*h;a=d*h;F=D.x-this.falseEasting;if(Math.abs(F)<0.0001){F=0}B=m/(2*r*A*Math.pow(this.scaleFactor,2));z=m*(5+3*j+h-4*Math.pow(h,2)-9*j*h)/(24*r*Math.pow(A,3)*Math.pow(this.scaleFactor,4));y=m*(61+90*j+46*h+45*g-252*j*h-3*e+100*d-66*j*e-90*g*h+88*a+225*g*e+84*j*d-192*j*a)/(720*r*Math.pow(A,5)*Math.pow(this.scaleFactor,6));w=m*(1385+3633*j+4095*g+1575*Math.pow(m,6))/(40320*r*Math.pow(A,7)*Math.pow(this.scaleFactor,8));var v=l-Math.pow(F,2)*B+Math.pow(F,4)*z-Math.pow(F,6)*y+Math.pow(F,8)*w;u=1/(A*G*this.scaleFactor);q=(1+2*j+h)/(6*Math.pow(A,3)*G*Math.pow(this.scaleFactor,3));p=(5+6*h+28*j-3*e+8*j*h+24*g-4*d+4*j*e+24*j*d)/(120*Math.pow(A,5)*G*Math.pow(this.scaleFactor,5));o=(61+662*j+1320*g+720*Math.pow(m,6))/(5040*Math.pow(A,7)*G*Math.pow(this.scaleFactor,7));k=F*u-Math.pow(F,3)*q+Math.pow(F,5)*p-Math.pow(F,7)*o;var E=this.radCentralMeridianLongitude+k;while(v>(90*Math.PI/180)){v=Math.PI-v;E+=Math.PI;if(E>Math.PI){E-=(2*Math.PI)}}while(v<(-90*Math.PI/180)){v=-(v+Math.PI);E+=Math.PI;if(E>Math.PI){E-=(2*Math.PI)}}if(E>(2*Math.PI)){E-=(2*Math.PI)}if(E<-Math.PI){E+=(2*Math.PI)}C.x=(E*180)/Math.PI;C.y=(v*180)/Math.PI;C.height=D.height;return C};MDVProjectionTransverseMercator.prototype.convertGeographicalToTransverseMercatorCoordinate=function(H){var I=new MDVCoordinates("",0,0);var L;var E;var C;var B;var z;var q;var l;var e;var d;var a;var A;var G;var y;var o;var m;var j;var h;var f;var x;var w;var v;var u;var r;var p;var n;var k;var i;var b;var g;var K=(Math.PI*H.x)/180;var F=(Math.PI*H.y)/180;if(K>Math.PI){K-=(2*Math.PI)}if((K<(this.radCentralMeridianLongitude-this.radMaxDeltaLongitude))||(K>(this.radCentralMeridianLongitude+this.radMaxDeltaLongitude))){var J=K;if(K<0){J=K+2*Math.PI}var D=this.radCentralMeridianLongitude;if(this.radCentralMeridianLongitude<0){D=this.radCentralMeridianLongitude+2*Math.PI}}q=K-this.radCentralMeridianLongitude;if(Math.abs(q)>(9*Math.PI/180)){}if(q>Math.PI){q-=(2*Math.PI)}if(q<-Math.PI){q+=(2*Math.PI)}if(Math.abs(q)<2e-10){q=0}A=Math.sin(F);L=Math.cos(F);E=L*L;C=E*L;B=C*E;z=B*E;y=Math.tan(F);o=y*y;m=o*y;j=m*y;h=j*y;f=h*y;l=this.ellipsoid.getSecondEccentricityESquare()*E;e=l*l;d=e*l;a=d*l;G=this.ellipsoid.getPrimeVerticalRadiusN(F);b=this.SPHTMD(this.ap,this.bp,this.cp,this.dp,this.ep,F);g=this.SPHTMD(this.ap,this.bp,this.cp,this.dp,this.ep,this.radOriginLatitude);x=(b-g)*this.scaleFactor;w=G*A*L*this.scaleFactor/2;v=G*A*C*this.scaleFactor*(5-o+9*l+4*e)/24;u=G*A*B*this.scaleFactor*(61-58*o+j+270*l-330*o*l+445*e+324*d-680*o*e+88*a-600*o*d-192*o*a)/720;r=G*A*z*this.scaleFactor*(1385-3111*o+543*j-f)/40320;I.y=this.falseNorthing+x+Math.pow(q,2)*w+Math.pow(q,4)*v+Math.pow(q,6)*u+Math.pow(q,8)*r;p=G*L*this.scaleFactor;n=G*C*this.scaleFactor*(1-o+l)/6;k=G*B*this.scaleFactor*(5-18*o+j+14*l-58*o*l+13*e+4*d-64*o*e-24*o*d)/120;i=G*z*this.scaleFactor*(61-479*o+179*j-f)/5040;I.x=this.falseEasting+q*p+Math.pow(q,3)*n+Math.pow(q,5)*k+Math.pow(q,7)*i;I.height=H.s_height;return I};MDVProjectionTransverseMercator.prototype.SPHTMD=function(b,c,d,f,a,e){return(b*e-c*Math.sin(2*e)+d*Math.sin(4*e)-f*Math.sin(6*e)+a*Math.sin(8*e))};MDVProjectionTransverseMercator.prototype.SPHSR=function(b,c,d){return(b*(1-c)/Math.pow(this.DENOM(c,d),3))};MDVProjectionTransverseMercator.prototype.DENOM=function(a,b){return(Math.sqrt(1-a*Math.pow(Math.sin(b),2)))};var MDVEventID=0;var MDVEvent_ERROR=MDVEventID++;var MDVEvent_DEBUG=MDVEventID++;var MDVEvent_WARNING=MDVEventID++;var MDVEvent_INITIALISED=MDVEventID++;var MDVEvent_MAP_INITIALISED=MDVEventID++;var MDVEvent_ZOOM_CHANGED=MDVEventID++;var MDVEvent_CENTRE_CHANGED=MDVEventID++;var MDVEvent_CONTEXT_MENU=MDVEventID++;var MDVEvent_GADGET_REGISTERED=MDVEventID++;var MDVEvent_LAYER_ADDED=MDVEventID++;var MDVEvent_LAYER_UPDATED=MDVEventID++;var MDVEvent_AJAX_CALLBACK=MDVEventID++;var MDVEvent_MOUSE_MOVED=MDVEventID++;var MDVEvent_TOOLTIP=MDVEventID++;var MDVEvent_OBJECT_CLICKED=MDVEventID++;var MDVEvent_OBJECT_DBLCLICKED=MDVEventID++;var MDVEvent_OBJECT_LOADED=MDVEventID++;var MDVEvent_ROUTE_TRACE_FINISHED=MDVEventID++;var MDVEvent_MOUSE_UP=MDVEventID++;var MDVEvent_MOUSE_DOWN=MDVEventID++;function MDVEvents(){this.events=[];this.lastEventID=0}MDVEvents.prototype.addEventID=function(a){if(!this.events[a]){this.events[a]=[]}};MDVEvents.prototype.registerEvent=function(c,b,a){if(this.events[c]){this.events[c].push([b,a])}};MDVEvents.prototype.deregisterEvent=function(e,d,b){var c=false;if(!this.events[e]){return false}for(var a=0;a<this.events[e].length;a++){if(this.events[e][a][0]==d&&this.events[e][a][1]==b){this.events[e].splice(a,1);c=true}}return c};MDVEvents.prototype.triggerEvent=function(h){if(!this.events[h]){return false}var d=new Array();for(var e=0;e<arguments.length;e++){d[d.length]=arguments[e]}if(document.getElementById&&document.getElementById("MDVMap_Console")&&d.length>=2){var b=new Date();var c=b.getHours();var f=b.getMinutes();var g=b.getSeconds();if(c<=9){c="0"+c}if(f<=9){f="0"+f}if(g<=9){g="0"+g}var a=c+":"+f+":"+g;document.getElementById("MDVMap_Console").value=a+" "+d[1]+" (id: "+h+")\n"+document.getElementById("MDVMap_Console").value}for(var e=0;e<this.events[h].length;e++){this.events[h][e][1].apply(this.events[h][e][0],arguments)}return true};function MDVMap(a,b){this.config=null;if(b==null){b={}}this.options=b;this.viewport=a;this.viewport.mdvMap=this;this.managedMarkers=false;this.markerObjects=null;this.markerLayer=null;this.tileRealWidth=-1;this.tileRealHeight=-1;this.tileCountWidth=-1;this.tileCountHeight=-1;this.startTileWidth=-1;this.startTileHeight=-1;this.imgCountWidth=0;this.imgCountHeight=0;this.viewportRealWidth=-1;this.viewportRealHeight=-1;this.tlReal=null;this.tlTileReal=null;this.offset=null;this.wrapOffset=null;this.real=new MDVCoordinates();this.viewport.style.overflow="hidden";this.viewport.style.position="relative";this.viewportHeight=-1;this.viewportWidth=-1;this.state=-1;this.lastTileLayerID=0;this.lastImageID=0;this.lastMarkerID=0;this.lastLayerID=0;this.lastToolTipID=0;this.lastContainerID=0;this.lastPolylineID=0;this.maxFailCount=3;this.transparent=new Image(1,1);this.failImg=new Image(1,1);this.mapper=null;this.mappers=new Array();this.events=new MDVEvents();this.gadgets=new Array();this.layers=new Array();this.overlays=new Array();this.renderer=null;this.toolTips=new MDVToolTipManager(this);this.cootrapro=new MDVMapCooTraPro();this.hotspots=null;this.speed=1;this.stepTime=40;this.stepPx=4;this.steps=null;this.moveJobID=null;this.crossHairSrc=new Image();this.crossHair=null;for(var c=0;c<MDVEventID;c++){this.events.addEventID(c)}}MDVMap.prototype.cleanMagnifyMapper=function(){var c=this.getMagnifyMapper();var b=c.childNodes.length;for(var a=0;a<b;a++){c.childNodes[b-a-1].mdvMap=null;if(c.childNodes[b-a-1].className!="mdvLayer"){c.removeChild(c.childNodes[b-a-1])}}return true};MDVMap.prototype.getMapper=function(){return this.mapper};MDVMap.prototype.getMagnifyMapper=function(){var b=null;for(var a=0;a<this.mappers.length;a++){if(this.mappers[a].id!=this.mapper.id){b=this.mappers[a];break}}return b};MDVMap.prototype.switchMapper=function(){var a,d,f,b,c,e;for(a=0;a<this.mappers.length;a++){if(this.mappers[a].id==this.mapper.id){f=this.mappers[a]}else{b=this.mappers[a]}}c=f.childNodes&&f.childNodes.length||0;while(c>1){e=(/mapTiles/.test(f.lastChild.id)===false)?f.lastChild:f.firstChild;b.appendChild(f.removeChild(e));c--}f.style.zIndex=1;b.style.zIndex=30;this.mapper=b;this._removeImages();this.update();c=b.childNodes&&b.childNodes.length||0;for(d=0;d<c;d+=1){if(/mapTiles|_overlay_/.test(b.childNodes[d].id)===false){if(b.childNodes[d].layer&&b.childNodes[d].layer.control&&b.childNodes[d].layer.control.checked===false){}else{b.childNodes[d].style.display="block"}}}return true};MDVMap.prototype.getToolTipManager=function(){return this.toolTips};MDVMap.prototype.getViewportExtends=function(){return{width:this.viewportWidth,height:this.viewportHeight}};MDVMap.prototype.getViewportRealExtends=function(){return{width:this.viewportRealWidth,height:this.viewportRealHeight}};MDVMap.prototype.getPoint=function(c){if(c==null){return null}this._updateMapValues();var g=this.config.getZoomLevel(this.config.currentZoomLevelIndex);var a=parseInt(g.get("tileSizeX"))*parseInt(g.get("numberOfTilesX"));var d=a/parseInt(g.get("realWidth"));var f=parseInt(g.get("tileSizeY"))*parseInt(g.get("numberOfTilesY"));var e=f/parseInt(g.get("realHeight"));var b=new MDVPoint(Math.floor(0.5+(c.x-this.tlTileReal.x)*d),Math.floor(0.5+(c.y-this.tlTileReal.y)*e));b.x=b.x-this.wrapOffset.x;b.y=b.y-this.wrapOffset.y;return b};MDVMap.prototype.inBounds=function(d){this._updateMapValues();var e=1;if(arguments.length>1){e=arguments[1]}var c=this.getViewportRealExtends();c.width=Math.floor(0.5+c.width/2)*e;c.height=Math.floor(0.5+c.height/2)*e;var a=this.getCentre().clone();a.x-=c.width;a.y-=c.height;var b=this.getCentre().clone();b.x+=c.width;b.y+=c.height;return a.x<=d.x&&b.x>d.x&&a.y<=d.y&&b.y>d.y};MDVMap.prototype.getCoordinates=function(b){if(b==null){return null}this._updateMapValues();var g=this.config.getZoomLevel(this.config.currentZoomLevelIndex);var a=parseInt(g.get("tileSizeX"))*parseInt(g.get("numberOfTilesX"));var e=parseInt(g.get("realWidth"))/a;var f=parseInt(g.get("tileSizeY"))*parseInt(g.get("numberOfTilesY"));var d=parseInt(g.get("realHeight"))/f;var c=new MDVCoordinates(this.config.get("mapName"),Math.floor(0.5+this.tlReal.x+(b.x*e)),Math.floor(0.5+this.tlReal.y+(b.y*d)));return c};MDVMap.prototype.getWGS84=function(a){if(a.mapName==this.config.get("mapName")){return this.cootrapro.transform(a)}else{return a}};MDVMap.prototype.getInternalCoordinates=function(a){if(a){if(a.mapName==this.config.get("mapName")){return a}else{if(this.config.get("mapName")=="MTCV"){return this.cootrapro.transform(a)}else{return this.getInternalCoordinatesViaAjax(a)}}}};MDVMap.prototype.getInternalCoordinatesViaAjax=function(coords){if(!coords){return null}if(coords.mapName==this.config.get("mapName")){return coords}if(this.config.get("sfURL")==null){return coords}var host=this.config.get("sfURL");var efa=null;var txt=null;var mapName=coords.mapName;switch(mapName){case"WGS84":mapName="WGS84[DD.ddddd]";break}var _params={type_sf:"coord",name_sf:coords.x+":"+coords.y+":"+mapName};var _ajax=mdvLib.ajax({host:host,parameters:_params,asynchronous:false});if(typeof _ajax.responseIsFailure==="function"&&_ajax.responseIsFailure()===true){return null}txt=_ajax.transport!==undefined?_ajax.transport.responseText:_ajax.responseText;try{eval("efa = "+txt)}catch(e){this.events.triggerEvent(MDVEvent_ERROR,"MDVMap encountered an error (JSON). "+e.message);return null}if(efa&&efa.stopFinder&&efa.stopFinder.point&&efa.stopFinder.point.ref&&efa.stopFinder.point.ref.coords){var n=efa.stopFinder.point.ref.coords.split(",");return new MDVCoordinates(this.config.get("mapName"),n[0],n[1])}return null};MDVMap.prototype.createMarker=function(c,a,b){if(b!=""){return new MDVMarker(this,c,b,a)}else{return null}};MDVMap.prototype.createManagedMarker=function(d,a,c){if(c!=""){var e=new MDVMarker(this,d,c,a);var b=1.2;e.img.onload=function(i){i=i?i:window.event;if(this.marker){this.marker.update();var g=this.mdvMap.inBounds(this.marker.getCoords(),b);if(!this.marker.append&&this.marker.layer&&g){this.mdvMap.markerObjects.appendChild(this);this.mdvMap.managedMarkers=true;this.marker.append=true;this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_LOADED,"MDVMap noticed that a marker finished loading.",this.marker)}if(document.all&&this.src!=this.marker.mdvMap.transparent.src&&this.src.substring(this.src.length,this.src.length-4).toLowerCase()==".png"){var h=this.width;var f=this.height;var j=this.src;this.style.width=h+"px";this.style.height=f+"px";this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+j+"');";this.marker.img.src=this.marker.mdvMap.transparent.src}}};e.update=function(){var h=this.mdvMap.getPoint(this.getCoords());var m=true;var i=this.mdvMap.inBounds(this.getCoords(),b);if(!this.append&&this.layer&&i){this.mdvMap.markerObjects.appendChild(this.img);this.mdvMap.managedMarkers=true;this.append=true;this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_LOADED,"MDVMap noticed that a marker finished loading.",this.marker)}else{if(this.append&&this.layer&&!i){if(this.marker.toolTip&&this.marker.toolTip.isVisible()){this.marker.toolTip.hide()}this.mdvMap.markerObjects.removeChild(this.img);this.append=false}}if(!h){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to get px coordinates for marker.");return false}if(arguments.length>0){m=arguments[0]}var k=this.img.width;var g=this.img.height;var f=this.getXFactor();var j=this.getYFactor();this.img.style.position="absolute";this.img.style.left=(h.x-k*f)+"px";this.img.style.top=(h.y-g*j)+"px";if(this.layer&&this.layer.zIndex){this.img.style.zIndex=this.layer.zIndex}var l=this.visible?"visible":"hidden";if(this.img.style.visibility!=l){this.img.style.visibility=l}if(this.toolTip&&this.toolTip.isVisible()&&m){this.toolTip.update()}return true};return e}else{return null}};MDVMap.prototype.createToolTip=function(b){if(arguments.length==2){var a=new MDVToolTip(this,arguments[1],"bubble");a.setSize(arguments[0]);return a}else{return new MDVToolTip(this,b,"simple")}};MDVMap.prototype._updateLayers=function(){for(var a=0;a<this.layers.length;a++){this.layers[a].update()}return true};MDVMap.prototype.release=function(c){for(var a=0;a<this.gadgets.length;a++){var b=this.gadgets[a];if(b.name=="MapNavigator"){b.onmouseup(c);return true}}return false};MDVMap.prototype.addMarker=function(a){return this.markerLayer.addMarker(a)};MDVMap.prototype.removeMarker=function(a){return this.markerLayer.removeMarker(a)};MDVMap.prototype.addLayer=function(b){var c=false;for(var a=0;a<this.layers.length;a++){if(this.layers[a].id==b.id){c=true}}if(!c){this.layers.push(b);this.events.triggerEvent(MDVEvent_LAYER_ADDED,"MDVMap has added a new layer ("+this.layers[a].name+")",this.layers[a]);this.layers.append=true;b.update()}};MDVMap.prototype.getLayer=function(b){for(var a=0;a<this.layers.length;a++){if(this.layers[a].name==b){return this.layers[a]}}return null};MDVMap.prototype.getLayers=function(){return this.layers};MDVMap.prototype.registerGadget=function(c){var b=false;for(var a=0;a<this.gadgets.length;a++){if(this.gadgets[a].name==c.name){b=true}}if(c.name=="GadgetBase"){b=true}if(!b){this.gadgets.push(c);this.events.triggerEvent(MDVEvent_GADGET_REGISTERED,"MDVMap registered a new gadget ("+c.name+")",c)}};MDVMap.prototype.getCentre=function(){if(this.real.x>0&&this.real.y>0){return this.real}else{return null}};MDVMap.prototype.setCentre=function(b){if(b){b=this.getInternalCoordinates(b)}if(b&&(!this.getCentre()||b.x!=this.getCentre().x||b.y!=this.getCentre().y)){var a=false;if(this._checkBoundariesX(b)){this.real.x=b.x;this.real.mapName=b.mapName;a=true}if(this._checkBoundariesY(b)){this.real.y=b.y;this.real.mapName=b.mapName;a=true}if(a){this.events.triggerEvent(MDVEvent_CENTRE_CHANGED,"MDVMap centre has been changed",b)}return a}else{return false}};MDVMap.prototype._checkBoundariesX=function(f){var e=this.config.getZoomLevel(this.config.getZoomLevelIndex());var b=parseInt(e.get("realOffsetX"));var d=parseInt(e.get("realWidth"));var a=parseInt(e.get("tileSizeX"))*parseInt(e.get("numberOfTilesX"));var c=d/a;if(((f.x-b)*(f.x-(b+d)))<=0){return true}else{return false}};MDVMap.prototype._checkBoundariesY=function(f){var d=this.config.getZoomLevel(this.config.getZoomLevelIndex());var e=parseInt(d.get("realOffsetY"));var b=parseInt(d.get("realHeight"));var c=parseInt(d.get("tileSizeY"))*parseInt(d.get("numberOfTilesY"));var a=b/c;if(((f.y-e)*(f.y-(e+b)))<=0){return true}else{return false}};MDVMap.prototype.setZoomLevel=function(a){var b=this.config.getZoomLevel(a);if(this.config.getZoomLevelIndex()!=a&&b){this.config.setZoomLevelIndex(a);if(this.config.get("showHotspotLevel")&&(a>=parseInt(this.config.get("showHotspotLevel")))&&this.hotspots.json==null){this.hotspots.retrieve()}this.events.triggerEvent(MDVEvent_ZOOM_CHANGED,"MDVMap zoom level has been changed",a);return true}else{if(!b){this.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to set new zoom level.")}return false}};MDVMap.prototype.getObjWidth=function(d){var a=0;if(d.offsetWidth){a=d.offsetWidth}else{if(d.clip&&d.clip.width){a=d.clip.width}else{if(d.style&&d.style.pixelWidth){a=d.style.pixelWidth}}}var b=parseInt(d.style.borderLeftWidth);var c=parseInt(d.style.borderRightWidth);if(b>0){a-=b}if(c>0){a-=c}return parseInt(a)};MDVMap.prototype.getObjHeight=function(e){var c=0;if(e.offsetHeight){c=e.offsetHeight}else{if(e.clip&&e.clip.height){c=e.clip.height}else{if(e.style&&e.style.pixelHeight){c=e.style.pixelHeight}}}var d=parseInt(e.style.borderTopWidth);var a=parseInt(e.style.borderBottomWidth);if(d>0){c-=d}if(a>0){c-=a}return parseInt(c)};MDVMap.prototype._setBackgroundColour=function(a){this.viewport.style.backgroundColor=a};MDVMap.prototype.getName=function(){return this.name};MDVMap.prototype.resize=function(){this.viewportHeight=this.getObjHeight(this.viewport);this.viewportWidth=this.getObjWidth(this.viewport);if(this.viewportHeight<=2||this.viewportWidth<=2){this.events.triggerEvent(MDVEvent_ERROR,"MDVMap couldn't get size from target map object ("+this.viewport.id+").")}if(this.state==1){this.update()}};MDVMap.prototype.execute=function(b){this.resize();this.wrapOffset=new MDVPoint(0,0);if(b&&this.config==null){this.config=b}else{this.events.triggerEvent(MDVEvent_ERROR,"MDVMap couldn't find an appropriate configuration or already has one.");this.state=-1;return false}this.name=this.viewport.id;if(!document.mdvMaps){document.mdvMaps=new Array()}document.mdvMaps["mdvMap_"+this.name]=this;if(this.config.get("defaultScale")>=0){this.setZoomLevel(parseInt(this.config.get("defaultScale")))}else{this.setZoomLevel(3)}if(!this.getCentre()){var c=new MDVCoordinates(this.config.get("mapName"),parseInt(this.config.get("xCenterReal")),parseInt(this.config.get("yCenterReal")));this.setCentre(c)}this._updateMapValues();if(this.config.get("enableHotspots")){new MDVHotspots(this)}this.mappers[0]=document.createElement("div");this.mappers[0].id=this.name+"_mapper0";this.mappers[0].style.position="absolute";this.mappers[0].style.left="0px";this.mappers[0].style.top="0px";this.mappers[0].style.zIndex="30";this.mappers[0].mdvMap=this;this.mappers[0].tiles=new Array();this.mappers[1]=document.createElement("div");this.mappers[1].id=this.name+"_mapper1";this.mappers[1].style.position="absolute";this.mappers[1].style.left="0px";this.mappers[1].style.top="0px";this.mappers[1].style.zIndex="1";this.mappers[1].mdvMap=this;this.mappers[1].tiles=new Array();this.mapper=this.mappers[0];this.viewport.appendChild(this.mappers[0]);this.viewport.appendChild(this.mappers[1]);this.mappers[0].onmousemove=MDVMap_onmousemove;this.mappers[0].onmouseover=MDVMap_onmouseover;this.mappers[0].onmousedown=MDVMap_onmousedown;this.mappers[0].onmouseup=MDVMap_onmouseup;this.mappers[0].onkeypress=MDVMap_onkeypress;this.mappers[0].ondblclick=MDVMap_ondblclick;this.mappers[0].oncontextmenu=MDVMap_oncontextmenu;this.mappers[0].onmousewheel=MDVMap_onmousewheel;this.mappers[0].onclick=MDVMap_onclick;this.mappers[1].onmousemove=MDVMap_onmousemove;this.mappers[1].onmouseover=MDVMap_onmouseover;this.mappers[1].onmousedown=MDVMap_onmousedown;this.mappers[1].onmouseup=MDVMap_onmouseup;this.mappers[1].onkeypress=MDVMap_onkeypress;this.mappers[1].ondblclick=MDVMap_ondblclick;this.mappers[1].oncontextmenu=MDVMap_oncontextmenu;this.mappers[1].onmousewheel=MDVMap_onmousewheel;this.mappers[1].onclick=MDVMap_onclick;this.viewport.onmouseout=MDVMap_onmouseout;if(window.addEventListener){this.viewport.addEventListener("DOMMouseScroll",MDVMap_onmousewheel,false)}this.viewport.onmousewheel=MDVMap_onmousewheel;if(this.config.get("maxFailCount")){this.maxFailCount=parseInt(this.config.get("maxFailCount"))}if(this.config.get("crosshair")){var a="images/";if(this.config.get("imagePath")){a=this.config.get("imagePath")}this.crossHairSrc.src=a+this.config.get("crosshair")}this.mappers[0].ondragstart=new Function([],"var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;");this.mappers[1].ondragstart=new Function([],"var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;");this.transparent.src=this.config.get("transparentImg");if(this.config.get("failImg")){this.failImg.src=this.config.get("failImg")}if(this.config.get("cursorIdle")){this.mappers[0].style.cursor=this.config.get("cursorIdle");this.mappers[1].style.cursor=this.config.get("cursorIdle")}this._viewMap();this.renderer=(this.config.get("useCanvasRenderer")=="true"&&document.createElement("canvas").getContext)?new MDVCanvasRenderer(this,this.markerObjects):((document.createElementNS)?new MDVSVGRenderer(this,this.markerObjects):new MDVVMLRenderer(this,this.markerObjects))};MDVMap.prototype.assignTooltipHandler=function(b){if(this.config.get("tooltipHandler")){var a=this.config.get("tooltipHandler");if(a.indexOf("click")!==-1){b.onclick=MDVMarker_displayToolTip}else{if(a.indexOf("mouseover")!==-1){b.onmouseover=MDVMarker_displayToolTip;b.onmouseout=MDVMarker_hideToolTip}}return true}b.onmouseover=MDVMarker_displayToolTip;b.onmouseout=MDVMarker_hideToolTip};MDVMap.prototype.destroy=function(){if(this.state==-1){return}var a=this.gadgets.length;for(var e=0;e<a;e++){var b=this.gadgets.pop();if(b){b.destroy()}}var j=this.layers.length;for(var c=0;c<j;c++){var f=this.layers.pop();if(f){f.destroy()}}for(var k=0;k<this.getMapper().tiles.length;k++){var h=this.getMapper().tiles[k];for(var d=0;d<h.div.childNodes.length;d++){if(h.div.childNodes[d].mdvMap){h.div.childNodes[d].mdvMap=null}}}if(this.mapper){this.mapper.onmousemove=null;this.mapper.onmouseover=null;this.mapper.onmousedown=null;this.mapper.onmouseup=null;this.viewport.onmouseout=null;this.mapper.onkeypress=null;this.mapper.ondblclick=null;this.mapper.oncontextmenu=null;this.mapper.onmousewheel=null;this.mapper.onclick=null;this.mapper.mdvMap=null}if(this.markerObjects&&this.markerObjects.mdvMap){this.markerObjects.mdvMap=null}if(this.viewport&&this.viewport.mdvMap){this.viewport.mdvMap=null}if(this.crossHair){this.crossHair=null}if(this.crossHairSrc){this.crossHairSrc=null}this.transparent=null;document.mdvMaps["mdvMap_"+this.name]=null};MDVMap.prototype._updateVisibleMap=function(){var d=this.config.getZoomLevel(this.config.currentZoomLevelIndex);this._updateMapValues();var e=parseInt((this.tlReal.x-parseInt(d.get("realOffsetX")))/this.tileRealWidth);if(e<0){e=0}var g=parseInt((this.tlReal.x+this.viewportRealWidth-d.get("realOffsetX"))/this.tileRealWidth);if(g>=parseInt(d.get("numberOfTilesX"))){g=parseInt(d.get("numberOfTilesX"))-1}var m=parseInt((this.tlReal.y-parseInt(d.get("realOffsetY")))/this.tileRealHeight);if(m<0){m=0}var f=parseInt((this.tlReal.y+this.viewportRealHeight-parseInt(d.get("realOffsetY")))/this.tileRealHeight);if(f>=parseInt(d.get("numberOfTilesY"))){f=parseInt(d.get("numberOfTilesY"))-1}this.tileVisibleWidth=g-e+2;this.tileVisibleHeight=f-m+2;this.startTileWidth=e;this.startTileHeight=m;if(d.get("numberOfTilesX")<=1){this.tileVisibleWidth--}if(d.get("numberOfTilesY")<=1){this.tileVisibleHeight--}var i=parseInt(d.get("tileSizeX"))*parseInt(d.get("numberOfTilesX"));var k=i/parseInt(d.get("realWidth"));var b=parseInt(d.get("tileSizeY"))*parseInt(d.get("numberOfTilesY"));var j=b/parseInt(d.get("realHeight"));var h=new MDVPoint((this.getCentre().x-parseInt(d.get("realOffsetX")))*k,(this.getCentre().y-parseInt(d.get("realOffsetY")))*j);var l=new MDVPoint((this.tlReal.x-parseInt(d.get("realOffsetX")))*k,(this.tlReal.y-parseInt(d.get("realOffsetY")))*j);var a=new MDVPoint();a.x=(this.tlTileReal.x-parseInt(d.get("realOffsetX")))*k;a.y=(this.tlTileReal.y-parseInt(d.get("realOffsetY")))*j;a.x=Math.floor(a.x+0.5);a.y=Math.floor(a.y+0.5);var c=new MDVPoint(a.x-parseInt(l.x),a.y-parseInt(l.y));this.getMapper().style.left=c.x+"px";this.getMapper().style.top=c.y+"px";this.getCentre().x=Math.floor(this.getCentre().x+0.5);this.getCentre().y=Math.floor(this.getCentre().y+0.5);this.wrapOffset=new MDVPoint(0,0)};MDVMap.prototype._updateMapValues=function(){var h=this.config.getZoomLevel(this.config.currentZoomLevelIndex);if(!h){this.events.triggerEvent(MDVEvent_ERROR,"MDVMap has an invalid zoom level.");return false}var a=parseInt(h.get("tileSizeX"))*parseInt(h.get("numberOfTilesX"));var e=a/parseInt(h.get("realWidth"));var g=parseInt(h.get("tileSizeY"))*parseInt(h.get("numberOfTilesY"));var f=g/parseInt(h.get("realHeight"));this.tileRealWidth=parseInt(h.get("realWidth"))/parseInt(h.get("numberOfTilesX"));this.tileRealHeight=parseInt(h.get("realHeight"))/parseInt(h.get("numberOfTilesY"));this.tileCountWidth=parseInt(this.viewportWidth)/parseInt(h.get("tileSizeX"));this.tileCountHeight=parseInt(this.viewportHeight)/parseInt(h.get("tileSizeY"));this.viewportRealWidth=parseInt(this.tileRealWidth*this.tileCountWidth);this.viewportRealHeight=parseInt(this.tileRealHeight*this.tileCountHeight);this.tlReal=new MDVCoordinates(this.config.get("mapName"),parseInt(this.getCentre().x-(this.viewportRealWidth/2)),parseInt(this.getCentre().y-(this.viewportRealHeight/2)));var b=new MDVPoint((this.tlReal.x-parseInt(h.get("realOffsetX")))*e,(this.tlReal.y-parseInt(h.get("realOffsetY")))*f);var d=parseInt(b.x/parseInt(h.get("tileSizeX")));var c=parseInt(b.y/parseInt(h.get("tileSizeY")));this.tlTileReal=new MDVCoordinates(this.config.get("mapName"),d*this.tileRealWidth+parseInt(h.get("realOffsetX")),c*this.tileRealHeight+parseInt(h.get("realOffsetY")));this.tlTileReal.x=Math.floor(this.tlTileReal.x+0.5);this.tlTileReal.y=Math.floor(this.tlTileReal.y+0.5);return true};MDVMap.prototype.getTopLeftTileReal=function(){return this.tlTileReal};MDVMap.prototype._checkWrap=function(){var f=this.config.getZoomLevel(this.config.getZoomLevelIndex());var c=new MDVPoint(f.get("tileSizeX"),f.get("tileSizeY"));var b=this.viewportWidth-parseInt(f.get("numberOfTilesX"))*parseInt(f.get("tileSizeX"));var a=this.viewportWidth-parseInt(f.get("numberOfTilesY"))*parseInt(f.get("tileSizeY"));var e=f.get("numberOfTilesX")<=1|b>0;var d=f.get("numberOfTilesY")<=1|a>0;this.offset=new MDVPoint(parseInt(this.getMapper().style.left)-this.wrapOffset.x,parseInt(this.getMapper().style.top)-this.wrapOffset.y);if(this.offset.x>0){if(e){return false}this._applyWrapR2L()}if(this.offset.x<-(c.x)){if(e){return false}this._applyWrapL2R()}if(this.offset.y>0){if(d){return false}this._applyWrapB2T()}if(this.offset.y<-(c.y)){if(d){return false}this._applyWrapT2B()}return true};MDVMap.prototype._applyWrapT2B=function(){for(var d=0;d<this.getMapper().tiles.length;d++){var b=this.getMapper().tiles[d];var g=this.config.getZoomLevel(this.config.getZoomLevelIndex());var f=new MDVPoint(g.get("tileSizeX"),g.get("tileSizeY"));var e=parseInt(b.div.childNodes[this.imgCountHeight*this.imgCountWidth-1].style.top);for(var a=0;a<this.imgCountWidth;a++){var c=b.div.childNodes[0];c.style.filter="";c.src=this.transparent.src;c.style.top=(parseInt(e)+parseInt(f.y))+"px";c.src=this.transparent.src;b.div.removeChild(c);b.div.appendChild(c)}}this.wrapOffset.y-=parseInt(f.y);this.startTileHeight++;this._setMapTiles(false)};MDVMap.prototype._applyWrapB2T=function(){for(var d=0;d<this.getMapper().tiles.length;d++){var b=this.getMapper().tiles[d];var g=this.config.getZoomLevel(this.config.getZoomLevelIndex());var f=new MDVPoint(g.get("tileSizeX"),g.get("tileSizeY"));var c=parseInt(b.div.childNodes[0].style.top);for(var a=0;a<this.imgCountWidth;a++){var e=b.div.childNodes[(this.imgCountHeight*this.imgCountWidth)-1];e.style.filter="";e.src=this.transparent.src;e.style.top=(parseInt(c)-parseInt(f.y))+"px";e.src=this.transparent.src;b.div.removeChild(e);b.div.insertBefore(e,b.div.childNodes[0])}}this.wrapOffset.y+=parseInt(f.y);this.startTileHeight--;this._setMapTiles(false)};MDVMap.prototype._applyWrapL2R=function(){for(var d=0;d<this.getMapper().tiles.length;d++){var a=this.getMapper().tiles[d];var g=this.config.getZoomLevel(this.config.getZoomLevelIndex());var f=new MDVPoint(g.get("tileSizeX"),g.get("tileSizeY"));var e=parseInt(a.div.childNodes[this.imgCountWidth-1].style.left);for(var h=0;h<this.imgCountHeight;h++){var b=a.div.childNodes[h*this.imgCountWidth];var c;if(h<(this.imgCountHeight-1)){c=a.div.childNodes[(h+1)*this.imgCountWidth]}else{c=null}b.style.filter="";b.src=this.transparent.src;b.style.left=(parseInt(e)+parseInt(f.x))+"px";b.src=this.transparent.src;a.div.removeChild(b);if(c){a.div.insertBefore(b,c)}else{a.div.appendChild(b)}}}this.wrapOffset.x-=parseInt(f.x);this.startTileWidth++;this._setMapTiles(false)};MDVMap.prototype._applyWrapR2L=function(){for(var b=0;b<this.getMapper().tiles.length;b++){var a=this.getMapper().tiles[b];var f=this.config.getZoomLevel(this.config.getZoomLevelIndex());var c=new MDVPoint(f.get("tileSizeX"),f.get("tileSizeY"));var d=parseInt(a.div.childNodes[0].style.left);for(var h=0;h<this.imgCountHeight;h++){var g=a.div.childNodes[((h+1)*this.imgCountWidth)-1];var e=a.div.childNodes[h*this.imgCountWidth];g.style.filter="";g.src=this.transparent.src;g.style.left=(d-c.x)+"px";g.src=this.transparent.src;a.div.removeChild(g);a.div.insertBefore(g,e)}}this.wrapOffset.x+=parseInt(c.x);this.startTileWidth--;this._setMapTiles(false)};MDVMap.prototype.update=function(){this._updateVisibleMap();this._setLayers();this._updateLayers();if(this._setImages()){this._setOptimisedMapTiles()}else{var c=this.config.getZoomLevel(this.config.getZoomLevelIndex());var d=parseInt(c.get("realOffsetX"))+parseInt(c.get("realWidth"))/2;var b=parseInt(c.get("realOffsetY"))+parseInt(c.get("realHeight"))/2;var a=new MDVCoordinates(this.config.get("mapName"),parseInt(d),parseInt(b));this.events.triggerEvent(MDVEvent_ERROR,"MDVMap has determined that the given coordinates are out of bounds. Setting zoom level centre.",a);this.setCentre(a);this.update()}this.events.triggerEvent(MDVEvent_MAP_INITIALISED,"MDVMap tiles have been initialised",this)};MDVMap.prototype._viewMap=function(){this.state=0;if(this.config.get("backgroundColour")){this._setBackgroundColour(this.config.get("backgroundColour"))}else{this._setBackgroundColour("#E5E5E5")}this.events.triggerEvent(MDVEvent_INITIALISED,"MDVMap has been initialised",this);this._setLayers();this.update();this.state=1};MDVMap.prototype._setMapTiles=function(h){for(var i=0;i<this.getMapper().tiles.length;i++){var b=this.getMapper().tiles[i];b.display();var c=this.config.getZoomLevel(this.config.getZoomLevelIndex());if(!(this.imgCountWidth*this.imgCountHeight==b.div.childNodes.length)){this.events.triggerEvent(MDVEvent_ERROR,"MDVMap noticed an inconsistency within the tile layer.");this._removeImages();this.update();return}var j=b.getFileType();for(var f=0;f<this.imgCountHeight;f++){for(var g=0;g<this.imgCountWidth;g++){var d=b.div.childNodes[(f*this.imgCountWidth)+g];if(!d){this.events.triggerEvent(MDVEvent_ERROR,"Error accessing tile within DOM.");return false}var e=new MDVPoint(g*parseInt(c.get("tileSizeX")),f*parseInt(c.get("tileSizeY")));var a=b.getImageURL(g,f);if(d.src!=a&&d.style.filter!="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a+"');"){d.style.filter="";if(b.isActive()){d.src=a}else{d.src=this.transparent.src}if(h&&!document.all){d.style.visibility="hidden"}}else{if(!h){continue}}if(b.isOverlay()){d.overlay=true}else{d.overlay=false}d.style.width=c.get("tileSizeX");d.style.height=c.get("tileSizeY");d.width=c.get("tileSizeX");d.height=c.get("tileSizeY");if(this.config.get("debug")){d.alt=a;d.title=a}d.failCount=0;if(h){d.style.left=e.x+"px";d.style.top=e.y+"px"}}}}};MDVMap.prototype._setOptimisedMapTiles=function(){var d=this.config.getZoomLevel(this.config.getZoomLevelIndex());for(var l=0;l<this.getMapper().tiles.length;l++){var c=this.getMapper().tiles[l];c.display();var b=new Array();if(!(this.imgCountWidth*this.imgCountHeight==c.div.childNodes.length)){this.events.triggerEvent(MDVEvent_ERROR,"MDVMap noticed an inconsistency within the tile layer.");this._removeImages();this.update();return}var m=c.getFileType();for(var h=0;h<this.imgCountHeight;h++){for(var j=0;j<this.imgCountWidth;j++){var f=c.div.childNodes[(h*this.imgCountWidth)+j];if(!f){this.events.triggerEvent(MDVEvent_ERROR,"Error accessing tile within DOM.");return false}var g=new MDVPoint(j*parseInt(d.get("tileSizeX")),h*parseInt(d.get("tileSizeY")));var a=c.getImageURL(j,h);if(c.isOverlay()){f.overlay=true}else{f.overlay=false}b.push({priority:c.quantifier(g),img:f,src:a,pos:g,size:new MDVPoint(d.get("tileSizeX"),d.get("tileSizeY"))})}}b.sort(c.sorter);for(var e=0;e<b.length;e++){var k=b[e];if(k.img.src!=k.src||c.isActive()==false){k.img.style.filter="";if(c.isActive()){k.img.src=k.src}else{k.img.src=this.transparent.src}if(!document.all){k.img.style.visibility="hidden"}}k.img.style.width=k.size.x+"px";k.img.style.height=k.size.y+"px";k.img.width=k.size.x;k.img.height=k.size.y;if(this.config.get("debug")){k.img.alt=a;k.img.title=a}k.img.failCount=0;k.img.style.left=k.pos.x+"px";k.img.style.top=k.pos.y+"px"}}};MDVMap.prototype.createOverlay=function(c,b){var a=null;a={mdvMap:this,name:c,url:b,imgURL:arguments.length>=3?arguments[2]:null,quantifier:arguments.length>=3?arguments[3]:null,sorter:arguments.length>=3?arguments[4]:null,fileType:null,tiles:null};a.setFileType=function(d){this.fileType=d};a.setActive=function(d){if(this.tiles){this.tiles.setActive(d)}};a.getName=function(){return this.name};return a};MDVMap.prototype.addOverlay=function(a){for(var b=0;b<this.overlays.length;b++){if(this.overlays[b].getName()==a.getName()){return false}}this.overlays.push(a);return true};MDVMap.prototype._setLayers=function(){if(this.getMapper().tiles.length<=0&&this.getMapper()){var b=new MDVTiles(this,this.getMapper().id+"_mapTiles");if(this.options.getImageURL!=null&&typeof this.options.getImageURL=="function"){b.getImageURL=this.options.getImageURL}this.getMapper().tiles.push(b);var a=null;for(var c=0;c<this.overlays.length;c++){if(this.overlays[c].imgURL){a=new MDVTiles(this.overlays[c].mdvMap,this.getMapper().id+"_overlay_"+this.overlays[c].name,this.overlays[c].imgURL);a.setOverlay(true);a.setSrcPath(this.overlays[c].url);if(this.overlays[c].fileType){a.setFileType(this.overlays[c].fileType)}if(this.overlays[c].quantifier){a.setQuantifier(this.overlays[c].quantifier)}if(this.overlays[c].sorter){a.setSorter(this.overlays[c].sorter)}}else{a=new MDVTiles(this.overlays[c].mdvMap,this.getMapper().id+"_overlay_"+this.overlays[c].name);a.setOverlay(true);if(this.overlays[c].url){a.setSrcPath(this.overlays[c].url)}if(this.overlays[c].fileType){a.setFileType(this.overlays[c].fileType)}}this.overlays[c].tiles=a;this.getMapper().tiles.push(a)}}if(!this.markerObjects&&this.getMapper()){this.markerObjects=document.createElement("div");this.markerObjects.className="mdvLayer";this.markerObjects.style.zIndex="55";this.markerObjects.id=this.getName()+"_mdvMarkers";this.markerObjects.style.position="absolute";this.markerObjects.style.visibility="visible";this.markerObjects.style.left="0px";this.markerObjects.style.top="0px";this.markerObjects.style.width="3000px";this.markerObjects.style.height="3000px";this.markerObjects.mdvMap=this;this.getMapper().appendChild(this.markerObjects);this.markerObjects.append=true}if(!this.markerLayer){this.markerLayer=this.createLayer("mdvMarkers");this.addLayer(this.markerLayer)}if(this.config.get("useTooltipLayer")==="true"&&!this.tooltipLayer){this.tooltipLayer=this.createLayer("mdvTooltips",{useOwnContainer:true});this.addLayer(this.tooltipLayer)}};MDVMap.prototype._setImages=function(){if(this.tileVisibleWidth<=0||this.tileVisibleHeight<=0){return false}while(this.imgCountWidth<this.tileVisibleWidth){this._addColumn()}while(this.imgCountHeight<this.tileVisibleHeight){this._addRow()}while(this.imgCountHeight>this.tileVisibleHeight){this._removeRow()}while(this.imgCountWidth>this.tileVisibleWidth){this._removeColumn()}return true};MDVMap.prototype._removeImages=function(){for(var d=0;d<this.getMapper().tiles.length;d++){var b=this.getMapper().tiles[d];var e=b.div.childNodes.length;for(var c=0;c<e;c++){var a=b.div.childNodes[e-c-1];a.onmousedown=null;a.onmousemove=null;a.onmouseout=null;a.onmouseover=null;a.onmouseup=null;a.onmousewheel=null;a.onclick=null;a.onload=null;a.onerror=null;if(a.mdvMap){a.mdvMap=null}b.div.removeChild(a)}this.imgCountWidth=0;this.imgCountHeight=0}if(this.getMapper().tiles.length==0){this.imgCountWidth=0;this.imgCountHeight=0}};MDVMap.prototype._addColumn=function(){if(this.tileVisibleWidth==0){return}for(var d=0;d<this.getMapper().tiles.length;d++){var a=this.getMapper().tiles[d];var e=this.config.getZoomLevel(this.config.getZoomLevelIndex());for(var c=0;c<this.imgCountHeight;c++){var f=new MDVPoint((this.imgCountWidth+1)*parseInt(e.get("tileSizeX")),c*parseInt(e.get("tileSizeY")));var b=this._createImage(f);a.div.appendChild(b)}}this.imgCountWidth++};MDVMap.prototype._removeColumn=function(){if(this.imgCountWidth<=1){return}for(var e=0;e<this.getMapper().tiles.length;e++){var a=this.getMapper().tiles[e];var d=a.div.childNodes.length+this.imgCountWidth-2;for(var f=0;f<this.imgCountHeight;f++){var c=(this.imgCountHeight*f)+(this.imgCountWidth-1);var b=a.div.childNodes[(d-c)];if(!b){this.events.triggerEvent(MDVEvent_ERROR,"Error accessing tile.");return false}b.onmousedown=null;b.onmousemove=null;b.onmouseout=null;b.onmouseover=null;b.onmouseup=null;b.onmousewheel=null;b.onclick=null;if(b.mdvMap){b.mdvMap=null}b.onload=null;b.onerror=null;a.div.removeChild(b)}}this.imgCountWidth--};MDVMap.prototype._addRow=function(){if(this.tileVisibleWidth==0){return}for(var d=0;d<this.getMapper().tiles.length;d++){var a=this.getMapper().tiles[d];var e=this.config.getZoomLevel(this.config.getZoomLevelIndex());var c;for(c=0;c<this.tileVisibleWidth;c++){var f=new MDVPoint(c*parseInt(e.get("tileSizeX")),this.imgCountHeight*parseInt(e.get("tileSizeY")));var b=this._createImage(f);a.div.appendChild(b);this.imgCountWidth++}}this.imgCountWidth=c;this.imgCountHeight++};MDVMap.prototype._removeRow=function(){if(this.imgCountHeight<=1){return}for(var e=0;e<this.getMapper().tiles.length;e++){var a=this.getMapper().tiles[e];var f=this.config.getZoomLevel(this.config.getZoomLevelIndex());for(var d=0;d<this.imgCountWidth;d++){var c=(this.imgCountHeight*this.imgCountWidth)-d-1;var b=a.div.childNodes[c];if(!b){this.events.triggerEvent(MDVEvent_ERROR,"MDVMap has problems while accessing tile.");return false}b.onload=null;b.onerror=null;a.div.removeChild(b)}}this.imgCountHeight--};MDVMap.prototype._createImage=function(c){var b=this.config.getZoomLevel(this.config.getZoomLevelIndex());var a=document.createElement("img");a.src=this.transparent.src;a.width=parseInt(b.get("tileSizeX"));a.height=parseInt(b.get("tileSizeY"));a.setAttribute("style","position:absolute; top:"+c.y+"px; left:"+c.x+"px;");a.style.position="absolute";a.style.width=parseInt(b.get("tileSizeX"))+"px";a.style.height=parseInt(b.get("tileSizeY"))+"px";a.style.top=c.y;a.style.left=c.x;a.galleryimg="no";a.onerror=MDVMap_imgOnError;a.onload=MDVMap_imgOnLoad;a.mdvMap=this;a.id="t"+this.lastImageID++;a.failCount=0;return a};MDVMap.prototype.getPolylinePoints=function(){var g=new Array();var e=new Array();for(var b=0;b<this.layers.length;b++){var d=this.layers[b].getPolylineCoords();for(var f=0;f<d.length;f++){var a=this.getPoint(d[f]);g.push(a.x);e.push(a.y)}}return[g,e]};MDVMap.prototype.getPolylineCoords=function(){var f=new Array();var d=new Array();for(var a=0;a<this.layers.length;a++){var b=this.layers[a].getPolylineCoords();for(var e=0;e<b.length;e++){f.push(b[e].x);d.push(b[e].y)}}return[f,d]};MDVMap.prototype.createLayer=function(b,a){return new MDVLayer(this,b,a)};MDVMap.prototype.createClusterLayer=function(b,a){return new MDVClusterLayer(this,b,a)};MDVMap.prototype.hideToolTips=function(){var c=this.getLayers();var b=false;for(var a=0;a<c.length;a++){b=c[a].hideToolTips()}return b};MDVMap.prototype.createPolyline=function(b){var a=null;if(arguments.length==2){a=new MDVPolyline(this,b,arguments[1])}else{a=new MDVPolyline(this,b)}return a};MDVMap.prototype.wizardSetMotIcon=function(c){var b,a,d=this;if(!c){return}a=function(){var e=this.wizardMotIcon,f=this.getViewportExtends();if(e){e.src=c;e.style.top=parseInt(f.height/2-b.height/2)+"px";e.style.left=parseInt(f.width/2-b.width/2)+"px";return}b.id="wizardMotIcon";b.style.display="block";b.style.position="absolute";b.style.top=parseInt(f.height/2-b.height/2)+"px";b.style.left=parseInt(f.width/2-b.width/2)+"px";b.style.zIndex=999;this.wizardMotIcon=b;this.viewport.appendChild(b)};b=new Image();b.onload=function(){a.apply(d,[])};b.src=c};MDVMap.prototype.wizardRemoveMotIcon=function(){if(!this.wizardMotIcon){return}this.viewport.removeChild(this.wizardMotIcon);this.wizardMotIcon=null};MDVMap.prototype.moveBySeq=function(e){var d=true;if(this.moveJobID){mdvTimer.remove(this.moveJobID)}this.cleanMagnifyMapper();var a=this.getMoveSeq(e);var c=null;if(arguments.length>=2){if(arguments[1]){c=arguments[1]}if(arguments.length==3){d=arguments[2]}}if(a.length>0&&d){var b=a[0].clone();this.setCentre(b);this.update()}this.moveJobID=mdvTimer.add(this.stepTime,this,this.move,[a,0]);return true};MDVMap.prototype.getMoveSeq=function(h){if(h.length<=0){return null}var e=this.config.getZoomLevel(this.config.currentZoomLevelIndex);var l=parseInt(e.get("tileSizeX"))*parseInt(e.get("numberOfTilesX"));var f=parseInt(e.get("realWidth"))/l;var m=new Array();var j=h[0].clone();var b=0;var g=null;var n=null;var i=this.stepPx*f;for(var k=1;k<h.length;k++){n=h[k];var d=new MDVPoint(n.x-j.x,n.y-j.y);if(d.x==0&&d.y==0){continue}b=Math.sqrt(Math.pow(d.x,2)+Math.pow(d.y,2));var a=i/b;g=new MDVPoint(d.x*a,d.y*a);while(b>i){j.x=(j.x+g.x);j.y=(j.y+g.y);m.push(j.clone());b=b-i}if(b>0){g=new MDVPoint(n.x-j.x,n.y-j.y);j.x=(j.x+g.x);j.y=(j.y+g.y);m.push(j.clone())}b=0}return m};MDVMap.prototype.move=function(a,b){if(b>=a.length){if(this.moveJobID){mdvTimer.remove(this.moveJobID)}this.moveJobID=null;this.wizardRemoveMotIcon();this.removeMarker(this.crossHair);if(this.crossHair){this.crossHair.destroy()}this.crossHair=null;this.events.triggerEvent(MDVEvent_ROUTE_TRACE_FINISHED,"MDVMap has finished moving...",a);this.update();return false}this.moveTo(a[b]);b++;this.moveJobID=mdvTimer.add(this.stepTime,this,this.move,[a,b])};MDVMap.prototype.cancelMoveBySeq=function(){var a=false;if(mdvTimer){a=mdvTimer.remove(this.moveJobID)}this.moveJobID=null;this.wizardRemoveMotIcon();if(this.crossHair){this.removeMarker(this.crossHair);this.crossHair.destroy();this.crossHair=null}return a};MDVMap.prototype.moveTo=function(c){var b=this.getPoint(this.getCentre());var d=this.getPoint(c);if(this.crossHair){this.crossHair.setCoords(c.clone())}var a=new MDVPoint(parseInt(this.getMapper().style.left),parseInt(this.getMapper().style.top));if(b==null||d==null){return false}var e=new MDVPoint(d.x-b.x,d.y-b.y);this.getMapper().style.left=(a.x-e.x)+"px";this.getMapper().style.top=(a.y-e.y)+"px";if(this.getMagnifyMapper()){this.getMagnifyMapper().style.left=(parseInt(this.getMagnifyMapper().style.left)-e.x)+"px";this.getMagnifyMapper().style.top=(parseInt(this.getMagnifyMapper().style.top)-e.y)+"px"}this.setCentre(c);this._checkWrap();return true};MDVMap.prototype.magnify=function(h){var m=this.config.getZoomLevel(this.config.getZoomLevelIndex());var s=this.config.getZoomLevel(h);if(m==null||s==null||m.level==s.level){return false}var a=parseInt(m.get("realWidth"))/parseInt(m.get("numberOfTilesX"));var k=parseInt(s.get("realWidth"))/parseInt(s.get("numberOfTilesX"));var g=a/k;var e=null;for(var l=0;l<this.getMapper().tiles.length;l++){if(!this.getMapper().tiles[l].isOverlay()){e=this.getMapper().tiles[l]}else{this.getMapper().tiles[l].hide()}}if(e==null){return false}var o=this.getMapper();var b=o.childNodes&&o.childNodes.length||0;for(var p=0;p<b;p+=1){if(/mapTiles/.test(o.childNodes[p].id)===false){o.childNodes[p].style.display="none"}}var q=this.getCentre();var d=new MDVPoint(0,0);if(arguments.length==2&&arguments[1]&&arguments[1].x>0&&arguments[1].y>0){var f=this.getPoint(q);q=arguments[1];var j=this.getPoint(q);d.x=f.x-j.x;d.y=f.y-j.y}var n=this.getPoint(q);var r=new MDVPoint(n.x*(1-g),n.y*(1-g));for(var p=0;p<e.div.childNodes.length;p++){var u=e.div.childNodes[p];u.style.width=Math.floor(0.5+(parseInt(u.style.width)*g))+"px";u.style.height=Math.floor(0.5+(parseInt(u.style.height)*g))+"px";u.style.top=(parseInt(u.style.top)*g)+"px";u.style.left=(parseInt(u.style.left)*g)+"px"}this.getMapper().style.left=(parseInt(this.getMapper().style.left)+d.x+r.x)+"px";this.getMapper().style.top=(parseInt(this.getMapper().style.top)+d.y+r.y)+"px";this.setZoomLevel(h);this.setCentre(q);return true};MDVMap.prototype.setDefaultCursor=function(){if(this.config.get("cursorIdle")){if(document.all){this.getMapper().style.cursor="url('"+this.config.get("cursorIdle")+"')"}else{this.getMapper().style.cursor="-moz-grab"}}};function MDVTiles(a,b){this.mdvMap=a;this.name=b;this.id=this.mdvMap.lastTileLayerID++;this.zIndex=this.id;this.srcPath=this.mdvMap.config.get("serverURL");this.block=parseInt(this.mdvMap.config.get("block"));this.fileType=".png";this.active=true;this.overlay=false;if(this.mdvMap.config.get("fileType")){this.fileType=this.mdvMap.config.get("fileType")}this.div=document.createElement("div");this.div.className="mdvLayer";this.div.style.zIndex=this.zIndex;this.div.id=this.mdvMap.getName()+"_"+this.name;this.div.style.position="absolute";this.div.style.visibility="visible";this.div.style.left="0px";this.div.style.top="0px";this.div.style.width="3000px";this.div.style.height="3000px";this.div.mdvMap=this;if(arguments.length==3&&arguments[2]){this.getImageURL=arguments[2]}this.mdvMap.getMapper().appendChild(this.div);this.div.append=true}MDVTiles.prototype.hide=function(a){this.div.style.display="none"};MDVTiles.prototype.display=function(){this.div.style.display="block"};MDVTiles.prototype.getName=function(){return this.name};MDVTiles.prototype.isOverlay=function(){return this.overlay};MDVTiles.prototype.setOverlay=function(a){this.overlay=a};MDVTiles.prototype.getSrcPath=function(b,c){if(typeof this.srcPath==="string"){return this.srcPath}if(this.srcPath.constructor!==Array){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"Invalid format for config.serverURL.\nArray or String expected.");return}var a=this.srcPath.length;if(a>0){return this.srcPath[(b&&c)?((b^c)%a):0]}};MDVTiles.prototype.setSrcPath=function(a){this.srcPath=a};MDVTiles.prototype.getBlock=function(){return this.block};MDVTiles.prototype.setBlock=function(a){this.block=a};MDVTiles.prototype.getFileType=function(){return this.fileType};MDVTiles.prototype.setFileType=function(a){this.fileType=a};MDVTiles.prototype.setActive=function(a){this.active=a};MDVTiles.prototype.isActive=function(){return this.active};MDVTiles.prototype.setQuantifier=function(a){this.quantifier=a};MDVTiles.prototype.setSorter=function(a){this.sorter=a};MDVTiles.prototype.getImageURL=function(j,h){var e=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var b=this.getSrcPath(j,h);var c=this.mdvMap.config.getZoomLevelIndex();if(e.get("zoomLevel")){c=e.get("zoomLevel")}if(this.getBlock()){var f=this.getBlock();var i=Math.floor((this.mdvMap.startTileWidth+j)/f)*f;var d=i+f-1;var g=Math.floor((this.mdvMap.startTileHeight+h)/f)*f;var a=g+f-1;b+="zoomlevel";b+=c;b+="/columns"+i+"-"+d;b+="/column";b+=(this.mdvMap.startTileWidth+j);b+="/rows"+g+"-"+a+"/";b+=(this.mdvMap.startTileHeight+h);b+="_";b+=(this.mdvMap.startTileWidth+j);b+="_";b+=c;b+=this.getFileType()}else{b+="zoomlevel";b+=c;b+="/column";b+=(this.mdvMap.startTileWidth+j);b+="/"+this.mdvMap.config.get("network")+"_";b+=(this.mdvMap.startTileHeight+h);b+="_";b+=(this.mdvMap.startTileWidth+j);b+=this.getFileType()}return b};MDVTiles.prototype.sorter=function(d,c){return d.priority-c.priority};MDVTiles.prototype.quantifier=function(d){var b=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var c=this.mdvMap.getPoint(this.mdvMap.getCentre());var a=new MDVPoint((d.x+parseInt(b.get("tileSizeX"))/2)-c.x,(d.y+parseInt(b.get("tileSizeY"))/2)-c.y);return Math.floor(0.5+(Math.pow(a.x,2)+Math.pow(a.y,2)))};function MDVMapConfig(){this.zoomLevels=new Array();this.currentZoomLevelIndex=null;this.params=new Array()}MDVMapConfig.prototype.clone=function(){var b=new MDVMapConfig();for(var d=0;d<=100;d++){if(this.zoomLevels[d]==null){continue}var a=new MDVMapConfigZoomLevel(this.zoomLevels[d].getLevel());a.setScale(this.zoomLevels[d].getScale());for(var c in this.zoomLevels[d].params){if(this.zoomLevels[d].params[c]){a.add(c,this.zoomLevels[d].params[c])}}b.registerZoomLevel(a)}return b};MDVMapConfig.prototype.registerZoomLevel=function(a){this.zoomLevels[a.level]=a};MDVMapConfig.prototype.getZoomLevels=function(){return this.zoomLevels};MDVMapConfig.prototype.getZoomLevel=function(a){if(this.zoomLevels[a]){return this.zoomLevels[a]}else{return null}};MDVMapConfig.prototype.add=function(a,b){this.params[a]=b};MDVMapConfig.prototype.get=function(a){return this.params[a]};MDVMapConfig.prototype.setZoomLevelIndex=function(a){this.currentZoomLevelIndex=a};MDVMapConfig.prototype.getZoomLevelIndex=function(){return this.currentZoomLevelIndex};function MDVMapConfigZoomLevel(a){this.level=a;this.scale=null;this.params=new Array()}MDVMapConfigZoomLevel.prototype.add=function(a,b){this.params[a]=b};MDVMapConfigZoomLevel.prototype.get=function(a){return this.params[a]};MDVMapConfigZoomLevel.prototype.setScale=function(a){this.scale=a};MDVMapConfigZoomLevel.prototype.getScale=function(){return this.scale};MDVMapConfigZoomLevel.prototype.getLevel=function(){return this.level};MDVMap_onmousemove=function(c){c=c?c:window.event;var a=true;if(c.button==2){this.mdvMap.events.triggerEvent(MDVEvent_CONTEXT_MENU)}for(var b=0;b<this.mdvMap.gadgets.length;b++){if(!this.mdvMap.gadgets[b].onmousemove(c)){a=false;break}}return a};MDVMap_onmouseover=function(c){c=c?c:window.event;var a=true;for(var b=0;b<this.mdvMap.gadgets.length;b++){if(!this.mdvMap.gadgets[b].onmouseover(c)){a=false}}return a};MDVMap_onmousedown=function(c){c=c?c:window.event;var a=true;this.mdvMap.events.triggerEvent(MDVEvent_MOUSE_DOWN,"MDVMap noticed a mouse down event.",c);for(var b=0;b<this.mdvMap.gadgets.length;b++){if(!this.mdvMap.gadgets[b].onmousedown(c)){a=false;break}}return a};MDVMap_onmouseup=function(b){b=b?b:window.event;this.mdvMap.events.triggerEvent(MDVEvent_MOUSE_UP,"MDVMap noticed a mouse up event.",b);for(var a=0;a<this.mdvMap.gadgets.length;a++){if(!this.mdvMap.gadgets[a].onmouseup(b)){ret=false;break}}return true};MDVMap_onmouseout=function(b){b=b?b:window.event;for(var a=0;a<this.mdvMap.gadgets.length;a++){if(!this.mdvMap.gadgets[a].onmouseout(b)){return false}}return true};MDVMap_onkeypress=function(b){b=b?b:window.event;for(var a=0;a<this.mdvMap.gadgets.length;a++){if(!this.mdvMap.gadgets[a].onkeypress(b)){return false}}return true};MDVMap_ondblclick=function(b){b=b?b:window.event;for(var a=0;a<this.mdvMap.gadgets.length;a++){if(!this.mdvMap.gadgets[a].ondblclick(b)){return false}}return true};MDVMap_oncontextmenu=function(b){b=b?b:window.event;for(var a=0;a<this.mdvMap.gadgets.length;a++){if(!this.mdvMap.gadgets[a].oncontextmenu(b)){return false}}return true};MDVMap_onmousewheel=function(b){b=b?b:window.event;for(var a=0;a<this.mdvMap.gadgets.length;a++){if(!this.mdvMap.gadgets[a].onmousewheel(b)){return false}}return true};MDVMap_onclick=function(a){a=a?a:window.event;if(!(this.mdvMap.config.get("enableHotspots"))){return}if(this.mdvMap.hotspots.current==null){return true}this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_CLICKED,"MDVMap Object clicked....",this.mdvMap.hotspots.current);return true};MDVMap_imgOnError=function(a){a=a?a:window.event;if(this.mdvMap){this.mdvMap.events.triggerEvent(MDVEvent_WARNING,"MDVMap couldn't load tile "+this.id+" (failCount: "+this.failCount+")");this.failCount++;var b=this.src;this.src=this.mdvMap.transparent.src;if(this.failCount<=this.mdvMap.maxFailCount){this.src=b}else{if(this.mdvMap.config.get("failImg")){this.src=this.mdvMap.failImg.src}else{this.src=this.mdvMap.transparent.src}}}};MDVMap_imgOnLoad=function(b){b=b?b:window.event;this.style.visibility="visible";var a=navigator.userAgent;if(this.src==this.mdvMap.transparent.src){return true}if(document.all&&a.indexOf("Opera")<0&&this.overlay){var c=this.src;this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+c+"');";this.src=this.mdvMap.transparent.src}if(this.failCount>0&&this.src!=this.mdvMap.transparent.src){this.mdvMap.events.triggerEvent(MDVEvent_WARNING,"MDVMap recovered tile "+this.id+" (failCount: "+this.failCount+")")}};function MDVCoordinates(b,a,c){this.x=a;this.y=c;if(typeof a=="string"&&b.indexOf("WGS")<0){this.x=parseInt(this.x)}else{if(typeof a=="string"&&b.indexOf("WGS")>=0){this.x=parseFloat(this.x)}}if(typeof c=="string"&&b.indexOf("WGS")<0){this.y=parseInt(this.y)}else{if(typeof c=="string"&&b.indexOf("WGS")>=0){this.y=parseFloat(this.y)}}this.mapName=b;this.zone=-1;this.height=0;this.hemisphere=""}MDVCoordinates.prototype.toString=function(){return this.mapName+", x: "+this.x+", y: "+this.y};MDVCoordinates.prototype.equals=function(d){if(!d||!d.x||!d.y){return false}var a=this.x;var e=this.y;var c=d.x;var b=d.y;if(a%1>0){a=parseInt(Math.floor(a+0.5))}if(e%1>0){e=parseInt(Math.floor(e+0.5))}if(c%1>0){c=parseInt(Math.floor(c+0.5))}if(b%1>0){b=parseInt(Math.floor(b+0.5))}return(a==c&&e==b&&this.mapName==d.mapName)};MDVCoordinates.prototype.clone=function(){var a=new MDVCoordinates(this.mapName,this.x,this.y);if(this.zone>=0){a.zone=this.zone}if(this.hemisphere!=""){a.hemisphere=this.hemisphere}if(this.height>0){a.height=this.height}return a};function MDVPoint(a,b){this.x=a;this.y=b;if(typeof a=="string"){this.x=parseInt(this.x)}if(typeof b=="string"){this.y=parseInt(this.y)}}MDVPoint.prototype.toString=function(){return"x: "+this.x+", y: "+this.y};MDVPoint.prototype.equals=function(b){if(!b||!b.x||!b.y){return false}var a=this.x;var e=this.y;var d=b.x;var c=b.y;if(a%1>0){a=parseInt(Math.floor(a+0.5))}if(e%1>0){e=parseInt(Math.floor(e+0.5))}if(d%1>0){d=parseInt(Math.floor(d+0.5))}if(c%1>0){c=parseInt(Math.floor(c+0.5))}return(a==d&&e==c)};MDVPoint.prototype.clone=function(){return new MDVPoint(this.x,this.y)};function MDVMarker(a,d,c,b){if(!a){return}this.mdvMap=a;this.img=new Image();this.img.marker=this;this.img.mdvMap=a;this.img.onload=MDVMarker_onload;this.img.onerror=MDVMarker_onerror;this.img.onclick=MDVMarker_onclick;this.img.oncontextmenu=MDVMarker_oncontextmenu;this.img.ondblclick=MDVMarker_ondblclick;this.imgSrc=c;this.marker=this;this.id=a.lastMarkerID++;this.coords=this.mdvMap.getInternalCoordinates(d);this.toolTip=null;this.visible=true;this.objectId={type:"coord",desc:"",id:this.getCoords().x+":"+this.getCoords().y+":"+this.getCoords().mapName,omc:"",marker:this};this.append=false;if(typeof b=="object"&&b&&b.x>=0&&b.y>=0){this.xFactor=b.x;this.yFactor=b.y}else{this.xFactor=b;this.yFactor=1}}MDVMarker.prototype.setVisibility=function(b){var a=b?"visible":"hidden";this.img.style.visibility=a;this.visible=b;return true};MDVMarker.prototype.isVisible=function(){return this.visible};MDVMarker.prototype.equals=function(a){return this.id==a.id};MDVMarker.prototype.intersects=function(c){if(c==null){return false}var a=this.getRectangle();var b=c.getRectangle();return b.width>0&&b.height>0&&a.width>0&&a.height>0&&b.x<a.x+a.width&&b.x+b.width>a.x&&b.y<a.y+a.height&&b.y+b.height>a.y};MDVMarker.prototype.getRectangle=function(){var c=this.mdvMap.getPoint(this.getCoords());var f=this.img.width;var b=this.img.height;var a=this.getXFactor();var d=this.getYFactor();var e=new MDVPoint(c.x-f*a,c.y-b*d);return{x:e.x,y:e.y,width:f,height:b}};MDVMarker.prototype.update=function(){var c=this.mdvMap.getPoint(this.getCoords());var g=true;if(!c){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to get px coordinates for marker.");return false}if(arguments.length>0){g=arguments[0]}var e=this.img.width;var b=this.img.height;var a=this.getXFactor();var d=this.getYFactor();this.img.style.position="absolute";this.img.style.left=(c.x-e*a)+"px";this.img.style.top=(c.y-b*d)+"px";if(this.layer&&this.layer.zIndex){this.img.style.zIndex=this.layer.zIndex}var f=this.visible?"visible":"hidden";if(this.img.style.visibility!=f){this.img.style.visibility=f}if(this.toolTip&&this.toolTip.isVisible()&&g){this.toolTip.update()}return true};MDVMarker.prototype.destroy=function(){this.img.marker=null;this.img.mdvMap=null;if(this.toolTip){this.toolTip.destroy()}if(this.marker.layer){this.marker.layer=null}this.toolTip=null;this.objectId=null;this.coords=null;this.marker=null;this.img.onload=null;this.img=null};MDVMarker.prototype.getCoords=function(){if(this.coords&&this.coords.x>0&&this.coords.y>0){return this.coords}return null};MDVMarker.prototype.setCoords=function(a){this.coords=this.mdvMap.getInternalCoordinates(a);this.update()};MDVMarker.prototype.getXFactor=function(){return this.xFactor};MDVMarker.prototype.getYFactor=function(){return this.yFactor};MDVMarker.prototype.setTitle=function(a){this.img.title=a;this.img.alt=a};MDVMarker.prototype.setToolTip=function(b){if(!b){return false}var c=false;if(arguments.length==2){c=arguments[1]}var a=this.coords.clone();this.toolTip=b;this.toolTip.setParent(this);this.img.toolTip=b;this.toolTip.setCoords(a);if(c&&this.toolTip.isVisible()){this.toolTip.update()}this.mdvMap.assignTooltipHandler(this.img);return true};MDVMarker.prototype.setObjectId=function(a){this.objectId=a};MDVMarker.prototype.getObjectId=function(){return this.objectId};MDVMarker.prototype.getImage=function(){return this.img};function MDVMarker_onload(c){c=c?c:window.event;if(this.marker){this.marker.update();if(!this.marker.append&&this.marker.layer){if(this.marker.layer.ownContainer){this.marker.layer.ownContainer.appendChild(this)}else{this.mdvMap.markerObjects.appendChild(this)}this.marker.append=true;if(document.all&&this.src!=this.marker.mdvMap.transparent.src&&this.src.substring(this.src.length,this.src.length-4).toLowerCase()==".png"){var b=this.width;var a=this.height;var d=this.src;this.style.width=b+"px";this.style.height=a+"px";this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+d+"');";this.marker.img.src=this.marker.mdvMap.transparent.src}this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_LOADED,"MDVMap noticed that a marker finished loading.",this.marker)}}}function MDVMarker_onerror(a){a=a?a:window.event}function MDVMarker_displayToolTip(g){g=g?g:window.event;var f=this.marker||this;if(f){f.mdvMap.cancelMoveBySeq();if(f.toolTip.isFixed()){return}if(f.toolTip){f.toolTip.cancelHide()}if(this.parentPolyline){var b=g.pageX||(g.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var a=g.pageY||(g.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var j=0;var h=0;var d=this.mdvMap.viewport;while(d){j+=d.offsetLeft;h+=d.offsetTop;d=d.offsetParent}var i=new MDVPoint(b-j-1,a-h-1);var c=this.mdvMap.getCoordinates(i);if(f.toolTip&&!f.toolTip.isVisible()){this.parentPolyline.setMouse(c)}}if(f.toolTip){f.toolTip.triggerDisplay()}}}function MDVMarker_hideToolTip(b){b=b?b:window.event;var a=this.marker||this;if(a&&a.toolTip){a.toolTip.cancelDisplay();a.toolTip.triggerHide()}}function MDVMarker_onclick(a){if(this.marker){this.marker.objectId.right=false;this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_CLICKED,"MDVMap Object clicked....",this.marker.objectId)}return false}function MDVMarker_oncontextmenu(a){a=a?a:window.event;if(this.marker){this.marker.objectId.right=true;this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_CLICKED,"MDVMap Object clicked....",this.marker.objectId)}a.cancelBubble=true;a.returnValue=false;if(a.stopPropagation){a.stopPropagation()}if(a.preventDefault){a.preventDefault()}return false}function MDVMarker_ondblclick(a){a=a?a:window.event;this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_DBLCLICKED,"MDVMap Object dblclicked....",this.marker.objectId);a.cancelBubble=true;a.returnValue=false;if(a.stopPropagation){a.stopPropagation()}if(a.preventDefault){a.preventDefault()}return false}function MDVToolTip(a,c,b){this.mdvMap=a;this.innerHTML=c;this.id=this.mdvMap.lastToolTipID++;this.slidable=false;this.parentMarker=null;this.type=b;this.coords=null;this.container=null;this.size=null;this.fixed=false;this.jobs=new Array();this.overflow=false;this.pin=false;this.disabled=false;this.jobs.display=null;this.jobs.hide=null;this.mdvMap.events.registerEvent(MDVEvent_TOOLTIP,this,this.scrollToFit)}MDVToolTip.prototype.setDisabled=function(a){this.disabled=a};MDVToolTip.prototype.isDisabled=function(){return this.disabled};MDVToolTip.prototype.setPin=function(a){this.pin=a};MDVToolTip.prototype.hasPin=function(){return this.pin};MDVToolTip.prototype.setOverflow=function(a){this.overflow=a};MDVToolTip.prototype.isOverflow=function(){return this.overflow};MDVToolTip.prototype.setSlidable=function(a){this.slidable=a};MDVToolTip.prototype.isSlidable=function(){return this.slidable};MDVToolTip.prototype.setInnerHTML=function(a){this.innerHTML=a;if(this.container){this.container.setInnerHTML(a)}};MDVToolTip.prototype.getInnerHTML=function(){return this.innerHTML};MDVToolTip.prototype.setContainer=function(a){this.container=a};MDVToolTip.prototype.getContainer=function(){return this.container};MDVToolTip.prototype.getManager=function(){return this.manager};MDVToolTip.prototype.setCoords=function(a){a=this.mdvMap.getInternalCoordinates(a);this.coords=a};MDVToolTip.prototype.getCoords=function(){return this.coords};MDVToolTip.prototype.setType=function(a){this.type=a};MDVToolTip.prototype.getType=function(){return this.type};MDVToolTip.prototype.setParent=function(a){this.parentMarker=a};MDVToolTip.prototype.getParent=function(){return this.parentMarker};MDVToolTip.prototype.setSize=function(a){this.size=a};MDVToolTip.prototype.getSize=function(){return this.size};MDVToolTip.prototype.setFixed=function(a){this.fixed=a};MDVToolTip.prototype.isFixed=function(){return this.fixed};MDVToolTip.prototype.scrollToFit=function(){if(!this.mdvMap||this.mdvMap.config.get("useToolTipScrollToFit")==null||this.mdvMap.config.get("useToolTipScrollToFit")!="true"){return}if(!this.isVisible()){return}var e=null;if(this.mdvMap&&this.mdvMap.config.get("useToolTipScrollToFitOffset")!=null){var m=this.mdvMap.config.get("useToolTipScrollToFitOffset").split(":");e=new MDVPoint(m[0],m[1])}var i=this.getSize().clone();i.x/=2;i.y/=2;var k=this.mdvMap.config.getZoomLevel(this.mdvMap.config.currentZoomLevelIndex);var t=parseInt(k.get("tileSizeX"))*parseInt(k.get("numberOfTilesX"));var a=parseInt(k.get("realWidth"))/t;var r=parseInt(k.get("tileSizeY"))*parseInt(k.get("numberOfTilesY"));var q=parseInt(k.get("realHeight"))/r;var f=this.mdvMap.getPoint(this.getCoords());var u=this.getCoords().clone();if(e){u.x-=Math.floor(0.5+e.x*a);u.y-=Math.floor(0.5+e.y*q)}var l=this.getContainer().getPosition();l.x+=Math.floor(0.5+i.x)-this.mdvMap.wrapOffset.x;l.y+=Math.floor(0.5+i.y)-this.mdvMap.wrapOffset.y;var h=new MDVPoint(l.x-f.x,l.y-f.y);h.x*=a;h.y*=q;u.x+=h.x;u.y+=h.y;var g=this.mdvMap.getCentre().clone();var j=[g,u];var s=new MDVPoint(u.x-g.x,u.y-g.y);var b=this.mdvMap.getViewportRealExtends();var w=Math.max(b.width,b.height);var n=Math.floor(0.5+Math.sqrt(Math.pow(s.x,2)+Math.pow(s.y,2)));if(n<(w)){this.mdvMap.cancelMoveBySeq();this.mdvMap.stepPx=document.all?3:6;this.mdvMap.stepTime=document.all?10:1;this.mdvMap.moveBySeq(j,null,false)}else{this.mdvMap.setCentre(u);this.mdvMap.update()}};MDVToolTip.prototype.display=function(){if(this.isDisabled()){return false}if(this.mdvMap){this.mdvMap.hideToolTips()}if(!this.getContainer()){this.require()}if(!this.getContainer()){return false}var a=this.update();this.getContainer().setInnerHTML(this.getInnerHTML());this.setVisibility(true);this.mdvMap.events.triggerEvent(MDVEvent_TOOLTIP,"MDVMap Tool Tip...",this);return a};MDVToolTip.prototype.hide=function(){if(this.isFixed()){return false}this.setVisibility(false);if(this.mdvMap&&this.mdvMap.events){this.mdvMap.events.triggerEvent(MDVEvent_TOOLTIP,"MDVMap Tool Tip...",this)}if(this.getParent()&&this.getParent().layer&&(this.getParent().layer.name=="efa_stops"||this.getParent().layer.name=="efa_poi")){var a=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());if(this.getParent().objectId.type=="stop"&&a.get("showSTOP")&&a.get("showSTOP")=="false"){this.getParent().layer.removeMarker(this.getParent())}if(this.getParent().objectId.type=="poi"&&a.get("showPOI")&&a.get("showPOI")=="false"){this.getParent().layer.removeMarker(this.getParent())}}return this.free()};MDVToolTip.prototype.require=function(){if(this.container){this.free(this.container)}if(this.mdvMap==null){return}var a=null;if(this.getSize()){a=this.mdvMap.getToolTipManager().require(this.getType(),this.getSize())}else{a=this.mdvMap.getToolTipManager().require(this.getType())}if(a){a.setParent(this.getParent());a.setToolTip(this);a.setInnerHTML(this.getInnerHTML())}this.setContainer(a)};MDVToolTip.prototype.free=function(){if(this.container){if(this.mdvMap.getToolTipManager().free(this.container)){this.container.setParent(null);this.container.setToolTip(null);this.setContainer(null);return true}}return false};MDVToolTip.prototype.destroy=function(){if(this.container){this.hide()}this.parentMarker=null;this.mdvMap=null};MDVToolTip.prototype.isVisible=function(){if(this.container){return this.container.isVisible()}return false};MDVToolTip.prototype.setVisibility=function(a){if(this.container){return this.container.setVisibility(a)}return false};MDVToolTip.prototype.update=function(){if(this.container){return this.container.update()}};MDVToolTip.prototype.triggerDisplay=function(){var a=250;this.jobs.display=mdvTimer.add(a,this,this.display,[])};MDVToolTip.prototype.triggerHide=function(){var a=100;this.jobs.hide=mdvTimer.add(a,this,this.hide,[])};MDVToolTip.prototype.cancelDisplay=function(){if(this.jobs.display!=null){if(mdvTimer.remove(this.jobs.display)){this.jobs.display=null;return true}}return false};MDVToolTip.prototype.cancelHide=function(){if(this.jobs.hide!=null){if(mdvTimer.remove(this.jobs.hide)){this.jobs.hide=null;return true}}return false};function MDVToolTipContainer(a){this.mdvMap=a;this.id=this.mdvMap.lastContainerID++;this.div=null;this.point=null;this.append=false;this.visibility=false;this.mousePos=null;this.parentMarker=null;this.vacant=true;this.type="simple";this.init()}MDVToolTipContainer.prototype.isVacant=function(){return this.vacant};MDVToolTipContainer.prototype.setVacant=function(a){this.vacant=a};MDVToolTipContainer.prototype.setParent=function(a){this.parentMarker=a};MDVToolTipContainer.prototype.getParent=function(){return this.parentMarker};MDVToolTipContainer.prototype.setVisibility=function(a){this.visibility=a;this.div.style.visibility=a?"visible":"hidden"};MDVToolTipContainer.prototype.isVisible=function(){return this.visibility};MDVToolTipContainer.prototype.getInnerHTML=function(){return this.div.innerHTML};MDVToolTipContainer.prototype.setInnerHTML=function(a){this.div.innerHTML=a};MDVToolTipContainer.prototype.setAppend=function(a){this.append=a};MDVToolTipContainer.prototype.isAppend=function(){this.append};MDVToolTipContainer.prototype.getType=function(){return this.type};MDVToolTipContainer.prototype.update=function(){return false};MDVToolTipContainer.prototype.setToolTip=function(a){if(this.div){this.div.toolTip=a}};MDVToolTipContainer.prototype.getPosition=function(){if(this.div){var a=new MDVPoint(parseInt(this.div.style.left),parseInt(this.div.style.top));a.x+=this.mdvMap.wrapOffset.x;a.y+=this.mdvMap.wrapOffset.y;return a}return(new MDVPoint(0,0))};MDVToolTipContainer.prototype.init=function(){var a=this;this.div=document.createElement("div");this.div.style.zIndex=100;this.div.style.position="absolute";this.div.style.top="0px";this.div.style.left="0px";this.div.toolTip=null;if(!this.isAppend()){if(this.mdvMap.tooltipLayer){this.mdvMap.tooltipLayer.ownContainer.appendChild(this.div)}else{this.mdvMap.markerObjects.appendChild(this.div)}this.setAppend(true)}this.div.onmouseover=MDVToolTipContainer_cancelHide;this.div.onmousemove=MDVToolTipContainer_cancelHide;this.div.onmouseout=function(){if(!a.mdvMap.config.get("tooltipHandler")){MDVToolTipContainer_triggerHide.bind(this)()}};this.div.onmousedown=MDVToolTipContainer_onMouseDown;this.div.ondblclick=MDVToolTipContainer_onMouseDown;this.setVisibility(false);return this.div!=null};function MDVToolTipContainer_triggerHide(a){a=a?a:window.event;if(this.toolTip){this.toolTip.triggerHide()}}function MDVToolTipContainer_cancelHide(a){a=a?a:window.event;if(this.toolTip){this.toolTip.cancelHide()}}function MDVToolTipContainer_onMouseDown(a){a=a?a:window.event;if(!this.toolTip.isSlidable()){a.cancelBubble=true;a.returnValue=false;if(a.stopPropagation){a.stopPropagation()}if(a.preventDefault){a.preventDefault()}return false}return true}function MDVToolTipBubble(a,b){this.mdvMap=a;this.id=this.mdvMap.lastContainerID++;this.div=null;this.point=null;this.append=false;this.visibility=false;this.complex=new Array();this.mousePos=null;this.parentMarker=null;this.margins=null;this.vacant=true;this.innerHTML="";this.type="bubble";this.lastParent=null;this.pointerSize=new MDVPoint(63,15);this.pointerBorder=new MDVPoint(34,34);this.pointerState=3;this.innerOffset=new MDVPoint(0,this.pointerSize.y-1);this.offset=null;this.size=b;this.delta=new MDVPoint(0,0);for(var c in MDVToolTipContainer.prototype){if(!MDVToolTipBubble.prototype[c]){MDVToolTipBubble.prototype[c]=MDVToolTipContainer.prototype[c]}}this.init();this.createBubble();this.updateBubble();this.setVisibility(false)}MDVToolTipBubble.prototype.setVisibility=function(c){this.visibility=c;var a=false;var b=this.getParent();if(b&&b.toolTip&&b.toolTip.isOverflow()){a=true}if(this.complex.body&&a){this.complex.body.style.overflow=c?"auto":"hidden"}this.div.style.visibility=c?"visible":"hidden"};MDVToolTipBubble.prototype.setLastParent=function(a){this.lastParent=a};MDVToolTipBubble.prototype.getLastParent=function(){return this.lastParent};MDVToolTipBubble.prototype.getInnerHTML=function(){return this.complex.body.innerHTML};MDVToolTipBubble.prototype.setInnerHTML=function(a){this.complex.body.innerHTML=a};MDVToolTipBubble.prototype.setSize=function(a){if(this.size){switch(this.pointerState){case 0:this.delta.x=0;this.delta.y=this.size.y-a.y;break;case 1:this.delta.x=0;this.delta.y=this.size.y-a.y;break;case 2:this.delta.x=0;this.delta.y=0;break;case 3:this.delta.x=0;this.delta.y=0;break}}this.size=a};MDVToolTipBubble.prototype.getSize=function(){return this.size};MDVToolTipBubble.prototype.createBubble=function(){var a="images/";if(this.mdvMap.config.get("imagePath")){a=this.mdvMap.config.get("imagePath")}var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=0+"px";b.style.top=0+"px";b.galleryimg="no";b.unselectable="no";this.complex.upperLeftCorner=document.createElement("div");this.complex.upperLeftCorner.appendChild(b);this.div.appendChild(this.complex.upperLeftCorner);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=-30+"px";b.style.top=0+"px";b.galleryimg="no";b.unselectable="no";this.complex.upperBorder=document.createElement("div");this.complex.upperBorder.appendChild(b);this.div.appendChild(this.complex.upperBorder);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=-672+"px";b.style.top=0+"px";b.galleryimg="no";b.unselectable="no";this.complex.upperRightCorner=document.createElement("div");this.complex.upperRightCorner.appendChild(b);this.div.appendChild(this.complex.upperRightCorner);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=0+"px";b.style.top=-30+"px";b.galleryimg="no";b.unselectable="no";this.complex.leftBorderBody=document.createElement("div");this.complex.leftBorderBody.appendChild(b);this.div.appendChild(this.complex.leftBorderBody);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=-670+"px";b.style.top=-670+"px";b.galleryimg="no";b.unselectable="no";this.complex.lowerRightCorner=document.createElement("div");this.complex.lowerRightCorner.appendChild(b);this.div.appendChild(this.complex.lowerRightCorner);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=-698+"px";b.style.top=0+"px";b.galleryimg="no";b.unselectable="no";this.complex.rightBorder=document.createElement("div");this.complex.rightBorder.appendChild(b);this.div.appendChild(this.complex.rightBorder);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=0+"px";b.style.top=-670+"px";b.galleryimg="no";b.unselectable="no";this.complex.lowerLeftCorner=document.createElement("div");this.complex.lowerLeftCorner.appendChild(b);this.div.appendChild(this.complex.lowerLeftCorner);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=-30+"px";b.style.top=-670+"px";b.galleryimg="no";b.unselectable="no";this.complex.lowerBorder=document.createElement("div");this.complex.lowerBorder.appendChild(b);this.div.appendChild(this.complex.lowerBorder);this.complex.body=document.createElement("div");this.complex.body.className="MDVToolTipBubble_Body";this.div.appendChild(this.complex.body);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=this.pointerState*-64+"px";b.style.top=-704+"px";b.galleryimg="no";b.unselectable="no";this.complex.pointer=document.createElement("div");this.complex.pointer.appendChild(b);this.div.appendChild(this.complex.pointer);var b=document.createElement("img");b.src=a+"bubble.png";b.style.position="relative";b.style.left=-662+"px";b.style.top=-701+"px";b.galleryimg="no";b.unselectable="no";b.onclick=MDVToolTipBubble_OnPinClick;b.bubble=this;this.complex.pin=document.createElement("div");this.complex.pin.mdvMap=this.mdvMap;this.complex.pin.appendChild(b);this.div.appendChild(this.complex.pin)};MDVToolTipBubble.prototype.updateBubble=function(){var e=this.size;var a="images/";if(this.mdvMap.config.get("imagePath")){a=this.mdvMap.config.get("imagePath")}this.complex.upperLeftCorner.style.position="absolute";this.complex.upperLeftCorner.style.overflow="hidden";this.complex.upperLeftCorner.style.width=30+"px";this.complex.upperLeftCorner.style.height=30+"px";this.complex.upperLeftCorner.style.left=0+"px";this.complex.upperLeftCorner.style.top=(0+this.innerOffset.y)+"px";this.complex.upperBorder.style.position="absolute";this.complex.upperBorder.style.overflow="hidden";this.complex.upperBorder.style.width=(e.x-2*28)+"px";this.complex.upperBorder.style.height=30+"px";this.complex.upperBorder.style.left=30+"px";this.complex.upperBorder.style.top=(0+this.innerOffset.y)+"px";this.complex.upperRightCorner.style.position="absolute";this.complex.upperRightCorner.style.overflow="hidden";this.complex.upperRightCorner.style.width=30+"px";this.complex.upperRightCorner.style.height=30+"px";this.complex.upperRightCorner.style.left=(e.x-26)+"px";this.complex.upperRightCorner.style.top=(0+this.innerOffset.y)+"px";this.complex.leftBorderBody.style.position="absolute";this.complex.leftBorderBody.style.overflow="hidden";this.complex.leftBorderBody.style.width=e.x+"px";this.complex.leftBorderBody.style.height=(e.y-(this.pointerSize.y-1-this.innerOffset.y)-2*30)+"px";this.complex.leftBorderBody.style.left=0+"px";this.complex.leftBorderBody.style.top=(30+this.innerOffset.y)+"px";this.complex.lowerRightCorner.style.position="absolute";this.complex.lowerRightCorner.style.overflow="hidden";this.complex.lowerRightCorner.style.width=30+"px";this.complex.lowerRightCorner.style.height=30+"px";this.complex.lowerRightCorner.style.left=(e.x-28)+"px";this.complex.lowerRightCorner.style.top=(e.y-(this.pointerSize.y-1-this.innerOffset.y)-30)+"px";this.complex.rightBorder.style.position="absolute";this.complex.rightBorder.style.overflow="hidden";this.complex.rightBorder.style.width=2+"px";this.complex.rightBorder.style.height=(e.y-(this.pointerSize.y-1-this.innerOffset.y)-30)+"px";this.complex.rightBorder.style.left=(e.x)+"px";this.complex.rightBorder.style.top=(0+this.innerOffset.y)+"px";this.complex.lowerLeftCorner.style.position="absolute";this.complex.lowerLeftCorner.style.overflow="hidden";this.complex.lowerLeftCorner.style.width=30+"px";this.complex.lowerLeftCorner.style.height=30+"px";this.complex.lowerLeftCorner.style.left=0+"px";this.complex.lowerLeftCorner.style.top=(e.y-(this.pointerSize.y-1-this.innerOffset.y)-30)+"px";this.complex.lowerBorder.style.position="absolute";this.complex.lowerBorder.style.overflow="hidden";this.complex.lowerBorder.style.width=(e.x-2*28)+"px";this.complex.lowerBorder.style.height=30+"px";this.complex.lowerBorder.style.left=30+"px";this.complex.lowerBorder.style.top=(e.y-(this.pointerSize.y-1-this.innerOffset.y)-30)+"px";var d=0;if(this.getParent()&&this.getParent().toolTip&&this.getParent().toolTip.hasPin()){d=-18}this.complex.body.style.position="absolute";this.complex.body.style.width=(e.x-30+d)+"px";this.complex.body.style.height=(e.y-35)+"px";this.complex.body.style.left=15+"px";this.complex.body.style.top=(10+this.innerOffset.y)+"px";this.innerOffset.y>=this.pointerSize.y-1;var b=this.innerOffset.y>=this.pointerSize.y-1?0:this.size.y-this.pointerSize.y;this.complex.pointer.style.position="absolute";this.complex.pointer.style.overflow="hidden";this.complex.pointer.style.width=this.pointerSize.x+"px";this.complex.pointer.style.height=this.pointerSize.y+"px";this.complex.pointer.style.left=this.pointerBorder.x+"px";this.complex.pointer.style.top=b+"px";if(this.complex.pointer.firstChild){this.complex.pointer.firstChild.style.left=this.pointerState*-64+"px"}var c=(this.getParent()&&this.getParent().toolTip&&this.getParent().toolTip.hasPin());if(this.complex.pin.firstChild){this.complex.pin.firstChild.src=c?(a+"bubble.png"):this.mdvMap.transparent.src;this.complex.pin.firstChild.onclick=c?MDVToolTipBubble_OnPinClick:null;this.complex.pin.firstChild.style.top=-701+"px"}this.complex.pin.style.position="absolute";this.complex.pin.style.overflow="hidden";this.complex.pin.style.width="19px";this.complex.pin.style.height="18px";this.complex.pin.style.left=(e.x-29)+"px";this.complex.pin.style.top=(10+this.innerOffset.y)+"px"};MDVToolTipBubble.prototype.update=function(){var l=this.mdvMap.getPoint(this.getParent().getCoords());if(!l){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to get px coordinates for marker.");return false}var k=this.getParent();var d=new MDVPoint(0,0);var e=0;var j=0;if(k&&k.img){d.x=k.img.width*k.getXFactor();d.y=k.img.height*k.getYFactor();e=k.img.width;j=k.img.height}if(k.img&&(this.margins==null||(this.getLastParent()&&this.getLastParent().id!=this.getParent().id))){var a=new MDVPoint(parseInt(this.div.style.left),parseInt(this.div.style.top));if(this.margins){this.div.style.left=(a.x-this.margins.x)+"px";this.div.style.top=(a.y-this.margins.y)+"px"}switch(this.pointerState){case 0:this.margins=new MDVPoint(e-d.x,0-d.y);break;case 1:this.margins=new MDVPoint(0-d.x,0-d.y);break;case 2:this.margins=new MDVPoint(0-d.x,j-d.y);break;case 3:this.margins=new MDVPoint(e-d.x,j-d.y);break}this.setLastParent(this.getParent())}else{if(k.img==null){this.margins=null;this.setLastParent(null)}}var h=this.mdvMap.getViewportExtends();if(!this.offset){this.offset=new MDVPoint(0+this.delta.x-this.pointerBorder.x,0)}else{this.offset.x+=this.delta.x;this.offset.y+=this.delta.y}this.delta.x=0;this.delta.y=0;var g=this.margins?this.margins.x:0;var c=this.margins?this.margins.y:0;this.div.style.left=(l.x+this.offset.x+g)+"px";this.div.style.top=(l.y+this.offset.y+c)+"px";var i=new MDVPoint(parseInt(this.div.style.left)+parseInt(this.mdvMap.mapper.style.left),parseInt(this.div.style.top)+parseInt(this.mdvMap.mapper.style.top));var f=false;var b={upper:true,lower:false,left:true,right:false};if(i.y<=0){this.innerOffset.y=this.pointerSize.y-1;this.offset.y=0;if(this.margins){this.margins.y=(j-d.y)}b.upper=true;f=true}else{b.upper=false}if(i.y+this.size.y+2*2>=h.height){this.innerOffset.y=0;this.offset.y=this.size.y*-1;if(this.margins){this.margins.y=0-d.y}b.lower=true;f=true}else{b.lower=false}if(i.x<0){this.pointerBorder.x=34;this.offset.x=0-34;if(this.margins){this.margins.x=e-d.x}b.left=true;f=true}else{b.left=false}if(i.x+this.size.x+2*2+d.x>h.width){this.offset.x=this.size.x*-1+34;this.pointerBorder.x=this.size.x-this.pointerSize.x-34;if(this.margins){this.margins.x=0-d.x}b.right=true;f=true}else{b.right=false}if(f){var g=this.margins?this.margins.x:0;var c=this.margins?this.margins.y:0;this.div.style.left=(l.x+this.offset.x+g)+"px";this.div.style.top=(l.y+this.offset.y+c)+"px"}this.pointerState=this.wrapPointer(b);this.updateBubble();return true};MDVToolTipBubble.prototype.wrapPointer=function(a){var b=this.pointerState;switch(this.pointerState){case 0:if(a.upper&&a.right){b=2}else{if(a.right){b=1}else{if(a.upper){b=3}}}break;case 1:if(a.upper&&a.left){b=3}else{if(a.left){b=0}else{if(a.upper){b=2}}}break;case 2:if(a.lower&&a.left){b=0}else{if(a.left){b=3}else{if(a.lower){b=1}}}break;case 3:if(a.lower&&a.right){b=1}else{if(a.right){b=2}else{if(a.lower){b=0}}}break}return b};function MDVToolTipBubble_OnPinClick(b){if(this.bubble&&this.bubble.getParent()&&this.bubble.getParent().toolTip){var a=this.bubble.getParent().toolTip.isFixed();this.bubble.complex.pin.firstChild.style.left=(a?-662:-681)+"px";this.bubble.getParent().toolTip.setFixed(!a)}}function MDVToolTipSimple(a){this.mdvMap=a;this.id=this.mdvMap.lastContainerID++;this.div=null;this.point=null;this.append=false;this.visibility=false;this.mousePos=null;this.parentMarker=null;this.vacant=true;this.type="simple";for(var b in MDVToolTipContainer.prototype){if(!MDVToolTipSimple.prototype[b]){MDVToolTipSimple.prototype[b]=MDVToolTipContainer.prototype[b]}}this.init();this.div.className="MDVToolTip"}MDVToolTipSimple.prototype.update=function(){var i=this.mdvMap.getPoint(this.getParent().getCoords());var f=4;if(!i){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to get px coordinates for marker.");return false}var h=this.getParent();var j=0;var b=0;var g=0;if(h.img){j=h.img.width*h.getXFactor();b=h.img.width;g=h.img.height}this.div.style.position="absolute";this.div.style.left=(i.x+j+f)+"px";this.div.style.top=(i.y+f)+"px";var a=this.mdvMap.getObjWidth(this.div);var k=this.mdvMap.getObjHeight(this.div);var d=new MDVPoint(parseInt(this.mdvMap.mapper.style.left),parseInt(this.mdvMap.mapper.style.top));if(i.x+d.x+a+j+f>(this.mdvMap.viewportWidth-2)){this.div.style.left=(i.x-a-b+j-f)+"px";if(i.x-a-b+j-(f*2)+d.x<=0){var e=i.x-a-b+j-(f*2)+d.x;this.div.style.left=parseInt(this.div.style.left)-e+"px"}}if(i.y+d.y+k+f>(this.mdvMap.viewportHeight-2)){var c=(i.y-k-g-(f*2)+d.y);if(c>0){c=0}this.div.style.top=(i.y-k-g-f-c)+"px"}return true};function MDVToolTipManager(a){this.mdvMap=a;this.growBy=1;this.containers=new Array()}MDVToolTipManager.prototype.require=function(d){var c=null;if(arguments.length==2){c=arguments[1]}if(this.containers[d]==null){this.containers[d]=new Array()}for(var b=0;b<this.containers[d].length;b++){if(this.containers[d][b].isVacant()){var e=this.containers[d][b];e.setVacant(false);if(c&&e.setSize){e.setSize(c)}return e}}var a=null;for(var b=0;b<this.growBy;b++){switch(d){case"bubble":var e=new MDVToolTipBubble(this.mdvMap,c);this.containers[d].push(e);if(!a){a=e;a.setVacant(false)}break;default:var e=new MDVToolTipSimple(this.mdvMap);this.containers[d].push(e);if(!a){a=e;a.setVacant(false)}break}}return a};MDVToolTipManager.prototype.free=function(a){var c=a.getType();if(!this.containers[c]){return false}for(var b=0;b<this.containers[c].length;b++){if(this.containers[c][b].id==a.id){this.containers[c][b].setVacant(true);return true}}return false};function MDVToolTipConsumer(){this.toolTip=null;this.coords=null}MDVToolTipConsumer.prototype.getCoords=function(){return this.coords};MDVToolTipConsumer.prototype.hide=function(){if(this.getToolTip()){this.getToolTip().hide()}};MDVToolTipConsumer.prototype.setCoords=function(a){this.coords=this.toolTip.mdvMap.getInternalCoordinates(a)};MDVToolTipConsumer.prototype.getToolTip=function(){return this.toolTip};MDVToolTipConsumer.prototype.setToolTip=function(a){this.toolTip=a;this.toolTip.setParent(this);this.toolTip.setCoords(this.coords)};function MDVClusterLayer(a,c,b){if(!a||c==""){return}this.mdvMap=a;this.gridSize=60;this.layer=this.mdvMap.createLayer(c);this.mdvMap.addLayer(this.layer);this.zl=this.mdvMap.config.getZoomLevelIndex();this.clusters=[];this.markers=[];this.clusterIcon=null;this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.update);if(b!=null){if(b.getClusterIcon!=null){this.getClusterIcon=b.getClusterIcon}if(b.gridSize!=null){this.gridSize=b.gridSize}}}MDVClusterLayer.prototype.addMarker=function(a){var b=true;if(arguments.length==2){b=arguments[1]}this.markers.push(a)};MDVClusterLayer.prototype.getClusters=function(){if(this.zl!=this.mdvMap.config.getZoomLevelIndex()){this.clear()}for(var b=0;b<this.markers.length;b++){var a=this.markers[b];if(a.getCoords()==null){continue}if(!this.mdvMap.inBounds(a.getCoords(),1.4)){continue}this.checkClusters(a)}this.zl=this.mdvMap.config.getZoomLevelIndex();return this.clusters};MDVClusterLayer.prototype.clear=function(){for(var e=0;e<this.clusters.length;e++){var b=this.clusters[e];if(b.counter){this.layer.removeMarker(b.counter);b.counter.clustered=false}for(var d=0;d<b.markers.length;d++){var a=b.markers[d];if(a.append){this.layer.removeMarker(a)}a.clustered=false}}this.clusters=[];this.layer.removeAllMarkers()};MDVClusterLayer.prototype.checkClusters=function(d){var b=this.mdvMap.getPoint(d.getCoords());for(var g=0;g<this.clusters.length;g++){var j=this.clusters[g];var f=this.mdvMap.getPoint(j.getCentre());var e=this.gridSize;if(b.x>=f.x-e&&b.x<=f.x+e&&b.y>=f.y-e&&b.y<=f.y+e){if(d.clustered==null||!d.clustered){j.addMarker(d)}return true}}var a=this.mdvMap;var i={mdvMap:a,markers:[],getCentre:function(){return this.markers.length>0?this.markers[0].getCoords():null},addMarker:function(c){if(c.clustered==null||!c.clustered){this.markers.push(c);c.clustered=true}},getMarkers:function(){return this.markers.length>1?[this.counter]:this.markers}};i.addMarker(d);var h=this.getClusterIcon(i);i.counter=i.mdvMap.createMarker(i.markers[0].getCoords().clone(),h.factor,h.src);i.counter.img.onclick=function(c){i.markers.beautify()};i.markers.beautify=function(){var q={x:[],y:[]};for(var l=0;l<this.length;l++){q.x.push(this[l].getCoords().x);q.y.push(this[l].getCoords().y)}q.x.sort();q.y.sort();var n=a.getCentre().clone();n.x=q.x[0]+Math.floor(0.5+(q.x[q.x.length-1]-q.x[0])/2);n.y=q.y[0]+Math.floor(0.5+(q.y[q.y.length-1]-q.y[0])/2);var t=a.config.getZoomLevels();var k=0;var u=new MDVPoint(0,0);var o=new MDVPoint(q.x[q.x.length-1]-q.x[0],q.y[q.y.length-1]-q.y[0]);for(var p=t.length-1;p>=0;p--){var s=t[p];var r=a.getViewportExtends();r.width/=parseInt(s.get("tileSizeX"));r.height/=parseInt(s.get("tileSizeY"));var m=new MDVPoint(0,0);m.x=parseInt(s.get("realWidth"))/parseInt(s.get("numberOfTilesX"))*r.width;m.y=parseInt(s.get("realHeight"))/parseInt(s.get("numberOfTilesY"))*r.height;if(o.x<m.x){k=p;u.x=true}if(o.y<m.y){k=p;u.y=true}if(u.x&&u.y){break}}a.setCentre(n);a.setZoomLevel(k);a.update()};this.clusters.push(i);return false};MDVClusterLayer.prototype.update=function(i,g,f){this.getClusters();for(var h=0;h<this.clusters.length;h++){var b=this.clusters[h];var e=b.getMarkers();for(var a=0;a<e.length;a++){var d=e[a];this.layer.addMarker(d,h+1==this.clusters.length)}}};MDVClusterLayer.prototype.getClusterIcon=function(a){if(this.clusterIcon==null){if(this.markers.length>0){this.clusterIcon={src:this.markers[0].imgSrc,factor:new MDVPoint(this.markers[0].xFactor,this.markers[0].yFactor)}}else{this.clusterIcon={src:"",factor:new MDVPoint(0.5,0.5)}}}return this.clusterIcon};function MDVLayer(a,b){if(!a||b==""){return}this.name=b;this.mdvMap=a;this.zIndex=0;this.id=a.lastLayerID++;this.visible=true;this.append=false;this.markers=new Array();this.polylines=new Array();this.options=arguments[2]||null;if(this.options&&this.options.useOwnContainer){this.createOwnContainer()}}MDVLayer.prototype.getPolylineCoords=function(){var a=new Array();for(var b=0;b<this.polylines.length;b++){if(this.polylines[b]==null){continue}for(var d=0;d<this.polylines[b].coords.length;d++){a.push(this.polylines[b].coords[d])}}return a};MDVLayer.prototype.getName=function(){return this.name};MDVLayer.prototype.destroy=function(){var b=this.polylines.length;for(var c=0;c<b;c++){var a=this.polylines.pop();if(a){a.destroy()}}this.mdvMap=null;this.layer=null;this.renderer=null};MDVLayer.prototype.addPolyline=function(a){if(!a){return false}var c=true;for(var b=0;b<this.polylines.length;b++){if(this.polylines[b]&&this.polylines[b].id==a.id){return false}}if(arguments.length==2){c=arguments[1]}a.layer=this;this.polylines.push(a);if(c){this.update()}return true};MDVLayer.prototype.removePolyline=function(a){if(!a){return false}for(var b=0;b<this.polylines.length;b++){if(this.polylines[b]&&this.polylines[b].id==a.id){if(this.mdvMap.renderer.removePolyline(this.polylines[b])){this.polylines.splice(b,1)}return true}}return false};MDVLayer.prototype.hideToolTips=function(){var b=false;for(var a=0;a<this.markers.length;a++){if(this.markers[a].toolTip){mdvTimer.remove(this.markers[a].toolTip.job);if(this.markers[a].toolTip.isVisible()){this.markers[a].toolTip.hide();b=true}}}for(var c=0;c<this.polylines.length;c++){if(this.polylines[c]&&this.polylines[c].toolTip){mdvTimer.remove(this.polylines[c].toolTip.job);if(this.polylines[c].toolTip.isVisible()){this.polylines[c].toolTip.hide()}b=true}}return b};MDVLayer.prototype.setVisibility=function(b){if(this.visible!=b){this.visible=b;for(var a=0;a<this.markers.length;a++){this.markers[a].setVisibility(this.visible)}}};MDVLayer.prototype.update=function(){for(var a=0;a<this.markers.length;a++){if(this.name!="efa_trip"){this.markers[a].setVisibility(this.visible)}this.markers[a].update()}if(this.mdvMap.renderer){this.mdvMap.renderer.update()}for(var b=0;b<this.polylines.length;b++){if(this.polylines[b]&&this.polylines[b].append){this.mdvMap.renderer.removePolyline(this.polylines[b])}this.mdvMap.renderer.drawPolyline(this.polylines[b])}this.mdvMap.events.triggerEvent(MDVEvent_LAYER_UPDATED,"MDVMap has updated layer ("+this.name+")",this)};MDVLayer.prototype.addMarker=function(b){var c=true;for(var a=0;a<this.markers.length;a++){if(this.markers[a].id==b.id){return false}}if(arguments.length==2){c=arguments[1]}b.layer=this;this.markers.push(b);b.img.src=b.imgSrc;return true};MDVLayer.prototype.removeMarker=function(c){if(c==null){return false}var e=new Array();var f=false;var b=this.markers.length;for(var a=0;a<b;a++){var d=this.markers.shift();if(d.id==c.id&&c.append&&(c.img.parentElement||c.img.parentNode)){if(this.ownContainer){this.ownContainer.removeChild(d.img)}else{this.mdvMap.markerObjects.removeChild(d.img)}d.append=false;f=true;break}e.push(d)}this.markers=e.concat(this.markers);return f};MDVLayer.prototype.getMarkers=function(){return this.markers};MDVLayer.prototype.getPolylines=function(){return this.polylines};MDVLayer.prototype.removeAll=function(){var b=this.removeAllMarkers();var a=this.removeAllPolylines();if(this.ownContainer){this.removeAllChildren()}return b&&a};MDVLayer.prototype.removeAllPolylines=function(){var b=null;var a=false;while(b=this.polylines.pop()){if(this.mdvMap.renderer.removePolyline(b)){a=true}}return a};MDVLayer.prototype.removeAllMarkers=function(){var b=this.markers.length;var d=new Array();for(var a=0;a<b;a++){var c=this.markers.pop();if(c.toolTip&&c.toolTip.isVisible()&&c.toolTip.isFixed()){d.push(c);continue}if(c.append){if(this.ownContainer){this.ownContainer.removeChild(c.img)}else{this.mdvMap.markerObjects.removeChild(c.img)}c.append=false}c.destroy()}this.markers=d;return true};MDVLayer.prototype.setZIndex=function(a){this.zIndex=a*this.id};MDVLayer.prototype.createOwnContainer=function(){var a;a=document.createElement("div");a.id=this.mdvMap.getName()+"_ownContainer_"+this.name;a.mdvMap=this.mdvMap;a.layer=this;this.control=null;if(this.options.switchRef!==undefined&&this.options.switchRef.checked!==undefined){this.control=this.options.switchRef}this.minLevel=this.options.minLevel||0;mdvLib.style([a],{position:"absolute",display:"block"});this.ownContainer=a;this.mdvMap.getMapper().appendChild(a)};MDVLayer.prototype.appendHtmlElem=function(a){if(!this.ownContainer){return null}return this.ownContainer.appendChild(a)};MDVLayer.prototype.removeAllChildren=function(){while(this.ownContainer.hasChildNodes()){this.ownContainer.removeChild(this.ownContainer.firstChild)}};function MDVTimer(){this.jobs=new Array()}MDVTimer.prototype.add=function(d,e,c,a){var g=this.jobs.length;for(var b=0;b<this.jobs.length;b++){if(this.jobs[b]==null){g=b;break}}var f=window.setTimeout("MDVTimer_execute("+g+")",d);this.jobs[g]=new MDVTimerJob(f,e,c,a);return g};MDVTimer.prototype.remove=function(a){if(this.jobs[a]!=null){window.clearTimeout(this.jobs[a].id);this.jobs[a]=null;return true}return false};var mdvTimer=new MDVTimer();function MDVTimerJob(d,c,b,a){this.id=d;this.target=c;this.func=b;this.arg=a}function MDVTimer_execute(c){if(mdvTimer.jobs[c]!=null){var b=mdvTimer.jobs[c].target;var a=mdvTimer.jobs[c].func;if(mdvTimer.jobs[c].arg!=null&&b!=null){a.apply(b,mdvTimer.jobs[c].arg)}else{a.apply(b)}mdvTimer.jobs[c]=null}}function MDVRenderer(a,b){this.mdvMap=a;this.container=b;this.max=null;this.min=null;this.border=10;this.offset=new MDVPoint(0,0);this.boundingBox=null}MDVRenderer.prototype.drawPolyline=function(a){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap: Not implemented.");return false};MDVRenderer.prototype.removePolyline=function(a){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap: Not implemented.");return false};MDVRenderer.prototype.setBoundingBox=function(){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap: Not implemented.");return false};MDVRenderer.prototype.update=function(){var c=this.mdvMap.getPolylinePoints();if(c.length!=2||c[0].length<=0||c[1].length<=0){return false}var a=c[0];var e=c[1];a.sort(MDVMap_NumSort);e.sort(MDVMap_NumSort);this.max=new MDVPoint(a[a.length-1],e[e.length-1]);this.min=new MDVPoint(a[0],e[0]);var d=this.max.clone();var b=this.min.clone();d.x+=this.getBorder();d.y+=this.getBorder();b.x-=this.getBorder();b.y-=this.getBorder();this.boundingBox=[b.clone(),d.clone()];this.setBoundingBox();return true};MDVRenderer.prototype.getBorder=function(){return this.border};function MDVVMLRenderer(a,b){this.mdvMap=a;this.container=b;this.max=null;this.min=null;this.border=50;this.offset=new MDVPoint(0,0);this.boundingBox=null;this.group=null;document.namespaces.add("v","urn:schemas-microsoft-com:vml");var c=document.createStyleSheet();c.addRule("v\\: *","behavior: url(#default#VML);");c.addRule("v\\:shape","behavior: url(#default#VML);");c.addRule("v\\:stroke","behavior: url(#default#VML);");this.group=document.createElement("v:group");this.container.appendChild(this.group);for(var d in MDVRenderer.prototype){if(!MDVVMLRenderer.prototype[d]){MDVVMLRenderer.prototype[d]=MDVRenderer.prototype[d]}}}MDVVMLRenderer.prototype.drawPolyline=function(l){if(!l){return false}var q="m";var k=l.getAllCoords();for(var d=0;d<k.length;d++){var n=this.mdvMap.getPoint(k[d]);var m=n.x-this.offset.x;var j=n.y-this.offset.y;q+=m+","+j;if(d<k.length-1){q+=" "}if(d==0){q+="l"}}q+=" e";var b=this.boundingBox[1].x-this.boundingBox[0].x;var o=this.boundingBox[1].y-this.boundingBox[0].y;var c=this.boundingBox[0].x;var h=this.boundingBox[0].y;var a=l.get("colour");if(!a){a="red"}var e=l.get("weight");if(!e){e="4px"}var f=l.get("opacity");if(!f){f="0.5"}if(!l.append){var g=document.createElement("v:shape");g.style.position="relative";g.style.top="0px";g.style.left="0px";g.style.width=b;g.style.height=o;g.setAttribute("filled","false");g.setAttribute("stroked","true");g.setAttribute("strokecolor",a);g.setAttribute("strokeweight",e);g.setAttribute("path",q);var p=document.createElement("v:stroke");p.setAttribute("opacity",f);p.setAttribute("joinstyle","round");p.setAttribute("endcap","round");g.appendChild(p);this.group.appendChild(g);g.parentPolyline=l;l.element=g;l.element.mdvMap=this.mdvMap;l.append=true}else{if(l.element.path.value!=q){l.element.path.value=q}}if(l.toolTip){l.setToolTip(l.toolTip)}return true};MDVVMLRenderer.prototype.removePolyline=function(a){if(!a||!a.append||a.element==null){return false}this.group.removeChild(a.element);a.element.onmousedown=null;a.element.onmousemove=null;a.element.onmouseout=null;a.element.onmouseover=null;a.element.onmouseup=null;if(a.element.toolTip){a.element.toolTip=null}if(a.element.mdvMap){a.element.mdvMap=null}a.element=null;a.append=false;return true};MDVVMLRenderer.prototype.setBoundingBox=function(){var b=this.boundingBox[1].x-this.boundingBox[0].x;var a=this.boundingBox[1].y-this.boundingBox[0].y;var d=this.boundingBox[0].x;var c=this.boundingBox[0].y;this.offset=new MDVPoint(d,c);this.group.style.behavior="url(#default#VML)";this.group.style.width=b+"px";this.group.style.height=a+"px";this.group.style.position="absolute";this.group.style.left=d+"px";this.group.style.top=c+"px";this.group.setAttribute("coordsize",b+","+a);this.group.coordsize.value=b+","+a;return true};function MDVSVGRenderer(a,b){this.mdvMap=a;this.container=b;this.max=null;this.min=null;this.border=10;this.offset=new MDVPoint(0,0);this.boundingBox=null;this.svgNS="http://www.w3.org/2000/svg";this.svg=document.createElementNS(this.svgNS,"svg");this.svg.setAttributeNS(null,"overflow","visible");this.container.appendChild(this.svg);for(var c in MDVRenderer.prototype){if(!MDVSVGRenderer.prototype[c]){MDVSVGRenderer.prototype[c]=MDVRenderer.prototype[c]}}}MDVSVGRenderer.prototype.drawPolyline=function(g){if(!g){return false}var l="M";var f=g.getAllCoords();for(var b=0;b<f.length;b++){var j=this.mdvMap.getPoint(f[b]);var h=j.x-this.offset.x;var e=j.y-this.offset.y;l+=h+","+e;if(b<f.length-1){l+=" "}if(b==0){l+="L"}}if(!g.append){var a=g.get("colour");if(!a){a="red"}var c=g.get("weight");if(!c){c="4px"}var d=g.get("opacity");if(!d){d="0.50"}var k=document.createElementNS(this.svgNS,"path");k.setAttributeNS(null,"d",l);k.setAttributeNS(null,"stroke-linejoin","round");k.setAttributeNS(null,"stroke-linecap","round");k.setAttributeNS(null,"stroke-opacity",d);k.setAttributeNS(null,"stroke-width",c);k.setAttributeNS(null,"stroke",a);k.setAttributeNS(null,"fill","none");this.svg.appendChild(k);k.parentPolyline=g;g.element=k;g.element.mdvMap=this.mdvMap;g.append=true}else{if(g.element){g.element.setAttributeNS(null,"d",l)}}if(g.toolTip){g.setToolTip(g.toolTip)}return true};MDVSVGRenderer.prototype.removePolyline=function(a){if(!a||!a.append||a.element==null){return false}this.svg.removeChild(a.element);a.element.onmousedown=null;a.element.onmousemove=null;a.element.onmouseout=null;a.element.onmouseover=null;a.element.onmouseup=null;if(a.element.toolTip){a.element.toolTip=null}if(a.element.mdvMap){a.element.mdvMap=null}a.element=null;a.append=false;return true};MDVSVGRenderer.prototype.setBoundingBox=function(){var b=this.boundingBox[1].x-this.boundingBox[0].x;var a=this.boundingBox[1].y-this.boundingBox[0].y;var d=this.boundingBox[0].x;var c=this.boundingBox[0].y;this.offset=new MDVPoint(d,c);this.svg.setAttributeNS(null,"width",b+"px");this.svg.setAttributeNS(null,"height",a+"px");this.svg.setAttributeNS(null,"style","position: absolute; left: "+d+"px; top: "+c+"px;");return true};function MDVCanvasRenderer(a,b){this.mdvMap=a;this.container=b;this.max=null;this.min=null;this.border=10;this.offset=new MDVPoint(0,0);this.boundingBox=null;this.widh=null;this.height=null;this.top=null;this.left=null;this.addSpace=300;this.clipping=false;this.centreOld=null;this.stepX=0;this.stepY=0;this.removeCanvas=true;if(this.mdvMap.config.get("canvasAddSpace")){this.addSpace=this.mdvMap.config.get("canvasAddSpace")}for(var c in MDVRenderer.prototype){if(!MDVCanvasRenderer.prototype[c]){MDVCanvasRenderer.prototype[c]=MDVRenderer.prototype[c]}}this.canvas=document.getElementById("canvas");this.ctx=this.canvas.getContext("2d");this.mdvMap.events.registerEvent(MDVEvent_MOUSE_UP,null,function(){this.removeCanvas=true;if(!this.centreOld){this.centreOld=this.mdvMap.getCentre().clone()}var d;for(var e=0;e<this.mdvMap.layers.length;e++){if(this.mdvMap.layers[e].name==="efa_trip"&&this.mdvMap.layers[e].polylines.length>0){d=this.mdvMap.layers[e].polylines}}if(d){this.setBoundingBox();for(var f=0;f<d.length;f++){if(d[f]&&d[f].append){this.mdvMap.renderer.removePolyline(d[f])}this.mdvMap.renderer.drawPolyline(d[f])}this.centreOld=this.mdvMap.getCentre().clone()}return true}.bind(this));this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,null,function(){this.removeCanvas=true;this.stepX=0;this.stepY=0;return true}.bind(this))}MDVCanvasRenderer.prototype.drawPolyline=function(j){var b,h,a,l,e,k,d,g,f;if(!j){return false}if(!j.append){if(this.container.innerHTML.indexOf("canvas")=="-1"){this.canvas.attributes.width.nodeValue=this.width;this.canvas.attributes.height.nodeValue=this.height;this.canvas.style.zIndex="1";this.canvas.style.position="absolute";this.canvas.style.left=this.left+"px";this.canvas.style.top=this.top+"px";this.container.appendChild(this.canvas)}a=j.get("colour");if(!a){a="red"}d=j.get("weight");if(!d){d="4"}e=j.get("opacity");if(!e){e="0.50"}this.ctx.strokeStyle=a;this.ctx.lineWidth=d;this.ctx.globalAlpha=e;this.ctx.lineJoin="round";this.ctx.lineCap="round";this.ctx.beginPath();h=j.getAllCoords();for(var c=0;c<h.length;c++){k=this.mdvMap.getPoint(h[c]);g=k.x-this.offset.x;f=k.y-this.offset.y;if(d%2==1){g+=0.5;f+=0.5}if(c==0){this.ctx.moveTo(g,f)}else{this.ctx.lineTo(g,f)}}this.ctx.stroke();this.ctx.closePath();j.element=this.canvas;j.append=true}return true};MDVCanvasRenderer.prototype.removePolyline=function(a){if(!a||!a.append||a.element==null){return false}if(this.removeCanvas==false){a.append=false;return true}this.container.removeChild(document.getElementById("canvas"));a.element.onmousedown=null;a.element.onmousemove=null;a.element.onmouseout=null;a.element.onmouseover=null;a.element.onmouseup=null;a.element=null;a.append=false;this.removeCanvas=false;return true};MDVCanvasRenderer.prototype.setBoundingBox=function(){if(!this.centreOld){this.centreOld=this.mdvMap.getCentre()}var b=this.mdvMap.getCentre();var e=(this.boundingBox[1].x-this.boundingBox[0].x)>(this.mdvMap.viewportWidth+2*this.addSpace)?true:false;var a=(this.boundingBox[1].y-this.boundingBox[0].y)>(this.mdvMap.viewportHeight+2*this.addSpace)?true:false;var c=this.mdvMap.config.currentZoomLevelIndex;var d=(this.mdvMap.config.zoomLevels[c].params.tileSizeX*100)/(this.mdvMap.config.zoomLevels[c].params.realWidth/this.mdvMap.config.zoomLevels[c].params.numberOfTilesX);this.stepX+=((parseInt(this.centreOld.x)-parseInt(b.x))*d)/100;this.stepY+=((parseInt(this.centreOld.y)-parseInt(b.y))*d)/100;if(e||a){this.clipping=true}else{this.clipping=false}this.width=e?Math.ceil(this.mdvMap.viewportWidth+2*this.addSpace):(this.boundingBox[1].x-this.boundingBox[0].x);this.height=a?Math.ceil(this.mdvMap.viewportHeight+2*this.addSpace):(this.boundingBox[1].y-this.boundingBox[0].y);this.left=e?Math.ceil(-1*this.addSpace-this.stepX):this.boundingBox[0].x;this.top=a?Math.ceil(-1*this.addSpace-this.stepY):this.boundingBox[0].y;this.offset=new MDVPoint(this.left,this.top);return true};function MDVPolyline(a,c){if(!a){return}this.mdvMap=a;this.id=a.lastPolylineID++;this.coords=null;this.toolTip=null;this.attributes=new Array();this.element=null;this.renderer=this.mdvMap.renderer;this.layer=null;this.append=false;this.markers=new Array();this.mouse=null;this.arrows=new Array();this.directions=new Array();this.options=[];if(typeof c=="string"){this.coords=this.parseString(c)}else{if(typeof c=="object"){this.coords=c}}if(arguments.length==3){for(var b in arguments[2]){this.options[b]=arguments[2][b]}}}MDVPolyline.prototype.setMouse=function(a){this.mouse=a};MDVPolyline.prototype.destroy=function(){this.mdvMap=null;this.coords=null;if(this.toolTip){this.toolTip.destroy()}this.coords=null;this.mdvMap=null;if(this.element){if(this.element.mdvMap){this.element.mdvMap=null}this.element.onmouseover=null;this.element.onmouseout=null;this.element.onclick=null;this.element=null}};MDVPolyline.prototype.parseString=function(d){var c=d.split(" ");var f=new Array();for(var a=0;a<c.length;a++){var b=c[a].split(",");if(b[0]&&b[1]){var e=new MDVCoordinates(this.mdvMap.config.get("mapName"),b[0],b[1]);f.push(e)}}return f};MDVPolyline.prototype.add=function(b,c){for(var a=0;a<this.attributes.length;a++){if(this.attributes[a].key==b){return false}}this.attributes[b]=c;return true};MDVPolyline.prototype.get=function(a){if(this.attributes[a]){return this.attributes[a]}else{return false}};MDVPolyline.prototype.getAllCoords=function(){if(this.options.reductionList==null||this.coords.length===2){return this.coords}var a=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var e=parseInt(a.getScale());var c=null;for(var b=0;b<this.options.reductionList.length;b++){c=this.options.reductionList[b];if(c.maxScale>=e){break}}var d=[];for(var b=0;b<c.mask.length;b++){d.push(this.coords[parseInt(c.mask[b])])}return d};MDVPolyline.prototype.getCoords=function(){if(this.mouse){return this.mouse}var b=new Array();b.x=new Array();b.y=new Array();var d=this.getAllCoords();for(var a=0;a<d.length;a++){b.x.push(d[a].x);b.y.push(d[a].y)}b.x.sort(MDVMap_NumSort);b.y.sort(MDVMap_NumSort);return new MDVCoordinates(d[0].mapName,Math.floor(0.5+(b.x[b.x.length-1]+b.x[0])/2),Math.floor(0.5+(b.y[b.y.length-1]+b.y[0])/2))};MDVPolyline.prototype.setToolTip=function(b){if(!b){return false}var c=true;if(arguments.length==2){c=arguments[1]}var a=this.coords[0].clone();a.x=Math.floor(0.5+(parseInt(a.x)+parseInt(this.coords[this.coords.length-1].x))/2);a.y=Math.floor(0.5+(parseInt(a.y)+parseInt(this.coords[this.coords.length-1].y))/2);this.toolTip=b;this.toolTip.setParent(this);this.toolTip.setCoords(a);if(c){this.toolTip.update()}if(this.element){this.element.toolTip=b;this.mdvMap.assignTooltipHandler(this.element)}return true};MDVPolyline.prototype.getDirection=function(i,h){var k=h.x-i.x;var j=h.y-i.y;var f=Math.atan2(j,k);var d=f*180/Math.PI;var n=d;if(d<0){d=360+d}d=Math.floor(0.5+d);d+=90;while(d>=120){d-=120}var g="";switch(d%3){case 0:g=d+".png";break;case 1:g=(d-1)+".png";break;case 2:if(d+1==120){d=-1}g=(d+1)+".png";break}var c="FF0000";if(this.attributes.colour&&this.attributes.colour.indexOf("#")>-1){c=this.attributes.colour.substring(this.attributes.colour.indexOf("#")+1)}var l="images/";if(this.mdvMap.config.get("imagePath")){l=this.mdvMap.config.get("imagePath")}var e=this.mdvMap.createMarker(i,new MDVPoint(0.5,0.5),l+"dir/"+c+"/"+g);return e};MDVPolyline.prototype.getDirections=function(){var e=this.getAllCoords();var k=20;var l=new Array();var a=0;var j=0;if(this.mdvMap.config.get("trips.polyline.arrows.max")){k=parseInt(this.mdvMap.config.get("trips.polyline.arrows.max"))}var d=this.mdvMap.config.getZoomLevel(this.mdvMap.config.currentZoomLevelIndex);var i=parseInt(d.get("tileSizeX"))*parseInt(d.get("numberOfTilesX"));var f=i/parseInt(d.get("realWidth"));while(a<=0&&j<3){for(var h=0;h<e.length-1;h++){if(!e[h]||!e[h+1]){return null}var b=new MDVPoint(e[h+1].x-e[h].x,e[h+1].y-e[h].y);var g=Math.sqrt(Math.pow(b.x,2)+Math.pow(b.y,2));g*=f;if(g>k){l.push(this.getDirection(new MDVCoordinates(e[h].mapName,e[h].x+b.x/2,e[h].y+b.y/2),e[h+1].clone()));a++}}k-=4;j++}return l};MDVPolyline.prototype.getArrow=function(o,k){var d=this;var g=this.mdvMap.config.getZoomLevel(this.mdvMap.config.currentZoomLevelIndex);var l=parseInt(g.get("tileSizeX"))*parseInt(g.get("numberOfTilesX"));var t=parseInt(g.get("realWidth"))/l;var c=parseInt(g.get("tileSizeY"))*parseInt(g.get("numberOfTilesY"));var q=parseInt(g.get("realHeight"))/c;var r=k.x-o.x;var m=k.y-o.y;var f=Math.atan2(m,r);var s=new Array();var j=null;s.push([new MDVCoordinates(o.mapName,o.x-5*t,o.y-6*q),new MDVCoordinates(o.mapName,o.x,o.y)]);s.push([new MDVCoordinates(o.mapName,o.x-5*t,o.y+6*q),new MDVCoordinates(o.mapName,o.x,o.y)]);for(var h=0;h<s.length;h++){var u=new MDVPoint(s[h][0].x-s[h][1].x,s[h][0].y-s[h][1].y);var e=new MDVPoint(0,0);e.x=u.x*Math.cos(f)-u.y*Math.sin(f);e.y=u.x*Math.sin(f)+u.y*Math.cos(f);s[h][0].x=s[h][1].x+e.x;s[h][0].y=s[h][1].y+e.y}j=this.mdvMap.createPolyline(s[0][0].x+","+s[0][0].y+" "+s[0][1].x+","+s[0][1].y+" "+s[1][0].x+","+s[1][0].y+" "+s[1][1].x+","+s[1][1].y);if(d.get("weight")){j.add("weight",d.get("weight"))}else{j.add("weight","3")}if(d.get("colour")){j.add("colour",d.get("colour"))}if(d.get("opacity")){j.add("opacity",d.get("opacity"))}else{j.add("opacity","0.5")}return j};MDVPolyline.prototype.getArrows=function(){var e=this.getAllCoords();var k=20;var l=new Array();var a=0;var j=0;if(this.mdvMap.config.get("trips.polyline.arrows.max")){k=parseInt(this.mdvMap.config.get("trips.polyline.arrows.max"))}var d=this.mdvMap.config.getZoomLevel(this.mdvMap.config.currentZoomLevelIndex);var i=parseInt(d.get("tileSizeX"))*parseInt(d.get("numberOfTilesX"));var f=i/parseInt(d.get("realWidth"));while(a<=0&&j<3){for(var h=0;h<e.length-1;h++){if(!e[h]||!e[h+1]){return null}var b=new MDVPoint(e[h+1].x-e[h].x,e[h+1].y-e[h].y);var g=Math.sqrt(Math.pow(b.x,2)+Math.pow(b.y,2));g*=f;if(g>k){l.push(this.getArrow(new MDVCoordinates(e[h].mapName,e[h].x+b.x/2,e[h].y+b.y/2),e[h+1].clone()));a++}}k-=4;j++}return l};function MDVMap_NumSort(d,c){return d-c}function MDVHotspots(a){if(!a){return}this.mdvMap=a;this.name="MDVHotspots";this.data=[];this.current=null;this.json=null;this.level=null;this.mapNavigator=null;this.tooltip=new MDVToolTipConsumer();var b=this.mdvMap.createToolTip();this.tooltip.setToolTip(b);this.mdvMap.hotspots=this;this.mdvMap.events.registerEvent(MDVEvent_CENTRE_CHANGED,this,this.onCentreChanged);this.mdvMap.events.registerEvent(MDVEvent_MOUSE_MOVED,this,this.check);this.mdvMap.events.registerEvent(MDVEvent_MOUSE_UP,this,this.appendExec);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.onLevelChanged);this.viewport=[]}MDVHotspots.prototype.setViewport=function(){var b=this.mdvMap.getCentre(),c=this.mdvMap.viewportRealWidth,a=this.mdvMap.viewportRealHeight;this.viewport=[{x:Math.floor(b.x-(c*0.5)),y:Math.floor(b.y-(a*0.5))},{x:Math.floor(b.x+(c*0.5)),y:Math.floor(b.y-(a*0.5))},{x:Math.floor(b.x+(c*0.5)),y:Math.floor(b.y+(a*0.5))},{x:Math.floor(b.x-(c*0.5)),y:Math.floor(b.y+(a*0.5))},{x:Math.floor(b.x-(c*0.5)),y:Math.floor(b.y-(a*0.5))}]};MDVHotspots.prototype.onCentreChanged=function(c,b,a){if(this.json===null){return}if(this.mdvMap.config.getZoomLevelIndex()<this.mdvMap.config.get("showHotspotLevel")){return true}this.setViewport()};MDVHotspots.prototype.onLevelChanged=function(){if(this.json===null){return}var a=this.mdvMap.config.getZoomLevelIndex();if(a<this.mdvMap.config.get("showHotspotLevel")||a===this.level){return true}this.setViewport();this.appendExec()};MDVHotspots.prototype.isPointInPoly=function(e,f){for(var g=false,d=-1,a=e.length,b=a-1;++d<a;b=d){((e[d].y<=f.y&&f.y<e[b].y)||(e[b].y<=f.y&&f.y<e[d].y))&&(f.x<(e[b].x-e[d].x)*(f.y-e[d].y)/(e[b].y-e[d].y)+e[d].x)&&(g=!g)}return g};MDVHotspots.prototype.appendExec=function(){if(this.json===null){return}if(this.mdvMap.config.getZoomLevelIndex()<this.mdvMap.config.get("showHotspotLevel")){return true}var b,d,f,a,c,e,g;this.data.length=0;b=this.json||[];for(d=0,f=b.length;d<f;d++){a=b[d][2];for(c=0,e=a.length;c<e;c+=1){g=a[c];if(this.isPointInPoly(this.viewport,g)===true){this.data.push(b[d]);break}}}};MDVHotspots.prototype.retrieve=function(){if(!this.mdvMap.config.get("hotspotURL")){return}for(var a=0;a<this.mdvMap.gadgets.length;a++){if(this.mdvMap.gadgets[a].name==="MapNavigator"){this.mapNavigator=this.mdvMap.gadgets[a];break}}if(this.json==null){mdvLib.ajax({host:this.mdvMap.config.get("hotspotURL"),method:"get",onComplete:assignAjaxResponse.bind(this)})}};function assignAjaxResponse(response){var cs,ca,i,j,len,ln,tr,br,bl,_response=typeof response!=="string"?(response.responseText||response):response.trim();try{this.json=eval("("+_response+")");if(this.json.stations!==undefined){this.json=this.json.stations}}catch(e){this.json=eval(_response)}for(i=0,len=this.json.length;i<len;i+=1){cs=this.json[i][2];ca=[];for(j=0,ln=cs.length;j<ln;j+=2){ca.push({x:parseInt(cs[j],10),y:parseInt(cs[j+1],10)})}if(ca.length===2){tr={x:ca[1].x,y:ca[0].y};bl={x:ca[0].x,y:ca[1].y};br=ca.pop();ca.splice(1,1,tr,br,bl,ca[0])}this.json[i][2]=ca}this.onLevelChanged()}MDVHotspots.prototype.check=function(g,f,e){if(this.mdvMap.config.getZoomLevelIndex()<this.mdvMap.config.get("showHotspotLevel")){return true}if(!e||!this.data||this.data.length===0){return}var b,a,c=this.mdvMap,d={x:e.x,y:e.y};for(b=0,a=this.data.length;b<a;b++){if(this.isPointInPoly(this.data[b][2],d)===true){c.getMapper().style.cursor="pointer";this.current=this.data[b];this.triggerTooltip(g,f,e);break}else{c.setDefaultCursor();this.tooltip.getToolTip().hide();this.current=null}}};MDVHotspots.prototype.triggerTooltip=function(e,d,c){var b=c.x+10;var a=c.y+10;this.tooltip.setCoords(new MDVCoordinates(this.mdvMap.name,b,a));this.tooltip.getToolTip().setInnerHTML(this.current[1]);this.tooltip.getToolTip().display()};function MDVGadgetBase(a){if(!a){return}this.name="GadgetBase";this.mdvMap=a;this.active=true;this.mdvMap.registerGadget(this)}MDVGadgetBase.prototype.stopEvent=function(a){if(!a){return true}a.cancelBubble=true;a.returnValue=false;if(a.stopPropagation){a.stopPropagation()}if(a.preventDefault){a.preventDefault()}return false};MDVGadgetBase.prototype.destroy=function(){if(this.mdvMap){this.mdvMap=null}this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null};MDVGadgetBase.prototype.setActive=function(a){this.active=a};MDVGadgetBase.prototype.isActive=function(){return this.active};MDVGadgetBase.prototype.ondblclick=function(a){return true};MDVGadgetBase.prototype.onkeypress=function(a){return true};MDVGadgetBase.prototype.onmousedown=function(a){return true};MDVGadgetBase.prototype.onmousemove=function(a){return true};MDVGadgetBase.prototype.onmouseout=function(a){return true};MDVGadgetBase.prototype.onmouseover=function(a){return true};MDVGadgetBase.prototype.onmouseup=function(a){return true};MDVGadgetBase.prototype.onmousewheel=function(a){return true};MDVGadgetBase.prototype.oncontextmenu=function(a){return true};function MDVMapNavigator(a){if(!a){return}this.name="MapNavigator";this.mdvMap=a;this.mouseDown=false;this.centre;this.timer=null;this.zlDelta=0;this.mouseLast=new MDVPoint(-1,-1);this.mouseStart=new MDVPoint(-1,-1);this.mwHotSpot=null;this.mdvMap.registerGadget(this);for(var b in MDVGadgetBase.prototype){if(!MDVMapNavigator.prototype[b]){MDVMapNavigator.prototype[b]=MDVGadgetBase.prototype[b]}}this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.setDefaultCursor);this.mdvMap.events.registerEvent(MDVEvent_MOUSE_MOVED,this,this.updateMWHotSpot)}MDVMapNavigator.prototype.destroy=function(){if(this.mdvMap){this.mdvMap=null}this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null};MDVMapNavigator.prototype.updateMWHotSpot=function(c,b,a){if(this.mdvMap.config.get("centreOnMouseWheel")&&this.mdvMap.config.get("centreOnMouseWheel")=="true"){this.mwHotSpot=a.clone()}else{if(this.mdvMap.config.get("hotspotOnMouseWheel")&&this.mdvMap.config.get("hotspotOnMouseWheel")=="true"){this.mwHotSpot=a.clone()}}};MDVMapNavigator.prototype.setDefaultCursor=function(){if(this.mdvMap.config.get("cursorIdle")){if(document.all){this.mdvMap.getMapper().style.cursor="url('"+this.mdvMap.config.get("cursorIdle")+"')"}else{this.mdvMap.getMapper().style.cursor="-moz-grab"}}};MDVMapNavigator.prototype.oncontextmenu=function(a){return false};MDVMapNavigator.prototype.ondblclick=function(h){h=h?h:window.event;if(this.mdvMap.config.get("omitDoubleClick")&&this.mdvMap.config.get("omitDoubleClick")=="true"){this.stopEvent(h);return false}var d=h.pageX||(h.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var a=h.pageY||(h.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var n=0;var i=0;var g=this.mdvMap.viewport;while(g){n+=g.offsetLeft;i+=g.offsetTop;if(g.style.position==="fixed"){i+=(window.pageYOffset||document.documentElement.scrollTop)}g=g.offsetParent}d=d-(n);a=a-(i);var f=(this.mdvMap.config.get("useMagnifyGlass")&&this.mdvMap.config.get("useMagnifyGlass")=="true");var j=new MDVPoint(d,a);var m=this.mdvMap.getCoordinates(j);var c=this.mdvMap.getPoint(this.mdvMap.getCentre());c.x+=parseInt(this.mdvMap.getMapper().style.left);c.y+=parseInt(this.mdvMap.getMapper().style.top);var k=new MDVPoint(c.x-j.x,c.y-j.y);if(this.mdvMap.config.get("zoomOnDoubleClick")&&this.mdvMap.config.get("zoomOnDoubleClick")=="true"){this.mdvMap.setCentre(m);this.mdvMap.getMapper().style.left=parseInt(this.mdvMap.getMapper().style.left)+k.x+"px";this.mdvMap.getMapper().style.top=parseInt(this.mdvMap.getMapper().style.top)+k.y+"px";var b=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);if(b!=null&&f){this.mdvMap._checkWrap();this.mdvMap.magnify(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);this.mdvMap.switchMapper()}else{if(b!=null&&!f){this.mdvMap.setZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);this.mdvMap.update()}else{this.mdvMap.update()}}}else{if(this.mdvMap.config.get("moveOnDoubleClick")&&this.mdvMap.config.get("moveOnDoubleClick")=="true"){var l=[this.mdvMap.getCentre().clone(),m.clone()];this.mdvMap.moveBySeq(l)}else{this.mdvMap.setCentre(m);this.mdvMap.update();this.mdvMap.events.triggerEvent(MDVEvent_MAP_INITIALISED,"MDVMap tiles have been initialised",this.mdvMap)}}this.stopEvent(h);return false};MDVMapNavigator.prototype.onmousewheel=function(c){var b=0;if(!c){c=window.event}if(c.detail){b=-c.detail/3}else{if(c.wheelDelta){b=c.wheelDelta/120;if(window.opera){b=-b}}}if(b===0){return}var a=function(){var g=null;var d=null;if(this.mdvMap.config.get("centreOnMouseWheel")&&this.mdvMap.config.get("centreOnMouseWheel")=="true"){g=this.mwHotSpot}else{if(this.mdvMap.config.get("hotspotOnMouseWheel")&&this.mdvMap.config.get("hotspotOnMouseWheel")=="true"){d=this.mwHotSpot}}if(b>0){var e=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex()+this.zlDelta);if(e!=null){var f=this.mdvMap.getCentre();if(g){this.mdvMap.setCentre(g)}else{if(d){f=this.getNewHotspotCentre(d,this.mdvMap.config.getZoomLevelIndex()+this.zlDelta)}}g=null;d=null;if(this.mdvMap.config.get("useMagnifyGlass")&&this.mdvMap.config.get("useMagnifyGlass")=="true"){this.mdvMap.magnify(this.mdvMap.config.getZoomLevelIndex()+this.zlDelta,f);this.mdvMap.switchMapper()}else{this.mdvMap.setZoomLevel(this.mdvMap.config.getZoomLevelIndex()+this.zlDelta);this.mdvMap.setCentre(f);this.mdvMap.update()}}}else{var e=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex()-this.zlDelta);if(e!=null){var f=this.mdvMap.getCentre();if(d&&!g){f=this.getNewHotspotCentre(d,this.mdvMap.config.getZoomLevelIndex()-this.zlDelta)}g=null;d=null;if(this.mdvMap.config.get("useMagnifyGlass")&&this.mdvMap.config.get("useMagnifyGlass")=="true"){this.mdvMap.magnify(this.mdvMap.config.getZoomLevelIndex()-this.zlDelta,f);this.mdvMap.switchMapper()}else{this.mdvMap.setZoomLevel(this.mdvMap.config.getZoomLevelIndex()-this.zlDelta);this.mdvMap.setCentre(f);this.mdvMap.update()}}}this.mouseDown=false;this.zlDelta=0};if(this.timer!==null){window.clearTimeout(this.timer);this.timer=null;this.zlDelta+=1}this.timer=window.setTimeout(function(){this.zlDelta=this.zlDelta||1;a.apply(this)}.bind(this),250);this.stopEvent(c);return false};MDVMapNavigator.prototype.getNewHotspotCentre=function(g,l){var f=g.clone();var b=this.mdvMap.getPoint(f);var a=this.mdvMap.getPoint(this.mdvMap.getCentre());var d=new MDVPoint(a.x-b.x,a.y-b.y);var k=this.mdvMap.config.getZoomLevel(l);var e=this.mdvMap.config.getZoomLevel(l);var h=parseInt(e.get("tileSizeX"))*parseInt(e.get("numberOfTilesX"));var j=parseInt(e.get("realWidth"))/h;var c=parseInt(e.get("tileSizeY"))*parseInt(e.get("numberOfTilesY"));var i=parseInt(e.get("realHeight"))/c;d.x*=j;d.y*=i;f.x+=d.x;f.y+=d.y;return f};MDVMapNavigator.prototype.onmousedown=function(c){c=c?c:window.event;if((c.button==1&&window.event)||(c.button==0)){var b=c.pageX||(c.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var a=c.pageY||(c.clientY+(document.documentElement.scrollTop||document.body.scrollTop));this.mouseLast.x=b;this.mouseLast.y=a;this.mouseStart.x=this.mouseLast.x;this.mouseStart.y=this.mouseLast.y;if(!this.mouseDown){if(this.mdvMap.config.get("cursorMove")){if(document.all){this.mdvMap.getMapper().style.cursor="url('"+this.mdvMap.config.get("cursorMove")+"')"}else{this.mdvMap.getMapper().style.cursor="-moz-grabbing"}}else{this.mdvMap.getMapper().style.cursor="auto"}}this.centre=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);this.mouseDown=true;return this.stopEvent(c)}else{this.mouseDown=false;return true}};MDVMapNavigator.prototype.onmouseup=function(b){b=b?b:window.event;if(this.mouseDown){if(document.all&&b.type=="mouseout"){return true}if(this.mdvMap.config.get("cursorIdle")){if(document.all){this.mdvMap.getMapper().style.cursor="url('"+this.mdvMap.config.get("cursorIdle")+"')"}else{this.mdvMap.getMapper().style.cursor="-moz-grab"}}else{this.mdvMap.getMapper().style.cursor="auto"}var a=this.mdvMap.getCentre();if(this.centre&&(this.centre.x!=a.x||this.centre.y!=a.y)){if(this.mdvMap.managedMarkers){this.mdvMap._updateLayers()}this.mdvMap.events.triggerEvent(MDVEvent_MAP_INITIALISED,"MDVMap tiles have been initialised",this.mdvMap)}}this.mouseDown=false;return false};MDVMapNavigator.prototype.onmouseout=function(b){b=b?b:window.event;var c=b.srcElement?b.srcElement:b.target;var a=b.srcElement?c.parentElement:c.parentNode;while(a){if(a.className=="mdvLayer"){return true}a=b.srcElement?a.parentElement:a.parentNode}return this.onmouseup(b)};MDVMapNavigator.prototype.onmousemove=function(o){o=o?o:window.event;var h=o.pageX||(o.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var g=o.pageY||(o.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var a=0;var s=0;var i=this.mdvMap.viewport;while(i){a+=i.offsetLeft;s+=i.offsetTop;if(i.style.position==="fixed"){s+=(window.pageYOffset||document.documentElement.scrollTop)}i=i.offsetParent}h=h-(a);g=g-(s);var l=new MDVPoint(h,g);var r=this.mdvMap.getCoordinates(l);this.mdvMap.events.triggerEvent(MDVEvent_MOUSE_MOVED,"MDVMap noticed a mouse movement.",r);if(this.mouseDown){if(this.mdvMap.config.get("cursorMove")){if(document.all){this.mdvMap.getMapper().style.cursor="url('"+this.mdvMap.config.get("cursorMove")+"')"}else{this.mdvMap.getMapper().style.cursor="-moz-grabbing"}}else{this.mdvMap.getMapper().style.cursor="auto"}var f=o.pageX||(o.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var d=o.pageY||(o.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var b=new MDVPoint(parseInt(this.mdvMap.getMapper().style.left),parseInt(this.mdvMap.getMapper().style.top));var j=this.mdvMap.config.getZoomLevel(this.mdvMap.config.currentZoomLevelIndex);var q=parseInt(j.get("tileSizeX"))*parseInt(j.get("numberOfTilesX"));var c=parseInt(j.get("realWidth"))/q;var n=parseInt(j.get("tileSizeY"))*parseInt(j.get("numberOfTilesY"));var m=parseInt(j.get("realHeight"))/n;var p=new MDVPoint(((f-this.mouseLast.x)*c),(d-this.mouseLast.y)*m);var k=new MDVCoordinates(this.mdvMap.config.get("mapName"),this.mdvMap.real.x-p.x,this.mdvMap.real.y-p.y);this.mdvMap.setCentre(k);if(this.mdvMap.getCentre().x==k.x){this.mdvMap.getMapper().style.left=(b.x+(f-this.mouseLast.x))+"px";this.mdvMap.getMagnifyMapper().style.left=(parseInt(this.mdvMap.getMagnifyMapper().style.left)+(f-this.mouseLast.x))+"px"}if(this.mdvMap.getCentre().y==k.y){this.mdvMap.getMapper().style.top=(b.y+(d-this.mouseLast.y))+"px";this.mdvMap.getMagnifyMapper().style.top=(parseInt(this.mdvMap.getMagnifyMapper().style.top)+(d-this.mouseLast.y))+"px"}this.mouseLast.x=f;this.mouseLast.y=d;this.mdvMap._checkWrap()}};function MDVMapCrosshair(a){if(!a){return}this.name="MapCrosshair";this.mdvMap=a;this.mdvMap.registerGadget(this);for(var b in MDVGadgetBase.prototype){if(!MDVMapCrosshair.prototype[b]){MDVMapCrosshair.prototype[b]=MDVGadgetBase.prototype[b]}}this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.execute)}MDVMapCrosshair.prototype.execute=function(){if(this.mdvMap.config.get("crosshair")){var d=this.mdvMap.config.get("crosshair");var b=this.mdvMap.getMapper();if(!document.getElementById("crosshairLayer")){var c=document.createElement("div");c.id="crosshairLayer";c.style.position="absolute";c.style.top=(this.mdvMap.viewportHeight)/2-parseInt(b.style.top);c.style.left=(this.mdvMap.viewportWidth)/2-parseInt(b.style.left);c.style.zIndex=10;var a=new Image();a.src=d;c.appendChild(a);this.mdvMap.getMapper().appendChild(c)}else{var c=document.getElementById("crosshairLayer");if(c){c.style.position="absolute";c.style.top=(this.mdvMap.viewportHeight)/2-parseInt(b.style.top)+"px";c.style.left=(this.mdvMap.viewportWidth)/2-parseInt(b.style.left)+"px";c.style.zIndex=10}}}};function MDVMapEFAInfo(a){this.mdvMap=a;this.name="MapEFAInfo";this.stops=null;this.poi=null;this.centre=null;this.id=null;this.lastCentre=null;this.stopImg=new Image();this.mot1Img=new Image();this.mot2Img=new Image();this.mot3Img=new Image();this.mot4Img=new Image();this.mot5Img=new Image();this.mot6Img=new Image();this.mot7Img=new Image();this.mot8Img=new Image();this.mot9Img=new Image();this.mot10Img=new Image();this.mot11Img=new Image();this.mot12Img=new Image();this.poiImg=new Image();this.imgsLoaded=false;this.comparator=null;if(arguments.length>=2&&arguments[1]!=null){this.comparator=arguments[1]}if(arguments.length>=2&&arguments[2]!=null){this.getMOTImage=arguments[2]}for(var b in MDVGadgetBase.prototype){if(!MDVMapEFAInfo.prototype[b]){MDVMapEFAInfo.prototype[b]=MDVGadgetBase.prototype[b]}}this.mdvMap.registerGadget(this);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.trigger);this.mdvMap.events.registerEvent(MDVEvent_AJAX_CALLBACK,this,this.processPins)}MDVMapEFAInfo.prototype.destroy=function(){this.stopImg.onclick=null;this.stopImg=null;this.mot1Img.onclick=null;this.mot1Img=null;this.mot2Img.onclick=null;this.mot2Img=null;this.mot3Img.onclick=null;this.mot3Img=null;this.mot4Img.onclick=null;this.mot4Img=null;this.mot5Img.onclick=null;this.mot5Img=null;this.mot6Img.onclick=null;this.mot6Img=null;this.mot7Img.onclick=null;this.mot7Img=null;this.mot8Img.onclick=null;this.mot8Img=null;this.mot9Img.onclick=null;this.mot9Img=null;this.mot10Img.onclick=null;this.mot10Img=null;this.mot11Img.onclick=null;this.mot11Img=null;this.mot12Img.onclick=null;this.mot12Img=null;this.poiImg.onclick=null;this.poiImg=null;if(this.stops){this.stops.removeAll()}if(this.poi){this.poi.removeAll()}};MDVMapEFAInfo.prototype.createLayers=function(){if(!this.stops){this.stops=this.mdvMap.createLayer("efa_stops");this.stops.setZIndex(2);this.mdvMap.addLayer(this.stops)}if(!this.poi){this.poi=this.mdvMap.createLayer("efa_poi");this.poi.setZIndex(1);this.mdvMap.addLayer(this.poi)}};MDVMapEFAInfo.prototype.trigger=function(){var a="images/";if(this.mdvMap.config.get("imagePath")){a=this.mdvMap.config.get("imagePath")}if(!this.imgsLoaded){this.stopImg.src=a+"stop.gif";this.mot1Img.src=a+"mot1.gif";this.mot2Img.src=a+"mot2.gif";this.mot3Img.src=a+"mot3.gif";this.mot4Img.src=a+"mot4.gif";this.mot5Img.src=a+"mot5.gif";this.mot6Img.src=a+"mot6.gif";this.mot7Img.src=a+"mot7.gif";this.mot8Img.src=a+"mot8.gif";this.mot9Img.src=a+"mot9.gif";this.mot10Img.src=a+"mot10.gif";this.mot11Img.src=a+"mot11.gif";this.mot12Img.src=a+"mot12.gif";this.poiImg.src=a+"pin.gif";this.imgsLoaded=true}if(this.id){mdvTimer.remove(this.id);this.id=null}this.id=mdvTimer.add(700,this,this.execute,[])};MDVMapEFAInfo.prototype.execute=function(){mdvTimer.remove(this.id);this.id=null;this.createLayers();var c=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var a=c.get("showSTOP")=="true";var b=c.get("showPOI")=="true";if(a||b){this.fetchPins()}else{this.stops.removeAll();this.poi.removeAll()}};MDVMapEFAInfo.prototype.getMOTImage=function(d,b,a,c){switch(parseInt(d)){case 1:return this.mot1Img.src;break;case 2:return this.mot2Img.src;break;case 3:return this.mot3Img.src;break;case 4:return this.mot4Img.src;break;case 5:return this.mot5Img.src;break;case 6:return this.mot6Img.src;break;case 7:return this.mot7Img.src;break;case 8:return this.mot8Img.src;break;case 9:return this.mot9Img.src;break;case 10:return this.mot10Img.src;break;case 11:return this.mot11Img.src;break;case 12:return this.mot12Img.src;break;default:if(b.toUpperCase()=="POI"){return this.poiImg.src}else{return this.stopImg.src}break}return null};MDVMapEFAInfo.prototype.processPins=function(t,b,d){if(b!="MapEFAInfo"){return false}mdvTimer.remove(this.id);this.id=null;var s=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var y=s.get("showSTOP")=="true"?true:false;var u=s.get("showPOI")=="true"?true:false;var A=d.getElementsByTagName("itdPinElem");var D=d.getElementsByTagName("itdMapRequest");this.stops.removeAll();this.poi.removeAll();if(D&&D.length>0){var e=new MDVCoordinates(D[0].getAttribute("mapName"),D[0].getAttribute("xCenterReal"),D[0].getAttribute("yCenterReal"));if(!e.equals(this.mdvMap.getCentre())){return false}}var c=false;var f=false;if(A.length<=0||D.length<=0){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to get pins from map request.");return false}for(var z=0;z<A.length;z++){var w=A[z].getAttribute("desc");var h=A[z].getAttribute("id");var E=A[z].getAttribute("type");var r=A[z].getAttribute("omc");var q=new Array();var n=new Image();var k=A[z].getElementsByTagName("genAttrElem");if(k.length>0){var a="";var C=k[0];while(C){if(C.nodeType!=1||!C.firstChild){C=C.nextSibling;continue}if(C.firstChild&&C.firstChild.firstChild&&C.firstChild.firstChild.nodeValue=="STOP_MAJOR_MEANS"&&C.firstChild.nextSibling&&C.firstChild.nextSibling.firstChild){a=C.firstChild.nextSibling.firstChild.nodeValue}if(C.firstChild&&C.firstChild.firstChild&&C.firstChild.nextSibling&&C.firstChild.nextSibling.firstChild){q.push({name:C.firstChild.firstChild.nodeValue,value:C.firstChild.nextSibling.firstChild.nodeValue})}C=C.nextSibling}n.src=this.getMOTImage(a,E,A[z],q)}else{if(E.toUpperCase()=="POI"){n.src=this.poiImg.src}else{n.src=this.stopImg.src}}var j=new Array();j.poi=new MDVPoint(284,190);j.stop=new MDVPoint(284,190);if(this.mdvMap.config.get("info.stop.size.width")&&this.mdvMap.config.get("info.stop.size.height")){j.stop=new MDVPoint(this.mdvMap.config.get("info.stop.size.width"),this.mdvMap.config.get("info.stop.size.height"))}if(this.mdvMap.config.get("info.poi.size.width")&&this.mdvMap.config.get("info.poi.size.height")){j.poi=new MDVPoint(this.mdvMap.config.get("info.poi.size.width"),this.mdvMap.config.get("info.poi.size.height"))}var x=new MDVCoordinates(D[0].getAttribute("mapName"),parseInt(A[z].firstChild.getAttribute("x")),parseInt(A[z].firstChild.getAttribute("y")));var o=this.mdvMap.createMarker(x,0.5,n.src);o.objectId={type:E,desc:w,id:h,omc:r,marker:o};if(o.objectId){o.objectId.attrs=q}if(this.comparator){if(!this.comparator(o.objectId)){continue}}switch(E){case"stop":var B=null;if(this.mdvMap.config.get("useBubbleForEFAInfo")&&this.mdvMap.config.get("useBubbleForEFAInfo")=="true"){B=this.mdvMap.createToolTip(j.stop,"<b>"+w+"</b>");if(this.mdvMap.config.get("useBubbleOverflowForEFAInfo")&&this.mdvMap.config.get("useBubbleOverflowForEFAInfo")=="true"){B.setOverflow(true)}if(this.mdvMap.config.get("useBubblePinForEFAInfo")&&this.mdvMap.config.get("useBubblePinForEFAInfo")=="true"){B.setPin(true)}o.setToolTip(B,false)}else{B=this.mdvMap.createToolTip("Stop: <b>"+w+"</b>");o.setToolTip(B,false)}break;case"poi":var B=null;if(this.mdvMap.config.get("useBubbleForEFAInfo")&&this.mdvMap.config.get("useBubbleForEFAInfo")=="true"){B=this.mdvMap.createToolTip(j.poi,"<b>"+w+"</b>");if(this.mdvMap.config.get("useBubbleOverflowForEFAInfo")&&this.mdvMap.config.get("useBubbleOverflowForEFAInfo")=="true"){B.setOverflow(true)}if(this.mdvMap.config.get("useBubblePinForEFAInfo")&&this.mdvMap.config.get("useBubblePinForEFAInfo")=="true"){B.setPin(true)}o.setToolTip(B,false)}else{B=this.mdvMap.createToolTip("Landmark: <b>"+w+"</b>");o.setToolTip(B,false)}break}switch(E){case"poi":if(u){for(var v=0;v<this.poi.getMarkers().length;v++){var l=this.poi.getMarkers();if(l[v].objectId.id==o.objectId.id&&l[v].objectId.omc==o.objectId.omc){p=true;break}}if(p){continue}this.poi.addMarker(o,false);f=true}break;default:if(y){var p=false;for(var v=0;v<this.stops.getMarkers().length;v++){var g=this.stops.getMarkers();if(g[v].objectId.id==o.objectId.id){p=true;break}}if(p){continue}this.stops.addMarker(o,false);c=true}break}}if(c){this.stops.update()}if(f){this.poi.update()}this.centre=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);return true};MDVMapEFAInfo.prototype.fetchPins=function(){if(this.mdvMap.config.get("efaURL")){var e=this.mdvMap.config.get("efaURL");var d=this.mdvMap.getCentre();var g=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var b=g.get("showSTOP")=="true"?1:0;var f=g.get("showPOI")=="true"?1:0;var h=this.mdvMap.config.get("language")!=null?this.mdvMap.config.get("language"):"en";var a={language:h,xCenterReal:Math.floor(d.x+0.5),yCenterReal:Math.floor(d.y+0.5),mapName:d.mapName,pinTypePOI:f,pinTypeStop:b,createImage:"0",realHeight:this.mdvMap.viewportRealHeight,realWidth:this.mdvMap.viewportRealWidth,screenWidth:this.mdvMap.viewportWidth,screenHeight:this.mdvMap.viewportHeight,command:"mapData",hideBannerInfo:"1",itdLPxx_mdvMapName:"mdvMap_"+this.mdvMap.getName(),itdLPxx_mdvMap:this.name};var c=mdvLib.ajax({host:e,parameters:a,onComplete:MDVMapEFAInfo_onAjaxComplete})}};MDVMapEFAInfo.prototype.onmousedown=function(a){mdvTimer.remove(this.id);this.id=null;this.lastCentre=this.mdvMap.getCentre().clone();return true};MDVMapEFAInfo.prototype.onmouseup=function(a){if(this.lastCentre&&this.lastCentre.equals(this.mdvMap.getCentre())){this.trigger()}return true};function MDVMapEFAInfo_onAjaxComplete(d){var b=null;if(d&&d.responseXML){b=d.responseXML}else{if(d){b=d}}var a=b.getElementsByTagName("itdLayoutParam");for(var c=0;c<a.length;c++){if(a[c].getAttribute("name")=="mdvMapName"){if(document.mdvMaps[a[c].getAttribute("value")]){document.mdvMaps[a[c].getAttribute("value")].events.triggerEvent(MDVEvent_AJAX_CALLBACK,"MapEFAInfo",b)}return}}}function MDVMapEFATrips(a){this.mdvMap=a;this.name="MDVMapEFATrips";this.layer=null;this.options=[];this.wizardJobID=null;this.wizardIndex=null;this.wizardScreenPlay=new Array();this.response=null;this.responseJson=null;this.tripParams={};this.polylines=new Array();this.zoomLevel=null;this.doBeautify=true;this.imgs=new Array();this.imgs.stop=new Image();this.imgs["1"]=new Image();this.imgs["1_follow"]=new Image();this.imgs["2"]=new Image();this.imgs["2_follow"]=new Image();this.imgs["3"]=new Image();this.imgs["3_follow"]=new Image();this.imgs["4"]=new Image();this.imgs["4_follow"]=new Image();this.imgs["5"]=new Image();this.imgs["5_follow"]=new Image();this.imgs["6"]=new Image();this.imgs["6_follow"]=new Image();this.imgs["7"]=new Image();this.imgs["7_follow"]=new Image();this.imgs["8"]=new Image();this.imgs["8_follow"]=new Image();this.imgs["9"]=new Image();this.imgs["9_follow"]=new Image();this.imgs["10"]=new Image();this.imgs["10_follow"]=new Image();this.imgs["11"]=new Image();this.imgs["11_follow"]=new Image();this.imgs["12"]=new Image();this.imgs["12_follow"]=new Image();this.imgs["13"]=new Image();this.imgs["13_follow"]=new Image();this.imgs["99"]=new Image();this.imgs["99_follow"]=new Image();this.imgs["100"]=new Image();this.imgs["100_follow"]=new Image();this.imgs["100_arrival"]=new Image();this.imgs["100_departure"]=new Image();this.imgs["101"]=new Image();this.imgs["101_follow"]=new Image();this.imgs["101_arrival"]=new Image();this.imgs["101_departure"]=new Image();this.imgs["102"]=new Image();this.imgs["102_follow"]=new Image();this.imgs["102_arrival"]=new Image();this.imgs["102_departure"]=new Image();this.imgs["103"]=new Image();this.imgs["103_follow"]=new Image();this.imgs["103_arrival"]=new Image();this.imgs["103_departure"]=new Image();this.imgs["104"]=new Image();this.imgs["104_follow"]=new Image();this.imgs["104_arrival"]=new Image();this.imgs["104_departure"]=new Image();this.imgs["105"]=new Image();this.imgs["105_follow"]=new Image();this.imgs["105_arrival"]=new Image();this.imgs["105_departure"]=new Image();this.imgs["106"]=new Image();this.imgs["106_follow"]=new Image();this.imgs["106_arrival"]=new Image();this.imgs["106_departure"]=new Image();this.imgs["107"]=new Image();this.imgs["107_follow"]=new Image();this.imgs["107_arrival"]=new Image();this.imgs["107_departure"]=new Image();this.imgs.poi=new Image();for(var c in MDVGadgetBase.prototype){if(!MDVMapEFATrips.prototype[c]){MDVMapEFATrips.prototype[c]=MDVGadgetBase.prototype[c]}}if(arguments.length==2){for(var b in arguments[1]){this.options[b]=arguments[1][b]}if(this.options.getMarker){this.getMarker=this.options.getMarker}}this.mdvMap.registerGadget(this);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.execute);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.update);this.mdvMap.events.registerEvent(MDVEvent_AJAX_CALLBACK,this,this.processTrip)}MDVMapEFATrips.prototype.prefetchImgs=function(){var a="images/";if(this.mdvMap.config.get("imagePath")){a=this.mdvMap.config.get("imagePath")}this.imgs.stop.src=a+"stop.gif";this.imgs["1"].src=a+"mot1.gif";this.imgs["1_follow"].src=a+"mot1_follow.gif";this.imgs["2"].src=a+"mot2.gif";this.imgs["2_follow"].src=a+"mot2_follow.gif";this.imgs["3"].src=a+"mot3.gif";this.imgs["3_follow"].src=a+"mot3_follow.gif";this.imgs["4"].src=a+"mot4.gif";this.imgs["4_follow"].src=a+"mot4_follow.gif";this.imgs["5"].src=a+"mot5.gif";this.imgs["5_follow"].src=a+"mot5_follow.gif";this.imgs["6"].src=a+"mot6.gif";this.imgs["6_follow"].src=a+"mot6_follow.gif";this.imgs["7"].src=a+"mot7.gif";this.imgs["7_follow"].src=a+"mot7_follow.gif";this.imgs["8"].src=a+"mot8.gif";this.imgs["8_follow"].src=a+"mot8_follow.gif";this.imgs["9"].src=a+"mot9.gif";this.imgs["9_follow"].src=a+"mot9_follow.gif";this.imgs["10"].src=a+"mot10.gif";this.imgs["10_follow"].src=a+"mot10_follow.gif";this.imgs["11"].src=a+"mot11.gif";this.imgs["11_follow"].src=a+"mot11_follow.gif";this.imgs["12"].src=a+"mot12.gif";this.imgs["12_follow"].src=a+"mot12_follow.gif";this.imgs["13"].src=a+"mot13.gif";this.imgs["13_follow"].src=a+"mot13_follow.gif";this.imgs["99"].src=a+"mot99.gif";this.imgs["99_follow"].src=a+"mot99_follow.gif";this.imgs["100"].src=a+"mot100.gif";this.imgs["100_follow"].src=a+"mot100_follow.gif";this.imgs["100_arrival"].src=a+"mot100_arrival.gif";this.imgs["100_departure"].src=a+"mot100.gif";this.imgs["101"].src=a+"mot101.gif";this.imgs["101_follow"].src=a+"mot101_follow.gif";this.imgs["101_arrival"].src=a+"mot101_arrival.gif";this.imgs["101_departure"].src=a+"mot101_departure.gif";this.imgs["102"].src=a+"mot102.gif";this.imgs["102_follow"].src=a+"mot102_follow.gif";this.imgs["102_arrival"].src=a+"mot102_arrival.gif";this.imgs["102_departure"].src=a+"mot102_departure.gif";this.imgs["103"].src=a+"mot103.gif";this.imgs["103_follow"].src=a+"mot103_follow.gif";this.imgs["103_arrival"].src=a+"mot103_arrival.gif";this.imgs["103_departure"].src=a+"mot103_departure.gif";this.imgs["104"].src=a+"mot104.gif";this.imgs["104_follow"].src=a+"mot104_follow.gif";this.imgs["104_arrival"].src=a+"mot104_arrival.gif";this.imgs["104_departure"].src=a+"mot104_departure.gif";this.imgs["105"].src=a+"mot105.gif";this.imgs["105_follow"].src=a+"mot105_follow.gif";this.imgs["105_arrival"].src=a+"mot105_arrival.gif";this.imgs["105_departure"].src=a+"mot105_departure.gif";this.imgs["106"].src=a+"mot106.gif";this.imgs["106_follow"].src=a+"mot106_follow.gif";this.imgs["106_arrival"].src=a+"mot106_arrival.gif";this.imgs["106_departure"].src=a+"mot106_departure.gif";this.imgs["107"].src=a+"mot107.gif";this.imgs["107_follow"].src=a+"mot107_follow.gif";this.imgs["107_arrival"].src=a+"mot107_arrival.gif";this.imgs["107_departure"].src=a+"mot107_departure.gif";this.imgs.poi.src=a+"pin.gif"};MDVMapEFATrips.prototype.onmousedown=function(b){mdvTimer.remove(this.wizardJobID);this.mdvMap.cancelMoveBySeq();this.wizardJobID=null;for(var a=0;a<this.wizardScreenPlay.length;a++){if(this.wizardScreenPlay[a].type=="marker"&&this.wizardScreenPlay[a].object.toolTip){this.wizardScreenPlay[a].object.toolTip.hide()}}return true};MDVMapEFATrips.prototype.execute=function(){if(this.layer==null){this.prefetchImgs();this.layer=this.mdvMap.createLayer("efa_trip");this.mdvMap.addLayer(this.layer)}};MDVMapEFATrips.prototype.clear=function(){if(this.mdvMap){mdvTimer.remove(this.wizardJobID);this.mdvMap.cancelMoveBySeq();this.wizardJobID=null;this.mdvMap.hideToolTips()}this.layer.removeAll();while(this.polylines.pop()){}while(this.wizardScreenPlay.pop()){}this.wizardJobID=null;this.wizardIndex=null};MDVMapEFATrips.prototype.loadTrip=function(j,h,c){if(!this.mdvMap.config.get("tripURL")){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"No tripURL specified.");return false}this.tripParams={sessionId:j,requestId:h,tripIndex:c};if(arguments.length==4){this.doBeautify=arguments[3]}this.tripParams.reductionList="";if(this.options.reductionList){for(var a=0;a<this.options.reductionList.length;a++){if(this.options.reductionList[a].maxScale){this.tripParams.reductionList+=this.options.reductionList[a].epsilon+":"}}}var f=this.mdvMap.config.get("language")!=null?this.mdvMap.config.get("language"):"en";var k=this.mdvMap.config.get("tripURL");var d=this.mdvMap.config.get("mapName");var e=("tripSelector"+c);var b=this.mdvMap.config.get("trips.useJsonEx");var i={};if(b=="true"){i={language:f,sessionID:j,requestID:h,coordListOutputFormat:"STRING",command:"tripCoordSeq:"+this.tripParams.tripIndex,output:"JSON",itdLPxx_mdvMapName:this.mdvMap.getName(),filterEpsilon:this.tripParams.reductionList}}else{i={language:f,sessionID:j,requestID:h,coordListOutputFormat:"STRING",command:"formatToXSLT",tripSelection:"on",coordOutputFormat:d,itdLPxx_mdvMap:"MDVMapEFATrips",itdLPxx_mdvMapName:this.mdvMap.getName(),showItdPathCoordinates:"1",filterEpsilon:this.tripParams.reductionList,itdLPxx_hideNotes:"1"};i[e]="on"}var g=mdvLib.ajax({host:k,parameters:i,onComplete:MDVMapEFATrips_onAjaxComplete});return true};MDVMapEFATrips.prototype.getReductionList=function(g){var f=[];if(this.options.reductionList&&g.reductionList){for(var c=0;c<this.options.reductionList.length;c++){var j=parseFloat(this.options.reductionList[c].epsilon);var a=0;var d=g.reductionList.epsilon?g.reductionList:g.reductionList[a];do{var h=parseFloat(d.epsilon);if(h==j){this.options.reductionList[c].mask=d.mask;var b={maxScale:this.options.reductionList[c].maxScale,epsilon:h,mask:this.options.reductionList[c].mask.split(" ")};f.push(b);break}a++}while(d=g.reductionList[a])}}return f};function MDVMapEFATrips_ScaleSort(d,c){return d.maxScale-c.maxScale}MDVMapEFATrips.prototype.processTrip=function(id,gName,efa){if(gName!="MDVMapEFATrips"){return false}var hostUrl,_params,createPath,process,alignment=0.5,leg=null;var jsonServerURL=this.mdvMap.config.get("trips.jsonServerURL");if(this.options.alignment){alignment=this.options.alignment}this.response=efa;this.clear();createPath=function(mode){var l=0,tripIsArr;var _response=mode==="lite"?this.response:this.responseJson;while(leg){if(mode==="json"){tripIsArr=mdvLib.typeOf(this.response.trips.trip.legs)==="array";leg.points=tripIsArr?this.response.trips.trip.legs[l].points:this.response.trips.trip.legs.leg.points;leg.mode=tripIsArr?this.response.trips.trip.legs[l].mode:this.response.trips.trip.legs.leg.mode}var type=leg.mode.type;var line="";if(leg.mode.diva){line=leg.mode.diva.line}var points=leg.points;var colour=this.getLegColour(type,line);var opacity=this.getLegOpacity(type,line);var weight=3;var p=null;var list=this.getReductionList(leg);list.sort(MDVMapEFATrips_ScaleSort);if(this.mdvMap.config.get("trips.polyline.weight")){weight=this.mdvMap.config.get("trips.polyline.weight")}if(!leg.path){if(leg.turnInst&&leg.turnInst.length>0){var pathStr="";for(var i=0;i<leg.turnInst.length;i++){for(var p in leg.turnInst[i]){if(p==="coords"){pathStr+=leg.turnInst[i][p]+" "}}}pathStr=pathStr.substring(0,pathStr.length-1)}else{var pathStr="";for(var i=0;i<leg.points.length;i++){if(leg.points[i].ref){for(var p in leg.points[i].ref){if(p==="coords"){pathStr+=leg.points[i].ref[p]+" "}}}}pathStr=pathStr.substring(0,pathStr.length-1)}}else{var pathStr=leg.path.replace(/\.00000/gi,"")}if(list.length>0){p=this.mdvMap.createPolyline(pathStr,{reductionList:list});this.polylines.push(p)}else{p=this.mdvMap.createPolyline(pathStr);this.polylines.push(p)}p.add("colour",colour);p.add("opacity",opacity);p.add("weight",weight);if(leg.stopSeq&&this.mdvMap.config.get("trips.polyline.stopSeq")=="true"){for(var s=1;s<leg.stopSeq.length-1;s++){var stop=leg.stopSeq[s];var cs=stop.ref.coords.split(",");var stopName=stop.name;var coords=new MDVCoordinates("NBWT",cs[0],cs[1]);var marker=null;if(coords.x>0&&coords.y>0){marker=this.mdvMap.createMarker(coords,new MDVPoint(0.5,0.5),this.imgs[type].src);marker.mode=leg.mode.type;var size=new MDVPoint(270,150);var tt=this.mdvMap.createToolTip(size,stopName);tt.stop=stop;tt.setOverflow(true);tt.setPin(true);marker.setToolTip(tt);this.layer.addMarker(marker)}}}if(!p.markers.departure){var coords=p.getAllCoords();var m=this.getMarker(type,"departure",coords[0],alignment,l);p.markers.departure=m;p.markers.departure.mode=type;p.markers.departure.point=points[0]}if(!p.markers.arrival){var coords=p.getAllCoords();var m=this.getMarker(type,"arrival",coords[coords.length-1],alignment,l);p.markers.arrival=m;p.markers.arrival.mode=type;p.markers.arrival.point=points[1]}p.leg=leg;this.layer.addPolyline(p,false);if(leg.interchange){var next=_response.trips.trip.legs[(l+1)];var nextPoints=mode==="lite"?next.points:this.response.trips.trip.legs[l+1].points;var ic=this.mdvMap.createPolyline(leg.interchange.path);colour=this.getLegColour(99);opacity=this.getLegOpacity(99);ic.add("colour",colour);ic.add("opacity",opacity);ic.add("weight",weight);ic.leg=leg;ic.isInterchange=true;var m=this.getMarker(99,"departure",coords[coords.length-1],alignment,l);ic.markers.departure=m;ic.markers.departure.mode=99;ic.markers.departure.point=points[1];var nextCoords=next.path.split(" ");nextCoords=nextCoords[0].split(",");var c=new MDVCoordinates(coords[coords.length-1].mapName,nextCoords[0],nextCoords[1]);m=this.getMarker(99,"arrival",c,alignment,l);ic.markers.arrival=m;ic.markers.arrival.mode=99;ic.markers.arrival.point=nextPoints[0];this.layer.addPolyline(ic,false);this.polylines.push(ic)}l++;leg=_response.trips.trip.legs[l]}}.bind(this);process=function(mode){createPath(mode);if(this.doBeautify){this.beautify()}this.processMarkers();this.mdvMap.update();this.processPolylines()}.bind(this);if(this.mdvMap.config.get("trips.useJsonForPath")!=="true"){if(this.response.trips.trip.legs.leg&&!this.response.trips.trip.legs.length){leg=this.response.trips.trip.legs.leg}else{if(this.response.trips.trip.legs.length){leg=this.response.trips.trip.legs[0]}}process("lite");return true}if(typeof jsonServerURL!=="undefined"){hostUrl=jsonServerURL}else{hostUrl=/^\/(?:[\w\-%]+\/)*(\w+)\??/.exec(window.location.pathname);hostUrl=hostUrl&&hostUrl[1]}_params={sessionID:this.tripParams.sessionId,requestID:this.tripParams.requestId,command:"tripCoordSeq:"+this.tripParams.tripIndex,filterEpsilon:this.tripParams.reductionList,output:"JSON"};if(typeof hostUrl==="string"){mdvLib.ajax({host:hostUrl,parameters:_params,onComplete:function(r){var _response=r.responseText||r;_response=_response.replace(/\.00000/gi,"");eval("this.responseJson = "+_response+";");if(!this.responseJson){return false}if(this.responseJson.trips.trip.legs.leg&&!this.responseJson.trips.trip.legs.length){leg=this.responseJson.trips.trip.legs.leg}else{if(this.responseJson.trips.trip.legs.length){leg=this.responseJson.trips.trip.legs[0]}}process("json")}.bind(this)})}else{}};MDVMapEFATrips.prototype.getMarker=function(b,d,c,g,f){var e="";if(b>=100&&this.imgs[b+"_"+d]&&this.imgs[b+"_"+d].complete){e=this.imgs[b+"_"+d]}else{if(this.imgs[b]){e=this.imgs[b]}else{e=this.imgs.stop}}var a=this.mdvMap.createMarker(c,g,e.src);return a};MDVMapEFATrips.prototype.updateWizard=function(){var a=this.polylines[0];for(var b=this.wizardScreenPlay.length;b>0;b--){this.wizardScreenPlay.pop()}if(a.markers.departure&&a.markers.departure.img&&a.markers.departure.img.toolTip){this.wizardScreenPlay.push({object:a.markers.departure,type:"marker",state:true,timeout:2200});this.wizardScreenPlay.push({object:a.markers.departure,type:"marker",state:false,timeout:50});this.wizardScreenPlay.push({object:a,type:"polyline",state:true,timeout:10})}for(var c=1;c<this.polylines.length;c++){if(a.isInterchange==null&&a.markers.arrival&&a.markers.arrival.img&&a.markers.arrival.img.toolTip){this.wizardScreenPlay.push({object:a.markers.arrival,type:"marker",state:true,timeout:2200});this.wizardScreenPlay.push({object:a.markers.arrival,type:"marker",state:false,timeout:50});var d=""}a=this.polylines[c];if(a.isInterchange==null&&a.markers.departure&&a.markers.departure.img&&a.markers.departure.img.toolTip){this.wizardScreenPlay.push({object:a.markers.departure,type:"marker",state:true,timeout:2200});this.wizardScreenPlay.push({object:a.markers.departure,type:"marker",state:false,timeout:50});var d=""}this.wizardScreenPlay.push({object:a,type:"polyline",state:true,timeout:10})}if(a.isInterchange==null&&a.markers.arrival&&a.markers.arrival.img&&a.markers.arrival.img.toolTip){this.wizardScreenPlay.push({object:a.markers.arrival,type:"marker",state:true,timeout:2200});this.wizardScreenPlay.push({object:a.markers.arrival,type:"marker",state:false,timeout:50});var d=""}return true};MDVMapEFATrips.prototype.beautify=function(){var m=this.mdvMap.getPolylineCoords();var e=m[0];var d=m[1];e.sort(MDVMap_NumSort);d.sort(MDVMap_NumSort);var l=e[e.length-1]-e[0];var h=d[d.length-1]-d[0];var u=parseInt(e[0])+Math.floor(0.5+l/2);var r=parseInt(d[0])+Math.floor(0.5+h/2);var k=new MDVCoordinates(this.mdvMap.config.get("mapName"),u,r);var a=0;var p=this.mdvMap.getViewportExtends();var q=this.mdvMap.config.getZoomLevels();for(var n=q.length-1;n>=0;n--){var c=q[n];var s=false;var b=false;var o=new MDVPoint(p.width/parseInt(c.get("tileSizeX")),p.height/parseInt(c.get("tileSizeY")));var t=new MDVPoint(c.get("numberOfTilesX"),c.get("numberOfTilesY"));var j=new MDVPoint(c.get("realWidth"),c.get("realHeight"));var f=new MDVPoint(Math.floor(0.5+j.x/t.x),Math.floor(0.5+j.y/t.y));var g=new MDVPoint(f.x*o.x,f.y*o.y);if(g.x>(l*1.15)&&!s){a=n;s=true}if(g.y>(h*1.15)&&!b){a=n;b=true}if(s&&b){break}}this.mdvMap.setCentre(k);this.mdvMap.setZoomLevel(a)};MDVMapEFATrips.prototype.processMarkers=function(){var h=0;var f=0;for(var b=0;b<this.response.parameters.length;b++){if(this.response.parameters[b].name=="sessionID"){h=this.response.parameters[b].value}if(this.response.parameters[b].name=="requestID"){f=this.response.parameters[b].value}}var d=new Array();for(var b=0;b<this.polylines.length;b++){var g=this.polylines[b];d.push([b,"departure",g.markers.departure]);d.push([b,"arrival",g.markers.arrival])}var a="";var j=new MDVPoint(220,124);if(this.mdvMap.config.get("trips.marker.size.width")&&this.mdvMap.config.get("trips.marker.size.height")){j=new MDVPoint(this.mdvMap.config.get("trips.marker.size.width"),this.mdvMap.config.get("trips.marker.size.height"))}for(var c=d.length-1;c>=0;c--){var e=d[c];var i="";if(e[2].point&&e[2].point.desc){i=e[2].point.desc}else{if(e[2].point&&e[2].point.name){i=e[2].point.name}}if(this.mdvMap.config.get("useBubbleForEFATrips")&&this.mdvMap.config.get("useBubbleForEFATrips")=="false"){e[2].setToolTip(this.mdvMap.createToolTip(i))}else{e[2].setToolTip(this.mdvMap.createToolTip(j,i))}this.layer.addMarker(e[2],false)}};MDVMapEFATrips.prototype.update=function(e,g,l){if(this.polylines.length<=0||this.zoomLevel==l.config.getZoomLevelIndex()){return false}var s=this.options.skipBoundaryCheck&&this.options.skipBoundaryCheck==true;this.zoomLevel=l.config.getZoomLevelIndex();for(var f=0;f<this.polylines.length;f++){if(this.polylines[f]&&this.polylines[f].markers.departure){this.polylines[f].markers.departure.visible=false}if(this.polylines[f]&&this.polylines[f].markers.arrival){this.polylines[f].markers.arrival.visible=false}for(var q=0;q<this.polylines[f].arrows.length;q++){this.layer.removePolyline(this.polylines[f].arrows[q]);if(this.polylines[f].arrows[q]){this.polylines[f].arrows[q].destroy()}}for(var q=0;q<this.polylines[f].directions.length;q++){this.layer.removeMarker(this.polylines[f].directions[q])}var c=25000;if(this.mdvMap.config.get("trips.polyline.arrows.maxScale")){c=parseInt(this.mdvMap.config.get("trips.polyline.arrows.maxScale"))}var t=this.mdvMap.config.getZoomLevel(this.zoomLevel);var u=t.getScale()<=c;if(this.mdvMap.config.get("useArrowsForEFATrips")&&this.mdvMap.config.get("useArrowsForEFATrips")=="true"&&u){this.polylines[f].arrows=this.polylines[f].getArrows();for(var q=0;q<this.polylines[f].arrows.length;q++){var j=q==this.polylines[f].arrows.length-1?true:false;this.layer.addPolyline(this.polylines[f].arrows[q],j)}}else{if(this.mdvMap.config.get("useDirectionsForEFATrips")&&this.mdvMap.config.get("useDirectionsForEFATrips")=="true"&&u){var b=this.polylines[f].getDirections();for(var n=0;n<b.length;n++){var j=n==b.length-1?true:false;this.layer.addMarker(b[n],j)}this.polylines[f].directions=b}}}if(this.polylines[0].markers.departure){this.polylines[0].markers.departure.setVisibility(true)}if(this.polylines[this.polylines.length-1].markers.arrival){this.polylines[this.polylines.length-1].markers.arrival.setVisibility(true)}for(var k=this.polylines.length-1;k>0;k--){var m=this.polylines[k];var h=this.polylines[k-1];if(!m||!h){continue}var o=[[k,"departure",m.markers.departure],[k,"arrival",h.markers.arrival]];o.sort(MDVMapEFATrips_PrioritySort);o[0][2].setVisibility(true);if(!o[1][2].intersects(o[0][2])||!o[0][2].isVisible()||s){o[1][2].setVisibility(true)}else{o[1][2].setVisibility(false)}}this.updateWizard();return true};MDVMapEFATrips.prototype.processPolylines=function(){for(var a=0;a<this.polylines.length;a++){var b=this.polylines[a];var e=b.leg.mode.desc;if(b.leg.interchange&&b.isInterchange){e=b.leg.interchange.desc}else{if(b.leg.mode.desc==""){e=b.leg.mode.type}}var c=new MDVPoint(220,150);if(this.mdvMap.config.get("trips.polyline.size.width")&&this.mdvMap.config.get("trips.polyline.size.height")){c=new MDVPoint(this.mdvMap.config.get("trips.polyline.size.width"),this.mdvMap.config.get("trips.polyline.size.height"))}if(this.mdvMap.config.get("useCanvasRenderer")!="true"){var d=null;if(this.mdvMap.config.get("useBubbleForEFATrips")&&this.mdvMap.config.get("useBubbleForEFATrips")=="false"){d=this.mdvMap.createToolTip(e)}else{d=this.mdvMap.createToolTip(c,e)}b.setToolTip(d,false)}b.element.mdvMap=this.mdvMap}};MDVMapEFATrips.prototype.getLegColour=function(b,a){if(this.mdvMap.config.get("motColour_"+b+"_"+a)){return this.mdvMap.config.get("motColour_"+b+"_"+a)}else{if(this.mdvMap.config.get("motColour_"+b)){return this.mdvMap.config.get("motColour_"+b)}}return"#FF0000"};MDVMapEFATrips.prototype.getLegOpacity=function(b,a){if(this.mdvMap.config.get("motOpacity_"+b+"_"+a)){return this.mdvMap.config.get("motOpacity_"+b+"_"+a)}else{if(this.mdvMap.config.get("motOpacity_"+b)){return this.mdvMap.config.get("motOpacity_"+b)}else{if(this.mdvMap.config.get("trips.polyline.opacity")){return this.mdvMap.config.get("trips.polyline.opacity")}else{return"0.5"}}}};MDVMapEFATrips.prototype.launchWizard=function(b){mdvTimer.remove(this.wizardJobID);this.mdvMap.stepPx=4;this.mdvMap.stepTime=40;this.mdvMap.cancelMoveBySeq();this.wizardJobID=null;var a=this.mdvMap.config.getZoomLevel(b);if(a){if(a.get("trace.step.px")){this.mdvMap.stepPx=parseInt(a.get("trace.step.px"))}if(a.get("trace.step.time")){this.mdvMap.stepTime=parseInt(a.get("trace.step.time"))}}if(this.polylines.length>0){if(b>=0){this.mdvMap.setZoomLevel(b)}this.mdvMap.setCentre(this.polylines[0].getAllCoords()[0].clone());this.mdvMap.update()}this.wizardIndex=0;this.wizardJobID=mdvTimer.add(1,this,this.wizardRun,[null,null,null])};MDVMapEFATrips.prototype.wizardRun=function(f,e,c){var a=this.wizardScreenPlay[this.wizardIndex];this.wizardIndex++;if(f==MDVEvent_ROUTE_TRACE_FINISHED){this.mdvMap.events.deregisterEvent(MDVEvent_ROUTE_TRACE_FINISHED,this,this.wizardRun)}if(a){switch(a.type){case"marker":if(a.state){a.object.toolTip.display()}else{a.object.toolTip.hide()}this.wizardJobID=mdvTimer.add(a.timeout,this,this.wizardRun,[null,null,null]);break;default:this.mdvMap.events.registerEvent(MDVEvent_ROUTE_TRACE_FINISHED,this,this.wizardRun);var b=a.object.getAllCoords();var d=null;if(a.object&&a.object.isInterchange){d=this.imgs["99_follow"].src}else{if(a.object.leg.mode.type&&this.imgs[a.object.leg.mode.type+"_follow"]){d=this.imgs[a.object.leg.mode.type+"_follow"].src}}this.mdvMap.wizardSetMotIcon(d);this.wizardJobID=mdvTimer.add(a.timeout,this,this.wizardMoveBySeq,[b]);break}}};MDVMapEFATrips.prototype.wizardMoveBySeq=function(b,a){this.mdvMap.moveBySeq(b,a)};function MDVMapEFATrips_onAjaxComplete(request){var efa;var json=null;var mdvMapName="";if(request&&request.responseText){json=request.responseText}else{if(request){json=request}}eval("efa = "+json+";");if(efa&&efa.parameters){for(var i=0;i<efa.parameters.length;i++){if(efa.parameters[i].name=="mdvMapName"){mdvMapName=efa.parameters[i].value;break}}}if(document.mdvMaps["mdvMap_"+mdvMapName]){document.mdvMaps["mdvMap_"+mdvMapName].events.triggerEvent(MDVEvent_AJAX_CALLBACK,"MDVMapEFATrips",efa)}}function MDVMapEFATrips_PrioritySort(d,c){return MDVMapEFATrips_GetPrority(d)-MDVMapEFATrips_GetPrority(c)}function MDVMapEFATrips_GetPrority(a){if(a[1]=="departure"&&a[2].mode>0&&a[2].mode<96){return 10}else{if(a[1]=="arrival"&&a[2].mode>0&&a[2].mode<96){return 20}else{if(a[1]=="departure"&&a[2].mode>100){return 30}else{if(a[1]=="arrival"&&a[2].mode>100){return 40}else{if(a[1]=="departure"&&a[2].mode==100){return 50}else{if(a[1]=="arrival"&&a[2].mode==100){return 60}else{return 1000}}}}}}}function MDVMapContextMenu(a,b){if(!a){return}this.name="MapContextMenu";this.mdvMap=a;this.mdvMap.registerGadget(this);this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,this,this.zoomLevelChange);this.contextMenu=b;for(var c=0;c<this.contextMenu.div.childNodes.length;c++){if(this.contextMenu.div.childNodes[c]){this.contextMenu.div.childNodes[c].mdvMap=this.mdvMap}}var d=false;document.body.contextMenu=this;this.contextMenu.div.onmousedown=function(){d=true};document.body.onmousedown=function(f){f=f?f:window.event;if(this.contextMenu&&this.contextMenu.contextMenu&&!d){this.contextMenu.contextMenu.div.style.display="none"}d=false};this.contextMenu.div.oncontextmenu=function(){return false};for(var e in MDVGadgetBase.prototype){if(!MDVMapContextMenu.prototype[e]){MDVMapContextMenu.prototype[e]=MDVGadgetBase.prototype[e]}}}MDVMapContextMenu.prototype.destroy=function(){if(this.mdvMap){this.mdvMap=null}for(var a=0;a<this.contextMenu.div.childNodes.length;a++){if(this.contextMenu.div.childNodes[a]&&this.contextMenu.div.childNodes[a].mdvMap){this.contextMenu.div.childNodes[a].mdvMap=null}}this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null};MDVMapContextMenu.prototype.oncontextmenu=function(i){i=i?i:window.event;var b=document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;var f=document.body.scrollLeft?document.body.scrollLeft:document.documentElement.scrollLeft;var m=i.clientX+f;var k=i.clientY+b;var d=i.pageX||(i.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var c=i.pageY||(i.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var o=0;var j=0;var g=this.mdvMap.viewport;while(g){o+=g.offsetLeft;j+=g.offsetTop;g=g.offsetParent}d=d-o-3;c=c-j-3;if(this.mdvMap.config.get("contextMenu.size.width")&&this.mdvMap.config.get("contextMenu.size.height")){var a=parseInt(this.mdvMap.config.get("contextMenu.size.width"));var n=parseInt(this.mdvMap.config.get("contextMenu.size.height"));if(c+n>this.mdvMap.viewport.offsetHeight&&d+a>this.mdvMap.viewport.offsetWidth){m=m-a;k=k-n}else{if(d+a>this.mdvMap.viewport.offsetWidth){m=m-a}else{if(c+n>this.mdvMap.viewport.offsetHeight){k=k-n}}}this.contextMenu.div.style.width=a+"px";this.contextMenu.div.style.height=n+"px"}this.contextMenu.div.style.display="none";this.contextMenu.div.style.left=m+"px";this.contextMenu.div.style.top=k+"px";this.contextMenu.div.style.display="block";var l=new MDVPoint(d,c);var h=this.mdvMap.getCoordinates(l);this.mdvMap.events.triggerEvent(MDVEvent_CONTEXT_MENU,true,h);return false};MDVMapContextMenu.prototype.hideContextMenu=function(){this.contextMenu.div.style.display="none";this.mdvMap.events.triggerEvent(MDVEvent_CONTEXT_MENU,false,null)};MDVMapContextMenu.prototype.onmousedown=function(a){a=a?a:window.event;if(a==null||a.button!=2){this.hideContextMenu()}this.stopEvent(a);return true};MDVMapContextMenu.prototype.zoomLevelChange=function(c,a,b){this.onmousedown(null)};function MDVMapMenu(d){this.menuItems=d;var f=document.createElement("div");f.className="mapContextMenu";document.body.appendChild(f);f.style.cursor="default";for(var c=0;c<this.menuItems.length;c++){if(this.menuItems[c].func){var e=document.createElement("div");e.className="mapContextMenuItem";e.onmouseover=function(){this.className="mapContextMenuItem_active";f.style.cursor="pointer"};e.onmouseout=function(){this.className="mapContextMenuItem";f.style.cursor="default"};e.onclick=this.menuItems[c].func;e.onmouseup=a;var b=document.createTextNode(" "+this.menuItems[c].description+" ");e.appendChild(b);f.appendChild(e)}else{var e=document.createElement("hr");f.appendChild(e)}}function a(){f.style.display="none"}this.div=f}function MDVMapMenuItem(b,a){this.description=b;if(a){this.func=a}}function MDVMapControl(a){if(!a){return}this.name="MapControl";this.mdvMap=a;this.origin=null;this.zoomLevel=null;this.images=new Array();this.images.top_normal=new Image();this.images.top_hover=new Image();this.images.left_normal=new Image();this.images.left_hover=new Image();this.images.centre_normal=new Image();this.images.centre_hover=new Image();this.images.right_normal=new Image();this.images.right_hover=new Image();this.images.bottom_normal=new Image();this.images.bottom_hover=new Image();this.images.zoomIn_normal=new Image();this.images.zoomIn_hover=new Image();this.images.zoomOut_normal=new Image();this.images.zoomOut_hover=new Image();this.images.zoomLevel_normal=new Image();this.images.zoomLevel_hover=new Image();this.images.zoomLevel_active=new Image();this.images.transparent=new Image();this.images.spacer=new Image();this.text=new Array();this.text.goNorth="Go north";this.text.goWest="Go west";this.text.goEast="Go east";this.text.goSouth="Go south";this.text.lastResult="Last result";this.text.zoomIn="Zoom in";this.text.zoomOut="Zoom out";if(arguments.length==2&&arguments[1]){this.text=arguments[1]}this.mapControl=null;this.arrowContainer=null;this.zoomContainer=null;this.mdvMap.registerGadget(this);for(var b in MDVGadgetBase.prototype){if(!MDVMapControl.prototype[b]){MDVMapControl.prototype[b]=MDVGadgetBase.prototype[b]}}this.mdvMap.events.registerEvent(MDVEvent_INITIALISED,this,this.execute);this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,this,this.update)}MDVMapControl.prototype.preloadImgs=function(){var a="images/";if(this.mdvMap.config.get("imagePath")){a=this.mdvMap.config.get("imagePath")}var b=a+"MDVMapControl/";if(this.mdvMap.config.get("imagePath.mapControl")){b=this.mdvMap.config.get("imagePath.mapControl")}this.images.top_normal.src=b+"topNormal.gif";this.images.top_normal.alt=this.text.goNorth;this.images.top_normal.title=this.images.top_normal.alt;this.images.top_hover.src=b+"topHover.gif";this.images.top_hover.alt=this.images.top_normal.alt;this.images.top_hover.title=this.images.top_normal.alt;this.images.left_normal.src=b+"leftNormal.gif";this.images.left_normal.alt=this.text.goWest;this.images.left_normal.title=this.images.left_normal.alt;this.images.left_hover.src=b+"leftHover.gif";this.images.left_hover.alt=this.images.left_normal.alt;this.images.left_hover.title=this.images.left_normal.alt;this.images.centre_normal.src=b+"centreNormal.gif";this.images.centre_normal.alt=this.text.lastResult;this.images.centre_normal.title=this.images.centre_normal.alt;this.images.centre_hover.src=b+"centreHover.gif";this.images.centre_hover.alt=this.images.centre_normal.alt;this.images.centre_hover.title=this.images.centre_normal.alt;this.images.right_normal.src=b+"rightNormal.gif";this.images.right_normal.alt=this.text.goEast;this.images.right_normal.title=this.images.right_normal.alt;this.images.right_hover.src=b+"rightHover.gif";this.images.right_hover.alt=this.images.right_normal.alt;this.images.right_hover.title=this.images.right_normal.alt;this.images.bottom_normal.src=b+"bottomNormal.gif";this.images.bottom_normal.alt=this.text.goSouth;this.images.bottom_normal.title=this.images.bottom_normal.alt;this.images.bottom_hover.src=b+"bottomHover.gif";this.images.bottom_hover.alt=this.images.bottom_normal.alt;this.images.bottom_hover.title=this.images.bottom_normal.alt;this.images.zoomIn_normal.src=b+"zoomInNormal.gif";this.images.zoomIn_normal.alt=this.text.zoomIn;this.images.zoomIn_normal.title=this.images.zoomIn_normal.alt;this.images.zoomIn_hover.src=b+"zoomInHover.gif";this.images.zoomIn_hover.alt=this.images.zoomIn_normal.alt;this.images.zoomIn_hover.title=this.images.zoomIn_normal.alt;this.images.zoomOut_normal.src=b+"zoomOutNormal.gif";this.images.zoomOut_normal.alt=this.text.zoomOut;this.images.zoomOut_normal.title=this.images.zoomOut_normal.alt;this.images.zoomOut_hover.src=b+"zoomOutHover.gif";this.images.zoomOut_hover.alt=this.images.zoomOut_normal.alt;this.images.zoomOut_hover.title=this.images.zoomOut_normal.alt;this.images.zoomLevel_normal.src=b+"zoomLevelNormal.gif";this.images.zoomLevel_active.src=b+"zoomLevelActive.gif";this.images.zoomLevel_hover.src=b+"zoomLevelHover.gif";this.images.transparent.src=b+"transparent.gif";this.images.spacer.src=b+"spacer.gif"};MDVMapControl.prototype.createDiv=function(){var a=document.createElement("div");return a};MDVMapControl.prototype.execute=function(){this.preloadImgs();this.origin=new MDVCoordinates(this.mdvMap.config.get("mapName"),parseInt(this.mdvMap.config.get("xCenterReal")),parseInt(this.mdvMap.config.get("yCenterReal")));this.zoomLevel=this.mdvMap.config.get("defaultScale");this.mapControl=this.createDiv();this.mapControl.className="MDVMapControl";this.mdvMap.viewport.appendChild(this.mapControl);this.arrowContainer=this.createDiv();this.zoomContainer=this.createDiv();this.zoomContainer.className="MDVMapControl_ZoomLevels";this.zoomLevels=new Array();this.mapControl.appendChild(this.arrowContainer);this.mapControl.appendChild(this.zoomContainer);this.populateContainers();this.update()};MDVMapControl.prototype.destroy=function(){if(this.mdvMap){this.mdvMap=null}for(var c=0;c<this.arrowContainer.childNodes.length;c++){for(var d=0;d<this.arrowContainer.childNodes[c].childNodes.length;d++){for(var b=0;b<this.arrowContainer.childNodes[c].childNodes[d].childNodes.length;b++){if(this.arrowContainer.childNodes[c].childNodes[d].childNodes[b].mdvMap){this.arrowContainer.childNodes[c].childNodes[d].childNodes[b].mdvMap=null}if(this.arrowContainer.childNodes[c].childNodes[d].childNodes[b].normal){this.arrowContainer.childNodes[c].childNodes[d].childNodes[b].normal=null}if(this.arrowContainer.childNodes[c].childNodes[d].childNodes[b].hover){this.arrowContainer.childNodes[c].childNodes[d].childNodes[b].hover=null}}}}for(var c=0;c<this.zoomContainer.childNodes.length;c++){for(var b=0;b<this.zoomContainer.childNodes[c].childNodes.length;b++){var a=this.zoomContainer.childNodes[c].childNodes[b];a.onmouseover=null;a.onmouseout=null;a.onclick=null;a.hover=null;a.normal=null;if(a.mdvMap){a.mdvMap=null}}}this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null;if(this.arrowContainer){this.arrowContainer.onmouseover=null;this.arrowContainer.onmouseout=null;this.arrowContainer.onclick=null;this.arrowContainer=null}if(this.zoomContainer){this.zoomContainer.onmouseover=null;this.zoomContainer.onmouseout=null;this.zoomContainer.onclick=null;this.zoomContainer=null}if(this.mapControl){this.mapControl.onmouseover=null;this.mapControl.onmouseout=null;this.mapControl.onclick=null;this.mapControl=null}};MDVMapControl.prototype.setZoomLevel=function(a){if(this.mdvMap.config.getZoomLevel(a)){this.zoomLevel=a;return true}return false};MDVMapControl.prototype.setOriginCoords=function(a){if(a&&a.x&&a.y&&a.mapName){this.origin=a;return true}return false};MDVMapControl.prototype.populateContainers=function(){if(!this.arrowContainer||!this.zoomContainer){return false}var a=this.createDiv();var h=this.createDiv();var l=this.createDiv();this.arrowContainer.appendChild(a);this.arrowContainer.appendChild(h);this.arrowContainer.appendChild(l);var g=this.createDiv();g.className="MDVMapControl_Arrow";arrowImg_1_1=this.createImage();arrowImg_1_1.src=this.images.transparent.src;g.appendChild(arrowImg_1_1);var t=this.createDiv();t.className="MDVMapControl_Arrow";arrowImg_2_1=this.createImage();arrowImg_2_1.hover=this.images.top_hover;arrowImg_2_1.normal=this.images.top_normal;arrowImg_2_1.alt=this.images.top_normal.alt;arrowImg_2_1.title=this.images.top_normal.title;arrowImg_2_1.onclick=this.goNorth;arrowImg_2_1.src=this.images.top_normal.src;t.appendChild(arrowImg_2_1);var m=this.createDiv();m.className="MDVMapControl_Arrow";arrowImg_3_1=this.createImage();arrowImg_3_1.src=this.images.transparent.src;m.appendChild(arrowImg_3_1);a.appendChild(g);a.appendChild(t);a.appendChild(m);var f=this.createDiv();f.className="MDVMapControl_Arrow";arrowImg_1_2=this.createImage();arrowImg_1_2.hover=this.images.left_hover;arrowImg_1_2.normal=this.images.left_normal;arrowImg_1_2.alt=this.images.left_normal.alt;arrowImg_1_2.title=this.images.left_normal.title;arrowImg_1_2.onclick=this.goEast;arrowImg_1_2.src=this.images.left_normal.src;f.appendChild(arrowImg_1_2);var r=this.createDiv();r.className="MDVMapControl_Arrow MDVMapControl_Arrow_LastResult";arrowImg_2_2=this.createImage();arrowImg_2_2.hover=this.images.centre_hover;arrowImg_2_2.normal=this.images.centre_normal;arrowImg_2_2.alt=this.images.centre_normal.alt;arrowImg_2_2.title=this.images.centre_normal.title;arrowImg_2_2.onclick=this.goBack;arrowImg_2_2.mapControl=this;arrowImg_2_2.src=this.images.centre_normal.src;r.appendChild(arrowImg_2_2);var k=this.createDiv();k.className="MDVMapControl_Arrow";arrowImg_3_2=this.createImage();arrowImg_3_2.hover=this.images.right_hover;arrowImg_3_2.normal=this.images.right_normal;arrowImg_3_2.alt=this.images.right_normal.alt;arrowImg_3_2.title=this.images.right_normal.title;arrowImg_3_2.onclick=this.goWest;arrowImg_3_2.src=this.images.right_normal.src;k.appendChild(arrowImg_3_2);h.appendChild(f);h.appendChild(r);h.appendChild(k);var e=this.createDiv();e.className="MDVMapControl_Arrow";arrowImg_1_3=this.createImage();arrowImg_1_3.src=this.images.transparent.src;e.appendChild(arrowImg_1_3);var q=this.createDiv();q.className="MDVMapControl_Arrow";arrowImg_2_3=this.createImage();arrowImg_2_3.hover=this.images.bottom_hover;arrowImg_2_3.normal=this.images.bottom_normal;arrowImg_2_3.alt=this.images.bottom_normal.alt;arrowImg_2_3.title=this.images.bottom_normal.title;arrowImg_2_3.onclick=this.goSouth;arrowImg_2_3.src=this.images.bottom_normal.src;q.appendChild(arrowImg_2_3);var i=this.createDiv();i.className="MDVMapControl_Arrow";arrowImg_3_3=this.createImage();arrowImg_3_3.src=this.images.transparent.src;i.appendChild(arrowImg_3_3);l.appendChild(e);l.appendChild(q);l.appendChild(i);var d=this.createDiv();d.className="MDVMapControl_Arrow";arrowImg_spacer=this.createImage();arrowImg_spacer.style.height="20px";arrowImg_spacer.src=this.images.spacer.src;d.appendChild(arrowImg_spacer);this.zoomContainer.appendChild(d);var s=this.createDiv();s.className="MDVMapControl_Zoom";zoomInImg=this.createImage();zoomInImg.hover=this.images.zoomIn_hover;zoomInImg.normal=this.images.zoomIn_normal;zoomInImg.alt=this.images.zoomIn_normal.alt;zoomInImg.title=this.images.zoomIn_normal.title;zoomInImg.src=this.images.zoomIn_normal.src;zoomInImg.onclick=this.zoomIn;s.appendChild(zoomInImg);this.zoomContainer.appendChild(s);var o=10;if(this.mdvMap.config.get("control.spacer.height")){o=parseInt(this.mdvMap.config.get("control.spacer.height"))}var d=this.createDiv();d.className="MDVMapControl_Arrow";arrowImg_spacer=this.createImage();arrowImg_spacer.style.height=o+"px";arrowImg_spacer.src=this.images.spacer.src;d.appendChild(arrowImg_spacer);this.zoomContainer.appendChild(d);var u=0;var c=this.mdvMap.config.getZoomLevels();if(c){u=c.length}for(var j=0;j<u;j++){var b=c[u-j-1];if(b){var p=this.createDiv();p.className="MDVMapControl_ZoomLevel";tmpZLImg=this.createImage();tmpZLImg.level=b.level;tmpZLImg.hover=this.images.zoomLevel_hover;tmpZLImg.normal=this.images.zoomLevel_normal;tmpZLImg.src=this.images.zoomLevel_normal.src;tmpZLImg.alt="1:"+parseInt(b.getScale(),10);tmpZLImg.title=tmpZLImg.alt;tmpZLImg.onclick=MDVMapControl_onclick;p.appendChild(tmpZLImg);this.zoomContainer.appendChild(p);this.zoomLevels.push(tmpZLImg)}}var n=this.createDiv();n.className="MDVMapControl_Zoom";zoomOutImg=this.createImage();zoomOutImg.hover=this.images.zoomOut_hover;zoomOutImg.normal=this.images.zoomOut_normal;zoomOutImg.alt=this.images.zoomOut_normal.alt;zoomOutImg.title=this.images.zoomOut_normal.title;zoomOutImg.src=this.images.zoomOut_normal.src;zoomOutImg.onclick=this.zoomOut;n.appendChild(zoomOutImg);this.zoomContainer.appendChild(n);return true};MDVMapControl.prototype.createImage=function(){var a=new Image();a.mdvMap=this.mdvMap;a.hover=null;a.normal=null;a.onmouseover=MDVMapControl_onmouseover;a.onmouseout=MDVMapControl_onmouseout;a.onclick=MDVMapControl_onclick;a.ondragstart=new Function([],"var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;");return a};MDVMapControl.prototype.update=function(){if(!this.zoomLevels){return false}var c=this.mdvMap.config.getZoomLevelIndex();var a=this.zoomLevels.length;for(var b=0;b<a;b++){if(this.zoomLevels[b].level==c){this.zoomLevels[b].src=this.images.zoomLevel_active.src;this.zoomLevels[b].hover=this.images.zoomLevel_active;this.zoomLevels[b].normal=this.images.zoomLevel_active}else{this.zoomLevels[b].src=this.images.zoomLevel_normal.src;this.zoomLevels[b].hover=this.images.zoomLevel_hover;this.zoomLevels[b].normal=this.images.zoomLevel_normal}}return true};MDVMapControl.prototype.zoomIn=function(){var a=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);if(a!=null){this.mdvMap.setZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);this.mdvMap.update()}return true};MDVMapControl.prototype.zoomOut=function(){var a=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())-1);if(a!=null){this.mdvMap.setZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())-1);this.mdvMap.update()}return true};MDVMapControl.prototype.goEast=function(){var b=this.mdvMap.viewportRealWidth*0.6;var a=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);a.x=a.x-Math.floor(b+0.5);this.mdvMap.setCentre(a);this.mdvMap.update();return true};MDVMapControl.prototype.goWest=function(){var b=this.mdvMap.viewportRealWidth*0.6;var a=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);a.x=a.x+Math.floor(b+0.5);this.mdvMap.setCentre(a);this.mdvMap.update();return true};MDVMapControl.prototype.goNorth=function(){var a=this.mdvMap.viewportRealHeight*0.6;var b=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);b.y=b.y-Math.floor(a+0.5);this.mdvMap.setCentre(b);this.mdvMap.update();return true};MDVMapControl.prototype.goSouth=function(){var a=this.mdvMap.viewportRealHeight*0.6;var b=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);b.y=b.y+Math.floor(a+0.5);this.mdvMap.setCentre(b);this.mdvMap.update();return true};MDVMapControl.prototype.goBack=function(){this.mdvMap.setZoomLevel(this.mapControl.zoomLevel);this.mdvMap.setCentre(this.mapControl.origin);this.mdvMap.update()};function MDVMapControl_onmouseover(a){if(this.hover&&this.hover.src){this.src=this.hover.src;this.style.cursor="pointer"}return true}function MDVMapControl_onmouseout(a){if(this.normal&&this.normal.src){this.src=this.normal.src;this.style.cursor="auto"}return true}function MDVMapControl_onclick(a){if(this.level!==undefined){var b=this.mdvMap.config.getZoomLevel(this.level);if(b!=null){this.mdvMap.setZoomLevel(this.level);this.mdvMap.update()}}return true}function MDVMapZoomBar(a){this.mdvMap=a;this.zoomBars=new Array();this.zoomImg=null;for(var b in MDVGadgetBase.prototype){if(!MDVMapZoomBar.prototype[b]){MDVMapZoomBar.prototype[b]=MDVGadgetBase.prototype[b]}}this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.preloadImgs);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.update)}MDVMapZoomBar.prototype.preloadImgs=function(){if(this.zoomImg){return false}var b=this.mdvMap.config.getZoomLevels();var a="";if(this.mdvMap.config.get("serverURL")){a=this.mdvMap.config.get("serverURL")}else{this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to find serverURL.");return false}for(var c=0;c<b.length;c++){this.zoomBars[b[c].level]=new Image();this.zoomBars[b[c].level].src=a+"zoomlevel"+b[c].level+"/ZoomBar_"+b[c].level+".gif"}this.zoomImg=document.createElement("img");this.zoomImg.className="MDVMap_ScaleBar";this.zoomImg.src=this.zoomBars[this.mdvMap.config.getZoomLevelIndex()].src;this.mdvMap.viewport.appendChild(this.zoomImg);return true};MDVMapZoomBar.prototype.update=function(){if(this.zoomBars[this.mdvMap.config.getZoomLevelIndex()]==null){this.mdvMap.events.triggerEvent(MDVEvent_WARNING,"MDVMap wasn't able to load appropriate zoom bar image.");this.zoomImg.style.visibility="hidden";return false}this.zoomImg.style.visibility="visible";this.zoomImg.src=this.zoomBars[this.mdvMap.config.getZoomLevelIndex()].src;return true};MDVMapZoomBar.prototype.destroy=function(){if(this.mdvMap){this.mdvMap=null}this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null;for(var a=0;a<this.zoomBars.length;a++){this.zoomBars[a].onload=null;this.zoomBars[a].onerror=null;this.zoomBars[a].available=null}};function MDVMapSync(a,c){this.mdvMap=a;this.mdvMiniMap=c;this.active=true;this.lastMap=null;this.lastMiniMap=null;for(var b in MDVGadgetBase.prototype){if(!MDVMapSync.prototype[b]){MDVMapSync.prototype[b]=MDVGadgetBase.prototype[b]}}this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.updateMiniMap);this.mdvMiniMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.updateMap)}MDVMapSync.prototype.updateMiniMap=function(c,b,a){if(this.mdvMap.state!=1||this.mdvMiniMap.state!=1||!this.isActive()){return false}if(this.lastMiniMap&&this.lastMiniMap.centre.equals(a.getCentre())&&this.lastMiniMap.zoomLevel==a.config.getZoomLevelIndex()){return false}this.mdvMiniMap.setCentre(a.getCentre().clone());this.mdvMiniMap.setZoomLevel(a.config.getZoomLevelIndex());this.lastMiniMap={centre:this.mdvMiniMap.getCentre(),zoomLevel:this.mdvMiniMap.config.getZoomLevelIndex()};return this.mdvMiniMap.update()};MDVMapSync.prototype.updateMap=function(c,a,b){if(this.mdvMap.state!=1||this.mdvMiniMap.state!=1||!this.isActive()){return false}if(this.lastMap&&this.lastMap.centre.equals(b.getCentre())&&this.lastMap.zoomLevel==b.config.getZoomLevelIndex()){return false}this.mdvMap.setCentre(b.getCentre().clone());this.mdvMap.setZoomLevel(b.config.getZoomLevelIndex());this.lastMap={centre:this.mdvMap.getCentre(),zoomLevel:this.mdvMap.config.getZoomLevelIndex()};return this.mdvMap.update()};function MDVMapSyncBound(a,c){for(var b in MDVGadgetBase.prototype){if(!MDVMapSync.prototype[b]){MDVMapSync.prototype[b]=MDVGadgetBase.prototype[b]}}for(var b in MDVMapSync.prototype){if(!MDVMapSyncBound.prototype[b]){MDVMapSyncBound.prototype[b]=MDVMapSync.prototype[b]}}this.mdvMap=a;this.mdvMiniMap=c;this.active=true;this.lastMap=null;this.lastMiniMap=null;this.border=null;this.inner=null;this.bounds=null;this.mouseDown=false;this.last=null;this.stepTime=40;this.stepPx=4;this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.updateMiniMap);this.mdvMap.events.registerEvent(MDVEvent_ROUTE_TRACE_FINISHED,this,this.onTraceFinished);this.mdvMap.events.registerEvent(MDVEvent_CENTRE_CHANGED,this,this.onCentreChanged);this.mdvMiniMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.updateMap);this.mdvMiniMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.update);this.update()}MDVMapSyncBound.prototype.update=function(){if(this.mdvMap.state!=1||this.mdvMiniMap.state==-1){return false}if(!this.border){this.border=document.createElement("div");this.border.className="MDVMapSync_Outer";this.border.style.zIndex="150";this.border.style.position="absolute";this.border.setAttribute("unselectable","on");this.inner=document.createElement("div");this.inner.setAttribute("unselectable","on");this.inner.className="MDVMapSync_Inner";this.bounds=document.createElement("div");this.bounds.style.position="absolute";this.bounds.style.zIndex="140";this.bounds.className="MDVMapSync_Outer";this.bounds.setAttribute("unselectable","on");this.mdvMiniMap.viewport.appendChild(this.bounds);this.border.appendChild(this.inner);this.mdvMiniMap.viewport.appendChild(this.border);this.border.ondragstart=function(c){var c=c?c:event;c.cancelBubble=true;c.returnValue=false;return false};this.inner.ondragstart=function(c){var c=c?c:event;c.cancelBubble=true;c.returnValue=false;return false};this.bounds.ondragstart=function(c){var c=c?c:event;c.cancelBubble=true;c.returnValue=false;return false};this.border.mdvMap=this.mdvMap;this.border.mdvSyncBound=this;this.border.onmousedown=MDVMapSyncBound_onmousedown;this.border.onmouseup=MDVMapSyncBound_onmouseup;this.border.onmousemove=MDVMapSyncBound_onmousemove;this.border.onmousewheel=MDVMap_onmousewheel;if(window.addEventListener&&navigator.product&&navigator.product=="Gecko"){this.border.addEventListener("DOMMouseScroll",MDVMap_onmousewheel,false)}}var a=this.mdvMiniMap.getPoint(this.mdvMap.tlReal);a=this.getAbsolutePoint(a);this.border.style.left=a.x+"px";this.border.style.top=a.y+"px";this.bounds.style.left=a.x+"px";this.bounds.style.top=a.y+"px";var b=this.mdvMap.getViewportRealExtends();b=this.getExtends(b);this.inner.style.width=b.width+"px";this.inner.style.height=b.height+"px";this.bounds.style.width=b.width+"px";this.bounds.style.height=b.height+"px";return true};MDVMapSyncBound.prototype.getAbsolutePoint=function(a){var b=new MDVPoint(parseInt(this.mdvMiniMap.getMapper().style.left),parseInt(this.mdvMiniMap.getMapper().style.top));a.x+=b.x;a.y+=b.y;return a};MDVMapSyncBound.prototype.getExtends=function(d){var f=this.mdvMiniMap.config.getZoomLevel(this.mdvMiniMap.config.getZoomLevelIndex());var a=parseInt(f.get("tileSizeX"))*parseInt(f.get("numberOfTilesX"));var c=a/parseInt(f.get("realWidth"));var e=parseInt(f.get("tileSizeY"))*parseInt(f.get("numberOfTilesY"));var b=e/parseInt(f.get("realHeight"));var d={width:Math.floor(0.5+(d.width*c)),height:Math.floor(0.5+(d.height*b))};return d};MDVMapSyncBound.prototype.setMouseDown=function(a){this.mouseDown=a};MDVMapSyncBound.prototype.isMouseDown=function(){return this.mouseDown};MDVMapSyncBound.prototype.apply=function(){var c=new MDVPoint(this.bounds.style.left,this.bounds.style.top);var k=new MDVPoint(this.border.style.left,this.border.style.top);var h=new MDVPoint(k.x-c.x,k.y-c.y);if(this.mdvMap.cancelMoveBySeq()){this.update()}this.setActive(false);this.centre=null;this.stepTime=this.mdvMap.stepTime;this.stepPx=this.mdvMap.stepPx;var b=this.mdvMiniMap.config.getZoomLevel(this.mdvMiniMap.config.getZoomLevelIndex());var f=parseInt(b.get("tileSizeX"))*parseInt(b.get("numberOfTilesX"));var e=parseInt(b.get("realWidth"))/f;var a=parseInt(b.get("tileSizeY"))*parseInt(b.get("numberOfTilesY"));var d=parseInt(b.get("realHeight"))/a;var i=this.mdvMiniMap.getCentre().clone();i.x+=Math.floor(0.5+h.x*e);i.y+=Math.floor(0.5+h.y*d);var g=this.mdvMap.getCentre().clone();var j=[g,i];this.mdvMap.stepTime=20;this.mdvMap.stepPx=15;this.mdvMap.moveBySeq(j,null,false);this.last=null;return true};MDVMapSyncBound.prototype.onTraceFinished=function(c,b,a){this.centre=null;this.mdvMap.stepTime=this.stepTime;this.mdvMap.stepPx=this.stepPx;this.setActive(true);this.updateMiniMap(-1,"",this.mdvMap)};MDVMapSyncBound.prototype.onCentreChanged=function(e,d,b){if(this.isActive()){return false}var c=new MDVPoint(parseInt(this.bounds.style.width)/2,parseInt(this.bounds.style.height)/2);var a=this.mdvMiniMap.getPoint(b);a=this.getAbsolutePoint(a);a.x-=c.x;a.y-=c.y;this.bounds.style.left=a.x+"px";this.bounds.style.top=a.y+"px";return true};function MDVMapSyncBound_onmousedown(a){this.mdvSyncBound.setMouseDown(true)}function MDVMapSyncBound_onmouseup(a){this.mdvSyncBound.setMouseDown(false);this.mdvSyncBound.apply();this.mdvMap.viewport.focus()}function MDVMapSyncBound_onmousemove(i){if(this.mdvSyncBound.isMouseDown()){i=i?i:window.event;var g=i.pageX||(i.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var c=i.pageY||(i.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var b=0;var f=0;var h=this.mdvMap.viewport;while(h){b+=h.offsetLeft;f+=h.offsetTop;h=h.offsetParent}g=g-(b);c=c-(f);var d=new MDVPoint(g,c);if(this.mdvSyncBound.last!=null){var a=new MDVPoint(d.x-this.mdvSyncBound.last.x,d.y-this.mdvSyncBound.last.y);this.mdvSyncBound.border.style.left=parseInt(this.mdvSyncBound.border.style.left)+a.x+"px";this.mdvSyncBound.border.style.top=parseInt(this.mdvSyncBound.border.style.top)+a.y+"px"}this.mdvSyncBound.last=d.clone()}return false}function MDVMapEFAInfoEx(a){this.mdvMap=a;this.name="MapEFAInfo";this.stops=null;this.poi=null;this.centre=null;this.id=null;this.options=[];this.lastCentre=null;this.boundLayers=[];this.stopImg=new Image();this.mot1Img=new Image();this.mot2Img=new Image();this.mot3Img=new Image();this.mot4Img=new Image();this.mot5Img=new Image();this.mot6Img=new Image();this.mot7Img=new Image();this.mot8Img=new Image();this.mot9Img=new Image();this.mot10Img=new Image();this.mot11Img=new Image();this.mot12Img=new Image();this.poiImg=new Image();this.entranceImg=new Image();this.pointImg=new Image();this.letters=new Array();this.letters["0"]=new Image();this.letters["1"]=new Image();this.letters["2"]=new Image();this.letters["3"]=new Image();this.letters["4"]=new Image();this.letters["5"]=new Image();this.letters["6"]=new Image();this.letters["7"]=new Image();this.letters["8"]=new Image();this.letters["9"]=new Image();this.letters.A=new Image();this.letters.B=new Image();this.letters.C=new Image();this.letters.D=new Image();this.letters.E=new Image();this.letters.F=new Image();this.letters.G=new Image();this.letters.H=new Image();this.letters.I=new Image();this.letters.J=new Image();this.letters.K=new Image();this.letters.L=new Image();this.letters.M=new Image();this.letters.N=new Image();this.letters.O=new Image();this.letters.P=new Image();this.letters.Q=new Image();this.letters.R=new Image();this.letters.S=new Image();this.letters.T=new Image();this.letters.U=new Image();this.letters.V=new Image();this.letters.W=new Image();this.letters.X=new Image();this.letters.Y=new Image();this.letters.Z=new Image();this.stopsOnly=false;this.imgsLoaded=false;this.comparator=null;if(arguments.length==2&&typeof arguments[1]=="object"){var b=arguments[1];for(var c in b){if(b[c]&&c=="comparator"){this.comparator=b.comparator}else{if(b[c]&&c=="getMOTImage"){this.getMOTImage=b.getMOTImage}else{if(b[c]&&c=="getBusPointImg"){this.getBusPointImg=b.getBusPointImg}else{this.options[c]=b[c]}}}}}else{if(arguments.length>=3&&arguments[1]!=null){this.comparator=arguments[1]}if(arguments.length>=3&&arguments[2]!=null){this.getMOTImage=arguments[2]}if(arguments.length>=3&&arguments[3]!=null){this.getBusPointImg=arguments[3]}}for(var d in MDVGadgetBase.prototype){if(!MDVMapEFAInfoEx.prototype[d]){MDVMapEFAInfoEx.prototype[d]=MDVGadgetBase.prototype[d]}}this.mdvMap.registerGadget(this);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.trigger);this.mdvMap.events.registerEvent(MDVEvent_AJAX_CALLBACK,this,this.processPins);this.mdvMap.events.registerEvent(MDVEvent_OBJECT_LOADED,this,this.intersects)}MDVMapEFAInfoEx.prototype.destroy=function(){this.stopImg.onclick=null;this.stopImg=null;this.mot1Img.onclick=null;this.mot1Img=null;this.mot2Img.onclick=null;this.mot2Img=null;this.mot3Img.onclick=null;this.mot3Img=null;this.mot4Img.onclick=null;this.mot4Img=null;this.mot5Img.onclick=null;this.mot5Img=null;this.mot6Img.onclick=null;this.mot6Img=null;this.mot7Img.onclick=null;this.mot7Img=null;this.mot8Img.onclick=null;this.mot8Img=null;this.mot9Img.onclick=null;this.mot9Img=null;this.mot10Img.onclick=null;this.mot10Img=null;this.mot11Img.onclick=null;this.mot11Img=null;this.mot12Img.onclick=null;this.mot12Img=null;this.poiImg.onclick=null;this.poiImg=null;this.entranceImg.onclick=null;this.entranceImg=null;this.pointImg.onclick=null;this.pointImg=null;if(this.stops){this.stops.removeAll()}if(this.poi){this.poi.removeAll()}while(this.boundLayers.pop()){}};MDVMapEFAInfoEx.prototype.addBoundaryLayer=function(b){for(var a=0;a<this.boundLayers.length;a++){if(this.boundLayers[a]&&this.boundLayers[a].id==b.id){return false}}this.boundLayers.push(b);return true};MDVMapEFAInfoEx.prototype.removeBoundaryLayer=function(b){for(var a=0;a<this.boundLayers.length;a++){if(this.boundLayers[a]&&this.boundLayers[a].id==b.id){this.boundLayers.splice(a,1);return true}}return false};MDVMapEFAInfoEx.prototype.createLayers=function(){var a=0;if(!this.stops){this.stops=this.mdvMap.createLayer("efa_stops");this.stops.setZIndex(2);this.mdvMap.addLayer(this.stops)}if(!this.poi){this.poi=this.mdvMap.createLayer("efa_poi");this.poi.setZIndex(1);this.mdvMap.addLayer(this.poi)}if(this.mdvMap.config.get("info.stopLabels")==="true"){if(!this.stopLabel){if(typeof this.mdvMap.config.get("info.stopLabels.minLevel")==="number"){a=this.mdvMap.config.get("info.stopLabels.minLevel")}this.stopLabel=this.mdvMap.createLayer("stopLabel",{useOwnContainer:true,minLevel:a});this.mdvMap.addLayer(this.stopLabel)}}else{this.stopLabel=null}};MDVMapEFAInfoEx.prototype.trigger=function(){var a="images/";if(this.mdvMap.config.get("imagePath")){a=this.mdvMap.config.get("imagePath")}if(this.options.imagePath){a=this.options.imagePath}if(!this.imgsLoaded){this.stopImg.src=a+"stop.gif";this.mot1Img.src=a+"mot1.gif";this.mot2Img.src=a+"mot2.gif";this.mot3Img.src=a+"mot3.gif";this.mot4Img.src=a+"mot4.gif";this.mot5Img.src=a+"mot5.gif";this.mot6Img.src=a+"mot6.gif";this.mot7Img.src=a+"mot7.gif";this.mot8Img.src=a+"mot8.gif";this.mot9Img.src=a+"mot9.gif";this.mot10Img.src=a+"mot10.gif";this.mot11Img.src=a+"mot11.gif";this.mot12Img.src=a+"mot12.gif";this.poiImg.src=a+"pin.gif";this.entranceImg.src=a+"entrance.gif";this.pointImg.src=a+"point.gif";if(this.mdvMap.config.get("info.stop.only")&&this.mdvMap.config.get("info.stop.only")=="true"){this.stopsOnly=true}this.imgsLoaded=true}if(this.id){mdvTimer.remove(this.id);this.id=null}this.id=mdvTimer.add(700,this,this.execute,[])};MDVMapEFAInfoEx.prototype.execute=function(){mdvTimer.remove(this.id);this.id=null;this.createLayers();var c=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var a=c.get("showSTOP")=="true";var b=c.get("showPOI")=="true";if(a||b){this.fetchPins()}else{this.stops.removeAll();this.poi.removeAll();if(this.stopLabel){this.stopLabel.removeAll()}}};MDVMapEFAInfoEx.prototype.getMOTImage=function(c,b,a){switch(parseInt(c)){case 1:return this.mot1Img.src;break;case 2:return this.mot2Img.src;break;case 3:return this.mot3Img.src;break;case 4:return this.mot4Img.src;break;case 5:return this.mot5Img.src;break;case 6:return this.mot6Img.src;break;case 7:return this.mot7Img.src;break;case 8:return this.mot8Img.src;break;case 9:return this.mot9Img.src;break;case 10:return this.mot10Img.src;break;case 11:return this.mot11Img.src;break;case 12:return this.mot12Img.src;break;default:if(b.toUpperCase()=="BUS_POINT"){return this.getBusPointImg(a)}else{if(b.toUpperCase()=="ENTRANCE"){return this.entranceImg.src}else{if(b.toUpperCase()=="POI_POINT"){return this.poiImg.src}else{if(b.toUpperCase()=="POI_AREA"){return this.poiImg.src}else{return this.stopImg.src}}}}break}};MDVMapEFAInfoEx.prototype.processPins=function(C,c,a){if(c!="MDVMapEFAInfoEx"){return false}mdvTimer.remove(this.id);this.id=null;var b=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var e=b.get("showSTOP")=="true"?true:false;var y=b.get("showPOI")=="true"?true:false;var o,G,n;if(!a.coordInfo){for(var K=0;K<a.parameters.length;K++){switch(a.parameters[K].name){case"x":o=a.parameters[K].value;break;case"y":G=a.parameters[K].value;break;case"mapName":n=a.parameters[K].value;break;default:break}}}this.stops.removeAll();this.poi.removeAll();if(this.stopLabel){this.stopLabel.removeAll()}if(a.coordInfo&&a.coordInfo.request){var z=new MDVCoordinates(a.coordInfo.request.coords.mapName,a.coordInfo.request.coords.x,a.coordInfo.request.coords.y);if(!z.equals(this.mdvMap.getCentre())){return false}}else{if(o&&G&&n){var z=new MDVCoordinates(n,o,G);if(!z.equals(this.mdvMap.getCentre())){return false}}}var k=false;var I=false;if((a.coordInfo&&(!a.coordInfo.pins||a.coordInfo.pins.length<=0))){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to get pins from map request.");return false}else{if(!a.coordInfo&&(!a.pins||a.pins.length<=0)){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,"MDVMap wasn't able to get pins from map request.");return false}}var O=[];var D=function(S,R,m){var i,Q;i=this.mdvMap.getPoint(R);Q=document.createElement("div");Q.className=m||"";Q.innerHTML=S;mdvLib.style([Q],{position:"absolute",top:i.y+"px",left:i.x+"px"});return Q};if(a.coordInfo&&mdvLib.typeOf(a.coordInfo.pins)==="object"&&a.coordInfo.pins.pin){O.push(a.coordInfo.pins.pin)}else{if(a.pins&&mdvLib.typeOf(a.pins)==="object"&&a.pins.pin){O.push(a.pins.pin)}else{if(a.pins){O=a.pins}else{O=a.coordInfo.pins}}}for(var K=0;K<O.length;K++){var v=O[K].desc;var A=O[K].desc;if(O[K].addname){A=O[K].addname}var p=O[K].locality;var s=O[K].stateless;var H=O[K].id;var g=O[K].type;var t=O[K].omc;var F=O[K].identifier;var M=new Image();var r=O[K].attrs;if(r&&r.length>0){var u="";for(var J=0;J<r.length;J++){var q=r[J];if(q.name=="STOP_MAJOR_MEANS"){u=q.value;break}else{if(!F&&q.name=="IDENTIFIER"){F=q.value;break}}}M.src=this.getMOTImage(u,g,O[K])}else{if(g.toUpperCase()=="BUS_POINT"){M.src=this.getBusPointImg(O[K])}else{if(g.toUpperCase()=="ENTRANCE"){M.src=this.entranceImg.src}else{if(g.toUpperCase()=="GIS_POINT"){M.src=this.poiImg.src}else{if(g.toUpperCase()=="POI_POINT"){M.src=this.poiImg.src}else{if(g.toUpperCase()=="POI_AREA"){M.src=this.poiImg.src}else{M.src=this.stopImg.src}}}}}}if(!F){F=""}var l=new Array();l.poi=new MDVPoint(284,190);l.stop=new MDVPoint(284,190);if(this.mdvMap.config.get("info.stop.size.width")&&this.mdvMap.config.get("info.stop.size.height")){l.stop=new MDVPoint(this.mdvMap.config.get("info.stop.size.width"),this.mdvMap.config.get("info.stop.size.height"))}if(this.mdvMap.config.get("info.poi.size.width")&&this.mdvMap.config.get("info.poi.size.height")){l.poi=new MDVPoint(this.mdvMap.config.get("info.poi.size.width"),this.mdvMap.config.get("info.poi.size.height"))}var N=O[K].coords.split(",");var E="";if(a.coordInfo&&a.coordInfo.request.coords.mapName){E=a.coordInfo.request.coords.mapName}else{if(a.request&&a.request.coords.mapName){E=a.request.coords.mapName}}var j=new MDVCoordinates(n?n:E,N[0],N[1]);var x=0.5;switch(g.toUpperCase()){case"ENTRANCE":x=new MDVPoint(0.5,0.5);break;case"BUSPOINT":x=new MDVPoint(0.5,0.5);break;default:if(this.options.alignment){x=this.options.alignment}break}var P=this.mdvMap.createMarker(j,x,M.src);var h=null;if(O[K].attrs){h=O[K].attrs}P.objectId={type:g,desc:v,addname:A,loc:p,stateless:s,id:H,omc:t,identifier:F,marker:P,attrs:h};if(this.comparator){if(!this.comparator(P.objectId)){continue}}switch(g.toUpperCase()){case"GIS_POINT":case"POI_POINT":case"POI_AREA":var d=null;if(this.mdvMap.config.get("useBubbleForEFAInfo")&&this.mdvMap.config.get("useBubbleForEFAInfo")=="true"){d=this.mdvMap.createToolTip(l.poi,"<b>"+v+"</b>");if(this.mdvMap.config.get("useBubbleOverflowForEFAInfo")&&this.mdvMap.config.get("useBubbleOverflowForEFAInfo")=="true"){d.setOverflow(true)}if(this.mdvMap.config.get("useBubblePinForEFAInfo")&&this.mdvMap.config.get("useBubblePinForEFAInfo")=="true"){d.setPin(true)}P.setToolTip(d,false)}else{d=this.mdvMap.createToolTip("Landmark: <b>"+v+"</b>");P.setToolTip(d,false)}break;default:var d=null;if(this.mdvMap.config.get("useBubbleForEFAInfo")&&this.mdvMap.config.get("useBubbleForEFAInfo")=="true"){d=this.mdvMap.createToolTip(l.stop,"<b>"+v+"</b>");if(this.mdvMap.config.get("useBubbleOverflowForEFAInfo")&&this.mdvMap.config.get("useBubbleOverflowForEFAInfo")=="true"){d.setOverflow(true)}if(this.mdvMap.config.get("useBubblePinForEFAInfo")&&this.mdvMap.config.get("useBubblePinForEFAInfo")=="true"){d.setPin(true)}P.setToolTip(d,false)}else{d=this.mdvMap.createToolTip("Stop: <b>"+v+"</b>");P.setToolTip(d,false)}break}switch(g.toUpperCase()){case"GIS_POINT":case"POI_POINT":case"POI_AREA":if(y){for(var J=0;J<this.poi.getMarkers().length;J++){var B=this.poi.getMarkers();if(B[J].objectId.id==P.objectId.id&&B[J].objectId.omc==P.objectId.omc){f=true;break}}if(f){continue}this.poi.addMarker(P,false);I=true}break;default:if(e){var f=false;if(this.stopLabel){if(this.mdvMap.config.currentZoomLevelIndex>=this.stopLabel.minLevel){if(g.toUpperCase()==="STOP"){var L=D.apply(this,[v,j,"stpLbl"]);this.stopLabel.appendHtmlElem(L)}}}for(var J=0;J<this.stops.getMarkers().length;J++){var w=this.stops.getMarkers();if(w[J].objectId.id==P.objectId.id){f=true;break}}if(f){continue}this.stops.addMarker(P,false);k=true}break}}if(k){this.stops.update()}if(I){this.poi.update()}this.centre=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);return true};MDVMapEFAInfoEx.prototype.intersects=function(g,f,c){if(this.stops!=null&&this.stops.name!=null&&this.poi!=null&&this.poi.name!=null&&c.layer.name!=this.stops.name&&c.layer.name!=this.poi.name){return false}for(var d=0;d<this.boundLayers.length;d++){var e=this.boundLayers[d].getMarkers();for(var a=0;a<e.length;a++){var b=e[a];if(b.id!=c.id&&b.intersects(c)){c.layer.removeMarker(c)}}}return true};MDVMapEFAInfoEx.prototype.getBusPointImg=function(a){if(this.letters[a.identifier]&&this.letters[a.identifier].src){return this.letters[a.identifier].src}else{var b="images/";if(this.mdvMap.config.get("imagePath")){b=this.mdvMap.config.get("imagePath")}b+="point_"+a.identifier+".gif";return b}};MDVMapEFAInfoEx.prototype.fetchPins=function(){if(this.mdvMap.config.get("efaURL")){var m=this.mdvMap.config.get("efaURL");var n=this.mdvMap.config.get("purpose")!=null?this.mdvMap.config.get("purpose"):"";var p=this.mdvMap.getCentre();var r=this.mdvMap.config.get("language")!=null?this.mdvMap.config.get("language"):"en";var o=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var j=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1)==null;var l=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+2)==null&&this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1)!=null;var s=o.get("showSTOP")=="true"&&this.stops.visible?1:0;var q=o.get("showPOI")=="true"&&this.poi.visible?1:0;var e=this.mdvMap.config.get("poiArea")=="true";var a=this.mdvMap.config.get("poiPoint")=="false";var h=this.mdvMap.getViewportRealExtends();var d=Math.floor(0.5+Math.sqrt((Math.pow(h.width/2,2)+Math.pow(h.height/2,2))));var i=Math.floor(p.x+0.5);var g=Math.floor(p.y+0.5);var f={language:r,itdLPxx_x:i,itdLPxx_y:g,itdLPxx_mapName:p.mapName,coord:Math.floor(p.x+0.5)+":"+Math.floor(p.y+0.5)+":"+p.mapName,inclFilter:1,purpose:n,max:-1,coordListFormat:"STRING",language:"en",itdLPxx_mdvMapName:"mdvMap_"+this.mdvMap.getName(),coordListOutputFormat:"STRING"};if(m.indexOf("lite")==-1){f.outputFormat="JSON"}var c=1;if(s){var t="";if(o.get("showSTOP.majorMeans")){t=o.get("showSTOP.majorMeans")}f["type_"+c]="STOP";f["radius_"+c]=d;f["inclDrawClasses_"+c]=t;c++;if((j||l)&&!this.stopsOnly){t="";if(j){f["type_"+c]="ENTRANCE";f["radius_"+c]=d;f["inclDrawClasses_"+c]=t;c++}t="";f["type_"+c]="BUS_POINT";f["radius_"+c]=d;f["inclDrawClasses_"+c]=t;c++}}if(q){var t="";for(var k=39;k<=80;k++){t+=k+":"}if(e){t="";f["type_"+c]="POI_AREA";f["radius_"+c]=d;f["inclDrawClasses_"+c]=t;c++}if(!a){t="";f["type_"+c]="POI_POINT";f["radius_"+c]=d;f["inclDrawClasses_"+c]=t;c++}if(this.options&&this.options.pools){for(pl in this.options.pools){f["type_"+c]=pl;f["radius_"+c]=d;if(this.options.pools[pl].inclDrawClasses&&this.options.pools[pl].inclDrawClasses.length>0){f["inclDrawClasses_"+c]=this.options.pools[pl].inclDrawClasses}if(this.options.pools[pl].exclLayers&&this.options.pools[pl].exclLayers.length>0){f["exclLayers_"+c]=this.options.pools[pl].exclLayers}c++}}}var b=mdvLib.ajax({host:m,parameters:f,onComplete:MDVMapEFAInfoEx_onAjaxComplete})}};MDVMapEFAInfoEx.prototype.getOptions=function(){return this.options};MDVMapEFAInfoEx.prototype.onmousedown=function(a){mdvTimer.remove(this.id);this.id=null;this.lastCentre=this.mdvMap.getCentre().clone();return true};MDVMapEFAInfoEx.prototype.onmouseup=function(a){if(this.lastCentre&&this.lastCentre.equals(this.mdvMap.getCentre())){this.trigger()}return true};function MDVMapEFAInfoEx_onAjaxComplete(request){var json=null;var efa=null;if(request&&request.responseText){json=request.responseText}else{if(request){json=request}}eval("efa = "+json+";");for(var i=0;i<efa.parameters.length;i++){if(efa.parameters[i].name=="mdvMapName"){mdvMapName=efa.parameters[i].value;break}}if(document.mdvMaps[mdvMapName]){document.mdvMaps[mdvMapName].events.triggerEvent(MDVEvent_AJAX_CALLBACK,"MDVMapEFAInfoEx",efa)}}function MDVMapScale(a,b){if(!a){return}this.mdvMap=a;this.init=false;this.maxScaleWidth=100;this.minScaleWidth=60;this.levels=[];this.divScale=null;this.divScaleLeft=null;this.divScaleBar=null;this.divScaleTickTop=null;this.divScaleTickBottom=null;this.divScaleTextTop=null;this.divScaleTextBottom=null;this.displayMeters=true;this.displayYards=true;if(b){for(var c in b){this[c]=b[c]}}if(this.mdvMap.viewportRealWidth!==-1){this._execute()}else{this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this._execute)}}MDVMapScale.prototype._execute=function(){if(this.init){return true}this.calculateScales();var b=this;this.scaleImg=new Image();this.scaleImg.failCount=0;this.scaleImg.onload=this.createDivs.bind(this);this.scaleImg.onerror=function(){if(b.mdvMap){b.scaleImg.failCount++;var c=b.scaleImg.src;if(b.scaleImg.failCount<=10){b.scaleImg.src=c}else{return}}}.bind(b);var a="images/";if(this.mdvMap.config.get("imagePath")){a=this.mdvMap.config.get("imagePath")}this.scaleImg.src=a+"scale.gif"};MDVMapScale.prototype.calculateScales=function(){var g=this;var e=1604.134;var l=1754.302;var r,a,u,p,h,d;for(var m=0,c=this.mdvMap.config.zoomLevels.length;m<c;m++){var k=this.mdvMap.config.getZoomLevel(m);var q=parseInt(k.get("tileSizeX"))*parseInt(k.get("numberOfTilesX"));var j=parseInt(k.get("realWidth"));var f=q/j;var b=s(this.maxScaleWidth/f);t(b);o();this.levels[m]={};this.levels[m].milesOut=r;this.levels[m].meterOut=a;this.levels[m].milesUnit=u;this.levels[m].meterUnit=p;this.levels[m].pxMiles=h;this.levels[m].pxMeter=d}function t(x){var w=1;var v=x*1000;if(v>=1000){w=1000}else{if(v>=100){v=v*l/1000;w=100}else{if(v>=10){v=v*l/1000;w=10}}}if(w>100){var i=Math.floor(v/w);if(i>10){if(Math.round(i/10)<i/10){i=Math.round(i/10)*10}else{i=(Math.round(i/10)*10)-10}}r=i}else{r=Math.floor(v/w)*w}u=(w>100)?((r===1)?"mile":"miles"):"yards";h=(w>100)?(Math.round(n(r)*f)):(Math.round(n(r/l)*f));while(h<g.minScaleWidth){t(x+0.1)}}function o(){var v=1;var w=(u.indexOf("mile")!==-1)?n(r):n(r/l);if(w>=1000){v=1000}else{if(w>=100){v=100}else{if(w>=10){v=10}}}if(v>100){var i=Math.floor(w/v);if(i>10){if(Math.round(i/10)<i/10){i=Math.round(i/10)*10}else{i=(Math.round(i/10)*10)-10}}a=i}else{a=Math.floor(w/v)*v}p=(v>100)?"km":"m";d=(v>100)?(Math.round(a*1000*f)):(Math.round(a*f))}function s(i){return i/e}function n(i){return i*e}};MDVMapScale.prototype.setScale=function(){var c=this.levels[this.mdvMap.config.getZoomLevelIndex()];var b=c.milesOut+" "+c.milesUnit;var a=c.meterOut+" "+c.meterUnit;if(this.divScaleTextTop){this.divScaleTextTop.innerHTML=b}if(this.divScaleTextBottom){this.divScaleTextBottom.innerHTML=a}mdvLib.style([this.divScaleBar],{width:c.pxMiles+"px",backgroundPosition:((this.scaleImg.width-c.pxMiles)*-1)+"px 0"});this.divScaleTickTop.style.left=c.pxMiles-1+"px";this.divScaleTickBottom.style.left=c.pxMeter-1+"px";return true};MDVMapScale.prototype.createDivs=function(){this.divScale=a("divScale");this.divScaleLeft=a("divScaleLeft");this.divScaleBar=a("divScaleBar");this.divScaleTickTop=a("divScaleTickTop");this.divScaleTickBottom=a("divScaleTickBottom");this.divScaleTextTop=a("divScaleTextTop");this.divScaleTextBottom=a("divScaleTextBottom");mdvLib.style([this.divScale],{position:"absolute",top:this.mdvMap.viewportHeight-40+"px",left:"15px",zIndex:999});mdvLib.style([this.divScaleBar,this.divScaleLeft,this.divScaleTextBottom,this.divScaleTextTop,this.divScaleTickBottom,this.divScaleTickTop],{position:"absolute",display:"inline"});mdvLib.style([this.divScaleBar,this.divScaleLeft,this.divScaleTickBottom,this.divScaleTickTop],{background:"transparent",backgroundImage:"url("+this.scaleImg.src+")",backgroundPosition:"0 0",backgroundRepeat:"no-repeat"});mdvLib.style([this.divScaleLeft],{width:"4px",height:"26px"});mdvLib.style([this.divScaleBar],{width:"100px",height:"4px",left:"3px",top:"11px"});mdvLib.style([this.divScaleTickTop],{width:"4px",height:"12px",backgroundPosition:"-4px 0",top:"0px"});mdvLib.style([this.divScaleTickBottom],{width:"4px",height:"12px",backgroundPosition:"-8px 0",top:"14px"});mdvLib.style([this.divScaleTextTop],{width:"60px",left:"8px",top:"-2px",fontSize:"10px"});mdvLib.style([this.divScaleTextBottom],{width:"60px",left:"8px",top:"15px",fontSize:"10px"});this.divScale.appendChild(this.divScaleLeft);this.divScale.appendChild(this.divScaleBar);this.divScale.appendChild(this.divScaleTickTop);this.divScale.appendChild(this.divScaleTickBottom);if(this.displayYards){this.divScale.appendChild(this.divScaleTextTop)}if(this.displayMeters){this.divScale.appendChild(this.divScaleTextBottom)}this.mdvMap.viewport.appendChild(this.divScale);this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,this,this.setScale);this.init=true;this.setScale();function a(c){var b=document.createElement("div");b.id=c;return b}};function MDVMapSlider(a,b){if(!a){return}this.mdvMap=a;this.mdvMap.registerGadget(this);for(var d in MDVGadgetBase.prototype){if(!MDVMapSlider.prototype[d]){MDVMapSlider.prototype[d]=MDVGadgetBase.prototype[d]}}this.name="MapSlider";this.imgs={plus:"zoom_Plus.png",minus:"zoom_Minus.png",tick:"tick.png",knob:"dragbar.png",indicator:"sizableBar_Large.png",bg:"zoomBG_separate.png"};this.sliderOffsetTop=50;this.sliderOffsetLeft=21;this.tickDiv=null;this.tickOffset=18;this.tickOffsetLeft=10;this.tickPositions=[];this.knob=null;this.knobDiv=null;this.knobActive=false;this.timer=null;this.timerDelay=20;this.currentLevel=0;this.zoomLevels=0;this.indicator=null;this.imagePath=this.mdvMap.config.get("imagePath");this.imagePath+="zoom/";this.imageRolloverPath="rollover/";this.plus=null;this.plusOver=null;this.minus=null;this.minusOver=null;this.bg=null;this.bgPos=0;this.garbage=[];this.init=false;if(b!==null){for(var c in b){if(this[c]){this[c]=b[c]}}}if(this.mdvMap.viewportRealWidth!==-1){this._execute()}else{this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this._execute)}}MDVMapSlider.prototype.destroy=function(){for(var c=0,a=this.garbage.length;c<a;c++){var e=this.garbage[c];switch(mdvLib.typeOf(e)){case"string":if(this[e]){this[e]=null}break;case"object":e=null;break;case"array":var d=this.garbage[c][0];var b=this.garbage[c][1];if(this[d][b]){this[d][b]=null}break;default:break}}};MDVMapSlider.prototype.createContainer=function(){var g=d("divSlider");var e=d("divSliderPlus");var c=d("divSliderBG");var f=d("divSliderKnob");var b=d("divSliderTicks");var a=d("divSliderMinus");mdvLib.style([g],{position:"absolute",top:this.sliderOffsetTop+"px",left:this.sliderOffsetLeft+"px",zIndex:999});mdvLib.style([e,a,c],{position:"relative"});mdvLib.style([e,a],{marginLeft:"3px",zIndex:6,height:"18px",width:"18px"});e.onclick=function(){if((this.currentLevel+1)<=(this.zoomLevels-1)){this.setZoomLevel(this.getZoomLevel()+1)}this.clearTimer();this.animate.bind(this)();return false}.bind(this);e.onmouseover=function(){this.plus.style.left="-2000px";this.plusOver.style.left="0px"}.bind(this);e.onmouseout=function(){this.plus.style.left="0px";this.plusOver.style.left="-2000px"}.bind(this);a.onclick=function(){if((this.currentLevel-1)>=0){this.setZoomLevel(this.getZoomLevel()-1)}this.clearTimer();this.animate.bind(this)();return false}.bind(this);a.onmouseover=function(){this.minus.style.left="-2000px";this.minusOver.style.left="0px"}.bind(this);a.onmouseout=function(){this.minus.style.left="0px";this.minusOver.style.left="-2000px"}.bind(this);b.style.zIndex=6;c.appendChild(f);c.appendChild(b);g.appendChild(e);g.appendChild(c);g.appendChild(a);this.mdvMap.viewport.appendChild(g);function d(i){var h=document.createElement("div");h.id=i;return h}};MDVMapSlider.prototype.loadImages=function(){for(var a in this.imgs){MDVMapSliderImages[a]=new Image();MDVMapSliderImages.over[a]=new Image();if(a==="bg"){MDVMapSliderImages[a].failCount=0;MDVMapSliderImages[a].onload=function(){this.setImages();this.drawTicks();this.createKnob();mdvLib.correctPNG(this.mdvMap,[this.plus,this.plusOver,this.minus,this.minusOver,this.bg,this.knob])}.bind(this);MDVMapSliderImages[a].onerror=function(){if(this.mdvMap){MDVMapSliderImages.bg.failCount++;var b=MDVMapSliderImages.bg.src;if(MDVMapSliderImages.bg.failCount<=10){MDVMapSliderImages.bg.src=b}else{return}}}.bind(this)}MDVMapSliderImages[a].src=this.imagePath+this.imgs[a];MDVMapSliderImages.over[a].src=this.imagePath+this.imageRolloverPath+this.imgs[a]}};MDVMapSlider.prototype.setImages=function(){var c=this;this.plus=mdvLib.createImg({position:"absolute",left:"0px"},{src:MDVMapSliderImages.plus.src,id:"MDVMapSliderPlus",title:"zoom in",alt:"zoom in"});this.plusOver=mdvLib.createImg({position:"absolute",left:"-2000px"},{src:MDVMapSliderImages.over.plus.src,id:"MDVMapSliderPlusOver",title:"zoom in",alt:"zoom in"});var a=mdvLib.$("divSliderPlus");a.appendChild(this.plus);a.appendChild(this.plusOver);this.bg=mdvLib.createImg({},{id:"MDVMapSliderBg",src:MDVMapSliderImages.bg.src,zIndex:2,onclick:c.setKnob.bind(c),onmousemove:c.onKnobMove.bind(c),onmouseup:c.onKnobUp.bind(c)});this.bgPos=mdvLib.getElementPosition(mdvLib.$("divSliderBG"));this.garbage.push(["bg","onclick"],["bg","onmousemove"],["bg","onmouseup"]);mdvLib.$("divSliderBG").appendChild(this.bg);this.minus=mdvLib.createImg({position:"absolute",left:"0"},{src:MDVMapSliderImages.minus.src,id:"MDVMapSliderMinus",title:"zoom out",alt:"zoom out"});this.minusOver=mdvLib.createImg({position:"absolute",left:"-2000px"},{src:MDVMapSliderImages.over.minus.src,id:"MDVMapSliderMinusOver",title:"zoom out",alt:"zoom out"});var b=mdvLib.$("divSliderMinus");b.appendChild(this.minus);b.appendChild(this.minusOver)};MDVMapSlider.prototype.drawTicks=function(){var d=Math.floor((MDVMapSliderImages.bg.height-this.tickOffset)/this.zoomLevels);var e=MDVMapSliderImages.bg.height-this.tickOffset;var c=this;this.tickDiv=mdvLib.$("divSliderTicks");this.tickDiv.appendChild(b(e));this.tickPositions.push(e);e=e-d;for(var a=2;a<=this.zoomLevels;a++){this.tickDiv.appendChild(b(e));this.tickPositions.push(e);e=e-d}function b(g){var f=document.createElement("img");f.src=MDVMapSliderImages.tick.src;f.style.position="absolute";f.style.top=g+"px";f.style.left=c.tickOffsetLeft+"px";f.id="tick"+g;return f}};MDVMapSlider.prototype.createKnob=function(){this.knobDiv=mdvLib.$("divSliderKnob");var a=this;mdvLib.style([this.knobDiv],{position:"absolute",top:(this.tickPositions[this.getZoomLevel()]-(Math.floor(MDVMapSliderImages.knob.height/2)))+"px",left:"1px",zIndex:5});this.knob=mdvLib.createImg({},{src:MDVMapSliderImages.knob.src,id:"MDVMapSliderKnob",onmousedown:function(){a.knobActive=true;a.clearTimer();return false},onmousemove:a.onKnobMove.bind(a),onmouseup:a.onKnobUp.bind(a)});this.garbage.push(["knob","onmousedown"],["knob","onmousemove"],["knob","onmouseup"]);this.indicator=mdvLib.createImg({position:"absolute",top:a.tickPositions[this.getZoomLevel()]+(Math.floor(MDVMapSliderImages.knob.height/2))-3+"px",left:"8px",zIndex:3},{id:"MDVMapSliderIndicator",src:MDVMapSliderImages.indicator.src,height:a.tickPositions[0]-a.tickPositions[this.getZoomLevel()]+7,width:MDVMapSliderImages.indicator.width,onclick:a.setKnob.bind(a),resize:function(b,c){this.height=(c)?this.height+1:this.height-1;this.style.top=b+(Math.floor(MDVMapSliderImages.knob.height/2))+"px";return true}});this.garbage.push(["indicator","onclick"]);this.knobDiv.appendChild(this.knob);mdvLib.$("divSliderBG").appendChild(this.indicator);this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,this,this.onZoomChanged);this.init=true;this.clearTimer()};MDVMapSlider.prototype.setKnob=function(d){var d=d||window.event;this.clearTimer();var a=mdvLib.getMousePosition(d);var f=MDVMapSliderImages.bg.height-(a.top-this.bgPos.top);var c=this.tickPositions.slice().reverse();for(var b=0;b<c.length;b++){if(f<=c[b+1]){var g=(f<=((c[b]+c[b+1])/2))?b:b+1;this.setZoomLevel(parseInt(g,10));break}}if(f>=c[this.zoomLevels-1]){this.setZoomLevel(this.zoomLevels-1)}this.animate();return true};MDVMapSlider.prototype.animate=function(){this.timer=window.setInterval(a.bind(this),this.timerDelay);var b=parseInt(this.knobDiv.style.top,10);var c=this.tickPositions[this.currentLevel]-Math.floor(MDVMapSliderImages.knob.height/2);function a(){if(c>b){b++;this.knobDiv.style.top=b+"px";this.indicator.resize(b,false);return}if(c<b){b--;this.knobDiv.style.top=b+"px";this.indicator.resize(b,true);return}this.clearTimer()}};MDVMapSlider.prototype.clearTimer=function(){window.clearInterval(this.timer);window.clearTimeout(this.timer);this.timer=null};MDVMapSlider.prototype.setZoomLevel=function(a){if(a===this.currentLevel){return true}var b=(this.mdvMap.config.get("useMagnifyGlass")&&this.mdvMap.config.get("useMagnifyGlass")=="true");if(b&&(this.currentLevel<a)){this.currentLevel=a;this.mdvMap._checkWrap();this.mdvMap.magnify(a);this.mdvMap.switchMapper()}else{this.currentLevel=a;this.mdvMap.setZoomLevel(a);this.mdvMap.update()}return true};MDVMapSlider.prototype.onZoomChanged=function(){if(this.currentLevel==this.getZoomLevel()){return}this.clearTimer();this.currentLevel=this.getZoomLevel();this.animate()};MDVMapSlider.prototype.getZoomLevel=function(){return(typeof this.mdvMap.config.getZoomLevelIndex()==="number")?this.mdvMap.config.getZoomLevelIndex():this.mdvMap.config.params.defaultScale};MDVMapSlider.prototype.onKnobMove=function(b){if(this.knobActive!==true){return true}var b=b||window.event;var a=mdvLib.getMousePosition(b);var c=(a.top-(this.bgPos.top+Math.floor(this.knob.height/2)));var d=parseInt(this.knobDiv.style.top,10);if((c<this.tickPositions[this.zoomLevels-1])||(c>this.tickPositions[0])){return true}if(d>c){this.indicator.style.top=c+(Math.floor(MDVMapSliderImages.knob.height/2))+"px";this.indicator.height=this.indicator.height+(d-c)}else{this.indicator.style.top=c+Math.floor((MDVMapSliderImages.knob.height/2))+"px";this.indicator.height=this.indicator.height-(c-d)}this.knobDiv.style.top=c+"px";return false};MDVMapSlider.prototype.onKnobUp=function(a){if(this.knobActive===true){this.knobActive=false;this.setKnob(a)}return false};MDVMapSlider.prototype._execute=function(){if(this.init===true){return}this.currentLevel=this.getZoomLevel();this.zoomLevels=this.mdvMap.config.zoomLevels.length;this.createContainer();this.loadImages()};var MDVMapSliderImages={over:{}};MDVMapSync.prototype.execute=function(b){if(!b){return false}this.container=b;var f=this;var a=parseInt(this.container.offsetHeight,10);var e=parseInt(this.container.offsetWidth,10);this.container.style.left=this.mdvMap.viewportWidth-e-2+"px";this.container.style.top=this.mdvMap.viewportHeight-a-2+"px";this.isVisible=true;this.timerDelay=10;this.timer=null;this.buttonN=null;this.buttonO=null;this.buttonA=null;this.buttonPos=null;this.normal=new Image();this.normal.src=this.mdvMap.config.get("imagePath")+"mapStretch.png";this.over=new Image();this.over.src=this.mdvMap.config.get("imagePath")+"mapStretch_rollover.png";this.active=new Image();this.active.failCount=0;this.active.onload=this.createImages.bind(this);this.active.onerror=function(){if(f.mdvMap){f.active.failCount++;var g=f.active.src;if(f.active.failCount<=10){f.active.src=g}else{return}}}.bind(f);this.active.src=this.mdvMap.config.get("imagePath")+"mapStretch_act.png";this.stepsX=[];this.stepsY=[];this.leftPos=parseInt(this.container.style.left,10);this.topPos=parseInt(this.container.style.top,10);this.topPosHidden=this.topPos+a;var d=Math.floor(e/a);var c=15;while(this.topPos<=this.topPosHidden+c){this.stepsX.push(this.leftPos);this.stepsY.push(this.topPos);this.topPos+=c;this.leftPos+=(c*d)}};MDVMapSync.prototype.createImages=function(){var a=this;var b=document.createElement("div");b.id="toggleImgDiv";mdvLib.style([b],{position:"absolute",top:this.mdvMap.viewportHeight-this.normal.height+"px",left:this.mdvMap.viewportWidth-this.normal.width+"px",zIndex:152});b.onclick=function(){a.clearTimer();a.animate.bind(a)();return false};b.onmouseover=function(){if(this.buttonA.style.left=="0px"){return true}this.buttonN.style.left="-2000px";this.buttonO.style.left="0px"}.bind(this);b.onmouseout=function(){if(this.buttonA.style.left=="0px"){return true}this.buttonN.style.left="0px";this.buttonO.style.left="-2000px"}.bind(this);this.buttonN=mdvLib.createImg({position:"absolute",left:"0px"},{src:a.normal.src,id:"togNormal",title:"hide MiniMap",alt:"hide MiniMap"});this.buttonO=mdvLib.createImg({position:"absolute",left:"-2000px"},{src:a.over.src,id:"togOver",title:"hide MiniMap",alt:"hide MiniMap"});this.buttonA=mdvLib.createImg({position:"absolute",left:"-2000px"},{src:a.active.src,id:"togActive",title:"show MiniMap",alt:" show MiniMap"});b.appendChild(this.buttonN);b.appendChild(this.buttonO);b.appendChild(this.buttonA);this.mdvMap.viewport.appendChild(b);mdvLib.correctPNG(this.mdvMap,[this.buttonN,this.buttonO,this.buttonA])};MDVMapSync.prototype.animate=function(){var d=parseInt(this.container.style.left,10);if(this.container.style.display==="none"){if(this.buttonA.style.left=="0px"){this.container.style.display="block";this.isVisible=false}else{return}}else{if((!this.isVisible)&&(d<=(this.mdvMap.viewportWidth-this.container.offsetWidth))){this.isVisible=true}}var c=this.stepsX.slice();var b=this.stepsY.slice();if(this.isVisible){c.reverse();b.reverse();this.setImgActive(true);this.isVisible=false}else{this.setImgActive(false);this.isVisible=true}this.timer=window.setInterval(a.bind(this),this.timerDelay);function a(){this.container.style.top=b.pop()+"px";this.container.style.left=c.pop()+"px";if(b.length==0){this.clearTimer()}}};MDVMapSync.prototype.clearTimer=function(){window.clearInterval(this.timer);this.timer=null};MDVMapSync.prototype.setImgActive=function(a){if(a===true){this.buttonN.style.left="-2000px";this.buttonO.style.left="-2000px";this.buttonA.style.left="0px"}else{this.buttonA.style.left="-2000px";this.buttonO.style.left="-2000px";this.buttonN.style.left="0px"}};MDVMapSync.prototype.hideButton=function(a){mdvLib.$("toggleImgDiv").style.display=(a)?"none":"block"};var resizeHandlerFunc=function(){};function MDVRectZoom(a,b){if(!a){return}this.mdvMap=a;this.mdvMap.registerGadget(this);this.name="RectZoom";this.init=false;this.bDragging=false;this.mc=null;this.mct=null;this.mcr=null;this.mcb=null;this.mcl=null;this.oOutline=null;this.mcOpacity=0.2;this.mcFilter="alpha(opacity=20)";this.gadgetBorder="1px solid #000";this.useButton=false;this.buttonN=null;this.buttonO=null;this.buttonA=null;this.buttonPosLeft="13px";this.buttonPosTop="280px";if(b){this.options=b}this.nBorderCorrect=this.gadgetBorder.split(" ")[0].replace(/px/,"")*2;this.oMapPos=null;this.nMapWidth=0;this.nMapHeight=0;this.nMapRatio=0;this.nStartX=0;this.nStartY=0;if(this.mdvMap.viewportRealWidth!==-1){this._execute()}else{this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this._execute)}}MDVRectZoom.prototype.onmousedown=function(a){if(this.useButton){return true}if(a.shiftKey){this._showCover();this._coverMousedown(a);return false}return true};MDVRectZoom.prototype.onmousemove=function(a){if(this.useButton){return true}if(a.shiftKey){this._coverDrag(a);return false}return true};MDVRectZoom.prototype.onmouseup=function(a){if(this.useButton){return true}if(this.bDragging){return false}return true};MDVRectZoom.prototype.onmouseover=function(a){return true};MDVRectZoom.prototype.onkeypress=function(a){return true};MDVRectZoom.prototype.onmouseout=function(a){return true};MDVRectZoom.prototype.oncontextmenu=function(a){return true};MDVRectZoom.prototype.ondblclick=function(a){return true};MDVRectZoom.prototype.onmousewheel=function(a){return true};MDVRectZoom.prototype.destroy=function(){var a;if(this.mdvMap){mdvLib.removeEvent(window,"resize",resizeHandlerFunc);a=document.getElementById("rz_MapCover");if(a){while(a.hasChildNodes()){a.removeChild(a.lastChild)}a.onmousemove=null;this.mdvMap.viewport.removeChild(a)}this.mdvMap=null}this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null};MDVRectZoom.prototype._execute=function(){if(this.init===true){return}if(this.options){var b=this;if(typeof this.options.buttonPosLeft!=="undefined"){this.buttonPosLeft=this.options.buttonPosLeft}if(typeof this.options.buttonPosTop!=="undefined"){this.buttonPosTop=this.options.buttonPosTop}if(typeof this.options.opacity!=="undefined"){this.mcOpacity=this.options.opacity;this.mcFilter=this.mcFilter.replace(/20/,this.options.opacity*100)}if(typeof this.options.border!=="undefined"){var a=this.options.border.split(" ");if(a[0].indexOf("px")===-1){a.reverse()}this.gadgetBorder=a.join(" ");this.nBorderCorrect=this.gadgetBorder.split(" ")[0].replace(/px/,"")*2}if(typeof this.options.useButton!=="undefined"){if(this.options.useButton===true){this.useButton=true;this.normal=new Image();this.normal.src=b.mdvMap.config.get("imagePath")+this.options.buttonImg;this.over=new Image();this.over.src=b.mdvMap.config.get("imagePath")+this.options.buttonImgOver;this.active=new Image();this.active.failCount=0;this.active.onload=this._createButton.bind(this);this.active.onerror=function(){if(b.mdvMap){b.active.failCount++;var c=b.active.src;if(b.active.failCount<=10){b.active.src=c}else{b.active.src=b.mdvMap.transparent.src}}}.bind(b);this.active.src=b.mdvMap.config.get("imagePath")+this.options.buttonImgActive}}}this._createGadgetElements();this.oOutline=mdvLib.$("rz-outline");if(this.useButton){this.oButton=mdvLib.$("rz_Button")}this.mc=mdvLib.$("rz_MapCover");this.mct=mdvLib.$("rz-mct");this.mcr=mdvLib.$("rz-mcr");this.mcb=mdvLib.$("rz-mcb");this.mcl=mdvLib.$("rz-mcl");this.oMapPos=mdvLib.getElementPosition(this.mdvMap.viewport);this._setDimensions();this._initStyles();if(this.useButton){this.mc.onmousedown=this._coverMousedown.bind(this)}document.onmouseup=this._coverMouseup.bind(this);this.mdvMap.events.deregisterEvent(MDVEvent_MAP_INITIALISED,this,this._execute);if(!this.useButton){this.init=true}resizeHandlerFunc=function(){this.oMapPos=mdvLib.getElementPosition(this.mdvMap.viewport)}.bind(this);attachEventListener(window,"resize",resizeHandlerFunc,null)};MDVRectZoom.prototype._createGadgetElements=function(){var a=document.createElement("div");a.id="rz_MapCover";a.innerHTML='<div id="rz-outline"></div><div id="rz-mct"></div><div id="rz-mcl"></div><div id="rz-mcr"></div><div id="rz-mcb"></div>';a.onmousemove=this._coverDrag.bind(this);mdvLib.style([a],{position:"absolute",display:"none",overflow:"hidden",cursor:"crosshair",zIndex:101});this.mdvMap.viewport.appendChild(a);return true};MDVRectZoom.prototype._createButton=function(){var b=document.createElement("div");b.id="rz_Button";mdvLib.style([b],{position:"absolute",zIndex:102,left:this.buttonPosLeft,top:this.buttonPosTop});b.onclick=this._buttonClick.bind(this);b.onmouseover=function(){if(this.buttonA.style.left=="0px"){return true}this.buttonN.style.left="-2000px";this.buttonO.style.left="0px"}.bind(this);b.onmouseout=function(){if(this.buttonA.style.left=="0px"){return true}this.buttonN.style.left="0px";this.buttonO.style.left="-2000px"}.bind(this);var a=this;this.buttonN=mdvLib.createImg({position:"absolute",left:"0px"},{src:a.normal.src,id:"rzbNormal",title:a.options.title||"Click, and then drag a box with your cursor to zoom in",alt:a.options.alt||"Click, and then drag a box with your cursor to zoom in"});this.buttonO=mdvLib.createImg({position:"absolute",left:"-2000px"},{src:a.over.src,id:"rzbOver",title:a.options.title||"Click, and then drag a box with your cursor to zoom in",alt:a.options.alt||"Click, and then drag a box with your cursor to zoom in"});this.buttonA=mdvLib.createImg({position:"absolute",left:"-2000px"},{src:a.active.src,id:"rzbActive",title:a.options.titleActive||"draw a rectangle",alt:a.options.altActive||"draw a rectangle"});b.appendChild(this.buttonN);b.appendChild(this.buttonO);b.appendChild(this.buttonA);this.mdvMap.viewport.appendChild(b);mdvLib.correctPNG(this.mdvMap,[this.buttonN,this.buttonO,this.buttonA]);this.init=true;this._toggleButton()};MDVRectZoom.prototype._showCover=function(){mdvLib.style([this.mc],{display:"block",top:"0px",left:"0px",backgroundColor:"#000",width:this.mdvMap.viewportWidth+"px",height:this.mdvMap.viewportHeight+"px",opacity:this.mcOpacity,filter:this.mcFilter});if(this.useButton){this._toggleButton("zoom")}return true};MDVRectZoom.prototype._toggleButton=function(a){if(a=="zoom"){this.buttonN.style.left="-2000px";this.buttonO.style.left="-2000px";this.buttonA.style.left="0px"}else{this.buttonA.style.left="-2000px";this.buttonO.style.left="-2000px";this.buttonN.style.left="0px"}};MDVRectZoom.prototype._buttonClick=function(){(this.mc.style.display=="block")?this._resetDragZoom():this._showCover();return false};MDVRectZoom.prototype._coverMousedown=function(a){oPos=this._getRelPos(a);this.nStartX=oPos.left;this.nStartY=oPos.top;mdvLib.style([this.mc],{background:"transparent",opacity:1,filter:"alpha(opacity=100)"});mdvLib.style([this.oOutline],{left:this.nStartX+"px",top:this.nStartY+"px",display:"block",width:"1px",height:"1px"});this.bDragging=true;this.mct.style.top=(this.nStartY-this.nMapHeight)+"px";this.mct.style.display="block";this.mcl.style.left=(this.nStartX-this.nMapWidth)+"px";this.mcl.style.top=(this.nStartY)+"px";this.mcl.style.width=this.nMapWidth+"px";this.mcl.style.display="block";this.mcr.style.left=this.nStartX+"px";this.mcr.style.top=this.nStartY+"px";this.mcr.style.display="block";this.mcb.style.left=this.nStartX+"px";this.mcb.style.top=this.nStartY+"px";this.mcb.style.width="0px";this.mcb.style.display="block";return true};MDVRectZoom.prototype._coverDrag=function(c){if(this.bDragging){var b=this._getRelPos(c);var a=this._getRectangle(this.nStartX,this.nStartY,b,this.nMapRatio);this.oOutline.style.width=a.nWidth+"px";this.oOutline.style.height=a.nHeight+"px";this.mcb.style.width=(a.nWidth+this.nBorderCorrect)+"px";this.oOutline.style.left=this.nStartX+"px";this.oOutline.style.top=this.nStartY+"px";this.mcb.style.left=this.nStartX+"px";this.mcb.style.top=this.nStartY+"px";this.mcl.style.width=this.nMapWidth+"px";this.mcl.style.top=this.nStartY+"px";this.mct.style.height=this.nMapHeight+"px";this.mcr.style.top=this.nStartY+"px";this.mcr.style.left=this.nStartX+"px";if(a.xFactor===1){this.mcr.style.left=(a.nEndX+this.nBorderCorrect)+"px";if(a.yFactor===1){this.mcb.style.top=(a.nEndY+this.nBorderCorrect)+"px"}else{this.oOutline.style.top=(this.nStartY-(a.nHeight+this.nBorderCorrect))+"px";this.mct.style.height=(this.nMapHeight-(a.nHeight+this.nBorderCorrect))+"px";this.mcr.style.top=(this.nStartY-(a.nHeight+this.nBorderCorrect))+"px";this.mcl.style.top=(this.nStartY-(a.nHeight+this.nBorderCorrect))+"px"}}else{this.oOutline.style.left=(this.nStartX-(a.nWidth+this.nBorderCorrect))+"px";this.mcl.style.width=(this.nMapWidth-(a.nWidth+this.nBorderCorrect))+"px";this.mcb.style.left=(a.nStartX-(a.nWidth+this.nBorderCorrect))+"px";if(a.yFactor===1){this.mcb.style.top=(a.nEndY+this.nBorderCorrect)+"px"}else{this.oOutline.style.top=(this.nStartY-(a.nHeight+this.nBorderCorrect))+"px";this.mct.style.height=(this.nMapHeight-(a.nHeight+this.nBorderCorrect))+"px";this.mcr.style.top=(this.nStartY-(a.nHeight+this.nBorderCorrect))+"px";this.mcl.style.top=(this.nStartY-(a.nHeight+this.nBorderCorrect))+"px"}}return false}};MDVRectZoom.prototype._coverMouseup=function(r){if(this.bDragging){var b=this._getRelPos(r);this.bDragging=false;var c=this._getRectangle(this.nStartX,this.nStartY,b,this.nMapRatio);this._resetDragZoom();if(c.nStartX>c.nEndX){var h=c.nStartX;c.nStartX=c.nEndX;c.nEndX=h}if(c.yFactor===-1){c.nEndY=c.nStartY-c.nHeight;var p=new MDVPoint(c.nStartX,c.nEndY);var q=new MDVPoint(c.nEndX,c.nEndY);var k=new MDVPoint(c.nEndX,c.nStartY);var i=new MDVPoint(c.nStartX,c.nStartY)}else{var p=new MDVPoint(c.nStartX,c.nStartY);var q=new MDVPoint(c.nEndX,c.nStartY);var k=new MDVPoint(c.nEndX,c.nEndY);var i=new MDVPoint(c.nStartX,c.nEndY)}var s=this.mdvMap.getCoordinates(p);var f=this.mdvMap.getCoordinates(q);var v=this.mdvMap.getCoordinates(k);var m=this.mdvMap.getCoordinates(i);var l=s.x+","+s.y+" "+f.x+","+f.y+" "+v.x+","+v.y+" "+m.x+","+m.y+" "+s.x+","+s.y;var w=v.x-s.x;var u=v.y-s.y;var o=this.mdvMap.config.currentZoomLevelIndex;while(this.mdvMap.config.getZoomLevel(o)!==null){var n=this.mdvMap.config.getZoomLevel(o);var a=Math.floor(n.get("realWidth")/n.get("numberOfTilesX")*this.mdvMap.tileCountWidth);if(a<w){o--;break}o++}if(this.mdvMap.config.getZoomLevel(o)===null){o--}var d=new MDVCoordinates(this.mdvMap.config.get("mapName"),s.x+(w/2),s.y+(u/2));var g=this.mdvMap.createLayer("rect_zoom");this.mdvMap.addLayer(g);var j=this.mdvMap.createPolyline(l);j.add("weight",this.gadgetBorder.split(" ")[0].replace(/px/,""));j.add("colour",this.gadgetBorder.split(" ")[2]);j.add("opacity","1");g.addPolyline(j);this.mdvMap.renderer.update();this.mdvMap.setCentre(d);this.mdvMap.setZoomLevel(o);this.mdvMap.update();this.mdvMap.renderer.drawPolyline(j);window.setTimeout(function(){g.removePolyline(j)},1000)}};MDVRectZoom.prototype._getRelPos=function(b){var a=mdvLib.getMousePosition(b);return{top:(a.top-this.oMapPos.top),left:(a.left-this.oMapPos.left)}};MDVRectZoom.prototype._setDimensions=function(){this.nMapWidth=this.mdvMap.viewportWidth;this.nMapHeight=this.mdvMap.viewportHeight;this.nMapRatio=this.nMapHeight/this.nMapWidth;mdvLib.style([this.mc,this.mct,this.mcb],{width:this.nMapWidth+"px",height:this.nMapHeight+"px"});mdvLib.style([this.mcr,this.mcl],{width:2*this.nMapWidth+"px",height:2*this.nMapHeight+"px"});return true};MDVRectZoom.prototype._initStyles=function(){mdvLib.style([this.mc,this.mct,this.mcr,this.mcb,this.mcl],{position:"absolute",display:"none",background:"#000",opacity:this.mcOpacity,filter:this.mcFilter});mdvLib.style([this.oOutline],{position:"absolute",display:"none"});this.oOutline.style.border=this.gadgetBorder;return true};MDVRectZoom.prototype._getRectangle=function(c,b,g,a){var f=g.left-c;var e=g.top-b;var i=1;var d=1;if(f<0){f=f*-1;i=-1}if(e<0){e=e*-1;d=-1}var h=(f>e)?f:e;return{nStartX:c,nStartY:b,nEndX:(i===1)?c+h:c-h,nEndY:b+parseInt(h*a,10),nWidth:h,nHeight:parseInt(h*a,10),xFactor:i,yFactor:d}};MDVRectZoom.prototype._resetDragZoom=function(){mdvLib.style([this.oOutline,this.mc,this.mct,this.mcr,this.mcb,this.mcl],{display:"none"});this.mct.style.height=this.nMapHeight+"px";if(this.useButton){this._toggleButton()}return true};
