var iSmoothMoveToCenterFlag=null;var iPan=new Pan();function Pan(){var g=null;var q=0;var r=0;var n=null;var o=null;var s=0;var k=this;var Q=0;var R=0;var t=0;var u=0;var z=100;var v=0;var w=0;var E="choiceMenu";var A=true;iGlobalZoomListener.addListener(this);iGlobalPanListener.addListener(this);iFirstTimeLoadListener.addListener(this);this.setListenerCreatingParam=function(a){A=a};this.onFirstTimeLoad=function(){t=iWidth/2;u=iHeight/2};this.onZoom=function(){iSmoothMoveToCenterFlag=null};this.onPan=function(){p()};this.onMapTouchStart=function(a){x();s=iVbWidth/iWidth;iPointData.clearTimeouts();iPointData.hideIcons(true)};this.onMapTouchMove=function(a){var b=a.touches.item(0);var d=b.clientX;var c=b.clientY;F(d,c)};this.onMapTouchEnd=function(a){G()};this.onMapMouseDown=function(a){var b=getXFromEvent(a,true);var d=getYFromEvent(a,true);var c=null;if(a){c=a.button}else{var f=window.event;c=f.button}J(b,d,c)};function J(a,b,d){p();x();s=iVbWidth/iWidth;q=a;r=b;if(d===2){var c=new ListMenuWnd(iDoc,Browser.type);var f=q-5;var i=r-5;if(Browser.type===0&&(Browser.vers<9||Browser.mode===0)){f=f-iGraphicsDiv.offsetLeft+document.body.scrollLeft;i=i-iGraphicsDiv.offsetTop+document.body.scrollTop}var j=c.getMenuWnd(f,i,E);try{iHandleService.mapRightMouseClick(c)}catch(e){var h='Zoom in';var l='Zoom out';var m='Center map';var y='Close';try{h=wZoomIn;l=wZoomOut;m=wCenterMap;y=wClose}catch(e2){}c.addNewLine(h,k,"zoom in");c.addNewLine(l,k,"zoom out");c.addNewLine(m,k,"center map");c.addNewLine(y,k,"close")}iGraphicsDiv.appendChild(j)}else{if(A){iPointData.clearTimeouts();iPointData.hideIcons(true);K()}else{A=true}}}function L(){var a=0;if(Browser.type===0){a=iGraphicsDiv.offsetLeft-document.body.scrollLeft}var b=q-a;return b}function M(){var a=0;if(Browser.type===0){a=iGraphicsDiv.offsetTop-document.body.scrollTop}var b=r-a;return b}this.setXY=function(a,b){q=a;r=b};this.handleCommand=function(a){if((a==="zoom in")||(a==="zoom out")||(a==="center map")){iPointData.hideIcons();var b=L();var d=M();var c=t-b;var f=u-d;var i=Math.ceil(Math.abs(c)/20);var j=Math.ceil(Math.abs(f)/20);var h=i;if(h8){h=8}v=c/h;w=f/h;setTimeout(function(){H(b,d,v,w,a)},z);iGlobalSmallPanListener.notifyListeners();k.handleCommand("close")}if(a==="close"){x()}};this.centerMapWithGlobalCoords=function(a,b,d){if((d==="zoomTo")&&(iSmoothMoveToCenterFlag)){var c=iZoomBar.getCursorCellId();c=Math.round(c);if(c<8){iZoomBar.onZoomOut();setTimeout(function(){k.centerMapWithGlobalCoords(null,null,"zoomTo")},400)}else{iGlobalZoomListener.notifyListeners()}}};this.centerMapOnIcon=function(a,b){iGlobalSmallPanListener.notifyListeners();var d=iVbX+(a-t)*iVbWidth/iWidth;var c=iVbY+(b-u)*iVbHeight/iHeight;iBasic.setViewBox(d,c,iVbWidth,iVbHeight);iGlobalPanListener.notifyListeners()};this.smoothMoveToCenterMapWithGlobalCoords=function(a,b,d){var c=iVbX+(iVbWidth/2);var f=iVbY+(iVbHeight/2);I(c,f,a,b,8,d)};function I(a,b,d,c,f,i){if(f>0){var j=(a-d)/f;var h=(b-c)/f;a=a-j;b=b-h;var l=a-(iVbWidth/2);var m=b-(iVbHeight/2);iBasic.setViewBox(l,m,iVbWidth,iVbHeight);f=f-1;iGlobalSmallPanListener.notifyListeners();setTimeout(function(){I(a,b,d,c,f,i)},z)}else{k.centerMapWithGlobalCoords(d,c,"zoomTo");if(i){iPointData.setDoNotShowParam(true);iGlobalPanListener.notifyListeners()}}}function H(a,b,d,c,f){var i=iVbWidth/iWidth;var j=iVbHeight/iHeight;var h=Math.abs(t-a);var l=Math.abs(u-b);if((d<=h)&&(c<=l)){var m=iVbX-(v)*i;var y=iVbY-(w)*j;iBasic.setViewBox(m,y,iVbWidth,iVbHeight);var N=d+Math.abs(v);var O=c+Math.abs(w);setTimeout(function(){H(a,b,N,O,f)},z)}else{if(f==="zoom in"){iZoomBarCurrent.zoomIn()}if(f==="zoom out"){iZoomBarCurrent.zoomOut()}iGlobalPanListener.notifyListeners()}}this.destroyChoiceMenuPublic=function(){x()};function x(){var a=iDoc.getElementById(E);if(a){a.parentNode.removeChild(a)}try{iMenuWnd.destroyMenu()}catch(e){}}function K(){var a=null;g=iDrawingTools.createRectangle(0,0,iWidth,iHeight,"white","white",0,0);if(!Browser.SVG){a=iDrawingTools.createGroup(null,iWidth,iHeight,0,0,iWidth,iHeight);g.onmouseup=B;g.onmouseout=C;g.onmousemove=D}else{a=iDrawingTools.createElement("svg");a.setAttribute("width",iWidth);a.setAttribute("height",iHeight);a.setAttribute("viewBox","0 0 "+iWidth+" "+iHeight);g.addEventListener("mouseup",B,false);g.addEventListener("mouseout",C,false);g.addEventListener("mousemove",D,false)}a.style.position="absolute";a.style.top="0px";a.style.left="0px";a.appendChild(g);if(Browser.type!==0||!Browser.SVG){g.style.cursor="url('"+iPath+"img/cursordown.cur'), default"}iGraphicsDiv.appendChild(a)}this.removeListener=function(){p()};function p(){if(g){if(Browser.SVG){g.removeEventListener("mouseup",B,false);g.removeEventListener("mouseout",C,false);g.removeEventListener("mousemove",D,false)}g.parentNode.parentNode.removeChild(g.parentNode);g=null;G()}}function G(){n=null;o=null;iGlobalPanListener.notifyListeners()}function B(a){p()}function C(){p()}function D(a,b){var d=0;var c=0;if(a){d=a.layerX;c=a.layerY}else{var f=window.event;d=f.clientX;c=f.clientY}F(d,c)}function F(a,b){if(n!==null&&o!==null){var d=s*(n-a);var c=s*(o-b);n=a;o=b;newX=iVbX+d;newY=iVbY+c;iBasic.setViewBox(newX,newY,iVbWidth,iVbHeight);iGlobalSmallPanListener.notifyListeners()}else{n=a;o=b}iPointData.checkStayOnMoveAndRecalc()}this.moveToDir=function(a){P(a)};function P(a){var b=iVbX;var d=iVbY;if(a==="N"){var c=Math.round(iVbHeight/3);d=iVbY-c}else if(a==="E"){var f=Math.round(iVbWidth/3);b=iVbX+f}else if(a==="S"){var i=Math.round(iVbHeight/3);d=iVbY+i}else if(a==="W"){var j=Math.round(iVbWidth/3);b=iVbX-j}iPointData.hideIcons();iBasic.setViewBox(b,d,iVbWidth,iVbHeight);iGlobalSmallPanListener.notifyListeners();iGlobalPanListener.notifyListeners()}}