/* Copyright (c) 2006-2007 Position s.r.o. */ngMapVer=1;ngMapSubVer=1;ngMapAPIVersion=ngMapVer+'.'+ngMapSubVer;ngMapAPIKey='';ngCurrentMap=null;ngMouseMap=null;ngKeyMap=null;CTRL_DOWN=false;PROJ_WGS='WGS-84';PROJ_UTM='UTM';curZoomIn=101;curZoomOut=102;curPan=103;curDefault=0;OnKeyDownBefore=null;OnKeyDownAfter=null;OnKeyUpBefore=null;OnKeyUpAfter=null;OnMouseDownBefore=null;OnMouseDownAfter=null;OnMouseUpBefore=null;OnMouseUpAfter=null;OnMouseMoveBefore=null;OnMouseMoveAfter=null;OnDblClickBefore=null;OnDblClickAfter=null;OnMouseWheelBefore=null;OnMouseWheelAfter=null;ngMapEventsInitialized=false;function PosProj(pos,proj){if(proj!='')pos=proj+';'+pos;return pos}function FormatScale(s){s=String(s);var i=s.indexOf('.');if(i<0)i=s.indexOf(',');if(i>=0)s=s.substring(0,i);var i,j;var o='';j=0;for(i=s.length-1;i>=0;i--){if((j!=0)&&((j%3)==0))o=' '+o;o=s.charAt(i)+o;j++}return o}function PopupIcon(id,url,pos,descr,hotspot){this.id=id;this.url=url;this.pos=pos;this.descr=descr;this.hotspot=hotspot;this.update=true;if(url!=''){this.icon=ngPreloadedImages[url];if(typeof this.icon!='object'){this.icon=ng_PreloadImage(url);}}else this.icon=null}function ng_StartAnimation(){this.LastAnimationTime=new Date().getTime();if(!this.AnimationStarted){this.AnimationStarted=true;if(this.OnStartAnimation)this.OnStartAnimation(this);}}function ng_EndAnimation(){if(this.AnimationStarted){this.AnimationStarted=false;if(this.OnEndAnimation)this.OnEndAnimation(this);}}function ng_CancelMapMove(){this.EndAnimation();this.PanNoPosChanged=false;if(this.PanTimer)clearTimeout(this.PanTimer);this.PanTimer=null}function ng_DoPan(mapid){var map=getMapByID(mapid);if(!map)return;if(map.PanTimer)clearTimeout(map.PanTimer);map.PanTimer=null;var stime=map.LastAnimationTime;var cnt=0;var cycles=1;while(cnt<cycles){map.PanX+=map.PanSX;map.PanY+=map.PanSY;if(map.PanSX<0){if((map.PanDX-map.PanX)>map.PanSX)map.PanSX=map.PanDX-map.PanX}else if((map.PanDX-map.PanX)<map.PanSX)map.PanSX=map.PanDX-map.PanX;if(map.PanSY<0){if((map.PanDY-map.PanY)>map.PanSY)map.PanSY=map.PanDY-map.PanY}else if((map.PanDY-map.PanY)<map.PanSY)map.PanSY=map.PanDY-map.PanY;if((!cnt)||((map.PanSX==0)&&(map.PanSY==0))){map.SetMapOffsetEx(map.PanStartX+map.PanX,map.PanStartY+map.PanY);if((map.PanSX==0)&&(map.PanSY==0))break}if((!cnt)&&(stime)){var etime=new Date().getTime();cycles=(etime-stime)/map.PanDelay;var max=(map.PanMinInterval/map.PanDelay)/4;if(cycles>max)cycles=max}cnt++}map.LastAnimationTime=(new Date().getTime())+map.PanDelay;if((map.PanSX!=0)||(map.PanSY!=0))map.PanTimer=setTimeout('ng_DoPan(\''+mapid+'\');',map.PanDelay);else{if(!map.PanNoPosChanged){map.MapCommand('P');}map.EndAnimation();}}function ng_DoImageZoomAnim(mapid){var map=getMapByID(mapid);if(!map)return;if(map.PanTimer)clearTimeout(map.PanTimer);map.PanTimer=null;var d;var stime=map.LastAnimationTime;var cnt=0;var cycles=1;while(cnt<cycles){map.ImageZoomC+=map.ImageZoomD;if(map.ImageZoomD<0){if((map.ImageZoomF-map.ImageZoomC)>map.ImageZoomD)map.ImageZoomD=map.ImageZoomF-map.ImageZoomC}else if((map.ImageZoomF-map.ImageZoomC)<map.ImageZoomD)map.ImageZoomD=map.ImageZoomF-map.ImageZoomC;if((!cnt)||(map.ImageZoomD==0)){if(map.ImageZoomNC){map.SetImageZoom(map.ImageZoomC,map.ImageZoomL,map.ImageZoomX,map.ImageZoomY,map.ImageZoomCX,map.ImageZoomCY);}else{if(map.ImageZoomF>map.ImageZoomS)d=(map.ImageZoomF-map.ImageZoomC)/(map.ImageZoomF-map.ImageZoomS);else d=(map.ImageZoomC-map.ImageZoomF)/(map.ImageZoomS-map.ImageZoomF);d=1-(d*map.ImageZoomC);map.SetImageZoom(map.ImageZoomC,map.ImageZoomL,map.ImageZoomX-map.ImageZoomDX*d,map.ImageZoomY-map.ImageZoomDY*d,map.ImageZoomCX+map.ImageZoomDX*d,map.ImageZoomCY+map.ImageZoomDY*d);}if(map.ImageZoomD==0)break}if((!cnt)&&(stime)){var etime=new Date().getTime();cycles=(etime-stime)/map.PanDelay;var max=(map.PanMinInterval/map.PanDelay)/4;if(cycles>max)cycles=max}cnt++}map.LastAnimationTime=(new Date().getTime())+map.PanDelay;if(map.ImageZoomD!=0)map.PanTimer=setTimeout('ng_DoImageZoomAnim(\''+mapid+'\');',map.PanDelay);else{map.CancelImageZoomAnim();map.EndAnimation();}}function ng_ImageZoomAnimFinished(){if((this.TileLoadingCnt<=0)&&(this.ImageZoomL==-1))this.HideSecondMapLayer();}function ng_CancelImageZoomAnim(){if(map.ImageZoomPan){if(map.ImageZoomPan==1)map.SetMapOffset(map.ImageZoomPanX,map.ImageZoomPanY);if(map.ImageZoomPan==2)map.SetMapOffsetEx(map.ImageZoomPanX,map.ImageZoomPanY);map.ImageZoomPan=0}if(this.ImageZoomL==-1)return;this.CancelMapMove();this.SwapMapLayers(this.MapLayer==1?2:1);this.ImageZoomL=-1;this.ShowCanvas();this.ImageZoomAnimFinished();}function ng_ImageZoomAnim(x,y,cx,cy,f,t,nc){this.ImageZoomHookPan=false;if(this.ImageZoomL==-1)return;this.HideCanvas();this.CancelMapMove();this.ClearCanvas();if(this.ZoomAnimation){this.ImageZoomX=x;this.ImageZoomY=y;cx+=(this.MapWidth-this.TileWidth)/2;cy+=(this.MapHeight-this.TileHeight)/2;this.ImageZoomDX=this.MapWidth/2-cx;this.ImageZoomDY=this.MapHeight/2-cy;this.ImageZoomCX=cx;this.ImageZoomCY=cy;this.ImageZoomS=f;this.ImageZoomC=f;this.ImageZoomF=t;this.ImageZoomNC=(typeof nc!='undefined'?nc:false);this.ImageZoomD=(this.ImageZoomF-this.ImageZoomC)/(this.PanMinInterval/this.PanDelay);this.StartAnimation();ng_DoImageZoomAnim(this.MapID);}else{this.CancelImageZoomAnim();}}function ng_Pan(dx,dy){this.HideSecondMapLayer();this.CancelMapCommand();this.CancelMapMove();this.HideMapMenu();this.HidePopup();this.CancelDisplayPopup();if(this.PanAnimation){this.PanDX=dx;this.PanDY=dy;this.PanStartX=this.X;this.PanStartY=this.Y;this.PanX=0;this.PanY=0;this.PanSX=dx/(this.PanMinInterval/this.PanDelay);this.PanSY=dy/(this.PanMinInterval/this.PanDelay);this.StartAnimation();ng_DoPan(this.MapID);}else{this.SetMapOffsetEx(this.X+dx,this.Y+dy);if(!this.PanNoPosChanged)this.PositionChanged();}}function ng_EnterMap(e){if(!e)e=window.event;if((this.ngMap)&&((!ngCurrentMap)||(ng_CheckMouseEnter(this,e)))){if(ngCurrentMap)ngCurrentMap.MouseOnMap=false;ngCurrentMap=this.ngMap;ngCurrentMap.MouseOnMap=true;if(ngCurrentMap.OnMouseEnter)ngCurrentMap.OnMouseEnter(ngCurrentMap);}}function ng_LeaveMap(e){if(!e)e=window.event;if((this.ngMap==ngCurrentMap)&&(ng_CheckMouseLeave(this,e))){if(ngCurrentMap){ngCurrentMap.MouseOnMap=false;if(ngCurrentMap.OnMouseLeave)ngCurrentMap.OnMouseLeave(ngCurrentMap);}ngCurrentMap=null}}function ng_MapContainerLeft(){var o=this.ObjMap[0];if(o)return ng_findPosX(o);return 0}function ng_MapContainerTop(){var o=this.ObjMap[0];if(o)return ng_findPosY(o);return 0}function ng_GetMousePosition(e){if(!e)e=window.event;var ox=this.MouseX;var oy=this.MouseY;this.MouseX=(e.clientX?e.clientX:e.offsetX)-this.MapContainerLeft()+ng_DocumentScrollX();this.MouseY=(e.clientY?e.clientY:e.offsetY)-this.MapContainerTop()+ng_DocumentScrollY();if(this.OnGetMousePosition)this.OnGetMousePosition(this);if(isNaN(this.MouseX))this.MouseX=ox;if(isNaN(this.MouseY))this.MouseY=oy}function ng_SetCursor(c){var cur='';var setcursor=this.MouseEvents;switch(c){case curDefault:cur='';break;case curZoomIn:cur=this.CursorZoomIn;break;case curZoomOut:cur=this.CursorZoomOut;break;case curPan:cur=this.CursorPan;break;default:cur=c;setcursor=true;break}if(this.CurrentCursor!=cur){if(setcursor){if(this.ObjMap[1]){try{this.ObjMap[1].style.cursor=cur}catch(e){}}if(this.ObjMap[2]){try{this.ObjMap[2].style.cursor=cur}catch(e){}}if(this.ObjCanvasDC){try{this.ObjCanvasDC.style.cursor=cur}catch(e){}}if(this.ObjSelRect){try{this.ObjSelRect.style.cursor=cur}catch(e){}}if(this.ObjSelRect2){try{this.ObjSelRect2.style.cursor=cur}catch(e){}}if(this.ObjPreview){try{this.ObjPreview.style.cursor=cur}catch(e){}}var o=document.getElementById(this.MapID+'_ImgMap');if(o){try{o.style.cursor=cur}catch(e){}}}this.CurrentCursor=cur}}function ng_SyncCursor(mapid,elm){var map=getMapByID(mapid);if(map){try{if(elm.style.cursor!=map.CurrentCursor)elm.style.cursor=map.CurrentCursor}catch(e){}}}function ng_UpdateRect(){var o1=this.ObjSelRect;var o2=this.ObjSelRect2;if((o1)&&(o2)){o2.style.width=o1.style.width;o2.style.height=o1.style.height;o2.style.left=o1.style.left;o2.style.top=o1.style.top;o2.style.visibility=o1.style.visibility}}function ng_UpdateRectIE(){var o1=this.ObjSelRect;var o2=this.ObjSelRect2;if((o1)&&(o2)){o2.style.pixelWidth=o1.style.pixelWidth;o2.style.pixelHeight=o1.style.pixelHeight;o2.style.pixelLeft=o1.style.pixelLeft;o2.style.pixelTop=o1.style.pixelTop;o2.style.visibility=o1.style.visibility}}function ng_EnterMapMenu(e){if(!e)e=window.event;if(ng_CheckMouseEnter(this,e)){if(this.ngMap)this.ngMap.InMapMenu=true}}function ng_LeaveMapMenu(e){if(!e)e=window.event;if(ng_CheckMouseLeave(this,e)){if(this.ngMap){this.ngMap.InMapMenu=false;this.ngMap.HideMapMenuTimer=setTimeout('ng_HideMapMenuTimer(\''+this.ngMap.MapID+'\');',100);}}}function ng_HideMapMenuTimer(mapid){var map=getMapByID(mapid);if((map)&&(!map.InMapMenu))map.HideMapMenu();}function ng_HideMapMenu(){clearTimeout(this.HideMapMenuTimer);var o=this.ObjMenu;if(o){if((this.PopupX==this.MapMenuX)&&(this.PopupY==this.MapMenuY)){this.PopupX=-1000;this.PopupY=-1000}this.MapMenuX=-1000;this.MapMenuY=-1000;this.InMapMenu=false;o.style.visibility='hidden';o.innerHTML=''}}function OnMapMouseDown(e){if(!e)e=window.event;if((OnMouseDownBefore)&&(!OnMouseDownBefore(e)))return true;var map=ngCurrentMap;if((map)&&(!map.InPopupRect)&&(!map.InMapMenu)){if(map.OnMapMenu){clearTimeout(map.MapMenuTimer);map.MapMenuTimer=null}map.HidePopup();map.GetMousePosition(e);if((!map.OnMouseDown)||(map.OnMouseDown(map,e))){if(map.MouseEvents){if(e.preventDefault)e.preventDefault();if((ngOpera)&&(map.OnMapMenu)&&(map.MapMenuTimeout>0))map.MapMenuTimer=setTimeout('ng_ShowMapMenuTimer('+map.MouseX+','+map.MouseY+',\''+map.MapID+'\');',map.MapMenuTimeout);if(e.button==2){if((map.OnMapMenu)&&(map.MapMenuTimeout>0))map.MapMenuTimer=setTimeout('ng_ShowMapMenuTimer('+map.MouseX+','+map.MouseY+',\''+map.MapID+'\');',map.MapMenuTimeout);}else{map.MouseSelLeft=map.MouseX;map.MouseSelRight=map.MouseX;map.MouseSelTop=map.MouseY;map.MouseSelBottom=map.MouseY;if(map.MouseMode=='R'){var o=map.ObjSelRect;if(o){ng_setBounds(o,map.MouseSelLeft,map.MouseSelTop,0,0);o.style.visibility='visible';map.UpdateRect();}}if((map.Mode=='Z+')||(map.Mode=='Z-'))map.CancelMapCommand();if(map.Mode=='P'){map.CancelMapCommand();map.MousePanMoved=false}}map.MouseDown=(e.button==2?2:1);ngMouseMap=map}}}if(OnMouseDownAfter){var ret=OnMouseDownAfter(e);if(typeof ret!='undefined')return ret}return true}function OnMapMouseMove(e){if(!e)e=window.event;if((ngIExplorer)&&(ngMouseMap)&&(ngMouseMap.MouseDown)&&(!e.button)){OnMapMouseUp(e);}if((OnMouseMoveBefore)&&(!OnMouseMoveBefore(e)))return true;var map=ngMouseMap;if(map){map.GetMousePosition(e);if((!map.OnMouseMove)||(map.OnMouseMove(map,e))){if(map.MouseDown){var mx=map.MouseX;var my=map.MouseY;map.MouseSelRight=mx;map.MouseSelBottom=my;if(map.MouseMode=='R'){var o=map.ObjSelRect;if(o){if(mx>map.MouseSelLeft){if(ngIExplorer){o.style.pixelWidth=(mx-map.MouseSelLeft);o.style.pixelLeft=map.MouseSelLeft}else{o.style.width=(mx-map.MouseSelLeft)+'px';o.style.left=map.MouseSelLeft+'px'}}else{if(ngIExplorer){o.style.pixelWidth=(map.MouseSelLeft-mx);o.style.pixelLeft=mx}else{o.style.width=(map.MouseSelLeft-mx)+'px';o.style.left=mx+'px'}}if(my>map.MouseSelTop){if(ngIExplorer){o.style.pixelHeight=(my-map.MouseSelTop);o.style.pixelTop=map.MouseSelTop}else{o.style.height=(my-map.MouseSelTop)+'px';o.style.top=map.MouseSelTop+'px'}}else{if(ngIExplorer){o.style.pixelHeight=(map.MouseSelTop-my);o.style.pixelTop=my}else{o.style.height=(map.MouseSelTop-my)+'px';o.style.top=my+'px'}}map.UpdateRect();}}if(map.MouseMode=='P'){var dx=(map.MouseSelRight-map.MouseSelLeft);var dy=(map.MouseSelBottom-map.MouseSelTop);map.MouseSelLeft=mx;map.MouseSelTop=my;map.CancelImageZoomAnim();if(map.Mode=='P'){if((dx)||(dy)){map.MousePanMoved=true;map.SetMapOffsetEx(map.X-dx,map.Y-dy);}}}}}}else if(ngCurrentMap){map=ngCurrentMap;map.GetMousePosition(e);}if((map)&&(map.DisplayPopupTimer)){if((map.DisplayPopupTimerMX!=map.MouseX)||(map.DisplayPopupTimerMY!=map.MouseY)){clearTimeout(map.DisplayPopupTimer);map.DisplayPopupTimerMX=map.MouseX;map.DisplayPopupTimerMY=map.MouseY;if(map.DisplayPopupTimeout)map.DisplayPopupTimer=setTimeout('ngAPU2(\''+map.MapID+'\');',map.DisplayPopupTimeout);}}if(OnMouseMoveAfter){var ret=OnMouseMoveAfter(e);if(typeof ret!='undefined'){if(map)map.IEForceUpdate();return ret}}if(map)map.IEForceUpdate();return true}function OnMapMouseOut(e){if(!e)e=window.event;var map=ngMouseMap;if((map)&&(map.MouseDown)){if((!ngIExplorer)&&(!e.relatedTarget)){OnMapMouseUp(e);}}return true}function ng_ShowMapMenuTimer(mousex,mousey,mapid){var map=getMapByID(mapid);if((map)&&(map.OnMapMenu)&&(mousex==map.MouseX)&&(mousey==map.MouseY)){map.MapMenuX=map.MouseX;map.MapMenuY=map.MouseY;map.PopupX=map.MapMenuX;map.PopupY=map.MapMenuY;var o=map.ObjMenu;if(o){var html=map.OnMapMenu(map);if(html!=''){clearTimeout(map.HideMapMenuTimer);map.CreatePopup(o,map.MouseX,map.MouseY,html,0,0);map.MouseDown=0;ngMouseMap=null;return false}}}}function OnMapMouseUp(e){var map=ngMouseMap;if((map)&&(map.OnMapMenu)){clearTimeout(map.MapMenuTimer);map.MapMenuTimer=null}if(!e)e=window.event;if((OnMouseUpBefore)&&(!OnMouseUpBefore(e))){map.MouseDown=0;ngMouseMap=null;return true}if(map){map.GetMousePosition(e);var mouseup=((!map.OnMouseUp)||(map.OnMouseUp(map,e)));var mousedown=map.MouseDown;map.MouseDown=0;ngMouseMap=null;if(mouseup){if(mousedown){if(mousedown==2){if((map.OnMapMenu)&&(map.MapMenuTimeout<=0))ng_ShowMapMenuTimer(map.MapID);else{if(map.MouseZoomOut)map.ZoomOut();return true}}else{map.MouseSelRight=map.MouseX;map.MouseSelBottom=map.MouseY;if((map.MouseMode=='R')||(map.MouseMode=='P')){var o=map.ObjSelRect;if(o)o.style.visibility='hidden';map.UpdateRect();}if(map.Mode=='Z+'){map.CancelImageZoomAnim();map.ZoomIn(map.MouseSelLeft,map.MouseSelTop,map.MouseSelRight,map.MouseSelBottom);}if(map.Mode=='Z-'){map.CancelImageZoomAnim();map.ZoomOut();}if(map.Mode=='P'){if(map.MousePanMoved)map.PositionChanged();}}}}}if(OnMouseUpAfter){var ret=OnMouseUpAfter(e);if(typeof ret!='undefined')return ret}return true}function OnMapDblClick(e){if(!e)e=window.event;if((OnDblClickBefore)&&(!OnDblClickBefore(e)))return true;var map=ngCurrentMap;if((map)&&(!map.InPopupRect)&&(!map.InMapMenu)){if(map.OnMapMenu){clearTimeout(map.MapMenuTimer);map.MapMenuTimer=null}map.HidePopup();map.GetMousePosition(e);if((!map.OnDblClick)||(map.OnDblClick(map,e))){if(map.MouseEvents){if(map.Mode=='P'){if(e.button==0){if(map.PreviewParent)map.Center(map.MouseX,map.MouseY);else map.ZoomIn(map.MouseX,map.MouseY);}}}}}if(OnDblClickAfter){var ret=OnDblClickAfter(e);if(typeof ret!='undefined')return ret}return true}function OnMapWheel(e){if(!e)e=window.event;if((OnMouseWheelBefore)&&(!OnMouseWheelBefore(e)))return true;var map=ngCurrentMap;if(map){if((!map.OnMouseWheel)||(map.OnMouseWheel(map,e))){if((map.MouseEvents)&&(map.MouseWheel)){var delta=0;if(e.detail){delta=-e.detail/3}else if(e.wheelDelta){delta=e.wheelDelta/120;if(window.opera)delta=-delta}if(delta){map.HidePopup();var mode=map.MouseWheelMode;if(mode==0)mode=((map.Mode=='Z+')||(map.Mode=='Z-')?2:1);if(mode==2){if((!map.AnimationStarted)||(!map.KeyScroll))map.KeyScroll=map.KeyScrollStart;else if(map.KeyScroll<map.KeyScrollMax)map.KeyScroll+=(map.KeyScrollDelta*Math.abs(delta));if(delta<0)map.Pan(0,map.KeyScroll);else map.Pan(0,-map.KeyScroll);}else{if(!map.AnimationStarted){if(map.LimitCommandFreq(1000)){if(delta<0){map.ZoomOut(map.MouseX,map.MouseY,true);}else map.ZoomIn(map.MouseX,map.MouseY,map.MouseX,map.MouseY,true);map.EndLimitCommand();}}}}if(e.preventDefault)e.preventDefault();e.returnValue=false}}}if(OnMouseWheelAfter){var ret=OnMouseWheelAfter(e);if(typeof ret!='undefined')return ret}return true}function ng_SwapMapLayers(curlayer){var o1=this.ObjMap[1];var o2=this.ObjMap[2];if((o1)&&(o2)){if(curlayer==1){o1.style.zIndex=1;o2.style.zIndex=2}else{o1.style.zIndex=2;o2.style.zIndex=1}}}function ng_HideSecondMapLayer(){this.ClearMapLayer(this.MapLayer==1?2:1);}function ng_GetMapLayer(){return this.MapLayer}function ng_ResetLoadEvents(o){o.onload=null;o.onabort=null;o.onerror=null}function ng_CancelTileLoading(layer){var i,j,o;for(j=0;j<this.TileRowCount;j++){for(i=0;i<this.TileColCount;i++){o=this.Tiles[layer][j][i];if(o){if(this.TileLoading[layer][j][i]){ng_ResetLoadEvents(o);this.TileLoading[layer][j][i]=false;this.TileLoadingCnt--;if(!ngOpera)o.src=ngEmptyURL;if(this.TileLoadingCnt<=0){this.TileLoadingCnt=0;if(this.OnTilesLoaded)this.OnTilesLoaded(this);}}}}}}function ng_ClearMapLayer(layer){if(layer==this.LastClearedLayer)return;this.LastClearedLayer=layer;var i,j,o;for(j=0;j<this.TileRowCount;j++){for(i=0;i<this.TileColCount;i++){o=this.Tiles[layer][j][i];if(o){o.style.visibility='hidden';if(this.TileLoading[layer][j][i]){ng_ResetLoadEvents(o);this.TileLoading[layer][j][i]=false;this.TileLoadingCnt--;o.src=ngEmptyURL;if(this.TileLoadingCnt<=0){this.TileLoadingCnt=0;if(this.OnTilesLoaded)this.OnTilesLoaded(this);}}}}}}function ng_Offset(x,y,anim){if((typeof anim=='undefined')||(anim)){this.SetMapOffset(x,y);this.PositionChanged();}else{this.SetMapOffsetEx(x,y);this.PositionChanged();}}function ng_SetMapOffset(x,y){if(this.ImageZoomHookPan){this.ImageZoomPan=1;this.ImageZoomPanX=x;this.ImageZoomPanY=y;return}x=Math.round(x);y=Math.round(y);if((this.X!=x)||(this.Y!=y)||(this.MapNeedRefresh)){var dx=x-this.X;var dy=y-this.Y;var maxpanx=2*this.MapWidth;var maxpany=2*this.MapHeight;if(maxpanx<400)maxpanx=400;if(maxpany<400)maxpany=400;if((this.MapNeedRefresh)||(Math.abs(dx)>maxpanx)||(Math.abs(dy)>maxpany)||((Math.abs(dx)<=3)&&(Math.abs(dy)<=3))){this.SetMapOffsetEx(x,y);}else{this.Pan(dx,dy);this.PanNoPosChanged=true}}}function ng_SetMapOffsetEx(x,y){if(this.ImageZoomHookPan){this.ImageZoomPan=2;this.ImageZoomPanX=x;this.ImageZoomPanY=y;return}x=Math.round(x);y=Math.round(y);if(!this.Initialized){this.X=x;this.Y=y}else if(((this.X!=x)||(this.Y!=y)||(this.MapNeedRefresh))&&(this.MapURL!='')&&((!this.OnOffsetChanging)||(this.OnOffsetChanging(this,x,y)))){var o,o2,url,i,j,tx,ty,sx,sy,tid;var lx,ly,rx,ry;this.X=x;this.Y=y;if((!this.InCmd)&&(this.TileLoadingCnt>0))this.HideSecondMapLayer();this.TilesCanceledByCommand=false;var stx=Math.round((x-(this.TileColCount*this.TileWidth/2))/this.TileWidth+0.5);var sty=Math.round((y-(this.TileRowCount*this.TileHeight/2))/this.TileHeight+0.5);this.TileOffsetX=Math.round((this.MapWidth/2)+((stx*this.TileWidth)-x)-this.TileWidth/2);this.TileOffsetY=Math.round((this.MapHeight/2)+((sty*this.TileHeight)-y)-this.TileHeight/2);o=this.ObjMap[this.MapLayer];if(o)ng_setLeftTop(o,this.TileOffsetX,this.TileOffsetY);this.SetCanvasOffset(this.CanvasX-x,this.CanvasY-y);this.LastTileStx=stx;this.LastTileSty=sty;sx=0;sy=0;tx=stx%this.TileColCount;ty=sty%this.TileRowCount;if(tx<0)tx+=this.TileColCount;if(ty<0)ty+=this.TileRowCount;var btx=tx;y=sy;var p=this.ObjMap[this.MapLayer];if((this.OnTilesLoading)&&(this.TileLoadingCnt<=0))this.OnTilesLoading(this);this.TileLoadingCnt++;var load=new Array();var idx;var dx=this.MapWidth/2+this.TileWidth;var dy=this.MapHeight/2+this.TileHeight;var maxdist=(Math.sqrt(dx*dx+dy*dy));if(maxdist<1.0)maxdist=1.0;var maxload=this.TileRowCount*this.TileColCount;var timestamp;if(ngOpera)timestamp=new Date().getTime();for(j=0;j<this.TileRowCount;j++){x=sx;tx=btx;for(i=0;i<this.TileColCount;i++){o=this.Tiles[this.MapLayer][ty][tx];if(o){url=ng_AddURLParam(ngHTTPProtocol+this.MapURL,'PX='+(stx+i)+'&PY='+(sty+j));if(o.src!=url){lx=x+this.TileOffsetX;ly=y+this.TileOffsetY;rx=lx+this.TileWidth;ry=ly+this.TileHeight;if(!((rx<0)||(ry<0)||(lx>=this.MapWidth)||(ly>=this.MapHeight))){if(!this.TileLoading[this.MapLayer][ty][tx])this.TileLoadingCnt++;this.TileLoading[this.MapLayer][ty][tx]=true;o.style.visibility='hidden';ng_setBounds(o,x,y,this.TileWidth,this.TileHeight);o.onload=ng_TileLoaded;o.onerror=ng_TileFailed;o.onabort=ng_TileFailed;o.ngMap=this;o.retrycnt=0;o.retryurl='';o.tilesrc=url;dx=(lx+this.TileWidth/2)-this.MapWidth/2;dy=(ly+this.TileHeight/2)-this.MapHeight/2;idx=Math.round((Math.sqrt(dx*dx+dy*dy)/maxdist)*maxload);o2=load[idx];if(typeof o2=='undefined')load[idx]=new Array(o);else o2[o2.length]=o;}else{ng_setBounds(o,x,y,this.TileWidth,this.TileHeight);o.style.visibility='hidden'}}else{ng_setBounds(o,x,y,this.TileWidth,this.TileHeight);if(!this.TileLoading[this.MapLayer][ty][tx])o.style.visibility='visible'}}x+=this.TileWidth;tx++;if(tx>=this.TileColCount)tx=0}y+=this.TileHeight;ty++;if(ty>=this.TileRowCount)ty=0}for(i=0;i<load.length;i++){o=load[i];if(typeof o=='undefined')continue;for(j=o.length-1;j>=0;j--){o2=o[j];if(ngOpera)o2.src=ngEmptyURL+'?'+i+j+timestamp;else{o2.alt='';o2.src=o2.tilesrc}}}this.TileLoadingCnt--;if(this.TileLoadingCnt<=0){this.TileLoadingCnt=0;this.DoTilesLoaded();}if(this.OnOffsetChanged)this.OnOffsetChanged(this);}this.MapNeedRefresh=false}function ng_SetImageZoom(d,layer,x,y,centerx,centery){var i,j,tx,ty,o;var tilew=this.TileWidth*d;var tileh=this.TileHeight*d;var stx=Math.round(((x*d)-(this.TileColCount*tilew/2))/(tilew)+0.5);var sty=Math.round(((y*d)-(this.TileRowCount*tileh/2))/(tileh)+0.5);var sx=(this.MapWidth/2)+((stx*(tilew))-(x*d))-(tilew)/2;var sy=(this.MapHeight/2)+((sty*(tileh))-(y*d))-(tileh)/2;sx+=(this.MapWidth/2-centerx)*(d-1.0);sy+=(this.MapHeight/2-centery)*(d-1.0);o=this.ObjMap[layer];if(o){ng_setLeftTop(o,sx,sy);}tx=stx%this.TileColCount;ty=sty%this.TileRowCount;if(tx<0)tx+=this.TileColCount;if(ty<0)ty+=this.TileRowCount;var btx=tx;var tw=Math.round(tilew+0.5);var th=Math.round(tileh+0.5);for(j=0;j<this.TileRowCount;j++){tx=btx;for(i=0;i<this.TileColCount;i++){o=this.Tiles[layer][ty][tx];if(o){ng_setBounds(o,Math.round(i*tilew),Math.round(j*tileh),tw,th);}tx++;if(tx>=this.TileColCount)tx=0}ty++;if(ty>=this.TileRowCount)ty=0}}function ng_TileLoaded(){if(this.src!=this.tilesrc){this.style.visibility='visible';this.src=this.tilesrc;return}this.retrycnt=0;this.retryurl='';var map=this.ngMap;ng_ResetLoadEvents(this);this.style.visibility='visible';if((map)&&(map.TileLoading[this.layer][this.row][this.col])){map.TileLoadingCnt--;map.TileLoading[this.layer][this.row][this.col]=false;if(map.TileLoadingCnt<=0){map.TileLoadingCnt=0;map.DoTilesLoaded();}}}function ng_ReloadFailedTilesTimer(mapid){var o=getMapByID(mapid);if(o)o.ReloadFailedTiles();}function ng_TileFailed(){if(this.src!=this.tilesrc){this.style.visibility='visible';this.src=this.tilesrc;return}var map=this.ngMap;if(!map)return;if(map.TileRetryTimer)clearTimeout(map.TileRetryTimer);map.TileRetryTimer=null;var id=this.id;ng_ResetLoadEvents(this);this.retryurl=this.src;this.src=ngEmptyURL;if(this.retrycnt<3){map.TileRetry[map.TileRetryCnt++]=id;this.retrycnt++;map.TileRetryTimer=setTimeout('ng_ReloadFailedTilesTimer(\''+map.MapID+'\');',1000);}else{if(map.TileLoading[this.layer][this.row][this.col]){map.TileLoadingCnt--;map.TileLoading[this.layer][this.row][this.col]=false;if(map.TileLoadingCnt<=0){map.TileLoadingCnt=0;map.DoTilesLoaded();}}}}function ng_ReloadFailedTiles(){if(this.TileRetryTimer)clearTimeout(this.TileRetryTimer);this.TileRetryTimer=null;for(var i=0;i<this.TileRetryCnt;i++){o=document.getElementById(this.TileRetry[i]);if((o)&&(o.retryurl!='')){o.onload=ng_TileLoaded;o.onerror=ng_TileFailed;o.onabort=ng_TileFailed;o.ngMap=this;o.src=o.retryurl}}this.TileRetry=new Array;this.TileRetryCnt=0}function ng_DoTilesLoaded(){this.ImageZoomAnimFinished();if(this.OnTilesLoaded)this.OnTilesLoaded(this);}function ng_SetMapSize(w,h){var update=false;var o1=this.ObjMap[1];var o2=this.ObjMap[2];if((o1)&&(o2)){if(w>0)o1.style.width=w;else{w=o1.clientWidth;if(ngOpera)w-=16}if(h>0)o1.style.height=h;else h=o1.clientHeight;o2.style.width=o1.style.width;o2.style.height=o1.style.height;this.TileColCount=Math.round(w/this.TileWidth+0.5);this.TileRowCount=Math.round(h/this.TileHeight+0.5);if(!(this.TileColCount%2))this.TileColCount++;else this.TileColCount+=2;if(!(this.TileRowCount%2))this.TileRowCount++;else this.TileRowCount+=2;var tiles1=new ngStringBuilder();var tiles2=new ngStringBuilder();for(j=0;j<this.TileRowCount;j++)for(i=0;i<this.TileColCount;i++){tiles1.append('<img id="'+this.MapID+'T1_'+i+'_'+j+'" class="cMT" />');tiles2.append('<img id="'+this.MapID+'T2_'+i+'_'+j+'" class="cMT" />');}o1.innerHTML=tiles1.toString();o2.innerHTML=tiles2.toString();this.TileLoadingCnt=0;this.TileLoading=new Array(null,new Array(),new Array());this.Tiles=new Array(null,new Array(),new Array());for(j=0;j<this.TileRowCount;j++){this.Tiles[1][j]=new Array();this.Tiles[2][j]=new Array();this.TileLoading[1][j]=new Array();this.TileLoading[2][j]=new Array();for(i=0;i<this.TileColCount;i++){o1=document.getElementById(this.MapID+'T1_'+i+'_'+j);o1.layer=1;o1.col=i;o1.row=j;o2=document.getElementById(this.MapID+'T2_'+i+'_'+j);o2.layer=2;o2.col=i;o2.row=j;this.Tiles[1][j][i]=o1;this.Tiles[2][j][i]=o2;this.TileLoading[1][j][i]=false;this.TileLoading[2][j][i]=false}}}if(!ngIExplorer){var o=this.ObjCanvasDC;if(o){o.width=this.TileColCount*this.TileWidth;o.height=this.TileRowCount*this.TileHeight}}o=this.ObjCanvasDI;if(o){o.width=this.TileColCount*this.TileWidth;o.height=this.TileRowCount*this.TileHeight}if((w!=this.MapWidth)||(h!=this.MapHeight)){this.MapWidth=w;this.MapHeight=h;this.ClearCanvas();update=true}this.Refresh();if(update)this.Update();}function ng_HideCanvas(){var o=this.ObjCanvasDI;if(o)o.style.visibility='hidden';if(!ngIExplorer){o=this.ObjCanvasDC;if(o)o.style.visibility='hidden'}o=this.ObjPreview;if(o)o.style.visibility='hidden'}function ng_ShowCanvas(){var o=this.ObjCanvasDI;if(o)o.style.visibility='visible';if(!ngIExplorer){o=this.ObjCanvasDC;if(o)o.style.visibility='visible'}o=this.ObjPreview;if(o)o.style.visibility='visible'}function ng_ClearCanvasEx(x,y){this.ClearCanvasEx2(x-this.X,y-this.Y);this.CanvasX=x;this.CanvasY=y}function ng_ClearCanvas(){this.ClearCanvasEx2(0,0);}function ng_ClearCanvasEx2(ox,oy){o=this.ObjCanvasDI;if(o){var html='<img id="'+this.MapID+'_ImgMap" src="'+ngMapAPIURL+'/empty.gif" style="position: relative; visibility: hidden; z-index: 10; cursor:'+this.CurrentCursor+';" alt="" border="0" usemap="#ngmap" />';html+='<div id="'+this.MapID+'_Popup" class="'+this.PopupStyle+'" onmouseover="ng_EnterPopup(event,this,\''+this.MapID+'\');" onmouseout="ng_LeavePopup(event,this,\''+this.MapID+'\');"></div>';o.innerHTML=html;ng_setLeftTop(o,this.TileOffsetX+ox,this.TileOffsetY+oy);this.InPopupRect=false;this.InPopupObj=false}this.CanvasOffsetX=this.TileOffsetX;this.CanvasOffsetY=this.TileOffsetY;this.CanvasX=this.X;this.CanvasY=this.Y;this.CanvasHTML=new ngStringBuilder();if(!ngIExplorer){var o=this.ObjCanvasDC;if(o){ng_setLeftTop(o,this.TileOffsetX+ox,this.TileOffsetY+oy);if(o.getContext){var ctx=o.getContext('2d');ctx.clearRect(0,0,this.TileColCount*this.TileWidth,this.TileRowCount*this.TileHeight);}}}}function ng_SetCanvasOffset(x,y){x+=this.CanvasOffsetX;y+=this.CanvasOffsetY;var o=this.ObjCanvasDI;if(o){ng_setLeftTop(o,x,y);}if(!ngIExplorer){var o=this.ObjCanvasDC;if(o){ng_setLeftTop(o,x,y);}}}function ng_CanvasBeginUpdate(){this.CanvasUpdateCnt++}function ng_CanvasEndUpdate(){this.CanvasUpdateCnt--;if(this.CanvasUpdateCnt<=0){this.CanvasUpdateCnt=0;var o=this.ObjCanvasDI;if(o)o.innerHTML=o.innerHTML+this.CanvasHTML.toString();this.CanvasHTML=new ngStringBuilder();}}function ng_CanvasDrawOffsetX(){out=-this.CanvasOffsetX;return out}function ng_CanvasDrawOffsetY(){out=-this.CanvasOffsetY;return out}function ng_DrawOverlay(){if(this.OnDrawOverlay)this.OnDrawOverlay(this);}function ng_DrawIcon(url,pos,w,h,hotspot){var ox=this.CanvasDrawOffsetX();var oy=this.CanvasDrawOffsetY();pos.x+=ox-hotspot.x;pos.y+=oy-hotspot.y;var drawsuccess=false;if(!ngIExplorer){var o=this.ObjCanvasDC;if((o)&&(o.getContext)){var ctx=o.getContext('2d');ctx.globalAlpha=1.0;var img=ngPreloadedImages[url];if(typeof img!='object'){img=new Image();img.src=url}ctx.beginPath();ctx.drawImage(img,pos.x,pos.y,w,h);drawsuccess=true}}if(!drawsuccess){this.CanvasBeginUpdate();var html=new ngStringBuilder();html.append('<span class="cMI" style="left:'+pos.x+'px;top:'+pos.y+'px;width:'+w+'px;height:'+h+'px;');if(ngIExplorer)html.append('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+url+'\', sizingMethod=\'image\')');html.append(';"></span>');this.CanvasHTML.append(html);this.CanvasEndUpdate();}}function ng_DrawLine(pts,col,width,opacity){if(pts.lenght<2)return;var ox=this.CanvasDrawOffsetX();var oy=this.CanvasDrawOffsetY();var o=this.ObjCanvasDC;if((o)&&(o.getContext)){var ctx=o.getContext('2d');ctx.globalAlpha=opacity;ctx.strokeStyle=col;ctx.lineWidth=width;ctx.beginPath();for(i=0;i<pts.length;i++){if(i==0)ctx.moveTo(pts[i].x+ox,pts[i].y+oy);else ctx.lineTo(pts[i].x+ox,pts[i].y+oy);}ctx.stroke();}}function ng_DrawLineIE(pts,col,width,opacity){if(pts.lenght<2)return;var ox=this.CanvasDrawOffsetX();var oy=this.CanvasDrawOffsetY();this.CanvasBeginUpdate();var html=new ngStringBuilder();var dcw=this.TileColCount*this.TileWidth;var dch=this.TileRowCount*this.TileHeight;html.append('<v:shape class="cDC" onmousemove="ng_SyncCursor(\''+this.MapID+'\',this);" style="width:'+dcw+'px; height:'+dch+'px;" coordorigin="0 0" coordsize="'+dcw+' '+dch+'" filled="f" stoked="t" strokecolor="'+col+'" strokeweight="'+width+'px" path="');for(i=0;i<pts.length;i++){if(i==0)html.append('m ');else html.append('l ');html.append(Math.round(pts[i].x+ox)+','+Math.round(pts[i].y+oy)+' ');}if(opacity<1)html.append('e" ><v:stroke opacity="'+opacity+'" /></v:shape>');else html.append('e" />');this.CanvasHTML.append(html);this.CanvasEndUpdate();}function ng_DrawLineFromStr(data,col,width,opacity){if((typeof data=='object')&&(data!=null)){this.CanvasBeginUpdate();for(var i=0;i<data.length;i++){var pts=PointsFromStr(data[i]);this.DrawLine(pts,col,width,opacity);}this.CanvasEndUpdate();}if(typeof data=='string'){this.CanvasBeginUpdate();var pts=PointsFromStr(data);this.DrawLine(pts,col,width,opacity);this.CanvasEndUpdate();}}function ng_DrawArea(pts,col,width,fillcol,opacity){if(pts.lenght<3)return;var ox=this.CanvasDrawOffsetX();var oy=this.CanvasDrawOffsetY();var o=this.ObjCanvasDC;if((o)&&(o.getContext)){var ctx=o.getContext('2d');ctx.globalAlpha=opacity;ctx.strokeStyle=col;ctx.fillStyle=fillcol;ctx.lineWidth=width;ctx.beginPath();for(i=0;i<pts.length;i++){if(i==0)ctx.moveTo(pts[i].x+ox,pts[i].y+oy);else ctx.lineTo(pts[i].x+ox,pts[i].y+oy);}ctx.lineTo(pts[0].x+ox,pts[0].y+oy);ctx.fill();if(width>0)ctx.stroke();}}function ng_DrawAreaIE(pts,col,width,fillcol,opacity){if(pts.lenght<3)return;var ox=this.CanvasDrawOffsetX();var oy=this.CanvasDrawOffsetY();this.CanvasBeginUpdate();var html=new ngStringBuilder();var dcw=this.TileColCount*this.TileWidth;var dch=this.TileRowCount*this.TileHeight;html.append('<v:shape class="cDC" onmousemove="ng_SyncCursor(\''+this.MapID+'\',this);" style="width:'+dcw+'px; height:'+dch+'px;" coordorigin="0 0" coordsize="'+dcw+' '+dch+'" filled="t" stoked="t" fillcolor="'+fillcol+'" strokecolor="'+col+'" strokeweight="'+width+'px" path="');for(i=0;i<pts.length;i++){if(i==0)html.append('m ');else html.append('l ');html.append(Math.round(pts[i].x+ox)+','+Math.round(pts[i].y+oy)+' ');}html.append(Math.round(pts[0].x+ox)+','+Math.round(pts[0].y+oy)+' ');if(opacity<1)html.append('e" ><v:fill opacity="'+opacity+'" /><v:stroke opacity="'+opacity+'" /></v:shape></v:shape>');else html.append('e" />');this.CanvasHTML.append(html);this.CanvasEndUpdate();}function ng_DrawAreaFromStr(data,col,width,fillcol,opacity){if((typeof data=='object')&&(data!=null)){this.CanvasBeginUpdate();for(var i=0;i<data.length;i++){var pts=PointsFromStr(data[i]);this.DrawArea(pts,col,width,fillcol,opacity);}this.CanvasEndUpdate();}if(typeof data=='string'){this.CanvasBeginUpdate();var pts=PointsFromStr(data);this.DrawArea(pts,col,width,fillcol,opacity);this.CanvasEndUpdate();}}function ng_DrawPopupIcon(id,iconpos,timeout){var ic=this.PopupIcons[id];if((typeof ic!='object')||(!ic))return;var pos=new ScreenPt(iconpos.x,iconpos.y);ic.screenpos=new ScreenPt(iconpos.x,iconpos.y);this.CanvasBeginUpdate();var ox=this.CanvasDrawOffsetX();var oy=this.CanvasDrawOffsetY();pos.x-=ic.hotspot.x;pos.y-=ic.hotspot.y;var w=ic.icon.width;var h=ic.icon.height;var url=ic.icon.src;ic.offsetx=ox;ic.offsety=oy;ic.popupx=pos.x+w/2;ic.popupy=pos.y+h/2;pos.x+=ox;pos.y+=oy;var pt=0;if(typeof(timeout)!='undefined')pt=timeout;var html=new ngStringBuilder();var onclick=((this.DisplayPopupTimeout>0)&&(this.DisplayPopupByClick));if((ngIExplorer)&&(url.indexOf('png')>=0)){html.append('<span class="cMI" id="'+id+'" style="left:'+pos.x+'px;top:'+pos.y+'px;width:'+w+'px;height:'+h+'px;');if(onclick)html.append('cursor:pointer;');html.append('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+url+'\', sizingMethod=\'image\')');html.append(';" onmouseover="ngSPU(event,this,\''+this.MapID+'\','+pt+');"');if(onclick){html.append(' onclick="ngSPU3(this, \''+this.MapID+'\');"');}html.append(' onmouseout="ngHPU(event,this,\''+this.MapID+'\')"></span>');}else{html.append('<img class="cMI" id="'+id+'" style="left:'+pos.x+'px;top:'+pos.y+'px;width:'+w+'px;height:'+h+'px;');if(onclick)html.append('cursor:pointer;');html.append('" src="'+url+'" alt="" border="0"');if(onclick){html.append(' onclick="ngSPU3(this, \''+this.MapID+'\');"');}html.append(' onmouseover="ngSPU(event,this,\''+this.MapID+'\','+pt+');" onmouseout="ngHPU(event,this,\''+this.MapID+'\')" />');}this.CanvasHTML.append(html);this.CanvasEndUpdate();}function ng_DrawPopupIcons(ids,pts){this.CanvasBeginUpdate();var positions=PointsFromStr(pts);for(var i=0;(i<ids.length)&&(i<positions.length);i++){this.DrawPopupIcon(ids[i],positions[i]);}this.CanvasEndUpdate();}function ng_PopupIconExists(id){var ic=this.PopupIcons[id];if((typeof ic!='object')||(!ic))return false;return true}function ngSPU(e,img,mapid,timeout){if(!e)e=window.event;if(ng_CheckMouseEnter(img,e)){var map=getMapByID(mapid);if(map){if(!map.DisplayPopupTimeout)map.ShowPopup(img,img.id,timeout);else{if(map.DisplayPopupTimer)clearTimeout(map.DisplayPopupTimer);map.DisplayPopupTimerIcon=img;map.DisplayPopupTimerMX=map.MouseX;map.DisplayPopupTimerMY=map.MouseY;map.DisplayPopupTimer=setTimeout('ngAPU2(\''+mapid+'\');',map.DisplayPopupTimeout);}return false}}}function ngSPU3(img,mapid){var map=getMapByID(mapid);if(map)map.ShowPopup(img,img.id);return false}function ngHPU(e,img,mapid){if(!e)e=window.event;if(ng_CheckMouseLeave(img,e)){var map=getMapByID(mapid);if(map){map.InPopupObj=false;map.HidePopupTimer=setTimeout('ng_HidePopupRectTimer(\''+mapid+'\');',100);map.CancelDisplayPopup();if((map.DisplayPopupTimeout>0)&&(map.DisplayPopupByClick)){var oldc=map.CurrentCursor;map.CurrentCursor='';map.SetCursor(oldc);}}}}function ng_AddPopupIcon(id,url,pos,descr,hotspot){var ic=new PopupIcon(id,url,pos,descr,hotspot);this.PopupIcons[id]=ic;return ic}function ng_SetPopupIcons(popupicons){for(var i=0;i<popupicons.length;i++)this.PopupIcons[popupicons[i].id]=popupicons[i]}function ng_ClearPopupIcons(){this.RemovePopupIconsByID('');}function ng_RemovePopupIconsByID(delid){var o;var l=delid.length;var del=0,cnt=0;this.HidePopup();for(var id in this.PopupIcons){cnt++;if(id.substring(0,l)==delid){this.PopupIcons[id]=false;o=document.getElementById(id);if((o)&&(o.parentNode))o.parentNode.removeChild(o);del++}}if(cnt==del)this.PopupIcons=new Array();}function ng_RemovePopupIconByID(delid){this.HidePopup();this.PopupIcons[delid]=false;var o=document.getElementById(delid);if((o)&&(o.parentNode))o.parentNode.removeChild(o);}function ng_ShowPopupByID(id,timeout){var o=document.getElementById(id);if(o){return this.ShowPopup(o,id,timeout);}return false}function ng_CreatePopupHTML(text,menu){var html='';if(text!='')html+='<div class="'+this.PopupTextStyle+'">'+text+'</div>';if((typeof menu!='undefined')&&(menu!=''))html+='<div class="'+this.PopupMenuStyle+'">'+menu+'</div>';else html+='<div class="'+this.PopupMenuStyle+'"></div>';return html}function ng_CreatePopup(o,x,y,popuphtml,offsetx,offsety){if(!o)return;o.innerHTML='<div class="'+this.PopupFrameStyle+'">'+popuphtml+'</div>';var swpx=false;var swpy=false;if((x+o.offsetWidth-28)>this.MapWidth+offsetx){swpx=true;x+=-o.offsetWidth+28}else x-=28;if((y-o.offsetHeight-12)>offsety){swpy=true;y+=-o.offsetHeight-12}if(swpy){popuphtml='<div class="'+this.PopupFrameStyle+'">'+popuphtml+'</div><div style=\"z-index: 503; position: relative; top:-1px; text-align:'+(swpx?'right':'left')+'\"><img src=\"'+ngMapAPIURL+'/popupArrDown.gif\" width=\"55\" height=\"13\" alt=\"\" border=\"0\" /></div>'}else{popuphtml='<div style=\"position: relative; z-index: 503; text-align:'+(swpx?'right':'left')+'\"><img src=\"'+ngMapAPIURL+'/popupArrUp.gif\" width=\"55\" height=\"13\" alt=\"\" border=\"0\" /></div><div class="'+this.PopupFrameStyle+'" style=\"position: relative; top: -1px;\">'+popuphtml+'</div>'}o.innerHTML=popuphtml;ng_setLeftTop(o,x,y);o.style.visibility='visible'}function ng_ShowPopup(img,id,timeout){if(this.MouseDown)return false;var ic=this.PopupIcons[id];if((typeof ic!='object')||(!ic))return false;var o=document.getElementById(this.MapID+'_Popup');if(o){var popuphtml;if(ic.onpopup)popuphtml=ic.onpopup(this,ic);else popuphtml=ic.descr;if(popuphtml==''){return false}else{clearTimeout(this.HidePopupTimer);this.InPopupObj=true;if(this.ActivePopupIcon)this.ActivePopupIcon.style.zIndex="10";if(img)img.style.zIndex="500";this.MapPopupX=ic.popupx;this.MapPopupY=ic.popupy;this.PopupX=this.MapPopupX;this.PopupY=this.MapPopupY;this.CreatePopup(o,ic.popupx+ic.offsetx,ic.popupy+ic.offsety,popuphtml,-this.TileOffsetX,-this.TileOffsetY);this.ActivePopupIcon=img;if(timeout>0){this.InPopupRect=false;this.InPopupObj=false;this.HidePopupTimer=setTimeout('ng_HidePopupRectTimer(\''+this.MapID+'\');',timeout);}}}return true}function ng_HidePopupRectTimer(mapid){var map=getMapByID(mapid);if(map){clearTimeout(map.HidePopupTimer);if((!map.InPopupRect)&&(!map.InPopupObj))map.HidePopup();}}function ng_HidePopup(){this.InPopupRect=false;this.InPopupObj=false;clearTimeout(this.HidePopupTimer);var o=document.getElementById(this.MapID+'_Popup');if((o)){if(this.ActivePopupIcon){this.ActivePopupIcon.style.zIndex="10";this.ActivePopupIcon=null}o.style.visibility='hidden';o.innerHTML='';if((this.PopupX==this.MapPopupX)&&(this.PopupY==this.MapPopupY)){this.PopupX=-1000;this.PopupY=-1000}this.MapPopupX=-1000;this.MapPopupY=-1000;if(typeof(this.OnHidePopup)=='function')this.OnHidePopup(this);}}function ng_EnterPopup(e,elm,mapid){if(!e)e=window.event;if(ng_CheckMouseEnter(elm,e)){var map=getMapByID(mapid);if(map)map.InPopupRect=true}}function ng_LeavePopup(e,elm,mapid){if(!e)e=window.event;if(ng_CheckMouseLeave(elm,e)){var map=getMapByID(mapid);if(map){map.InPopupRect=false;map.HidePopupTimer=setTimeout('ng_HidePopupRectTimer(\''+mapid+'\');',100);}}}function ngAPU(e,obj,mapid,idxl,idxo,timeout){if(!e)e=window.event;if(ng_CheckMouseEnter(obj,e)){var map=getMapByID(mapid);if(map){if(!map.DisplayPopupTimeout)return map.ShowActiveObjPopup(idxl,idxo,timeout);var oldc=map.CurrentCursor;map.SetCursor('pointer');map.CurrentCursor=oldc;if(map.DisplayPopupTimer)clearTimeout(map.DisplayPopupTimer);map.DisplayPopupTimerIdxL=idxl;map.DisplayPopupTimerIdxO=idxo;map.DisplayPopupTimerIcon=null;map.DisplayPopupTimerMX=map.MouseX;map.DisplayPopupTimerMY=map.MouseY;map.DisplayPopupTimer=setTimeout('ngAPU2(\''+mapid+'\');',map.DisplayPopupTimeout);return false}}}function ngAPU2(mapid){var map=getMapByID(mapid);if(map){map.CancelDisplayPopup();if((map.DisplayPopupTimerMX==map.MouseX)&&(map.DisplayPopupTimerMY==map.MouseY)){var img=map.DisplayPopupTimerIcon;if(img)map.ShowPopup(img,img.id);else map.ShowActiveObjPopup(map.DisplayPopupTimerIdxL,map.DisplayPopupTimerIdxO,0);}}}function ngAPU3(mapid,idxl,idxo){var map=getMapByID(mapid);if(map){map.ShowActiveObjPopup(idxl,idxo);return false}}function ng_CancelDisplayPopup(){if(this.DisplayPopupTimer)clearTimeout(this.DisplayPopupTimer);this.DisplayPopupTimer=null}function ngNop(){}function ng_GetActiveObjByID(lay,objid){var cnt,idxl=-1;if(typeof lay=='string'){cnt=this.ActiveLayers.length;for(var i=0;i<cnt;i++)if(this.ActiveLayers[i].objid==lay){idxl=i;break}}else idxl=lay;if((idxl>=0)&&(idxl<this.ActiveLayers.length)){var objs=this.ActiveLayers[idxl].objs;cnt=objs.length;for(var i=0;i<cnt;i++)if(objs[i].objid==objid)return i}return-1}function ng_ShowActiveObjPopupByID(lay,objid,timeout){var o=document.getElementById(this.MapID+'_Popup');if(!o)return false;var cnt,idxl=-1;if(typeof lay=='string'){cnt=this.ActiveLayers.length;for(var i=0;i<cnt;i++)if(this.ActiveLayers[i].objid==lay){idxl=i;break}}else idxl=lay;var idxo=this.GetActiveObjByID(lay,objid);if(idxo>=0)return this.ShowActiveObjPopup(idxl,idxo,timeout);return false}function ng_ShowActiveObjPopup(idxl,idxo,timeout){if(this.MouseDown)return false;var o=document.getElementById(this.MapID+'_Popup');if((o)&&(idxl<this.ActiveLayers.length)){var al=this.ActiveLayers[idxl];if(typeof al!='object')return false;if(idxo>=al.objs.length)return false;var ao=al.objs[idxo];if(typeof ao!='object')return false;var popuphtml;if(ao.onpopup)popuphtml=ao.onpopup(map,ao);else{if(this.OnActiveObjectMenu)popuphtml=this.OnActiveObjectMenu(map,al,ao);else popuphtml=ao.descr}if(popuphtml!=''){clearTimeout(this.HidePopupTimer);this.InPopupObj=true;if(this.ActivePopupIcon)this.ActivePopupIcon.style.zIndex="10";this.MapPopupX=ao.popupx;this.MapPopupY=ao.popupy;this.PopupX=this.MapPopupX;this.PopupY=this.MapPopupY;this.CreatePopup(o,ao.popupx+ao.offsetx,ao.popupy+ao.offsety,popuphtml,-this.TileOffsetX,-this.TileOffsetY);this.ActivePopupIcon=null;if(typeof(timeout)!='undefined'&&timeout>0){this.InPopupRect=false;this.InPopupObj=false;this.HidePopupTimer=setTimeout('ng_HidePopupRectTimer(\''+this.MapID+'\');',timeout);}return true}}return false}function ng_SetActiveLayers(layers){if(typeof layers!='object')return;if((this.OnActiveLayers)&&(!this.OnActiveLayers(this,layers)))return;this.CancelDisplayPopup();this.ActiveLayers=layers;var ox=this.CanvasDrawOffsetX();var oy=this.CanvasDrawOffsetY();var i,j,cnt2,l;var imgmap=new ngStringBuilder();var cnt1=layers.length;var onclick=((this.DisplayPopupTimeout>0)&&(this.DisplayPopupByClick));for(i=0;i<cnt1;i++){l=layers[i];if(typeof l=='object'){cnt2=l.objs.length;for(j=0;j<cnt2;j++){l.objs[j].offsetx=ox;l.objs[j].offsety=oy;imgmap.append('<area shape="'+l.objs[j].shape+'" coords="'+l.objs[j].coords+'"');if(onclick){imgmap.append(' onclick="ngAPU3(\''+this.MapID+'\','+i+','+j+');"');}imgmap.append(' onmouseover="ngAPU(event,this,\''+this.MapID+'\','+i+','+j+');" onmouseout="ngHPU(event,this,\''+this.MapID+'\')" />');}}}if(!imgmap.empty()){if(ngFireFox1x)imgmap.append('<area href="javascript:ngNop();" shape="rect" coords="0,0,'+this.MapWidth+','+this.MapHeight+'" />');var o=document.getElementById(this.MapID+'_ImgMap');if(o){ng_setBounds(o,ox,oy,this.MapWidth,this.MapHeight);o.style.visibility='visible'}this.CanvasBeginUpdate();this.CanvasHTML.append('<map name="ngmap">');this.CanvasHTML.append(imgmap);this.CanvasHTML.append('</map>');this.CanvasEndUpdate();}else{var o=document.getElementById(this.MapID+'_ImgMap');if(o){o.style.visibility='hidden'}}}function ng_LocatePopupIcon(id,scale,timeout){var ic=this.PopupIcons[id];var pt='';if(typeof(timeout)!='undefined')pt='&PT='+timeout;if((typeof ic!='object')||(!ic))return;if(ic.update)this.MapCommand('LI',ng_URLEncode(id)+'&SC='+scale+pt);else{this.MapCommand('L',ng_URLEncode(ic.pos)+'&SC='+scale+'&LI='+ng_URLEncode(id)+pt);}}function ng_LocatePopupIcons(id,timeout){var pt='';if(typeof(timeout)!='undefined')pt='&PT='+timeout;this.MapCommand('LI',ng_URLEncode(id)+pt);}function ng_ProcessUrl(url){this.rpc.sendRequest(url);}function ng_URLStateParams(icons,mapprops,preview,internal){if(typeof mapprops=='undefined')mapprops=false;if(typeof icons=='undefined')icons=true;if(typeof preview=='undefined')preview=false;if(typeof internal=='undefined')internal=false;var params=new ngStringBuilder();params.append('&S='+this.MapSession+'&PX='+this.X+'&PY='+this.Y);if(mapprops){params.append('&M='+this.MapID+'&W='+this.MapWidth+'&H='+this.MapHeight);if(this.PHPSession!='')params.append('&'+this.PHPSession);}if(internal){if(!this.Initialized)params.append('&INIT=1');if(this.APIKey!='')params.append('&KEY='+this.APIKey);}var pmap=this.PreviewMap;if((preview)&&(pmap)){params.append('&PM='+pmap.MapID);params.append('&PPX='+pmap.X);params.append('&PPY='+pmap.Y);params.append('&PW='+pmap.MapWidth);params.append('&PH='+pmap.MapHeight);params.append('&PZ='+pmap.PreviewZoom);params.append('&PS='+pmap.MapSession);}if(icons){var iconids=new ngStringBuilder(),iconpos=new ngStringBuilder();var proj="",lastproj=PROJ_WGS;for(var id in this.PopupIcons){if((typeof this.PopupIcons[id].pos!='undefined')&&(this.PopupIcons[id].update)){iconids.append(id+";");if(!iconpos.empty())iconpos.append("|"+this.PopupIcons[id].pos);else iconpos.append(this.PopupIcons[id].pos);}}if(!iconids.empty()){params.append('&IC=');params.append(ng_URLEncode(iconids.toString()));params.append('&ICP=');params.append(ng_URLEncode(iconpos.toString()));}}var p=params.toString();return p.substring(1,p.length);}function ng_SetPHPSession(phpsess){this.PHPSession=phpsess}function ng_SetMapCommandParam(param){this.RemoveMapCommandParam(param);this.MapCommandParams=this.MapCommandParams+'&'+param}function ng_RemoveMapCommandParam(param){var i=param.indexOf('=');if(i>=0)param=param.substring(0,i);i=this.MapCommandParams.indexOf(param+'=');if(i>=0){var p1=this.MapCommandParams.substring(0,i-1);var p2=this.MapCommandParams.substring(i,this.MapCommandParams.length+1);i=p2.indexOf('&');if(i>=0)p2=p2.substring(i,p2.length+1);else p2='';this.MapCommandParams=p1+p2}}function ng_IsActiveCmd(cmdid){return(cmdid==this.ActiveCommandID);}function ng_MapCommand(cmd,cmdparam){if(this.InCmd)return;var param='';if(typeof cmdparam!='undefined')param=cmdparam;if((this.OnCommand)&&(!this.OnCommand(this,cmd,param)))return;this.CancelMapCommand();if((this.PreviewParent)&&(cmd=='P')&&(param=='')){this.PreviewParent.MapCommand('UP');return}if(this.TileLoadingCnt>0){this.TilesCanceledByCommand=true;this.CancelTileLoading(this.MapLayer);}this.ActiveCommand=cmd;this.ActiveCommandParams=param;this.ActiveCommandID++;if(this.ActiveCommandID>99)this.ActiveCommandID=0;var url=ng_AddURLParam(this.CommandURL,this.URLStateParams(true,true,true,true)+'&C='+cmd+'_'+this.ActiveCommandID+'&P='+param+this.MapCommandParams);this.ProcessUrl(url);}function ng_LimitCommandFreq(timeout){var curtime=new Date().getTime();if((!this.LimitCommandTimeout)||(curtime>this.LimitCommandTimeout)){this.LimitCommandTimeout=curtime+timeout;return true}return false}function ng_EndLimitCommand(){this.LimitCommandID=this.ActiveCommandID}function ng_CmdFinished(){if(this.ActiveCommandID==this.LimitCommandID){this.LimitCommandTimeout=0}if(this.TilesCanceledByCommand){this.Refresh();}this.InCmd=false;if(this.OnCommandFinished)this.OnCommandFinished(this);if(this.Initialized==1){this.Initialized=2;if(this.OnInitialize)this.OnInitialize(this);}if(this.PreviewParent){this.PreviewParent.MapCommand('UP');}if(this.ActiveCommandCallback)this.ActiveCommandCallback(this);this.ActiveCommand='';this.ActiveCommandParams='';this.ActiveCommandCallback=null}function ng_GetMapSession(){return this.MapSession}function ng_GetMapURL(){return this.MapURL}function ng_SetMapSession(session,url,zoomanim){if((this.MapSession!=session)||(this.MapURL!=url)){if(zoomanim){this.ImageZoomL=this.MapLayer;this.CancelTileLoading(this.MapLayer);if(this.MapLayer==1)this.MapLayer=2;else this.MapLayer=1;this.LastClearedLayer=-1}this.ClearMapLayer(this.MapLayer);this.MapURL=url;this.MapSession=session;this.MapNeedRefresh=true;this.X=0;this.Y=0;if(this.OnSetMapSession)this.OnSetMapSession(this);return true}return false}function ng_CancelMapCommand(){if(this.InCmd)return;if(this.ActiveCommand!=''){if(this.OnCommandCancel)this.OnCommandCancel(this);this.ActiveCommandCallback=null}this.ActiveCommandID++;if(this.ActiveCommandID>99)this.ActiveCommandID=0;this.ActiveCommand='';this.ActiveCommandParams='';if(this.MapCommandTimer)clearTimeout(this.MapCommandTimer);this.MapCommandTimer=null}function ng_PositionChangedTimer(mapid){var map=getMapByID(mapid);if(map)map.MapCommand('P');}function ng_PositionChanged(){if(this.OnPositionChanged)this.OnPositionChanged(this);this.CancelMapCommand();this.MapCommandTimer=setTimeout('ng_PositionChangedTimer(\''+this.MapID+'\');',500);}function ng_SetMode(mode){if(!this.Initialized){this.InitMode=mode;return}if((this.OnModeChanging)&&(!this.OnModeChanging(this,mode)))return;if(mode!=this.Mode){this.HidePopup();this.HideMapMenu();}this.MouseMode='';if(mode=='P'){this.MouseMode='P';this.SetCursor(curPan);}if(mode=='Z+'){this.MouseMode='R';this.SetCursor(curZoomIn);}this.Mode=mode;if(this.OnModeChanged)this.OnModeChanged(this);}function ng_PanMode(){this.SetMode('P');}function ng_ZoomMode(){this.SetMode('Z+');}function ng_GetVerticalPan(){var pan=this.VerticalPan;if(pan==0)pan=(this.MapHeight/2)-30;if(pan<30)pan=30;return pan}function ng_GetHorizontalPan(){var pan=this.HorizontalPan;if(pan==0)pan=(this.MapWidth/2)-30;if(pan<30)pan=30;return pan}function ng_MapLeft(){this.Pan(-this.GetHorizontalPan(),0);}function ng_MapRight(){this.Pan(this.GetHorizontalPan(),0);}function ng_MapUp(){this.Pan(0,-this.GetVerticalPan());}function ng_MapDown(){this.Pan(0,this.GetVerticalPan());}function ng_MapLeftUp(){this.Pan(-this.GetHorizontalPan(),-this.GetVerticalPan());}function ng_MapRightUp(){this.Pan(this.GetHorizontalPan(),-this.GetVerticalPan());}function ng_MapLeftDown(){this.Pan(-this.GetHorizontalPan(),this.GetVerticalPan());}function ng_MapRightDown(){this.Pan(this.GetHorizontalPan(),this.GetVerticalPan());}function ng_ZoomOut(l,t,nc){var params='';if((typeof nc!='undefined')&&(nc))params+='1';else params+='0';if((typeof l!='undefined')&&(typeof t!='undefined')){params+='&SL='+l+'&ST='+t}this.MapCommand('ZO',params);}function ng_ZoomIn(l,t,r,b,nc){var params='';if((typeof nc!='undefined')&&(nc))params+='1';else params+='0';if((typeof l!='undefined')&&(typeof t!='undefined')){if(typeof r=='undefined')r=l;if(typeof b=='undefined')b=t;params+='&SL='+l+'&ST='+t+'&SR='+r+'&SB='+b}this.MapCommand('ZI',params);}function ng_MaxDetail(l,t,nc){var params='';if((typeof nc!='undefined')&&(nc))params+='1';else params+='0';if((typeof l!='undefined')&&(typeof t!='undefined')){params+='&SL='+l+'&ST='+t}this.MapCommand('MI',params);}function ng_MinDetail(l,t,nc){var params='';if((typeof nc!='undefined')&&(nc))params+='1';else params+='0';if((typeof l!='undefined')&&(typeof t!='undefined')){params+='&SL='+l+'&ST='+t}this.MapCommand('MO',params);}function ng_Home(){this.MapSession='';this.X=0;this.Y=0;if(this.PreviewMap){this.PreviewMap.MapSession='';this.PreviewMap.X=0;this.PreviewMap.Y=0}this.MapCommand('P');}function ng_Refresh(){this.MapNeedRefresh=true;this.SetMapOffsetEx(this.X,this.Y);}function ng_Update(){this.MapCommand('P');}function ng_SetScale(scale,l,t){var params=scale;if((typeof l!='undefined')&&(typeof t!='undefined')){params+='&SL='+l+'&ST='+t}this.MapCommand('SC',params);}function ng_LocateXY(pos){if((typeof pos=='undefined')||(pos==''))return;this.MapCommand('L',ng_URLEncode(pos));}function ng_LocateScaleXY(scale,pos){if((typeof pos=='undefined')||(pos==''))return;this.MapCommand('L',ng_URLEncode(pos)+'&SC='+scale);}function ng_SetRegion(regionid){if((typeof regionid=='undefined')||(regionid==''))return;this.MapCommand('R',ng_URLEncode(regionid));}function ng_Center(x,y){this.Pan(x-this.MapWidth/2,y-this.MapHeight/2);}function ng_MoveTo(x,y){this.SetMapOffsetEx(this.X+x-this.MapWidth/2,this.Y+y-this.MapHeight/2);}function ng_OnDrag(e){if(!e){e=window.event;e.returnValue=false}else{if(e.preventDefault)e.preventDefault();}return false}function ng_OnContextMenu(e){if(!e){e=window.event;e.returnValue=false}else{if(e.preventDefault)e.preventDefault();}return false}function ng_HandleCtrl(ctrlDown){if(ctrlDown!=CTRL_DOWN){CTRL_DOWN=ctrlDown;if((ctrlDown)&&(!ngKeyMap)&&(ngCurrentMap)&&(ngCurrentMap.AllowCtrl)&&(ngCurrentMap.MouseEvents)&&(ngCurrentMap.MouseOnMap)&&(!ngCurrentMap.MouseDown)){ngCurrentMap.SetMode(ngCurrentMap.Mode=='P'?'Z+':'P');ngKeyMap=ngCurrentMap}else if((!ctrlDown)&&(ngKeyMap)){ngKeyMap.SetMode(ngKeyMap.Mode=='P'?'Z+':'P');ngKeyMap=null}}}function OnMapKeyDown(e){if(!e)e=window.event;if((OnKeyDownBefore)&&(!OnKeyDownBefore(e)))return true;var map=ngCurrentMap;var ieKey=e.keyCode;ng_HandleCtrl((e.ctrlKey)||((ieKey==32)&&((ngKeyMap)||((map)&&(map.Mode!='P')))));if((map)&&(map.KeyEvents)&&(map.MouseOnMap)){if((map.OnKeyDown)&&(!map.OnKeyDown(map,e)))return true;if((ieKey==37)||(ieKey==38)||(ieKey==39)||(ieKey==40)){if((!map.AnimationStarted)||(!map.KeyScroll))map.KeyScroll=map.KeyScrollStart;else if(map.KeyScroll<map.KeyScrollMax)map.KeyScroll+=map.KeyScrollDelta;if(map.AnimationStarted){switch(ieKey){case 37:map.PanDX=-map.KeyScroll;map.PanDY=0;break;case 38:map.PanDY=-map.KeyScroll;map.PanDX=0;break;case 39:map.PanDX=map.KeyScroll;map.PanDY=0;break;case 40:map.PanDY=map.KeyScroll;map.PanDX=0;break}map.PanStartX=map.X+map.PanSX;map.PanStartY=map.Y+map.PanSY;map.PanX=map.PanSX;map.PanY=map.PanSY;map.PanSX=map.PanDX/(map.PanMinInterval/map.PanDelay);map.PanSY=map.PanDY/(map.PanMinInterval/map.PanDelay);ieKey=0}}switch(ieKey){case 33:map.Up();break;case 34:map.Down();break;case 37:map.Pan(-map.KeyScroll,0);break;case 38:map.Pan(0,-map.KeyScroll);break;case 39:map.Pan(map.KeyScroll,0);break;case 40:map.Pan(0,map.KeyScroll);break;case 187:case 107:if(map.LimitCommandFreq(1000))map.ZoomIn();break;case 189:case 109:if(map.LimitCommandFreq(1000))map.ZoomOut();break}return false}if(OnKeyDownAfter){var ret=OnKeyDownAfter(e);if(typeof ret!='undefined')return ret}return true}function OnMapKeyUp(e){if(!e)e=window.event;if((OnKeyUpBefore)&&(!OnKeyUpBefore(e)))return true;var map=ngCurrentMap;ng_HandleCtrl(e.ctrlKey);if((map)&&(map.KeyEvents)&&(map.MouseOnMap)){if((map.OnKeyUp)&&(!map.OnKeyUp(map,e)))return true}if(OnKeyUpAfter){var ret=OnKeyUpAfter(e);if(typeof ret!='undefined')return ret}return true}function getMapByID(mapid){var o=document.getElementById(mapid);if((o)&&(o.ngMap))return o.ngMap;return null}function ng_RefreshObjReferences(){this.ObjMap=new Array(document.getElementById(this.MapID),document.getElementById(this.MapID+'_M1'),document.getElementById(this.MapID+'_M2'));var o=document.getElementById(this.MapID+'_Holder');o.ondrag=function(){return false};o.onselectstart=function(){return false};this.ObjCanvasDC=document.getElementById(this.MapID+'DC');this.ObjCanvasDI=document.getElementById(this.MapID+'DI');this.ObjSelRect=document.getElementById(this.MapID+'_Sel');this.ObjSelRect2=document.getElementById(this.MapID+'_Sel2');this.ObjMenu=document.getElementById(this.MapID+'_Menu');this.ObjPreview=document.getElementById(this.MapID+'_Preview');}function ng_IEForceUpdate(){this.ObjMap[0].offsetLeft}function ng_SetKeyEvents(val){if(this.KeyEvents!=val){this.KeyEvents=val}}function ng_SetMouseEvents(val){if(this.MouseEvents!=val){if(!val)this.SetCursor(curDefault);else this.SetCursor(this.CurrentCursor);this.MouseEvents=val}}function ng_Initialize(){if(this.Initialized)return;this.SetMapSize(this.MapWidth,this.MapHeight);this.Initialized=1;this.SetMode(this.InitMode);}function ng_Assign(srcmap){if(srcmap==this)return;this.SetMapSession(srcmap.MapSession,srcmap.MapURL,false);this.SetMapOffsetEx(srcmap.X,srcmap.Y);this.ClearCanvas();}function ng_Preview(srcmap,style){if((typeof style=='undefined')||(style==''))style='cMapPreviewDefault';var o=this.ObjMap[0];if(o){if(srcmap){var html=o.innerHTML;if(html.indexOf(this.MapID+'_Preview')==-1){o.innerHTML=html+'<div class="cMapPreview '+style+'" id="'+this.MapID+'_Preview"></div>';this.RefreshObjReferences();}}}if(this.PreviewParent)this.PreviewParent.PreviewMap=null;this.PreviewParent=srcmap;if(srcmap)srcmap.PreviewMap=this;this.SetKeyEvents(false);this.AllowCtrl=false;this.MouseZoomOut=false;this.MouseWheel=false;this.PanMode();}function ng_SetPreviewRect(l,t,r,b){var o=this.ObjPreview;if(o){o.style.visibility='visible';ng_setBounds(o,l,t,r-l,b-t);if(this.OnPreviewRectChanged)this.OnPreviewRectChanged(this,o);}}function ngMap(mapid,commandurl){this.MapID=mapid;this.rpc=new ngRPC(this.MapID);this.APIKey='';if(typeof ngMapAPIKey!='undefined')this.APIKey=ngMapAPIKey;ng_PreloadImage(ngMapAPIURL+'/popupArrDown.gif');ng_PreloadImage(ngMapAPIURL+'/popupArrUp.gif');var o=document.getElementById(mapid);if(o){o.ngMap=this;o.onmouseover=ng_EnterMap;o.onmouseout=ng_LeaveMap;var html=new ngStringBuilder();html.append('<canvas id="'+mapid+'DC" class="cDC"></canvas>');html.append('<div id="'+mapid+'DI" class="cDC"></div>');html.append('<div id="'+mapid+'_Menu" class="csMAPPopup"></div>');html.append('<div id="'+mapid+'_Holder" class="cMapHolder">');html.append('<div class="cMapSelRect"  id="'+mapid+'_Sel"></div>');html.append('<div class="cMapSelRect2" id="'+mapid+'_Sel2"></div>');html.append('<div id="'+mapid+'_M1" class="cMap1"></div>');html.append('<div id="'+mapid+'_M2" class="cMap2"></div>');html.append('</div>');o.innerHTML=html.toString();o.oncontextmenu=ng_OnContextMenu;o.ondrag=ng_OnDrag;o=document.getElementById(this.MapID+'_Menu');if(o){o.ngMap=this;o.onmouseover=ng_EnterMapMenu;o.onmouseout=ng_LeaveMapMenu}}this.RefreshObjReferences=ng_RefreshObjReferences;this.RefreshObjReferences();this.IEForceUpdate=(ngIExplorer?ng_IEForceUpdate:ngNop);this.Initialized=0;this.TileWidth=0;this.TileHeight=0;this.TileColCount=0;this.TileRowCount=0;this.TileOffsetX=0;this.TileOffsetY=0;this.TileLoading=new Array(null,null,null);this.TileLoadingCnt=0;this.TileRetryTimer=null;this.TileRetry=new Array;this.TileRetryCnt=0;this.LastTileStx=-1;this.LastTileSty=-1;this.MapLayer=1;this.LastClearedLayer=2;this.MapWidth=0;this.MapHeight=0;this.MapNeedRefresh=false;this.MouseOnMap=false;o=this.ObjMap[1];if(o){this.MapWidth=o.clientWidth;if(ngOpera)this.MapWidth-=16;this.MapHeight=o.clientHeight}this.PopupX=-1000;this.PopupY=-1000;this.MapMenuX=-1000;this.MapMenuY=-1000;this.MapMenuTimeout=300;this.MapMenuTimer=null;this.InMapMenu=false;this.HideMapMenuTimer=null;this.MapURL='';this.MapSession='';this.MapCommandTimer=null;this.MapCommandParams='';this.PHPSession='';this.CommandURL=ngMapAPIURL+'/map.php';if(typeof commandurl!='undefined')this.CommandURL=commandurl;this.InCmd=false;this.ActiveCommand='';this.ActiveCommandParams='';this.ActiveCommandID=0;this.LimitCommandID=-1;this.LimitCommandTimeout=0;this.ActiveCommandCallback=null;this.TilesCanceledByCommand=false;this.PreviewZoom=10;this.PreviewMap=null;this.PreviewParent=null;this.Mode='Z+';this.InitMode='Z+';this.MouseMode='';this.CurrentCursor='';if(ngOpera){this.CursorZoomIn="crosshair";this.CursorZoomOut="crosshair";this.CursorPan="move"}else{this.CursorZoomIn="url('"+ngMapAPIURL+"/DynamicZoomIn.cur'), crosshair";this.CursorZoomOut="url('"+ngMapAPIURL+"/ZoomOut.cur'), crosshair";this.CursorPan="url('"+ngMapAPIURL+"/Pan.cur'), move"}this.AnimationStarted=false;this.PanTimer=null;this.PanMinInterval=600;this.PanDelay=10;this.PanNoPosChanged=false;this.HorizontalPan=0;this.VerticalPan=0;this.ImageZoomL=-1;this.ImageZoomHookPan=false;this.ImageZoomPan=0;this.MouseDown=0;this.MouseUpTicks=0;this.MouseX=0;this.MouseY=0;this.MouseSelLeft=0;this.MouseSelTop=0;this.MouseSelRight=0;this.MouseSelBottom=0;this.CanvasX=0;this.CanvasY=0;this.CanvasOffsetX=0;this.CanvasOffsetY=0;this.CanvasHTML=new ngStringBuilder();this.CanvasUpdateCnt=0;this.MapPopupX=-1000;this.MapPopupY=-1000;this.PopupIcons=new Array();this.InPopupRect=false;this.InPopupObj=false;this.HidePopupTimer=null;this.ActivePopupIcon=null;this.PopupStyle="csMAPPopup";this.PopupTextStyle="csMAPPopupText";this.PopupMenuStyle="csMAPPopupMenu";this.PopupFrameStyle="csMAPPopupFrame";this.DisplayPopupTimeout=0;this.DisplayPopupByClick=true;this.DisplayPopupTimer=null;this.X=0;this.Y=0;this.ZoomAnimation=true;this.PanAnimation=true;this.MouseEvents=true;this.KeyEvents=true;this.AllowCtrl=true;this.MouseZoomOut=true;this.MouseWheel=true;this.MouseWheelMode=0;this.KeyScrollStart=100;this.KeyScrollDelta=10;this.KeyScrollMax=1000;this.KeyScroll=0;this.Initialize=ng_Initialize;this.CancelMapMove=ng_CancelMapMove;this.ImageZoomAnimFinished=ng_ImageZoomAnimFinished;this.CancelImageZoomAnim=ng_CancelImageZoomAnim;this.ImageZoomAnim=ng_ImageZoomAnim;this.StartAnimation=ng_StartAnimation;this.EndAnimation=ng_EndAnimation;this.GetMousePosition=ng_GetMousePosition;this.UpdateRect=(ngIExplorer?ng_UpdateRectIE:ng_UpdateRect);this.SwapMapLayers=ng_SwapMapLayers;this.HideSecondMapLayer=ng_HideSecondMapLayer;this.GetMapLayer=ng_GetMapLayer;this.GetMapURL=ng_GetMapURL;this.CancelTileLoading=ng_CancelTileLoading;this.ClearMapLayer=ng_ClearMapLayer;this.SetImageZoom=ng_SetImageZoom;this.ReloadFailedTiles=ng_ReloadFailedTiles;this.DoTilesLoaded=ng_DoTilesLoaded;this.SetMapOffset=ng_SetMapOffset;this.SetMapOffsetEx=ng_SetMapOffsetEx;this.HideCanvas=ng_HideCanvas;this.ShowCanvas=ng_ShowCanvas;this.ClearCanvasEx=ng_ClearCanvasEx;this.ClearCanvasEx2=ng_ClearCanvasEx2;this.SetCanvasOffset=ng_SetCanvasOffset;this.CanvasDrawOffsetX=ng_CanvasDrawOffsetX;this.CanvasDrawOffsetY=ng_CanvasDrawOffsetY;this.DrawOverlay=ng_DrawOverlay;this.DrawPopupIcons=ng_DrawPopupIcons;this.DrawPopupIcon=ng_DrawPopupIcon;this.SetPopupIcons=ng_SetPopupIcons;this.CreatePopup=ng_CreatePopup;this.ShowPopup=ng_ShowPopup;this.CancelDisplayPopup=ng_CancelDisplayPopup;this.ActiveLayers=new Array();this.SetActiveLayers=ng_SetActiveLayers;this.IsActiveCmd=ng_IsActiveCmd;this.CmdFinished=ng_CmdFinished;this.PositionChanged=ng_PositionChanged;this.GetVerticalPan=ng_GetVerticalPan;this.GetHorizontalPan=ng_GetHorizontalPan;this.SetPreviewRect=ng_SetPreviewRect;this.SetKeyEvents=ng_SetKeyEvents;this.SetMouseEvents=ng_SetMouseEvents;this.Assign=ng_Assign;this.Preview=ng_Preview;this.SetMapSize=ng_SetMapSize;this.HideMapMenu=ng_HideMapMenu;this.MapCommand=ng_MapCommand;this.CancelMapCommand=ng_CancelMapCommand;this.SetMapCommandParam=ng_SetMapCommandParam;this.RemoveMapCommandParam=ng_RemoveMapCommandParam;this.LimitCommandFreq=ng_LimitCommandFreq;this.EndLimitCommand=ng_EndLimitCommand;this.SetPHPSession=ng_SetPHPSession;this.SetMode=ng_SetMode;this.PanMode=ng_PanMode;this.ZoomMode=ng_ZoomMode;this.Left=ng_MapLeft;this.Right=ng_MapRight;this.Up=ng_MapUp;this.Down=ng_MapDown;this.LeftUp=ng_MapLeftUp;this.RightUp=ng_MapRightUp;this.LeftDown=ng_MapLeftDown;this.RightDown=ng_MapRightDown;this.ZoomOut=ng_ZoomOut;this.ZoomIn=ng_ZoomIn;this.MaxDetail=ng_MaxDetail;this.MinDetail=ng_MinDetail;this.Home=ng_Home;this.Refresh=ng_Refresh;this.Update=ng_Update;this.Pan=ng_Pan;this.SetScale=ng_SetScale;this.LocateXY=ng_LocateXY;this.LocateScaleXY=ng_LocateScaleXY;this.LocatePopupIcon=ng_LocatePopupIcon;this.LocatePopupIcons=ng_LocatePopupIcons;this.SetRegion=ng_SetRegion;this.Center=ng_Center;this.MoveTo=ng_MoveTo;this.DrawIcon=ng_DrawIcon;this.DrawLine=(ngIExplorer?ng_DrawLineIE:ng_DrawLine);this.DrawLineFromStr=ng_DrawLineFromStr;this.DrawArea=(ngIExplorer?ng_DrawAreaIE:ng_DrawArea);this.DrawAreaFromStr=ng_DrawAreaFromStr;this.ClearCanvas=ng_ClearCanvas;this.CanvasEndUpdate=ng_CanvasEndUpdate;this.CanvasBeginUpdate=ng_CanvasBeginUpdate;this.AddPopupIcon=ng_AddPopupIcon;this.ClearPopupIcons=ng_ClearPopupIcons;this.RemovePopupIconByID=ng_RemovePopupIconByID;this.RemovePopupIconsByID=ng_RemovePopupIconsByID;this.CreatePopupHTML=ng_CreatePopupHTML;this.PopupIconExists=ng_PopupIconExists;this.ShowPopupByID=ng_ShowPopupByID;this.HidePopup=ng_HidePopup;this.GetActiveObjByID=ng_GetActiveObjByID;this.ShowActiveObjPopupByID=ng_ShowActiveObjPopupByID;this.ShowActiveObjPopup=ng_ShowActiveObjPopup;this.SetMapSession=ng_SetMapSession;this.GetMapSession=ng_GetMapSession;this.Offset=ng_Offset;this.URLStateParams=ng_URLStateParams;this.SetCursor=ng_SetCursor;this.ProcessUrl=ng_ProcessUrl;this.MapContainerLeft=ng_MapContainerLeft;this.MapContainerTop=ng_MapContainerTop;this.OnInitialize=null;this.OnModeChanging=null;this.OnModeChanged=null;this.OnCommand=null;this.OnCommandFinished=null;this.OnCommandCancel=null;this.OnTilesLoading=null;this.OnTilesLoaded=null;this.OnSetMapSession=null;this.OnOffsetChanging=null;this.OnOffsetChanged=null;this.OnPositionChanged=null;this.OnPreviewRectChanged=null;this.OnDrawOverlay=null;this.OnMapMenu=null;this.OnActiveLayers=null;this.OnActiveObjectMenu=null;this.OnGetMousePosition=null;this.OnMouseDown=null;this.OnMouseMove=null;this.OnMouseUp=null;this.OnDblClick=null;this.OnMouseWheel=null;this.OnKeyDown=null;this.OnKeyUp=null;this.OnMouseEnter=null;this.OnMouseLeave=null;this.OnStartAnimation=null;this.OnEndAnimation=null;this.OnHidePopup=null;if(!ngMapEventsInitialized){document.onkeydown=ngAddEvent(document.onkeydown,OnMapKeyDown);document.onkeyup=ngAddEvent(document.onkeyup,OnMapKeyUp);document.onmousedown=ngAddEvent(document.onmousedown,OnMapMouseDown);document.onmousemove=ngAddEvent(document.onmousemove,OnMapMouseMove);document.onmouseout=ngAddEvent(document.onmouseout,OnMapMouseOut);document.onmouseup=ngAddEvent(document.onmouseup,OnMapMouseUp);document.ondblclick=ngAddEvent(document.ondblclick,OnMapDblClick);document.onmousewheel=ngAddEvent(document.onmousewheel,OnMapWheel);if(window.addEventListener)window.addEventListener('DOMMouseScroll',OnMapWheel,false);ngMapEventsInitialized=true}}