var DomeMaps={version:'1.1'};(function(){this.$=window.$;var extend_initObject=[];function extend(Child,Parent){var F=function(){};if(!extend_initObject[Parent]){new Parent();extend_initObject[Parent]=1;}
F.prototype=Parent.prototype;Child.prototype=new F();Child.prototype.constructor=Child;Child.superclass=Parent.prototype;}
var MAPTYPE_NORMAL=1;var MAPTYPE_HYBRID=2;var MAPTYPE_SATELITE=3;var mLatLng=function(x,y)
{this.x=+x;this.y=+y;}
mLatLng.prototype.lat=function(){return this.x;}
mLatLng.prototype.lng=function(){return this.y;}
mLatLng.prototype.getLat=function(){return this.lat();}
mLatLng.prototype.getLng=function(){return this.lng();}
mLatLng.prototype.dup=function(){return new mLatLng(this.x,this.y)};var mLatLngBounds=function(lt,br)
{this.lt=lt;this.br=br;}
mLatLngBounds.prototype.getCenter=function(){return new mLatLng(this.lt.x+(this.br.x-this.lt.x)/2,this.lt.y+(this.br.y-this.lt.y)/2)}
mLatLngBounds.prototype.getSouthWest=function(){return this.br;}
mLatLngBounds.prototype.getNorthEast=function(){return this.lt;}
mLatLngBounds.prototype.dup=function(){return new mLatLngBounds(this.lt,this.br)};var MapWorker=function(divid,classname)
{this._tearFunction=0;this._divClassName=classname||"ged_map";this.initialize(divid);}
MapWorker.prototype.initialize=function(divid)
{this._mapDivId=divid;this.useAbsoluteMapDiv=1;this.traceSelfToLocation=1;this.worker=0;this.workerName=0;this.mapType=0;this.activated=0;this.isMapReady=0;this.mapDivWorkable=0;this.ZTile=0;this.currentBalloon=0;this._windowInitialLocation=[];this._readyEvents=[];this._initstateEvents=[];this._leavestateEvents=[];this._position=this.LatLng(55.743545,37.597962);this._zoom=10;this.DivOffset=1;this.layers=[];this.layerDef=[];this._selectedLayers=[];this._eventViewActivation=[];this.divDim={w:0,h:0,x:0,y:0};this._lastDivDim={w:0,h:0,x:0,y:0};this.isActive=0;this.checkInterval=0;this.tryRepositionTimeout=0;this.fullScreenMode=0;this._stages=[];this._stageTimeout=0;this.activeViewLayers=[];this.callZTile_tm=0;this.events_moveend=[];this.events_onmove=[];this.events_dragend=[];this.paranoicReposition=0;this.have_error=0;this.loadingGuardCntErrors=0;this.messageLog=[];this.__initialState=this._enterState("init-idle");this.__initialTime=this.microtime();}
MapWorker.prototype.microtime=function(){var now=new Date().getTime()/1000;return now;}
MapWorker.prototype.console=function(text){if(text)
{var message=(Math.round((this.microtime()-this.__initialTime)*100)/100)+": "+text;if(window.console&&console)
console.log(message);this.messageLog.push(message);}}
MapWorker.prototype.setWindowRef=function(refarray){this._windowInitialLocation=refarray;}
MapWorker.prototype.activate=function(objName){this.activated=1;if(this.workerName=='yandex')
this.setYandexMaps();if(this.workerName=='google')
this.setGoogleMaps();}
MapWorker.prototype.$=function(name){return document.getElementById(name);}
MapWorker.prototype.getRealOffsetX=function(objName){var tmpX=0;var tmpObj=objName.offsetParent;if(tmpObj)
while(tmpObj&&tmpObj.tagName!='BODY'){tmpX+=(tmpObj.offsetLeft);tmpObj=tmpObj.offsetParent;}
return tmpX+(objName.offsetLeft);}
MapWorker.prototype.getRealOffsetY=function(objName){var tmpY=0;var tmpObj=objName.offsetParent;if(tmpObj)
while(tmpObj&&tmpObj.tagName!='BODY'){tmpY+=(tmpObj.offsetTop);tmpObj=tmpObj.offsetParent;}
return tmpY+(objName.offsetTop);}
MapWorker.prototype.is_visible=function(objName)
{if(!$(objName).visible())return 0;var tmpObj=objName.offsetParent;if(!tmpObj)tmpObj=objName.parentNode;if(tmpObj)
while(tmpObj&&tmpObj.tagName!='BODY'){if(!$(tmpObj).visible())return 0;objName=tmpObj;tmpObj=tmpObj.offsetParent;if(!tmpObj)tmpObj=objName.parentNode;if(objName==tmpObj)return 0;}
return 1;}
MapWorker.prototype._inject=function()
{this.console("inject");if(!this.useAbsoluteMapDiv){this.mapDivId=this._mapDivId;this.mapWorkerId=this._mapDivId;this.mapDiv=this.$(this.mapDivId);this.mapDiv.innerHTML='';this.onRepositionDiv();}else{this._deject();this.mapDivId=this._mapDivId+'_mapBlocker';this.mapWorkerId=this._mapDivId+'_mapWorker';this.mapDiv=document.createElement("div");this.mapDiv.className=this._divClassName;this.mapDiv.style.position="absolute";this.mapDiv.setAttribute('id',this.mapDivId);this.mapDiv.innerHTML="<div id='"+this.mapWorkerId+"' style='width:100%;height:100%;'></div>";this.onRepositionDiv();document.body.appendChild(this.mapDiv);}
this.mapWorkerDiv=document.getElementById(this.mapWorkerId);var thisworker=this;this.try_onRepositionDiv();if(window.addEventListener)window.addEventListener("resize",function(){thisworker.try_onRepositionDiv()},false);if(window.attachEvent)window.attachEvent("onresize",function(){thisworker.try_onRepositionDiv()});this.checkInterval=setInterval(function(){thisworker.try_onRepositionDiv(1);},500);}
MapWorker.prototype._deject=function()
{if(!this.useAbsoluteMapDiv)return;if(this.mapDiv)
{this.mapDiv.parentNode.removeChild(this.mapDiv);clearInterval(this.checkInterval);clearTimeout(this.tryRepositionTimeout);this.checkInterval=0;delete this.mapDiv;this.mapDiv=0;}}
MapWorker.prototype.toggleFullScreen=function(){this.fullScreenMode=this.fullScreenMode?0:1;if(this.fullScreenMode)
this.enterFullscreenMode();else
this.leaveFullscreenMode();this.onRepositionDiv();}
MapWorker.prototype.enterFullscreenMode=function(){}
MapWorker.prototype.leaveFullscreenMode=function(){}
MapWorker.prototype.containerOffset=function(){return{x:parseInt(this.mapDiv.style.left),y:parseInt(this.mapDiv.style.top)};}
MapWorker.prototype.containerDimensions=function(){return{w:parseInt(this.mapDiv.style.width),h:parseInt(this.mapDiv.style.height)};}
MapWorker.prototype.try_onRepositionDiv=function(passive){var _this=this;clearTimeout(this.tryRepositionTimeout);this.tryRepositionTimeout=setTimeout(function(){try{_this.onRepositionDiv(passive);}catch(e){}},1);}
MapWorker.prototype.getSourceDiv=function(){return this.$(this._mapDivId);}
MapWorker.prototype.window_innerHeight=function()
{if(typeof(window.innerWidth)=='number')
return window.innerHeight;else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
return document.documentElement.clientHeight;return 1;}
MapWorker.prototype.setParanoicReposition=function(on){this.paranoicReposition=on;}
MapWorker.prototype.onRepositionDiv=function(passive)
{passive=passive||0;var _this=this;var source=this.getSourceDiv();if(!source||!source.style)this.try_onRepositionDiv();if(!this.useAbsoluteMapDiv){this.mapDivWorkable=1;}
else{var offy=this.getRealOffsetY(source);if(source.style.display=='none'||source.offsetWidth<10||source.offsetHeight<10||(!this.getRealOffsetX(source)||(this.paranoicReposition&&(offy<1||offy>Math.max(document.body.clientHeight,0))))){if(this.mapDiv.style.display!='none'){if(window.console){console.log("will hide(",this._mapDivId,"):",",D:",source.style.display,",oW:",source.offsetWidth,",oH:",source.offsetHeight,",ROX:",this.getRealOffsetX(source),"||",offy,"(",this.paranoicReposition,")<",document.body.clientHeight,":",1);}
this.mapDiv.style.display='none';this.divDim={w:1,h:1};this._lastDivDim={w:1,h:1};this.mapDivWorkable=0;this.tryCloseBalloon(0,true);}
return;}
else
{if(this.mapDiv.style.display=='none')
this.mapDiv.style.display='';if(!this.mapDivWorkable)
this.tryRestoreBalloon(0,true);}
this.mapDivWorkable=1;this.mapDiv.style.top=(this.getRealOffsetY(source)+this.DivOffset)+'px';this.mapDiv.style.left=(this.getRealOffsetX(source)+this.DivOffset)+'px';this.mapDiv.style.width=(parseInt(source.clientWidth)-this.DivOffset)+'px';this.mapDiv.style.height=(parseInt(source.clientHeight)-this.DivOffset)+'px';}
if(!isFinite(parseInt(this.mapDiv.style.left))){return;}
this.divDim={w:parseInt(this.mapDiv.clientWidth),h:parseInt(this.mapDiv.clientHeight),x:parseInt(this.mapDiv.style.left),y:parseInt(this.mapDiv.style.top)};{var sizechanged=this._lastDivDim.w!=this.divDim.w||this._lastDivDim.h!=this.divDim.h||this._lastDivDim.x!=this.divDim.x||this._lastDivDim.y!=this.divDim.y;if(sizechanged){this.console("set dim("+this._mapDivId+") as "+this.divDim.w+"x"+this.divDim.h+" at "+this.divDim.x+":"+this.divDim.y+" of "+this.window_innerHeight()+"/"+document.body.clientHeight);this._lastDivDim={w:this.divDim.w,h:this.divDim.h,x:this.divDim.x,y:this.divDim.y};if(this.worker&&this.isActive)
{var oldposition=this.worker.getPosition();var onrepositionevent=function(){if(_this.callWorker()){_this.worker.checkResize();_this.setPosition(oldposition,_this.getZoom());_this.callZTile();}}
if(oldposition){clearTimeout(this.onrepositionevent_tm);if(passive==2)this.onrepositionevent_tm=setTimeout(onrepositionevent,20);else onrepositionevent();}}
this._onOuterBalloonMove();setTimeout(function(){_this._onOuterBalloonMove();},100);}}}
MapWorker.prototype.checkMap=function()
{this.onRepositionDiv();}
MapWorker.prototype.getMinViewDimensions=function()
{var dw=this.divDim.w;var dh=this.divDim.h;if(dw>dh)return dh;else return dw;}
MapWorker.prototype.getViewDimensions=function()
{return this.divDim;}
MapWorker.prototype.tearUp=function(byfunction)
{if(window.ControlCustomOverlay)
new ControlCustomOverlay();if(window.BalloonsOverlay)
BalloonsOverlay();this._tearFunction=byfunction;this._inject();}
MapWorker.prototype.tearDown=function()
{this.killWorker();this._deject();}
MapWorker.prototype.respawn=function()
{this.tearDown();this.initialize(this._mapDivId);if(this._tearFunction)
this._tearFunction();else
this.tearUp();}
MapWorker.prototype.activateZTile=function()
{if(!this.ZTile)
{this.ZTile=new TileTale_jQuery(this);this.ZTile.init(this);}}
MapWorker.prototype.killWorker=function()
{this.isMapReady=0;var ecall=0;if(this.worker)
{var _this=this;this._enterState("worker tear down",function(){_this.tryCloseBalloon(0,true);if(_this.ZTile){_this.ZTile.resetObjects();}
var stateEvents=_this._leavestateEvents.slice(0);while((ecall=stateEvents.shift()))
{try{ecall(_this);}catch(e){this.console(e);}}
_this.worker.isClosed=1;_this.worker.tearDown();delete _this.worker;_this.$(_this.mapWorkerId).innerHTML='';},1);this.worker=0;this.isActive=0;}
clearTimeout(this.callZTile_tm);}
MapWorker.prototype._leaveState=function(_event){var _this=this;_event.leave=_this.microtime();_this.console("["+_event.name+"] took "+(_event.leave-_event.enter));return _event;}
MapWorker.prototype.__stateLoadingDone=function(){this._stages=[];}
MapWorker.prototype.__stateException=function(_event,_error){var states=this._stages.slice(0);var state=0;while((state=states.shift()))
{if(state.leave==0&&state.catcheble)
{state.catcheble(_event,_error);}}}
MapWorker.prototype.__callState=function(_event){try
{_event.func();this._leaveState(_event);}catch(e)
{_event.error=e;this.console("state-error ["+_event.name+"] "+e.fileName+":"+e.lineNumber+"\n"+e+"\n"+e.stack);this._leaveState(_event);this.__stateException(_event,e);;}}
MapWorker.prototype._enterState=function(name,func,sync,catcheble){var _event={'name':name,'func':func,'enter':this.microtime(),'leave':0,'catcheble':catcheble};var _this=this;this.console('entering ['+name+']'+this._stages.length);this._stages.push(_event);if(func){clearTimeout(this._stageTimeout);if(sync){_this.__callState(_event);}
else{this._stageTimeout=setTimeout(function(){_this.__callState(_event);},1);}}
return _event;}
MapWorker.prototype.onElementClick=function(element,refname){if(refname)
this.changeLocation(refname,'TPZVW');}
MapWorker.prototype.onParametersChange=function(){this.changeLocation('','TPLZVW');}
MapWorker.prototype._linejoinArray=function(a,names){var result='';var i;if(!names){for(i in a){if(a[i]){if(result)result+='&';result+=i+'='+a[i];}}}else{for(i in a){if(a[i]){if(result)result+=names;result+=a[i];}}}
return result;}
MapWorker.prototype.changeLocation=function(prefix,enabled){clearTimeout(this._changeLocationTm1);var _this=this;this._changeLocationTm1=setTimeout(function(){_this._changeLocation(prefix,enabled)},100);}
MapWorker.prototype._changeLocation=function(prefix,enabled)
{var _this=this;if(!this.activated||!this.isMapReady||!this.traceSelfToLocation)return false;var more={};var i;if(0){for(i in this._windowInitialLocation)
if(this._windowInitialLocation[i])
more[i]=this._windowInitialLocation[i];}
if(enabled.search(/P/)!=-1){var pos=this.getPosition();if(pos){more['lat']=Math.round(pos.lat()*100000)/100000;more['lng']=Math.round(pos.lng()*100000)/100000;}}
if(enabled.search(/W/)!=-1){var name=this.getWorkerName();if(name){more['m']=name;}}
if(enabled.search(/T/)!=-1){var name=this.getMapType();if(name){more['t']=name;}}
if(enabled.search(/Z/)!=-1){var name=this.getZoom();if(name){more['z']=name;}}
if(enabled.search(/L/)!=-1){if(this.getSelectedLayers()){var name=this._linejoinArray(this.getSelectedLayers(),'-');if(name){more['l']=name;}}}
var result=prefix;if(result)result+='&';result+=this._linejoinArray(more,0);clearTimeout(this.locationChangeTm);this.locationChangeTm=setTimeout(function(){_this.onChangeLocation(result);},500);return result;}
MapWorker.prototype.onChangeLocation=function(loc){}
MapWorker.prototype.reportError=function(text){}
MapWorker.prototype.onLoadingGuard=function(_event,error){var havingmaps=0;var _this=this;this.have_error=1;var ert='|error|';if(!error&&this.isMapReady)return;if(!error)ert='{timeout}';var oldapi=this.workerName;this.loadingGuardCntErrors++;this.console("guard count "+this.loadingGuardCntErrors);if(this.loadingGuardCntErrors>4){this.console("stop try start map "+this.loadingGuardCntErrors);return;}
try{this.worker.tryScanErrors();}catch(e){}
if(this.workerName=='yandex')this.workerName='google';else this.workerName='yandex';this.console("guard switch "+ert+" to other API ("+oldapi+"-->"+this.workerName+"), error cnt:"+this.loadingGuardCntErrors);this.isMapReady=0;this.__stateLoadingDone();this.reportError('* '+this.messageLog.join("\n* "));this.messageLog=[];this.console("change by "+ert+" Guarding ("+oldapi+"-->"+this.workerName+")");this._enterState("reactivate",function(){_this.activate();});}
MapWorker.prototype.startWorker=function(){this.isMapReady=0;this._inject();var _this=this;this.worker.isClosed=0;this.loadingGuard=this._enterState('loading guard',0,0,function(_event,error){_this.onLoadingGuard(_event,error);});this.loadingGuardTm=setTimeout(function(){_this.onLoadingGuard(0,0)},20000);this._enterState('init worker '+this.workerName,function(){_this.worker.init(_this.mapWorkerDiv,_this);});}
MapWorker.prototype.isYandex=function(){return this.worker&&this.worker.name=='yandex';}
MapWorker.prototype.isGoogle=function(){return this.worker&&this.worker.name=='google';}
MapWorker.prototype.onMapReady=function(){var thisworker=this;clearTimeout(this.tm_onMapReady);this._enterState('mapReady',function(){thisworker._onMapReady();});}
MapWorker.prototype._onMapReady=function(){this.isActive=1;var _this=this;var ecall=0;this.activateZTile();if(this.ZTile)this.ZTile.resetObjects();this.bindEvents();this.have_error=0;this.onRepositionDiv();this.setPosition(this._position,this._zoom);this._enterState('onready',function(){while((ecall=_this._readyEvents.shift()))
{try{ecall(_this);}catch(e){_this.console(e);}}},1);if(this.have_error)return;var stateEvents=this._initstateEvents.slice(0);this._enterState('stateInit',function(){while((ecall=stateEvents.shift()))
{try{ecall(_this);}catch(e){_this.console(e);}}},1);if(this.have_error)return;var ldef=this.layerDef.slice(0);while((ecall=ldef.shift()))
{try{ecall.setMap(this);}catch(e){this.console(e);}}
if(this.have_error)return;this.positionChanged();this.callZTile();if(!this.testMap()){this.console("map lag");}
if(this.__initialState){this._leaveState(this.__initialState);this.__initialState=0;}
if(this.have_error)return;this.isMapReady=1;this.setMapType(this.mapType);this.setPosition(this.getPosition(),this.getZoom());this.ZTile.newGeneration();clearTimeout(this.loadingGuardTm);this._leaveState(this.loadingGuard);this.__stateLoadingDone();this.tryRestoreBalloon(0,true);}
MapWorker.prototype.callZTile=function()
{clearTimeout(this.callZTile_tm);var tilethis=this;this.callZTile_tm=setTimeout(function(){tilethis.do_callZTile()},50);}
MapWorker.prototype.fixOutzoom=function(){if(this.ZTile&&this.mapDivWorkable&&this.isMapReady){var nowzoom=this.getZoom(true);if(nowzoom<2){return false;}
var pass=(this.lastZoom&&this.lastZoom>nowzoom+1);if(pass){var _this=this;clearTimeout(this.fixOutzoom_tm);this.fixOutzoom_tm=setTimeout(function(){_this.ZTile.hideAll(function(){_this.callZTile();});},1);return false;}}
return true;}
MapWorker.prototype.do_callZTile=function()
{if(this.positionChanged())
if(this.ZTile&&this.mapDivWorkable&&this.isMapReady)
{this.lastZoom=this.getZoom();this.ZTile.ZoomOffset=1;if(this.getMinViewDimensions()>100)
this.ZTile.moveend();else
this.ZTile.hideAll();}}
MapWorker.prototype.bindEvents=function()
{var thisworker=this;this.worker.bind2MoveEnd(function(){try{thisworker.fixOutzoom();setTimeout(function(){thisworker.callZTile();thisworker._onOuterBalloonMove();thisworker.dispatchEvents(thisworker.events_moveend);},1);thisworker._onOuterBalloonMove();}catch(e){thisworker.console(e);};},function(){try{setTimeout(function(){thisworker.dispatchEvents(thisworker.events_onmove);},1);thisworker._onOuterBalloonMove();}catch(e){thisworker.console(e);};},function(){try{setTimeout(function(){thisworker.dispatchEvents(thisworker.events_dragend);},1);thisworker._onOuterBalloonMove();}catch(e){thisworker.console(e);};});this.worker.bindClick(function(){thisworker.closeBalloon();});}
MapWorker.prototype.bindClick=function(closure){this.worker.bindClick(closure);}
MapWorker.prototype.bind2MoveEnd=function(onmove,onmoving,ondragend)
{if(onmove)this.events_moveend.push(onmove);if(onmoving)this.events_onmove.push(onmoving);if(ondragend)this.events_dragend.push(ondragend);}
MapWorker.prototype.dispatchEvents=function(inevents){var events=inevents.slice(0);var ecall=0;while((ecall=events.shift()))
{try{ecall(this);}catch(e){this.console(e);}}}
MapWorker.prototype.callWorker=function()
{if(this.worker)return true;else return false;}
MapWorker.prototype.setYandexMaps=function()
{this.workerName='yandex';if(this.activated&&!(this.worker&&this.worker.name=='yandex')){this.killWorker();this.worker=new YandexMapWorker(this.mapDivId,this);this.startWorker();}}
MapWorker.prototype.setGoogleMaps=function()
{this.workerName='google';if(this.activated&&!(this.worker&&this.worker.name=='google')){this.killWorker();this.worker=new GoogleMapWorker(this.mapDivId,this);this.startWorker();}}
MapWorker.prototype.geocode=function(search,callback,keyframe){keyframe=keyframe||0;if(this.worker)
return this.worker.geocode(search,callback,keyframe);else return false;}
MapWorker.prototype.onReady=function(a)
{this._readyEvents.push(a);if(this.isActive)a(this);}
MapWorker.prototype.onStateInit=function(a)
{this._initstateEvents.push(a);if(this.isActive)a(this);}
MapWorker.prototype.onStateLeave=function(a)
{this._leavestateEvents.push(a);}
MapWorker.prototype.setMapType=function(type){this.mapType=type;if(this.callWorker()){this.worker.setMapType(type);}
this.onParametersChange();}
MapWorker.prototype.getMapType=function(){return this.mapType;}
MapWorker.prototype.getWorkerName=function(){if(this.worker)return this.worker.name;else return'';}
MapWorker.prototype.testMap=function(){if(this.worker&&this.worker.api&&this.worker.getZoom()>0&&this.worker.getPosition())
return true;this.setPosition(this.getPosition(),this.getZoom());return false;}
MapWorker.prototype.setJump=function(){this.worker.setJump=1;}
MapWorker.prototype.setPosition=function(in_latlng,zoom)
{if(!in_latlng)in_latlng=this.getPosition();var latlng=in_latlng.dup();zoom=parseInt(zoom);zoom=Math.max(1,(zoom||this.getZoom()));this._position=latlng;this._zoom=zoom;if(this.callWorker())
{this.worker.setPosition(latlng,zoom);}}
MapWorker.prototype.setZoom=function(zoom)
{this.setPosition(this.getPosition(),zoom);}
MapWorker.prototype.getPosition=function()
{return this._position.dup();if(!this.callWorker())return false;return this.worker.getPosition();}
MapWorker.prototype.getZoom=function(force)
{if(!force)
return this._zoom;if(!this.callWorker())return this._zoom;this._zoom=this.worker.getZoom();return this._zoom;}
MapWorker.prototype.zoomToPointSet=function(set,maxzoom){maxzoom=maxzoom||16;maxzoom=Math.min(17,Math.max(3,maxzoom));this.worker.zoomToPointSet(set,maxzoom)}
MapWorker.prototype.getBounds=function()
{var bounds=this.worker.getBounds();if(!bounds)return false;bounds.equalsTo=function(bnd)
{var precision=0.0005;return(Math.abs(this.x1-bnd.x1)<=precision)&&(Math.abs(this.x2-bnd.x2)<=precision)&&(Math.abs(this.y1-bnd.y1)<=precision)&&(Math.abs(this.y2-bnd.y2)<=precision);}
return bounds;}
MapWorker.prototype.positionChanged=function()
{if(this.isMapReady&&this.worker&&this.worker.api){var newPosition=this.worker.getPosition();var newZoom=this.worker.getZoom();if(!newPosition||!newZoom)return false;this._position=newPosition.dup();this._zoom=newZoom;this.onParametersChange();}
return 1;}
MapWorker.prototype.LatLng=function(x,y)
{return new mLatLng(x,y);}
MapWorker.prototype.LLBounds=function(lt,br)
{return new mLatLngBounds(lt,br);}
MapWorker.prototype.CollectionBounds=function(pset){var lt=this.LatLng(pset[0].x,pset[0].y);var br=this.LatLng(pset[0].x,pset[0].y);pset=pset.slice(0);while((elem=pset.shift())){if(lt.x>elem.x)lt.x=elem.x;if(lt.y>elem.y)lt.y=elem.y;if(br.x<elem.x)lt.x=elem.x;if(br.y<elem.y)lt.y=elem.y;}
return this.LLBounds(lt,br);}
MapWorker.prototype.clearLayersSet=function(){var i;for(i in this.layers)
if(this.layers[i])
this.disableLayer(i);this.ZTile.clearLayersSet();this._selectedLayers=[];var _this=this;this.ZTile.hideAll(function(){_this.callZTile();});}
MapWorker.prototype.getSelectedLayers=function(){var ret=[];var l=0;var cnt=0;for(l in this._selectedLayers)
if(this._selectedLayers[l]){ret.push(l);cnt++;}
if(!cnt)return false;return ret;}
MapWorker.prototype.allowLayer=function(layerId,pids)
{if(!this.layers[layerId])
this.layers[layerId]=this.attachLayer(layerId,pids);if(!this.layers[layerId])return false;return true;}
MapWorker.prototype.enableLayer=function(layerId,pids)
{this.console("enabling "+layerId);this.allowLayer(layerId,pids);if(this.layers[layerId].enable(layerId))
{this._selectedLayers[layerId]=layerId;this.callZTile();return true;}
return false;}
MapWorker.prototype.disableLayer=function(layerId)
{this.console("disabling "+layerId);if(this.layers[layerId])
{this.layers[layerId].disable(layerId);this._selectedLayers[layerId]=null;if(!this.getSelectedLayers())
this._selectedLayers=[];this.callZTile();}}
MapWorker.prototype.isLayerActive=function(layerId){return this._selectedLayers[layerId]==layerId;}
MapWorker.prototype.attachLayer=function(layerId,misparent)
{var layer=0;var layers=this.layerDef.slice(0);while((layer=layers.shift()))
{if(layer.canHandle(layerId))
{result=layer.Assign(layerId,this,this.ZTile);return result;}}
var parents=misparent.split('_');var layerPId=0;while((layerPId=parents.shift()))
{var layers=this.layerDef.slice(0);while((layer=layers.shift()))
{if(layer.canHandle(layerPId))
{var result=layer.Assign(layerId,this,this.ZTile);return result;}}}
return false;}
MapWorker.prototype.getEntityView=function(entityId)
{var layers=this.layerDef.slice(0);var layer;while((layer=layers.shift()))
{if(layer.driveEntity(entityId))
{return layer.getView(entityId);}}
return false;}
MapWorker.prototype.describeLayer=function(layerdef)
{layerdef.setZInstance(this.ZTile);layerdef.setMap(this);this.layerDef.push(layerdef);}
MapWorker.prototype.canHandleReposition=function(){return(this.ZTile&&this.mapDivWorkable&&this.isMapReady);}
MapWorker.prototype.fromLatLngToContainerPixel=function(a){if(!this.canHandleReposition())return false;return this.worker.fromLatLngToContainerPixel(a);}
MapWorker.prototype.fromContainerPixelToLatLng=function(a){if(!this.canHandleReposition())return false;return this.worker.fromContainerPixelToLatLng(a);}
MapWorker.prototype.fromLatLngToDivPixel=function(a){if(!this.canHandleReposition())return false;return this.worker.fromLatLngToDivPixel(a);}
MapWorker.prototype.fromDivPixelToLatLng=function(a){if(!this.canHandleReposition())return false;return this.worker.fromDivPixelToLatLng(a);}
MapWorker.prototype.openMapTransaction=function(){if(this.callWorker())this.worker.openTransaction();}
MapWorker.prototype.closeMapTransaction=function(){if(this.callWorker())this.worker.closeTransaction();}
MapWorker.prototype.addOverlay=function(layerobject)
{layerobject.map=this;if(!layerobject.worker_storeId){var storeId=this.activeViewLayers.push(layerobject);layerobject.worker_storeId=storeId;}
var ret=this.worker.addOverlay(layerobject);if(layerobject.reStacked&&layerobject.reStacked())
layerobject.reStack();if(layerobject.mapAttach){layerobject.mapAttach(this);}
this.run_eventViewActivation(layerobject);return ret;}
MapWorker.prototype.addControl=function(layerobject)
{if(typeof(layerobject)=='object'&&(layerobject instanceof Array))
{var result=[];var el;while((el=layerobject.shift()))
result.push(this.addControl(el));return result;}
else
{layerobject.map=this;if(layerobject.mapAttach){layerobject.mapAttach(this);}
return this.worker.addControl(layerobject);}}
MapWorker.prototype.removeOverlay=function(layerobject)
{if(layerobject.worker_storeId>0){this.activeViewLayers[layerobject.worker_storeId-1]=null;}
layerobject.worker_storeId=-1
if(layerobject.mapDettach){layerobject.mapDettach(this);}
return this.worker.removeOverlay(layerobject);}
MapWorker.prototype.closeBalloon=function(){if(this.currentBalloon){this.currentBalloon.dejectSelf(this);this.currentBalloon.tearDown(1);delete this.currentBalloon;this.currentBalloon=0;}}
MapWorker.prototype.openBalloon=function(latlng,html,Balloonworker,holder){this.closeBalloon();this.currentBalloon=new Balloonworker();var frontier=0;if(holder)frontier=holder.getBalloonFrontier(html);else frontier=mapDefaultBalloonFrontier(html);this.currentBalloon.map=this;this.currentBalloon.setLatLng(latlng);this.currentBalloon.setContent(frontier(html,this.currentBalloon.modBallonClass(holder.getBallonClasses(),holder)));this.currentBalloon.holder=holder;this.currentBalloon.injectSelf(this);}
MapWorker.prototype.tryRestoreBalloon=function(caller,force){force=force||0;var _this=this;if(this.currentBalloon&&(force||(this.currentBalloon.holder&&this.currentBalloon.holder.maybeSame(caller)))){setTimeout(function(){_this.currentBalloon.injectSelf(_this);},100);}}
MapWorker.prototype.tryCloseBalloon=function(caller,force){force=force||0;if(this.currentBalloon&&(force||(this.currentBalloon.holder&&this.currentBalloon.holder.maybeSame(caller)))){this.currentBalloon.saveSelf();this.currentBalloon.dejectSelf(this);}}
MapWorker.prototype.tryResetBalloon=function(caller){if(this.currentBalloon&&(force||(this.currentBalloon.holder&&this.currentBalloon.holder.maybeSame(caller)))){this.closeBalloon();}}
MapWorker.prototype._onOuterBalloonMove=function(){if(this.currentBalloon&&this.isMapReady)
this.currentBalloon.positionChanged();}
MapWorker.prototype.zoomControl=function(enabled)
{if(this.worker){if(enabled)this.worker.enableZoomControl(enabled);else this.worker.disableZoomControl();}}
MapWorker.prototype.getObject=function(id)
{return this.ZTile.getObject(id);}
MapWorker.prototype.createMarker=function(options){return this.worker.createMarker(options);}
MapWorker.prototype.run_eventViewActivation=function(view){var i=0;for(i in this._eventViewActivation){if(this._eventViewActivation[i]){var ret=this._eventViewActivation[i](view);if(ret=='close'){this._eventViewActivation[i]=null;}}}}
MapWorker.prototype.domMouseControl=function(action,set){if(this.worker&&this.isActive&&this.isMapReady)
if(this.getWorkerName()=='yandex'){this.worker.domMouseControl(action,set);}}
MapWorker.prototype.eventViewActivation=function(callback){var i=0;var ret='';for(i in this.activeViewLayers)
if(this.activeViewLayers[i]&&this.activeViewLayers[i].object.shown){ret=callback(this.activeViewLayers[i]);if(ret=='close')return;}
for(i in this._eventViewActivation){if(this._eventViewActivation[i]==callback){return;}}
this._eventViewActivation.push(callback);}
var mapi={'extend':extend,'api':MapWorker};;window['gedi_map']=mapi;window.tile_isset=function(a){return a&&typeof(a)!='undefined';}
function TileTale(map)
{}
var ZM_FACTOR=1000000;TileTale.prototype.init=function(map)
{this.map=map;this.nav_objects=[];this.nav_block_index=[];this.nav_layers=[];this.objects_to_hide=[];this.objects_to_show=[];this.NavRequestsAjaxian=[];this.NavRequestImage=[];this.NavRequestsTimes=[];this.new_objects=[];this.render_objects=[];this.active_render=[];this.thisBounds={};this.layerEvents=[];this.NowRequestingCnt=0;this.realrender=[];this.LIMIT_OBJECTS=150;this.ZTILE_RENDER_LIMIT=35;this.RENDER_TIME_STEP=0;this.layerSet=[];this.layerEvents=new Array();this.widthDivCounter=11;this.objectUsageCounter=1;this.ts_queryRender=0;this.ts_queryRender2=0;this.requestTimeShift=300;this.allowBlockRequests=1;this.allowSortRender=1;this._collapceCounter=0;this.ZoomOffset=0;this._tiledebug=0;this.zBurstLimit=4;this.renderHide_tm=0;this.hideAll_Tm=0;this.inqueryRenderCnt=0;this.generationCounter=0;this._newObjectsCnt=0;this.renderPipeline=[];this.visiblePipeline=[];this.objectHashCounter=0;this.y_consar=new Array(-85051128,-83979259,-82676284,-81093213,-79171334,-76840816,-74019543,-70612614,-66513260,-61606396,-55776579,-48922499,-40979898,-31952162,-21943045,-11178401,0,11178401,21943045,31952162,40979898,48922499,55776579,61606396,66513260,70612614,74019543,76840816,79171334,81093213,82676284,83979259,85051128);this.absoluteObjectCounter=0;this.config_TimeredLoad=1;this.injectDirectObject=1;this.dirrectObjects=[];this.cluster=new zClusterIndex();}
TileTale.prototype.microtime=function(){var now=new Date().getTime()/1000;return now;}
TileTale.prototype.newGeneration=function(){this.generationCounter++;}
TileTale.prototype.currentGeneration=function(){return this.generationCounter;}
TileTale.prototype.clearLayersSet=function()
{this.layerSet=[];this.checkObjects();this.queryRender();}
TileTale.prototype.enableLayer=function(layer,ison)
{ison=typeof(ison)=='undefined'?1:ison;;this.layerSet[layer]=ison?layer:0;var outset=[];for(var i in this.layerSet){if(this.layerSet[i]==i){outset[i]=i;}}
this.layerSet=outset;this.newGeneration();this.checkObjects();this.queryRender();}
TileTale.prototype.disableLayer=function(layer,ison)
{this.enableLayer(layer,0);}
TileTale.prototype.checkObjects=function(){for(var i in this.nav_objects){if(this.nav_objects[i]&&this.nav_objects[i].LATITUDE)
this.checkObject(this.nav_objects[i]);}}
TileTale.prototype.injectObject=function(object,layer_id,weight){var idkey=(object['ID_MAP_OBJECT']);object.layers={};object.stacked=[];object.stackedBefore=0;object.stackCNT=0;object.reStack=0;object.generation=this.currentGeneration();if(!object.dim)object.dim={w:16,h:16};if(!object.relativeCounter)object.relativeCounter=0;if(!object.storedCapacity)
object.storedCapacity=parseFloat(object.CNT);object.LATITUDE=parseFloat(object.LATITUDE);object.LONGITUDE=parseFloat(object.LONGITUDE);if(!object.LATITUDE&&!object.LONGITUDE){return false;}
object.maxLayer=layer_id;object.layers[layer_id]=(layer_id);object.shown=0;object.map_object=0;object.randWeight=this.absoluteObjectCounter++;object.stackgroup=0;this.layerCall(object.layers,object,'preprocess');object._enabled=(this.getFilterCascade())(object);this.nav_objects[idkey]=object;this.new_objects[idkey]=(idkey);this._newObjectsCnt++;this.checkObject(this.nav_objects[idkey]);if(this.injectDirectObject)
this.dirrectObjects[idkey]=idkey;this.queryRender();return object;}
TileTale.prototype.applyFilter=function(){var i;var filter=this.getFilterCascade();for(i in this.nav_objects){this.nav_objects[i]._enabled=filter(this.nav_objects[i]);}
this.newGeneration();this.queryRender();}
TileTale.prototype.checkObject=function(obj){var ison=0;for(var j in this.layerSet){if(obj.layers[j]){ison=1;break;}}
var newstate=ison||obj.forceShow;if(obj.layerEnabled!=newstate)
obj.generation=this.currentGeneration();obj.layerEnabled=newstate;}
TileTale.prototype.getObjects=function()
{return this.nav_objects.split(0);}
TileTale.prototype.getObject=function(id)
{return this.nav_objects[id];}
TileTale.prototype.dirrectAccess=function()
{return this.nav_objects;}
TileTale.prototype.assignDataCenter=function()
{return"/maptiles/";}
TileTale.prototype.zoomTile=function(code)
{var x1=-180000000;var x2=180000000;var y1=-90000000;var y2=90000000;var l=code.length;for(i=0;i<l;i++)
{xdel=Math.round((x1+x2)/2);ydel=Math.round((y1+y2)/2);if(code[i]=='0'){p1=0;p2=0;}
if(code[i]=='1'){p1=0;p2=1;}
if(code[i]=='2'){p1=1;p2=1;}
if(code[i]=='3'){p1=1;p2=0;}
if(p1==0){x1=xdel+1}
else{x2=xdel}
if(p2==0){y1=ydel+1;}
else{y2=ydel;}}
var points=new Array();points[0]=this.map.getPositionInstance(y1/ZM_FACTOR,x1/ZM_FACTOR);points[1]=this.map.getPositionInstance(y2/ZM_FACTOR,x2/ZM_FACTOR);this.map.zoomToPointSet(points);}
TileTale.prototype.checkPoint=function(x,y,xline,yline,curzoomkv)
{var xdel=0;var ydel=0;var x1=-180000000;var x2=180000000;var y1=-90000000;var y2=90000000;var y1cons=0;var y2cons=32;var yconsdel=0;var n=0;var xlinetest=0;var ylinetest=0;var test=0;var z=curzoomkv-1;while(z>=0)
{xdel=Math.round((x1+x2)/2);ydel=Math.round((y1+y2)/2);test=Math.pow(2,z);xlinetest=xline&test;ylinetest=yline&test;if(xlinetest>0){x1=xdel+1}
else{x2=xdel}
if(ylinetest>0){y1=ydel+1;y1cons=yconsdel}
else{y2=ydel;y2cons=yconsdel}
z--;n++;}
if((x>=x1)&&(x<=x2)&&(y>=y1)&&(y<=y2))return 1;else return 0;}
TileTale.prototype.getZTile=function(x,y,zoom)
{var xdel=0;var ydel=0;var xline=0;var yline=0;var x1=-180000000;var x2=180000000;var y1=-90000000;var y2=90000000;var y1cons=0;var y2cons=32;var yconsdel=0;var n=0;var z=zoom-1;while(z>=0)
{xdel=Math.round((x1+x2)/2);ydel=Math.round((y1+y2)/2);if(x<=xdel){x2=xdel;xline=xline*2;}
else{x1=xdel+1;xline=xline*2+1;}
if(y<=ydel){y2=ydel;y2cons=yconsdel;yline=yline*2;}
else{y1=ydel+1;y1cons=yconsdel;yline=yline*2+1;}
z--;n++}
return{x:xline,y:yline}}
TileTale.prototype.retcode=function(xline,yline,curzoomkv)
{var xparam=0;var yparam=0;var test=0;var xlinetest=0;var ylinetest=0;var line='';var z=curzoomkv-1;var linepart=0;while(z>=0)
{test=Math.pow(2,z);xlinetest=xline&test;ylinetest=yline&test;if(xlinetest>0){xparam=2}
else{xparam=0}
if(ylinetest>0){yparam=1}
else{yparam=0}
if(xparam&&yparam)linepart='0';if(xparam&&!yparam)linepart='1';if(!xparam&&!yparam)linepart='2';if(!xparam&&yparam)linepart='3';line=line+linepart;z--;}
return line;}
TileTale.prototype.getTiles=function(x1point,y1point,x2point,y2point,zoompoint)
{var require_block=[];x1point=Math.ceil(x1point*ZM_FACTOR);y1point=Math.ceil(y1point*ZM_FACTOR);x2point=Math.ceil(x2point*ZM_FACTOR);y2point=Math.ceil(y2point*ZM_FACTOR);zoompoint=zoompoint-1;if(x1point<-180000000){x1point=-180000000}
if(x2point<-180000000){x2point=-180000000}
if(x1point>180000000){x1point=180000000}
if(x2point>180000000){x2point=180000000}
if(y1point<-85051128){y1point=-85051128}
if(y2point<-85051128){y2point=-85051128}
if(y1point>85051128){y1point=85051128}
if(y2point>85051128){y2point=85051128}
var outar=this.getZTile(x1point,y1point,zoompoint);var xline=outar.x;var yline=outar.y;var zmax=Math.pow(2,zoompoint)-1;var vres=0;var xsdvig=0;var xlinet=xline;var ylinet=yline;while(vres!=1)
{vres=this.checkPoint(x2point,y1point,xlinet,ylinet,zoompoint);xsdvig++;xlinet=xlinet+1;if(xlinet>zmax){xlinet=0}}
if(xlinet==zmax)
{xsdvig=1};vres=0;var ysdvig=0;xlinet=xline;ylinet=yline;while(vres!=1)
{vres=this.checkPoint(x1point,y2point,xlinet,ylinet,zoompoint);ysdvig++;ylinet=ylinet+1;if(ylinet>zmax){ylinet=0}}
if(ylinet==zmax)
{ysdvig=1};var temp='';var newtemp='';var ylinesave=yline;var ysdvigsave=ysdvig;while(xsdvig>0)
{while(ysdvig>0)
{temp=''+this.retcode(xline,yline,zoompoint);temp=temp.substring(0,16);var lineleng=0;var newtemp='';while(lineleng<temp.length)
{newtemp=newtemp+"/"+temp.substring(lineleng,lineleng+3);lineleng=lineleng+3;}
newtemp=newtemp.substr(1,newtemp.length-1);newtemp=newtemp;var xml_url=newtemp;require_block.push({addr:temp,z:xml_url,x:xline,y:yline,zoom:zoompoint});ysdvig--;yline++;if(yline>zmax){yline=0}}
yline=ylinesave;ysdvig=ysdvigsave;xsdvig--;xline++;if(xline>zmax){xline=0}}
return require_block;}
TileTale.prototype.getTilesVisibleSet=function(){var b=this.getBounds();var visibleset=this.getTiles(b.x1,b.y1,b.x2,b.y2,zoom);var outset=array();var layerSet=this.layerSet.slice(0);while((rq=visibleset.shift())){rq.layers=layerSet.slice(0);var gotarrn=rq.addr;if(this.nav_block_index[gotarrn])
for(i in layerSet)
if(this.nav_block_index[gotarrn][i])
{rq.layers[i]=0;outset.push(this.nav_block_index[gotarrn][i]);}
var a1=String(gotarrn);var stop1=0;var stop2=0;var l=a1.length;for(ii=1;ii<l;ii++)
{var ind=a1.slice(0,ii);var f=0;if(this.nav_block_index[ind])
{f=1;for(li in layerSet)
if(rq.layers[li])
{if(this.nav_block_index[ind][li])
if(this.nav_block_index[ind][li]['final'])
{rq.layers[li]=0;}}}}}}
TileTale.prototype.TileRelationsBroker=function(RB)
{var req=[];var rq;var layerSet=this.layerSet.slice(0);while((rq=RB.shift()))
{rq.layers=layerSet.slice(0);var i=0;var gotarrn=rq.addr;if(this.nav_block_index[gotarrn])
for(i in layerSet)
if(this.nav_block_index[gotarrn][i])
rq.layers[i]=0;var a1=String(gotarrn);var stop1=0;var stop2=0;var l=a1.length;for(var ii=1;ii<l;ii++)
{var ind=a1.slice(0,ii);var f=0;if(this.nav_block_index[ind])
{f=1;for(li in layerSet)
if(rq.layers[li])
{if(this.nav_block_index[ind][li])
if(this.nav_block_index[ind][li]['final'])
{rq.layers[li]=0;}}}}
var limore='';rq.inLayers=0;for(var i in rq.layers){if(rq.layers[i]==i){limore+=i+'-';rq.inLayers++;}}
if(limore){rq.layerLine=limore;rq.DS=this.assignDataCenter(rq);rq.addr_to=this.createLineRequest(rq);req[gotarrn]=(rq);}}
return req;}
TileTale.prototype.sliceBuyLayer=function(blocks){var ret=[];var i=0;var rq=0;var ind=0;var MAX_LAYERS_PER_REQUEST=2;for(ind in blocks)
if(blocks[ind])
{var irq=blocks[ind];if(irq.inLayers>MAX_LAYERS_PER_REQUEST){for(i=0;i<irq.inLayers;i+=MAX_LAYERS_PER_REQUEST){var tmp={addr:irq.addr,z:irq.z,x:irq.x,y:irq.y,zoom:irq.zoom};tmp.DS=irq.DS;var limore='';var inLayers=0;var sliced=0;var ini=0;for(ini in irq.layers)
{if(irq.layers[ini]==ini){if(inLayers>=i)
{limore+=ini+'-';sliced++;if(sliced>=MAX_LAYERS_PER_REQUEST)break;}
inLayers++;}}
tmp.layerLine=limore;tmp.addr_to=this.createLineRequest(tmp);ret.push(tmp);}}else ret.push(irq);}
return ret;}
TileTale.prototype.performRequire=function(require_block)
{var i=0;var gotarrn=0;var clientRequests=this.TileRelationsBroker(require_block);var cnt=0;for(i in clientRequests)if(clientRequests[i])cnt++;this.queryRender();if(cnt>0){clientRequests=this.clearNavRequestTimeouts(clientRequests);clientRequests=this.sliceBuyLayer(clientRequests);var cnt=0;for(i in clientRequests)if(clientRequests[i])cnt++;if(!this.allowBlockRequests){while((rq=clientRequests.shift()))
{this.callRequestTimer(rq,i);i++;}}
else
{this.blockRequest(clientRequests);}}
this.queryRender();}
TileTale.prototype.clearNavRequestTimeouts=function(active)
{var idx=0;this.NowRequestingCnt=0;var ii;for(ii in this.NavRequestsTimes)
{var i=this.NavRequestsTimes.ii;idx++;var del=0;if(!active[i.id])
{if(!(i.count--))
{clearTimeout(i.tm);idx--;del=1;}}else
{delete(active[i.id]);}}
if(idx==0)
this.NavRequestsTimes=[];idx=0;for(ii in this.NavRequestsAjaxian)
{var i=this.NavRequestsAjaxian[ii];var del=0;if(!active[i.id])
{if(!(i.rq.count--))
{del=1;i.rq.ajax.transport.abort();delete this.NavRequestsAjaxian[ii];}}else
{delete(active[i.id]);idx++;}}
if(idx==0)
this.NavRequestsAjaxian=[];return active;}
TileTale.prototype.callRequestTimer=function(rq,i)
{var d=0;if(i>0)d=50;else d=0;var topobj=this;this.NavRequestsTimes[rq.addr]={id:rq.addr,count:1,tm:(setTimeout(function(){delete topobj.NavRequestsTimes[rq.addr];topobj.request_map_block(rq);},50+topobj.requestTimeShift*i+d))};}
TileTale.prototype.createLineRequest=function(rq){return rq.layerLine+'l'+rq.z;}
window.tile__mergepos=function(a,b)
{var l1=a.length;var l2=b.length;var i=0;var l=l1>l2?l2:l1;for(i=0;i<l;i++){if(a[i]!=b[i])return i;}
return 0;}
var js_natsortType=1;var js_natsortLimit=256;function js_natsort(a,b){if(js_natsortType==1){var replaceArray=new Array('0','1','2','3','4','5','6','7','8','9','A','a','B','b','C','c','D','d','E','e','F','f','G','g','H','h','I','i','J','j','K','k','L','l','M','m','N','n','O','o','P','p','Q','q','R','r','S','s','T','t','U','u','V','v','W','w','X','x','Y','y','Z','z','_');}else if(js_natsortType==2){var replaceArray=new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_');}
a=a.toString();if(a.length>js_natsortLimit)a=a.substr(0,js_natsortLimit);a=a.replace(/\W/g,'_');var aArr=a.split('');for(var i=0;i<replaceArray.length;i++){for(var k=0;k<aArr.length;k++){if(aArr[k]==replaceArray[i]){if(i<10)aArr[k]=parseInt(i);else aArr[k]=i.toString();}}}
b=b.toString();if(b.length>js_natsortLimit)b=b.substr(0,js_natsortLimit);b=b.replace(/\W/g,'_');var bArr=b.split('');for(var i=0;i<replaceArray.length;i++){for(var k=0;k<bArr.length;k++){if(bArr[k]==replaceArray[i]){if(i<10)bArr[k]=parseInt(i);else bArr[k]=i.toString();}}}
aArr=js_natsort_combineInt(aArr);bArr=js_natsort_combineInt(bArr);for(var i=0;i<aArr.length;i++){if(aArr[i]!=bArr[i]){if(typeof aArr[i]==typeof bArr[i]){return(aArr[i]==bArr[i])?0:(aArr[i]>bArr[i])?1:-1;}else{if(typeof aArr[i]=='string'&&typeof bArr[i]=='number')return 1;if(typeof aArr[i]=='number'&&typeof bArr[i]=='string')return-1;}}}
return 0;}
function js_natsort_combineInt(array){for(var i=0;i<array.length;i++){if(typeof array[i]=='number'&&typeof array[i+1]=='number'){var num=array[i].toString()+array[i+1].toString();array[i]=parseInt(num);array=js_natsort_delArrayEl(array,i+1);js_natsort_combineInt(array);break;}}
while(array.length<js_natsortLimit)void array.push('00');return array;}
function js_natsort_delArrayEl(array,element){for(var i=element;i<array.length;i++){array[i]=array[i+1];}
array.pop();return array;}
function isInt(x){var y=parseInt(x);if(isNaN(y))return false;return x==y&&x.toString()==y.toString();}
TileTale.prototype.blockRequest=function(rq_line)
{var addr='';var cnt=0;var proxy='';var callobj=this;var setarray=[];for(var i in rq_line){var rq=rq_line[i];if(!proxy)proxy=rq.DS;var gotarrn=rq.addr;var addr_to=rq.addr_to;setarray.push(addr_to);cnt++;}
if(cnt==0)return;var sortgeneration=0;var ts1=this.microtime();setarray.sort();{var insort=function(){addr='';var preaddr='';var aline;var acnt=0;var thisrqline=[];while((aline=setarray.shift()))
{if(!preaddr)preaddr=aline;else{var p=tile__mergepos(preaddr,aline)
preaddr=aline;aline=aline.substr(p,aline.length-p);if(p>0)aline=p+"~"+aline;}
addr+=aline+";";for(var i in rq_line){if(rq_line[i].addr_to==aline){thisrqline.push(rq_line[i]);delete rq_line[i];break;}}
acnt++;if(acnt>=callobj.zBurstLimit)
break;}
if(!addr||!acnt)
return false;sortgeneration++;var startTime=callobj.microtime();var ajaxreq={count:acnt,ajax:callobj.AjaxRequest(proxy+addr,{method:'get',encoding:"UTF-8",asynchronous:true,onFail:function(a,b,s){callobj.stopRequesting(thisrqline)},onComplete:function(data){callobj.stopRequesting(thisrqline);callobj.loadNavBlock(data,thisrqline,startTime);}},sortgeneration)};callobj.startRequesting(thisrqline);for(i in thisrqline){var rq=thisrqline[i];callobj.NavRequestsAjaxian[rq.addr_to]={id:rq.addr,rq:ajaxreq};}
return true;}
var acnt=0;while(insort())
{acnt++;}}}
TileTale.prototype.request_map_block=function(rq)
{var gotarrn=rq.addr;var addr_to=rq.addr_to;if(!this.NavRequestsAjaxian[addr_to])
{var inrq={0:rq};this.startRequesting(inrq);var callobj=this;var startTime=callobj.microtime();var rqobj={id:gotarrn,rq:{count:1,timein:this.microtime(),ajax:this.AjaxRequest(proxy+addr_to,{method:'get',encoding:"UTF-8",asynchronous:true,onFail:function(a,b,s){callobj.stopRequesting(inrq)},onComplete:function(data){callobj.stopRequesting(inrq);callobj.loadNavBlock(data,rq,startTime);}})}};this.NavRequestsAjaxian[addr_to]=rqobj;}
else
{if(window.console)
console.log(addr_to+" is allready proccessing");}}
TileTale.prototype.startRequesting=function(rqs)
{for(var i in rqs){var rq=rqs[i];this.NowRequesting(1);var addr_to=rq.addr_to;this.NavRequestsAjaxian[addr_to]=0;delete this.NavRequestsAjaxian[addr_to];}}
TileTale.prototype.stopRequesting=function(rqs)
{for(var i in rqs){var rq=rqs[i];this.NowRequesting(-1);var addr_to=rq.addr_to;this.NavRequestsAjaxian[addr_to]=0;delete this.NavRequestsAjaxian[addr_to];}}
TileTale.prototype.NowRequesting=function(a)
{this.NowRequestingCnt+=a;this.onRequestingChange(this.NowRequestingCnt);}
TileTale.prototype.AjaxRequest=function(addr,params)
{alert("implement your own!")}
TileTale.prototype.decodeNavBlock=function(data,uri,gotarrn)
{return data;}
TileTale.prototype.insertObject=function(object,layer,gotarrn)
{if(!gotarrn)
gotarrn='';block=gotarrn;}
TileTale.prototype.preprocessData=function(dataline,request)
{if(!dataline.mapreq)return{mapreq:{0:dataline}};else return dataline;}
TileTale.prototype.loadNavBlock=function(data,request,startTime){var _this=this;setTimeout(function(){_this.injectDirectObject=0;_this._in_loadNavBlock(data,request,startTime)
_this.injectDirectObject=1;},1);}
TileTale.prototype._in_loadNavBlock=function(data,request,AstartTime)
{var tilethis=this;var ticktack=0;var objcount=0;var loadingStart=this.microtime();data=this.preprocessData(data,request);var closure=function(){var undone=0;var i;ticktack++;for(i in data.mapreq)
if(data.mapreq[i]){try{objcount+=tilethis.loadDataLine(tilethis.decodeNavBlock(data.mapreq[i],request));}catch(e)
{if(window.console)
console.log(e);}
delete data.mapreq[i];undone=1;break;}
if(undone){closure();}
else{tilethis.queryRender();if(window.console){console.log("tile loadparsed (",ticktack," ticks) in",(tilethis.microtime()-loadingStart)," load in",(tilethis.microtime()-AstartTime));console.log("now ",tilethis._newObjectsCnt," objects -",objcount);}}}
if(this.config_TimeredLoad){closure();}
else{for(i in data.mapreq){objcount+=this.loadDataLine(this.decodeNavBlock(data.mapreq[i],request));}
tilethis.queryRender();if(window.console){console.log("tile loadparsed (",ticktack," ticks) in",(tilethis.microtime()-loadingStart)," load in",(tilethis.microtime()-AstartTime));console.log("now ",tilethis._newObjectsCnt," objects -",objcount);}}}
function getRandomArbitary(min,max)
{return Math.random()*(max-min)+min;}
TileTale.prototype.loadDataLine=function(data,request)
{var i;var bounds=this.getBounds();this.newGeneration();var cntin=0;for(i in data)
{var layer=data[i];var layer_id=parseInt(layer.layer);var l1cnt=0;var l2cnt=0;var ltcnt=0;{var block=layer.tile;var bzoom=block.length;var inblock=layer.intile;if(this._tiledebug)
{var polygon=new YMaps.Polyline([new YMaps.GeoPoint(layer.area.x1/ZM_FACTOR,layer.area.y1/ZM_FACTOR),new YMaps.GeoPoint(layer.area.x1/ZM_FACTOR,layer.area.y2/ZM_FACTOR),new YMaps.GeoPoint(layer.area.x2/ZM_FACTOR,layer.area.y2/ZM_FACTOR),new YMaps.GeoPoint(layer.area.x2/ZM_FACTOR,layer.area.y1/ZM_FACTOR)],{style:"polygon#Example",hasHint:1,hasBalloon:1});polygon.name=block;polygon.description=block;this.map.worker.api.addOverlay(polygon);}
if(!this.nav_block_index[block]){this.nav_block_index[block]={};this.nav_block_index[block]['area']={x1:layer.area.x1/ZM_FACTOR,x2:layer.area.x2/ZM_FACTOR,y1:layer.area.y1/ZM_FACTOR,y2:layer.area.y2/ZM_FACTOR};this.nav_block_index[block]['zoom']=block.length;}
if(!this.nav_block_index[block][layer_id]){this.nav_block_index[block][layer_id]=[];this.nav_block_index[block][layer_id].objects=[];}
layer.isFinal=parseInt(layer['final']);this.nav_block_index[block][layer_id]['final']=layer.isFinal;var objects=layer.objects;var layerlen=block.length;for(var x in objects){var object=objects[x];if(this._collapceCounter)
object.CNT=1;var idkey=(object['ID_MAP_OBJECT']);ltcnt=Math.max(ltcnt,object['CNT']);object.CNT=parseFloat(object.CNT);if(!this.nav_objects[idkey]){cntin++;var obj=this.injectObject(object,layer_id,x+layerlen*layer.objcnt);if(!obj){continue;}
obj.maxKnownZoom=bzoom;l1cnt++;}else{l2cnt++;var obj=this.nav_objects[idkey];var newcnt=Math.min(this.nav_objects[idkey].storedCapacity,object.CNT);if(newcnt!=this.nav_objects[idkey].storedCapacity){this.nav_objects[idkey].generation=this.currentGeneration();}
this.nav_objects[idkey].storedCapacity=newcnt;this.nav_objects[idkey].reStack=1;obj.maxKnownZoom=Math.min(obj.maxKnownZoom,bzoom);object=this.nav_objects[idkey];if(!object.layers[layer_id])
this.nav_objects[idkey].layers[layer_id]=(layer_id);}
this.nav_objects[idkey].lasttile=block;if(this.nav_block_index[block]&&this.nav_block_index[block][layer_id]&&this.nav_block_index[block][layer_id].objects)
this.nav_block_index[block][layer_id].objects[idkey]=idkey;}
if(block!=inblock)
{var l1=inblock.length;var ii=0;var layerinto=[];layerinto['final']=1;layerinto['dummy']=1;for(i=block.length+1;i<=l1;i++)
{var nameblock=inblock.slice(0,i);if(!(this.nav_block_index[nameblock]&&this.nav_block_index[nameblock][layer_id])){if(!this.nav_block_index[nameblock])
this.nav_block_index[nameblock]={zoom:nameblock.length,area:this.nav_block_index[block]['area']};if(!this.nav_block_index[nameblock][layer_id]){this.nav_block_index[nameblock][layer_id]=layerinto;}}}}}}
return cntin;}
TileTale.prototype.objectInLayer=function(obj,l)
{for(i in obj.layers)
{if(i==l)return true;}
return false;}
TileTale.prototype.queryRender=function()
{var tile=this;clearTimeout(this.ts_queryRender2);clearTimeout(this.ts_queryRender);this.ts_queryRender=setTimeout(function(){tile.in_queryRender(1)},100);}
TileTale.prototype.hideAll=function(a){var tileobjects=this.nav_objects;var deleteset=[];for(i in this.nav_objects){if(tileobjects[i]&&tileobjects[i].shown){this.hideObject(i);}}
this.newGeneration();}
TileTale.prototype.DimensionError=function(){if(window.console)
console.log("dimension error");this.hideAll();return false;}
TileTale.prototype.in_queryRender=function(force)
{clearTimeout(this.refreshTimer);clearTimeout(this.ts_queryRender);clearTimeout(this.ts_queryRender2);var starttime=this.microtime();var bounds=this.getBounds();var tileobjects=this.nav_objects;var blockindex=this.nav_block_index;var _this=this;var tilethis=this;var cnt=0;var vcnt=0;var delta=tilethis.getStackableDelta();if(!delta)return this.DimensionError();var v2cnt=0;var ingen=this.currentGeneration();this.lastRenderZoom=bounds.zoom;var workingset=this.cluster.setup(bounds.x1,bounds.y1,bounds.x2,bounds.y2,bounds.zoom,ingen);var realbounds=this.cluster.getBounds();var pushobjset=[];var pushObject=function(iobject,fullpass){if(pushobjset[iobject])return;pushobjset[iobject]=1;var obj=tileobjects[iobject];if(fullpass){_this.cluster.push(obj);cnt++;}
else{var dimw=0;var dimh=0;if(((obj.LATITUDE+dimh)>realbounds.y1&&(obj.LATITUDE-dimh)<realbounds.y2&&(obj.LONGITUDE+dimw)>realbounds.x1&&(obj.LONGITUDE-dimw)<realbounds.x2)){_this.cluster.push(obj);cnt++;}}
if(obj.shown)
v2cnt++;}
var allowzoomdelta=1;if(bounds.zoom<9)allowzoomdelta=2;if(bounds.zoom<6)allowzoomdelta=4;var QRprepare=function(){for(i in tilethis.dirrectObjects){pushObject(i,false);}
var block;var lset=tilethis.layerSet.slice(0);for(block in blockindex){var thisblock=blockindex[block];var area=thisblock['area'];var zoom=thisblock['zoom'];if(zoom<=(bounds.zoom+allowzoomdelta)){var hit=area.x1<realbounds.x2&&area.x2>realbounds.x1&&area.y1<realbounds.y2&&area.y2>realbounds.y1;if(hit){var fullhit=area.x1>=realbounds.x1&&area.x2<=realbounds.x2&&area.y1>=realbounds.y1&&area.y2<=realbounds.y2;var l=0;for(l in lset)if(thisblock[l]){var linner=thisblock[l].objects;var i;for(i in linner){if(linner[i]&&tileobjects[linner[i]]&&tileobjects[linner[i]]._enabled){pushObject(linner[i],fullhit);}}}}}}}
if(workingset.update.length){this.cluster.start(workingset);QRprepare();this.cluster.end();}
this.cluster.setVisibleSet();var torender=this.cluster.getRender(tilethis.LIMIT_OBJECTS);var rcnt=this.cluster.renderCount;var updateset=this.cluster.getUpdateset(tilethis.LIMIT_OBJECTS);var todelete=[];var deleted=0;var QRhintdeleted=function(){for(i in tilethis.visiblePipeline)
{if(i&&tilethis.visiblePipeline[i])
if(!torender[i]||typeof(torender[i])=='undefined'){tilethis.hideObject(i);deleted++;}}}
QRhintdeleted();var newcnt=0;var rencnt=0;var QRhintrender=function(){for(ii in updateset)
{var f=0;i=updateset[ii];{tilethis.showObject(i);vcnt++;}}}
QRhintrender();this.render_objects=torender;if(window.console&&console)
{var endtime=this.microtime();var rrcnt=tilethis.realrender.length;console.log("currently("+ingen+") visible:"+cnt+"-"+
this.cluster.renderCount+"/"+this.cluster.renderShown+"/"+this.cluster.renderUpdate+"("+vcnt+"), deleted:"+deleted+" | in "+(endtime-starttime));}
this.ts_queryRender=0;this.queryRefresh();if(vcnt){}else this.cluster.finishTurn();return true;}
TileTale.prototype.addFilter=function(filter){_this.filterCascade.push(filter);return filter;}
TileTale.prototype.getFilterCascade=function(){var _this=this;return function(object){var i;for(i in _this.filterCascade){var filter=_this.filterCascade[i];if(filter.enabled){if(!filter.filter(object)){return false;}}}
return true;}}
TileTale.prototype.stackedTween=function(_inset)
{var cnt=0;var tilethis=this;var i;for(i in this.nav_objects){var iobj=this.nav_objects[i];for(j in this.new_objects)
if(j>i){var jobj=this.nav_objects[i];if(iobj.LATITUDE==jobj.LATITUDE&&iobj.LONGITUDE==jobj.LONGITUDE)
this.setstackedTween(iobj,jobj);}}
return resultset;}
TileTale.prototype.setstackedTween=function(iobj,jobj){}
TileTale.prototype.queryRefresh=function()
{if(this.refreshTimer)
clearTimeout(this.refreshTimer);var tile=this;this.refreshTimer=setTimeout(function(){tile.tickRender()},this.RENDER_TIME_STEP);}
TileTale.prototype.tickRender=function()
{clearTimeout(this.refreshTimer);this.refreshTimer=0;var cnt=0;var ticktest=0;var rr=this.renderPipeline;var limit=this.ZTILE_RENDER_LIMIT;var tilethis=this;var i;var haveobjects=0;for(i in rr){haveobjects=1;break;}
var tickRenderFlow=function(){for(i in rr){var cmd=rr[i];ticktest++;cmd();cnt++;delete rr[i];if(cnt>limit)
break;}}
if(haveobjects){this.map.openMapTransaction();tickRenderFlow();this.map.closeMapTransaction();}
if(cnt){this.chargeAfterRender=1;tilethis.queryRefresh();}
else{this.renderPipeline=[];if(this.chargeAfterRender)
this.queryRender();this.chargeAfterRender=0;}
return cnt;}
TileTale.prototype.pushRender=function(obj,action){this.renderPipeline[obj.ID_MAP_OBJECT]=action;this.queryRefresh();}
TileTale.prototype.hideObject=function(ind)
{var bounds=this.getBounds();var object=this.nav_objects[ind];if(object)
{var _this=this;this.pushRender(object,function(){_this.visiblePipeline[ind]=0;object.shown=0;_this.layerCall(object.layers,object,'hide');});}}
TileTale.prototype.resetObjects=function()
{this.chargeAfterRender=0;while(this.tickRender()){this.chargeAfterRender=0;}
this.map.openMapTransaction();for(var ind in this.nav_objects){if(ind&&this.nav_objects[ind]){var object=this.nav_objects[ind];var _this=this;_this.visiblePipeline[ind]=0;_this.layerCall(object.layers,object,'reset');this.nav_objects[ind]=object;}}
this.map.closeMapTransaction();this.restackObjects();this.newGeneration();}
TileTale.prototype.showObject=function(ind)
{var object=this.nav_objects[ind];var _this=this;_this.visiblePipeline[ind]=1;this.pushRender(object,function(){object.shown=1;_this.layerCall(object.layers,object,'show');});}
TileTale.prototype.restackObjects=function()
{for(ind in this.nav_objects)
if(ind&&this.nav_objects[ind])
{var object=this.nav_objects[ind];object.stackCNT=0;object.stackedBefore=0;object.stacked=[];this.nav_objects[ind]=object;}}
TileTale.prototype.layerCall=function(layerlist,object,func)
{try{for(var l in layerlist){if(this.layerEvents[l]){for(var i in this.layerEvents[l]){var f=this.layerEvents[l][i]['functions'][func];if(f)
object=f(this.layerEvents[l][i]['meta'],object,l,this.map,this);}}}}catch(e)
{if(window.console)
console.log("Zshow error:",e);}
return object;}
TileTale.prototype.assignLayer=function(layer,meta,functionlist)
{if(!layer)return;if(!this.layerEvents[layer])
this.layerEvents[layer]=[];this.layerEvents[layer].push({'meta':meta,'functions':functionlist});}
TileTale.prototype.setObject=function(object)
{this.nav_objects[object.idkey]=object;}
TileTale.prototype.getMinViewDimensions=function()
{return this.map.getMinViewDimensions();}
TileTale.prototype.getStackableDelta=function()
{var bounds=this.thisBounds;var dw=1;var dim=this.getMinViewDimensions();if(dim<100)return false;var dx=Math.abs(bounds.x2-bounds.x1);var dy=Math.abs(bounds.y2-bounds.y1);if(dx>dy)dw=dy;else dw=dx;return(dw/dim);return dw/this.widthDivCounter;}
TileTale.prototype.moveend=function()
{var zoom=this.map.getZoom();var b=this.map.getBounds();if(!b)return false;this.thisBounds={x1:b.x1,x2:b.x2,y1:b.y1,y2:b.y2,zoom:zoom};var w=(b.x2-b.x1)*0.2;var h=(b.y2-b.y1)*0.2;this.performRequire(this.getTiles(b.x1-w,b.y1-h,b.x2+w,b.y2+h,zoom));return true;}
TileTale.prototype.onRequestingChange=function(current_cnt)
{}
TileTale.prototype.getBounds=function()
{return this.thisBounds;}
window.TileTale_jQuery=function(map)
{}
TileTale_jQuery.prototype=new TileTale();function SlicedAjax(params,generation){this.params=params;this.generation=generation-1;this.ajax=0;this.start();}
SlicedAjax.prototype.start=function(){var _this=this;this.timeout=setTimeout(function(){_this.ajax=$.ajax(_this.params);_this.timeout=0;},Math.ceil(this.generation/2)*300);}
SlicedAjax.prototype.abort=function(){if(this.timeout)clearTimeout(this.timeout);if(this.ajax){this.ajax.abort();delete this.ajax;this.ajax=0;}}
TileTale_jQuery.prototype.AjaxRequest=function(addr,params,generation)
{var jparams={cache:false,url:addr,global:false,error:params.onFail,success:params.onComplete,dataType:'json',contentType:"application/json"}
var res=new SlicedAjax(jparams,generation);return{transport:{abort:function(){res.abort()}}};}
if(0)
{ZTile=new TileTale_jQuery(map);ZTile.init(map);ZTile.assignLayer(7,ZTile,function(meta,object,i){object.shown=1;return object;},function(meta,object,i){object.shown=0;return object;},function(meta,object,i){return object;})
function tileend(){ZTile.moveend()};this.map.addEvent(this.map,"moveend",tileend);}
var ZCLUSTER_SIZE=1024;var ZCLUSTER_DELTA_Z=-2;var zClusterIndex=function(){this.bounds={x1:0,y1:0,x2:0,y2:0};this.zoom=0;this.cells=0;this.cellx=0;this.celly=0;this.reset();}
zClusterIndex.prototype.setup=function(_x1,_y1,_x2,_y2,z,gen){z+=ZCLUSTER_DELTA_Z;if(z!=this.zoom){this.reset();}
this.upgen=gen;this.zoom=z;this.setBounds={x1:_x1,x2:_x2,y1:_y1,y2:_y2,zoom:z};return{update:this.setupBounds(_x1,_y1,_x2,_y2),logen:this.logen}}
zClusterIndex.prototype.reset=function(){this.index=[];this.upgen=0;this.logen=0;}
zClusterIndex.prototype.setupBounds=function(x1,y1,x2,y2){this.cells=Math.pow(2,this.zoom);this.cellPixelSize=Math.round(Math.pow(256,this.zoom)/this.cells);this.cellx=(360/this.cells)*ZM_FACTOR;this.celly=(180/this.cells)*ZM_FACTOR;this.cellset={x1:Math.floor((x1*ZM_FACTOR)/this.cellx),y1:Math.floor((y1*ZM_FACTOR)/this.celly),x2:Math.ceil((x2*ZM_FACTOR)/this.cellx),y2:Math.ceil((y2*ZM_FACTOR)/this.celly)};var x1point=(this.cellx*this.cellset.x1)/ZM_FACTOR;var y1point=(this.celly*this.cellset.y1)/ZM_FACTOR;var x2point=(this.cellx*this.cellset.x2)/ZM_FACTOR;var y2point=(this.celly*this.cellset.y2)/ZM_FACTOR;this.bounds={x1:x1point,y1:y1point,x2:x2point,y2:y2point};return this.rebuildIndex();}
zClusterIndex.prototype.getCluster=function(x,y){var cx=Math.floor((x*ZM_FACTOR)/this.cellx);var cy=Math.floor((y*ZM_FACTOR)/this.celly);return this.index[cx+cy*this.cells];}
zClusterIndex.prototype.rebuildIndex=function(){var x=0;var y=0;var newcnt=[];var cnt=0;for(x=this.cellset.x1;x<this.cellset.x2;x++)
for(y=this.cellset.y1;y<this.cellset.y2;y++){if(!this.index[x+y*this.cells]){this.index[x+y*this.cells]=new zCluster(this.getCellSize(x,y),this.zoom);newcnt.push(this.index[x+y*this.cells]);}
else if(this.index[x+y*this.cells].generation<this.upgen||this.index[x+y*this.cells].haveRestack()){newcnt.push(this.index[x+y*this.cells]);}}
return newcnt;}
zClusterIndex.prototype.getVisibleSet=function(){var x=0;var y=0;var newcnt=[];for(x=this.cellset.x1;x<this.cellset.x2;x++)
for(y=this.cellset.y1;y<this.cellset.y2;y++){if(this.index[x+y*this.cells])
newcnt.push(this.index[x+y*this.cells]);}
return newcnt;}
zClusterIndex.prototype.setVisibleSet=function(){this.renderSet=this.getVisibleSet();}
zClusterIndex.prototype.getCellSize=function(x,y){return{x1:this.cellx*x,y1:this.celly*y,x2:this.cellx*(x+1),y2:this.celly*(y+1)};}
zClusterIndex.prototype.getBounds=function(){return this.bounds;}
zClusterIndex.prototype.start=function(set){this.activeSet=set.update;this._nowgen=0;this.changeCnt=0;for(var i in this.activeSet){var cluster=this.activeSet[i];cluster.prepare();}}
zClusterIndex.prototype.end=function(genfor){genfor=this.upgen;this.logen=Math.max(this.logen,this._nowgen);if(!genfor)genfor=this.logen;var i;for(i in this.activeSet){var cluster=this.activeSet[i];cluster.generation=genfor;cluster.logen=this.logen;{cluster.end();}}}
zClusterIndex.prototype.distto=function(obj){var x=obj.LONGITUDE-this.centerPoint.x;var y=(obj.LATITUDE-this.centerPoint.y)/8;return x*x+y*y;}
zClusterIndex.prototype.getRender=function(maxcnt){var result=[];var uncluster=[];var i;var ii;var setBounds=this.setBounds;this.centerPoint={x:setBounds.x1+(setBounds.x2-setBounds.x1)/2,y:setBounds.y1+(setBounds.y2-setBounds.y1)/2};this.renderCount=0;this.renderShown=0;var knownset=0;var outset=[];for(i in this.renderSet){var cluster=this.renderSet[i];var set=cluster.workingset;var index=cluster.index;var inchain=cluster.inVisibleSet(setBounds);var middleset=[];for(ii in set){var obj=index[ii];if(inchain||(obj.LONGITUDE>setBounds.x1&&obj.LONGITUDE<setBounds.x2&&obj.LATITUDE>setBounds.y1&&obj.LATITUDE<setBounds.y2)){obj.clusterDistTo=this.distto(obj);if(obj.shown)this.renderShown++;middleset.push(ii);uncluster[ii]=ii;knownset++;}}
outset.push({oset:middleset,oindex:index});}
if(knownset>maxcnt){uncluster=[];knownset=0;this.renderShown=0;while(1){var incnt=0;for(i in outset){var obj=outset[i].oset.shift();if(obj){var obji=outset[i].oindex[obj];if(obji.shown)this.renderShown++;uncluster[obj]=obj;knownset++;incnt++;}}
if(!incnt||knownset>maxcnt)break;}}
this.renderCount=knownset;this.renderCluster=uncluster;return uncluster;var _this=this;if(knownset>maxcnt){result=result.sort(function(a,b){return a.clusterDistTo-b.clusterDistTo;});}
else return unclaster;this.renderCount=0;this.renderShown=0;var outset=[];while((obj=result.shift())){this.renderCount++;if(obj.shown)this.renderShown++;if(this.renderCount>maxcnt)break;var ii=obj.ID_MAP_OBJECT;outset[ii]=ii;}
return outset;}
zClusterIndex.prototype.getUpdateset=function(maxcnt){var result=[];var i;var ii;var stop=0;var setBounds=this.setBounds;this.renderUpdate=0;var uncluster=[];var knownset=0;var outset=[];var updaterset=[];for(i in this.renderSet){var cluster=this.renderSet[i];cluster.updateVisible();var set=cluster.updateoutset;var index=cluster.index;var inchain=cluster.inVisibleSet(setBounds);var middleset=[];for(ii in set){var obj=index[ii];if(inchain||(obj.LONGITUDE>setBounds.x1&&obj.LONGITUDE<setBounds.x2&&obj.LATITUDE>setBounds.y1&&obj.LATITUDE<setBounds.y2)){if(!obj.shown)knownset++;uncluster[ii]=ii;middleset.push(ii);if(this.renderCluster[ii]){updaterset[ii]=ii;this.renderUpdate++;}}}
outset.push({oset:middleset,oindex:index});}
return updaterset;if((knownset+this.renderShown)>=maxcnt){uncluster=[];knownset=0;this.renderUpdate=0;while(1){var incnt=0;for(i in outset){var obj=outset[i].oset.shift();if(obj){var obji=outset[i].oindex[obj];if(!obji.shown)this.renderUpdate++;if(obji.shown||(this.renderUpdate+this.renderShown)<=maxcnt){uncluster[obj]=obj;knownset++;incnt++;}}}
if((this.renderUpdate+this.renderShown)>=maxcnt)break;if(!incnt)break;}}
this.renderUpdate=knownset;return uncluster;var _this=this;if((knownset+this.renderShown)>maxcnt){result=result.sort(function(a,b){return a.clusterDistTo-b.clusterDistTo;});}else return uncluster;var outset=[];this.renderUpdate=0;while((obj=result.shift())){if(!obj.shown)this.renderUpdate++;if((this.renderUpdate+this.renderShown)>maxcnt)break;var ii=obj.ID_MAP_OBJECT;outset[ii]=ii;}
return outset;}
zClusterIndex.prototype.finishTurn=function(){var i;for(i in this.index)
if(i&&this.index[i]){this.index[i].seal();}}
zClusterIndex.prototype.push=function(object){this._nowgen=Math.max(object.generation,this._nowgen);var cluster=this.getCluster(object.LONGITUDE,object.LATITUDE);if(cluster){if(cluster.push(object))
this.changeCnt++;}
else{}}
var zCluster=function(cellsize,in_zoom){this.cell=cellsize;this.latbox={x1:cellsize.x1/ZM_FACTOR,y1:cellsize.y1/ZM_FACTOR,x2:cellsize.x2/ZM_FACTOR,y2:cellsize.y2/ZM_FACTOR,zoom:in_zoom};this.gen=0;this.generation=0;this.workingset=[];this.clear();}
zCluster.prototype.inVisibleSet=function(set){return this.latbox.x1>=set.x1&&this.latbox.x2<=set.x2&&this.latbox.y1>=set.y1&&this.latbox.y2<=set.y2;}
zCluster.prototype.hit=function(x,y){return this.latbox.x1<x&&this.latbox.y1<y&&this.latbox.x2>x&&this.latbox.y2>y;}
zCluster.prototype.prepare=function(){this.changeCnt=0;this.updateset=[];this.workingset=[];this.index=[];}
zCluster.prototype.push=function(object){if(1){this.index[object.ID_MAP_OBJECT]=(object);this.changeCnt++;return 1;}
return 0;}
zCluster.prototype.getStackableDelta=function(){return(this.latbox.x2-this.latbox.x1)/ZCLUSTER_SIZE;}
zCluster.prototype.haveRestack=function(){var i;for(i in this.index)
if(this.index.reStack)return 1;return false;}
zCluster.prototype.glueData=function(){var inset=this.index;var tileobjnav=this.index;var temp=[];var outset=[];var resultset=[];this.updateset=[];var delta=this.getStackableDelta();var bounds=this.latbox;var deltafactor=0.5;if(this.latbox.zoom>=15)deltafactor=0.3;if(this.latbox.zoom>=17)deltafactor=0.2;var sizeshiftfactor=0.4;deltafactor*=sizeshiftfactor*2;deltafactor*=delta;var bw=bounds.y2-bounds.y1;var bh=bounds.x2-bounds.x1;var boundsdelta=16;var deltashiftX=bounds.y1;var deltashiftY=bounds.x1;var _this=this;var prepare=function(){var i;for(i in inset){if(i&&inset[i]){var object=inset[i];temp.push({id:object.ID_MAP_OBJECT,randWeight:object.randWeight});}}};var dosort=function(){temp.sort(function(a,b){return a.randWeight-b.randWeight;})}
var formout=function(){var grid=[];var usecnt=0;var line;while((line=temp.shift()))
{var i=line.id;var obj=inset[i];var ison=1;var ox1,oy1,ox2,oy2=0;ox1=Math.floor(boundsdelta*(obj.LATITUDE-deltashiftX-obj.dim.w*deltafactor)/bw);oy1=Math.floor(boundsdelta*(obj.LONGITUDE-deltashiftY-obj.dim.h*deltafactor)/bh);ox2=Math.ceil(boundsdelta*(obj.LATITUDE-deltashiftX+obj.dim.w*deltafactor)/bw);oy2=Math.ceil(boundsdelta*(obj.LONGITUDE-deltashiftY+obj.dim.h*deltafactor)/bh);var thispass=[];for(var ix=ox1;ix<ox2;ix++)
for(var iy=oy1;iy<oy2;iy++)
{if(grid[ix]&&grid[ix][iy]){for(var iii in grid[ix][iy]){var ii=grid[ix][iy][iii];if(thispass[ii])continue;else thispass[ii]=1;usecnt++;var obj2=tileobjnav[ii];if(obj2){var dx=Math.abs(obj2.LATITUDE-obj.LATITUDE);var dy=Math.abs(obj2.LONGITUDE-obj.LONGITUDE);var xdelta=delta*(obj.dim.w+obj2.dim.w)*sizeshiftfactor;var ydelta=delta*(obj.dim.h+obj2.dim.h)*sizeshiftfactor;if(dx==0&&dy==0){}
if(dx<xdelta&&dy<ydelta){obj2.stacked.push(i);obj.stackCNT=0;obj.stackedBefore=obj.stackCNT;obj.stacked=[];ison=0;break;}}}}}
if(!ison)
continue;obj.stackedBefore=obj.stackCNT;obj.stacked=[];outset.push(i);resultset[i]=i;for(var ix=ox1;ix<=ox2;ix++)
for(var iy=oy1;iy<=oy2;iy++){if(!grid[ix])grid[ix]=[];if(!grid[ix][iy])grid[ix][iy]=[];grid[ix][iy].push(i);}}};prepare();dosort();formout();this.workingset=resultset;this.postprocess();}
zCluster.prototype.postprocess=function(){this.updateset=[];var i;var newcnt=0;var rencnt=0;for(i in this.workingset){var obj=this.index[i];if(obj&&obj.LATITUDE)
{var stackCNT=obj.storedCapacity;var f=0;var si;var tileobjnav=this.index;var rein=0;var intcount=1;for(si in obj.stacked){var inobj=tileobjnav[obj.stacked[si]];if(inobj){stackCNT+=inobj.storedCapacity;rein+=inobj.reStack;inobj.reStack=0;intcount++;}}
obj.relativeCounter=(intcount==stackCNT);obj.stackCNT=Math.round(stackCNT);if(obj.stackedBefore!=obj.stackCNT||obj.reStack||rein){if(obj.stackedBefore!=obj.stackCNT||rein)
obj.reStack++
newcnt++;f=1;}
if(!obj.shown){rencnt++;f=1;}
if(f)
this.updateset.push(obj.ID_MAP_OBJECT);}}}
zCluster.prototype.updateVisible=function(){var ret=[];var i;for(i in this.workingset){var obj=this.index[i];if(!obj.shown||obj.reStack)
ret[i]=(i);}
for(i in this.updateset){var ii=this.updateset[i];var obj=this.index[ii];if(!obj.shown||obj.reStack)
ret[ii]=(ii);}
this.updateoutset=ret;return ret;}
zCluster.prototype.end=function(){this.glueData();}
zCluster.prototype.clear=function(){this.generation=0;this.index=[];this.workingset=[];this.updateset=[];this.updateoutset=[];}
zCluster.prototype.seal=function(generation){}
function GoogleMapWorker(div,driver)
{this.divId=div;this.driver=driver;this.name='google';this.objectcontainer=0;}
function GoogleOverlayHelper()
{this.api=0;this.helperOverlay=0;}
GoogleMapWorker.prototype.fromLatLng=function(inLat)
{return new google.maps.LatLng(inLat.getLat(),inLat.getLng());}
GoogleMapWorker.prototype.toLatLng=function(inLat)
{return new this.driver.LatLng(inLat.lat(),inLat.lng());}
GoogleMapWorker.prototype.GP2YA=function(a)
{return a;}
GoogleMapWorker.prototype.init=function(div,driver)
{this.divId=div;this.driver=driver;this.api=0;this.helperOverlay=0;this.loadingState=this.driver._enterState("google script-load");this.__loadingTm=0;this.__init_loadingCycle(0);}
GoogleMapWorker.prototype.tryScanErrors=function(){var ret="G:"+typeof(window.google);if(window.google){ret+=",load:"+typeof(window.google.load)+",maps:"+typeof(window.google.maps)
if(window.google.maps){ret+=",caller:"+typeof(window.google.maps.Map)}}
else ret+="; unloaded";this.driver.console(ret);}
GoogleMapWorker.prototype.soIfail=function(tick){this.tryScanErrors();this.driver._enterState('google fail'+tick,function(){letswitchtoohterapi();});}
GoogleMapWorker.prototype.__init_loadingCycle=function(tick){clearTimeout(this.__loadingTm);if(tick++>200){this.soIfail(tick);return;}
var thisworker=this;if(window.google&&typeof(window.google)!=undefined&&typeof(window.google.load)=='function'){this.driver.console("google start at "+tick+" tick");thisworker.driver._enterState('GMaps.load',function(){google.load("maps","3",{other_params:"sensor=true","callback":function(){if(thisworker.isClosed){thisworker.driver.console("google post-activaion");return;}
thisworker.driver._enterState("google start",function(){thisworker.start();},0);},"sensor":"true","language":"ru","hl":"ru","base_domain":"maps.google.ru"});},0);}
else{this.__loadingTm=setTimeout(function(){thisworker.__init_loadingCycle(tick)},10);}}
function GoogleV3ProjectionHelperOverlay(map)
{this.setMap(map);}
GoogleMapWorker.prototype.start=function()
{this.driver._leaveState(this.loadingState);var myOptions={zoom:this.driver.getZoom(),center:this.fromLatLng(this.driver.getPosition()),mapTypeId:this.decodeMapType(this.driver.getMapType()),disableDefaultUI:true,scrollwheel:false}
var thisworker=this;this.api=new google.maps.Map(this.divId,myOptions);this.helperOverlay=0;var _this=this;this.startIniter=0;GoogleV3ProjectionHelperOverlay.prototype=new google.maps.OverlayView();GoogleV3ProjectionHelperOverlay.prototype.draw=function(){if(!this.ready){google.maps.event.trigger(this,'ready');this.ready=true;this.tearMapOn(0);}};GoogleV3ProjectionHelperOverlay.prototype.tearMapOn=function(tick){if(this.getPanes()){_this.driver._enterState("google-doStartInit - "+tick,function(){_this.doStartInit();});}
else{var __this=this;setTimeout(function(){__this.tearMapOn(tick++)},1);}}
this.initViewOverlay();this.api.setCenter(myOptions.center);this.api.setZoom(myOptions.zoom);this.api.setMapTypeId(myOptions.mapTypeId);this.helperOverlay=new GoogleV3ProjectionHelperOverlay(this.api);this.helperOverlay.setMap(this.api);this.helperOverlay.draw();}
GoogleMapWorker.prototype.doStartInit=function()
{if(this.startIniter)
google.maps.event.removeListener(this.startIniter);this.driver.onMapReady();}
GoogleMapWorker.prototype.enableZoomControl=function(type){var myOptions={navigationControl:true,navigationControlOptions:{style:(type=='small'?google.maps.NavigationControlStyle.SMALL:google.maps.NavigationControlStyle.DEFAULT)}};this.api.setOptions(myOptions);}
GoogleMapWorker.prototype.disableZoomControl=function(){var myOptions={navigationControl:false};this.api.setOptions(myOptions);}
GoogleMapWorker.prototype.tearDown=function()
{clearTimeout(this.__loadingTm);if(this.api)
{google.maps.event.clearInstanceListeners(this.api);delete this.api
this.api=0;}}
GoogleMapWorker.prototype.setPosition=function(Pos,zoom)
{if(!this.api)return;this.checkResize();this.api.setZoom(zoom);if(this.setJump)
this.api.setCenter(this.fromLatLng(Pos));else
this.api.panTo(this.fromLatLng(Pos));this.setJump=0;}
GoogleMapWorker.prototype.getPosition=function(){if(!this.api)return false;return this.toLatLng(this.api.getCenter());}
GoogleMapWorker.prototype.getBounds=function()
{if(!this.api)return false;var gmap_bounds=this.api.getBounds();if(!gmap_bounds)return false;var gmap_bounds_sw=gmap_bounds.getSouthWest();var gmap_bounds_ne=gmap_bounds.getNorthEast();return{x1:gmap_bounds_sw.lng(),y1:gmap_bounds_sw.lat(),x2:gmap_bounds_ne.lng(),y2:gmap_bounds_ne.lat()}}
GoogleMapWorker.prototype.decodeMapType=function(type){var mtype=google.maps.MapTypeId.ROADMAP;if(type==MAPTYPE_NORMAL)mtype=google.maps.MapTypeId.ROADMAP;if(type==MAPTYPE_HYBRID)mtype=google.maps.MapTypeId.HYBRID;if(type==MAPTYPE_SATELITE)mtype=google.maps.MapTypeId.SATELLITE;return mtype;}
GoogleMapWorker.prototype.setMapType=function(type)
{var mtype=this.decodeMapType(type);this.api.setMapTypeId(mtype)}
GoogleMapWorker.prototype.getMapType=function()
{var type=this.api.getMapTypeId();if(type==google.maps.MapTypeId.ROADMAP)return MAPTYPE_NORMAL;if(type==google.maps.MapTypeId.HYBRID)return MAPTYPE_HYBRID;if(type==google.maps.MapTypeId.SATELLITE)return MAPTYPE_SATELITE;return MAPTYPE_NORMAL;}
GoogleMapWorker.prototype.zoomToPointSet=function(_inpoints,maxzoom)
{var points=[];var inpoints=_inpoints.slice(0);var point=0;while((point=inpoints.shift()))
points.push(this.fromLatLng(point));var inpoint=points.slice(0);point=inpoint.shift();var bounds=new google.maps.LatLngBounds(point,point);while((point=points.shift()))
bounds.extend(point);this.api.fitBounds(bounds);if(this.api.getZoom()>maxzoom)this.api.setZoom(maxzoom);this.driver.positionChanged();}
GoogleMapWorker.prototype.geocode=function(search,callback,keyframe){var map=this;var geo=new google.maps.Geocoder();keyframe=keyframe||0;var searchstr={};if(search.x){searchstr={'location':this.fromLatLng(search)};}
else{searchstr={'address':search};}
geo.geocode(searchstr,function(result,status){if(status==google.maps.GeocoderStatus.OK)
{if(callback.geocode){var r=result[0];var ret={};var components={};var i;for(i in r.address_components){var l=r.address_components[i];components[l['types'][0]]=l.long_name;}
ret.addr=r.formatted_address;ret.country=components.country;ret.region=components.administrative_area_level_1;ret.city=components.locality;ret.adm1=components.administrative_area_level_2;ret.adm2=components.administrative_area_level_3;ret.street=components.route;ret.bld=components.street_address;callback.geocode(ret);return;}
if(callback.success)
callback.success(map.toLatLng(result[0].geometry.location),result[0].geometry.location_type==google.maps.GeocoderLocationType.ROOFTOP,result[0].formatted_address,search,keyframe);}
else
{if(callback.fail)
callback.fail(search,keyframe);}});}
GoogleMapWorker.prototype.bind2MoveEnd=function(map_moveend_event,map_move_event,map_drag_end)
{google.maps.event.addListener(this.api,'idle',map_moveend_event);google.maps.event.addListener(this.api,'dragend',map_moveend_event);google.maps.event.addListener(this.api,'drag',map_moveend_event);}
GoogleMapWorker.prototype.bindClick=function(event,closure)
{var _this=this;if(closure&&closure.efor=='google')
google.maps.event.removeListener(closure.event);return{efor:'google',event:google.maps.event.addListener(this.api,'click',function(edata){event(_this.toLatLng(edata.latLng))})};}
GoogleMapWorker.prototype.getPane=function(a)
{if(!this.helperOverlay||typeof(this.helperOverlay.getPanes)!='function')
return false;var panes=this.helperOverlay.getPanes();return panes;return this.api.getDiv();}
GoogleMapWorker.prototype.checkResize=function(){if(this.api)
google.maps.event.trigger(this.api,'resize');}
GoogleMapWorker.prototype.disableScrollWheelZoom=function(){this.api.setOptions({scrollwheel:false});}
GoogleMapWorker.prototype.enableScrollWheelZoom=function()
{this.api.setOptions({scrollwheel:true});}
GoogleMapWorker.prototype.getZoom=function(){if(!this.api)return false;return this.api.getZoom();}
GoogleMapWorker.prototype.modPointByOffset=function(point,fac){var bounds=this.api.getBounds();var swPoint=this.fromLatLngToDivPixel(bounds.getSouthWest());var nePoint=this.fromLatLngToDivPixel(bounds.getNorthEast());return{x:point.x-swPoint.x*fac,y:point.y-nePoint.y*fac};}
GoogleMapWorker.prototype.fromLatLngToContainerPixel=function(a){var point=this.fromLatLngToDivPixel(a);return this.modPointByOffset(point,1);}
GoogleMapWorker.prototype.fromContainerPixelToLatLng=function(a){var point=this.modPointByOffset(a,-1);return this.fromDivPixelToLatLng(point);}
GoogleMapWorker.prototype.fromLatLngToDivPixel=function(a){if(!this.helperOverlay)return{x:0,y:0};return this.helperOverlay.getProjection().fromLatLngToDivPixel(a);}
GoogleMapWorker.prototype.fromDivPixelToLatLng=function(a){return this.toLatLng(this.helperOverlay.getProjection().fromDivPixelToLatLng(a));}
GoogleMapWorker.prototype.createPolygon=function(polygon){var mirror=new GooglePolygon(this);polygon.attach(mirror);}
GoogleMapWorker.prototype.openTransaction=function(){if(this.getPane())
this.objectcontainer=this.getPane().floatPane;if(this.objectcontainer)
this.objectcontainer.style.display='none';}
GoogleMapWorker.prototype.closeTransaction=function(){if(this.objectcontainer)
this.objectcontainer.style.display='';}
GoogleMapWorker.prototype.createMarker=function(options){var _this=this;function MarkerWraper(marker){this.driverMarker=marker;this.setPosition=function(pos){marker.setPosition(_this.fromLatLng(pos))}
this.getPosition=function(){return _this.toLatLng(marker.getPosition())}
this.tearDown=function(){marker.setMap(null);}}
var ic=options.icon;ic.origin=ic.origin||{x:0,y:0};var mopts={map:this.api,position:this.fromLatLng(options.position),title:options.title,icon:new google.maps.MarkerImage(ic.url,new google.maps.Size(ic.size.w,ic.size.h),new google.maps.Point(ic.origin.x,ic.origin.y),new google.maps.Point(ic.anchor.x,ic.anchor.y)),draggable:((options.draggable)?true:false)};var marker=new google.maps.Marker(mopts);if(options.events){if(options.events.dragEnd){google.maps.event.addListener(marker,'dragend',options.events.dragEnd);}}
return new MarkerWraper(marker);}
GoogleMapWorker.prototype.addOverlay=function(layerobject)
{if(layerobject.isPolygon){return this.createPolygon(layerobject);}
if(layerobject.layerObject&&layerobject.layerObject.workerName!='googlev3')
layerobject.layerObject=0;if(!layerobject.layerObject)
layerobject.layerObject=new GoogleLayerView(this,layerobject,(this.getPane()).floatPane);layerobject.layerObject.workerName='googlev3';layerobject.layerObject.show();}
GoogleMapWorker.prototype.addControl=function(layerobject)
{if(!layerobject.layerObject)
layerobject.layerObject=new GoogleLayerView(this,layerobject,this.api.getDiv());layerobject.layerObject.show();}
GoogleMapWorker.prototype.removeOverlay=function(layerobject)
{if(layerobject.layerObject&&layerobject.layerObject.hide)
layerobject.layerObject.hide();}
function GoogleLayerView(map,object,layer)
{this.inmap=map;this.object=object;this.layer=layer;this.shown=0;}
GoogleMapWorker.prototype.initViewOverlay=function()
{GoogleLayerView.prototype=new google.maps.OverlayView();GoogleLayerView.prototype.onAdd=function(map,container)
{this.object.init(this.inmap);if((this.object.getDiv()).parentNode!=this.layer)
{this.layer.appendChild(this.object.getDiv());this.object.EventOnAttach();}
this.draw();return this.object.getDiv();}
GoogleLayerView.prototype.draw=function(map,container)
{this.object.redraw(true);}
GoogleLayerView.prototype.onRemove=function(map,container)
{this.shown=0;return this.object.remove();}
GoogleLayerView.prototype.show=function(){if(!this.object.getDiv())
this.onAdd(this.inmap,0);if(!this.shown)
this.setMap(this.inmap.api);this.draw();this.shown=1;}
GoogleLayerView.prototype.hide=function(){this.onRemove();this.setMap(null);}}
var GooglePolygon=function(map){this.polygon=0;this.map=map;this.events=[];}
GooglePolygon.prototype.attach=function(){}
GooglePolygon.prototype.draw=function(poly){this.dettach();var coords=[];for(i in poly.coords){coords=this.map.fromLatLng(poly.coords[i]);}
var options={fillColor:poly.fill,strokeColor:poly.border,strokeWidth:1,map:this.map,paths:coords};if(poly.style=='border'){this.polygon=this.map.api.Polygon(options);}
else{this.polygon=this.map.api.Polyline(options);}
this.events['click']=google.maps.event.addListener(this.polygon,'click',function(a,b,c){poly.onClick();});this.events['mouseover']=google.maps.event.addListener(this.polygon,'mouseover',function(a,b,c){poly.onMouseOver();});this.events['mouseout']=google.maps.event.addListener(this.polygon,'mouseout',function(a,b,c){poly.onMouseOut();});}
GooglePolygon.prototype.dettach=function(){if(this.polygon){this.map.api.removeOverlay(this.polygon);this.polygon=0;}
var i;for(i in this.events){this.events[i].cleanup();}
this.events=[];}
function YandexMapWorker(div,driver)
{this.divId=div;this.driver=driver;this.name='yandex';this.eventDomSet={move:[],up:[],down:[]};this.objectcontainer=0;}
YandexMapWorker.prototype.fromLatLng=function(inLat)
{if(!inLat)return false;return new YMaps.GeoPoint(inLat.lng(),inLat.lat());}
YandexMapWorker.prototype.toLatLng=function(inLat)
{if(!inLat)return false;return new this.driver.LatLng(inLat.getLat(),inLat.getLng());}
YandexMapWorker.prototype.GP2YA=function(a)
{return new YMaps.Point(a.x,a.y);}
YandexMapWorker.prototype.init=function(div,driver)
{this.divId=div;this.driver=driver;var thisworker=this;this.loadState=this.driver._enterState('yandex script-load');this.__loadingTm=0;this.__init_loadingCycle(0);}
YandexMapWorker.prototype.tryScanErrors=function(){var ret="Y:"+typeof(window.YMaps);if(window.YMaps){ret+=",load:"+typeof(window.YMaps.load)+",maps:"+typeof(window.YMaps.Map)}
else ret+="; unloaded";this.driver.console(ret);}
YandexMapWorker.prototype.soIfail=function(){this.tryScanErrors();this.driver._enterState('yandex fail',function(){letswitchtoohterapi();});}
YandexMapWorker.prototype.__init_loadingCycle=function(tick){clearTimeout(this.__loadingTm);if(tick++>200){this.soIfail();return;}
var thisworker=this;if(window.YMaps&&typeof(window.YMaps)!='undefined'&&typeof(window.YMaps.load)=='function'){this.driver.console("yandex start at "+tick+" tick");thisworker.driver._enterState('YMaps.load',function(){YMaps.load(function(){if(thisworker.isClosed){thisworker.driver.console("yandex post-activaion");return;}
thisworker.driver._enterState('yandex start',function(){thisworker.start();});});},0,function(){thisworker.__init_loadingCycle(tick);});}else{this.__loadingTm=setTimeout(function(){thisworker.__init_loadingCycle(tick)},10);}}
YandexMapWorker.prototype.start=function()
{this.driver._leaveState(this.loadState);this.api=new YMaps.Map(this.divId);this.driver.onMapReady();}
YandexMapWorker.prototype.tearDown=function()
{this.api.removeAllOverlays();clearTimeout(this.__loadingTm);this.api.destructor();delete this.api;this.api=0;}
YandexMapWorker.prototype.enableZoomControl=function(type){if(!this.zoomControl){var position=new YMaps.ControlPosition(YMaps.ControlPosition.TOP_LEFT,new YMaps.Point(10,10));if(type=='small')
this.zoomControl=new YMaps.SmallZoom({noTips:true});else
this.zoomControl=new YMaps.Zoom({noTips:true});this.api.addControl(this.zoomControl,position);}}
YandexMapWorker.prototype.disableZoomControl=function(){if(!this.zoomControl){this.api.removeControl(this.zoomControl);delete this.zoomControl;this.zoomControl=0;}}
YandexMapWorker.prototype.setPosition=function(Pos,zoom)
{if(!this.api)return;if(zoom==this.api.getZoom()){var to=this.api.converter.coordinatesToLocalPixels(this.fromLatLng(Pos));var from=this.api.converter.coordinatesToLocalPixels(this.api.getCenter());var shift=new YMaps.Point(to.x-from.x,to.y-from.y);if(this.setJump||Math.abs(shift.x)>512||Math.abs(shift.y)>512)
this.api.setCenter(this.fromLatLng(Pos),zoom);else
this.api.moveBy(shift,true);this.setJump=0;}
else this.api.setCenter(this.fromLatLng(Pos),zoom);}
YandexMapWorker.prototype.getPosition=function(){return this.toLatLng(this.api.getCenter());}
YandexMapWorker.prototype.getBounds=function()
{if(!this.api)return false;var gmap_bounds=this.api.getBounds();if(!gmap_bounds)return false;var gmap_bounds_sw=gmap_bounds.getLeftBottom();var gmap_bounds_ne=gmap_bounds.getRightTop();return{x1:gmap_bounds_sw.getLng(),y1:gmap_bounds_sw.getLat(),x2:gmap_bounds_ne.getLng(),y2:gmap_bounds_ne.getLat()}}
YandexMapWorker.prototype.setMapType=function(type)
{var mtype=YMaps.MapType.MAP;if(type==MAPTYPE_NORMAL)mtype=YMaps.MapType.MAP;if(type==MAPTYPE_HYBRID)mtype=YMaps.MapType.HYBRID;if(type==MAPTYPE_SATELITE)mtype=YMaps.MapType.SATELLITE;this.api.setType(mtype)}
YandexMapWorker.prototype.getMapType=function()
{var type=this.api.getType();if(type==YMaps.MapType.MAP)return MAPTYPE_NORMAL;if(type==YMaps.MapType.HYBRID)return MAPTYPE_HYBRID;if(type==YMaps.MapType.SATELLITE)return MAPTYPE_SATELITE;return MAPTYPE_NORMAL;}
YandexMapWorker.prototype.zoomToPointSet=function(_inpoints,maxzoom)
{var points=[];var inpoints=_inpoints.slice(0);while((point=inpoints.shift()))
points.push(this.fromLatLng(point));var bounds=new YMaps.GeoCollectionBounds(points);this.api.setCenter(bounds.getCenter(),Math.min(maxzoom,bounds.getMapZoom(this.api)));this.driver.positionChanged();}
YandexMapWorker.prototype.geocode=function(search,callback,keyframe){if(search.x){search=this.fromLatLng(search);}
var geo=new YMaps.Geocoder(search);var map=this;keyframe=keyframe||0;YMaps.Events.observe(geo,geo.Events.Load,function(){if(this.length())
{var precision=this.get(0).precision;if(callback.geocode){var elem=this.get(0);var co={};function geodeep(ar){var i;for(i in ar){if(i&&ar[i]&&ar[i][i+'Name']){ar[i]['n']=ar[i][i+'Name'];co[i]=ar[i];}
if(typeof(ar[i])=='object'){geodeep(ar[i]);}}}
r=elem.AddressDetails;geodeep(r);ret={};ret.addr=elem.text;ret.country=co.Country.n;ret.region=co.AdministrativeArea?co.AdministrativeArea.n:co.Locality.n;ret.adm1=co.SubAdministrativeArea?co.SubAdministrativeArea.n:'';ret.city=co.Locality.n;ret.street=co.Thoroughfare?co.Thoroughfare.n:'';ret.bld=(co.Thoroughfare&&co.Thoroughfare.Premise)?co.Thoroughfare.Premise.PremiseNumber:'';callback.geocode(ret);return;}
else
if(precision=="exact"||precision=="number"||precision=="near"||precision=="street"||precision=="other")
{var point=this.get(0).getGeoPoint();if(callback.success)
callback.success(map.toLatLng(point),precision=="number"||precision=="exact"||precision=="near",this.get(0).text,search,keyframe);}
else
{if(callback.fail)
callback.fail(search,keyframe);}}
else
{if(callback.fail)
callback.fail(search,keyframe);}});}
YandexMapWorker.prototype.bind2MoveEnd=function(map_moveend_event,map_move_event,map_drag_end)
{var _this=this;YMaps.Events.observe(this.api,this.api.Events.Update,map_moveend_event);YMaps.Events.observe(this.api,this.api.Events.MoveEnd,map_moveend_event);YMaps.Events.observe(this.api,this.api.Events.Move,map_move_event);YMaps.Events.observe(this.api,this.api.Events.DragEnd,map_drag_end);YMaps.Events.observe(this.api,this.api.Events.MouseMove,function(a,b){if(b)
_this.dispatchDomEvent(b.getEvent(),'move');});YMaps.Events.observe(this.api,this.api.Events.MouseUp,function(a,b){if(b)
_this.dispatchDomEvent(b.getEvent(),'up');});YMaps.Events.observe(this.api,this.api.Events.Click,function(a,b){if(b)
_this.dispatchDomEvent(b.getEvent(),'click');});}
YandexMapWorker.prototype.realOffsetY=function(objName){var tmpY=0;var tmpObj=objName.offsetParent;if(tmpObj)
while(tmpObj&&tmpObj.tagName!='BODY'){tmpY+=(tmpObj.offsetTop);tmpObj=tmpObj.offsetParent;}
return tmpY+(objName.offsetTop);}
YandexMapWorker.prototype.dispatchDomEvent=function(event,place){var i;for(i in this.eventDomSet[place])
if(this.eventDomSet[place][i]){var devent=this.eventDomSet[place][i];devent(event);}}
YandexMapWorker.prototype.eventDomFind=function(place,set){var i;for(i in this.eventDomSet[place])
if(this.eventDomSet[place][i]==set){return i;}
return-1;}
YandexMapWorker.prototype.domMouseControl=function(action,set){var i=0;if(action=='enable'){if(set.move&&this.eventDomFind('move',set.move)==-1)
this.eventDomSet.move.push(set.move);if(set.up&&this.eventDomFind('up',set.up)==-1)
this.eventDomSet.up.push(set.up)
if(set.click&&this.eventDomFind('click',set.click)==-1)
this.eventDomSet.up.push(set.click)}
if(action=='disable'){i=this.eventDomFind('move',set.move);if(i>=0)delete this.eventDomSet['move'][i];i=this.eventDomFind('up',set.up);if(i>=0)delete this.eventDomSet['up'][i];i=this.eventDomFind('click',set.click);if(i>=0)delete this.eventDomSet['click'][i];}}
YandexMapWorker.prototype.bindClick=function(event,closure)
{var _this=this;if(closure&&closure.efor=='yandex')
closure.event.cleanup();return{efor:'yandex',event:YMaps.Events.observe(this.api,this.api.Events.Click,function(a,b,c){event(_this.toLatLng(b.getCoordPoint()))})};}
YandexMapWorker.prototype.getPane=function(a){return this.api.getContainer();}
YandexMapWorker.prototype.checkResize=function(){if(this.api)this.api.redraw(true);}
YandexMapWorker.prototype.disableScrollWheelZoom=function(){this.api.disableScrollZoom();}
YandexMapWorker.prototype.enableScrollWheelZoom=function(){this.api.enableScrollZoom();}
YandexMapWorker.prototype.getZoom=function(){return this.api.getZoom();}
YandexMapWorker.prototype.fromLatLngToContainerPixel=function(a){var YA=this.fromLatLng(a);return this.api.converter.coordinatesToLocalPixels(YA);}
YandexMapWorker.prototype.fromContainerPixelToLatLng=function(a){return this.toLatLng(this.api.converter.localPixelsToCoordinates(this.GP2YA(a)));}
YandexMapWorker.prototype.fromLatLngToDivPixel=function(a){var YA=this.fromLatLng(a);return this.api.converter.coordinatesToMapPixels(YA);}
YandexMapWorker.prototype.fromDivPixelToLatLng=function(a){return this.toLatLng(this.api.converter.mapPixelsToCoordinates(this.GP2YA(a)));}
YandexMapWorker.prototype.createPolygon=function(polygon){var mirror=new YandexPolygon(this);polygon.attach(mirror);}
YandexMapWorker.prototype.openTransaction=function(){if(this.objectcontainer){this.objectcontainer.style.display='none';this.detachCountainer=0;if(this.detachCountainer)
this.detachCountainer.removeChild(this.objectcontainer);}
this.trans_open=this.driver.microtime();}
YandexMapWorker.prototype.closeTransaction=function(){if(this.objectcontainer){if(this.detachCountainer)
this.detachCountainer.appendChild(this.objectcontainer);this.objectcontainer.style.display='';}
this.trans_close=this.driver.microtime();}
YandexMapWorker.prototype.createMarker=function(options){var _this=this;function MarkerWraper(marker){this.driverMarker=marker;this.setPosition=function(pos){marker.setGeoPoint(_this.fromLatLng(pos))}
this.getPosition=function(){return _this.toLatLng(marker.getGeoPoint())}
this.tearDown=function(){_this.api.removeOverlay(marker);}}
var ic=options.icon;var s=new YMaps.Style();s.iconStyle=new YMaps.IconStyle();s.iconStyle.href=ic.url;s.iconStyle.size=new YMaps.Point(ic.size.w,ic.size.h);s.iconStyle.offset=new YMaps.Point(-ic.anchor.x,-ic.anchor.y);var mopts={style:s,title:options.title,draggable:((options.draggable)?true:false)};var marker=new YMaps.Placemark(this.fromLatLng(options.position),mopts);this.api.addOverlay(marker);if(options.events){if(options.events.dragEnd){YMaps.Events.observe(marker,marker.Events.DragEnd,options.events.dragEnd);}}
return new MarkerWraper(marker);}
YandexMapWorker.prototype.addOverlay=function(layerobject)
{if(layerobject.isPolygon){return this.createPolygon(layerobject);}
if(layerobject.layerObject&&layerobject.layerObject.workerName!='yandex')
layerobject.layerObject=0;if(!layerobject.layerObject){layerobject.layerObject=new YandexLayerView(this,layerobject);}
layerobject.layerObject.workerName='yandex';this.api.addOverlay(layerobject.layerObject);}
YandexMapWorker.prototype.addControl=function(layerobject)
{if(!layerobject.layerObject)
layerobject.layerObject=new YandexLayerView(this,layerobject);layerobject.layerObject.container=this.api.getContainer();this.api.addControl(layerobject.layerObject);}
YandexMapWorker.prototype.removeOverlay=function(layerobject)
{this.api.removeOverlay(layerobject.layerObject);}
function YandexLayerView(map,object)
{this.inmap=map;this.object=object;this.shown=0;this.container=0;}
YandexLayerView.prototype.onAddToMap=function(map,container)
{this.object.init(map);if(this.container)container=this.container;else this.inmap.objectcontainer=container;if(!this.shown)
{var div=this.object.getDiv()
container.appendChild(div);this.object.EventOnAttach();}
this.onMapUpdate(map);this.shown=1;return this.object.getDiv();}
YandexLayerView.prototype.onMapUpdate=function(map,container)
{this.object.redraw(true);}
YandexLayerView.prototype.onRemoveFromMap=function(map,container)
{this.shown=0;return this.object.remove();}
var YandexPolygon=function(map){this.polygon=0;this.map=map;this.events=[];}
YandexPolygon.prototype.attach=function(){}
YandexPolygon.prototype.draw=function(poly){this.dettach();var coords=[];for(i in poly.coords){coords=this.map.fromLatLng(poly.coords[i]);}
var options={style:{polygonStyle:{outline:true,strokeWidth:1,strokeColor:poly.border,fillColor:poly.fill}}};if(poly.style=='border'){this.polygon=YMaps.Polygon(coords,options);}
else{this.polygon=YMaps.Polyline(coords,options);}
this.map.api.addOverlay(this.polygon);this.events['click']=YMaps.Events.observe(this.polygon,this.polygon.Events.Click,function(a,b,c){poly.onClick();});this.events['mouseover']=YMaps.Events.observe(this.polygon,this.polygon.Events.MouseEnter,function(a,b,c){poly.onMouseOver();});this.events['mouseout']=YMaps.Events.observe(this.polygon,this.polygon.Events.MouseLeave,function(a,b,c){poly.onMouseOut();});}
YandexPolygon.prototype.dettach=function(){if(this.polygon){this.map.api.removeOverlay(this.polygon);this.polygon=0;}
var i;for(i in this.events){this.events[i].cleanup();}
this.events=[];}
function MapLayer()
{}
MapLayer.prototype.setZInstance=function(z)
{this.ZTile=z;if(this.zTouchable())
{this.ZTile.assignLayer(this.layerId,this,{'show':function(meta,object,lid,map){meta.showObject(object,lid,map);return object;},'hide':function(meta,object,lid,map){meta.hideObject(object,lid,map);return object;},'reset':function(meta,object,lid,map){meta.resetObject(object,lid,map);return object;},'preprocess':function(meta,object,lid,map){meta.preprocessObject(object,lid,map);return object;}})}}
MapLayer.prototype.zTouchable=function()
{return true;}
MapLayer.prototype.canHandle=function(entityId)
{return false;}
MapLayer.prototype.driveEntity=function(entityId)
{return false;}
MapLayer.prototype.setMap=function(map)
{var oldmap=this._map;this._map=map;this.onAttach();}
MapLayer.prototype.onAttach=function(){}
MapLayer.prototype.Assign=function(layerId,driver,ztile)
{this.layerId=layerId;this.driver=driver;this.setZInstance(ztile);return this;}
MapLayer.prototype.enable=function(layerId)
{this.ZTile.enableLayer(layerId);return true;}
MapLayer.prototype.disable=function(layerId)
{this.ZTile.disableLayer(layerId);return true;}
MapLayer.prototype.showObject=function(object,lid,map)
{object.shown=1;}
MapLayer.prototype.hideObject=function(object,lid,map)
{object.shown=0;}
MapLayer.prototype.resetObject=function(object,lid,map)
{object.shown=0;}
MapLayer.prototype.preprocessObject=function(object,lid,map)
{return object;}
function MapLayerOverlayed(){}
mapi.extend(MapLayerOverlayed,MapLayer);MapLayerOverlayed.prototype.showObject=function(object,lid,map)
{if(!object.mapObject)
this.initOverlay(object,map);if(object.mapObject)
{object.mapObject.show();object.shown=1;return true;}
return false;}
MapLayerOverlayed.prototype.hideObject=function(object,layerId,map)
{if(object.mapObject)
object.mapObject.hide();object.shown=0;}
MapLayerOverlayed.prototype.resetObject=function(object,layerId,map)
{if(object.mapObject)
{object.mapObject.tearDown();delete object.mapObject;object.mapObject=0;}
object.shown=0;}
MapLayerOverlayed.prototype.initOverlay=function(object,map)
{var View=map.getEntityView(object.ID_MAP_OBJECT_TYPE);if(View)
{View.setObject(object,map);object.mapObject=View;}
return View;}
MapLayerOverlayed.prototype.getView=function()
{return false;}
function MapOverlay()
{this.object=0;this.map=0;this.isAttached=false;}
MapOverlay.prototype.maybeSame=function(source){return this.object&&source.object&&this.object.ID_MAP_OBJECT==source.object.ID_MAP_OBJECT;}
MapOverlay.prototype.setObject=function(object,map){this.object=object;if(map)
{this.latlng=map.LatLng(object.LATITUDE,object.LONGITUDE);this.map=map;}}
MapOverlay.prototype.mapAttach=function(map){this.map=map;this.isAttached=1;}
MapOverlay.prototype.mapDettach=function(){this.isAttached=0;}
MapOverlay.prototype.fixDocumentLayout=function(){if(this.isAttached)
if(this.allowPngFix())
this.pngFix();}
MapOverlay.prototype.EventOnAttach=function(){var _this=this;_this.onAttach();_this.fixDocumentLayout();return true;}
MapOverlay.prototype.onAttach=function(){this.isAttached=true;return true;}
MapOverlay.prototype.onDettach=function(){this.isAttached=false;return true;}
MapOverlay.prototype.allowPngFix=function(){return true;}
MapOverlay.prototype.pngFix=function(){return;var _this=$(this._div);var fixobj=$("img:first",_this);fixobj.pngFix();$(".pngFix",_this).pngFix();}
MapOverlay.prototype.getDiv=function(){return false;}
MapOverlay.prototype.init=function(mapApi){return false;}
MapOverlay.prototype.remove=function(){return false;}
MapOverlay.prototype.tearDown=function(){return false;}
MapOverlay.prototype.render=function(){return false;}
MapOverlay.prototype.redraw=function(byForce){this.setPosition();this.render();}
MapOverlay.prototype.show=function(){this.map.addOverlay(this);this.map.tryRestoreBalloon(this);return false;}
MapOverlay.prototype.hide=function(){this.map.removeOverlay(this);this.map.tryCloseBalloon(this);return false;}
MapOverlay.prototype.tearDown=function(force){this.hide(force);this.map.tryCloseBalloon(this);delete this.layerObject;}
MapOverlay.prototype.setPosition=function(){return false;}
function MapPointOverlay()
{MapPointOverlay.superclass.constructor.call(this);this.stackCount=0;this.innerHTML='';this._setInnerHTML='';}
mapi.extend(MapPointOverlay,MapOverlay);MapPointOverlay.prototype.stop_bubble=function(event)
{event=event||window.event;event.cancelBubble=true;event.cancel=true;event.returnValue=false;if(event.stopPropagation)event.stopPropagation();return true;}
MapPointOverlay.prototype.overHookWheel=function()
{var element=this._div;var eventName='mousewheel';var _this=this;var callback=function(event){return _this.stop_bubble(event)};if(element.addEventListener)
{element.addEventListener('DOMMouseScroll',callback,false);element.addEventListener(eventName,callback,false);}
else if(element.attachEvent)
element.attachEvent("on"+eventName,callback);}
MapPointOverlay.prototype.getCursor=function(){return'pointer';}
MapPointOverlay.prototype.isTransparent=function(){return false;}
MapPointOverlay.prototype.prestyle=function(){return'position:absolute;z-index:'+this.getZIndex()+";cursor:"+this.getCursor()+";";}
MapPointOverlay.prototype.createDiv=function(){this._div=document.createElement("div");this._div.upobj=this;if(!this.isTransparent())
{if(this.getCursor())
this._div.style.cursor=this.getCursor();this._div.onclick=function(event){this.upobj.stop_bubble(event);return this.upobj.doonclick(event);}
this._div.onmousemove=function(event){this.upobj.stop_bubble(event);return false;}
this._div.onmousedown=function(event){this.upobj.stop_bubble(event);return false;}
this._div.onmouseup=function(event){this.upobj.stop_bubble(event);return false;}
this._div.onselectstart=function(){return false;};this._div.unselectable="on";this.overHookWheel();}
this._div.style.cssText=this.prestyle();this._div.className=this.getDivClassName();return this._div;}
MapPointOverlay.prototype.getCenter=function(){return this.latlng;}
MapPointOverlay.prototype.setCenter=function(latlng){this.latlng=latlng;}
MapPointOverlay.prototype.getDim=function(){return{w:0,h:0};}
MapPointOverlay.prototype.getMarkerAttach=function(){var dim=this.getDim();return{x:Math.round(dim.w/2),y:Math.round(dim.h/2)}};MapPointOverlay.prototype.getAttachPoint=function(){if(this._superAttachPoint)return this.getreStackAttach();return this.getMarkerAttach();}
MapPointOverlay.prototype.getDiv=function(){return this._div;}
MapPointOverlay.prototype.getZIndex=function(){return 1;}
MapPointOverlay.prototype.setinnerHTML=function(val)
{var _this=this;if(!val)val=this.innerHTML;if(this._div&&this._setInnerHTML!=val)
{this._div.innerHTML=[val].join("");this._setInnerHTML=val;this.fixDocumentLayout();}}
MapPointOverlay.prototype.remove=function(force)
{if(this._div&&this._div.parentNode)
{force=force||0;this._div.parentNode.removeChild(this._div);{delete this._div;this._setInnerHTML='';this._div=0;}}
if(this.object){this.object.shown=0;}}
MapPointOverlay.prototype.setPosition=function()
{if(!this.map.fixOutzoom()){if(this._div)
this._div.style.display='none';return false;;}
var tl=this.map.fromLatLngToDivPixel(this.getCenter());var dim=this.getAttachPoint();if(this._div&&tl){var left=Math.round(tl.x-dim.x)+'px';var top=Math.round(tl.y-dim.y)+'px';this._div.style.cssText=this.prestyle()+"left:"+left+";top:"+top;}
return true;}
MapPointOverlay.prototype.setLatLng=function(latlng){this.latlng=latlng;if(this._div)
{this.setPosition();this.init();}}
MapPointOverlay.prototype.setText=function(text){this.innerHTML=text;}
MapPointOverlay.prototype.getStackedTitle=function(cnt){return cnt+" обьектов";}
MapPointOverlay.prototype.getFloatName=function(){return'unnamed object';}
MapPointOverlay.prototype.FloatName=function()
{var ret='';if(this.stackCount)
{if(this.allStackedInOne()){ret=this.getStackedTitle(this.stackCount+1);}
else ret="Приблизительно "+(this.stackCount+1)+" обьектов в районе";}
else ret=this.getFloatName();return ret;}
MapPointOverlay.prototype.getBalloonTitle=function(){return this.getFloatName();}
MapPointOverlay.prototype.getBalloonHTML=function(){return false;}
MapPointOverlay.prototype.getBalloonStyle=function(){return mapBalloonSimple;}
MapPointOverlay.prototype.getBallonClasses=function(){return'';}
MapPointOverlay.prototype.getBalloonFrontier=function(){return mapDefaultBalloonFrontier;}
MapPointOverlay.prototype.onBalloonAttach=function(parent){}
MapPointOverlay.prototype.onclick=function(event){var Balloon=this.getBalloonHTML()
if(Balloon)
this.map.openBalloon(this.latlng,Balloon,this.getBalloonStyle(),this);return false;}
MapPointOverlay.prototype.getRefName=function(){return false;}
MapPointOverlay.prototype._runonclick=function(event){return this.onclick(event);}
MapPointOverlay.prototype.doonclick=function(event){if(this._div.onmouseout)
this._div.onmouseout(event);this.map.onElementClick(this,this.getRefName());return this._runonclick(event);}
MapPointOverlay.prototype.stackZoomLimit=function(){var ret=this.map.getZoom()<17&&!this.allStackedInOne();return ret;}
MapPointOverlay.prototype.allStackedInOne=function()
{if(this.stackCount!=this.object.stacked.length)return false;var lat=this.object.LATITUDE;var lng=this.object.LONGITUDE;var sta=this.object.stacked;var objects=this.map.ZTile.dirrectAccess();for(var i=0;i<sta.length;i++)
{var idx=sta[i];var dx=Math.abs(lat-objects[idx].LATITUDE);var dy=Math.abs(lng-objects[idx].LONGITUDE);if(dx>0.0005||dy>0.0005)return false;}
return true;}
MapPointOverlay.prototype.zoomToStack=function(){var set=[];var list=this.object.stacked.slice(0);var objects=this.map.ZTile.dirrectAccess();set.push(new mLatLng(this.object.LATITUDE,this.object.LONGITUDE));var element;while((element=list.shift()))
{var obj=objects[element];set.push(new mLatLng(obj.LATITUDE,obj.LONGITUDE));}
var z=this.map.getZoom();z+=2;this.map.zoomToPointSet(set,z)}
MapPointOverlay.prototype.htmlUnRollStack=function(event,elsewrap,includeSelf){var set=[];var list=this.object.stacked.slice(0);var objects=this.map.ZTile.dirrectAccess();if(includeSelf)
set.push(this.object);var element;while((element=list.shift()))
{if(!includeSelf&&objects[element]==this.object)
continue;set.push(objects[element]);}
set.sort(function(a,b){return a.ID_MAP_OBJECT_TYPE-b.ID_MAP_OBJECT_TYPE;});var typeDrivers=[];var view=0;var result='';while((element=set.shift()))
{if(!typeDrivers[element.ID_MAP_OBJECT_TYPE])
typeDrivers[element.ID_MAP_OBJECT_TYPE]=this.map.getEntityView(element.ID_MAP_OBJECT_TYPE);view=typeDrivers[element.ID_MAP_OBJECT_TYPE];view.setObject(element);var name=view.getBalloonTitle();if(elsewrap)
result+='<div class="else">'+name+"</div>";else result+=name;}
return result;}
MapPointOverlay.prototype.reStackShow=function(event){var set=[];if(!this.unforceStacked&&this.stackZoomLimit())
{this.zoomToStack();return;}
var result="<div class='list'>"+this.htmlUnRollStack(event,true,true)+"</div>";;this.map.openBalloon(this.latlng,result,mapBalloonRestack,this);}
MapPointOverlay.prototype.reStacked=function()
{return this.object.reStack||this.object.stackCNT;}
MapPointOverlay.prototype.getDivClassName=function(){return'';}
MapPointOverlay.prototype.getreStackCode=function(){return"<img src='/images/v3/ico_multi.png'>";}
MapPointOverlay.prototype.reStack=function()
{if(this.object.stackCNT<1)
{this.object.stackCNT=1;}
this.stackCount=this.object.stackCNT-1;if(this.stackCount)
{this._superAttachPoint=1;this.setinnerHTML(this.getreStackCode());this.getDiv().className='restackMarker';this._runonclick=function(){this.reStackShow();}
this.setPosition();}
else
{this._superAttachPoint=0;this.setinnerHTML();this.getDiv().className=this.getDivClassName();this._runonclick=this.onclick;this.setPosition();}
this.object.reStack--;if(this.object.reStack<0)this.object.reStack=0;}
var ControlHelpOverlayControls=0;var controlHelpIsHidden=0;window.ControlHelpOverlayhideSelf=function(){if(controlHelpIsHidden)return;$(".gedMap_help_overlay").hide("slow");controlHelpIsHidden=1;controlHelpOverlayInfoSelf();}
window.controlHelpOverlayInfoSelf=function(){var text='';if(controlHelpIsHidden)text='Показать подсказки';else text='Убрать подсказки';$("#mapHelpExtButtons").html("<a title='' href='#' onclick='map_help_off("+controlHelpIsHidden+");return false;'>"+text+"</a>");}
window.ControlHelpOverlayTestSelf=function(forceon){if(parseInt($.cookie("isShowingMapHelp"))&&!forceon)
{ControlHelpOverlayhideSelf();controlHelpIsHidden=1;}
else controlHelpIsHidden=0;}
ControlHelpOverlayTestSelf();var ControlCustomOverlay_tear=0;var ControlCustomOverlay=function()
{if(!ControlCustomOverlay_tear)
{this.tear();return new ControlCustomOverlay();}
return this;}
ControlCustomOverlay_tear=1;mapi.extend(ControlCustomOverlay,MapPointOverlay);ControlCustomOverlay.prototype.getZIndex=function(){return 90;}
ControlCustomOverlay.prototype.setPosition=function()
{return true;}
var ControlTypeOverlay=function()
{}
ControlTypeOverlay.prototype=new ControlCustomOverlay();ControlTypeOverlay.prototype.setPosition=function()
{this._div.style.right='0px';this._div.style.top='0px';return true;}
ControlTypeOverlay.prototype.mapcurrent=function(name,mapType){$('.mapTypeSwitcher',this._div).addClass('active');$(".maptype_buttons",this._div).removeClass('active');if(name=='yandex')$('.yandex_button',this._div).removeClass('active');else $('.google_button',this._div).removeClass('active');if(mapType==MAPTYPE_SATELITE)$(".maptype_satellite_button",this._div).addClass('active');else if(mapType==MAPTYPE_HYBRID)$(".maptype_hybrid_button",this._div).addClass('active');else $(".maptype_map_button",this._div).addClass('active');}
ControlTypeOverlay.prototype.onmapType=function(call){$('.maptype_buttons',this._div).removeClass('active');$(call).addClass('active');}
ControlTypeOverlay.prototype.onAttach=function()
{var tdiv=$(this._div);$("div",tdiv).unbind('click');var callobj=this;$(".map_reinit",tdiv).click(function(){callobj.map.respawn();return false;})
$(".yandex_button",tdiv).click(function(){callobj.map.setYandexMaps();return false;})
$(".google_button",tdiv).click(function(){callobj.map.setGoogleMaps();return false;})
$(".maptype_satellite_button",tdiv).click(function(){callobj.onmapType(this);callobj.map.setMapType(MAPTYPE_SATELITE);return false;})
$(".maptype_hybrid_button",tdiv).click(function(){callobj.onmapType(this);callobj.map.setMapType(MAPTYPE_HYBRID);return false;})
$(".maptype_map_button",tdiv).click(function(){callobj.onmapType(this);callobj.map.setMapType(MAPTYPE_NORMAL);return false;})
$(".r360",tdiv).click(function(){callobj.map.r360.toggle();return false;})
$(".right_switcher",tdiv).click(function(){callobj.map.toggleFullScreen();})}
ControlTypeOverlay.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.className='map_TypeControl';div.innerHTML=$('#map_top_pannel').html();}}
var ControlHelpOverlay=function(map)
{map.bind2MoveEnd(0,0,ControlHelpOverlayhideSelf);controlHelpOverlayInfoSelf();if(controlHelpIsHidden)return[];controlHelpIsHidden=0;if(!ControlHelpOverlayControls)
ControlHelpOverlayControls=[new ControlHelpOverlayItem('typeHelp'),new ControlHelpOverlayItem('servHelp'),new ControlHelpOverlayItem('noHelp')];else{$(".gedMap_help_overlay").show("slow");}
return ControlHelpOverlayControls}
var ControlHelpOverlayItem=function(classhtml)
{var e=$("#_maphelper_overlay_store ."+classhtml);this.inHTML=e.html();this.className=classhtml;}
mapi.extend(ControlHelpOverlayItem,ControlCustomOverlay);ControlHelpOverlayItem.prototype.setPosition=function()
{return true;}
ControlHelpOverlayItem.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.className='gedMap_help_overlay '+this.className;div.innerHTML=this.inHTML;}}
var ControlLoadingHelpOverlay=function()
{}
mapi.extend(ControlLoadingHelpOverlay,ControlCustomOverlay);ControlLoadingHelpOverlay.prototype.setPosition=function()
{return true;}
ControlLoadingHelpOverlay.prototype.onAttach=function()
{var thisobj=this;this.map.ZTile.onRequestingChange=function(cnt)
{if(cnt>0)
thisobj.show(cnt);else
{thisobj.hide();}}}
ControlLoadingHelpOverlay.prototype.show=function(){$(this._div).stop();$(this._div).animate({top:'0'});}
ControlLoadingHelpOverlay.prototype.hide=function(){$(this._div).stop();$(this._div).animate({top:'-30'});}
ControlLoadingHelpOverlay.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.className='state_loader';this.innerHTML="<p>Идет загрузка карты</p>";this.setinnerHTML();}}
var MapDefaultFloater=0;var MapFloatToolTip=function(div,namefunc,floater)
{if(!floater)
{if(!MapDefaultFloater)
{MapDefaultFloater=1;MapDefaultFloater=new MapFloatToolTip(0,0,1);MapDefaultFloater.tearUp();}
floater=MapDefaultFloater;}
this.floatToolDiv_element=0;if(div)
{div._floatNameFunction=namefunc;div.onmousemove=function(event){event=event||window.event;floater.onmouse(event,this);return false;};div.onmouseover=function(event){event=event||window.event;floater.onmouse(event,this);return false;};div.onmouseout=function(){floater.outmouse(this);};}}
MapFloatToolTip.prototype.tearUp=function()
{var div=document.createElement("div");div.style.position="absolute";div.setAttribute('id','map_float_tooltip');div.style.zIndex=20002;div.innerHTML="";div.style.display='none';document.body.appendChild(div);this._tool_div=div;this.lastText='';}
MapFloatToolTip.prototype.outmouse=function(e,obj)
{if(this._tool_div)
{$(this._tool_div).stop();$(this._tool_div).fadeOut("normal");this.fade=1;}}
MapFloatToolTip.prototype.onmouse=function(e,obj)
{if(!this._tool_div)return;var newText=obj._floatNameFunction(obj);if(newText!=this.lastText)
this._tool_div.innerHTML=newText;this.lastText=newText;e=e||window.event;var z=25;var zy=5;var x=e.clientX+z;var y=e.clientY+zy;if(this.fade)
{this.fade=0;$(this._tool_div).stop();$(this._tool_div).fadeIn("fast",function(){$(this).css({opacity:1});});}
if(this._tool_div.style.display!='block')this._tool_div.style.display='block';var df=this.defScroll(x,y);x=df.x;y=df.y;if(x<0)x=e.clientX+z;if(y<0)y=e.clientY+zy;this._tool_div.style.left=(x)+'px';this._tool_div.style.top=(y)+'px'}
MapFloatToolTip.prototype.defScroll=function(x,y){if(document.attachEvent!=null){x=x+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);y=y+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);}else if(!document.attachEvent&&document.addEventListener){x=x+window.scrollX;y=y+window.scrollY;}else{}
return{x:x,y:y};}
var mapDefaultBalloonFrontier=function(innerHTML){return{html:innerHTML};}
function BalloonsOverlay()
{}
var mapBalloon=function(){mapBalloon.superclass.constructor.call(this);}
mapi.extend(mapBalloon,MapPointOverlay);mapBalloon.prototype.modBallonClass=function(a,b){return a;}
mapBalloon.prototype.onInject=function(){if(this.content&&this.content.onAttach)
this.content.onAttach(this.getDiv(),this);if(this.holder&&this.holder.onBalloonAttach)
this.holder.onBalloonAttach(this.getDiv(),this);}
mapBalloon.prototype.close=function(content){this.map.closeBalloon();}
mapBalloon.prototype.saveSelf=function(){this.content.onDettach(this.getDiv(),this);this.setText(this.getDiv().innerHTML);}
mapBalloon.prototype.setContent=function(content){this.content=content;this.setText(content.html);}
mapBalloon.prototype.injectSelf=function(map){}
mapBalloon.prototype.isTransparent=function(){return true;}
mapBalloon.prototype.onclick=function(){return true;}
mapBalloon.prototype.getZIndex=function(){return 80;}
mapBalloon.prototype.positionChanged=function(){}
var mapInnerBalloon=function(){mapInnerBalloon.superclass.constructor.call(this);}
mapi.extend(mapInnerBalloon,mapBalloon);mapInnerBalloon.prototype.injectSelf=function(map){map.addOverlay(this);this.onInject();}
mapInnerBalloon.prototype.dejectSelf=function(map){map.removeOverlay(this);}
var mapOuterBalloon=function(){mapOuterBalloon.superclass.constructor.call(this);}
mapi.extend(mapOuterBalloon,mapBalloon);mapOuterBalloon.prototype.injectSelf=function(map){this.map=map;this.init();document.body.appendChild(this.getDiv());this.onInject();this.onAttach();this.positionChanged();}
mapBalloon.prototype.getZIndex=function(){return 10000;}
mapOuterBalloon.prototype.dejectSelf=function(map){this.remove(true);}
mapOuterBalloon.prototype.positionChanged=function(){this.setPosition();}
mapOuterBalloon.prototype.getDim=function(){var hdim=this.holder.getDim();var cw=this._BalloonWidth?0:this.getDiv().clientWidth;var ch=this._BalloonHeight?0:this.getDiv().clientHeight;if(!cw)cw=this._BalloonWidth;else this._BalloonWidth=cw;if(!ch)ch=this._BalloonHeight;else this._BalloonHeight=ch;return{w:cw,h:ch*2};}
mapOuterBalloon.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.id='map_Balloon_Outer';div.className='gedmap_Balloon gedMap';this.setinnerHTML();this._BalloonWidth=0;this._BalloonHeight=0;}}
mapOuterBalloon.prototype.defScroll=function(x,y)
{if(document.attachEvent!=null){x=x+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);y=y+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);}else if(!document.attachEvent&&document.addEventListener){x=x+window.scrollX;y=y+window.scrollY;}else{}
return{x:x,y:y};}
mapOuterBalloon.prototype.onReposition=function(){this._BalloonWidth=0;this._BalloonHeight=0;this.setPosition();}
mapOuterBalloon.prototype.setPosition=function(){if(!this._div)return;var _this=this;var tl=this.map.fromLatLngToContainerPixel(this.getCenter());var offset=this.map.containerOffset();var cdim=this.map.containerDimensions();var firsttouch=0;if(!this._BalloonWidth)
{var cw=this._div.clientWidth+0;var ch=this._div.clientHeight+0;if(cw&&ch)
{clearTimeout(firsttouch);firsttouch=1;if(this.content.afterTouch){firsttouch=setTimeout(function(){if(_this&&_this.content&&_this.content.afterTouch)
_this.content.afterTouch($(_this._div),_this);},100);}}
if(!cw)cw=this._BalloonWidth;else this._BalloonWidth=cw;if(!ch)ch=this._BalloonHeight;else this._BalloonHeight=ch;}
else{cw=this._BalloonWidth;ch=this._BalloonHeight;}
var dim=this.getDim();var dleft=Math.round(offset.x+tl.x-dim.w/2);var dtop=Math.round(offset.y+tl.y-dim.h/2);if(firsttouch){var scroll=this.defScroll(0,0);var dx=0;var dy=0;if(dleft<10)dx=10-dleft;if(scroll.y>dtop-10){dy=scroll.y-(dtop-10);}
if(dx||dy){var mp=this.map.fromLatLngToContainerPixel(this.map.getPosition());var mdim=this.map.getBounds();var mp2=this.map.fromLatLngToContainerPixel(new mLatLng(mdim.y1,mdim.x2));if(tl.y+dy>mp2.y-20){dy=(mp2.y-20)-tl.y;}
mp.x-=dx;mp.y-=dy;var outPosition=_this.map.fromContainerPixelToLatLng(mp);setTimeout(function(){_this.map.setPosition(outPosition);},500);}}
var left=dleft+'px';var top=dtop+'px';var willfade=0;var isnan=0;if(isNaN(dleft)||isNaN(dtop)){willfade=1;isnan=1;}
if(tl.x<0||tl.y<0||tl.x>cdim.w||tl.y>cdim.h)willfade=1;if(!willfade)
this._div.style.cssText=this.prestyle()+"left:"+left+";top:"+top;if(tl.x<0||tl.y<0||tl.x>cdim.w||tl.y>cdim.h||isnan)
{if(!this.faded){this.faded=1;$(this._div).stop();$(this._div).fadeOut("normal");}}
else
{if(this.faded)
{$(this._div).stop();$(this._div).fadeIn("fast",function(){$(this).css({opacity:1});});this.faded=0;}}
return;}
var mapBalloonRestack=function(){mapBalloonRestack.superclass.constructor.call(this);}
mapi.extend(mapBalloonRestack,mapOuterBalloon);mapBalloonRestack.prototype.getFloatName=function()
{return"";}
mapBalloonRestack.prototype.modBallonClass=function(a,b){return'ball_stack';}
mapBalloonRestack.prototype.onAttach=function()
{return;callobj=this;$(".list a",this._div).click(function(){return false;});$(".list h3",this._div).click(function(){var ref=$(this).attr('title');var id=ref.substr(1);var element=callobj.map.getObject(id);if(element){var view=callobj.map.getEntityView(element.ID_MAP_OBJECT_TYPE);view.setObject(element,callobj.map);var save=view.object.stacked;view.object.stacked=callobj.holder.object.stacked;view.onclick();view.object.stacked=save;}
return false;});}
mapBalloonRestack.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.id='map_Balloon_reStack';div.className='gedmap_Balloon gedMap';this.setinnerHTML();this._BalloonWidth=0;this._BalloonHeight=0;}}
var mapBalloonSimple=function(){mapBalloonSimple.superclass.constructor.call(this);}
mapi.extend(mapBalloonSimple,mapInnerBalloon);mapBalloonSimple.prototype.getDim=function(){return{w:this._div.clientWidth*0.5,h:(this._div.clientHeight*2)+this.holder.getDim().h};}
mapBalloonSimple.prototype.getFloatName=function()
{return"";}
mapBalloonSimple.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.id='map_Balloon_reStack';this.setinnerHTML();}}
var gedMapPointOverlay_tear=0;function gedMapPointOverlay()
{if(!gedMapPointOverlay_tear)
{this.tear();return new gedMapPointOverlay();}
return this;}
gedMapPointOverlay.prototype.tear=function(){gedMapPointOverlay_tear=1;mapi.extend(gedMapPointOverlay,MapPointOverlay);gedMapPointOverlay.prototype.getBalloonFrontier=function(){return gedBalloonTemplateFrontier;}
gedMapPointOverlay.prototype.getBalloonStyle=function(){return mapOuterBalloon;}
gedMapPointOverlay.prototype.htmlUnRollStack=function(event,elsewrap,includeSelf){var set=[];var element;var list=this.object.stacked.slice(0);var objects=this.map.ZTile.dirrectAccess();if(includeSelf)
set.push(this.object);while((element=list.shift()))
{if(!includeSelf&&objects[element]==this.object)
continue;set.push(objects[element]);}
set.sort(function(a,b){return a.ID_MAP_OBJECT_TYPE-b.ID_MAP_OBJECT_TYPE;});var typeDrivers=[];var view=0;var result='';while((element=set.shift()))
{if(!typeDrivers[element.ID_MAP_OBJECT_TYPE])
typeDrivers[element.ID_MAP_OBJECT_TYPE]=this.map.getEntityView(element.ID_MAP_OBJECT_TYPE);view=typeDrivers[element.ID_MAP_OBJECT_TYPE];view.setObject(element);var name=view.getBalloonTitle();if(elsewrap){result+='<div class="else">'+name+"</div>";result+="<div class='nextcontent'></div>";}
else result+=name;}
return result;}
gedMapPointOverlay.prototype.getDivClassName=function(){return'mapMarker';}
gedMapPointOverlay.prototype.getMarkerAttach=function(){return{x:17,y:31}};gedMapPointOverlay.prototype.getreStackAttach=function(){if(this.allStackedInOne())
return{x:14,y:36}
return{x:18,y:18}};gedMapPointOverlay.prototype.getreStackCode=function(){if(this.allStackedInOne())
return"<img class='pngFix' src='/skin/ged4/img/map/stackHouse.png'>";else return"<img class='pngFix' src='/skin/ged4/img/map/zoomStack.png'>";}
gedMapPointOverlay.prototype.ucFirst=function(text){var f=text.charAt(0).toUpperCase();return f+text.substr(1);}
gedMapPointOverlay.prototype.getContentPhoto=function(adclass,adfield,postfix,sizes){if(!adfield)adfield=this.object.icon;if(!adfield)adfield=this.object.pic;if(adfield)adfield=adfield+postfix;if(!adfield)adfield="/skin/ged4/img/map/noimage.jpg";postfix=postfix||'';var isizes='';var ssizes='';if(sizes){if(sizes.w){isizes+="width='"+sizes.w+"' ";ssizes+="width:"+sizes.w+"px;";}
if(sizes.h){isizes+="height='"+sizes.h+"' ";ssizes+="height:"+sizes.h+"px;";}}
if(ssizes)ssizes="style='"+ssizes+";display:block'";if(adfield){return'<div class="photo '+adclass+'">'+'<div class="frameT"><i></i></div>'+'<a href="'+this.getLinkRef()+'" target="_blank" '+ssizes+'><img alt="" src="'+adfield+'" '+isizes+'/></a>'+'<div class="frameB"><i></i></div>'+'</div>';}
return'';}
gedMapPointOverlay.prototype.formatCost=function(cost){cost=""+Math.round(cost)+"";var l=cost.length;var result='';for(i=l;i>0;i-=3){var off=i>3?3:i;result=" "+cost.substr(i-off,off)+result;}
return result.substr(1);}
gedMapPointOverlay.prototype.formatDistance=function(dist){return this.formatCost(dist)+" м.";}
gedMapPointOverlay.prototype.getContentDistance=function(pclass){pclass=pclass||'';if(pclass)pclass="class='"+pclass+"'";if(this.object.DIST_METRO)
return"<p "+pclass+">До метро: <em>"+this.formatDistance(this.object.DIST_METRO)+"</em></p>";return'';}
gedMapPointOverlay.prototype.getStackedTitle=function(cnt){var cntAdv=0;var cntPOI=0;var cntPhoto=0;var objects=this.map.ZTile.dirrectAccess();var sta=this.object.stacked;var obj=this.object;if(obj.ID_POI)cntPOI++;else if(obj.ID_ADVERT)cntAdv++;else cntPhoto++;for(var i=0;i<sta.length;i++)
{var idx=sta[i];obj=objects[idx];if(obj.ID_POI)cntPOI++;else if(obj.ID_ADVERT)cntAdv++;else cntPhoto++;}
var ret='';if(cntAdv)ret+="Предложений: "+cntAdv;if(cntPOI){if(ret)ret+="<br />";ret+="Инфраструктура: "+cntPOI;}
if(cntPhoto){if(ret)ret+="<br />";ret+="Фотографий: "+cntPhoto;}
return ret;}}
var gedBallonOverride=function(object,callobj,balloon){var ref=$(object).attr('name');if(!ref)return;var id=ref.substr(1);var element=callobj.map.getObject(id);if(element){var view=callobj.map.getEntityView(element.ID_MAP_OBJECT_TYPE);view.setObject(element,callobj.map);$("div:first",balloon).get(0).className="mapBalloon "+view.getBallonClasses();var thisref=$(object).parent();var innerText=$(object).parent().next();if(!callobj.lastSlideElement||innerText.get(0)!=callobj.lastSlideElement.get(0)){$(".mapBalloonContent",balloon).css({height:''});$(".mapBalloonTail em",balloon).css({position:'relative'});$("h3",thisref).unbind('click');$("h3 a",thisref).unbind('click');if(callobj.lastInRef){$("h3 a",callobj.lastInRef).click(function(){return gedBallonOverride($(this).parents("h3:first"),callobj,balloon,'clicka');});$("h3",callobj.lastInRef).click(function(){return gedBallonOverride(this,callobj,balloon);});callobj.lastInRef.click(function(){return gedBallonOverride(callobj.lastInRef.parents("h3:first"),callobj,balloon,'clicka');});}
callobj.lastInRef=thisref;innerText.html(view.getInnerBalloonData());var touch=callobj.content.afterTouch;callobj.content.afterTouch=0;innerText.css({display:'block',position:'relative',left:'-999999px'});if(callobj.lastSlideElement)callobj.lastSlideElement.css({display:'none'});$(".mapBalloonContent",balloon).css({height:$(".mapBalloonContent",balloon).get(0).clientHeight+'px'});innerText.css({position:'static',left:'0px'});if(callobj.lastSlideElement)
{callobj.lastSlideElement.css({display:''});var slideElement=callobj.lastSlideElement;setTimeout(function(){slideElement.slideUp('')},1);}
innerText.css({display:'none'});callobj.lastSlideElement=innerText;callobj.onReposition();innerText.slideDown();callobj.onReposition();}}
return false;}
var gedBalloonTemplateFrontier=function(innerHTML,classes){classes=classes||'';var touchfunction=function(object,callobj){$(".mapBalloonTail em",object).css({position:'absolute'});}
var detouchfunction=function(object,callobj){$(".mapBalloonTail em",object).css({position:'relative'});}
var attachfunction=function(object,callobj){$(".mapBalloonClose",object).click(function(){callobj.close();return false;});$(".list h3 a",this._div).click(function(){return gedBallonOverride($(this).parents("h3:first"),callobj,object,'clicka');});$(".list h3",this._div).click(function(){return gedBallonOverride(this,callobj,object);});if($(".list div.else",this._div).length>8){$("div.list",this._div).addClass("scrollable");}};var htmlmask='<div class="mapBalloon '+classes+'">'+'<div class="mapBalloonFrameT"><div><i></i></div></div>'+'<a href="#" class="mapBalloonClose" title="Закрыть"></a>'+'<div class="mapBalloonContent">'+
innerHTML+'</div>'+'<div class="mapBalloonFrameB"><div><i></i></div></div>'+'<div class="mapBalloonTail"><em></em></div>'+'</div>';return{onAttach:attachfunction,onDettach:detouchfunction,html:htmlmask,afterTouch:touchfunction};}
var ID_POI_TO_ICON=[];ID_POI_TO_ICON[10133774]="animals";ID_POI_TO_ICON[10133775]="leisure";ID_POI_TO_ICON[10133777]="auto";ID_POI_TO_ICON[10133768]="shopping";ID_POI_TO_ICON[10133772]="health";ID_POI_TO_ICON[10133778]="beauty";ID_POI_TO_ICON[10133766]="offices";ID_POI_TO_ICON[10133767]="food";ID_POI_TO_ICON[10133776]="cafes";ID_POI_TO_ICON[10133769]="kindergarten";ID_POI_TO_ICON[10133770]="school";ID_POI_TO_ICON[10133771]="universities";ID_POI_TO_ICON[10133765]="services";ID_POI_TO_ICON[10133773]="pharmacies";ID_POI_TO_ICON[124680458]="mail";ID_POI_TO_ICON[124680525]="sport";ID_POI_TO_ICON[124680457]="sberbank";ID_POI_TO_ICON[124680456]="hotels";ID_POI_TO_ICON[124680459]="culture";var ID_POI_TO_LAYER=[];ID_POI_TO_LAYER[10133774]="32";ID_POI_TO_LAYER[10133775]="23";ID_POI_TO_LAYER[10133777]="16";ID_POI_TO_LAYER[10133768]="27";ID_POI_TO_LAYER[10133772]="26";ID_POI_TO_LAYER[10133778]="24";ID_POI_TO_LAYER[10133766]="19";ID_POI_TO_LAYER[10133767]="29";ID_POI_TO_LAYER[10133776]="30";ID_POI_TO_LAYER[10133769]="22";ID_POI_TO_LAYER[10133770]="33";ID_POI_TO_LAYER[10133771]="20";ID_POI_TO_LAYER[10133765]="31";ID_POI_TO_LAYER[10133773]="26";ID_POI_TO_LAYER[124680458]="28";ID_POI_TO_LAYER[124680525]="2";ID_POI_TO_LAYER[124680457]="18";ID_POI_TO_LAYER[124680456]="21";ID_POI_TO_LAYER[124680459]="25";var MapLayerPOI_tear=0;var MapLayerPOI=function()
{if(!MapLayerPOI_tear)
{this.tear();return new MapLayerPOI();}
return this;}
var MapPOILayerView=0;MapLayerPOI.prototype.tear=function(){MapLayerPOI_tear=1;mapi.extend(MapLayerPOI,MapLayerOverlayed);MapLayerPOI.prototype.canHandle=function(layerId)
{if(layerId==1)return true;return false;}
MapLayerPOI.prototype.driveEntity=function(entityId)
{if(entityId==2)return true;return false;}
MapLayerPOI.prototype.getView=function()
{return new MapPOILayerView();}
MapLayerPOI.prototype.preprocessObject=function(object,lid,map)
{object.dim={w:32,h:32};}
MapPOILayerView=function(){MapPOILayerView.superclass.constructor.call(this);}
mapi.extend(MapPOILayerView,gedMapPointOverlay);MapPOILayerView.prototype.getDim=function(){return this.object.dim;}
MapPOILayerView.prototype.rewriteObjectDimensions=function()
{this.object.dim=this.getDim();}
MapPOILayerView.prototype.getFloatName=function()
{return this.ucFirst(this.object.HINT);}
MapPOILayerView.prototype.getLinkRef=function(){return"/information/addresses/"+this.object.ID_REGION+"/"+this.object.ID_POI_GROUP+"/"+this.object.ID_POI_RUBRIC+"/"+this.object.ID_POI+"/";}
MapPOILayerView.prototype.getIconClassName=function(){var l=this.object.maxLayer;;if(ID_POI_TO_LAYER[this.object.ID_POI_GROUP])
l=ID_POI_TO_LAYER[this.object.ID_POI_GROUP];return"ml_"+l;}
MapPOILayerView.prototype.getBalloonTitle=function(){return"<h3 class='POIType simple POI' name='m"+this.object.ID_MAP_OBJECT+"'>"+"<div class='mapMarker'><i class='"+this.getIconClassName()+"'></i></div>"+"<span><a href='"+this.getLinkRef()+"' target='_blank'>"+this.getFloatName()+"</a> - "+
this.ucFirst(this.object.POI_RUBRIC_NAME)+"</span></h3>";}
MapPOILayerView.prototype.getInnerBalloonData=function(){var ret="<div class='about'>";ret+=this.getContentPhoto('house',this.object.img,'',{w:160,h:120});ret+=this.getContentDistance();ret+="</div>";ret+="<p class='detailInfo'><a href='"+this.getLinkRef()+"' target='_blank'>Подробная информация</a>";ret+="<dl class='address'><dt>Адрес:</dt><dd>"+this.object.ADDRESS_FULL+"</dd></dl>";if(this.object.PHONE)
ret+='<dl class="phone"><dt>Телефон:</dt><dd>'+this.object.PHONE+'</dd></dl>';return ret;}
MapPOILayerView.prototype.getBalloonHTML=function(){var ret=this.getBalloonTitle();ret+=this.getInnerBalloonData();ret+="<div class='list'>"+this.htmlUnRollStack(false,true,false)+"</div>";return ret;}
MapPOILayerView.prototype.getBallonClasses=function(){return'ball_poi';}
MapPhotoLayerView.prototype.getDivClassName=function(){return'mapMarker poiMarker';}
MapPOILayerView.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.id='mlv_poi_'+this.object.ID_MAP_OBJECT;div.className=this.getDivClassName();this.innerHTML="<i class='"+this.getIconClassName()+"'></i>";this.setinnerHTML();this.floatToolTip=new MapFloatToolTip(this.getDiv(),function(obj){return obj.upobj.FloatName();});}}}
var MapLayerAdverts_tear=0;var MapLayerAdverts=function(){if(!MapLayerAdverts_tear)
{this.tear();return new MapLayerAdverts();}
MapLayerAdverts.superclass.constructor.call(this);return this;}
var MapAdvertsLayerView=0;MapLayerAdverts.prototype.tear=function(){MapLayerAdverts_tear=1;mapi.extend(MapLayerAdverts,MapLayerOverlayed);MapLayerAdverts.prototype.canHandle=function(layerId)
{if(layerId==9)return true;return false;}
MapLayerAdverts.prototype.driveEntity=function(entityId)
{if(entityId==1)return true;return false;}
MapLayerAdverts.prototype.getView=function()
{return new MapAdvertsLayerView();}
MapLayerAdverts.prototype.preprocessObject=function(object,lid,map)
{object.dim={w:40,h:40};}
MapAdvertsLayerView=function()
{MapAdvertsLayerView.superclass.constructor.call(this);}
mapi.extend(MapAdvertsLayerView,gedMapPointOverlay);MapAdvertsLayerView.prototype.getDim=function(){return this.object.dim;}
MapAdvertsLayerView.prototype.rewriteObjectDimensions=function()
{this.object.dim=this.getDim();}
MapAdvertsLayerView.prototype.decodeType=function()
{var type=this.object.ID_RLTTYPE;switch(''+type)
{case'1':return'жилая';case'2':return'комерческая';case'3':return'элитная';case'4':return'загородная';default:return'';}}
MapAdvertsLayerView.prototype.decodeVariant=function()
{return this.object.OBJTYPE_NAME+(this.object.ROOM_QTY?(", "+this.object.ROOM_QTY+" кмн"):"");}
MapAdvertsLayerView.prototype.decodeTypeToClass=function()
{var type=this.object.ID_RLTTYPE;switch(''+type)
{case'1':return'mtrealty';case'2':return'commercial';case'3':return'elite';case'4':return'country';default:return'mtrealty';}}
MapAdvertsLayerView.prototype.decodeAddr=function()
{var addr=this.object.ADDRESS3.split('|');var ret=addr[0];if(addr[1])
ret+=", "+addr[1];return ret;}
MapAdvertsLayerView.prototype.getFloatName=function()
{addr=this.ucFirst(this.decodeAddr());return this.ucFirst((this.object.ID_AD_TYPEOP==2?"Аренда":"Продажа")+", "+this.decodeVariant())+" - "+addr;}
MapAdvertsLayerView.prototype.getLinkRef=function(){if(this.object.URL)return this.object.URL;var type='';if(this.object.ID_RLTTYPE=='1')type='living/';else type=this.decodeTypeToClass()+'/';return"/obj/"+type+this.object.ID_ADVERT+"/";}
MapAdvertsLayerView.prototype.getBalloonTitle=function(){var name=this.ucFirst((this.object.ID_AD_TYPEOP==2?"Аренда":"Продажа")+", "+this.decodeVariant()+(this.object.FULLSQUARE?(", "+this.object.FULLSQUARE+"м<sup>2</sup>"):"")
+(this.object.FLOOR?(", "+this.object.FLOOR+"-й этаж"):""));return"<h3 class='realtyType "+(this.object.ID_AD_TYPEOP==2?"rentType":"")+"' name='m"+this.object.ID_MAP_OBJECT+"'>"+"<i class='"+this.decodeTypeToClass()+"'></i>"+"<span><a href='"+this.getLinkRef()+"' target='_blank'>"+name+"</a></span></h3>";}
MapAdvertsLayerView.prototype.getBallonClasses=function(){return'ball_realty';}
MapAdvertsLayerView.prototype.getContentInfo=function(){var ret="<p>";if(this.object.BLDYEAR)
ret+="Год постройки: "+this.object.BLDYEAR+"<br />";if(this.object.FLOOR_QTY)
ret+="Этажей: "+this.object.FLOOR_QTY+"<br />";ret+="</p>";return ret;}
MapAdvertsLayerView.prototype.getContentServices=function(){var ret='<div class="services houseServicesBox">';var _this=this;function href(more){return"<a href='"+_this.getLinkRef()+"#"+more+"' target='_blank' ";}
if(this.object.IS_SPHEREPHOTO)ret+=href('tab_russia360_tab')+' title="наличие россии 360" class="service_1"></a>';else ret+="<div></div>";if(this.object.IS_PHOTO)ret+=href('house_photos')+' title="есть фотографии дома" class="service_2"></a>';else ret+="<div></div>";if(this.object.IS_PANORAMA)ret+=href('panoramic')+' title="панорамные фотографии" class="service_3"></a>';else ret+="<div></div>";ret+="<br style='clear:both' />";if(this.object.IS_HISTORY)ret+=href('adverthistory')+' title="история обьявлений" class="service_4"></a>';else ret+="<div></div>";if(this.object.IS_LAYOUT)ret+=href('flatplans')+' title="наличие планировок" class="service_5"></a>';else ret+="<div></div>";if(this.object.IS_BTI)ret+=href('plusservices')+' title="дополнительные сервисы" class="service_6"></a>';else ret+="<div></div>";ret+='</div>';return ret;}
MapAdvertsLayerView.prototype.getKaleva=function(){var place_id='fokon_balloon_'+this.object.ID_BUILDING+'_'+Math.floor(Math.random()*(10000));var cnt=this.object.CNT_KALEVA_WINDOWS;var banner_url=GED_ROTATOR_URL+'/rotator/?place=62&t_region='+this.object.ID_REGION
+'&t_country='+this.object.ID_COUNTRY+'&mode=jquery&selector='+place_id;var fileref=document.createElement("script");fileref.type="text/javascript";fileref.src=banner_url;document.getElementsByTagName("head")[0].appendChild(fileref);if(cnt>0)
{var fn=function(){var wrapper=$('#'+place_id);if($('div.fOkonBalloon',wrapper).length==0)
{setTimeout(fn,50);return;}
var windows_str=getCountVal(cnt*1,['окно','окна','окон']);$('.quantity span',wrapper).text(''+cnt+' '+windows_str+' в этом доме');$('.fOkon_p',wrapper).text('Скидка на следующую установку!');};setTimeout(fn,1);}
return'<div id="'+place_id+'"></div><p style="clear: both"></p>';}
MapAdvertsLayerView.prototype.getAboutContent=function(){return this.getContentPhoto('','','',{w:160,h:120})+
this.getKaleva()+
this.getContentDistance()+
this.getContentInfo()+
this.getContentServices();}
MapAdvertsLayerView.prototype.getPriceList=function(){if(!this.object.COST_RUR){if(this.object.COST_NATIVE){return"<em>"+this.object.COST_NATIVE+" "+CURRENCY_NATIVE+"</em>"}
else return this.getPriceListM2();}
return"<em>"+this.formatCost(this.object.COST_RUR)+" р.</em><br />"+"<span>~"+this.formatCost(this.object.COST_DOLLAR)+" $</span><br />"+"<span>~"+this.formatCost(this.object.COST_EURO)+" €</span>"+"";}
MapAdvertsLayerView.prototype.getPriceListM2=function(){if(!this.object.PRICE_M2_RUR){if(this.object.PRICE_M2_NATIVE){return"<em>"+this.object.PRICE_M2_NATIVE+" "+CURRENCY_NATIVE+"</em>"}
else return"<em>цена договорная</em>";}
return"<em>"+this.formatCost(this.object.PRICE_M2_RUR)+" р. м<sup>2</sup></em><br />"+"<span>~"+this.formatCost(this.object.PRICE_M2_DOLLAR)+" $</span><br />"+"<span>~"+this.formatCost(this.object.PRICE_M2_EURO)+" €</span>"+"";}
MapAdvertsLayerView.prototype.getInnerBalloonData=function(){var ret="<div class='about'>"+this.getAboutContent()+"</div>"+"<p class='address'>"+this.object.ADDRESS+"</p>"+"<p class='detail'><a href='"+this.getLinkRef()+"' target='_blank'>Подробная информация</a>"+"<p class='price'>"+this.getPriceList()+"</p>";return ret;}
MapAdvertsLayerView.prototype.getBalloonHTML=function(){var ret=this.getBalloonTitle();ret+=this.getInnerBalloonData();ret+="<div class='list'>"+this.htmlUnRollStack(false,true,false)+"</div>";return ret;}
MapAdvertsLayerView.prototype.getDivClassName=function(){return' realtyMarker'+(this.object.ID_AD_TYPEOP==2?" rent":"");}
MapAdvertsLayerView.prototype.getMarkerAttach=function(){return{x:10,y:10}};MapAdvertsLayerView.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.id='mlv_advert_'+this.object.ID_MAP_OBJECT;div.className=this.getDivClassName();this.loadimg_src=this.object.icon;this.loadimg_src='/skin/ged4/img/ico/agency.gif';this._div=div;this.innerHTML="<i class='"+this.decodeTypeToClass()+"'></i>";this.setinnerHTML();this.floatToolTip=new MapFloatToolTip(this.getDiv(),function(obj){return obj.upobj.FloatName()});}}}
var MapLayerPhotos_tear=0;var MapBizLayerView=0;var MapLayerPhotos=function()
{if(!MapLayerPhotos_tear)
{this.tear();return new MapLayerPhotos();}
return this;}
var MapPhotoLayerView=0;MapLayerPhotos.prototype.tear=function(){MapLayerPhotos_tear=1;mapi.extend(MapLayerPhotos,MapLayerOverlayed);MapLayerPhotos.prototype.canHandle=function(layerId)
{if(layerId==6||layerId==7||layerId==8||layerId==44||layerId==45||layerId==46){return true;}
else{return false;}}
MapLayerPhotos.prototype.driveEntity=function(entityId)
{if(entityId==3||entityId==4||entityId==5)return true;return false;}
MapLayerPhotos.prototype.getView=function(entityId){if(entityId==5){return new MapBizLayerView();}
return new MapPhotoLayerView();}
MapLayerPhotos.prototype.preprocessObject=function(object,lid,map)
{if(object.small){object.dim={w:18,h:16};}else{object.dim={w:37,h:35};}}
MapPhotoLayerView=function(){MapPhotoLayerView.superclass.constructor.call(this);}
mapi.extend(MapPhotoLayerView,gedMapPointOverlay);MapPhotoLayerView.prototype.getDim=function(){return{w:0,h:0}}
MapPhotoLayerView.prototype.rewriteObjectDimensions=function()
{this.object.dim={x:27,y:35};}
MapPhotoLayerView.prototype.getFloatName=function()
{return(this.object.maxLayer==8?"Панорама":"Фото")+":"+this.object.STREET_FULLNAME+", д."+this.object.NUM;}
MapPhotoLayerView.prototype.getLinkRef=function(){if(this.object.targetUrl){return this.object.targetUrl;}
return"/house/"+this.object.region_code+"/"+this.object.ID_BUILDING+"/";}
MapPhotoLayerView.prototype.getBalloonTitle=function(){var more='';if(this.object.maxLayer==8)more='- панорама';return"<h3 class='realtyType simple photo_in_it' name='m"+this.object.ID_MAP_OBJECT+"'>"+"<i class='pict "+(this.object.maxLayer==8?"panorama":"")+"'></i>"+"<span><a href='"+this.getLinkRef()+"' target='_blank'>"+this.ucFirst(this.object.STREET_FULLNAME+", д."+this.object.NUM)+"</a> "+more+"</span></h3>";}
MapPhotoLayerView.prototype.getHouseInfo=function(){var ret='';if(this.object.MM_WALL_MATERIAL){ret+="<dt>Тип дома: </dt>";ret+="<dd>"+this.object.MM_WALL_MATERIAL+"<br/></dd>";}
if(this.object.MM_FLOORES){ret+="<dt>Этажей: </dt>";ret+="<dd>"+this.object.MM_FLOORES+"<br/></dd>";}
if(this.object.BLDYEAR){ret+="<dt>Год постройки: </dt>";ret+="<dd>"+this.object.BLDYEAR+"<br/></dd>";}
if(this.object.BLDSERIES_NAME&&this.object.BLDSERIES_NAME!='нет данных'){ret+="<dt>Серия: </dt>";ret+="<dd>"+this.object.BLDSERIES_NAME+"<br/></dd>";}
if(!ret){ret+="<dt>Информация о доме: </dt>";ret+="<dd>отсуствует<br/></dd>";}
if(ret){ret='<dl class="houseInfo">'+ret;ret+="</dl>";}
return ret;}
MapPhotoLayerView.prototype.getKaleva=function(position){if(position=='center')
return'';var place_id='fokon_balloon_'+this.object.ID_MAP_OBJECT;var cnt=this.object.CNT_KALEVA_WINDOWS;var banner_url=GED_ROTATOR_URL+'/rotator/?place=62&t_region='+this.object.ID_REGION
+'&t_country='+this.object.ID_COUNTRY+'&mode=jquery&selector='+place_id;var fileref=document.createElement("script");fileref.type="text/javascript";fileref.src=banner_url;document.getElementsByTagName("head")[0].appendChild(fileref);if(cnt>0)
{var fn=function(){var wrapper=$('#'+place_id);if($('div.fOkonBalloon',wrapper).length==0)
{setTimeout(fn,50);return;}
var windows_str=getCountVal(cnt*1,['окно','окна','окон']);$('.quantity span',wrapper).text(''+cnt+' '+windows_str+' в этом доме');$('.fOkon_p',wrapper).text('Скидка на следующую установку!');};setTimeout(fn,1);}
return'<div id="'+place_id+'"></div>';}
MapPhotoLayerView.prototype.getInnerBalloonData=function(){var ret="<div class='about'>";if(this.object.maxLayer==8)
ret+="<h4>Сферическая сьемка</h4>";if(this.object.maxLayer==8)
ret+=this.getContentPhoto("panorama",this.object.img,'',{w:571,h:80});else{ret+=this.getContentPhoto("house",this.object.img,'',{w:160,h:120});ret+=this.getKaleva("right");}
ret+="</div>";ret+="<p class='detail'><a href='"+this.getLinkRef()+"' target='_blank'>Подробная информация</a>";ret+="<h4 class='spec'><div style='width:140px;float:left;padding-right:5px'>"+this.object.BUILDINGTYPE+"</div>";if(this.object.maxLayer==8){ret+=this.getKaleva("center");}
ret+="</h4>";ret+=this.getContentDistance('distance');ret+=this.getHouseInfo();return ret;}
MapPhotoLayerView.prototype.getBalloonHTML=function(){var ret=this.getBalloonTitle();ret+=this.getInnerBalloonData();ret+="<div class='list'>"+this.htmlUnRollStack(false,true,false)+"</div>";return ret;}
MapPhotoLayerView.prototype.getBallonClasses=function(){if(this.object.maxLayer==8)
return'ball_panorama';else
return'ball_photo';}
MapPhotoLayerView.prototype.getDivClassName=function(){return'mapMarker';}
MapPhotoLayerView.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.id='mlv_photo_'+this.object.ID_MAP_OBJECT;this.innerHTML='<div><i class="pict '+(this.object.maxLayer==8?"panorama":"")+'"></i></div>';this.setinnerHTML();this.floatToolTip=new MapFloatToolTip(this.getDiv(),function(obj){return obj.upobj.FloatName()});}}
MapBizLayerView=function(){MapBizLayerView.superclass.constructor.call(this);}
mapi.extend(MapBizLayerView,MapPhotoLayerView);MapBizLayerView.prototype.getFloatName=function(){return this.object.OBJ_NAME;}
MapBizLayerView.prototype.getBalloonTitle=function(){var more='';return"<h3 class='realtyType' name='m"+this.object.ID_MAP_OBJECT+"'>"+"<i class='ml_46 bl'></i>"+"<span><a href='"+this.getLinkRef()+"' target='_blank'>"+this.getFloatName()+"</a> "+more+"</span></h3>";}
MapBizLayerView.prototype.getHouseInfo=function(){var ret='';if(this.object.STREET_FULLNAME){ret+="<dt>Адрес: </dt>";ret+="<dd>"+this.object.STREET_FULLNAME;if(this.object.NUM){ret+=", "+this.object.NUM;}
ret+="<br/></dd>";}
if(this.object.BC_CLASS){ret+="<dt>Класс : </dt>";ret+="<dd>"+this.object.BC_CLASS+"<br/></dd>";}
if(this.object.FULLSQUARE){ret+="<dt>Площадь : </dt>";ret+="<dd>"+this.formatCost(this.object.FULLSQUARE)+" м<sup>2</sup><br/></dd>";}
if(this.object.YEAR_OPER){ret+="<dt>Открыто в : </dt>";ret+="<dd>"+this.object.YEAR_OPER+"<br/></dd>";}
if(this.object.MM_FLOORES){ret+="<dt>Этажей: </dt>";ret+="<dd>"+this.object.MM_FLOORES+"<br/></dd>";}
if(this.object.PARKING){ret+="<dt>Парковка : </dt>";ret+="<dd>"+this.object.PARKING+"<br/></dd>";}
if(this.object.ZONE){ret+="<dt>Зона: </dt>";ret+="<dd>"+this.object.ZONE+"<br/></dd>";}
if(!ret){ret+="<dt>Информация: </dt>";ret+="<dd>отсуствует<br/></dd>";}
if(ret){ret='<dl class="houseInfo">'+ret;ret+="</dl>";}
return ret;}
MapBizLayerView.prototype.getInnerBalloonData=function(){var ret="<div class='about'>";ret+=this.getContentPhoto("house",this.object.img,'',{w:160,h:120});ret+=this.getKaleva("right");ret+="</div>";this.object.BUILDINGTYPE=(this.object.maxLayer==47)?'Торговый центр':'Бизнес центр';this.object.DIST_METRO=this.object.DIST2METRO*1000;ret+="<p class='detail'><a href='"+this.getLinkRef()+"' target='_blank'>Подробная информация</a>";ret+="<h4 class='spec'><div style='width:140px;float:left;padding-right:5px'>"+this.object.BUILDINGTYPE+"</div>";ret+="</h4>";ret+=this.getContentDistance('distance');ret+=this.getHouseInfo();return ret;}
MapBizLayerView.prototype.getBalloonHTML=function(){var ret=this.getBalloonTitle();ret+=this.getInnerBalloonData();ret+="<div class='list'>"+this.htmlUnRollStack(false,true,false)+"</div>";return ret;}
MapBizLayerView.prototype.getDivClassName=function(){var more='';if(this.layerToClass()>46){more=" extendBL";}
return'realtyMarker'+more;}
MapBizLayerView.prototype.layerToClass=function(){var ret=this.object.maxLayer;switch(this.object.BC_CLASS){case'A+':return 50;case'A':return 49;case'A-':return 51;case'B+':return 53;case'B':return 52;case'C':return 54;}
return ret;}
MapBizLayerView.prototype.getIconClassName=function(){return"bl ml_"+this.layerToClass();}
MapBizLayerView.prototype.getMarkerAttach=function(){if(this.object.maxLayer>46){return{x:17,y:12}}
return{x:10,y:11}};MapBizLayerView.prototype.init=function(mapApi)
{if(!this._div)
{var div=0;div=this.createDiv();div.id='mlv_photo_'+this.object.ID_MAP_OBJECT;this.innerHTML='<i class="'+this.getIconClassName()+'"></i>';this.setinnerHTML();this.floatToolTip=new MapFloatToolTip(this.getDiv(),function(obj){return obj.upobj.FloatName()});}}}
var SparseTileLayerOverlay_tear=0;var SparseTileLayerOverlay=function(){if(!SparseTileLayerOverlay_tear)
{this.tear();return new SparseTileLayerOverlay();}else
{this.loop=0;this.isActive=0;}}
SparseTileLayerOverlay.prototype.tear=function()
{SparseTileLayerOverlay_tear=1;SparseTileLayerOverlay.prototype=new google.maps.OverlayView;SparseTileLayerOverlay.prototype.setUrl=function(xy,z){return[];}
SparseTileLayerOverlay.prototype.loaded=function(e)
{e=window.event?window.event.srcElement:e.currentTarget;e.loaded=1;e.failed=0;e.style.display="";}
SparseTileLayerOverlay.prototype.failed=function(e)
{e=window.event?window.event.srcElement:e.currentTarget;e.loaded=0;e.failed=1;e.style.display="none";}
SparseTileLayerOverlay.prototype.idle=function(){this.redraw();}
SparseTileLayerOverlay.prototype.draw=function(){this.redraw();}
SparseTileLayerOverlay.prototype.show=function(){this.isActive=1;if(this.L)this.L.style.display='block';}
SparseTileLayerOverlay.prototype.hide=function(){this.isActive=0;if(this.L)this.L.style.display='none';}
SparseTileLayerOverlay.prototype.pushTo=function(e,a)
{if(window.XMLHttpRequest)
{e.style.display="none";e.loaded=0;e.failed=0;e.onload=this.loaded;e.onerror=this.failed;e.src=a;}
else
{e.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a+"',sizingMethod='scale')";e.style.display="";e.src=a;}}
SparseTileLayerOverlay.prototype.redraw=function()
{try{var a,b,c,d,e,f,g,h,i,j,k,l,o,p,q,r,s,t,u,v,w,x,y,z,iil;var X$=0,Y$=0,X_=0,Y_=0,X0=0,X1=0,Y0=0,Y1=0;var offset=268435456;var radius=offset/Math.PI;function LToX(x){return Math.round(offset+radius*x*Math.PI/180);}
function LToY(y){return Math.round(offset-radius*Math.log((1+Math.sin(y*Math.PI/180))/(1-Math.sin(y*Math.PI/180)))/2);}
function XToL(x){return((Math.round(x)-offset)/radius)*180/Math.PI;}
function YToL(y){return(Math.PI/2-2*Math.atan(Math.exp((Math.round(y)-offset)/radius)))*180/Math.PI;}
function LLToXY(w,z){return{x:LToX(w.x)>>(21-z),y:LToY(w.y)>>(21-z)};}
function XYToLL(w,z){return{x:XToL(w.x<<(21-z)),y:YToL(w.y<<(21-z))};}
w=this.getMap();u=this.getPanes();if(!u||!u.overlayLayer)return;v=this.getProjection();if(!w)return;if(!u)return;if(!v)return;l=w.getDiv();q=w.getBounds();c=w.getCenter();z=w.getZoom();w=8;q={x:LToX(c.lng())>>(21-z),y:LToY(c.lat())>>(21-z)};c=v.fromLatLngToDivPixel(c);X0=q.x-((l.offsetWidth+1)>>1);X1=q.x+((l.offsetWidth+1)>>1);Y0=q.y-((l.offsetHeight+1)>>1);Y1=q.y+((l.offsetHeight+1)>>1);X$=q.x-c.x;Y$=q.y-c.y;X_=1+((X1-X0)>>w)+1;Y_=1+((Y1-Y0)>>w)+1;X0=X0>>w;X1=X0+X_;Y0=Y0>>w;Y1=Y0+Y_;if((z!=this.Z)||(X$!=this.X$)||(Y$!=this.Y$)||(X_!=this.X_)||(Y_!=this.Y_))
{l=this.L;if(l)
{for(i=l.childNodes.length-1;i+1;i--)
{o=l.childNodes[i];l.removeChild(o);}
u.overlayLayer.removeChild(l);l=null;}
l=document.createElement("DIV");l.style.display=this.isActive?"block":"none";if(l)
{u.overlayLayer.appendChild(l);l.style.position="absolute";for(i=0;X_*Y_-i;i++)
{o=document.createElement("DIV");l.appendChild(o);o.style.position="absolute";o.style.width=(1<<w);o.style.height=(1<<w);}}
this.X$=X$;this.Y$=Y$;this.X_=X_;this.Y_=Y_;this.X0=0;this.Y0=0;this.X1=0;this.Y1=0;this.L=l;this.Z=z;}
if((z!=this.Z)+(X0<this.X0)+(Y0<this.Y0)+(X1>this.X1)+(Y1>this.Y1))
{l=this.L;i=(0%X_)*Y_+(0%Y_);var knownset;var keep=0;for(i=l.childNodes.length-1;i+1;i--){e=l.childNodes[i];e.used=0;if(e.tileX>=X0&&e.tileX<X1&&e.tileY>=Y0&&e.tileY<Y1)
{e.used=1;keep++;}}
for(y=Y0;Y1-y;y++)
for(x=X0;X1-x;x++)
{a=this.setUrl({x:x,y:y},z);if(typeof(a)!="object")a=[a];i=((x+X_)%X_)*Y_+((y+Y_)%Y_);o=0;for(iil=l.childNodes.length-1;iil+1;iil--){o=l.childNodes[i];if(o.tileX==x&&o.tileY==y)break;else o=0;}
if(o)
{o.used=1;continue;}
for(iil=l.childNodes.length-1;iil+1;iil--){o=l.childNodes[i];if(!o.used)break;else o=0;}
if(!o)
{break;}
if(o.tileX==x&&o.tileY==y)break;o.used=1;o.tileX=x;o.tileY=y;if(a.length!=o.childNodes.length)
{for(i=o.childNodes.length-1;i+1;i--){e=o.childNodes[i];o.removeChild(e);}
for(i=0;a[i];i++)
{e=document.createElement(window.XMLHttpRequest?"IMG":"DIV");o.appendChild(e);}}
for(i=0;a[i];i++)
{e=o.childNodes[i];e.style.position="absolute";e.style.left=0+"px";e.style.top=0+"px";e.style.width=(1<<w);e.style.height=(1<<w);this.pushTo(e,a[i]);}}
for(i=l.childNodes.length-1;i+1;i--){o=l.childNodes[i];o.style.left=((o.tileX<<w)-X$)+"px";o.style.top=((o.tileY<<w)-Y$)+"px";o.style.width=(1<<w)+"px";o.style.height=(1<<w)+"px";}
this.X0=X0;this.Y0=Y0;this.X1=X1;this.Y1=Y1;this.L=l;this.Z=z;}
this.loop++;}catch(e){}}}
var r360_tear=0;function r360_frame2(divname)
{if(!r360_tear)
{this.tear();return new r360_frame2(divname);}
this.divname=divname;this.divid=$(divname);this.tileLayer=0;this.pointAzimut=0;this.FlashHolder=0;this.isShown=false;this.enabled=false;return this;}
r360_frame2.prototype.tear=function(){r360_tear=1;r360_frame2.prototype=new MapLayerOverlayed();r360_frame2.prototype.onAttach=function(){var thisworker=this;this._clickEvent=this._map.worker.bindClick(function(latlng){thisworker.moveTo(latlng);},this._clickEvent);}
r360_frame2.prototype.moveTo=function(latlng){if(this.enabled)
{this.pointAzimut.setLatLng(latlng);this.Frame2.setPosition(this.pointAzimut);}}
r360_frame2.prototype.canHandle=function(layerId)
{if(layerId=='r360')return true;return false;}
r360_frame2.prototype.driveEntity=function(entityId)
{if(entityId==-1)return true;return false;}
r360_frame2.prototype.toggle=function()
{this.enabled?this.disable():this.enable();}
r360_frame2.prototype.enable=function(layerId)
{this.enabled=true;this.show();return true;}
r360_frame2.prototype.disable=function(layerId){this.enabled=false;this.hide();}
r360_frame2.prototype.onReposition=function(){if(this.Frame2)
this.Frame2.infoWindowReposition();}
r360_frame2.prototype.inshow=function(){this.Frame2.setPosition(this.pointAzimut);}
r360_frame2.prototype.show=function(){if(!this.enabled)return;if(this.isShown)return;this.isShown=true;var _this=this;var newlayer=0;if(!this.tileLayer)
{is_Frame2_Player_Ready=0;this.pointAzimut=new r360_AzimutMarker();this.Frame2=new Frame2Player(this.divid,this._map);this.Frame2.r360parent=this;newlayer=0;this.pointAzimut.setObject(0,this._map);this.pointAzimut.setLatLng(this._map.getPosition());}
this.pointAzimut.setObject(0,this._map);this.tileLayer=new r360TileLayer(this._map);this.pointAzimut.setObject(0,this._map);this.pointAzimut.setLatLng(this._map.getPosition());this._map.onRepositionDiv();this.tileLayer.show();this.pointAzimut.show();$(this.divid,this._map).show('',function(){this._map.onRepositionDiv();_this.inshow();});this.Frame2.setPosition(this.pointAzimut);this._map.onRepositionDiv();return;$(this.divid,this._map).show('normal',function(){_this.inshow();});}
r360_frame2.prototype.hide=function(layerId){if(this.tileLayer)
{this.tileLayer.hide();this.pointAzimut.hide();$(this.divid,this._map).hide();this._map.onRepositionDiv();}
this.isShown=false;}}
var Frame2DefaultPlayer=0;function Frame2Player(parent,map)
{this._map=map;this.fullScreenArea=$('.fullscreenPlayerAttachPoint',parent);this.parent=parent;this.player=0;this.fullScreen=0;this.flashPath='/swf/Russia360_2.swf';this.version='201001272021';this.spheraURL='/map/getSpheraJSON';this.sphereRequestGeneration=0;this.flashWidth='100%';this.flashHeight='100%';this.f2marker=0;this.frame2Map=0;this.frameMode='';this.frameName='Frame2PlayerObject_map';this.infoFrame='.r360info300';this.setPosTimeout=0;this.flashVars={lat:0,lng:0};Frame2DefaultPlayer=this;}
Frame2Player.prototype.getFlashPath=function(){return this.version?(this.flashPath+'?version='+this.version):(this.flashPath);}
Frame2Player.prototype.onSwitchPlayerMode=function(params){if(params.newMode=='fullscreen'){var str=this.getHTML(Frame2.marker,true);this.fullScreenArea.innerHTML=str;this.isFullscreen=true;}
else
if(params.oldMode=='fullscreen'){this.restoreMapSize();this.isFullscreen=false;this.fullScreenArea.innerHTML='&nbsp;';}}
Frame2Player.prototype.getPlayer=function()
{var rset=$('#'+this.frameName,this.fullScreenArea);var sret=rset.get(0);return sret;}
Frame2Player.prototype.syncMaps=function(){if(this.frame2Map){if(this._map.getWorkerName()=='yandex')
this.frame2Map.setYandexMaps();else this.frame2Map.setGoogleMaps();this.frame2Map.setPosition(this._map.getPosition());try{if(this.frame2Map.markerh)
this.frame2Map.markerh.setLatLng(this.f2marker.getCenter());}catch(e){}}}
Frame2Player.prototype.setPosition=function(f2marker){clearTimeout(this.setPosTimeout);this.f2marker=f2marker;var _this=this;var latlng=f2marker.getCenter();if(!latlng)return;if(this.flashVars.lat==latlng.lat()&&this.flashVars.lng==latlng.lng())return;this.flashVars.lat=latlng.lat();this.flashVars.lng=latlng.lng();var player=this.getPlayer();if(!player){is_Frame2_Player_Ready=0;var strset=(this.getHTML(f2marker,this.fullScreen));this.fullScreenArea.get(0).innerHTML='';this.fullScreenArea.get(0).innerHTML=strset;this.getSpheraAdverts(latlng.getLat(),latlng.getLng());this.setPosTimeout=setTimeout(function(){_this.setPosition(f2marker)},50);setTimeout(function(){onPanoramaReady()},3000);}
else
{if(!is_Frame2_Player_Ready){this.setPosTimeout=setTimeout(function(){_this.setPosition(f2marker)},100);return;}
else{this.setPosTimeout=setTimeout(function(){try{var player=_this.getPlayer();_this.getSpheraAdverts(latlng.getLat(),latlng.getLng());var szoom=_this._map.getZoom();if(_this.frame2Map&&_this.frame2Map.mapDivWorkable){szoom=_this.frame2Map.getZoom();}
if(szoom<16)szoom+=2;player.setZoom(szoom);player.moveTo(latlng.getLat(),latlng.getLng());}catch(e){if(window.console)
console.log(e);}},10);}}}
Frame2Player.prototype.onPointReady=function(lat,lng,angle,vangle,zoom){this.f2marker.updatePosition(new mLatLng(lat,lng),angle,vangle);this.flashVars.angle=angle;this.flashVars.vangle=vangle;this.flashVars.lat=lat;this.flashVars.lng=lng;this._map.setPosition(new mLatLng(lat,lng));this.syncMaps();}
Frame2Player.prototype.infoWindowReposition=function()
{var obj=$(this.infoFrame,this.parent);var attach=$(".fullscreenPlayerAttachEnd",this.parent);var point=$(".fullscreenPlayerAttachPoint",this.parent);var offset={left:0,top:point.height()};obj.css({position:'absolute',left:offset.left+attach.width()-obj.width()-18,top:offset.top+attach.height()-obj.height()-17,zIndex:1,opacity:1});}
Frame2Player.prototype.innerMapStart=function(map){var _this=this;if(map.tileLayer){map.tileLayer.hide();delete map.tileLayer;}
map.tileLayer=new r360TileLayer(map);map.tileLayer.show();map.zoomControl('small');map.markerh=new r360_PointMarker();map.markerh.setObject(0,map);map.markerh.setLatLng(map.getPosition());map.markerh.show();this.map_clickEvent=map.worker.bindClick(function(latlng){_this.r360parent.moveTo(latlng);map.setPosition(latlng);map.markerh.setLatLng(latlng);},this.map_clickEvent);}
Frame2Player.prototype.infoFrameText=function(text){var mapplace='';var _this=this;this.lastInfoText=text;if(this.frameMode=='middle')
{mapplace=1;}
var thisbox=$(this.infoFrame,this.parent);if(text||mapplace){if(!thisbox.html())
{thisbox.html("<div class='content300'></div>"+"<div class='contentmap'>"+"<h4 class='miniMap'>Карта</h4><p>Данная карта облегчает перемещение в пространстве</p>"+"<div id='frame2contentmap_up'><div id='frame2contentmap'></div></div></div>");}
if(mapplace&&!this.frame2Map){this.frame2Map=new MapWorker('frame2contentmap','gedMapSmall');this.frame2Map.useAbsoluteMapDiv=1;this.frame2Map.tileLayer=0;this.frame2Map.traceSelfToLocation=0;this.frame2Map.onChangeLocation=function(){};this.frame2Map.setZoom(15);this.frame2Map.setParanoicReposition(1);this.syncMaps();setTimeout(function(){_this.frame2Map.tearUp();_this.frame2Map.onStateInit(function(map){_this.innerMapStart(map);});_this.frame2Map.activate();},1);}
if(!mapplace&&this.frame2Map){this.frame2Map.tearDown();delete this.frame2Map;this.frame2Map=0;}
$(".content300",thisbox).html(text);if(mapplace){$(".contentmap",thisbox).show();}
else
$(".contentmap",thisbox).hide();thisbox.show();this.infoWindowReposition();}
else
thisbox.hide();}
Frame2Player.prototype.getSpheraAdverts=function(lat,lng)
{var advertsObjects=new Array();var _this=this;var obj=$(this.infoFrame,this.parent);this.sphereRequestGeneration++;var thisGen=this.sphereRequestGeneration;$.getJSON(this.spheraURL,{x:lat,y:lng,seq:thisGen},function(data)
{if(thisGen!=_this.sphereRequestGeneration){return false;}
advertsObjects["ADVERTS"]=new Array();if(data.ADVERTS!=undefined)
{advertsObjects["ADVERTS"]=data.ADVERTS;var outInfoHtml="";var lastInfoObj=0;for(var j in advertsObjects["ADVERTS"])
{if(lastInfoObj!=advertsObjects["ADVERTS"][j]['ID_OBJTYPE'])
{lastInfoObj=advertsObjects["ADVERTS"][j]['ID_OBJTYPE'];}
outInfoHtml+="<li><a href=\""+advertsObjects["ADVERTS"][j]['LINK']+"\" target='_blank'>"+advertsObjects["ADVERTS"][j]['LINKNAME']+"</a> "+
advertsObjects["ADVERTS"][j]['CNT']+"</li>";}
if(outInfoHtml)
{var offers="<h4>Обьявления в радиусе 300м.</h4>"+"<ul class='houseOffers'>"+outInfoHtml+"</ul>";outInfoHtml=offers;}
if(outInfoHtml!='')
{_this.infoFrameText(offers);}
else
{_this.infoFrameText('');}}
else
{_this.infoFrameText('');}});}
Frame2Player.prototype.closePanorama=function(){this.parent.hide();this._map.onRepositionDiv();}
Frame2Player.prototype.onNoPoints=function(lat,lng){this.infoFrameText("<h4>Отсуствуют панорамы данного участка</h4>");this.infoWindowReposition();}
Frame2Player.prototype.changeViewMode=function(mode){this.frameMode=mode;if(mode=='middle'){$('#gedMap').addClass('frame2MiddleSize');}else
$('#gedMap').removeClass('frame2MiddleSize');this._map.onRepositionDiv();var _this=this;this.infoFrameText(this.lastInfoText);setTimeout(function(){_this.infoWindowReposition();_this._map.onRepositionDiv();},10);}
Frame2Player.prototype.getHTML=function(f2marker,fullscreen){var latlng=f2marker.getCenter();var flashvars={lat:latlng.getLat(),lng:latlng.getLng(),mapZoom:16,onModeChange:'frame2_onModeChange',onInit:'frame2_onInit'};if(f2marker.angle){flashvars.angle=f2marker.angle;flashvars.vangle=f2marker.vangle;flashvars.zoom=f2marker.zoom;}
this.flashVars=flashvars;if(fullscreen!=undefined&&fullscreen)
flashvars.fullscreen='true';var params={allowScriptAccess:'samedomain',allowFullScreen:'true',quality:'high',wmode:'opaque',devicefont:'true'};var attributes={id:this.frameName};if(fullscreen!=undefined&&fullscreen){var width='100%';var height='100%';}
else{var width=this.flashWidth;var height=this.flashHeight;}
var SWFHTMLGenerator=new swfobjectGenerator();return SWFHTMLGenerator.generate(this.getFlashPath(),width,height,flashvars,params,attributes);}
var is_Frame2_Player_Ready=0;window.frame2_onInit=function(){var out={};var i;for(i in Frame2DefaultPlayer.flashVars)
out[i]=Frame2DefaultPlayer.flashVars[i];return out;}
window.onPointReady=function(lat,lng,angle,vangle,zoom)
{onPanoramaReady();setTimeout(function(){Frame2DefaultPlayer.onPointReady(lat,lng,angle,vangle,zoom);},10);}
window.onViewParametersChanged=function(angle,vangle,zoom)
{setTimeout(function(){Frame2DefaultPlayer.flashVars.angle=angle;Frame2DefaultPlayer.flashVars.vangle=vangle;Frame2DefaultPlayer.f2marker.updatePosition(Frame2DefaultPlayer.f2marker.getCenter(),angle,vangle);},10);onPanoramaReady();}
window.onNoPoints=function(lat,lng)
{onPanoramaReady();setTimeout(function(){Frame2DefaultPlayer.onNoPoints(lat,lng);},10);}
window.onCloseTrigger=function()
{Frame2DefaultPlayer.closePanorama();}
window.frame2_onModeChange=function(mode){onPanoramaReady();Frame2DefaultPlayer.flashVars.frameMode=mode;setTimeout(function(){Frame2DefaultPlayer.changeViewMode(mode);},10);}
window.onGetCurrentURL=function()
{var vars=Frame2DefaultPlayer.flashVars;Frame2DefaultPlayer._map.setPosition(new mLatLng(vars.lat,vars.lng));var strURL=Frame2DefaultPlayer._map._changeLocation('','TPLZVW');var wurl=window.location.href.substr(0);var hpos=wurl.indexOf('#');if(hpos==-1)wurl+='#';else wurl=wurl.substr(0,hpos)+'#';strURL=wurl+strURL;var z='z='+Frame2DefaultPlayer._map.getZoom();strURL=strURL.replace(z,'z=16')
strURL+='&;F2:0,0,'+parseInt(Frame2DefaultPlayer.flashVars.angle)+","+parseInt(Frame2DefaultPlayer.flashVars.vangle);return strURL;}
window.onPanoramaReady=function()
{setTimeout(function(){is_Frame2_Player_Ready=1;},20);}
var r360_AzimutMarker_tear=0;function r360_AzimutMarker()
{this.markersURL='/images/map/eyemarkers/';if(!r360_AzimutMarker_tear)
{this.tear();return new r360_AzimutMarker();}
else{this.angle=0;this.vangle=0;this.isInfoWindowOpened=false;this.closeIcon=null;this.infoWindow=null;this.needCatchInfoWindow=false;var locationref=window.location.href;var pairs=locationref.split("&");var pairslen=pairs.length;var adrconf={};var i;for(i=0;i<pairslen;i++){var line=pairs[i];if(line.search(';F2:')==0){var line=line.split(",");this.angle=parseFloat(line[2]);this.vangle=parseFloat(line[3]);}}
this.setAzimut(this.angle);}
return this;}
r360_AzimutMarker.prototype.tear=function(){r360_AzimutMarker_tear=1;r360_AzimutMarker.prototype=new MapPointOverlay();r360_AzimutMarker.prototype.isTransparent=function(){return true;}
r360_AzimutMarker.prototype.getAngleFilename=function(angle){var parts=16;angle+=(angle>=0?1:-1)*360/(parts*2);var piece=parseInt(parts*angle/360);if(piece<0)
piece+=16;if(piece>=16)
piece-=16;switch(piece){case 1:return'022,5.png';case 2:return'045.png';case 3:return'067,5.png';case 4:return'090.png';case 5:return'112,5.png';case 6:return'135.png';case 7:return'157,5.png';case 8:return'180.png';case 9:return'202,5.png';case 10:return'225.png';case 11:return'247,5.png';case 12:return'270.png';case 13:return'292,5.png';case 14:return'315.png';case 15:return'337,5.png';default:return'000.png';}}
r360_AzimutMarker.prototype.getDim=function(){return{w:135,h:135}}
r360_AzimutMarker.prototype.setAzimut=function(az){this.innerHTML="<img class='pngFix' src='"+this.markersURL+this.getAngleFilename(az)+"'>";this.init();}
r360_AzimutMarker.prototype.updatePosition=function(latlng,angle,vangle)
{this.setLatLng(latlng);this.angle=angle;this.vangle=vangle;this.setAzimut(angle);}
r360_AzimutMarker.prototype.init=function(map){if(!this._div)
{var div=0;div=this.createDiv();div.id='r360_Azimut';}
this.setinnerHTML();}
var temp=new r360_AzimutMarker();this.eyeMarkers=[];for(var angle=0;angle<360;angle+=22.5){var eyemarker=new Image();eyemarker.src=temp.markersURL+temp.getAngleFilename(angle);this.eyeMarkers.push(eyemarker)}}
function r360_PointMarker(){}
r360_PointMarker.prototype=new MapPointOverlay();r360_PointMarker.prototype.isTransparent=function(){return true;}
r360_PointMarker.prototype.getDim=function(){return{w:24,h:39}}
r360_PointMarker.prototype.getAttachPoint=function(){return{x:12,y:37}}
r360_PointMarker.prototype.init=function(map){if(!this._div)
{var div=0;div=this.createDiv();div.className='r360_human_marker pngFix';this.innerHTML='';}
this.setinnerHTML();}
var r360TileLayer=function(map)
{this.map=map;this.layer=0;this.tileURL="/images/map/tiles/zoomlevel";this.shown=0;this.attach();}
r360TileLayer.prototype.attach=function()
{if(this.layer)
delete this.layer;if(this.setupGoogle)
delete this.setupGoogle;if(this.map.isYandex())
this.setupYandex();if(this.map.isGoogle())
this.setupGoogle();}
r360TileLayer.prototype.show=function()
{if(this.map.isYandex())
{this.map.worker.api.addLayer(this.layer);}
if(this.map.isGoogle())
{this.overlay.show();}
this.shown=1;}
r360TileLayer.prototype.hide=function()
{{if(this.map.isYandex())
{if(this.layer)
this.map.worker.api.removeLayer(this.layer);}
if(this.map.isGoogle())
{if(this.overlay)
this.overlay.hide();}
this.shown=0;}}
r360TileLayer.prototype.toggle=function()
{if(this.shown)this.hide();else this.show();}
r360TileLayer.prototype.setupYandex=function()
{Yandex_myTile_generation=0;function Yandex_myTile(indataSource){var myPos=new YMaps.Point(),dataSource=indataSource,dy=0,element=document.createElement(window.XMLHttpRequest?"IMG":"DIV"),originalSize=new YMaps.Point(256);element.style.position='absolute';element.style.display='none';this.onAddToMap=function(map,parentContainer){this.onRemoveFromMap();parentContainer.appendChild(element);}
this.onRemoveFromMap=function(){if(element.parentNode)
element.parentNode.removeChild(element);element.src='';}
this.setPosition=function(position){myPos.moveTo(position);element.style.left=myPos.x+'px';py=myPos.y+dy;element.style.top=py+'px';}
this.getPosition=function(){var p=myPos.copy();return p;}
this.pushTo=function(a)
{var e=element;if(window.XMLHttpRequest)
{e.style.display="none";e.onload=function(){this.style.display='block'};e.src=a;if(e.complete){e.onload();}}
else
{e.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a+"',sizingMethod='scale')";e.style.display="block";e.src=a;}}
this.load=function(tile,zoom){element.style.display='none';var src=dataSource.getTileUrl(tile,zoom);dy=dataSource.yoffset;this.pushTo(src);this.setPosition(this.getPosition());}
this.error=function(){}
this.abort=function(){}
this.scale=function(coeff){var newSize=originalSize.copy().scale(coeff);element.style.width=newSize.x+'px';element.style.height=newSize.y+'px';}}
var myparent=this;var urlTemplate=this.tileURL+'%c';var tileDataSource=new YMaps.TileDataSource(urlTemplate,true,false);tileDataSource.map=this.map;tileDataSource.getTile=function(){return new Yandex_myTile(this);}
tileDataSource.tileToMercator=function(d){return{x:(Math.round(d.x/53.5865938-20037508.342789)),y:(Math.round(20037508.342789-d.y/53.5865938))};}
tileDataSource.mercatorToGeo=function(p){var ab=0.00335655146887969400,bb=0.00000657187271079536,cb=0.00000001764564338702,db=0.00000000005328478445;Rn=6378137;var xphi=Math.PI/2-2*Math.atan(1/Math.exp(p.y/Rn));var latitude=xphi+ab*Math.sin(2*xphi)+bb*Math.sin(4*xphi)+cb*Math.sin(6*xphi)+db*Math.sin(8*xphi);var longitude=p.x/Rn;return new YMaps.GeoPoint(longitude*180/Math.PI,latitude*180/Math.PI,true);}
tileDataSource.fromLatLngToPixel=function(a,b)
{var c=256*Math.pow(2,b);var Mw=c/2;var Ow=c/360;var Pw=c/(2*Math.PI);var x=Math.round(Mw+a.getLng()*Ow);var y=Math.min(Math.max(Math.sin(a.getLat()/180*Math.PI),-0.9999),0.9999);y=Mw+0.5*Math.log((1+y)/(1-y))*(-Pw);y=Math.round(y);return new YMaps.Point(x,y);};tileDataSource.getTileUrl=function(tile,zoom)
{var n=this.map.worker.api;var p=n.tileCoordinates.toPixels(tile,new YMaps.Point(0,0),zoom);var geo=this.mercatorToGeo(this.tileToMercator(p));var geopt=this.fromLatLngToPixel(geo,zoom);var yaopt={x:0,y:0};yaopt.x=p.x>>(23-zoom);yaopt.y=p.y>>(23-zoom);this.yoffset=(yaopt.y-geopt.y);var off=128;while(this.yoffset>off)
{tile.y--;this.yoffset-=256;}
while(this.yoffset<-off)
{tile.y++;this.yoffset+=256;}
return myparent.tileURL+"x="+tile.x+"&y="+tile.y+"&z="+zoom;}
this.layer=new YMaps.Layer(tileDataSource);}
r360TileLayer.prototype.setupGoogle=function(){var myparent=this;this.overlay=new SparseTileLayerOverlay();this.overlay.setMap(this.map.worker.api);this.overlay.setUrl=function(tile,zoom)
{return myparent.tileURL+'x='+tile.x+'&y='+tile.y+'&z='+zoom;};var _this=this;this.map.worker.bind2MoveEnd(function(){_this.overlay.idle();});}
window['mLatLng']=mLatLng;window['MapWorker']=MapWorker;window['MapLayerPhotos']=MapLayerPhotos;window['MapLayerAdverts']=MapLayerAdverts;window['MapLayerPOI']=MapLayerPOI;window['r360_frame2']=r360_frame2;window['ControlTypeOverlay']=ControlTypeOverlay;window['ControlHelpOverlay']=ControlHelpOverlay;window['ControlLoadingHelpOverlay']=ControlLoadingHelpOverlay;})(DomeMaps);