var gnLastEventId=0;var KAMAP_ERROR=gnLastEventId++;var KAMAP_WARNING=gnLastEventId++;var KAMAP_NOTICE=gnLastEventId++;var KAMAP_INITIALIZED=gnLastEventId++;var KAMAP_MAP_INITIALIZED=gnLastEventId++;var KAMAP_EXTENTS_CHANGED=gnLastEventId++;var KAMAP_SCALE_CHANGED=gnLastEventId++;var KAMAP_LAYERS_CHANGED=gnLastEventId++;var KAMAP_CONTEXT_MENU=gnLastEventId++;function kaMap(A){this.isCSS=false;this.isW3C=false;this.isIE4=false;this.isNN4=false;this.isIE6CSS=false;if(document.images){this.isCSS=(document.body&&document.body.style)?true:false;this.isW3C=(this.isCSS&&document.getElementById)?true:false;this.isIE4=(this.isCSS&&document.all)?true:false;this.isNN4=(document.layers)?true:false;this.isIE6CSS=(document.compatMode&&document.compatMode.indexOf("CSS1")>=0)?true:false}this.domObj=this.getRawObject(A);this.domObj.style.overflow="hidden";this.hideLayersOnMove=false;this.loadUnchecked=false;this.initializationState=0;this.bMouseDown=false;this.lastx=0;this.lasty=0;this.theInsideLayer=null;this.viewportWidth=safeParseInt(this.domObj.style.width);this.viewportHeight=safeParseInt(this.domObj.style.height);this.xOffset=0;this.yOffset=0;this.xOrigin=0;this.yOrigin=0;this.currentMap="";this.nWide=5;this.nHigh=5;this.nCurrentTop=0;this.nCurrentLeft=0;this.aPixel=new Image(1,1);this.aPixel.src="/images/a_pixel.gif";this.imgErrors=new Array();this.aMaps=new Array();this.tileWidth=null;this.tileHeight=null;this.nBuffer=1;this.baseURL="";this.cellSize=null;this.gImageID=0;this.eventManager=new _eventManager();this.as=slideid=null;this.accelerationFactor=1;this.pixelsPerStep=30;this.timePerStep=25;this.server="";this.init="/init.php";this.tileURL=null;this.aObjects=[];this.aCanvases=[];this.layersHidden=false;this.aTools=[];for(var B=0;B<gnLastEventId;B++){this.registerEventID(B)}this.createLayers()}kaMap.prototype.seekLayer=function(D,A){var C;for(var B=0;B<D.layers.length;B++){if(D.layers[B].name==A){C=D.layers[B];break}if(D.layers[B].document.layers.length>0){C=this.seekLayer(document.layers[B].document,A)}}return C};kaMap.prototype.getRawObject=function(B){var A;if(typeof B=="string"){if(this.isW3C){A=document.getElementById(B)}else{if(this.isIE4){A=document.all(B)}else{if(this.isNN4){A=seekLayer(document,B)}}}}else{A=B}return A};kaMap.prototype.getObject=function(B){var A=this.getRawObject(B);if(A&&this.isCSS){A=A.style}return A};kaMap.prototype.getObjectWidth=function(C){var A=this.getRawObject(C);var B=0;if(A.offsetWidth){B=A.offsetWidth}else{if(A.clip&&A.clip.width){B=A.clip.width}else{if(A.style&&A.style.pixelWidth){B=A.style.pixelWidth}}}return parseInt(B)};kaMap.prototype.getObjectHeight=function(C){var A=this.getRawObject(C);var B=0;if(A.offsetHeight){B=A.offsetHeight}else{if(A.clip&&A.clip.height){B=A.clip.height}else{if(A.style&&A.style.pixelHeight){B=A.style.pixelHeight}}}return parseInt(B)};kaMap.prototype.zoomTo=function(R,Q){var K=this.getCurrentMap();var S=new Array(1,12,63360,39.3701,39370.1,4374754);var N;var L=false;if(arguments.length==3){N=arguments[2];L=(N!=this.getCurrentScale())}else{N=this.getCurrentScale()}this.cellSize=N/(K.resolution*S[K.units]);var P=K.zoomToScale(N);this.setMapLayers();var A=R/this.cellSize;var U=Q/this.cellSize;var E=Math.round(A-this.viewportWidth/2);var D=Math.round(U+this.viewportHeight/2);var I=Math.floor(A/this.tileWidth)*this.tileWidth;var M=Math.floor(U/this.tileHeight)*this.tileHeight;var F=Math.ceil(this.viewportWidth/(2*this.tileWidth))*this.tileWidth;var C=Math.ceil(this.viewportHeight/(2*this.tileHeight))*this.tileHeight;this.nCurrentLeft=I-F;this.nCurrentTop=-1*(M+C);this.xOrigin=this.nCurrentLeft;this.yOrigin=this.nCurrentTop;this.theInsideLayer.style.left=-1*(E-this.xOrigin)+"px";this.theInsideLayer.style.top=(D+this.yOrigin)+"px";var B=K.getLayers();for(var G=0;G<B.length;G++){var O=B[G].domObj;for(var H=0;H<this.nHigh;H++){for(var J=0;J<this.nWide;J++){var T=O.childNodes[(H*this.nWide)+J];T.src=this.aPixel.src;T.style.top=(this.nCurrentTop+H*this.tileHeight-this.yOrigin)+"px";T.style.left=(this.nCurrentLeft+J*this.tileWidth-this.xOrigin)+"px";B[G].setTile(T)}}}this.checkWrap();this.updateObjects();if(L){this.triggerEvent(KAMAP_SCALE_CHANGED,this.getCurrentScale())}this.triggerEvent(KAMAP_EXTENTS_CHANGED,this.getGeoExtents())};kaMap.prototype.zoomToExtents=function(H,E,D,B){var Z=new Array(1,12,63360,39.3701,39370.1,4374754);var S=this.getCurrentMap();var Y=(D+H)/2;var X=(B+E)/2;var C=(D-H)/this.viewportWidth;var F=(B-E)/this.viewportHeight;var I=Math.max(C,F);var L=I*S.resolution*Z[S.units];var U=S.aScales[0];for(var T=1;T<S.aScales.length;T++){if(L>=S.aScales[T]){break}U=S.aScales[T]}this.cellSize=U/(S.resolution*Z[S.units]);var W=S.zoomToScale(U);this.setMapLayers();var A=Y/this.cellSize;var c=X/this.cellSize;var M=Math.round(A-this.viewportWidth/2);var K=Math.round(c+this.viewportHeight/2);var Q=Math.floor(A/this.tileWidth)*this.tileWidth;var R=Math.floor(c/this.tileHeight)*this.tileHeight;var N=Math.ceil(this.viewportWidth/(2*this.tileWidth))*this.tileWidth;var J=Math.ceil(this.viewportHeight/(2*this.tileHeight))*this.tileHeight;this.nCurrentLeft=Q-N;this.nCurrentTop=-1*(R+J);this.xOrigin=this.nCurrentLeft;this.yOrigin=this.nCurrentTop;this.theInsideLayer.style.left=-1*(M-this.xOrigin)+"px";this.theInsideLayer.style.top=(K+this.yOrigin)+"px";var G=S.getLayers();for(var O=0;O<G.length;O++){var V=G[O].domObj;for(var P=0;P<this.nHigh;P++){for(var T=0;T<this.nWide;T++){var b=V.childNodes[(P*this.nWide)+T];b.src=this.aPixel.src;b.style.top=(this.nCurrentTop+P*this.tileHeight-this.yOrigin)+"px";b.style.left=(this.nCurrentLeft+T*this.tileWidth-this.xOrigin)+"px";G[O].setTile(b)}}}this.checkWrap();this.updateObjects();this.triggerEvent(KAMAP_SCALE_CHANGED,this.getCurrentScale());this.triggerEvent(KAMAP_EXTENTS_CHANGED,this.getGeoExtents())};kaMap.prototype.createDrawingCanvas=function(A){var B=document.createElement("div");B.style.position="absolute";B.style.left="0px";B.style.top="0px";B.style.width="3000px";B.style.height="3000px";B.style.zIndex=A;this.theInsideLayer.appendChild(B);this.aCanvases.push(B);B.kaMap=this;return B};kaMap.prototype.removeDrawingCanvas=function(B){for(var A=0;A<this.aCanvases.length;A++){if(this.aCanvases[A]==B){this.aCanvases.splice(A,1)}}this.theInsideLayer.removeChild(B);B.kaMap=null;return true};kaMap.prototype.addObjectGeo=function(A,E,D,C){C.lon=E;C.lat=D;var B=this.geoToPix(E,D);return this.addObjectPix(A,B[0],B[1],C)};kaMap.prototype.addObjectPix=function(B,A,H,F){var C=(F.xOffset)?F.xOffset:0;var G=(F.yOffset)?F.yOffset:0;var E=(H-this.yOrigin+G);var D=(A-this.xOrigin+C);F.style.position="absolute";F.style.top=E+"px";F.style.left=D+"px";F.canvas=B;B.appendChild(F);this.aObjects.push(F);return true};kaMap.prototype.shiftObject=function(A,E,D){var C=safeParseInt(D.style.top);var B=safeParseInt(D.style.left);D.style.top=(C+E)+"px";D.style.left=(B+A)+"px";return true};kaMap.prototype.removeObject=function(B){for(var A=0;A<this.aObjects.length;A++){if(this.aObjects[A]==B||B==null){if(!B){B=this.aObjects[A]}if(B.canvas){B.canvas.removeChild(B);B.canvas=null}this.aObjects.splice(A,1);return true}}return false};kaMap.prototype.centerObject=function(F){var D=-safeParseInt(this.theInsideLayer.style.left)+this.viewportWidth/2;var C=-safeParseInt(this.theInsideLayer.style.top)+this.viewportHeight/2;var E=(F.xOffset)?F.xOffset:0;var G=(F.yOffset)?F.yOffset:0;var B=safeParseInt(F.style.left)-E-D;var A=safeParseInt(F.style.top)-G-C;this.slideBy(-B,-A);return true};kaMap.prototype.geoToPix=function(D,C){var B=D/this.cellSize;var A=-1*C/this.cellSize;return[Math.floor(B),Math.floor(A)]};kaMap.prototype.pixToGeo=function(B,A){var E=(arguments.length==3&&arguments[2])?true:false;if(E){B=B+this.xOrigin;A=A+this.yOrigin}var D=-1*B*this.cellSize;var C=A*this.cellSize;return[D,C]};kaMap.prototype.initialize=function(){if(this.initializationState==2){this.triggerEvent(KAMAP_ERROR,"ERROR: ka-Map! is already initialized!");return false}else{if(this.intializationState==1){this.triggerEvent(KAMAP_WARNING,"WARNING: ka-Map! is currently initializing ... wait for the KAMAP_INITIALIZED event to be triggered.");return false}}this.initializationState=1;var G=this.server+this.init;var J=(this.init.indexOf("?")==-1)?"?":"&";var E="gmap_r";if(arguments.length>0&&arguments[0]!=""){E=arguments[0];G=G+J+"map="+arguments[0];J="&"}if(arguments.length>1&&arguments[1]!=""){var I=arguments[1];G=G+J+"extents="+arguments[1];J="&"}if(arguments.length>2&&arguments[2]!=""){var B=arguments[2];G=G+J+"scale="+arguments[2];J="&"}if(arguments.length>3&&arguments[3]!=""){var F=arguments[3];G=G+J+"centerPoint="+arguments[3];J="&"}var D=new Array(2900000,1000000,500000,250000,125000,75000,15000,5000);var C=new Array(145000000,58000000,29000000,14500000,7250000,2900000,1000000,500000,250000,125000);var A=new _map("gmap_r","map bg relef",0,5,D);A.setDefaultExtents(22,42,28.8,43);A.setMaxExtents(20,42,28.8,46);A.setBackgroundColor("rgb(136,180,76)");A.addLayer(new _layer("__base__",true,100,"png",false,new Array(1,1,1,1,1,1,1,1)));A.resolution=72;this.addMap(A);var A=new _map("gmap_p","map bg plain",0,5,D);A.setDefaultExtents(22,42,28.8,43);A.setMaxExtents(22,42,28.8,43);A.setBackgroundColor("rgb(97,161,221)");A.addLayer(new _layer("__base__",true,100,"png",false,new Array(1,1,1,1,1,1,1,1)));A.resolution=72;this.addMap(A);var A=new _map("gmap_w","world map",0,5,C);A.setDefaultExtents(-80,20,50,50);A.setMaxExtents(-80,20,50.8,50);A.setBackgroundColor("rgb(0,0,50)");A.addLayer(new _layer("__base__",true,100,"png",false,new Array(1,1,1,1,1,1,1,1,1,1)));A.resolution=72;this.addMap(A);this.tileWidth=200;this.tileHeight=200;this.server="";this.tileURL="/tile.php";if(E){this.selectMap(E)}else{this.selectMap("gmap_r")}if(I){var H=I.split(",");this.zoomToExtents(H[0],H[1],H[2],H[3])}if(F){var H=F.split(",");this.zoomTo(H[0],H[1],H[2])}if(B){this.zoomToScale(B)}this.triggerEvent(KAMAP_INITIALIZED);this.initializationState=2;return true};kaMap.prototype.initializeCallback=function(szInit){if(szInit.substr(0,1)!="/"){this.triggerEvent(KAMAP_ERROR,"ERROR: ka-Map! initialization failed on the server.  Message returned was:\n"+szInit);return false}eval(szInit);this.triggerEvent(KAMAP_INITIALIZED);this.initializationState=2};kaMap.prototype.setBackgroundColor=function(A){this.domObj.style.backgroundColor=A;return true};kaMap.prototype.createLayers=function(){this.theInsideLayer=document.createElement("div");this.theInsideLayer.id="theInsideLayer";this.theInsideLayer.style.position="absolute";this.theInsideLayer.style.left="0px";this.theInsideLayer.style.top="0px";this.theInsideLayer.style.zIndex="1";this.theInsideLayer.kaMap=this;if(this.currentTool){this.theInsideLayer.style.cursor=this.currentTool.cursor}this.domObj.appendChild(this.theInsideLayer);this.domObj.kaMap=this;this.theInsideLayer.onmousedown=kaMap_onmousedown;this.theInsideLayer.onmouseup=kaMap_onmouseup;this.theInsideLayer.onmousemove=kaMap_onmousemove;this.theInsideLayer.onmouseover=kaMap_onmouseover;this.domObj.onmouseout=kaMap_onmouseout;this.theInsideLayer.onkeypress=kaMap_onkeypress;this.theInsideLayer.ondblclick=kaMap_ondblclick;this.theInsideLayer.oncontextmenu=kaMap_oncontextmenu;this.theInsideLayer.onmousewheel=kaMap_onmousewheel;if(window.addEventListener&&navigator.product&&navigator.product=="Gecko"){this.domObj.addEventListener("DOMMouseScroll",kaMap_onmousewheel,false)}this.theInsideLayer.ondragstart=new Function([],"var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;")};kaMap.prototype.initializeLayers=function(Y){var b=this.nCurrentLeft+safeParseInt(this.theInsideLayer.style.left)-this.xOrigin;var B=this.nCurrentTop+safeParseInt(this.theInsideLayer.style.top)-this.yOrigin;var J=this.nCurrentTop-B;var M=this.nCurrentLeft-b;var D=M+this.viewportWidth/2;var C=J+this.viewportHeight/2;var G=Math.floor(D/this.tileWidth)*this.tileWidth;var E=Math.floor(C/this.tileHeight)*this.tileHeight;var S=G-this.nCurrentLeft;var U=E-this.nCurrentTop;var T=D*Y;var R=C*Y;var I=Math.floor(T/this.tileWidth)*this.tileWidth;var H=Math.floor(R/this.tileHeight)*this.tileHeight;var W=I-S;var Q=H-U;this.nCurrentLeft=W;this.nCurrentTop=Q;var A=-T+this.viewportWidth/2;var K=-R+this.viewportHeight/2;var L=this.xOrigin;var X=this.yOrigin;this.xOrigin=this.nCurrentLeft;this.yOrigin=this.nCurrentTop;this.theInsideLayer.style.left=(A+this.xOrigin)+"px";this.theInsideLayer.style.top=(K+this.yOrigin)+"px";var F=this.aMaps[this.currentMap].getLayers();for(var N=0;N<F.length;N++){var V=F[N].domObj;for(var O=0;O<this.nHigh;O++){for(var P=0;P<this.nWide;P++){var Z=V.childNodes[(O*this.nWide)+P];Z.src=this.aPixel.src;Z.style.top=(this.nCurrentTop+O*this.tileHeight-this.yOrigin)+"px";Z.style.left=(this.nCurrentLeft+P*this.tileWidth-this.xOrigin)+"px";F[N].setTile(Z)}}}this.checkWrap();this.updateObjects()};kaMap.prototype.paintLayer=function(A){var E=A.domObj;for(var C=0;C<this.nHigh;C++){for(var D=0;D<this.nWide;D++){var B=E.childNodes[(C*this.nWide)+D];B.style.top=(this.nCurrentTop+C*this.tileHeight-this.yOrigin)+"px";B.style.left=(this.nCurrentLeft+D*this.tileWidth-this.xOrigin)+"px";A.setTile(B)}}this.checkWrap()};kaMap.prototype.updateObjects=function(){for(var A=0;A<this.aObjects.length;A++){var F=this.aObjects[A];var B=(F.xOffset)?F.xOffset:0;var G=(F.yOffset)?F.yOffset:0;var C=this.geoToPix(F.lon,F.lat);var E=(C[1]-this.yOrigin+G);var D=(C[0]-this.xOrigin+B);F.style.top=E+"px";F.style.left=D+"px"}};kaMap.prototype.resize=function(){if(this.initializationState!=2){return false}var D=this.getObjectWidth(this.domObj);var C=this.getObjectHeight(this.domObj);if(this.viewportWidth==null){this.theInsideLayer.style.top=(-1*this.nCurrentTop+this.yOrigin)+"px";this.theInsideLayer.style.left=(-1*this.nCurrentLeft+this.xOrigin)+"px";this.viewportWidth=D;this.viewportHeight=C}var A=Math.ceil((D/this.tileWidth)+2*this.nBuffer);var B=Math.ceil((C/this.tileHeight)+2*this.nBuffer);this.viewportWidth=D;this.viewportHeight=C;if(this.nHigh==0&&this.nWide==0){this.nWide=A}while(this.nHigh<B){this.appendRow()}while(this.nHigh>B&&B>3){this.removeRow()}while(this.nWide<A){this.appendColumn()}while(this.nWide>A&&A>3){this.removeColumn()}var E=this.getCurrentMap();var F=E.getLayers();for(i=0;i<F.length;i++){F[i].setTileLayer()}this.triggerEvent(KAMAP_EXTENTS_CHANGED,this.getGeoExtents());this.triggerEvent(KAMAP_EXTENTS_CHANGED,this.getGeoExtents())};kaMap.prototype.createImage=function(D,C,B){var A=document.createElement("img");A.src=this.aPixel.src;A.width=this.tileWidth;A.height=this.tileHeight;A.setAttribute("style","position:absolute; top:"+D+"px; left:"+C+"px;");A.style.position="absolute";A.style.top=(D-this.yOrigin)+"px";A.style.left=(C-this.xOrigin)+"px";A.style.width=this.tileWidth+"px";A.style.height=this.tileHeight+"px";A.style.visibility="hidden";A.galleryimg="no";A.onerror=kaMap_imgOnError;A.onload=kaMap_imgOnLoad;A.errorCount=0;A.id="i"+this.gImageID;A.layer=B;A.kaMap=this;this.gImageID=this.gImageID+1;return A};kaMap.prototype.resetTile=function(C,B){var A=this.DHTMLapi.getRawObject(C);if(A.layer){A.layer.setTile(this,B)}};kaMap.prototype.reloadImage=function(A){};kaMap.prototype.resetImage=function(A){};kaMap_imgOnError=function(A){if(this.layer){this.layer.setTile(this,true)}};kaMap_imgOnLoad=function(A){this.style.visibility="visible"};kaMap.prototype.appendRow=function(D){if(this.nWide==0){return }if(arguments.length==1){var H=Array(D)}else{var H=this.aMaps[this.currentMap].getLayers()}for(var C=0;C<H.length;C++){var G=H[C].domObj;for(var B=0;B<this.nWide;B++){var F=this.nCurrentTop+(this.nHigh*this.tileHeight);var E=this.nCurrentLeft+(B*this.tileWidth);var A=this.createImage(F,E,H[C]);if(this.isIE4){A.style.filter="Alpha(opacity="+H[C].opacity+")"}G.appendChild(A)}}this.nHigh=this.nHigh+1};kaMap.prototype.appendColumn=function(D){if(this.nHigh==0){return }if(arguments.length==1){var H=Array(D)}else{var H=this.aMaps[this.currentMap].getLayers()}for(var C=0;C<H.length;C++){var G=H[C].domObj;for(var B=this.nHigh-1;B>=0;B--){var F=this.nCurrentTop+(B*this.tileHeight);var E=this.nCurrentLeft+(this.nWide*this.tileWidth);var A=this.createImage(F,E,H[C]);if(this.isIE4){A.style.filter="Alpha(opacity="+H[C].opacity+")"}if(B<this.nHigh-1){G.insertBefore(A,G.childNodes[((B+1)*this.nWide)])}else{G.appendChild(A)}}}this.nWide=this.nWide+1};kaMap.prototype.removeColumn=function(D){if(this.nWide<3){return }if(arguments.length==1){var F=Array(D)}else{var F=this.aMaps[this.currentMap].getLayers()}for(var C=0;C<F.length;C++){var E=F[C].domObj;for(var B=this.nHigh-1;B>=0;B--){var A=E.childNodes[((B+1)*this.nWide)-1];E.removeChild(A);A.onload=null;A.onerror=null}}this.nWide=this.nWide-1};kaMap.prototype.removeRow=function(D){if(this.nHigh<3){return }if(arguments.length==1){var F=Array(D)}else{var F=this.aMaps[this.currentMap].getLayers()}for(var C=0;C<F.length;C++){var E=F[C].domObj;for(var B=this.nWide-1;B>=0;B--){var A=E.childNodes[((this.nHigh-1)*this.nWide)+B];E.removeChild(A);A.onload=null;A.onerror=null}}this.nHigh=this.nHigh-1};kaMap.prototype.hideLayers=function(){if(!this.hideLayersOnMove){return }if(this.layersHidden){return }var B=this.aMaps[this.currentMap].getLayers();for(var A=0;A<B.length;A++){B[A]._visible=B[A].visible;if(B[A].name!="__base__"){B[A].setVisibility(false)}}for(var A=0;A<this.aCanvases.length;A++){this.aCanvases[A].style.visibility="hidden";this.aCanvases[A].style.display="none"}this.layersHidden=true};kaMap.prototype.showLayers=function(){if(!this.hideLayersOnMove){return }if(!this.layersHidden){return }var B=this.aMaps[this.currentMap].getLayers();for(var A=0;A<B.length;A++){B[A].setVisibility(B[A]._visible)}for(var A=0;A<this.aCanvases.length;A++){this.aCanvases[A].style.visibility="visible";this.aCanvases[A].style.display="block"}this.layersHidden=false};kaMap.prototype.moveBy=function(B,C){var A=this.theInsideLayer;A.style.top=(safeParseInt(A.style.top)+C)+"px";A.style.left=(safeParseInt(A.style.left)+B)+"px";this.checkWrap()};kaMap.prototype.slideBy=function(K,J){if(this.slideid!=null){goQueueManager.dequeue(this.slideid)}this.as=[];var C=Math.abs(K);var B=Math.abs(J);var N=K/C;var M=J/B;var A=C>B?C:B;var I=Math.floor(A/this.pixelsPerStep);var P=dy=0;if(I>0){P=(K)/(I*this.pixelsPerStep);dy=(J)/(I*this.pixelsPerStep)}var H=K-P*I*this.pixelsPerStep;var G=J-dy*I*this.pixelsPerStep;var L=py=0;var O=this.accelerationFactor;var F=0;while(F<I){if(F>0){L+=this.as[F-1][0];py+=this.as[F-1][1]}var E=L+Math.round(P*this.pixelsPerStep);var D=py+Math.round(dy*this.pixelsPerStep);this.as[F]=new Array(E-L,D-py);F++}if(H!=0||G!=0){this.as[F]=[H,G]}this.hideLayers();this.slideid=goQueueManager.enqueue(this.timePerStep,this,this.slide,[0])};kaMap.prototype.slide=function(A){if(A>=this.as.length){this.as=slideid=null;this.showLayers();this.triggerEvent(KAMAP_EXTENTS_CHANGED,this.getGeoExtents());return }this.moveBy(this.as[A][0],this.as[A][1]);A++;this.slideid=goQueueManager.enqueue(this.timePerStep,this,this.slide,[A])};kaMap_onkeypress=function(A){if(this.kaMap.currentTool){this.kaMap.currentTool.onkeypress(A)}};kaMap_onmousemove=function(A){A=(A)?A:((event)?event:null);if(A.button==2){this.kaMap.triggerEvent(KAMAP_CONTEXT_MENU)}if(this.kaMap.currentTool){this.kaMap.currentTool.onmousemove(A)}};kaMap_onmousedown=function(A){if(this.kaMap.currentTool){this.kaMap.currentTool.onmousedown(A)}};kaMap_onmouseup=function(A){if(this.kaMap.currentTool){this.kaMap.currentTool.onmouseup(A)}};kaMap_onmouseover=function(A){if(this.kaMap.currentTool){this.kaMap.currentTool.onmouseover(A)}};kaMap_onmouseout=function(A){if(this.kaMap.currentTool){this.kaMap.currentTool.onmouseout(A)}};kaMap_oncontextmenu=function(A){A=A?A:event;if(A.preventDefault){A.preventDefault()}return false};kaMap_ondblclick=function(A){if(this.kaMap.currentTool){this.kaMap.currentTool.ondblclick(A)}};kaMap_onmousewheel=function(A){if(this.kaMap.currentTool){this.kaMap.currentTool.onmousewheel(A)}};kaMap.prototype.cancelEvent=function(A){A=(A)?A:((event)?event:null);A.returnValue=false;if(A.preventDefault){A.preventDefault()}return false};kaMap.prototype.registerTool=function(A){this.aTools.push(A)};kaMap.prototype.activateTool=function(A){if(this.currentTool){this.currentTool.deactivate()}this.currentTool=A;if(this.theInsideLayer){this.setCursor(this.currentTool.cursor)}};kaMap.prototype.deactivateTool=function(A){if(this.currentTool==A){this.currentTool=null}if(this.theInsideLayer){this.theInsideLayer.style.cursor="auto"}};kaMap.prototype.setCursor=function(B){if(B&&B.length&&typeof B=="object"){for(var A=0;A<B.length;A++){this.theInsideLayer.style.cursor=B[A];if(this.theInsideLayer.style.cursor==B[A]){break}}}else{if(typeof B=="string"){this.theInsideLayer.style.cursor=B}else{this.theInsideLayer.style.cursor="auto"}}};kaMap.prototype.checkWrap=function(){this.xOffset=safeParseInt(this.theInsideLayer.style.left)+this.nCurrentLeft-this.xOrigin;this.yOffset=safeParseInt(this.theInsideLayer.style.top)+this.nCurrentTop-this.yOrigin;while(this.xOffset>0){this.wrapR2L()}while(this.xOffset<-(this.nBuffer*this.tileWidth)){this.wrapL2R()}while(this.yOffset>-(this.nBuffer*this.tileHeight)){this.wrapB2T()}while(this.yOffset<-(2*this.nBuffer*this.tileHeight)){this.wrapT2B()}var B=this.aMaps[this.currentMap].aLayers[0].domObj;var A=B.childNodes[0].style;this.nCurrentTop=safeParseInt(A.top)+this.yOrigin;this.nCurrentLeft=safeParseInt(A.left)+this.xOrigin};kaMap.prototype.wrapR2L=function(){this.xOffset=this.xOffset-(this.nBuffer*this.tileWidth);var G=this.aMaps[this.currentMap].getLayers();for(var A=0;A<G.length;A++){var F=G[A].domObj;var C=safeParseInt(F.childNodes[0].style.left);for(var B=0;B<this.nHigh;B++){var E=F.childNodes[((B+1)*this.nWide)-1];var D=F.childNodes[B*this.nWide];E.style.left=(C-this.tileWidth)+"px";E.src=this.aPixel.src;F.removeChild(E);F.insertBefore(E,D);if(G[A].visible){G[A].setTile(E)}}}};kaMap.prototype.wrapL2R=function(){this.xOffset=this.xOffset+(this.nBuffer*this.tileWidth);var G=this.aMaps[this.currentMap].getLayers();for(var B=0;B<G.length;B++){var F=G[B].domObj;var D=safeParseInt(F.childNodes[this.nWide-1].style.left);for(var C=0;C<this.nHigh;C++){var A=F.childNodes[C*this.nWide];var E;if(C<this.nHigh-1){E=F.childNodes[((C+1)*this.nWide)]}else{E=null}A.style.left=(D+this.tileWidth)+"px";A.src=this.aPixel.src;F.removeChild(A);if(E){F.insertBefore(A,E)}else{F.appendChild(A)}if(G[B].visible){G[B].setTile(A)}}}};kaMap.prototype.wrapT2B=function(){this.yOffset=this.yOffset+(this.nBuffer*this.tileHeight);var F=this.aMaps[this.currentMap].getLayers();for(var B=0;B<F.length;B++){var E=F[B].domObj;var A=safeParseInt(E.childNodes[(this.nHigh*this.nWide)-1].style.top);for(var C=0;C<this.nWide;C++){var D=E.childNodes[0];D.style.top=(A+this.tileHeight)+"px";D.src=this.aPixel.src;E.removeChild(D);E.appendChild(D);if(F[B].visible){F[B].setTile(D)}}}};kaMap.prototype.wrapB2T=function(){this.yOffset=this.yOffset-(this.nBuffer*this.tileHeight);var F=this.aMaps[this.currentMap].getLayers();for(var B=0;B<F.length;B++){var E=F[B].domObj;var A=safeParseInt(E.childNodes[0].style.top);for(var D=0;D<this.nWide;D++){var C=E.childNodes[(this.nHigh*this.nWide)-1];C.style.top=(A-this.tileHeight)+"px";C.src=this.aPixel.src;E.removeChild(C);E.insertBefore(C,E.childNodes[0]);if(F[B].visible){F[B].setTile(C)}}}};kaMap.prototype.addMap=function(A){A.kaMap=this;this.aMaps[A.name]=A};kaMap.prototype.getMaps=function(){return this.aMaps};kaMap.prototype.getCurrentMap=function(){return this.aMaps[this.currentMap]};kaMap.prototype.selectMap=function(B){if(!this.aMaps[B]){return false}else{if(this.initializationState==2){var A=this.getCurrentMap();var C=this.getGeoExtents()}this.currentMap=B;var A=this.getCurrentMap();this.setBackgroundColor(A.backgroundColor);this.setMapLayers();if(A.aZoomTo.length!=0){this.zoomTo(A.aZoomTo[0],A.aZoomTo[1],A.aZoomTo[2]);A.aZoomTo.length=0}else{this.zoomToExtents(A.currentExtents[0],A.currentExtents[1],A.currentExtents[2],A.currentExtents[3])}if(C){this.zoomToExtents(C[0],C[1],C[2],C[3])}this.triggerEvent(KAMAP_MAP_INITIALIZED,this.currentMap);return true}};kaMap.prototype.setMapLayers=function(){var A=this.getCurrentMap();for(var B=this.theInsideLayer.childNodes.length-1;B>=0;B--){if(this.theInsideLayer.childNodes[B].className=="mapLayer"){this.theInsideLayer.childNodes[B].appended=false;this.theInsideLayer.removeChild(this.theInsideLayer.childNodes[B])}}layers=A.getLayers();for(var B=0;B<layers.length;B++){if(!layers[B].domObj){var C=this.createMapLayer(layers[B].name);this.theInsideLayer.appendChild(C);C.appended=true;layers[B].domObj=C;layers[B].setOpacity(layers[B].opacity);layers[B].setZIndex(layers[B].zIndex);layers[B].setVisibility(layers[B].visible);this.nWide=0;this.nHigh=0;this.drawGroup(layers[B])}else{if(!layers[B].domObj.appended){this.theInsideLayer.appendChild(layers[B].domObj);layers[B].domObj.appended=true;layers[B].setZIndex(layers[B].zIndex)}}}return true};kaMap.prototype.drawGroup=function(E){var D=this.getObjectWidth(this.domObj);var C=this.getObjectHeight(this.domObj);if(this.viewportWidth==null){this.theInsideLayer.style.top=(-1*this.nCurrentTop+this.yOrigin)+"px";this.theInsideLayer.style.left=(-1*this.nCurrentLeft+this.xOrigin)+"px";this.viewportWidth=D;this.viewportHeight=C}var A=Math.ceil((D/this.tileWidth)+2*this.nBuffer);var B=Math.ceil((C/this.tileHeight)+2*this.nBuffer);this.viewportWidth=D;this.viewportHeight=C;if(this.nHigh==0&&this.nWide==0){this.nWide=A}while(this.nHigh<B){this.appendRow(E)}while(this.nHigh>B){this.removeRow(E)}while(this.nWide<A){this.appendColumn(E)}while(this.nWide>A){this.removeColumn(E)}return true};kaMap.prototype.createMapLayer=function(B){var A=document.createElement("div");A.id=B;A.className="mapLayer";A.style.position="absolute";A.style.visibility="visible";A.style.left="0px";A.style.top="0px";A.style.width="3000px";A.style.height="3000px";A.appended=false;return A};kaMap.prototype.addMapLayer=function(A){var B=this.getCurrentMap();B.addLayer(A);this.setMapLayers();this.paintLayer(A);this.triggerEvent(KAMAP_LAYERS_CHANGED,this.currentMap)};kaMap.prototype.removeMapLayer=function(C){var B=this.getCurrentMap();var A=B.getLayer(C);if(!A){return false}if(B.removeLayer(B.getLayer(C))){this.setMapLayers();this.triggerEvent(KAMAP_LAYERS_CHANGED,this.currentMap)}};kaMap.prototype.getCenter=function(){var D=this.nCurrentLeft-this.xOrigin+safeParseInt(this.theInsideLayer.style.left);var E=this.nCurrentTop-this.yOrigin+safeParseInt(this.theInsideLayer.style.top);var B=this.nCurrentTop-E;var F=this.nCurrentLeft-D;var C=F+this.viewportWidth/2;var A=B+this.viewportHeight/2;return new Array(C,A)};kaMap.prototype.getGeoExtents=function(){var B=-1*(safeParseInt(this.theInsideLayer.style.left)-this.xOrigin)*this.cellSize;var D=B+this.viewportWidth*this.cellSize;var C=(safeParseInt(this.theInsideLayer.style.top)-this.yOrigin)*this.cellSize;var A=C-this.viewportHeight*this.cellSize;return[B,A,D,C]};kaMap.prototype.zoomIn=function(){this.zoomByFactor(this.aMaps[this.currentMap].zoomIn())};kaMap.prototype.zoomOut=function(){this.zoomByFactor(this.aMaps[this.currentMap].zoomOut())};kaMap.prototype.zoomToScale=function(A){this.zoomByFactor(this.aMaps[this.currentMap].zoomToScale(A))};kaMap.prototype.zoomByFactor=function(A){if(A==1){this.triggerEvent(KAMAP_NOTICE,"NOTICE: changing to current scale aborted");return }this.cellSize=this.cellSize/A;this.setMapLayers();this.initializeLayers(A);this.triggerEvent(KAMAP_SCALE_CHANGED,this.getCurrentScale());this.triggerEvent(KAMAP_EXTENTS_CHANGED,this.getGeoExtents())};kaMap.prototype.getCurrentScale=function(){return this.aMaps[this.currentMap].aScales[this.aMaps[this.currentMap].currentScale]};kaMap.prototype.setLayerQueryable=function(B,A){this.aMaps[this.currentMap].setLayerQueryable(B,A)};kaMap.prototype.setLayerVisibility=function(B,A){if(!this.loadUnchecked&&A){layer=this.aMaps[this.currentMap].getLayer(B);layer.visible=true;this.setMapLayers();this.aMaps[this.currentMap].setLayerVisibility(B,A);this.paintLayer(layer)}else{this.aMaps[this.currentMap].setLayerVisibility(B,A)}};kaMap.prototype.setLayerOpacity=function(A,B){this.aMaps[this.currentMap].setLayerOpacity(A,B)};kaMap.prototype.registerEventID=function(A){return this.eventManager.registerEventID(A)};kaMap.prototype.registerForEvent=function(A,C,B){return this.eventManager.registerForEvent(A,C,B)};kaMap.prototype.deregisterForEvent=function(A,C,B){return this.eventManager.deregisterForEvent(A,C,B)};kaMap.prototype.triggerEvent=function(A){return this.eventManager.triggerEvent.apply(this.eventManager,arguments)};function safeParseInt(A){return Math.round(parseFloat(A))}function _map(B,D,E,A,C){this.name=B;this.title=D;this.aScales=C;this.currentScale=parseFloat(E);this.units=A;this.resolution=72;this.aLayers=[];this.defaultExtents=[];this.currentExtents=[];this.maxExtents=[];this.backgroundColor="#ffffff";this.version="0";this.aZoomTo=[];this.kaMap=null}_map.prototype.addLayer=function(A){A._map=this;A.zIndex=this.aLayers.length;this.aLayers.push(A)};_map.prototype.removeLayer=function(A){var B=Array();for(i=0,a=0;i<this.aLayers.length;i++){if(this.aLayers[i]!=A){B[a]=this.aLayers[i];a++}}this.aLayers=B;return true};_map.prototype.getQueryableLayers=function(){var C=[];var A=this.getLayers();for(var B=0;B<A.length;B++){if(A[B].isQueryable()){C.push(A[B])}}return C};_map.prototype.getLayers=function(){var B=[];for(var A=0;A<this.aLayers.length;A++){if(this.aLayers[A].isVisible()&&(this.aLayers[A].visible||this.kaMap.loadUnchecked)){B.push(this.aLayers[A])}}return B};_map.prototype.getAllQueryableLayers=function(){var B=[];for(var A=0;A<this.aLayers.length;A++){if(this.aLayers[A].isQueryable()){B.push(this.aLayers[A])}}return B};_map.prototype.getAllLayers=function(){return this.aLayers};_map.prototype.getLayer=function(A){for(var B=0;B<this.aLayers.length;B++){if(this.aLayers[B].name==A){return this.aLayers[B]}}};_map.prototype.getScales=function(){return this.aScales};_map.prototype.zoomIn=function(){var A=1;if(this.currentScale<this.aScales.length-1){A=this.aScales[this.currentScale]/this.aScales[this.currentScale+1];this.currentScale=this.currentScale+1}return A};_map.prototype.zoomOut=function(){var A=1;if(this.currentScale>0){A=this.aScales[this.currentScale]/this.aScales[this.currentScale-1];this.currentScale=this.currentScale-1}return A};_map.prototype.zoomToScale=function(C){var B=1;for(var A=0;A<this.aScales.length;A++){if(this.aScales[A]==C){B=this.aScales[this.currentScale]/C;this.currentScale=parseInt(A)}}return B};_map.prototype.setLayerQueryable=function(B,A){var C=this.getLayer(B);C.setQueryable(A)};_map.prototype.setLayerVisibility=function(B,A){var C=this.getLayer(B);C.setVisibility(A)};_map.prototype.setLayerOpacity=function(A,C){var B=this.getLayer(A);B.setOpacity(C)};_map.prototype.setDefaultExtents=function(B,A,D,C){this.defaultExtents=[B,A,D,C];if(this.currentExtents.length==0){this.setCurrentExtents(B,A,D,C)}};_map.prototype.setCurrentExtents=function(B,A,D,C){this.currentExtents=[B,A,D,C]};_map.prototype.setMaxExtents=function(B,A,D,C){this.maxExtents=[B,A,D,C]};_map.prototype.setBackgroundColor=function(A){this.backgroundColor=A};function _layer(D,A,C,E,B,F){this.name=D;this.visible=A;this.opacity=C;this.domObj=null;this._map=null;this.imageformat=E;this.queryable=B;this.queryState=B;if(F){this.scales=F}else{this.scales=Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)}this.toLoad=0}_layer.prototype.isQueryable=function(){return this.queryState};_layer.prototype.setQueryable=function(A){if(this.queryable){this.queryState=A}};_layer.prototype.isVisible=function(){return(this.scales[this._map.currentScale]==1)?true:false};_layer.prototype.setOpacity=function(A){this.opacity=A;if(this.domObj){this.domObj.style.opacity=A/100;this.domObj.style.mozOpacity=A/100;for(var B=0;B<this.domObj.childNodes.length;B++){this.domObj.childNodes[B].style.filter="Alpha(opacity="+A+")"}}};_layer.prototype.setTile=function(G){var I="";var B="";if(arguments[1]){I="&force=true"}var E="&g="+G.layer.domObj.id;var H="&s="+this._map.aScales[this._map.currentScale];var C="";var D="";if(G.layer.imageformat&&G.layer.imageformat!=""){D=G.layer.imageformat;C="&i="+D}var F=safeParseInt(G.style.left)+this._map.kaMap.xOrigin;var J=safeParseInt(G.style.top)+this._map.kaMap.yOrigin;var A=this._map.kaMap.server+this._map.kaMap.tileURL+"?map="+this._map.name+"&t="+J+"&l="+F+H+I+E+C;if((this.isIE4)&&(D.toLowerCase()=="png24")){G.style.visibility="hidden";G.src=this._map.kaMap.aPixel.src;G.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+A+"', sizingMethod='scale')"}else{if(G.src!=A){G.style.visibility="hidden";G.src=this._map.kaMap.server+this._map.kaMap.tileURL+"?map="+this._map.name+"&t="+J+"&l="+F+H+I+E+C}}};_layer.prototype.setVisibility=function(A){this.visible=A;if(this.domObj){this.domObj.style.visibility=A?"visible":"hidden";this.domObj.style.display=A?"block":"none"}for(var B=0;B<this.domObj.childNodes.length;B++){this.setTile(this.domObj.childNodes[B])}};_layer.prototype.setZIndex=function(A){this.zIndex=A;if(this.domObj){this.domObj.style.zIndex=A}};_layer.prototype.setTileLayer=function(){var H="";var B="";this.loaded=0;if(arguments[0]){H="&force=true"}var E="&g="+this.name;var G="&s="+this._map.aScales[this._map.currentScale];var C="";var D="";if(this.imageformat&&this.imageformat!=""){D=this.imageformat;C="&i="+D}for(i=0;i<this.domObj.childNodes.length;i++){img=this.domObj.childNodes[i];var F=safeParseInt(img.style.left)+this._map.kaMap.xOrigin;var I=safeParseInt(img.style.top)+this._map.kaMap.yOrigin;var A=this._map.kaMap.server+this._map.kaMap.tileURL+"?map="+this._map.name+"&t="+I+"&l="+F+G+H+E+C;if((this.isIE4)&&(D.toLowerCase()=="png24")){img.style.visibility="hidden";img.src=this._map.kaMap.aPixel.src;img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+A+"', sizingMethod='scale')"}else{if(img.src!=A){img.style.visibility="hidden";img.src=this._map.kaMap.server+this._map.kaMap.tileURL+"?map="+this._map.name+"&t="+I+"&l="+F+G+H+E+C}}}};function _eventManager(){this.events=[];this.lastEventID=0}_eventManager.prototype.registerEventID=function(A){var B=new String(A);if(!this.events[A]){this.events[A]=[]}};_eventManager.prototype.registerForEvent=function(A,D,C){var B=new String(A);this.events[A].push([D,C])};_eventManager.prototype.deregisterForEvent=function(A,F,D){var C=new String(A);var E=false;if(!this.events[A]){return false}for(var B=0;B<this.events[A].length;B++){if(this.events[A][B][0]==F&&this.events[A][B][1]==D){this.events[A].splice(B,1);E=true}}return E};_eventManager.prototype.triggerEvent=function(B){var D=new String(B);if(!this.events[B]){return false}var A=new Array();for(C=1;C<arguments.length;C++){A[A.length]=arguments[C]}for(var C=0;C<this.events[B].length;C++){this.events[B][C][1].apply(this.events[B][C][0],arguments)}return true};var goQueueManager=new _queueManager();function _queueManager(){this.queue=new Array()}_queueManager.prototype.enqueue=function(A,E,D,B){var G=this.queue.length;for(var C=0;C<this.queue.length;C++){if(this.queue[C]==null){G=C;break}}var F=window.setTimeout("_queueManager_execute("+G+")",A);this.queue[G]=new Array(F,E,D,B);return G};_queueManager.prototype.dequeue=function(A){if(this.queue[A]!=null){window.clearTimeout(this.queue[A][0]);this.queue[A]=null}};function _queueManager_execute(C){if(goQueueManager.queue[C]!=null){var B=goQueueManager.queue[C][1];var A=goQueueManager.queue[C][2];if(goQueueManager.queue[C][3]!=null){A.apply(B,goQueueManager.queue[C][3])}else{A.apply(B)}goQueueManager.queue[C]=null}};