var QMW2=function(){var f=4;var j={};var N=[];var x={};var B={};var w={};var n={};var m=function(e,D){var F=w[e];if(!F){F={};}F[D]=true;w[e]=F;};var p=function(e,D){var F=w[e];if(!F){return null;}return F[D];};var t={hasCanvas:false,hasVML:false,hasPNG24:false};var P=function(){if(Ext.isIE&&!Ext.isIE7){document.body.id="ie6root";}if(!Ext.isIE){t.hasCanvas=true;try{var F=document.createElement("canvas");document.body.appendChild(F);F.getContext("2d");F.style.display="none";}catch(D){t.hasCanvas=false;}}else{t.hasCanvas=false;}t.hasVML=Ext.isIE;t.hasPNG24=!(Ext.isIE&&!Ext.isIE7);};return {isIE:(!(/Safari|Konqueror|KHTML/gi).test(navigator.userAgent)&&!navigator.userAgent.match(/opera/gi)&&navigator.userAgent.match(/msie/gi)),hasCapability:function(F){return t["has"+F];},fix:function(J,D){var e=Ext.get(D);if(J=="PNG24"){var F=e.getStyle("backgroundImage");if(F.length>7){F=F.substring(5,F.length-2);if(F.indexOf(".png")!=-1){e.setStyle("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+F+"',sizingMethod='scale')");e.setStyle("background","");}}}},frameworkMode:"standard",resourcesPath:"qmw2/resources",librariesPath:"qmw2/jslib",frameworkPath:"qmw2",modulesPath:"qmw2/js/lib",controlsPath:"qmw2/js/ui",pagePath:".",servicesPath:".",applicationOptions:{},checkFloat:function(e){var D=/^[-]{0,1}[0-9.]+$/i;var F;if((F=D.exec(e))!==null){return true;}return false;},checkInt:function(e){var D=/^[-]{0,1}[0-9]+$/i;var F;if((F=D.exec(e))!==null){return true;}return false;},addModuleInitializer:function(F,e){B[F]=e;},initModule:function(e,F){var D=B[e];if(D){D.apply(null,[F]);}},init:function(F){P();F=F||{};if(F.resourcesPath){this.resourcesPath=F.resourcesPath;}if(F.librariesPath){this.librariesPath=F.librariesPath;}if(F.modulesPath){this.modulesPath=F.modulesPath;}if(F.controlsPath){this.controlsPath=F.controlsPath;}if(F.pagePath){this.pagePath=F.pagePath;}if(F.frameworkPath){this.frameworkPath=F.frameworkPath;}if(F.servicesPath){this.servicesPath=F.servicesPath;}this.frameworkMode=F.mode||"standard";if(F){this.applicationOptions=F;}if(typeof QMW2Loader!=="undefined"&&F.loaderId&&Ext.get(F.loaderId)!==null){this.loader=QMW2Loader;if(F.loaderSteps){f=F.loaderSteps;}this.loader.init(f,F.loaderId,F.onApplicationLoad,F.autoUpdateLoader);}},nextStep:function(){if(this.loader){this.loader.nextStep();}},applicationLoaded:function(){if(this.loader){this.loader.end();}},start:function(){QMW2.Application.start(this.applicationOptions);},registerCRS:function(F){n[F]=true;},getSupportedCRSs:function(){var F=[];for(var e in n){F.push(e);}return F;},registerControl:function(e,F){j[e]=F;},addControl:function(J,e,F){N.push({"id":J,"type":e,"cfg":F});if(F.crs){this.registerCRS(F.crs);}if(F.provides){for(var D=0;D<F.provides.length;D++){m(F.provides[D],J);}}},initControls:function(l){var D,e,J;for(D=0;D<N.length;D++){e=N[D];var E=j[e.type];if(E){var o=new E();J=e.cfg;J.name=e.id;J.map=QMW2.Application.getMap(J.mapName);o.init(Ext.apply(J,l));x[e.id]=o;}else{alert("Unknown control type: "+e.type);}}for(D=0;D<N.length;D++){e=N[D];J=e.cfg;if(J.requires){for(var v=0;v<J.requires.length;v++){var b=J.requires[v].split("=");var X=b[0];var F=b[1];if(p(X,F)){x[e.id].requireObject(X,x[F].provideObject(X));}}}}for(D=0;D<N.length;D++){e=N[D];if(x[e.id].postInit){x[e.id].postInit();}}},endInitControls:function(){var F,e;for(F=0;F<N.length;F++){e=N[F];if(x[e.id].endInit){x[e.id].endInit();}}},getControl:function(F){if(x[F]){return x[F];}return null;},getControlsByType:function(e){var F=[];for(var D in x){if(x[D].type==e){F.push(x[D]);}}return F;},externalCall:function(F){if((typeof QMW2.Application!=="undefined")&&(typeof QMW2.Application.externalCall=="function")){QMW2.Application.externalCall(F);}},loadModule:function(F){},loadControl:function(F){},loadWidget:function(F){},moduleLoaded:function(F){},widgetLoaded:function(F){},clear:function(){},getArray:function(J,e){if(!J){return [];}var F,D;if(J instanceof Array||typeof J=="array"){if(e){F=[];for(var X=0;X<J.length;X++){var b=J[X];for(D in b){F.push(b[D]);}}return F;}else{return J;}}else{if(e){F=[];for(D in J){F.push(J[D]);}return F;}else{return [J];}}},getObject:function(F){if(F.indexOf("window.")==-1){F="window."+F;}var J=F.split(".");var D=window;for(var e=1;e<J.length&&D;e++){D=D[J[e]];}return D||null;},addScript:function(e){var F=document.createElement("script");F.setAttribute("type","text/javascript");F.setAttribute("src",e);(document.getElementsByTagName("head")[0]).appendChild(F);},addStyleSheet:function(e){var F=document.createElement("link");F.setAttribute("type","text/css");F.setAttribute("rel","stylesheet");F.setAttribute("href",e);(document.getElementsByTagName("head")[0]).appendChild(F);}};}();QMW2.controlLoaded=QMW2.registerControl;Namespace=Ext.namespace;$=function(t){return document.getElementById(t);};QMW2.declare=function(className,subclass,proto){var pos=className.lastIndexOf(".");var ns=(pos!=-1)?className.substring(0,pos):"window";var cn=(pos!=-1)?className.substring(pos+1):className;Ext.namespace(ns);var nsObj=eval(ns);var ctor;if(typeof proto.initializer!=="undefined"){ctor=proto.initializer;delete proto["initializer"];}else{ctor=function(){};}nsObj[cn]=ctor;if(subclass){Ext.extend(nsObj[cn],subclass,proto);}else{nsObj[cn].prototype=proto;}};QMW2.decorate=function(w,m){if(typeof w!=="undefined"){var n=null;if(typeof w.prototype!=="undefined"){n=w.prototype;}else{n=w;}for(var P in m){var N=false;if(typeof n[P]==="function"){var t=n[P];var j=m[P];if(typeof j.before==="function"){t=t.createInterceptor(j.before);N=true;}if(typeof j.after==="function"){t=t.createSequence(j.after);N=true;}if(typeof j.flow==="function"){t=t.createFlow(j.flow);N=true;}if(typeof j.conditional==="function"){t=t.createConditional(j.conditional);N=true;}n[P]=t;}if(!N){n[P]=m[P];}}}};QMW2.decorate(Function,{createFlow:function(N,t){if(typeof N!="function"){return this;}var m=this;return function(){var P=m.apply(this||window,arguments);var n=[];for(var w=0;w<arguments.length;w++){n.push(arguments[w]);}n.push(P);return N.apply(t||this||window,n);};},createConditional:function(N,t){if(typeof N!="function"){return this;}var m=this;return function(){var P=N.apply(t||this||window,arguments);if(P){return m.apply(this||window,arguments);}else{return null;}};}});QMW2.decorate(String,{trim:function(){return this.replace(/^\s*(.*?)\s*$/,"$1");}});QMW2.moduleLoaded("oop");if(typeof QMW2!=="undefined"){QMW2.Application=function(){var scriptsPath="js";var mainMapName="main";function checkMapCfg(name,cfg){if(typeof cfg.minX==="undefined"||typeof cfg.maxX==="undefined"||typeof cfg.minY==="undefined"||typeof cfg.maxY==="undefined"){QMW2.Application.error($L("no_cfg_map_range")+": "+name);return false;}if(!cfg.CRS){QMW2.Application.error($L("no_cfg_map_crs")+": "+name);return false;}if(!QMW2.checkFloat(cfg.minX)||!QMW2.checkFloat(cfg.maxX)||!QMW2.checkFloat(cfg.minY)||!QMW2.checkFloat(cfg.maxY)){QMW2.Application.QMW2.error($L("cfg_map_range_not_numeric")+": "+name);return false;}return true;}function checkDataSource(sourceDesc){if(!sourceDesc.name){QMW2.Application.error($L("datasource_name_missing"));return false;}if(!sourceDesc.type){QMW2.Application.error($L("datasource_type_missing"));return false;}if(typeof QMW2.communication.datasources[sourceDesc.type]==="undefined"){QMW2.Application.error($L("datasource_type_unknown"));return false;}return true;}function clear(){this.eventManager=null;this.cache=null;workflows=null;for(var count=0;count<this.objectsToClean.length;count++){var obj=this.objectsToClean[count];if(obj&&obj.clear){obj.clear();}obj=null;}this.objectsToClean=null;for(var mapName in this.maps){this.maps[mapName].clear();}maps=null;engines=null;QMW2.clear();}function receiveCfg(status,response){if(status=="SUCCESS"){try{eval("var cfg={"+response.replace(/\\'/g,"'")+"}");}catch(e){QMW2.Application.error("Errore nella elaborazione della configurazione ("+e.message+"): "+response);}if(typeof cfg!=="undefined"){initCfg(cfg);}}else{QMW2.Application.error("Errore nella lettura della configurazione: "+response);}}function receiveResourcesCfg(status,response,mainCfg){if(status=="SUCCESS"){try{eval("var cfg={"+response.replace(/\\'/g,"'")+"}");mainCfg.QMW2Application.Resources=cfg.QMW2Application.Resources;mainCfg.QMW2Application.Coordinates=cfg.QMW2Application.Coordinates;}catch(e){QMW2.Application.error("Errore nella elaborazione della configurazione ("+e.message+"): "+response);}if(typeof mainCfg!=="undefined"){initCfg(mainCfg);}}else{QMW2.Application.error("Errore nella lettura della configurazione: "+response);}}function initCfg(cfg){if(!QMW2.Application.applicationCfg&&cfg.QMW2Application.name){QMW2.Application.applicationCfg=cfg.QMW2Application.name;}if(cfg.QMW2Application.Resources){resources=cfg.QMW2Application.Resources;}else{QMW2.Application.error("La configurazione non contiene i messaggi localizzati. Non sar� possibile visualizzare messaggi corretti");}try{QMW2.Application.readConfiguration(cfg.QMW2Application);}catch(e){QMW2.Application.error("Errore nella lettura della configurazione: "+e.message);}try{QMW2.Application.initControls({},cfg.QMW2Application);QMW2.Application.initMaps((typeof QMW2.Application.options.loadMaps!=="undefined")?QMW2.Application.options.loadMaps:true);QMW2.Application.initApplication(cfg.QMW2Application);QMW2.Application.applicationLoaded(true);QMW2.Application.endInit(cfg.QMW2Application);}catch(e){QMW2.Application.error($L("error_during_init_cfg")+": "+e.message);}}function destroyWorkflow(wid){delete workflows[wid];}function receiveEngineResponse(status,response,handlers){var workflow=null;var result=response;if(response.indexOf(",")!=-1){var sWid=response.substring(0,response.indexOf(","));result=response.substring(response.indexOf(",")+1);var wid=parseInt(sWid);workflow=workflows[wid];}if(status=="SUCCESS"){try{(handlers[0])(workflow,result);}catch(e){if(handlers[2]){(handlers[2])(workflow,result);}}}else{(handlers[1])(workflow,result);}}function $L_internal(resource){if(resources[resource]){return resources[resource];}else{alert("Localization error: resource "+resource+" not found");}return "";}function $L_tags(resource){var searchTags=new RegExp(/\$L\{([^}]+?)\}/ig);var result=resource;var found;while((found=searchTags.exec(resource))!=null){result=result.replace(found[0],$L_internal(found[1]));}return result;}var engines={};var initEngine=null;var resources={};var dataSources={};var maps={};var workflows={};return {objectsToClean:[],applicationName:"",applicationCfg:"",applicationParameters:{},eventManager:null,externalCallHandler:null,options:{},error:function(message){alert(message);},yesNo:function(message){return confirm(message);},start:function(options){if(options.applicationPath){scriptsPath=options.applicationPath;}this.options=options;var params=window.location.search;if(params.length>0){params=params.substring(1);this.applicationParameters=Ext.urlDecode(params);}Ext.EventManager.addListener(window,"unload",clear,this,true);this.applicationName="";this.applicationCfg=options.applicationCfg||"";this.language=options.language||"it";if(this.applicationParameters["application"]){this.applicationName=this.applicationParameters["application"];}QMW2.loadModule("event");QMW2.loadModule("workflow");QMW2.loadModule("communication");QMW2.loadModule("map");QMW2.loadModule("coordinates");this.eventManager=new QMW2.event.EventManager();initEngine=new QMW2.communication.SynchronousEngine();initEngine.registerHandler("getConfig",new QMW2.communication.AJAXEngine(QMW2.servicesPath+"/GetConfig.aspx"));initEngine.registerHandler("updateSteps",new QMW2.communication.AJAXEngine(QMW2.servicesPath+"/UpdateLoaderSteps.aspx"));if(options.autoStart){this.autoStart();}},autoStart:function(){this.getConfig({application:this.applicationCfg||"",language:this.language},receiveCfg);},applicationLoaded:function(status){QMW2.applicationLoaded();if(status){var toActivate=Ext.query(".qmw2-inactive");for(var pos=0;pos<toActivate.length;pos++){Ext.get(toActivate[pos]).removeClass("qmw2-inactive");}this.eventManager.fireEvent("applicationLoaded");}},loadConfiguration:function(cfgName,callback,language){var options={};if(typeof cfgName==="object"){options=cfgName;}else{options["application"]=cfgName;}if(!options["application"]){options["application"]=this.applicationCfg||"";}if(!options["language"]){options["language"]=language||this.language;}this.getConfig(options,callback);},getConfig:function(options,callback){var args=["getConfig",callback||receiveCfg];for(var option in options){args.push(option+"="+options[option]);}args.push("crs="+QMW2.getSupportedCRSs().join(","));initEngine.sendMsg.apply(initEngine,args);QMW2.nextStep();},applyConfig:function(response,name,language,doNotLoadResources){try{eval("var cfg={"+response.replace(/\\'/g,"'")+"}");if(name){cfg.QMW2Application.name=name;}if(doNotLoadResources){initCfg(cfg);}else{this.getConfig({application:name||"",lang:language},receiveResourcesCfg.createDelegate(null,[cfg],true));}}catch(e){QMW2.Application.error("Errore nella elaborazione della configurazione ("+e.message+"): "+response);}},updateLoaderSteps:function(steps,storage){initEngine.sendMsg("updateSteps",this.stepsUpdated.createDelegate(this),"application="+this.applicationCfg,"steps="+steps,"storage="+storage);},stepsUpdated:function(status,response){},registerEngine:function(action,engine){engines[action]=engine;engine.setResponseHandler(receiveEngineResponse);},callService:function(serviceName){var engine=engines[serviceName];if(engine){engine.sendMsg.apply(engine,arguments);}else{alert("Engine non definito per il servizio: "+serviceName);}},getEngine:function(action){return engines[action];},createWorkflow:function(){var workflow=new QMW2.workflow.Workflow();workflow.setManager(destroyWorkflow);workflows[workflow.uid]=workflow;return workflow;},getWorkflow:function(wid){return workflows[wid];},initApplication:function(cfg){},initMaps:function(loadMaps){for(var mapName in maps){var map=maps[mapName];map.init();if(loadMaps){this.eventManager.fireEvent("mapUpdated",mapName);}}},readMap:function(mapCfg){var name=mainMapName;if(mapCfg.name){name=mapCfg.name;}if(checkMapCfg(name,mapCfg)){var range=new QMW2.map.Range(mapCfg.minX,mapCfg.maxX,mapCfg.minY,mapCfg.maxY,mapCfg.CRS);var map=new QMW2.map.Map(name,"",range,range,this.eventManager);maps[name]=map;}},checkEntity:function(entity){if(!entity.name){return $L("entity_name_missing");}if(typeof entity.priority==="undefined"||!QMW2.checkInt(entity.priority)){return $L("entity_wrong_priority")+": "+entity.name;}return null;},getScaleConfiguration:function(entity,map){if(entity.zoomMin&&entity.zoomMax){return {min:parseFloat(entity.zoomMin),max:parseFloat(entity.zoomMax),units:entity.zoomUnit||"m"};}else{return null;}},readMapLayer:function(layer,map){if(typeof layer.MapEntity!=="undefined"){var entities=QMW2.getArray(layer.MapEntity);for(var count=0;count<entities.length;count++){var entity=entities[count];for(var propName in layer){if(typeof entity[propName]==="undefined"){entity[propName]=layer[propName];}else{entity["layer"+propName]=layer[propName];}}this.readMapEntity(entity,map);}}else{this.readMapEntity(layer,map);}},readMapEntity:function(entity,map){if(entity.type){var entityCreator=QMW2.map.layers.Layer.implementations[entity.type];if(entityCreator){var layer=entityCreator(entity,map,dataSources);if(typeof layer==="string"){QMW2.Application.error(layer);}}else{QMW2.Application.error($L("entity_type_unknown")+": "+entity.type);}}else{QMW2.Application.error($L("entity_type_unknown")+": "+entity.type);}},getMap:function(mapName){if(mapName){return maps[mapName];}else{return maps[mainMapName];}},readDataSource:function(cfg,sourceDesc){if(checkDataSource(sourceDesc)){var dataSourceCreator=QMW2.communication.datasources[sourceDesc.type];var dataSource=dataSourceCreator(cfg.name||"",sourceDesc);if(dataSource){dataSources[sourceDesc.name]=dataSource;}}},getDataSource:function(name){return dataSources[name];},readConfiguration:function(cfg){if(QMW2.coordinates&&QMW2.coordinates.Config){QMW2.coordinates.Config(cfg);}dataSources={};if(cfg.DataSources&&cfg.DataSources.DataSource){var sources=QMW2.getArray(cfg.DataSources.DataSource);for(var pos=0;pos<sources.length;pos++){this.readDataSource(cfg,sources[pos]);}}maps={};var mapRoot=QMW2.getArray(cfg.Maps.Map);for(var count=0;count<mapRoot.length;count++){this.readMap(mapRoot[count]);}var mapsLayers=QMW2.getArray(cfg.Layers);for(var count=0;count<mapsLayers.length;count++){var map=maps[mapsLayers[count].mapName||mainMapName];var mapLayers=QMW2.getArray(mapsLayers[count].Layer);if(map){for(var pos=0;pos<mapLayers.length;pos++){var layer=mapLayers[pos];this.readMapLayer(layer,map);}}else{QMW2.Application.error($L("map_unknown")+": "+mapName);}}},endHandler:function(){},initControls:function(options,cfg){options=options||{};options.maps=maps;options.eventManager=this.eventManager;options.cache=this.cache;options.engines=engines;options.applicationCfg=cfg;options.onEnd=this.endHandler.createDelegate(this);QMW2.initControls(options);},endInit:function(cfg){QMW2.endInitControls();},externalCall:function(callOptions){if(this.externalCallHandler){this.externalCallHandler(callOptions);}},addObjectToClear:function(obj){this.objectsToClean.push(obj);},loadApplication:function(){QMW2.loadScript(scriptsPath+"/"+this.applicationName+".js",{async:true});},$L:function(resource,localizeTags){if(localizeTags){return $L_tags(resource);}else{return $L_internal(resource);}}};}();$L=QMW2.Application.$L;}QMW2.moduleLoaded("application");QMW2.declare("QMW2.workflow.Workflow",null,{initializer:function(){this.uid=QMW2.workflow.Workflow.getUID();this.manager=null;},setManager:function(t){this.manager=t;},destroy:function(){if(this.manager){if(typeof this.manager=="function"){this.manager(this.uid);}else{this.manager.removeWorkflow(this.uid);}}}});QMW2.workflow.Workflow.currentUID=0;QMW2.workflow.Workflow.getUID=function(){return QMW2.workflow.Workflow.currentUID++;};QMW2.moduleLoaded("workflow");QMW2.declare("QMW2.event.EventManager",null,{initializer:function(){this.events={};},attachToEvent:function(t,m){var N=this.events[t];if(!N){N=[];}N.push(m);this.events[t]=N;},fireEvent:function(t){var P=this.events[t];if(P){for(var w=0;w<P.length;w++){var n=P[w];var N=[];for(var m=1;m<arguments.length;m++){N.push(arguments[m]);}n.apply(null,N);}}}});QMW2.moduleLoaded("event");Namespace("QMW2.communication");QMW2.communication.Engine={getUID:function(){return (new Date()).getTime();}};QMW2.communication.datasources={};QMW2.declare("QMW2.communication.DelegateEngine",null,{initializer:function(){this.handlers=[];this.handler=null;this.defaultHandler=null;this.lastHandler=null;},registerHandler:function(t,N){if(t=="*"){this.defaultHandler=N;}else{this.handlers[t]=N;}},sendMsg:function(N,t){var m=QMW2.communication.Engine.getUID();this.delegateMsg(m,N,t,arguments);return m;},delegateMsg:function(n,P,t,m){this.handler=t;var N=[];for(var w=2;w<m.length;w++){N.push(m[w]);}N.push("pagePath="+QMW2.pagePath);N.push("frameworkPath="+QMW2.frameworkPath);this.lastHandler=this.defaultHandler;if(this.handlers[P]){this.lastHandler=this.handlers[P];}this.lastHandler.handleMsg(n,P,this,N);}});QMW2.declare("QMW2.communication.SynchronousEngine",QMW2.communication.DelegateEngine,{initializer:function(){QMW2.communication.SynchronousEngine.superclass.constructor.call(this);this.ready=true;this.queue=[];this.queueByUid={};this.responseHandler=null;this.canceledRequests={};},processQueue:function(){var P=this.queue.pop();var N=this.queueByUid[P];delete this.queueByUid[P];var m=N[0];var t=N[1];this.handler=t;this.delegateMsg(P,m,t,N);},setResponseHandler:function(t){this.responseHandler=t;},sendMsg:function(N,t){var m=QMW2.communication.Engine.getUID();if(this.ready){this.ready=false;this.delegateMsg(m,N,t,arguments);}else{this.queue.push(m);this.queueByUid[m]=arguments;}return m;},receiveResponse:function(P,t,N){if(this.canceledRequests[P]){delete this.canceledRequests[P];}else{try{var m=N.replace(/\'/g,"\\'");if(this.responseHandler){this.responseHandler(t,m,this.handler);}else{if(this.handler!==null){this.handler(t,m);}else{alert("no handler for response: "+t+","+N);}}}catch(n){t="FAILURE";m="";alert("Exception in response ("+N+") handling: "+n.message);}this.handler=null;if(this.queue.length===0){this.ready=true;}else{this.processQueue();}}},cancelMsg:function(t){this.canceledRequests[t]=true;this.handler=null;if(this.queue.length===0){this.ready=true;}else{this.processQueue();}}});QMW2.declare("QMW2.communication.AJAXEngine",null,{initializer:function(t,N,m){this.url=t;this.proxy=null;this.method="get";this.parent=null;if(N){this.proxy=N;}if(m){this.method=m;}},handleMsg:function(n,x,f,B){var m="action="+x+"&method="+this.method;var t=this.url;if(this.proxy){t=this.proxy;m+="&url="+this.url;}var j=30000;for(var P=0;P<B.length;P++){if(B[P].indexOf&&B[P].indexOf("=")!=-1){var w=B[P].split("=");if(w[0].toLowerCase()=="timeout"){j=parseInt(w[1],10)*1000;}m+="&"+B[P];}else{m+="&arg"+(P+1)+"="+B[P];}}m+="&uid="+n;QMW2.communication.AJAXEngine.requests[n]=this;this.parent=f;m=encodeURI(m).replace("+","%2B");var N=null;if(this.method.toLowerCase()=="get"){t+="?"+m;}else{N=m;}Ext.Ajax.timeout=j;Ext.Ajax.request({method:this.method,url:t,params:N,success:function(p){QMW2.communication.AJAXEngine.onSuccess(p,n);},failure:function(p){QMW2.communication.AJAXEngine.onFailure(p,n);}});},receiveResponse:function(m,t,N){if(this.parent){this.parent.receiveResponse(m,t,N);}else{alert("no parent to send the response: "+t+","+N);}}});QMW2.communication.AJAXEngine.onResponse=function(t,N,m){if(QMW2.communication.AJAXEngine.requests[N]){QMW2.communication.AJAXEngine.requests[N].receiveResponse(N,m,t);delete QMW2.communication.AJAXEngine.requests[N];}};QMW2.communication.AJAXEngine.onSuccess=function(t,N){QMW2.communication.AJAXEngine.onResponse(t.responseText,N,"SUCCESS");};QMW2.communication.AJAXEngine.onFailure=function(t,N){if(t.status!=-1){if(t.responseText!==undefined){QMW2.communication.AJAXEngine.onResponse(t.responseText,N,"FAILURE");}else{QMW2.communication.AJAXEngine.onResponse("no_response",N,"FAILURE");}}else{QMW2.communication.AJAXEngine.onResponse("timeout",N,"FAILURE");}};QMW2.communication.AJAXEngine.requests={};QMW2.moduleLoaded("communication");QMW2.declare("QMW2.map.Range",null,{initializer:function(t,P,n,m,N){this.minX=t;this.maxX=P;this.minY=n;this.maxY=m;this.crs=N||null;},reproject:function(P){if(P&&this.crs&&this.crs!=P){var N=QMW2.coordinates.Projections[this.crs];var n=QMW2.coordinates.Projections[P];var j=new QMW2.coordinates.Point(this.minX,this.minY);var w=new QMW2.coordinates.Point(this.maxX,this.maxY);var m=n.reproject(N,j);var t=n.reproject(N,w);this.minX=m.x;this.minY=m.y;this.maxX=t.x;this.maxY=t.y;this.crs=P;}},zoom:function(P){var m;var t;if(P!==0){var N=(1-1/P)/2;m=this.getDeltaX()*N;t=this.getDeltaY()*N;this.minX+=m;this.minY+=t;this.maxX-=m;this.maxY-=t;}},normalizeToOneMeter:function(){var t=this.getDeltaX();var m=this.getDeltaY();var P=(this.minX+this.maxX)/2;var N=(this.minY+this.maxY)/2;if(this.getDeltaX()<1||this.getDeltaY()<1){if(this.getDeltaY()<this.getDeltaX()){this.minY=N-0.6;this.maxY=N+0.6;}else{this.minX=N-0.6;this.maxX=N+0.6;}this.inverseAdjustAspectRatio(t,m);}},normalizeToMaxRange:function(N){if(N!==null){var t=this.getDeltaX();var n=this.getDeltaY();var P=N.getDeltaX();var m=N.getDeltaY();if(t>P||n>m){this.minX=N.minX;this.minY=N.minY;this.maxX=N.maxX;this.maxY=N.maxY;}else{if(this.maxX>N.maxX){this.maxX=N.maxX;this.minX=N.maxX-t;}else{if(this.minX<N.minX){this.minX=N.minX;this.maxX=N.minX+t;}}if(this.maxY>N.maxY){this.maxY=N.maxY;this.minY=N.maxY-n;}else{if(this.minY<N.minY){this.minY=N.minY;this.maxY=N.minY+n;}}}this.adjustAspectRatio(t,n);this.normalizeToOneMeter();}},union:function(t){var n=this.minX<t.minX?this.minX:t.minX;var m=this.maxX>t.maxX?this.maxX:t.maxX;var P=this.minY<t.minY?this.minY:t.minY;var N=this.maxY>t.maxY?this.maxY:t.maxY;return new QMW2.map.Range(n,m,P,N);},equals:function(t){return (Math.round(this.minX*100)/100)==(Math.round(t.minX*100)/100)&&(Math.round(this.maxX*100)/100)==(Math.round(t.maxX*100)/100)&&(Math.round(this.minY*100)/100)==(Math.round(t.minY*100)/100)&&(Math.round(this.maxY*100)/100)==(Math.round(t.maxY*100)/100);},adjustAspectRatio:function(m,t){var N=this.getDeltaX();var n=this.getDeltaY();var w=N/n-m/t;var P=0;if(w>0){P=((m/t*n)-N)/2;this.minX=this.minX-P;this.maxX=this.maxX+P;}else{if(w<0){P=((t/m*N)-n)/2;this.minY=this.minY-P;this.maxY=this.maxY+P;}}},inverseAdjustAspectRatio:function(m,t){var N=this.getDeltaX();var n=this.getDeltaY();var w=N/n-m/t;var P=0;if(w<0){P=((m/t*n)-N)/2;this.minX=this.minX-P;this.maxX=this.maxX+P;}else{if(w>0){P=((t/m*N)-n)/2;this.minY=this.minY-P;this.maxY=this.maxY+P;}}},getDeltaX:function(){return this.maxX-this.minX;},getDeltaY:function(){return this.maxY-this.minY;},getScale:function(t){return t.getDeltaX()/this.getDeltaX();},getScaleX:function(t){return t.getDeltaX()/this.getDeltaX();},getScaleY:function(t){return t.getDeltaY()/this.getDeltaY();},pan:function(n,B){var N=this.getDeltaX();var t=this.getDeltaY();var m=this.minX+N/2;var P=this.minY+t/2;var j=m-n;var w=P-B;this.minX=j;this.minY=w;this.maxX=j+N;this.maxY=w+t;},copy:function(){return new QMW2.map.Range(this.minX,this.maxX,this.minY,this.maxY,this.crs);},toString:function(){return this.minX+","+this.maxX+","+this.minY+","+this.maxY+","+this.crs;},intersects:function(N){var t=this.maxX>N.minX&&this.minX<N.maxX&&this.maxY>N.minY&&this.minY<N.maxY;return t;},zoomAbsolute:function(n,m){var N=m.getDeltaX()/n;var t=m.getDeltaY()/n;var w=this.minX/2+this.maxX/2;var P=this.minY/2+this.maxY/2;this.minX=w-N/2;this.maxX=w+N/2;this.minY=P-t/2;this.maxY=P+t/2;},isValid:function(){return (!isNaN(this.minX)&&isFinite(this.minX))&&(!isNaN(this.maxX)&&isFinite(this.maxX))&&(!isNaN(this.minY)&&isFinite(this.minY))&&(!isNaN(this.maxY)&&isFinite(this.maxY));},containsPoint:function(t,N){return t>=this.minX&&t<=this.maxX&&N>=this.minY&&N<=this.maxY;}});QMW2.declare("QMW2.map.Map",null,{initializer:function(w,n,P,m,N,t){this.crs=t||null;this.layers={};this.priorities={};this.allowOverlappingPriorities=false;this.ready=true;this.mapName=w;this.type=n;this.crs=null;this.realRange=P.copy();this.maxRealRange=m.copy();this.oldRange=P.copy();this.scaleMetricFactor=1;this.eventManager=N;this.locked=false;},clear:function(){for(var t in this.layers){if(this.layers[t]&&this.layers[t].clear){this.layers[t].clear();}}},print:function(){var t=this.realRange;var P={range:{minX:t.minX,maxX:t.maxX,minY:t.minY,maxY:t.maxY,crs:t.crs},layers:[],crs:this.crs,aspectRatio:(t.getDeltaX()/t.getDeltaY())};for(var N in this.layers){var m=this.layers[N].print(this.realRange,this.maxRealRange);if(m){m.name=N;P.layers.push(m);}}return P;},lock:function(){if(!this.locked){this.locked=true;}},unlock:function(){if(this.locked){this.locked=false;}},isLocked:function(){return this.locked;},adjustRange:function(t){},getMetricScale:function(){return this.realRange.getDeltaX()/this.scaleMetricFactor;},zoomToMetricScale:function(w){if(!this.locked){var P=w*this.scaleMetricFactor;var m=this.realRange;var N=P*m.getDeltaY()/m.getDeltaX();var t=(P-m.getDeltaX())/2;var j=(N-m.getDeltaY())/2;var n=new QMW2.map.Range(m.minX-t,m.maxX+t,m.minY-j,m.maxY+j,this.crs);this.zoomBox(n);}},updateView:function(P,t,m,N){this.crs=N;this.scaleMetricFactor=P/(m*100)*2.54;this.realRange.adjustAspectRatio(P,t);this.realRange.normalizeToMaxRange(this.maxRealRange);if(N){this.projection=QMW2.coordinates.Projections[N];}},zoom:function(m){if(!this.locked){if(m===0){var N=this.realRange.getDeltaX();var t=this.realRange.getDeltaY();this.realRange=this.maxRealRange.copy();this.realRange.adjustAspectRatio(N,t);}else{this.realRange.zoom(m);}this.realRange.normalizeToMaxRange(this.maxRealRange);this.adjustRange(this.realRange);}},zoomOnPoint:function(N,n,P){if(!this.locked){var m=this.realRange.getDeltaX()/2;var t=this.realRange.getDeltaY()/2;this.realRange.minX=N-m;this.realRange.maxX=N+m;this.realRange.minY=n-t;this.realRange.maxY=n+t;this.realRange.zoom(P);this.realRange.normalizeToMaxRange(this.maxRealRange);this.adjustRange(this.realRange);}},zoomBox:function(N){if(!this.locked){var m=this.realRange.getDeltaX();var t=this.realRange.getDeltaY();this.realRange=N.copy();this.realRange.inverseAdjustAspectRatio(m,t);this.realRange.normalizeToMaxRange(this.maxRealRange);this.adjustRange(this.realRange);}},isPannable:function(){return true;},pan:function(m,n){if(!this.locked){var t=m*this.realRange.getDeltaX();var N=n*this.realRange.getDeltaY();var P=this.realRange.copy();this.realRange.pan(t,N);this.realRange.normalizeToMaxRange(this.maxRealRange);this.adjustRange(this.realRange);if(!P.equals(this.realRange)){return true;}}return false;},addLayer:function(t){if(!this.locked){var N=true;if(typeof t.priority!=="undefined"){if(!this.allowOverlappingPriorities&&this.priorities[t.priority]){N=false;QMW2.Application.error($L("not_allowed_overlapping_priority"));}else{this.priorities[t.priority]=true;}}if(N){this.layers[t.name]=t;this.eventManager.fireEvent("layerAdded",this.mapName,t);}}},removeLayer:function(t){if(!this.locked){var N=this.layers[t];N.unload();delete this.layers[N.name];if(typeof N.priority!=="undefined"){delete this.priorities[N.priority];}}},getLayer:function(t){return this.layers[t];},init:function(){if(this.eventManager){this.eventManager.fireEvent("mapInitialized",this.mapName);}this.adjustRange(this.realRange);},layerLoaded:function(t,m){var N=this.layers[t];N.setLoaded(t,m);return t;},reset:function(){this.layers={};this.ready=true;}});QMW2.moduleLoaded("map");QMW2.Data=function(){var N={};var t={};return {loadDataWidget:function(P,m){var n=QMW2.controlsPath+"/data";N[P]=true;QMW2.addScript((m||n)+"/"+P+".js");},registerWidget:function(P,m){t[P]=m;N[P]=false;},applyWidget:function(w,n,P,j){if(t[w]&&typeof t[w]=="function"){var m=t[w].apply(null,[n,P]);if(m&&j){j.apply(null,[m]);}}else{if(!N[w]){QMW2.Data.loadDataWidget(w);}QMW2.Data.applyWidget.defer(200,null,[w,Ext.get(n.dom.id),P,j],false);}},getBaseParams:function(){return {mapembedded:true,application:QMW2.Application.applicationCfg,frameworkPath:QMW2.frameworkPath,pagePath:QMW2.pagePath};},getFormParams:function(P,m){var n=m||{};P.select("input").each(function(j){switch(j.dom.type.toLowerCase()){case "checkbox":case "radio":if(j.dom.checked){n[j.dom.name]=j.dom.value;}break;default:var w=j.dom.name;if(w.indexOf("Hidden")!=-1){w=w.substring(0,w.length-6);}n[w]=j.dom.value;}});P.select("textarea").each(function(w){n[w.dom.name]=w.dom.value;});P.select("select").each(function(f){switch(f.dom.type.toLowerCase()){case "select-one":var x="",B,w=f.dom.selectedIndex;if(w>=0){B=f.dom.options[w];if(typeof B.value!=="undefined"){x=B.value;}else{x=B.innerText;}}n[f.dom.name]=x;break;default:var x=[];for(var j=0;j<f.dom.length;j++){var B=f.dom.options[j];if(B.selected){x.push((typeof B.value!=="undefined")?B.value:B.text);}}n[f.dom.name]=x;}});return n;}};}();QMW2.moduleLoaded("data");Namespace("QMW2.coordinates");QMW2.coordinates.ProjectionTypes={};QMW2.coordinates.EllipsoidTypes={};QMW2.declare("QMW2.coordinates.Point",null,{initializer:function(t,N){this.x=t;this.y=N;}});QMW2.declare("QMW2.coordinates.Projection",null,{initializer:function(t){this.ellipsoid=t;},reproject:function(N,t){var m=N.toGeographic(t);return this.fromGeographic(m);}});QMW2.declare("QMW2.coordinates.SPHERE",null,{initializer:function(){},getEquatorialRadius:function(){return 6378137;},getPolarRadius:function(){return 6378136.93621863;},getSquaredEccentricity:function(){return 2e-8;}});QMW2.coordinates.EllipsoidTypes["SPHERE"]=function(){return new QMW2.coordinates.SPHERE();};QMW2.declare("QMW2.coordinates.WGS84",null,{initializer:function(){},getEquatorialRadius:function(){return 6378137;},getPolarRadius:function(){return 6356752.314;},getSquaredEccentricity:function(){return 0.00669437999013;}});QMW2.coordinates.EllipsoidTypes["WGS84"]=function(){return new QMW2.coordinates.WGS84();};QMW2.declare("QMW2.coordinates.Rome1940",null,{initializer:function(){},getEquatorialRadius:function(){return 6378388;},getPolarRadius:function(){return 6356911.94612795;},getSquaredEccentricity:function(){return 0.006722670022333327;}});QMW2.coordinates.EllipsoidTypes["ROME40"]=function(){return new QMW2.coordinates.Rome1940();};QMW2.declare("QMW2.coordinates.ED50",null,{initializer:function(){},getEquatorialRadius:function(){return 6378388;},getPolarRadius:function(){return 6356911.94612795;},getSquaredEccentricity:function(){return 0.006722670022333327;}});QMW2.coordinates.EllipsoidTypes["ED50"]=function(){return new QMW2.coordinates.ED50();};QMW2.declare("QMW2.coordinates.Krassowsky1940",null,{initializer:function(){},getEquatorialRadius:function(){return 6378245;},getPolarRadius:function(){return 6356863.01877305;},getSquaredEccentricity:function(){return 0.006693421622965952;}});QMW2.coordinates.EllipsoidTypes["KR40"]=function(){return new QMW2.coordinates.Krassowsky1940();};QMW2.coordinates.ProjectionTypes["GEOGRAPHIC"]=function(t,N){return new QMW2.coordinates.Geographic(N);};QMW2.declare("QMW2.coordinates.MercatorProjection",QMW2.coordinates.Projection,{initializer:function(t){QMW2.coordinates.MercatorProjection.superclass.constructor.call(this,t);},fromGeographic:function(N){var P=N.x;var m=N.y;var t=P*20037508.34/180;var n=Math.log(Math.tan((90+m)*Math.PI/360))/(Math.PI/180);n=n*20037508.34/180;return new QMW2.coordinates.Point(t,n);},toGeographic:function(t){var m=(t.x/20037508.34)*180;var N=(t.y/20037508.34)*180;N=180/Math.PI*(2*Math.atan(Math.exp(N*Math.PI/180))-Math.PI/2);return new QMW2.coordinates.Point(m,N);}});QMW2.coordinates.ProjectionTypes["MERCATOR"]=function(t,N){return new QMW2.coordinates.MercatorProjection(N);};QMW2.declare("QMW2.coordinates.TransverseMercatorProjection",QMW2.coordinates.Projection,{initializer:function(N,t,n,P,w,m){QMW2.coordinates.TransverseMercatorProjection.superclass.constructor.call(this,N);this.setParameters(t,n,P,w,m);},setParameters:function(t,P,m,n,N){this.scaleFactor=t;this.lonOrigin=P;this.latOrigin=m;this.falseX=n;this.falseY=N;},arcLengthOfMeridian:function(j){var m,B,N,f,x,t;var p;var w=this.ellipsoid.getEquatorialRadius();var P=this.ellipsoid.getPolarRadius();t=(w-P)/(w+P);m=((w+P)/2)*(1+(Math.pow(t,2)/4)+(Math.pow(t,4)/64));B=(-3*t/2)+(9*Math.pow(t,3)/16)+(-3*Math.pow(t,5)/32);N=(15*Math.pow(t,2)/16)+(-15*Math.pow(t,4)/32);f=(-35*Math.pow(t,3)/48)+(105*Math.pow(t,5)/256);x=(315*Math.pow(t,4)/512);p=m*(j+(B*Math.sin(2*j))+(N*Math.sin(4*j))+(f*Math.sin(6*j))+(x*Math.sin(8*j)));return p;},footpointLatitude:function(f){var x,p,j,B,t,m,N;var F;var w=this.ellipsoid.getEquatorialRadius();var P=this.ellipsoid.getPolarRadius();N=(w-P)/(w+P);p=((w+P)/2)*(1+(Math.pow(N,2)/4)+(Math.pow(N,4)/64));x=f/p;j=(3*N/2)+(-27*Math.pow(N,3)/32)+(269*Math.pow(N,5)/512);B=(21*Math.pow(N,2)/16)+(-55*Math.pow(N,4)/32);t=(151*Math.pow(N,3)/96)+(-417*Math.pow(N,5)/128);m=(1097*Math.pow(N,4)/512);F=x+(j*Math.sin(2*x))+(B*Math.sin(4*x))+(t*Math.sin(6*x))+(m*Math.sin(8*x));return F;},mapLatLonToXY:function(n,p,P,T,j){var f,D,K,F,x,v;var m,X,B,E,e,w;var o;var b=this.ellipsoid.getEquatorialRadius();var J=this.ellipsoid.getPolarRadius();K=(Math.pow(b,2)-Math.pow(J,2))/Math.pow(J,2);D=K*Math.pow(Math.cos(n),2);f=Math.pow(b,2)/(J*Math.sqrt(1+D));F=Math.tan(n);x=F*F;o=(x*x*x)-Math.pow(F,6);v=p-P;m=1-x+D;X=5-x+9*D+4*(D*D);B=5-18*x+(x*x)+14*D-58*x*D;E=61-58*x+(x*x)+270*D-330*x*D;e=61-479*x+179*(x*x)-(x*x*x);w=1385-3111*x+543*(x*x)-(x*x*x);j[0]=f*Math.cos(n)*v+(f/6*Math.pow(Math.cos(n),3)*m*Math.pow(v,3))+(f/120*Math.pow(Math.cos(n),5)*B*Math.pow(v,5))+(f/5040*Math.pow(Math.cos(n),7)*e*Math.pow(v,7));j[1]=this.arcLengthOfMeridian(n)-this.arcLengthOfMeridian(T)+(F/2*f*Math.pow(Math.cos(n),2)*Math.pow(v,2))+(F/24*f*Math.pow(Math.cos(n),4)*X*Math.pow(v,4))+(F/720*f*Math.pow(Math.cos(n),6)*E*Math.pow(v,6))+(F/40320*f*Math.pow(Math.cos(n),8)*w*Math.pow(v,8));return ;},mapXYToLatLon:function(F,p,N,H,J){var c,B,X,T,i,w,s,k,b;var P,V,f,t,o,n,O,e;var a,D,m,K,j,C,v;var E=this.ellipsoid.getEquatorialRadius();var l=this.ellipsoid.getPolarRadius();c=this.footpointLatitude(p);i=(Math.pow(E,2)-Math.pow(l,2))/Math.pow(l,2);b=Math.cos(c);T=i*Math.pow(b,2);B=Math.pow(E,2)/(l*Math.sqrt(1+T));X=B;w=Math.tan(c);s=w*w;k=s*s;P=1/(X*b);X*=B;V=w/(2*X);X*=B;f=1/(6*X*b);X*=B;t=w/(24*X);X*=B;o=1/(120*X*b);X*=B;n=w/(720*X);X*=B;O=1/(5040*X*b);X*=B;e=w/(40320*X);a=-1-T;D=-1-2*s-T;m=5+3*s+6*T-6*s*T-3*(T*T)-9*s*(T*T);K=5+28*s+24*k+6*T+8*s*T;j=-61-90*s-45*k-107*T+162*s*T;C=-61-662*s-1320*k-720*(k*s);v=1385+3633*s+4095*k+1575*(k*s);J[0]=H+c+V*a*(F*F)+t*m*Math.pow(F,4)+n*j*Math.pow(F,6)+e*v*Math.pow(F,8);J[1]=N+P*F+f*D*Math.pow(F,3)+o*K*Math.pow(F,5)+O*C*Math.pow(F,7);return ;},latLonToTMXY:function(N,m,t){this.mapLatLonToXY(N,m,this.lonOrigin,this.latOrigin,t);t[0]=t[0]*this.scaleFactor+this.falseX;t[1]=t[1]*this.scaleFactor+this.falseY;if(t[1]<0){t[1]=t[1]+10000000;}},TMXYToLatLon:function(t,n,P,m){var N;t-=this.falseX;t/=this.scaleFactor;n-=this.falseY;if(P){n-=10000000;}n/=this.scaleFactor;this.mapXYToLatLon(t,n,this.lonOrigin,this.latOrigin,m);},toGeographic:function(t){latlon=new Array(2);this.TMXYToLatLon(t.x,t.y,t.y<0,latlon);return new QMW2.coordinates.Point(QMW2.coordinates.radToDeg(latlon[1]),QMW2.coordinates.radToDeg(latlon[0]));},fromGeographic:function(t){xy=new Array(2);this.latLonToTMXY(QMW2.coordinates.degToRad(t.y),QMW2.coordinates.degToRad(t.x),xy);return new QMW2.coordinates.Point(xy[0],xy[1]);}});QMW2.declare("QMW2.coordinates.UTMProjection",QMW2.coordinates.TransverseMercatorProjection,{initializer:function(N,t){QMW2.coordinates.UTMProjection.superclass.constructor.call(this,N);this.setParameters(0.9996,QMW2.coordinates.degToRad(-183+(t*6)),0,500000,0);}});QMW2.coordinates.ProjectionTypes["UTM"]=function(t,N){return new QMW2.coordinates.UTMProjection(N,t.zone);};QMW2.declare("QMW2.coordinates.GaussBoagaEstProjection",QMW2.coordinates.TransverseMercatorProjection,{initializer:function(t){QMW2.coordinates.GaussBoagaEstProjection.superclass.constructor.call(this,t);this.setParameters(0.9996,QMW2.coordinates.degToRad(15),0,2520000,0);}});QMW2.coordinates.ProjectionTypes["GBEST"]=function(t,N){return new QMW2.coordinates.GaussBoagaEstProjection(N);};QMW2.declare("QMW2.coordinates.GaussBoagaOvestProjection",QMW2.coordinates.TransverseMercatorProjection,{initializer:function(t){QMW2.coordinates.GaussBoagaOvestProjection.superclass.constructor.call(this,t);this.setParameters(0.9996,QMW2.coordinates.degToRad(9),0,1500000,0);}});QMW2.coordinates.ProjectionTypes["GBOVEST"]=function(t,N){return new QMW2.coordinates.GaussBoagaOvestProjection(N);};QMW2.declare("QMW2.coordinates.ObliqueStereographicProjection",QMW2.coordinates.Projection,{initializer:function(m,N,w,n,j,P){QMW2.coordinates.ObliqueStereographicProjection.superclass.constructor.call(this,m);this.scaleFactor=N;this.lonOrigin=QMW2.coordinates.degToRad(w);this.latOrigin=QMW2.coordinates.degToRad(n);this.falseX=j;this.falseY=P;this.epsilon=0.000001;this.excentricity=Math.sqrt(this.ellipsoid.getSquaredEccentricity());this.cosphi0=Math.cos(this.latOrigin);this.sinphi0=Math.sin(this.latOrigin);this.chi1=2*Math.atan(this.ssfn(this.latOrigin,this.sinphi0))-(Math.PI/2);this.cosChi1=Math.cos(this.chi1);this.sinChi1=Math.sin(this.chi1);this.k0=2*this.msfn(this.sinphi0,this.cosphi0);this.sphi=this.sinphi0;this.cphi=this.cosphi0;this.cphi*=this.cphi;var t=this.ellipsoid.getSquaredEccentricity();this.R2=2*Math.sqrt(1-t)/(1-t*this.sphi*this.sphi);this.C=Math.sqrt(1+t*this.cphi*this.cphi/(1-t));this.phic0=Math.asin(this.sphi/this.C);this.sinc0=Math.sin(this.phic0);this.cosc0=Math.cos(this.phic0);this.ratexp=0.5*this.C*this.excentricity;this.K=Math.tan(0.5*this.phic0+Math.PI/4)/(Math.pow(Math.tan(0.5*this.latOrigin+Math.PI/4),this.C)*this.srat(this.excentricity*this.sphi,this.ratexp));},srat:function(t,N){return Math.pow((1-t)/(1+t),N);},ssfn:function(N,t){t*=this.excentricity;return Math.tan((Math.PI/4)+N/2)*Math.pow((1-t)/(1+t),this.excentricity/2);},msfn:function(t,N){return N/Math.sqrt(1-(t*t)*this.ellipsoid.getSquaredEccentricity());},fromGeographic:function(N){var P=N.x;var m=N.y;var t=P*20037508.34/180;var n=Math.log(Math.tan((90+m)*Math.PI/360))/(Math.PI/180);n=n*20037508.34/180;return new QMW2.coordinates.Point(t,n);},toGeographic:function(f){var w=(f.x-this.falseX)/(this.scaleFactor*this.ellipsoid.getEquatorialRadius());var B=(f.y-this.falseY)/(this.scaleFactor*this.ellipsoid.getEquatorialRadius());var j=Math.sqrt(B*B+w*w);if(Math.abs(j)<this.EPSILON){B=0;w=this.phic0;}else{var t=2*Math.atan2(j,this.R2);var N=Math.sin(t);var F=Math.cos(t);B=Math.atan2(B*N,j*this.cosc0*F-w*this.sinc0*N);w=(F*this.sinc0)+(w*N*this.cosc0/j);if(Math.abs(w)>=1){w=(w<0)?-Math.PI/2:Math.PI/2;}else{w=Math.asin(w);}}B/=this.C;var P=Math.pow(Math.tan(0.5*w+Math.PI/4)/this.K,1/this.C);for(var m=15;;){var n=2*Math.atan(P*this.srat(this.excentricity*Math.sin(w),-0.5*this.excentricity))-Math.PI/2;if(Math.abs(n-w)<1e-10){break;}w=n;if(--m<0){return null;}}B+=this.lonOrigin;var p=QMW2.coordinates.radToDeg(B);var n=QMW2.coordinates.radToDeg(w);return new QMW2.coordinates.Point(p,n);}});QMW2.coordinates.ProjectionTypes["OBLIQUESTEREOGRAPHIC"]=function(t,N){return new QMW2.coordinates.ObliqueStereographicProjection(N,t.scaleFactor,t.longitudeOfOrigin,t.latitudeOfOrigin,t.falseX,t.falseY);};QMW2.coordinates.degToRad=function(t){return (t/180*Math.PI);};QMW2.coordinates.radToDeg=function(t){return (t/Math.PI*180);};QMW2.coordinates.Projections={};QMW2.coordinates.Config=function(w){if(w.Coordinates&&w.Coordinates.CRS){var j=w.Coordinates.CRS;if(typeof j.length=="undefined"){j=[j];}for(var n=0;n<j.length;n++){var B=j[n].name;var N=j[n].Projection;var f=j[n].Ellipsoid;if(B&&N&&f){var x=QMW2.coordinates.EllipsoidTypes[f.type];var t=QMW2.coordinates.ProjectionTypes[N.type];if(x&&t){var P=x(f);var m=t(N,P);QMW2.coordinates.Projections[B]=m;}}}}};QMW2.moduleLoaded("coordinates");Namespace("QMW2.communication.ogc");QMW2.loadModule("communication");QMW2.communication.ogc.checkWmsDataSource=function(t){if(!t.url){QMW2.Application.error($L("datasource_url_missing"));return false;}if(!t.serverurl){QMW2.Application.error($L("datasource_serverurl_missing"));return false;}return true;};QMW2.communication.ogc.checkWfsDataSource=function(t){if(!t.serverurl){QMW2.Application.error($L("datasource_serverurl_missing"));return false;}return true;};QMW2.declare("QMW2.communication.ogc.WMS",null,{initializer:function(m,N,t,P){this.engine=m;this.application=N;this.url=t;this.timeout=P||30;},print:function(){return {type:this.type,url:this.url};},sendMsg:function(m,t,N){var P=this.getHeader(N)+N.sld+this.getFooter(N);if(N.extra){return this.engine.sendMsg(m,t,"url="+this.url,"layer="+N.layerName,"wms="+P,"application="+this.application,"type="+this.type,"timeout="+this.timeout,N.extra);}else{return this.engine.sendMsg(m,t,"url="+this.url,"layer="+N.layerName,"wms="+P,"application="+this.application,"type="+this.type,"timeout="+this.timeout);}},cancelMsg:function(t){this.engine.cancelMsg(t);}});QMW2.declare("QMW2.communication.ogc.WMWMS",QMW2.communication.ogc.WMS,{initializer:function(m,N,t,P){QMW2.communication.ogc.WMWMS.superclass.constructor.call(this,m,N,t,P);this.type="webmap";},getHeader:function(t){if(t.useLogo){return "<GetMap xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:gml=\"http://www.intergraph.com/geomedia/gml\" service=\"WMS\" version=\"1.3.0\" format=\""+t.outputFormat+"\"  width=\""+t.mapWidth+"\"  height=\""+t.mapHeight+"\" transparent=\"false\" bgcolor=\"0xFFFFFF\"  crs=\""+t.crs+"\" logo=\""+t.layerName+"\" xslfilename=\""+t.styleProcessor+"\"><StyledLayerDescriptor version =\"1.0.0\">";}else{return "<GetMap xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:gml=\"http://www.intergraph.com/geomedia/gml\" service=\"WMS\" version=\"1.3.0\" format=\""+t.outputFormat+"\"  width=\""+t.mapWidth+"\"  height=\""+t.mapHeight+"\" transparent=\"false\" bgcolor=\"0xFFFFFF\"  crs=\""+t.crs+"\" xslfilename=\""+t.styleProcessor+"\"><StyledLayerDescriptor version =\"1.0.0\">";}},getFooter:function(t){return "</StyledLayerDescriptor><BoundingBox dimensions=\"2\"><LowerCorner>"+t.range.minX+" "+t.range.minY+"</LowerCorner><UpperCorner>"+t.range.maxX+" "+t.range.maxY+"</UpperCorner></BoundingBox><Output><Format>"+t.outputFormat+"</Format><Transparent>false</Transparent><Size><Width>"+t.mapWidth+"</Width><Height>"+t.mapHeight+"</Height></Size></Output><Exceptions>XML</Exceptions></GetMap>";}});QMW2.communication.datasources["webmapwms"]=function(N,P){if(QMW2.communication.ogc.checkWmsDataSource(P)){var m=new QMW2.communication.SynchronousEngine();m.registerHandler("wmsMap",new QMW2.communication.AJAXEngine(P.url,null,"post"));var t=new QMW2.communication.ogc.WMWMS(m,N,P.serverurl,P.timeout);return t;}else{return null;}};QMW2.declare("QMW2.communication.ogc.GSWMS",QMW2.communication.ogc.WMS,{initializer:function(m,N,t,P){QMW2.communication.ogc.GSWMS.superclass.constructor.call(this,m,N,t,P);this.type="geoserver";},getHeader:function(t){var B="<ogc:GetMap xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:gml=\"http://www.opengis.net/gml\"  xmlns:ogc=\"http://www.opengis.net/ows\"";var w={};if(t.namespaces&&t.namespaces.length&&t.namespaces.length>0){for(var P=0;P<t.namespaces.length;P++){var j=t.namespaces[P];if(!w[j]){w[j]=true;var m=j.indexOf(":");var n=j.substring(0,m);var N=j.substring(m+1);B+=" xmlns:"+n+"=\""+N+"\"";}}}B+=" service=\"WMS\" version=\"1.3.0\"><StyledLayerDescriptor xsi:schemaLocation=\"http://www.opengis.net/sld StyledLayerDescriptor.xsd\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"1.0.0\">";return B;},getFooter:function(t){return "</StyledLayerDescriptor><BoundingBox srsName=\"http://www.opengis.net/gml/srs/epsg.xml#"+t.crs+"\"><gml:coord><gml:X>"+t.range.minX+"</gml:X><gml:Y>"+t.range.minY+"</gml:Y></gml:coord><gml:coord><gml:X>"+t.range.maxX+"</gml:X><gml:Y>"+t.range.maxY+"</gml:Y></gml:coord></BoundingBox><Output><Format>"+t.outputFormat+"</Format><Transparent>true</Transparent><Size><Width>"+t.mapWidth+"</Width><Height>"+t.mapHeight+"</Height></Size></Output><Exceptions>XML</Exceptions></ogc:GetMap>";}});QMW2.communication.datasources["geoserverwms"]=function(N,P){if(QMW2.communication.ogc.checkWmsDataSource(P)){var m=new QMW2.communication.SynchronousEngine();m.registerHandler("wmsMap",new QMW2.communication.AJAXEngine(P.url,null,"post"));var t=new QMW2.communication.ogc.GSWMS(m,N,P.serverurl,P.timeout);return t;}else{return null;}};QMW2.communication.datasources["geoserverwfs"]=function(t,N){if(QMW2.communication.ogc.checkWfsDataSource(N)){return {servertype:"geoserver",url:N.serverurl,timeout:N.timeout};}else{return null;}};QMW2.communication.datasources["webmapwfs"]=function(t,N){if(QMW2.communication.ogc.checkWfsDataSource(N)){return {servertype:"webmap",url:N.serverurl,timeout:N.timeout};}else{return null;}};QMW2.communication.datasources["wmsget"]=function(t,N){if(!N.url){QMW2.Application.error($L("datasource_url_missing"));return null;}return {url:N.url};};QMW2.moduleLoaded("communication.ogc");QMW2.declare("QMW2.map.layers.Layer",null,{initializer:function(t,m,N){this.type="";this.priorities={};this.occupiedPriorities={};this.allowOverlappingPriorities=false;this.styles={};this.name=t;this.map=m;this.opacity=100;this.priority=N;this.renderingManagers={};this.crs=null;this.reallyVisible=false;this.changed=false;this.loaded=false;this.currRange=null;this.maxRange=null;this.originalRange=null;this.realRange=null;this.endHandler=null;this.features=[];this.oldRange=null;},setOpacity:function(t){this.opacity=t;},getOpacity:function(){return this.opacity;},hasCanvas:function(){return false;},getCanvas:function(){return null;},canBeUsedAsCanvas:function(){return false;},clear:function(){},setCRS:function(t){this.crs=t;},setRenderingManager:function(N,t,m){if(typeof t==="undefined"){t=this.noSubLayerName;}this.renderingManagers[t]=N;if(m){this.renderingManagers[t].read(m);this.setStyle(m,t);}},getRenderingManager:function(t){if(typeof t==="undefined"){t=this.noSubLayerName;}return this.renderingManagers[t];},init:function(){return "<div id=\""+this.getContainerName()+"\" style=\"position:absolute;top:0px;left:0px;z-index: "+this.priority+";visibility:hidden\">&nbsp;</div>";},getContainer:function(){return Ext.get(this.getContainerName());},getSize:function(){return this.getContainer().getSize();},getContainerName:function(){return "layer"+this.name+"Container";},getPriority:function(t){if(typeof t==="undefined"){t=this.noSubLayerName;}return this.priorities[t];},isPriorityOccupied:function(t){if(!this.allowOverlappingPriorities&&this.occupiedPriorities[t]){return true;}return false;},setPriority:function(N,t){if(typeof t==="undefined"){t=this.noSubLayerName;}this.priorities[t]=N;this.occupiedPriorities[N]=true;},setStyle:function(N,t){if(typeof t==="undefined"){t=this.noSubLayerName;}this.styles[t]=N.replace(new RegExp("\r|\n","gi"),"");},isVisible:function(){for(var t in this.renderingManagers){if(this.renderingManagers[t].isAny("visibility")){return true;}}return false;},convertScale:function(m,t){if(t=="m"){if(m.units=="m"){return m;}else{if(m.units=="mpp"){var N=this.getSize().width;return {units:"m",min:m.min*N,max:m.max*N};}else{if(m.units=="ratio"){var N=this.getSize().width;return {units:"m",min:m.min*this.map.scaleMetricFactor,max:m.max*this.map.scaleMetricFactor};}}}}return null;},getFeatureScale:function(N,t){var w={min:Number.MAX_VALUE,max:0,units:"m"};var m;if(typeof N==="undefined"){m=this.features;}else{m=[N];}var n=this.convertScale.createDelegate(this);for(var P=0;P<m.length;P++){N=m[P];this.renderingManagers[N].getMappedProperty("scale",function(j){j=n(j,"m");if(j.min<w.min){w.min=j.min;}if(j.max>w.max){w.max=j.max;}},t);}return w;},visibleInScale:function(P,m,t){var N=this.getFeatureScale(m,t);return P>=N.min&&P<=N.max;},show:function(){if(this.loaded&&!this.reallyVisible){Ext.fly(this.getContainerName()).setVisible(true);this.reallyVisible=true;}},hide:function(){if(this.reallyVisible){Ext.fly(this.getContainerName()).setVisible(false);this.reallyVisible=false;}},hasToBeUpdated:function(P,m){if(this.realRange){this.oldRange=this.realRange.copy();}if(this.changed){this.changed=false;for(var t in this.renderingManagers){this.renderingManagers[t].changed=false;}return true;}var w=P.getDeltaX();var N=false;var n=false;for(var t in this.renderingManagers){if(this.renderingManagers[t].isAny("visibility")){n=true;}if(this.renderingManagers[t].hasChanged()){N=true;}}if(n){if(this.visibleInScale(w)&&N){return true;}if((!this.oldRange.equals(P)&&this.visibleInScale(w))||(this.reallyVisible&&!this.visibleInScale(w))){return true;}}else{if(this.loaded){return true;}}return false;},beforeUpdate:function(N,t){},afterUpdate:function(N,t){},isPrintable:function(){return true;},print:function(N,t){var m=N.getDeltaX();if(this.isVisible()&&this.visibleInScale(m)){return this.printImpl(N,t);}return null;},printImpl:function(N,t){return null;},update:function(P,m,N,t){var n=P.getDeltaX();if(n<1){n=1;}this.endHandler=N;this.realRange=P.copy();this.maxRealRange=m;if(this.isVisible()&&this.visibleInScale(n)){if(!this.loaded){this.load(P,m,t);}else{this.updateRange(P,m,t);}}else{if(this.loaded){this.hide();this.unload();}this.endHandler(this.name);}},addFeature:function(t){this.features.push(t);this.changed=true;},removeFeature:function(N){var t=[];for(var m=0;m<this.features.length;m++){if(this.features[m]!=N){t.push(this.features[m]);}}if(this.priorities[N]){delete this.occupiedPriorities[this.priorities[N]];}this.features=t;this.changed=true;},load:function(n,P,m,N,t){},unload:function(){this.loaded=false;},updateRange:function(N,t){},updateProperty:function(t,P,m,N){return false;},isCurrentlyVisible:function(m,N){var P=(N||this.realRange).getDeltaX();var t=this.renderingManagers[m];return t.isAny("visibility")&&this.visibleInScale(P,m);},resetInteractions:function(){},noSubLayerName:"mainLayer"});QMW2.map.layers.Layer.implementations={};QMW2.moduleLoaded("map.layers");QMW2.declare("QMW2.map.rendering.Renderer",null,{initializer:function(){this.feature=null;if(!this.type){this.type="base";}this.changed=false;this.properties={};this.selectors={};this.selectorCount=0;this.sampleGenerator=this.getSampleGenerator();},getSampleGenerator:function(){var N=QMW2.map.rendering.Renderer.sampleGenerators;for(var t in N){if(N[t].canProcess(this)){return N[t];}}return null;},addSelector:function(t,N){if(!this.selectors[t]){this.selectorCount++;}this.selectors[t]=N;},drawSample:function(m,P,N,t){return this.sampleGenerator.drawSample(this,m,P,N,t);},getDescription:function(N){if(N){return [this.selectors[N]];}else{var t=[];for(var N in this.selectors){t.push(this.selectors[N]);}return t;}},setAllProperty:function(N,P){this.changed=true;for(var t in this.selectors){var m=this.properties[t];if(!m){m={};}m[N]=P;this.properties[t]=m;}},setProperty:function(N,P,t){this.changed=true;if(!t){alert("set propery with no selector");}else{var m=this.properties[t];if(!m){m={};}m[N]=P;this.properties[t]=m;}},getAnyProperty:function(N){for(var t in this.properties){return (this.properties[t])[N];}return null;},getMappedProperty:function(m,P,N){var t;if(N){return P.apply(this,[(this.properties[N])[m]]);}for(var N in this.properties){t=P.apply(this,[(this.properties[N])[m]]);}return t;},getProperty:function(N,t){if(this.properties[t]&&(this.properties[t])[N]){return (this.properties[t])[N];}else{return null;}},getPropertyCollection:function(m){var N={};for(var t in this.selectors){N[t]=this.getProperty(m,t);}return N;},isAny:function(N){for(var t in this.properties){if((this.properties[t])[N]){return true;}}return false;},applyAllProperty:function(N,P,n){var t=true;for(var w in this.rules){var m=this.applyProperty(N,P,w,n);if(!m){t=m;}}return t;},applyProperty:function(N,m,t,P){return m.updateProperty(t,N,this.getProperty(N,t),P);},setFeature:function(t){this.feature=t;},getFeature:function(){return this.feature;},hasChanged:function(){var t=this.changed;this.changed=false;return t;},copyProperties:function(t){for(var N in this.properties){t.properties[N]=this.properties[N];}},newInstance:function(){},clone:function(){var t=this.newInstance();this.copyProperties(t);return t;}});QMW2.map.rendering.Renderer.implementations={};QMW2.map.rendering.Renderer.sampleGenerators={};QMW2.moduleLoaded("map.rendering");QMW2.loadModule("map.rendering");QMW2.loadModule("map.rendering");QMW2.declare("QMW2.map.rendering.SLDRenderer",QMW2.map.rendering.Renderer,{initializer:function(){this.type="sld";QMW2.map.rendering.SLDRenderer.superclass.constructor.call(this);},read:function(t){QMW2.map.rendering.SLDRenderer.styleReader.read(t,this);},splitStyle:function(N){var P=[];var m=new RegExp("^(.*?)(<Rule>.*</Rule>)(.*?)$","gi");var t;if((t=m.exec(N))!==null){P=[t[1],t[2],t[3]];}return P;},getWmsLayer:function(P,N){var w=this.splitStyle(P);var m="";for(var t in this.selectors){if(N||this.getProperty("visibility",t)){var n=this.selectors[t];m+="<Rule>"+n+"</Rule>";}}return w[0]+m+w[2];},newInstance:function(){return new QMW2.map.rendering.SLDRenderer();}});QMW2.map.rendering.Renderer.implementations["sld"]=new QMW2.map.rendering.SLDRenderer();QMW2.declare("QMW2.map.rendering.SLDReader",null,{initializer:function(){},parseColor:function(m){var N=/^#[0-9a-f]+$/i;var t;if((t=N.exec(m))!=null){return m;}return "";},getCssParameters:function(P){var t;var n=new RegExp("<([a-z]+:){0,1}CssParameter\\s*name=\"([^\"]*)\"[^>]*>\\s*(.*?)\\s*</([a-z]+:){0,1}CssParameter>","gi");var w={};while((t=n.exec(P))!==null){var m=t[2];var N=t[3];w[m]=N;}return w;},getCssParametersFromContainer:function(P,m){var N=new RegExp("<([a-z]+:){0,1}"+P+"[^>]*>(.*?)</([a-z]+:){0,1}"+P+">","gi");var t;var n={};if((t=N.exec(m))!=null){n=this.getCssParameters(t[2]);}return n;},getFont:function(t){var N=this.getCssParametersFromContainer("Font",t);return {family:N["font-family"]||"Sans-Serif",size:N["font-size"]||"10",weight:N["font-weight"]||"normal",style:N["font-style"]||"normal"};},getGraphicFill:function(m){var t;var N=new RegExp("<([a-z]+:){0,1}GraphicFill[^>]*>(.*?)</([a-z]+:){0,1}GraphicFill>","gi");if((t=N.exec(m))!==null){var P=this.getGraphic(t[2]);P.simpleStyle=m.replace(t[0],"");return P;}return null;},getFill:function(t){var N=this.getGraphicFill(t);if(N){t=N.simpleStyle;}var m=this.getCssParametersFromContainer("Fill",t);return {graphicfill:N,color:this.parseColor(m["fill"])||"",opacity:m["stroke-opacity"]||1};},getStroke:function(t){var N=this.getCssParametersFromContainer("Stroke",t);return {color:this.parseColor(N["stroke"])||"",weight:(N["stroke-width"]?parseFloat(N["stroke-width"]):1),dashed:N["stroke-dasharray"]||"",opacity:N["stroke-opacity"]||1};},getMark:function(N){var n=new RegExp("<([a-z]+:){0,1}WellKnownName[^>]*>\\s*(.*?)\\s*</([a-z]+:){0,1}WellKnownName>","gi");var t;var P=this.has("Stroke",N)?this.getStroke(N):null;var m=this.has("Fill",N)?this.getFill(N):null;var w="";if((t=n.exec(N))!=null){w=t[2];}return {symbol:w,stroke:P,fill:m};},getExternalGraphic:function(m){var N=new RegExp("<([a-z]+:){0,1}OnlineResource.*?href=\"([^\"]*)\"[^>]*>","gi");var t;if((t=N.exec(m))!=null){return t[2];}return "";},getSize:function(m){var N=new RegExp("<([a-z]+:){0,1}Size[^>]*>\\s*(.*?)\\s*</([a-z]+:){0,1}Size>","gi");var t;if((t=N.exec(m))!=null){return parseInt(t[2],10);}else{return 3;}},getGraphic:function(N){var t;var m=new RegExp("<([a-z]+:){0,1}Graphic[^>]*>(.*?)</([a-z]+:){0,1}Graphic>","gi");while((t=m.exec(N))!==null){if(this.has("Mark",N)){return {mark:this.getMark(t[2])};}else{if(this.has("ExternalGraphic",N)){return {url:this.getExternalGraphic(t[2])};}else{return {};}}}},getSymbolizers:function(N){var m=new RegExp(/<([a-zA-Z]+)Symbolizer.*?>(.*?)<\/([a-zA-Z]+)Symbolizer>/gi);var P=[];var t;while((t=m.exec(N))!=null){P.push({type:t[1].toLowerCase(),style:t[2]});}return P;},has:function(N,t){var m=new RegExp("<([a-z]+:){0,1}"+N+"[^>]*>.*?</([a-z]+:){0,1}"+N+">","gi");return (m.exec(t)!=null);},read:function(p,n){var F=new RegExp("<([a-z]+:){0,1}NamedLayer[^>]*>\\s*<([a-z]+:){0,1}Name[^>]*>(.*?)</([a-z]+:){0,1}Name>.*?</([a-z]+:){0,1}NamedLayer>","gi");var e;if((e=F.exec(p))!=null){n.setFeature(e[3]);}var N=new RegExp("<([a-z]+:){0,1}Rule[^>]*>(.*?)</([a-z]+:){0,1}Rule>","gi");var t=0;while((e=N.exec(p))!==null){var B=e[2];var x="";var j=new RegExp("<([a-z]+:){0,1}Name[^>]*>\\s*(.*?)\\s*</([a-z]+:){0,1}Name>","gi");while((e=j.exec(B))!==null){x=e[2];}n.addSelector(x,B);var P=null;var m=new RegExp("<([a-z]+:){0,1}((Min)|(Max))ScaleDenominator[^>]*>\\s*(.*?)\\s*</([a-z]+:){0,1}((Min)|(Max))ScaleDenominator>","gi");while((e=m.exec(B))!=null){if(!P){P={units:"ratio",min:0,max:Number.MAX_VALUE};}var w=e[2].toLowerCase();var f=e[5];P[w]=parseFloat(f);}if(P){n.setProperty("scale",P,x);}}}});QMW2.map.rendering.SLDRenderer.styleReader=new QMW2.map.rendering.SLDReader();QMW2.map.rendering.Renderer.sampleGenerators["sld"]=function(){var t=QMW2.map.rendering.SLDRenderer.styleReader;function m(j,w){var n=Math.floor(j/5);return w<n?w:n;}function P(w,B,j,n){w.drawString("?",4,1+B,"Sans-Serif",j-4,"#FF0000");}function N(J,f,x,j,b){var D=t.getSymbolizers(J);for(var F=0;F<D.length;F++){var e=D[F].type;var w=D[F].style;switch(e){case "raster":f.drawImage(QMW2.resourcesPath+"/images/raster.gif",0,x,j,b);break;case "line":if(t.has("Stroke",w)){var o=t.getStroke(w);f.drawPolyline([{x:0,y:(x+b)},{x:Math.floor(j/3),y:Math.floor(b/3+x)},{x:Math.floor(j-j/3),y:Math.floor(b-b/3+x)},{x:j,y:x}],o);}else{P(f,x,j,b);}break;case "polygon":var p=true;var X=f.getRectPoints(0,Math.floor(x+b/4),j,Math.floor(b/2));if(t.has("Fill",w)){var v=t.getFill(w);if(v&&(v.color||v.graphicfill)){p=false;f.drawPolygon(X,v,false);}}if(t.has("Stroke",w)){p=false;var o=t.getStroke(w);f.drawPolyline(X,o);}if(p){P(f,x,j,b);}break;case "point":var n=t.getGraphic(w);var l=t.getSize(w);if(l>j){l=j;}if(n.mark){f.drawSymbol(n.mark.symbol,(j-l)/2,x+(b-l)/2,l,l,n.mark.stroke,n.mark.fill);}else{if(n.url){f.drawImage(n.url,0,x,j,b);}else{P(f,x,j,b);}}break;case "text":var v=t.getFill(w);var B=t.getFont(w);f.drawString("T",4,1+x,B.family,j-4,v.color);break;default:P(f,x,j,b);break;}}}return {canProcess:function(n){return n.type=="sld";},drawSample:function(x,w,n,F,j){var p=x.getDescription(j);var B=m(F,p.length);var e=F/B;for(var f=0;f<B;f++){N(p[f],w,f*e,n,e);}}};}();QMW2.moduleLoaded("map.sldrendering");QMW2.loadModule("map.layers");QMW2.loadModule("map.rendering");QMW2.declare("QMW2.map.layers.WMSLayer",QMW2.map.layers.Layer,{initializer:function(N,w,m,t,j,P,n){QMW2.map.layers.WMSLayer.superclass.constructor.call(this,N,w,m);this.type="wms";this.map=w;this.featureName=t;this.engine=P;this.action=n;this.outputFormat=j;this.animationStarted=false;this.animationSteps=10;this.animationInterval=10;this.currentLoading=0;this.currentLoaded=0;this.currentAnimation=0;this.layerContainer=null;this.oldLayerContainer=null;this.zoomRange=null;},init:function(){return "<div id=\""+this.getContainerName()+"\" style=\"position:absolute;top:0px;left:0px;z-index: "+this.priority+"\"><img src=\""+QMW2.resourcesPath+"/images/spacer.gif\" style=\"position:absolute;top:0px;left:0px;width:10000px;height:10000px\"/></div>";},clear:function(){this.removeContent();},load:function(m,N,t){this.updateRange(m,N,t);},removeContent:function(){if(this.layerContainer){this.layerContainer.parentNode.removeChild(this.layerContainer);this.layerContainer=null;}if(this.oldLayerContainer){if(this.oldLayerContainer.parentNode){this.oldLayerContainer.parentNode.removeChild(this.oldLayerContainer);}this.oldLayerContainer=null;}},unload:function(){this.removeContent();this.loaded=false;},hide:function(){},getVisibleFeaturesByPriority:function(P){var F=[];var t={};var B=0;for(var w=0;w<this.features.length;w++){var p=this.features[w];var j=this.getPriority(p);if(this.isCurrentlyVisible(p,P)){F.push(j);t[j]=p;B++;}}var N=null;var x=[];if(B>0){var m="";F=F.sort(function(D,e){return D-e;});for(var n=0;n<F.length;n++){var f=F[n];if(t[f]){x.push(t[f]);}}}return x;},getStylesForFeatures:function(N){var t=[];for(var m=0;m<N.length;m++){t.push(this.styles[N[m]]);}return t;},updateProperty:function(t,P,m,N){return true;},applyRemoval:function(t){return this.implementation.removeFeature(t);},updateRange:function(m,N,t){this.zoomRange=null;if(t||this.layerContainer===null||this.error){if(this.error&&this.layerContainer!==null){this.oldLayerContainer=this.layerContainer;}var P=this.getWmsQuery(m,N);if(P){this.doWMSRequest(P,m,N);}else{this.removeContent();this.cancelUpdate();this.endHandler(this.name);}}else{this.startAnimation(t,this.updateRange.createDelegate(this,[m,N,true]));}},cancelUpdate:function(){},getLayerHTML:function(t){var N=this.getSize();if(this.outputFormat=="image/png"&&!QMW2.hasCapability("PNG24")){return "<div style=\"position:absolute;top:0px;left:0px;width:"+N.width+"px;height:"+N.height+"px;z-index:1;background:url("+QMW2.resourcePath+"/images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+t+"',sizingMethod='scale')\">&nbsp;</div>";}else{return "<img style=\"position:absolute;top:0px;left:0px\" src=\""+t+"\" width=\""+N.width+"\" height=\""+N.height+"\"/>";}},startInteractivePan:function(){this.oldLayerContainer=this.layerContainer;},getImage:function(){if(this.outputFormat=="image/png"&&!QMW2.hasCapability("PNG24")){return Ext.fly(this.layerContainer).child("div");}else{return Ext.fly(this.layerContainer).child("img");}},interactiveZoom:function(n){if(this.layerContainer){if(this.zoomRange==null){this.zoomRange=this.realRange.copy();this.oldZoomRange=this.zoomRange.copy();}this.changed=true;this.zoomRange.zoom(n);var m=this.oldZoomRange.getDeltaX()/this.zoomRange.getDeltaX();var N=this.oldZoomRange.getDeltaY()/this.zoomRange.getDeltaY();var P=this.getSize();var t=(this.oldZoomRange.minX-this.zoomRange.minX)/this.oldZoomRange.getDeltaX()*P.width;var w=(-this.oldZoomRange.maxY+this.zoomRange.maxY)/this.oldZoomRange.getDeltaY()*P.height;this.getImage().setLocalBounds(t*m,w*N,P.width*m,P.height*N,true,0.5,null,Ext.lib.Easing.easeOut);}},interactivePan:function(N,P,t,m){if(!isNaN(N)&&!isNaN(P)&&!isNaN(t)&&!isNaN(m)&&this.layerContainer){this.layerContainer.style.left=(t-N)+"px";this.layerContainer.style.top=(m-P)+"px";}},endInteractivePan:function(){},undoInteractivePan:function(){if(this.layerContainer){this.layerContainer.style.left="0px";this.layerContainer.style.top="0px";}},startAnimation:function(n,N){this.oldLayerContainer=this.layerContainer;var P=this.oldRange.getDeltaX()/this.realRange.getDeltaX();var m=this.oldRange.getDeltaY()/this.realRange.getDeltaY();var w=this.getSize();var t=(this.oldRange.minX-this.realRange.minX)/this.oldRange.getDeltaX()*w.width;var j=(-this.oldRange.maxY+this.realRange.maxY)/this.oldRange.getDeltaY()*w.height;this.getImage().setLocalBounds(t*P,j*m,w.width*P,w.height*m,true,0.5,N,Ext.lib.Easing.easeOut);},setLoaded:function(){if(this.oldLayerContainer!==null){this.oldLayerContainer.parentNode.removeChild(this.oldLayerContainer);this.oldLayerContainer=null;}this.layerContainer.style.display="block";this.loaded=true;this.endHandler(this.name);},addFeature:function(t){QMW2.map.layers.Layer.prototype.addFeature.apply(this,arguments);},setOutputFormat:function(t){this.changed=true;this.outputFormat="image/"+t;}});QMW2.declare("QMW2.map.rendering.WMSRenderer",QMW2.map.rendering.Renderer,{initializer:function(){this.type="wms";QMW2.map.rendering.WMSRenderer.superclass.constructor.call(this);this.style="";},drawSample:function(m,P,N,t){m.drawImage(QMW2.resourcesPath+"/images/raster.gif",0,0,P,N);},newInstance:function(){return new QMW2.map.rendering.WMSRenderer();},read:function(t){this.style=t;this.addSelector("main",{});}});QMW2.map.rendering.Renderer.implementations["wms"]=new QMW2.map.rendering.WMSRenderer();QMW2.moduleLoaded("map.wmslayer");QMW2.loadModule("map.wmslayer");QMW2.declare("QMW2.map.layers.WMSGETLayer",QMW2.map.layers.WMSLayer,{initializer:function(m,j,P,N,B,n,w,t){QMW2.map.layers.WMSGETLayer.superclass.constructor.call(this,m,j,P,N,B,n,w);this.type="wmsget";this.crs=t;},setCRS:function(t){if(!this.crs){this.crs=t;}},getWmsQuery:function(P,t){var m=this.getVisibleFeaturesByPriority(P);var n=this.getStylesForFeatures(m);if(m.length>0){var N=this.getSize();return this.engine.url+"&LAYERS="+m.join(",")+"&STYLES="+n.join(",")+"&WIDTH="+N.width+"&HEIGHT="+N.height+"&BBOX="+P.minX+","+P.minY+","+P.maxX+","+P.maxY+"&FORMAT="+this.outputFormat+"&SRS=EPSG:"+this.crs;}else{return "";}},doWMSRequest:function(m,N,t){this.layerContainer=document.createElement("div");this.layerContainer.className="qmw2-dynamicwmslayer";this.getContainer().appendChild(this.layerContainer);this.layerContainer.innerHTML=this.getLayerHTML(m);Ext.fly(this.layerContainer).setDisplayed("none").setSize(this.getSize());if(this.opacity!=100){Ext.fly(this.layerContainer).setOpacity(this.opacity/100);}this.map.layerLoaded(this.name);}});QMW2.map.layers.Layer.implementations["wmsget"]=function(n,m,t){var x=QMW2.Application.checkEntity(n);if(x){return x;}if(typeof n.featureName==="undefined"){return $L("entity_missing_featurename")+": "+n.name;}var w=m.getLayer(n.name);action="wmsMap";var N=n.src||action;if(t[N]){if(!w){var p=n.priority;var j=n.opacity;if(typeof n.layerpriority!=="undefined"){p=n.layerpriority;}w=new QMW2.map.layers.WMSGETLayer(n.name,m,parseInt(p,10),n.name,"image/"+n.outputFormat,t[N],action,n.CRS);if(typeof j!=="undefined"){w.setOpacity(j);}m.addLayer(w);}var P=parseInt(n.priority,10);if(!w.isPriorityOccupied(P)){w.addFeature(n.featureName);w.setPriority(P,n.featureName);var B=QMW2.map.rendering.Renderer.implementations["wms"].newInstance();w.setRenderingManager(B,n.featureName,n.Style);if(n.visible){B.setAllProperty("visibility",true);}else{B.setAllProperty("visibility",false);}var f=QMW2.Application.getScaleConfiguration(n,m);if(f){B.setAllProperty("scale",f);}}else{QMW2.Application.error($L("entity_not_allowed_overlapping_priority"));}return w;}else{return $L("entity_datasource_unknown")+": "+n.name;}};QMW2.moduleLoaded("map.wmsgetlayer");QMW2.loadModule("map.wmslayer");QMW2.loadModule("map.sldrendering");QMW2.declare("QMW2.map.layers.DynamicWMSLayer",QMW2.map.layers.WMSLayer,{initializer:function(N,t,j,f,n,w,P,B,m){QMW2.map.layers.DynamicWMSLayer.superclass.constructor.call(this,N,t,j,f,n,w,P);this.type="dynamicwms";this.fileName="";this.namespaces={};this.updateUid=null;this.errorIsNotBlocking=B;this.error=false;this.useAsCanvas=m;},hasCanvas:function(){return this.useAsCanvas;},getCanvas:function(){return this.layerContainer;},canBeUsedAsCanvas:function(){return true;},printImpl:function(N,t){return {src:this.engine.print(),type:"dynamicwms",wms:this.getWmsQuery(N,t),namespaces:this.getNameSpaces()};},replaceFilter:function(m,N){var t;var n=new RegExp("<(ogc:){0,1}Filter[^>]*?>(.*?)</(ogc:){0,1}Filter>","gi");if((t=n.exec(m))!==null){m=m.replace(t[0],"");}var P=new RegExp("(<Rule*?>\\s*<Name>.*?</Name>)(.*?)(</Rule>)","gi");if((t=P.exec(m))!==null){m=m.replace(t[0],t[1]+"<ogc:Filter>"+N+"</ogc:Filter>"+t[2]+t[3]);}return m;},getStyleFilter:function(N){var t;var m=new RegExp("<(ogc:){0,1}Filter[^>]*?>(.*?)</(ogc:){0,1}Filter>","gi");if((t=m.exec(N))!==null){return t[2];}return null;},getWmsQuery:function(n,N){var P=this.getVisibleFeaturesByPriority(n);var j="";var t;if(P.length>0){for(var w=0;w<P.length;w++){var m=P[w];t=this.renderingManagers[m];j+=t.getWmsLayer(this.styles[m]);}}return j;},getNameSpaces:function(){var t=[];for(var N in this.namespaces){t.push(this.namespaces[N]);}return t;},doWMSRequest:function(P,m,t){var N=this.getSize();this.updateUid=this.engineSend({sld:P,layerName:this.name,range:m,mapWidth:N.width,mapHeight:N.height,crs:this.crs,outputFormat:this.outputFormat,namespaces:this.getNameSpaces()});},cancelUpdate:function(){this.updateUid=null;},engineSend:function(t){this.engine.sendMsg(this.action,this.responseFromEngine.createDelegate(this),t);},cancelLoading:function(){if(this.updateUid){this.engine.cancelMsg(this.updateUid);this.changed=true;return true;}else{return false;}},responseFromEngine:function(N,t){this.updateUid=null;if(N=="FAILURE"){this.error=true;this.changed=true;if(!this.errorIsNotBlocking){this.endHandler(this.name,true,t);}}else{this.error=false;if(t.indexOf(",")==-1){this.fileName=t;}else{var m=t.split(",");this.fileName=m[0];}}if(N!="FAILURE"||this.errorIsNotBlocking){this.layerContainer=document.createElement("div");if(N=="FAILURE"){this.layerContainer.className="qmw2-dynamicwmslayererror";}else{this.layerContainer.className="qmw2-dynamicwmslayer";}this.layerUid=(new Date()).getTime();this.getContainer().appendChild(this.layerContainer);if(N=="FAILURE"&&!QMW2.hasCapability("PNG24")){QMW2.fix("PNG24",this.layerContainer);}if(N!="FAILURE"){this.layerContainer.innerHTML=this.getLayerHTML();}Ext.fly(this.layerContainer).setDisplayed("none").setSize(this.getSize());if(this.opacity!=100){Ext.fly(this.layerContainer).setOpacity(this.opacity/100);}this.map.layerLoaded(this.name);}},getLayerHTML:function(N){var t=this.getSize();if(N){return "<img style=\"position:absolute;top:0px;left:0px\" src=\""+QMW2.resourcePath+"/spacer.gif\" width=\""+t.width+"\" height=\""+t.height+"\"/>";}else{if(this.fileName.indexOf(".png")!=-1&&!QMW2.hasCapability("PNG24")){return "<div style=\"position:absolute;top:0px;left:0px;width:"+t.width+"px;height:"+t.height+"px;z-index:1;background:url("+QMW2.resourcePath+"/images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.fileName+"',sizingMethod='scale')\">&nbsp;</div>";}else{return "<img style=\"position:absolute;top:0px;left:0px\" src=\""+this.fileName+"\" width=\""+t.width+"\" height=\""+t.height+"\"/>";}}},addFeature:function(N,t){QMW2.map.layers.WMSLayer.prototype.addFeature.apply(this,arguments);if(t){this.setNamespace(t,N);}},setNamespace:function(t,N){this.namespaces[N]=t;}});QMW2.map.layers.Layer.implementations["dynamicwms"]=function(n,m,t){var x=QMW2.Application.checkEntity(n);if(x){return x;}if(typeof n.featureName==="undefined"){return $L("entity_missing_featurename")+": "+n.name;}if(!QMW2.map.rendering.Renderer.implementations["sld"]){return $L("entity_unknown_sld_renderer")+": "+n.name+"."+n.featureName;}var F=n.errorIsNotBlocking||false;var w=m.getLayer(n.name);action="wmsMap";var N=n.src||action;if(t[N]){if(!w){var p=n.priority;var j=n.opacity;if(typeof n.layerpriority!=="undefined"){p=n.layerpriority;}w=new QMW2.map.layers.DynamicWMSLayer(n.name,m,parseInt(p,10),n.name,"image/"+n.outputFormat,t[N],action,F,n.useAsCanvas);if(typeof j!=="undefined"){w.setOpacity(j);}m.addLayer(w);}var P=parseInt(n.priority,10);if(!w.isPriorityOccupied(P)){w.addFeature(n.featureName,n.namespace);w.setPriority(P,n.featureName);var B=QMW2.map.rendering.Renderer.implementations["sld"].newInstance();w.setRenderingManager(B,n.featureName,n.Style);if(n.visible){B.setAllProperty("visibility",true);}else{B.setAllProperty("visibility",false);}var f=QMW2.Application.getScaleConfiguration(n,m);if(f){B.setAllProperty("scale",f);}}else{QMW2.Application.error($L("entity_not_allowed_overlapping_priority"));}return w;}else{return $L("entity_datasource_unknown")+": "+n.name;}};QMW2.moduleLoaded("map.dynamicwmslayer");QMW2.loadModule("map.layers");Ext.namespace("QMW2.map.layers.extenders.TooltipExtender");QMW2.map.layers.extenders.TooltipExtender.addExtender=function(t){QMW2.map.layers.Layer.implementations[t]=QMW2.map.layers.Layer.implementations[t].createFlow(function(N,P,n,m){if(typeof m==="object"){if(!m.tooltipExtenderApplied){QMW2.decorate(m,{tooltipExtenderApplied:true,activeTooltip:null,activeTooltipMapName:null,tooltips:{},setFeatureTooltip:function(w,j,B,x,f){this.tooltips[w]={expression:j,description:B,ifvisible:f};if(x){this.activeTooltip=w;}},activateTooltip:function(w){this.activeTooltip=w;if(w&&this.isTooltipVisible(this.realRange)){this.changed=true;}else{if(this.activeTooltipMapName&&$(this.activeTooltipMapName)){Ext.fly(this.activeTooltipMapName).remove();}}},filterTooltipStyle:function(B){var x=[];for(var f=0;f<B.length;f++){var w=B[f];if(this.isCurrentlyVisible(w)){var j=this.getStyleFilter(this.styles[w]);if(j){x.push(j);}}}if(x.length==1){this.applyTooltipFilter(this.currentTooltip,x[0]);}else{if(x.length>1){this.applyTooltipFilter(this.currentTooltip,"<ogc:Or>"+x.join("")+"</ogc:Or>");}}},applyTooltipFilter:function(x,B){var j=x.style;var w=this.getStyleFilter(j);var f;if(w){f=this.replaceFilter(j,"<ogc:And>"+w+B+"</ogc:And>");}else{f=this.replaceFilter(j,B);}x.style=f;},getTooltip:function(){if(this.currentTooltip){var w=this.tooltips[this.activeTooltip];if(w.ifvisible){this.filterTooltipStyle(w.ifvisible.split(","));}return this.currentTooltip;}return null;},engineSend:function(w){var j=this.getTooltip();if(j){w["extra"]=Ext.urlEncode(j);}this.engine.sendMsg(this.action,this.responseFromEngine.createDelegate(this),w);},isTooltipVisible:function(f){var p=this.tooltips[this.activeTooltip];var F=p.ifvisible?p.ifvisible.split(","):[this.activeTooltip];for(var x=0;x<F.length;x++){var j=F[x];var w=this.renderingManagers[j];if(!w){if(j.indexOf(".")!=-1){var B=j.substring(0,j.indexOf("."));if(B!=this.name){QMW2.Application.error($L("wrong_tooltip_layer")+": "+B);return false;}j=j.substring(j.indexOf(".")+1);w=this.renderingManagers[j];}}if(w){if(this.isCurrentlyVisible(j)){return true;}}else{QMW2.Application.error($L("wrong_tooltip_entity_ifvisible")+": "+j);return false;}}return false;},getWmsQuery:{before:function(j,w){if(this.activeTooltip&&this.isTooltipVisible(j)){this.currentTooltip={tooltip:this.tooltips[this.activeTooltip].expression,style:this.renderingManagers[this.activeTooltip].getWmsLayer(this.styles[this.activeTooltip],true)};}else{this.currentTooltip=null;}}},responseFromEngine:{before:function(j,w){if(this.currentTooltip&&j!="FAILURE"){var B=w.substring(w.indexOf(",")+1);B=B.substring(B.indexOf(",")+1).replace(/\\\'/g,"'");this.activeTooltipMapName=this.activeTooltip;var f=new RegExp("<map\\s*name=\"(.*?)\"","gi");var w;while((w=f.exec(B))!==null){this.activeTooltipMapName=w[1];B="<map id=\""+this.activeTooltipMapName+"\""+B.substring(4);}this.activeTooltipMap=B;}}},getLayerHTML:{flow:function(w){if(this.currentTooltip){var B=this.getSize();if(this.fileName.indexOf(".png")!=-1&&!QMW2.hasCapability("PNG24")){w+="<img style=\"position:absolute;top:0px;left:0px;z-index:2\" src=\""+QMW2.resourcesPath+"/images/spacer.gif\" width=\""+B.width+"\" height=\""+B.height+"\"/>";}var j=w.substring(0,w.length-2)+" usemap=\"#"+this.activeTooltipMapName+"\"/>";this.currentTooltip=null;return this.activeTooltipMap+j;}else{return w;}}}});}if(N.Tooltip){m.setFeatureTooltip(N.featureName,N.Tooltip.Text,N.Tooltip.description,N.Tooltip.active,N.Tooltip.ifvisible);}return m;}});};QMW2.addModuleInitializer("map.impl.tooltipextender",function(t){if(t.typesToExtend){var N=QMW2.getArray(t.typesToExtend);for(var P=0;P<N.length;P++){var m=N[P];QMW2.map.layers.extenders.TooltipExtender.addExtender(m);}}else{}});QMW2.moduleLoaded("map.impl.tooltipextender");QMW2.loadModule("map.layers");QMW2.loadModule("map.rendering");QMW2.loadModule("coordinates");QMW2.declare("QMW2.map.layers.PublicApiLayer",QMW2.map.layers.Layer,{initializer:function(name,map,priority,options){QMW2.map.layers.PublicApiLayer.superclass.constructor.call(this,name,map,priority);this.map=null;this.type="publicapi";this.zoomLimit=22;this.xOffset=0;this.yOffset=0;this.implementation=null;if(options){eval("this.options={"+options+"};");}else{this.options={};}},resize:function(){if(this.implementation&&this.implementation.resize){var m=this.realRange.getDeltaX();if(this.isVisible()&&this.visibleInScale(m)){var N=this.getSize();var t=Ext.get("publicApiMask"+this.name);if(t){t.setSize(N);}this.implementation.resize(N.width,N.height);}}},load:function(w,P,m){var j=this.getRenderingManager(this.name);var B=j.getAnyProperty("maptype");var N=this.getContainer();var n=this.getSize();var t=Ext.get("publicApiMask"+this.name);t.dom.src=QMW2.resourcesPath+"/images/spacer.gif";t.setSize(n);this.projection=QMW2.coordinates.Projections[this.crs];this.implementation=QMW2.map.layers.PublicApiLayerImplementations[B];this.implementation.options=this.options;if(this.implementation){this.implementation.load(w,P,m,B,this.getContainerName(),this);}else{this.endHandler(this.name);}},isPrintable:function(){return false;},setLoaded:function(m,N,t){this.loaded=true;this.updateRange(m,N,t);},init:function(){return "<div id=\"layer"+this.name+"Container\" style=\"position:absolute;top:0px;left:0px;z-index: "+this.priority+";visibility:hidden\"><div id=\"layer"+this.name+"map\" style=\"position:absolute;top:0px;left:0px;z-index:1\">&nbsp;</div><div id=\"layer"+this.name+"mask\" style=\"position:absolute;top:0px;left:0px;z-index:2\"><img id=\"publicApiMask"+this.name+"\" src=\"about:blank\"/></div></div>";},getContainerName:function(){return "layer"+this.name+"map";},hide:function(){if(this.reallyVisible){this.implementation.hide();Ext.fly(this.getContainer()).update("");}QMW2.map.layers.Layer.prototype.hide.apply(this,arguments);},updateProperty:function(t,P,m,N){switch(P){case "visibility":if(m){if(N){return false;}}else{this.hide();this.unload();}break;case "opacity":break;case "maptype":if(N){this.unload();return false;}break;default:break;}return true;},updateRange:function(t,N,m){this.getContainer().setLeftTop(0,0);var j=t.minX+t.getDeltaX()/2+this.xOffset;var w=t.minY+t.getDeltaY()/2+this.yOffset;this.realRange=t.copy();var f=this.getSize();if(this.projection){var n=this.projection.toGeographic(new QMW2.coordinates.Point(j,w));var P=2*Math.PI*6378137*f.width;var B=Math.round(Math.log(P/t.getDeltaX()/512)*Math.LOG2E);if(B<1){B=1;}if(B>this.zoomLimit){B=this.zoomLimit;}if(this.implementation.isEnabled()){this.implementation.updateRange(n.y,n.x,B+1);}this.endHandler(this.name);}else{this.changed=true;this.endHandler(this.name,true,$L("unrecognized_crs")+" :"+this.crs);}},startInteractivePan:function(){},fromFactorToLevel:function(t){return Math.round(Math.log(t)*Math.LOG2E);},interactiveZoom:function(t){if(this.implementation){var N=this.realRange.getDeltaX();if(this.isVisible()&&this.visibleInScale(N)){this.changed=true;this.implementation.interactiveZoom(this.fromFactorToLevel(t));}}},interactivePan:function(N,P,t,m){if(!isNaN(N)&&!isNaN(P)&&!isNaN(t)&&!isNaN(m)){this.getContainer().setLeftTop(t-N,m-P);}},endInteractivePan:function(){},undoInteractivePan:function(){this.getContainer().setLeftTop(0,0);}});QMW2.map.layers.Layer.implementations["publicapi"]=function(N,j){var m=QMW2.Application.checkEntity(N);if(m){return m;}if((N.xOffset&&!QMW2.checkInt(N.xOffset))||(N.yOffset&&!QMW2.checkInt(N.yOffset))){return $L("entity_wrong_offset")+": "+N.name;}var B=QMW2.Application.getScaleConfiguration(N,j);var n=1;if(N.scaleFactor){if(!QMW2.checkFloat(N.scaleFactor)){return $L("entity_wrong_scalefactor")+": "+N.name;}n=N.scaleFactor;}var P=j.getLayer(N.name);if(!P){P=new QMW2.map.layers.PublicApiLayer(N.name,j,parseInt(N.priority),N.options);if(N.xOffset){P.xOffset=N.xOffset;}if(N.yOffset){P.yOffset=N.yOffset;}P.addFeature(N.name);P.setPriority(parseInt(N.priority),N.name);j.addLayer(P);if(!j.isPublicApiEnabled){j.isPublicApiEnabled=true;var t=j.updateView;j.updateView=function(F,f,p,x){t.apply(this,[F,f,p,x]);this.projectionConstant=2*Math.PI*6378137*F;this.adjustRange(this.realRange);};QMW2.map.Map.prototype.getBestZoomLevel=function(x){var f=Math.round(x);if((f-x)<0.01){return f;}return Math.floor(x);};QMW2.map.Map.prototype.adjustRange=function(F){var x=QMW2.Application.options.maxZoom||22;var D=this.getBestZoomLevel(Math.log(this.projectionConstant/F.getDeltaX()/512)*Math.LOG2E);if(D<1){D=1;}if(D>x){D=x;}var e=512*Math.pow(2,D);var p=this.projectionConstant/e;var f=p*this.realRange.getDeltaY()/this.realRange.getDeltaX();var X=F.minX+F.getDeltaX()/2;var J=F.minY+F.getDeltaY()/2;F.minX=X-p/2;F.maxX=X+p/2;F.minY=J-f/2;F.maxY=J+f/2;};}var w=QMW2.map.rendering.Renderer.implementations["publicapi"].newInstance();P.setRenderingManager(w,N.name);w.addSelector(N.name);if(N.visible){w.setAllProperty("visibility",true);}var B=QMW2.Application.getScaleConfiguration(N,j);if(B){w.setAllProperty("scale",B);}w.setAllProperty("maptype",N.mapType);return P;}else{return $L("already_existing_layer")+": "+N.name;}};QMW2.declare("QMW2.map.layers.PublicApiLayerImplementation",null,{initializer:function(){this.map=null;this.loaded=false;this.invalid=false;this.tryCounter=0;},loadApiAndRetry:function(){if(!this.timeout){if(this.options&&this.options["timeout"]){this.timeout=this.options["timeout"]*10;}else{this.timeout=300;}}if(!this.loaded){this.loaded=true;this.loadApi();}this.tryCounter++;if(this.tryCounter>=this.timeout){this.invalid=true;QMW2.Application.error($L("cant_load_api_"+this.apitype));}this.load.defer(100,this,arguments);},load:function(m,N,t){},hide:function(){},setMapType:function(t){},updateRange:function(N,m,t){}});QMW2.map.layers.PublicApiLayerImplementations={};QMW2.declare("QMW2.map.rendering.PublicApiRenderer",QMW2.map.rendering.Renderer,{initializer:function(){this.type="publicapi";QMW2.map.rendering.PublicApiRenderer.superclass.constructor.call(this);this.addSelector("publicapi",true);},drawSample:function(m,P,N,t){m.drawImage(QMW2.resourcesPath+"/images/raster.gif",0,0,P,N);},newInstance:function(){return new QMW2.map.rendering.PublicApiRenderer();}});QMW2.map.rendering.Renderer.implementations["publicapi"]=new QMW2.map.rendering.PublicApiRenderer();QMW2.moduleLoaded("map.publicapi");QMW2.loadModule("map.publicapi");QMW2.declare("QMW2.map.layers.VirtualEarthImplementation",QMW2.map.layers.PublicApiLayerImplementation,{initializer:function(){QMW2.map.layers.VirtualEarthImplementation.superclass.constructor.call(this);this.apitype="virtualearth";this.needsHack=false;this.container=null;},resize:function(N,t){this.map.Resize(N,t);},isEnabled:function(){return (typeof VEMap!=="undefined");},loadApi:function(){if(QMW2.map.layers.VirtualEarthImplementation.loadClientSide){QMW2.addScript("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1");}else{QMW2.addScript(QMW2.servicesPath+"/PublicApiLoader.aspx?api=virtualearth");}},applyHack:function(){if(!this.needsHack&&(typeof HTMLElement!=="undefined")&&(typeof HTMLElement.prototype.attachEvent==="undefined")){this.needsHack=true;}if(this.needsHack){HTMLElement.prototype.attachEvent=function(){};window.attachEvent=function(){};HTMLElement.prototype.detachEvent=function(){};}},removeHack:function(){if(this.needsHack){HTMLElement.prototype.attachEvent=undefined;window.attachEvent=undefined;HTMLElement.prototype.detachEvent=undefined;}},load:function(n,m,N,w,t,P){if(this.isEnabled()){this.applyHack();this.container=t;this.map=new VEMap(t);this.map.LoadMap(new VELatLong(47.6,-122.33),10,"r",false);this.map.HideDashboard();this.setMapType(w);this.removeHack();P.setLoaded(n,m,N);}else{if(!this.invalid){this.loadApiAndRetry.apply(this,arguments);}else{P.setLoaded(n,m,N);}}},hide:function(){if(this.map){this.map.Dispose();}},setMapType:function(t){if(t=="vesatellite"){this.map.SetMapStyle(VEMapStyle.Aerial);}else{if(t=="vehybrid"){this.map.SetMapStyle(VEMapStyle.Hybrid);}}},updateRange:function(N,m,t){this.map.SetCenterAndZoom(new VELatLong(N,m),t);},interactiveZoom:function(t){this.map.SetZoomLevel(this.map.GetZoomLevel()+t);}});QMW2.map.layers.VirtualEarthImplementation.loadClientSide=false;QMW2.map.layers.PublicApiLayerImplementations["vehybrid"]=new QMW2.map.layers.VirtualEarthImplementation();QMW2.map.layers.PublicApiLayerImplementations["vesatellite"]=new QMW2.map.layers.VirtualEarthImplementation();QMW2.map.layers.PublicApiLayerImplementations["veroad"]=new QMW2.map.layers.VirtualEarthImplementation();QMW2.addModuleInitializer("map.impl.virtualearth",function(t){if(typeof VEMap==="undefined"&&t&&!t.lazyload){document.write("<script type='text/javascript' src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1'></script>");}if(t.loadClientSide){QMW2.map.layers.VirtualEarthImplementation.loadClientSide=true;}});QMW2.moduleLoaded("map.impl.virtualearth");QMW2.loadModule("map.publicapi");QMW2.declare("QMW2.map.layers.GoogleMapsImplementation",QMW2.map.layers.PublicApiLayerImplementation,{initializer:function(){QMW2.map.layers.GoogleMapsImplementation.superclass.constructor.call(this);this.apitype="google";},resize:function(N,t){this.map.checkResize();},getKey:function(){var t=QMW2.map.layers.GoogleMapsImplementation.getKeyFrom(this.options);if(!t){t=QMW2.map.layers.GoogleMapsImplementation.key;}return t;},isEnabled:function(){return (typeof GMap2!=="undefined");},loadApi:function(){if(QMW2.map.layers.GoogleMapsImplementation.loadClientSide){QMW2.addScript("http://maps.google.com/maps?file=api&v=2.97&async=2&key="+this.getKey());}else{QMW2.addScript(QMW2.servicesPath+"/PublicApiLoader.aspx?api=google&key="+this.getKey());}},load:function(n,m,N,w,t,P){if(this.isEnabled()){this.map=new GMap2(Ext.getDom(t));this.map.disableDragging();this.map.disableDoubleClickZoom();this.map.setCenter(new GLatLng(40.5026833333333,14.8991833333333),13);this.setMapType(w);P.setLoaded(n,m,N);}else{if(!this.invalid){this.loadApiAndRetry.apply(this,arguments);}else{P.setLoaded(n,m,N);}}},setMapType:function(t){if(t=="googlesatellite"){this.map.setMapType(G_SATELLITE_MAP);}else{if(t=="googlehybrid"){this.map.setMapType(G_HYBRID_MAP);}else{if(t=="googlesky"){this.map.setMapType(G_SKY_VISIBLE_MAP);}else{if(t=="googleterrain"){this.map.setMapType(G_PHYSICAL_MAP);}}}}},updateRange:function(N,m,t){this.map.setCenter(new GLatLng(N,m),t);},interactiveZoom:function(t){this.map.setZoom(this.map.getZoom()+t);}});QMW2.map.layers.GoogleMapsImplementation.loadClientSide=false;QMW2.map.layers.PublicApiLayerImplementations["googlehybrid"]=new QMW2.map.layers.GoogleMapsImplementation();QMW2.map.layers.PublicApiLayerImplementations["googlesatellite"]=new QMW2.map.layers.GoogleMapsImplementation();QMW2.map.layers.PublicApiLayerImplementations["googleroad"]=new QMW2.map.layers.GoogleMapsImplementation();QMW2.map.layers.PublicApiLayerImplementations["googlesky"]=new QMW2.map.layers.GoogleMapsImplementation();QMW2.map.layers.PublicApiLayerImplementations["googleterrain"]=new QMW2.map.layers.GoogleMapsImplementation();QMW2.map.layers.GoogleMapsImplementation.getKeyFrom=function(t){if(typeof t.apikeys!=="undefined"){return t.apikeys[document.location.host];}return null;};QMW2.addModuleInitializer("map.impl.googlemaps",function(t){if(typeof GMap2==="undefined"&&t&&t.apikeys){var N=QMW2.map.layers.GoogleMapsImplementation.getKeyFrom(t);if(N){QMW2.map.layers.GoogleMapsImplementation.key=N;}if(!t.lazyload){document.write("<script type='text/javascript' src='http://maps.google.com/maps?file=api&amp;v=2.97&amp;key="+N+"'></script>");}}if(t.loadClientSide){QMW2.map.layers.GoogleMapsImplementation.loadClientSide=true;}});QMW2.moduleLoaded("map.impl.googlemaps");QMW2.loadModule("map.publicapi");QMW2.declare("QMW2.map.layers.YahooMapsImplementation",QMW2.map.layers.PublicApiLayerImplementation,{initializer:function(){QMW2.map.layers.YahooMapsImplementation.superclass.constructor.call(this);this.apitype="yahoo";},resize:function(N,t){this.map.resizeTo(new YSize(N,t));},isEnabled:function(){return (typeof YMap!=="undefined");},loadApi:function(){if(QMW2.map.layers.YahooMapsImplementation.loadClientSide){QMW2.addScript("http://us.js2.yimg.com/us.js.yimg.com/lib/map/js/api/ymapapi_3_4_1_5.js");}else{QMW2.addScript(QMW2.servicesPath+"/PublicApiLoader.aspx?api=yahoo&mode="+QMW2.frameworkMode);}},load:function(n,m,N,w,t,P){if(this.isEnabled()){this.map=new YMap(Ext.getDom(t));this.map.drawZoomAndCenter(new YGeoPoint(40.5026833333333,14.8991833333333),13);this.setMapType(w);P.setLoaded(n,m,N);}else{if(!this.invalid){this.loadApiAndRetry.apply(this,arguments);}else{P.setLoaded(n,m,N);}}},setMapType:function(t){if(t=="yahoosatellite"){this.map.setMapType(YAHOO_MAP_SAT);}else{if(t=="yahoohybrid"){this.map.setMapType(YAHOO_MAP_HYB);}else{this.map.setMapType(YAHOO_MAP_REG);}}},updateRange:function(N,m,t){var t=18-(t);if(t<1){t=1;}this.map.drawZoomAndCenter(new YGeoPoint(N,m),t);},interactiveZoom:function(t){this.map.setZoomLevel(this.map.getZoomLevel()-t);}});QMW2.map.layers.YahooMapsImplementation.loadClientSide=false;QMW2.map.layers.PublicApiLayerImplementations["yahoosatellite"]=new QMW2.map.layers.YahooMapsImplementation();QMW2.map.layers.PublicApiLayerImplementations["yahooroad"]=new QMW2.map.layers.YahooMapsImplementation();QMW2.map.layers.PublicApiLayerImplementations["yahoohybrid"]=new QMW2.map.layers.YahooMapsImplementation();QMW2.addModuleInitializer("map.impl.yahoomaps",function(t){if(typeof YMap==="undefined"&&t&&t.apikey){var N=t.apikey;window.YMAPPID=N;if(!t.lazyload){if(typeof YAHOO==="undefined"){document.write("<script type=\"text/javascript\" src=\""+QMW2.librariesPath+"/yui-0.12.0/utilities/bigutilities.js\"></script>");}document.write("<script type='text/javascript' src='http://us.js2.yimg.com/us.js.yimg.com/lib/map/js/api/ymapapi_3_4_1_5.js'></script>");}}if(t.loadClientSide){if(typeof YAHOO==="undefined"){document.write("<script type=\"text/javascript\" src=\""+QMW2.librariesPath+"/yui-0.12.0/utilities/bigutilities.js\"></script>");}QMW2.map.layers.YahooMapsImplementation.loadClientSide=true;}});QMW2.moduleLoaded("map.impl.yahoomaps");if(typeof Ext!=="undefined"){if(typeof Ext.lib.Easing==="undefined"&&typeof YAHOO!=="undefined"){Namespace("Ext.lib");Ext.lib.Easing=YAHOO.util.Easing;}if(typeof Ext.Resizable!=="undefined"){Ext.Resizable.prototype.destroy=function(m){this.proxy.remove();if(this.overlay){this.overlay.removeAllListeners();this.overlay.remove();}var P=Ext.Resizable.positions;for(var t in P){if(typeof P[t]!="function"&&this[P[t]]){var N=this[P[t]];N.el.removeAllListeners();N.el.remove();}}if(m){this.el.update("");this.el.remove();}};}if(typeof Ext.EventObject!=="undefined"){Ext.EventObject.getOffsetX=function(N){if(this.browserEvent){if(N){return this.getPageX()-Ext.fly(N).getX();}else{if(this.browserEvent.offsetX){return this.browserEvent.offsetX;}var m=this.getTarget();if(m){var t=0;while(m.offsetParent){t+=m.offsetLeft;m=m.offsetParent;}return this.getPageX()-t;}}}return null;};Ext.EventObject.getOffsetY=function(N){if(this.browserEvent){if(N){return this.getPageY()-Ext.fly(N).getY();}else{if(this.browserEvent.offsetY){return this.browserEvent.offsetY;}var m=this.getTarget();if(m){var t=0;while(m.offsetParent){t+=m.offsetTop;m=m.offsetParent;}return this.getPageY()-t;}}}return null;};Ext.EventObject.isLeftClicked=function(){if(this.browserEvent){if(typeof this.browserEvent.which!=="undefined"){return this.browserEvent.which==1;}else{if(typeof this.browserEvent.button!=="undefined"){return this.browserEvent.button==1;}}}return false;};}if(typeof Ext.EventObjectImpl!=="undefined"){Ext.EventObjectImpl.prototype.getOffsetX=Ext.EventObject.getOffsetX;Ext.EventObjectImpl.prototype.getOffsetY=Ext.EventObject.getOffsetY;Ext.EventObjectImpl.prototype.isLeftClicked=Ext.EventObject.isLeftClicked;}if(typeof Ext.Element!=="undefined"){Ext.Element.prototype.removeAllChilds=function(){var m=this.dom.childNodes;var t=[];for(var N=0;N<m.length;N++){t.push(m[N]);}for(var N=0;N<t.length;N++){this.dom.removeChild(t[N]);}t=null;};Ext.Element.prototype.setLocalBounds=function(N,n,P,t,m){if(!m){this.setSize(P,t);this.setLeftTop(N,n);}else{P=this.adjustWidth(P);t=this.adjustHeight(t);this.anim({left:{to:N},top:{to:n},width:{to:P},height:{to:t}},this.preanim(arguments,4),"motion");}return this;};}Ext.QMW2UtilsLoaded=true;}var QMW2Loader=function(){var B=0;var t=0;var w=null;var n=null;var m=null;var j=0;var f=0;var x=false;var P=null;var N=false;return {init:function(b,D,X,e){B=b;w=document.getElementById(D);P=X;if(e){N=e;}if(w){var v=w.className;if(v.length>1){v+=" ";}v+="qmw2-Loader";w.className=v;var J=window.getComputedStyle?window.getComputedStyle(w,""):w.currentStyle;var p=parseInt(J.borderLeftWidth,10);var F=parseInt(J.borderRightWidth,10);j=w.offsetWidth-p-F;f=Math.floor(j/B);w.innerHTML="<div id=\"qmw2LoaderBar\" class=\"qmw2-LoaderBar\"></div><div id=\"qmw2LoaderText\" class=\"qmw2-LoaderText\">0%</div>";n=document.getElementById("qmw2LoaderBar");m=document.getElementById("qmw2LoaderText");x=true;}else{alert("unknown DOM element: "+D);}},nextStep:function(){if(x){t++;var F=t*f;var p=Math.floor(F/j*100);if(t==B){p=100;F=j;}n.style.width=F+"px";m.innerHTML=p+"%";}},end:function(){n=null;m=null;if(x){w.style.display="none";}w=null;if(t!=B&&N){QMW2.Application.updateLoaderSteps(t,N);}if(P){P();}}};}();Namespace("QMW2.widgets.ui");QMW2.declare("QMW2.widgets.ui.Polyline",null,{initializer:function(t){this.blackboard=t;this.points=[];},draw:function(t,m){var N=t?this.points.concat(this.points[0]):this.points;this.blackboard.drawPolyline(N,m,true);},addPoints:function(){this.points.push.apply(this.points,arguments);},changeLastPoint:function(t,m){var N=this.points[this.points.length-1];N.x=t||0;N.y=m||0;},removeLastPoint:function(){return this.points.pop();}});QMW2.widgetLoaded("polyline");Namespace("QMW2.widgets.ui");QMW2.loadWidget("polyline");QMW2.declare("QMW2.widgets.ui.PolygonSelector",Ext.util.Observable,{initializer:function(P,B,N,f,n,w,x,m,j,p){this.name=P;this.cfg=B;this.map=N;this.eventManager=f;this.events={};this.dom=null;var t=m.split(",");this.stroke={color:t[0],weight:t[1],opacity:parseInt(t[2],10)/100};if(t.length>=5){this.fill={color:t[3],opacity:parseInt(t[4],10)/100};}this.events={"select":new Ext.util.Event(this,"select"),"undo":new Ext.util.Event(this,"undo")};this.cursor=x||"pointer";this.canvas=w||null;this.constraint=n;this.boxSelect=j||false;this.startEvent=j?"mousedown":"click";this.endEvent=j?"mouseup":"dblclick";this.pointSelect=p||false;},getDOM:function(){this.dom=document.createElement("div");this.dom.className="polygonSelectorMap";this.dom.id="polygonSelectorMap"+this.name;this.canvas=new quadratech.qmw2.canvas.ui.Canvas(this.dom,"polygonSelectorCanvas",1);return this.dom;},enableSelect:function(){this.canvas.show(this.cursor);this.canvas.on(this.startEvent,this.beginPolygonSelect.createDelegate(this));},disableSelect:function(){this.canvas.un(this.startEvent);this.canvas.un("mousemove");this.canvas.un(this.endEvent);},reenableSelect:function(){this.canvas.clear();this.enableSelect();},drawPolygon:function(){this.polygon.draw(true,this.stroke);},normalizeRect:function(){var j=this.polygon.points[0];var n=this.polygon.points[1];var t=j.x;var B=j.y;var N=n.x-j.x;var P=n.y-j.y;if(N<0){N=-N;t=n.x;}if(this.constraint){var m=parseInt(N/this.canvas.getWidth()*this.canvas.getHeight());if(P<0){B=j.y-m;}P=m;}else{if(P<0){P=-P;B=n.y;}}return {x:t,y:B,width:N,height:P};},drawRect:function(){var N=this.normalizeRect();var t=this.canvas.blackboard.getRectPoints(N.x,N.y,N.width,N.height);this.canvas.blackboard.drawPolygon(t,this.fill,this.stroke,true);},beginPolygonSelect:function(t){t.preventDefault();this.canvas.beginDraw();this.polygon=new QMW2.widgets.ui.Polyline(this.canvas.blackboard);if(this.boxSelect){this.canvas.on(this.endEvent,this.endBoxSelect.createDelegate(this));}else{this.canvas.on(this.startEvent,this.nextPolygonSelect.createDelegate(this));this.canvas.on(this.endEvent,this.endPolygonSelect.createDelegate(this));}this.canvas.on("mousemove",this.movePolygonSelect.createDelegate(this));this.polygon.addPoints({x:t.getOffsetX(),y:t.getOffsetY()},{x:t.getOffsetX(),y:t.getOffsetY()});},movePolygonSelect:function(t){if(this.boxSelect&&!t.isLeftClicked()){this.undoSelect();}else{this.polygon.changeLastPoint(t.getOffsetX(),t.getOffsetY());if(this.boxSelect){this.drawRect();}else{this.drawPolygon();}}},undoSelect:function(){this.canvas.un(this.endEvent);this.canvas.un("mousemove");this.canvas.clear();this.fireEvent("undo");},nextPolygonSelect:function(N){var t=N.getOffsetX();var m=N.getOffsetY();this.polygon.changeLastPoint(t,m);this.polygon.addPoints({x:t,y:m});this.drawPolygon();},endPolygonSelect:function(t){this.polygon.removeLastPoint();this.canvas.un("mousemove");this.canvas.un(this.endEvent);this.canvas.on(this.startEvent,this.beginPolygonSelect.createDelegate(this));this.canvas.erase();this.fireEvent("select",this.polygon.points);},endBoxSelect:function(t){var N=this.normalizeRect();if((N.width!=0&&N.height!=0)||this.pointSelect){this.canvas.un(this.endEvent);this.canvas.un("mousemove");this.canvas.erase();document.onselectstart=null;this.fireEvent("select",N.x,N.x+N.width,N.y,N.y+N.height);}else{this.undoSelect();}}});QMW2.widgetLoaded("polygonselector");Namespace("QMW2.blackboard.ui.Blackboard");QMW2.declare("QMW2.blackboard.ui.Blackboard",null,{initializer:function(t){this.container=t;this.buffer=[];this.clip=null;},addToBuffer:function(t){this.buffer.push(t);},doTransaction:function(t,m,N){if(t){this.begin();}m.apply(this,N);if(t){this.commit();}},drawImage:function(n,N,w,P,t,m){this.doTransaction(m,function(p,B,F,f,j){this.addToBuffer("<img src=\""+p+"\" width=\""+f+"\" height=\""+j+"\" style=\"position:absolute;top:"+F+"px;left:"+B+"px\">");},arguments);},drawString:function(w,t,j,P,n,m,N){this.doTransaction(N,function(e,B,D,p,F,f){this.addToBuffer("<div style=\"padding-left:"+B+"px;padding-top:"+D+"px;font-family:"+p+";font-size:"+F+"px;color:"+f+"\">"+e+"</div>");},arguments);},drawSymbol:function(n,N,B,P,t,j,w,m){this.doTransaction(m,function(D,p,b,e,f,X,J){var F=this.getSymbologyEncoder(D);if(F){F.drawSymbol(this,D,p,b,e,f,X,J);}else{this.drawEllipse(p,b,e,f,X,J);}},arguments);},drawPolygon:function(m,P,N,t){this.doTransaction(t,function(j,B,w){if(w){this.drawPolyline(j,w,false);}if(B&&B.color){this.drawArea(j,B);}if(B.graphicfill&&B.graphicfill.mark){var n=this.getRange(j);var f=B.graphicfill.mark;this.drawSymbol(f.symbol,n.minX,n.minY,n.getDeltaX(),n.getDeltaY(),f.stroke,f.fill);}},arguments);},begin:function(){this.container.innerHTML="";},commit:function(){this.container.innerHTML=this.buffer.join("");this.buffer=[];this.clip=null;},getSymbologyEncoder:function(m){var N=QMW2.blackboard.ui.Blackboard.SymbologyEncoders;for(var t in N){if(N[t].canProcess(m)){return N[t];}}return null;},getRange:function(m){var t=m[0];var N=new QMW2.map.Range(t.x,t.x,t.y,t.y);for(var P=1;P<m.length;P++){t=m[P];N=N.union(new QMW2.map.Range(t.x,t.x,t.y,t.y));}return N;},setClip:function(t){this.clip=t;},getRectPoints:function(N,P,m,t){N=N||0;P=P||0;m=m||1;t=t||1;return [{x:N,y:P},{x:N+m,y:P},{x:N+m,y:P+t},{x:N,y:P+t},{x:N,y:P}];}});QMW2.declare("QMW2.blackboard.ui.VMLBlackboard",QMW2.blackboard.ui.Blackboard,{initializer:function(N,t){QMW2.blackboard.ui.VMLBlackboard.superclass.constructor.apply(this,[N]);this.cls=t;},getCoordinates:function(N){var P=[];for(var m=0;m<N.length;m++){var t=N[m];P.push(Math.floor(t.x)+"px,"+Math.floor(t.y)+"px");}return P.join(" ");},drawPolyline:function(N,m,t){this.doTransaction(t,function(w,j){var n=this.getOpacity(j.opacity);var P="color=\""+j.color+"\" weight=\""+j.weight+"\" opacity=\""+n+"\"";if(j.dashed){P+=" dashstyle=\"1 1\"";}this.addToBuffer("<v:polyline style=\"position:absolute;left:0px;top:0px\" filled=\"false\" points=\""+this.getCoordinates(w)+"\"><v:stroke "+P+"/></v:polyline>");},arguments);},getOpacity:function(t){return (t?Math.floor(t*100):100)+"%";},drawArea:function(N,m){var t=this.getOpacity(m.opacity);this.addToBuffer("<v:polyline style=\"position:absolute;left:0px;top:0px\" stroked=\"false\" points=\""+this.getCoordinates(N)+"\"><v:fill opacity=\""+t+"\" color=\""+m.color+"\"></v:fill></v:polyline>");},drawEllipse:function(N,j,P,t,w,n,m){this.doTransaction(m,function(D,e,p,J,X,b){var v=b?"<v:fill color=\""+b.color+"\"/>":"";var F=b?" filled=\"true\"":" filled=\"false\"";var f=X?"<v:stroke color=\""+X.color+"\" weight=\"1\"/>":"";var B=X?" stroked=\"true\"":" stroked=\"false\"";this.addToBuffer("<v:oval style=\"position:absolute;left:"+D+"px;top:"+e+"px;width:"+p+"px;height:"+J+"px\""+F+B+">"+v+f+"</v:oval>");},arguments);},addToBuffer:function(N){var t;var m="";if(this.clip){m=" style=\"position:absolute;clip:rect("+this.clip.minY+"px "+this.clip.maxX+"px "+this.clip.maxY+"px "+this.clip.minX+"px);width:"+this.clip.getDeltaX()+"px;height:"+this.clip.getDeltaY()+"px\"";}if(this.cls){t="<div class=\""+this.cls+"\""+m+">"+N+"</div>";}else{t="<div"+m+">"+N+"</div>";}this.buffer.push(t);}});QMW2.declare("QMW2.blackboard.ui.CanvasBlackboard",QMW2.blackboard.ui.Blackboard,{initializer:function(N,t){QMW2.blackboard.ui.CanvasBlackboard.superclass.constructor.apply(this,[N]);this.ctx=t;},setClip:function(t){this.clip=t;if(this.clip){this.ctx.save();this.ctx.beginPath();this.ctx.rect(t.minX,t.minY,t.getDeltaX(),t.getDeltaY());this.ctx.clip();}else{this.ctx.restore();}},drawPath:function(N,t){this.ctx.beginPath();this.ctx.moveTo(N[0].x,N[0].y);for(var m=1;m<N.length;m++){if(t){this.ctx.lineTo(Math.floor((N[m].x+N[m-1].x)/2),Math.floor((N[m].y+N[m-1].y)/2));this.ctx.moveTo(N[m].x,N[m].y);}else{this.ctx.lineTo(N[m].x,N[m].y);}}},drawPolyline:function(N,m,t){this.doTransaction(t,function(n,j){this.ctx.globalAlpha=j.opacity||1;this.ctx.strokeStyle=j.color;var P=0;try{P=parseInt(j.weight,0);}catch(w){}this.ctx.lineWidth=P;this.drawPath(n,j.dashed);this.ctx.stroke();},arguments);},drawEllipse:function(N,j,P,t,w,n,m){this.doTransaction(m,function(f,D,p,B,e,F){this.ctx.globalAlpha=1;this.ctx.beginPath();p=p/2;this.ctx.arc(Math.floor(f+p/2)+1,Math.floor(D+B/2),p,0,2*Math.PI,false);if(F){this.ctx.fillStyle=F.color;this.ctx.fill();}if(e){this.ctx.strokeStyle=e.color;this.ctx.lineWidth=1;this.ctx.stroke();}},arguments);},drawArea:function(t,N){this.ctx.globalAlpha=N.opacity||1;this.ctx.fillStyle=N.color;this.drawPath(t,false);this.ctx.fill();},begin:function(){this.ctx.clearRect(0,0,this.container.width||Ext.fly(this.container).getWidth(),this.container.height||Ext.fly(this.container).getHeight());}});QMW2.blackboard.ui.Blackboard.implementations={};QMW2.blackboard.ui.Blackboard.implementations["VML"]=function(t){return new QMW2.blackboard.ui.VMLBlackboard(t);};QMW2.blackboard.ui.Blackboard.implementations["CANVAS"]=function(N,t){return new QMW2.blackboard.ui.CanvasBlackboard(N,t);};QMW2.blackboard.ui.Blackboard.SymbologyEncoders={};QMW2.widgetLoaded("blackboard");Namespace("QMW2.canvas.ui");QMW2.loadWidget("blackboard");QMW2.declare("QMW2.canvas.ui.Canvas",null,{initializer:function(t,n,P,N,m){this.container=t;this.name=n;this.index=P;this.crs=N;this.blackboardContainer=null;this.blackboard=null;this.ctx=null;this.capturer=m;this.eventHandlers={};this.outOfCanvasEventHandlers={};this.currentCursor="default";this.useCanvas=QMW2.hasCapability("Canvas");if(!QMW2.hasCapability("Canvas")&&!QMW2.hasCapability("VML")){QMW2.Application.error($L("canvas_not_supported"));}},getCRS:function(){return this.crs;},getWidth:function(){return this.container.offsetWidth;},getHeight:function(){return this.container.offsetHeight;},getRealX:function(t,N){var m=N.getDeltaX()/this.getWidth();return t*m+N.minX;},getRealY:function(m,N){var t=N.getDeltaY()/this.getHeight();return (this.getHeight()-m)*t+N.minY;},getScreenX:function(t,N){var m=N.getDeltaX()/this.getWidth();return (t-N.minX)/m;},getScreenY:function(m,N){var t=N.getDeltaY()/this.getHeight();return this.getHeight()-(m-N.minY)/t;},createBlackboard:function(){var N;if(this.useCanvas){N=document.createElement("canvas");N.setAttribute("width",this.container.offsetWidth);N.setAttribute("height",this.container.offsetHeight);}else{N=document.createElement("div");}N.setAttribute("id",this.name);N.className=this.name;N.style.top="0px";N.style.left="0px";N.style.width=this.container.offsetWidth+"px";N.style.height=this.container.offsetHeight+"px";N.style.clip="rect(0px "+this.container.offsetWidth+"px "+this.container.offsetHeight+"px 0px)";N.style.position="absolute";N.style.zIndex=this.index;N.style.display="none";if(this.externalCapturer){Ext.get(this.externalCapturer).appendChild(N);}else{this.container.appendChild(N);}this.blackboardContainer=N;var t=null;if(this.useCanvas){t=N.getContext("2d");}else{N.innerHTML="<v:rect id=\""+this.name+"Canvas\" style=\"position:absolute;top:0px;left:0px;width:10000px;height:10000px;z-index:3000\"><v:stroke opacity=\"0\" color=\"red\"/><v:fill opacity=\"0\" color=\"red\"/></v:rect>";}this.blackboard=QMW2.blackboard.ui.Blackboard.implementations[this.useCanvas?"CANVAS":"VML"](N,t);},createCapturer:function(m){var N=document.createElement("img");N.setAttribute("id",this.name+"Capturer");N.className="qmw2-unselectable";N.src=QMW2.resourcesPath+"/images/spacer.gif";this.container.appendChild(N);N.style.width=this.container.offsetWidth+"px";N.style.height=this.container.offsetHeight+"px";N.style.position="absolute";N.style.zIndex=this.index+1;Ext.get(N).swallowEvent("selectstart",true);Ext.get(N).swallowEvent("dragstart",true);if(m){N.style.cursor=m.toLowerCase();}this.internalCapturer=$(this.name+"Capturer");if(this.capturer){N.style.display="none";var t=this.capturer.getContainer();Ext.get(t).swallowEvent("selectstart",true);Ext.get(t).swallowEvent("dragstart",true);if(m){this.currentCursor=m.toLowerCase();t.setStyle("cursor",this.currentCursor);}this.externalCapturer=t;}},show:function(t){this.createCapturer(t);this.createBlackboard();},removeBlackboard:function(){if(this.blackboardContainer){this.blackboardContainer.parentNode.removeChild(this.blackboardContainer);this.blackboardContainer=null;this.blackboard=null;}},removeCapturer:function(){if(this.internalCapturer){Ext.fly(this.internalCapturer).removeAllListeners();this.internalCapturer.parentNode.removeChild(this.internalCapturer);this.internalCapturer=null;}if(this.externalCapturer){Ext.fly(this.externalCapturer).removeAllListeners();Ext.fly(this.externalCapturer).setStyle("cursor","default");}this.eventHandlers={};this.outOfCanvasEventHandlers={};},clear:function(){this.endDraw();this.removeCapturer();this.removeBlackboard();},on:function(N,m,t,w){if(this.eventHandlers[N]){this.un(N);}var n=null;var P=w?true:false;if(!t){n=m;}else{P=true;n=function(j,B){if(this.within(j)){m(j);}else{t(j);}}.createDelegate(this);}if(P){Ext.fly(document).on(N,n);}else{Ext.fly(this.internalCapturer).on(N,n);if(this.externalCapturer){Ext.fly(this.externalCapturer).on(N,n);}}this.eventHandlers[N]=n;},un:function(t,N){if(this.eventHandlers[t]){if(N){Ext.fly(document).un(t,this.eventHandlers[t]);}else{Ext.fly(this.internalCapturer).un(t,this.eventHandlers[t]);if(this.externalCapturer){Ext.fly(this.externalCapturer).un(t,this.eventHandlers[t]);}}}},within:function(t){var N=new Ext.lib.Point(t.getPageX(),t.getPageY());return Ext.fly(this.internalCapturer).getRegion().contains(N)||(this.externalCapturer&&Ext.fly(this.externalCapturer).getRegion().contains(N));},beginDraw:function(){this.setBlackboardVisible(true);if(this.externalCapturer&&this.internalCapturer.style.display=="none"){this.internalCapturer.style.display="block";}},endDraw:function(){if(this.externalCapturer&&this.internalCapturer&&this.internalCapturer.style.display=="block"){this.internalCapturer.style.display="none";}},setBlackboardVisible:function(t){this.blackboardContainer.style.display=t?"block":"none";if(this.externalCapturer){Ext.fly(document.body).setStyle("cursor",t?this.currentCursor:"default");}},erase:function(){this.setBlackboardVisible(false);this.endDraw();this.blackboard.begin();},getCapturer:function(){if(this.internalCapturer){return Ext.get(this.internalCapturer);}else{if(this.externalCapturer){return Ext.fly(this.externalCapturer);}}return null;}});QMW2.widgetLoaded("canvas");QMW2.loadWidget("canvas");QMW2.declare("QMW2.ui.Map",null,{initializer:function(){this.layersToBeUpdated={};this.layersUpdated={};this.container=null;this.layersContainer=null;this.errorContainer=null;this.loadingEl=null;this.dpi=null;this.canvasOnLayer=null;this.type="map";this.reload=false;this.updatable=true;},enableUpdate:function(t){this.updatable=t;},getDimension:function(t,N){return N?"100%":t;},createErrorContainer:function(N,t){this.errorContainer=Ext.DomHelper.append(this.container,{tag:"div",id:"mapError"+this.name,cls:"qmw2-mapError",children:[{tag:"p",id:"mapErrorMsg"+this.name,cls:"qmw2-mapErrorMsg"}]},true).setPositioning({position:"absolute",left:0,top:0,"z-index":this.staticIndex+2}).setSize(this.getDimension(this.mapWidth,N),this.getDimension(this.mapHeight,t)).setDisplayed("none");},createLayersContainer:function(){this.layersContainer=Ext.DomHelper.append(this.container,{tag:"div",id:"layersContainer"+this.name,cls:"qmw2-layersContainer"},true).setPositioning({position:"absolute",left:0,top:0,"z-index":this.staticIndex}).setSize(this.mapWidth,this.mapHeight);},createPanArrows:function(N){for(var t in QMW2.ui.Map.panArrows){Ext.DomHelper.append(this.frame,{tag:"div",id:"mapPan"+t+this.name,cls:"qmw2-mapPan"+t+" qmw2-mapPan"},true);}},getArrowPosition:function(P,N,t,m){var n=(N==1)?1:2;switch(P){case 0:return Math.floor((this.frameSize-t/n)/2);case 1:return Math.floor((m-t)/2);case 2:return Math.floor(m-t-(this.frameSize-t/n)/2);}},positionPanArrows:function(N,n){var m=QMW2.ui.Map.panArrows;for(var P in m){var t=m[P].x;var j=m[P].y;var w=Ext.get("mapPan"+P+this.name);w.setLeftTop(this.getArrowPosition(t,j,w.getWidth(),N),this.getArrowPosition(j,t,w.getHeight(),n));}},cfgFrame:function(P,m){if(this.frame){var t=this.mapWidth+this.frameSize*2;var N=this.mapHeight+this.frameSize*2;this.frame.setPositioning({"position":"relative","left":0,"top":0,"z-index":this.staticIndex}).setSize(this.getDimension(t,P),this.getDimension(N,m));this.container.setLeftTop(this.frameSize,this.frameSize);if(this.withPan){this.createPanArrows();this.positionPanArrows(t,N);}}},calculateDim:function(t,m){if(t[m]){return t[m];}var N=m=="width"?this.container.getWidth():this.container.getHeight();if(t.withFrame){N-=this.frameSize*2;}return N;},init:function(t){this.cfg=t;this.name=t.name;this.map=t.map;this.container=Ext.get(t.container||this.name);this.frameSize=t.withFrame?t.frameWidth:0;this.mapWidth=this.calculateDim(t,"width");this.mapHeight=this.calculateDim(t,"height");this.crs=t.crs||this.map.realRange.crs;this.endAction=t.onEnd;this.staticIndex=t.baseIndex||1;this.eventManager=t.eventManager||this.map.eventManager;var P=(!t.width);var m=(!t.height);this.container.setPositioning({"position":"relative","left":0,"top":0,"z-index":this.staticIndex}).setSize(this.mapWidth,this.mapHeight).clip();this.createLayersContainer();if(t.canvasOnLayer){for(var N in this.map.layers){if(this.map.layers[N].hasCanvas()){this.canvasOnLayer=this.map.layers[N];}}if(!this.canvasOnLayer){for(var N in this.map.layers){if(this.map.layers[N].canBeUsedAsCanvas()){this.canvasOnLayer=this.map.layers[N];}}}}if(t.withPan){this.withPan=true;}if(t.withFrame){this.frame=Ext.get(this.container.dom.parentNode);this.cfgFrame(P,m);}if(t.errorContainer){this.errorContainer=t.errorContainer;}else{if(t.errorHandler){this.createErrorContainer(P,m);}}this.attachFrameworkEvents();this.attachEvents();},provideObject:function(t){if(t=="canvas"){if(this.canvasOnLayer){return new QMW2.canvas.ui.Canvas(this.container.dom,this.name+"Canvas",this.staticIndex+1,this.crs,this.canvasOnLayer);}else{return new QMW2.canvas.ui.Canvas(this.container.dom,this.name+"Canvas",this.staticIndex+1,this.crs);}}return null;},attachFrameworkEvents:function(){this.eventManager.attachToEvent("mapUpdated",this.update.createDelegate(this));this.eventManager.attachToEvent("mapStopped",this.cancelLoading.createDelegate(this));this.eventManager.attachToEvent("layerAdded",this.addLayer.createDelegate(this));this.eventManager.attachToEvent("mapCleared",this.clear.createDelegate(this));this.eventManager.attachToEvent("mapInitialized",this.initMap.createDelegate(this));this.eventManager.attachToEvent("interactivePan",this.interactivePan.createDelegate(this));this.eventManager.attachToEvent("startInteractivePan",this.startInteractivePan.createDelegate(this));this.eventManager.attachToEvent("endInteractivePan",this.endInteractivePan.createDelegate(this));this.eventManager.attachToEvent("undoInteractivePan",this.undoInteractivePan.createDelegate(this));this.eventManager.attachToEvent("interactiveZoom",this.interactiveZoom.createDelegate(this));},attachEvents:function(){if(this.frame&&this.withPan){this.frame.on("click",function(t){var m=t.getTarget();if(m.id.substring(0,6)=="mapPan"){var N=m.id.substring(6,8);this.pan(N);}},this,true);}},pan:function(N){var m=QMW2.ui.Map.panArrows[N];var t=(2-m.x)/2;var P=m.y/2;if(this.map.pan(t,P)){this.eventManager.fireEvent("mapUpdated",this.map.mapName,null,false);}},manageError:function(){if(this.errorContainer){this.loadingEl.setDisplayed("none");Ext.get(this.errorContainer).setDisplayed("block");var t=Ext.get("mapErrorMsg"+this.name);if(t){t.update($L("map_not_available"));}}},startInteractivePan:function(){for(var t in this.map.layers){var N=this.map.getLayer(t);if(N.startInteractivePan){N.startInteractivePan();}}},interactivePan:function(m,w,t,n){for(var N in this.map.layers){var P=this.map.getLayer(N);if(P.interactivePan){P.interactivePan(m,w,t,n);}}},interactiveZoom:function(m){for(var t in this.map.layers){var N=this.map.getLayer(t);if(N.interactiveZoom){N.interactiveZoom(m);}}},endInteractivePan:function(){for(var t in this.map.layers){var N=this.map.getLayer(t);if(N.endInteractivePan){N.endInteractivePan();}}},undoInteractivePan:function(){for(var t in this.map.layers){var N=this.map.getLayer(t);if(N.undoInteractivePan){N.undoInteractivePan();}}},cancelLoading:function(m){if(m==this.map.mapName&&this.map.isLocked()){var t=true;for(count=0;count<this.layersToBeUpdated.length;count++){var n=true;for(count2=0;count2<this.layersUpdated.length&&n;count2++){if(this.layersUpdated[count2]==this.layersToBeUpdated[count]){n=false;}}if(n){var N=this.map.getLayer(this.layersToBeUpdated[count]);if(N&&N.cancelLoading){var P=N.cancelLoading();if(!P){t=false;}}}}if(t){this.manageError();this.end();this.endAction("map",this.name);}}},reloadMap:function(){var m=this.map.layers;var N=null;for(var t in m){N=this.map.getLayer(t);N.changed=true;}this.update(this.map.mapName);},update:function(n,m,N){if(n==this.map.mapName&&this.updatable){if(!this.map.isLocked()){this.map.lock();this.layersToBeUpdated=[];this.layersUpdated=[];var P=null;var w={};if(!m){w=this.map.layers;}else{w[m]=this.map.getLayer(m);}for(var t in w){P=this.map.getLayer(t);if(P.hasToBeUpdated(this.map.realRange,this.map.maxRealRange)){this.layersToBeUpdated.push(t);}}if(this.layersToBeUpdated.length===0){this.map.unlock();for(t in this.map.layers){P=this.map.getLayer(t);P.resetInteractions();}this.endAction("map",this.name);}else{this.loadingEl.setDisplayed("block");if(this.errorContainer){Ext.get(this.errorContainer).setDisplayed("none");}this.map.eventManager.fireEvent("mapIsLoading",this.map.mapName);}for(var j=0;j<this.layersToBeUpdated.length;j++){t=this.layersToBeUpdated[j];P=this.map.getLayer(t);P.beforeUpdate(this.map.realRange,this.map.maxRealRange);P.update(this.map.realRange,this.map.maxRealRange,this.layerUpdated.createDelegate(this),N);P.afterUpdate(this.map.realRange,this.map.maxRealRange);}}else{this.reload=true;}}},print:function(P){if(P==this.map.mapName){if(!this.map.isLocked()){this.map.lock();var t=[];for(var N in this.map.layers){var m=this.map.getLayer(N);if(m.print){t.push(m.print(this.map.realRange,this.map.maxRealRange));}}this.map.unlock();return t.join();}}return null;},layerUpdated:function(m,N,n,t){for(var P=0;P<this.layersToBeUpdated.length;P++){if(this.layersToBeUpdated[P]==m){this.layersUpdated.push(m);}}if(N&&!t){if(QMW2.Application.yesNo($L("layer_loading_error"))){QMW2.Application.error(n);}this.manageError();}if(this.layersToBeUpdated.length==this.layersUpdated.length){this.end();this.endAction("map",this.name);}},end:function(){this.loadingEl.setDisplayed("none");for(var m=0;m<this.layersToBeUpdated.length;m++){var t=this.layersToBeUpdated[m];var N=this.map.getLayer(t);N.show();}this.layersToBeUpdated=[];this.map.eventManager.fireEvent("mapLoaded",this.map.mapName);this.map.unlock();if(this.reload){this.reload=false;this.update(this.map.mapName);}},addLayer:function(N,t){if(N==this.map.mapName&&t){t.setCRS(this.crs);}},clear:function(t){if(t==this.map.mapName&&this.layersContainer){this.layersContainer.update("");}},positionLoading:function(){this.loadingEl.beginMeasure();this.loadingEl.setLeftTop(Math.floor((this.mapWidth-this.loadingEl.getWidth())/2),Math.floor((this.mapHeight-this.loadingEl.getHeight())/2));this.loadingEl.endMeasure();},addDynamicLayer:function(t){var m=t.init();var N=Ext.getDom("dynamicLayers"+this.name).innerHTML;Ext.fly("dynamicLayers"+this.name).update(N+m);},initMap:function(P,t){if(P==this.map.mapName){if(!this.dpi){this.dpi=Ext.DomHelper.append(document.body,{tag:"div",id:"dpiDetect"+this.name,cls:"qmw2-dpiDetect"},true).getWidth();Ext.fly("dpiDetect"+this.name).remove();}this.map.updateView(this.mapWidth,this.mapHeight,this.dpi,this.crs);var m="";if(t){m=t;}var N;for(N in this.map.layers){m+=this.map.getLayer(N).init();}m+="<div id=\"dynamicLayers"+this.name+"\" class=\"qmw2-dynamicLayers\"></div>";m+="<div id=\"mapLoadingMessage"+this.name+"\" class=\"qmw2-mapLoadingMessage\"></div>";this.layersContainer.update(m);this.loadingEl=Ext.get("mapLoadingMessage"+this.name);this.positionLoading();this.loadingEl.setDisplayed("none");for(N in this.map.layers){layer=this.map.getLayer(N);this.addLayer(P,layer);Ext.fly(layer.getContainer()).setSize(this.mapWidth,this.mapHeight).clip();}}},getExternalContainer:function(){return this.frame?this.frame:this.container;}});QMW2.ui.Map.panArrows={"nw":{x:0,y:0},"nn":{x:1,y:0},"ne":{x:2,y:0},"ee":{x:2,y:1},"se":{x:2,y:2},"ss":{x:1,y:2},"sw":{x:0,y:2},"ww":{x:0,y:1}};QMW2.controlLoaded("map",QMW2.ui.Map);QMW2.decorate(QMW2.ui.Map,{monitorSize:function(m,N){if(!this.map.isLocked()){var P=Ext.fly(this.container.dom.parentNode).getWidth()-this.frameSize*2;var t=Ext.fly(this.container.dom.parentNode).getHeight()-this.frameSize*2;if((P!=this.mapWidth&&m)||(t!=this.mapHeight&&N)){this.updateSize(m?P:this.mapWidth,N?t:this.mapHeight);}}this.monitorSize.defer(500,this,[m,N]);},checkAndUpdateSize:function(P,t,m,N,n){if(n){P-=this.frameSize*2;t-=this.frameSize*2;}if(!this.map.isLocked()){if((P!=this.mapWidth&&m)||(t!=this.mapHeight&&N)){this.updateSize(m?P:this.mapWidth,N?t:this.mapHeight);}}},updateSize:function(j,t){if(this.frame){this.positionPanArrows(j+this.frameSize*2,t+this.frameSize*2);}this.container.setSize(j,t).clip();var P=this.map.realRange.copy();var m=j/this.mapWidth*P.getDeltaX();var N=t/this.mapHeight*P.getDeltaY();P.maxX=P.minX+m;P.minY=P.maxY-N;this.map.zoomBox(P);this.map.updateView(j,t,this.dpi,this.crs);this.mapWidth=j;this.mapHeight=t;this.positionLoading();for(var n in this.map.layers){var w=this.map.getLayer(n);Ext.fly(w.getContainer()).setSize(this.mapWidth,this.mapHeight).clip();if(typeof w.resize!=="undefined"){w.resize();}}this.eventManager.fireEvent("mapResized",this.map.mapName);if(j<=this.loadedWidth&&t<=this.loadedHeight){this.enableUpdate(false);this.eventManager.fireEvent("mapUpdated",this.map.mapName,true);this.enableUpdate(true);}else{this.eventManager.fireEvent("mapUpdated",this.map.mapName);}},init:{after:function(t){if(t.autoUpdateSize){var m=(!t.width)&&t.autoUpdateSize;var N=(!t.height)&&t.autoUpdateSize;this.monitorSize.defer(500,this,[m,N]);}}},end:{after:function(){this.loadedWidth=this.mapWidth;this.loadedHeight=this.mapHeight;}},provideObject:{flow:function(N,t){if(N=="canvas"&&t){QMW2.decorate(t,{resize:function(){var m=Ext.getDom(this.name);if(m){if(this.useCanvas){m.setAttribute("width",this.container.offsetWidth);m.setAttribute("height",this.container.offsetHeight);}else{m.style.width=this.container.offsetWidth+"px";m.style.height=this.container.offsetHeight+"px";m.style.clip="rect(0px "+this.container.offsetWidth+"px "+this.container.offsetHeight+"px 0px)";}}m=Ext.getDom(this.name+"Capturer");if(m){m.style.width=this.container.offsetWidth+"px";m.style.height=this.container.offsetHeight+"px";}}});this.eventManager.attachToEvent("mapResized",t.resize.createDelegate(t));}return t;}}});QMW2.decorate(QMW2.ui.Map,{setMapWarning:function(t){this.mapWarning=t;},createWarningContainer:function(N,t){this.warningContainer=Ext.DomHelper.append(this.container,{tag:"div",id:"mapWarning"+this.name,cls:"qmw2-mapWarning",children:[{tag:"p",id:"mapWarningMsg"+this.name,cls:"qmw2-mapWarningMsg"}]},true).setPositioning({position:"absolute",left:0,top:0,"z-index":this.staticIndex+2}).setSize(this.getDimension(this.mapWidth,N),0).setDisplayed("none");Ext.fly("mapWarningMsg"+this.name).on("click",this.hide.createDelegate(this));},hide:function(){this.setMapWarning(null);this.updateWarning(this.map.mapName);},updateWarning:function(t){if(t==this.map.mapName){if(this.mapWarning){Ext.fly("mapWarningMsg"+this.name).update(this.mapWarning);this.warningContainer.setDisplayed("block");this.mapWarning=null;}else{this.warningContainer.setDisplayed("none");}}},resizeWarning:function(){Ext.fly("mapWarning"+this.name).setWidth(this.mapWidth);},init:{after:function(){this.mapWarning=null;this.createWarningContainer();this.map.eventManager.attachToEvent("mapUpdated",this.updateWarning.createDelegate(this));this.map.eventManager.attachToEvent("mapResized",this.resizeWarning.createDelegate(this));}}});QMW2.decorate(QMW2.ui.Map,{initMap:{before:function(N,t){this.map.originalMaxRange=this.map.maxRealRange.copy();this.map.maxRealRange.inverseAdjustAspectRatio(this.mapWidth,this.mapHeight);this.map.realRange=this.map.maxRealRange.copy();}},updateSize:{before:function(N,t){this.map.maxRealRange=this.map.originalMaxRange.copy();this.map.maxRealRange.inverseAdjustAspectRatio(N,t);}}});QMW2.decorate(QMW2.ui.Map,{attachFrameworkEvents:{after:function(){this.eventManager.attachToEvent("updatemapquality",this.updateOutputFormat.createDelegate(this));}},updateOutputFormat:function(m){for(var t in this.map.layers){var N=this.map.layers[t];if(typeof N.setOutputFormat==="function"){N.setOutputFormat(m);}}}});QMW2.declare("QMW2.ui.Navigator",null,{initializer:function(){this.canvas=null;this.collapsed=false;this.tempListeners={mouseup:null,mousemove:null};this.type="navigator";},requireObject:function(N,m){if(N=="canvas"){this.canvas=m;if(this.onCanvas){var t=this.frame||this.container;t.remove();t.appendTo(this.canvas.container);t.alignTo(this.canvas.container,this.onCanvas+"-"+this.onCanvas);}}return null;},cfgFrame:function(P,m,n){if(this.frame){var t=(P&&m)?this.frameSize:this.navWidth+this.frameSize*2;var N=(P&&m)?this.frameSize:this.navHeight+this.frameSize*2;this.frame.setPositioning({"position":"absolute","left":0,"top":0,"z-index":n}).setSize(t,N);this.container.setLeftTop(this.frameSize,this.frameSize);if(P){if(m){this.collapsed=true;}this.frame.on("click",function(w,j){if(j==this.frame.dom){if(this.collapsed){this.expand();}else{this.collapse();}}},this,true);}}},collapse:function(){if(this.frame){this.frame.setSize(this.frameSize,this.frameSize).clip();this.frame.removeClass("qmw2-navigatorExpanded");this.frame.addClass("qmw2-navigatorCollapsed");this.collapsed=true;}},expand:function(){if(this.frame){var t=this.navWidth+this.frameSize*2;var N=this.navHeight+this.frameSize*2;this.frame.setSize(t,N).clip();this.frame.addClass("qmw2-navigatorExpanded");this.frame.removeClass("qmw2-navigatorCollapsed");this.collapsed=false;}},createMonitor:function(){return Ext.DomHelper.append(this.container,{tag:"div",id:this.name+"Monitor",cls:"qmw2-navigatorMonitor"},true);},init:function(t){this.name=t.name||"navigator";this.container=Ext.get(t.container||this.name);this.monitor=t.monitor?Ext.get(t.monitor):this.createMonitor();this.map=t.map;this.eventManager=t.eventManager;this.x=null;this.y=null;this.width=null;this.height=null;this.onCanvas=t.onCanvas;if(t.width){this.navWidth=t.width;this.container.setWidth(this.navWidth);}else{this.navWidth=this.container.getWidth();}this.navHeight=Math.floor(this.navWidth/this.map.maxRealRange.getDeltaX()*this.map.maxRealRange.getDeltaY());this.container.setHeight(this.navHeight);this.frameSize=t.withFrame?t.frameWidth:0;if(t.withFrame){this.frame=Ext.get(this.container.dom.parentNode);this.cfgFrame(t.withCollapse,t.startCollapsed,t.order||1);}this.scaleX=this.map.maxRealRange.getDeltaX()/this.navWidth;this.scaleY=this.map.maxRealRange.getDeltaY()/this.navHeight;this.attachFrameworkEvents();this.attachEvents();},attachFrameworkEvents:function(){this.eventManager.attachToEvent("mapUpdated",this.update.createDelegate(this));},attachEvents:function(){this.container.unselectable();this.container.on("mousedown",function(N){var t=N.getTarget();if(t==this.monitor.dom){this.startDrag(N.getPageX(),N.getPageY());N.stopEvent();}},this,true);this.container.on("mouseup",function(N){var t=N.getTarget();if(t==this.container.dom){this.moveTo(N.getOffsetX(),N.getOffsetY());N.stopEvent();}},this,true);},update:function(){this.x=Math.floor((this.map.realRange.minX-this.map.maxRealRange.minX)/this.scaleX);this.y=Math.floor((this.map.maxRealRange.maxY-this.map.realRange.maxY)/this.scaleY);var t=Math.floor(this.map.realRange.getDeltaX()/this.scaleX);if(t<1){t=1;}this.width=t;h=Math.floor(this.map.realRange.getDeltaY()/this.scaleY);if(h<1){h=1;}this.height=h;this.updateMonitor(this.x,this.y,this.width,this.height);},updateMonitor:function(N,n,P,t,m){if(n<0){n=0;}if((n+t)>this.navHeight){n=this.navHeight-t;}if(N<0){N=0;}if((N+P)>this.navWidth){N=this.navWidth-P;}if(m){this.monitor.setLocalBounds(N,n,P,t);}else{this.monitor.setLocalBounds(N,n,P,t,true,0.5,null,Ext.lib.Easing.easeOut);}},startDrag:function(N,n){this.dragX=N;this.dragY=n;var P=Ext.get(document);var m=this.moveDrag.createDelegate(this);var t=this.endDrag.createDelegate(this);this.tempListeners={mousemove:m,mouseup:t};P.on("mousemove",m);P.on("mouseup",t);},moveDrag:function(P){if(!P.isLeftClicked()){this.undoDrag();}else{var N=P.getPageX(P);var n=P.getPageY(P);var m=N-this.dragX;var t=n-this.dragY;this.updateMonitor(this.x+m,this.y+t,this.width,this.height,true);}},removeDragListeners:function(){var t=Ext.get(document);if(this.tempListeners["mouseup"]){t.un("mouseup",this.tempListeners["mouseup"]);}if(this.tempListeners["mousemove"]){t.un("mousemove",this.tempListeners["mousemove"]);}this.tempListeners={mousemove:null,mousemove:null};},undoDrag:function(){this.removeDragListeners();this.update();},moveTo:function(t,N){this.x=Math.floor(t-this.width/2);this.y=Math.floor(N-this.height/2);if(this.y<0){this.y=0;}if((this.y+this.height)>this.navHeight){this.y=this.navHeight-this.height;}if(this.x<0){this.x=0;}if((this.x+this.width)>this.navWidth){this.x=this.navWidth-this.width;}this.updateMap();},endDrag:function(P){this.removeDragListeners();var N=P.getPageX(P);var n=P.getPageY(P);var m=N-this.dragX;var t=n-this.dragY;this.x=this.x+m;this.y=this.y+t;if(this.y<0){this.y=0;}if((this.y+this.height)>this.navHeight){this.y=this.navHeight-this.height;}if(this.x<0){this.x=0;}if((this.x+this.width)>this.navWidth){this.x=this.navWidth-this.width;}this.updateMap();},updateMap:function(){var t=this.map.maxRealRange.minX+this.x*this.scaleX;var P=t+this.map.realRange.getDeltaX();var n=this.map.maxRealRange.maxY-(this.y+this.height)*this.scaleY;var m=n+this.map.realRange.getDeltaY();var N=new QMW2.map.Range(t,P,n,m);N.adjustAspectRatio(this.map.realRange.getDeltaX(),this.map.realRange.getDeltaY());this.map.zoomBox(N);this.eventManager.fireEvent("mapUpdated",this.map.mapName);}});QMW2.controlLoaded("navigator",QMW2.ui.Navigator);QMW2.decorate(QMW2.ui.Navigator,{init:{after:function(t){this.originalMaxRange=this.map.maxRealRange.copy();this.originalWidth=this.navWidth;this.originalHeight=this.navHeight;}},update:{before:function(){if(!this.originalMaxRange.equals(this.map.maxRealRange)){var t=new QMW2.map.Range(0,this.originalWidth,0,this.originalHeight);t.inverseAdjustAspectRatio(this.map.maxRealRange.getDeltaX(),this.map.maxRealRange.getDeltaY());t.minX=Math.floor(t.minX);t.maxX=Math.floor(t.maxX);t.minY=Math.floor(t.minY);t.maxY=Math.floor(t.maxY);if(t.getDeltaX()!=this.navWidth||t.getDeltaY()!=this.navHeight){this.updateSize(t);}}}},updateSize:function(N){this.navWidth=N.getDeltaX();this.navHeight=N.getDeltaY();this.scaleX=this.map.maxRealRange.getDeltaX()/this.navWidth;this.scaleY=this.map.maxRealRange.getDeltaY()/this.navHeight;var t=0;var m=0;if(this.navWidth>this.originalWidth){t+=Math.floor((this.navWidth-this.originalWidth)/2);}if(this.navHeight>this.originalHeight){m+=Math.floor((this.navHeight-this.originalHeight)/2);}this.container.setStyle("backgroundPosition",t+"px "+m+"px");this.container.setSize(this.navWidth,this.navHeight);if(this.frame&&!this.collapsed){this.frame.setSize(this.navWidth+this.frameSize*2,this.navHeight+this.frameSize*2);}}});QMW2.loadWidget("blackboard");QMW2.declare("QMW2.ui.Legend",null,{initializer:function(){this.legendTree=null;this.handlers={};this.legendTreeCfg=null;this.type="legend";},init:function(t){this.name=t.name||"legend";this.container=Ext.get(t.container||this.name);this.map=t.map;this.eventManager=t.eventManager;if(t.applicationCfg){this.cfg=t;}if(t.width){this.container.setWidth(t.width);}if(t.height){this.container.setHeight(t.height);}if(t.clip&&t.width&&t.height){var N=this.container;this.container=Ext.DomHelper.append(N,{tag:"div",id:"legendInternal"+this.name,cls:"qmw2-legendContainer"},true);N.setStyle("clip","rect(0px "+t.width+"px "+t.height+"px 0px)");N.setStyle("overflow","auto");}this.legendTree=new QMW2.ui.Legend.LegendNode("root","root",this);this.nodesById={};this.stylers={};this.attachFrameworkEvents();this.attachEvents();this.legendTreeCfg=this.getLegendCfg();this.addStylers();this.populate();},updateMap:function(){this.eventManager.fireEvent("mapUpdated",this.map.mapName);},getLegendCfg:function(){var N=this.cfg.tree||"";var P=null;if(this.cfg.applicationCfg.Components&&this.cfg.applicationCfg.Components.Legend){var t=[];if(this.cfg.applicationCfg.Components.Legend.length){for(var m=0;m<this.cfg.applicationCfg.Components.Legend.length;m++){t.push(this.cfg.applicationCfg.Components.Legend[m]);}}else{t.push(this.cfg.applicationCfg.Components.Legend);}if(N){for(var m=0;m<t.length;m++){if(t[m].name===N){P=t[m];}}}else{if(t.length>0){P=t[0];}}}if(P===null){QMW2.Application.error($L("legend_tree_not_found"));}return P;},addStylers:function(){var j=this.legendTreeCfg;if(j&&j.Styler){var w=j.Styler;var N=[];if(w.length){for(var n=0;n<w.length;n++){N.push(w[n]);}}else{N.push(w);}for(var n=0;n<N.length;n++){var t=N[n].nodeType;var P=N[n].stylerType;var m=QMW2.ui.Legend.stylerTypes[P];if(m){this.addStyler(t,m());}else{QMW2.Application.error($L("styler_type_unknown")+": "+P);}}}},addNode:function(N,t,P){var n=QMW2.ui.Legend.LegendNode.implementations[N.type];if(n){var m=n(this,N,P);t.addChild(m);m.registerHandlers();return m;}else{QMW2.Application.error($L("legendnode_type_unknown")+": "+N.type);}},populateLegend:function(N,t,P){var m=null;if(N.LegendNode.length){m=N.LegendNode;}else{m=new Array(N.LegendNode);}for(var w=0;w<m.length;w++){var n=m[w];this.addNode(n,t,P);}},populate:function(){var t=[];var m=this.getLegendCfg();if(m){this.localized=m.localized&&m.localized===true;if(m.length===undefined){t.push(m.LegendRoot);}else{t=m.LegendRoot;}for(var N=0;N<t.length;N++){if(t[N].LegendNode){this.populateLegend(t[N],this.legendTree,this.localized);}}this.draw();}},attachFrameworkEvents:function(){this.eventManager.attachToEvent("mapLoaded",this.stylize.createDelegate(this,["maploaded"]));this.eventManager.attachToEvent("mapUpdated",this.stylize.createDelegate(this,["mapupdated"]));this.eventManager.attachToEvent("applicationLoaded",this.stylize.createDelegate(this,["apploaded"]));},attachEvents:function(){var t=this.container;t.unselectable();t.on("mousedown",function(N){this.handleEvent("mousedown",N);},this,true);t.on("mouseup",function(N){this.handleEvent("mouseup",N);},this,true);t.on("mousemove",function(N){this.handleEvent("mousemove",N);},this,true);t.on("dblclick",function(N){this.handleEvent("dblclick",N);},this,true);t.on("mouseover",function(N){this.handleEvent("mouseover",N);},this,true);t.on("mouseout",function(N){this.handleEvent("mouseout",N);},this,true);},addHandler:function(t,m,N){this.handlers[t+"."+m]=N;},getHandler:function(t,N){return this.handlers[t+"."+N];},handleEvent:function(N,t){var P=t.getTarget();while(P&&P!=this.container){if(P.id&&this.getHandler(N,P.id)){var m=this.getHandler(N,P.id);if(m(N,t)){P=null;}else{P=P.parentNode;}}else{P=P.parentNode;}}},stylize:function(t){this.legendTree.stylize(t);},draw:function(t){this.container.update(this.legendTree.draw());if(t){this.stylize("all");}},setNodeProperty:function(P,m,N){if(this.nodesById[P]){var t=this.nodesById[P];t[m]=N;}},addStyler:function(N,m){var t=this.stylers[N];if(!t){t=new Array();}t.push(m);this.stylers[N]=t;},getStylers:function(t){return this.stylers[t];},getNode:function(t){return this.legendTree.getNode(t);}});QMW2.ui.Legend.stylerTypes={};QMW2.declare("QMW2.ui.Legend.IconStyle",null,{initializer:function(){this.types={apploaded:true,nodeshown:true};},isOfType:function(t){return this.types[t];},applyStyle:function(t){t.drawIcon();}});QMW2.ui.Legend.stylerTypes["icon"]=function(){return new QMW2.ui.Legend.IconStyle();};QMW2.declare("QMW2.ui.Legend.VisibilityStyle",null,{initializer:function(){this.types={mapupdated:true,nodeshown:true};},isOfType:function(t){return this.types[t];},applyStyle:function(N){var m=false;for(var t in N.subItems){var P=N.subItems[t];if(P.isVisible()){m=true;}}if(m){N.unmaskIcon();}else{N.maskIcon();}}});QMW2.ui.Legend.stylerTypes["visibility"]=function(){return new QMW2.ui.Legend.VisibilityStyle();};QMW2.declare("QMW2.ui.Legend.LegendNode",null,{initializer:function(m,t,N){this.id=m;this.name=t;this.type="root";this.legend=N;this.childs=[];this.classes={};this.parent=null;},getLevel:function(){var N=0;var t=this;while(t.parent){N++;t=t.parent;}return N;},initClasses:function(){this.addClass(this.type);},addChild:function(t){this.legend.nodesById[t.id]=t;this.childs.push(t);t.parent=this;},removeChild:function(N){delete this.legend.nodesById[N.id];var m=[];for(var t=0;t<this.childs.length;t++){if(this.childs[t].id!=N.id){m.push(this.childs[t]);}}this.childs=m;},registerHandlers:function(){},addClass:function(t){this.classes[t]=true;},draw:function(){this.preDraw();var t=this.drawHeader();t+=this.drawChilds();t+=this.drawFooter();this.postDraw();return t;},preDraw:function(){},postDraw:function(){},drawHeader:function(){return "<ul class=\""+this.getCssClasses("root")+"\">";},drawChilds:function(){var t="";for(var N=0;N<this.childs.length;N++){t+=this.childs[N].draw();}return t;},drawFooter:function(){return "</ul>";},getCssClasses:function(t){switch(t){default:return "qmw2-legend";}},stylize:function(N){var m=0;var t=this.legend.getStylers(this.type);if(t){for(m=0;m<t.length;m++){if(N=="all"||t[m].isOfType(N)){t[m].applyStyle(this);}}}for(m=0;m<this.childs.length;m++){this.childs[m].stylize(N);}},updateMap:function(){this.legend.updateMap();},getContainer:function(){if(!this.container){this.container=$("legend");}return this.container;},getNode:function(m){if(this.id==m){return this;}for(var N=0;N<this.childs.length;N++){var t=this.childs[N].getNode(m);if(t){return t;}}return null;}});QMW2.ui.Legend.LegendNode.implementations={};QMW2.declare("QMW2.ui.Legend.LegendCategory",QMW2.ui.Legend.LegendNode,{initializer:function(P,N,m,t){QMW2.ui.Legend.LegendCategory.superclass.constructor.call(this,P,N,m);this.open=t;this.type="category";},stylize:function(N){var m=0;var t=this.legend.getStylers(this.type);if(t){for(m=0;m<t.length;m++){if(N=="all"||t[m].isOfType(N)){t[m].applyStyle(this);}}}if(this.open){for(m=0;m<this.childs.length;m++){this.childs[m].stylize(N);}}},registerHandlers:function(){this.legend.addHandler("mouseup","legendCategory"+this.id,this.toggleOpen.createDelegate(this));},toggleOpen:function(){this.open=!this.open;if($("legendCategoryChilds"+this.id)){var t=this.open?"block":"none";$("legendCategoryChilds"+this.id).style.display=t;if(this.open){this.stylize("nodeshown");}else{this.stylize("nodehidden");}}return true;},preDraw:function(){this.container=null;},drawHeader:function(){return "<li id=\"legendCategory"+this.id+"\" class=\""+this.getCssClasses("category")+"\"><div class=\""+this.getCssClasses("categoryname")+"\">"+this.name+"</div><div class=\"clear\"></div>";},drawChilds:function(){var N="";if(this.childs.length>0){var t=this.open?"display:block":"display:none";N+="<ul id=\"legendCategoryChilds"+this.id+"\" class=\""+this.getCssClasses("categorychilds")+"\" style=\""+t+"\">";for(var m=0;m<this.childs.length;m++){N+=this.childs[m].draw();}N+="</ul>";}return N;},drawFooter:function(){return "</li>";},getCssClasses:function(N){var t=this.open?"Open":"Closed";switch(N){case "category":if(this.parent.childs[this.parent.childs.length-1].id==this.id){return "qmw2-legendCategory qmw2-legendCategory"+this.getLevel()+" qmw2-legendCategory"+this.getLevel()+t+" qmw2-legendCategory"+this.getLevel()+"Last";}else{return "qmw2-legendCategory qmw2-legendCategory"+this.getLevel()+" qmw2-legendCategory"+this.getLevel()+t;}break;case "categoryname":if(this.parent.childs[this.parent.childs.length-1].id==this.id){return "qmw2-legendCategoryName qmw2-legendCategoryName"+this.getLevel()+" qmw2-legendCategoryName"+this.getLevel()+t+" qmw2-legendCategoryName"+this.getLevel()+"Last";}else{return "qmw2-legendCategoryName qmw2-legendCategoryName"+this.getLevel()+" qmw2-legendCategoryName"+this.getLevel()+t;}break;case "categorychilds":return "qmw2-legendCategoryChilds";break;default:return "";}},getContainer:function(){if(!this.container){this.container=$("legendCategory"+this.id);}return this.container;},getProperty:function(N){var t=true;for(var m=0;m<this.childs.length;m++){var n=this.childs[m];var P=n.getProperty(N);if(P!=t){return P;}}return t;},applyProperty:function(m,n,N){var t=true;for(var P=0;P<this.childs.length;P++){var w=this.childs[P];if(w.applyProperty!==undefined){if(!w.applyProperty(m,n,N)){t=false;}}}return t;},setProperty:function(m,j,w,N){var t=true;for(var n=0;n<this.childs.length;n++){var B=this.childs[n];B.setProperty(m,j,N);var P=true;if(B.applyProperty===undefined){P=false;}else{P=B.applyProperty(m,w,N);}if(!P){t=false;}}return t;},removeAll:function(){var t=true;for(var m=0;m<this.childs.length;m++){var P=this.childs[m];var N=P.remove();if(!N){t=false;}}return t;}});QMW2.ui.Legend.LegendNode.implementations["category"]=function(N,P,t){var m=new QMW2.ui.Legend.LegendCategory(P.id,t?$L(P.description,true):P.description,N,P.open);m.initClasses();if(P.LegendNode){N.populateLegend(P,m,t);}return m;};QMW2.declare("QMW2.ui.Legend.LegendItem",QMW2.ui.Legend.LegendNode,{initializer:function(N,t,B,m){QMW2.ui.Legend.LegendItem.superclass.constructor.call(this,N,t,B);this.useCanvas=QMW2.hasCapability("Canvas");this.type="item";this.subItems={};this.renderer=null;this.entArr=m.split(",");for(var j=0;j<this.entArr.length;j++){var x=this.entArr[j];var w="";var p="";var P="";if(x.indexOf(".")!=-1){var f=x.split(".");w=f[0];p=f[1];if(f.length>=3){P=f[2];}}else{w=x;p=x;P=x;}var n=this.legend.map.getLayer(w);if(n){this.renderer=n.getRenderingManager(p);if(this.renderer){this.subItems[x]=new QMW2.ui.Legend.LegendSubItem(B.map,n,p,P,this.renderer);}else{alert("No RenderingManager defined for "+x);}}else{alert("No layer named "+w+" found");}}},initClasses:function(){QMW2.ui.Legend.LegendNode.prototype.initClasses.apply(this,arguments);for(var t in this.subItems){var N=this.subItems[t];this.addClass(N.renderer.type);}},registerHandlers:function(){this.legend.addHandler("mouseup","legendItem"+this.id,this.toggleVisibility.createDelegate(this));},toggleVisibility:function(){var t=!this.getProperty("visibility");if(this.setProperty("visibility",t)){this.updateMap();}this.stylize("mapupdated");return true;},getIcon:function(){if(this.useCanvas){return "<canvas id=\"legendItem"+this.id+"IconCanvas\" width=\""+this.legend.cfg.iconWidth+"\" height=\""+this.legend.cfg.iconHeight+"\"></canvas><div id=\"legendItem"+this.id+"IconCanvasAlt\" class=\"qmw2-legendSubItemIcon\"></div>";}else{return "<div id=\"legendItem"+this.id+"IconCanvas\" class=\"qmw2-legendItemIconCanvas\"></div>";}},drawIcon:function(){if(!this.icon){this.icon=$("legendItem"+this.id+"IconCanvas");this.iconAlt=$("legendItem"+this.id+"IconCanvasAlt");}var N=this.legend.cfg.iconWidth;var j=this.legend.cfg.iconHeight;var m;if(this.useCanvas){var P=this.icon;var t=P.getContext("2d");t.clearRect(0,0,N,j);m=QMW2.blackboard.ui.Blackboard.implementations["CANVAS"](this.iconAlt,t);}else{m=QMW2.blackboard.ui.Blackboard.implementations["VML"](this.icon,"qmw2-legendSubItemIcon");}m.begin();for(var n in this.subItems){var B=this.subItems[n];B.renderer.drawSample(m,N,j,B.boundSelector);}m.commit();},maskIcon:function(){var t=$("legendItem"+this.id+"IconMask");if(!t){var m=Ext.get("legendItem"+this.id+"Icon");var t=document.createElement("div");t.id="legendItem"+this.id+"IconMask";m.dom.appendChild(t);var N=Ext.get("legendItem"+this.id+"IconMask");N.position("absolute",1000);N.setLeft(0);N.setTop(0);N.setOpacity(0.8);N.setWidth(this.legend.cfg.iconWidth);N.setHeight(this.legend.cfg.iconHeight);N.setStyle("backgroundColor","#FFFFFF");N.setStyle("lineHeight","1px");N.setStyle("fontSize","1px");}},unmaskIcon:function(){var t=$("legendItem"+this.id+"IconMask");if(t&&t.parentNode){t.parentNode.removeChild(t);}},preDraw:function(){this.icon=null;this.iconAlt=null;this.container=null;},drawHeader:function(){var t="<li class=\""+this.getCssClasses("item")+"\" id=\"legendItem"+this.id+"\"><table><tr><td><div class=\""+this.getCssClasses("itemicon")+"\" id=\"legendItem"+this.id+"Icon\">";t+=this.getIcon();t+="</div></td><td><div class=\""+this.getCssClasses("itemname")+"\">"+this.name+"</div><div class=\"clear\"><img src=\""+QMW2.resourcesPath+"/images/spacer.gif\" width=\"1\" height=\"1\"/></div></td></tr></table>";return t;},drawFooter:function(){return "</li>";},getCssClasses:function(t){switch(t){case "item":if(this.parent.childs[this.parent.childs.length-1].id==this.id){return "qmw2-legendItem qmw2-legendItem"+this.getLevel()+" qmw2-legendItem"+this.getLevel()+"Last";}return "qmw2-legendItem qmw2-legendItem"+this.getLevel();break;case "itemicon":return "qmw2-legendItemIcon";break;case "itemname":return "qmw2-legendItemName";break;default:return "";}},getContainer:function(){if(!this.container){this.container=$("legendItem"+this.id);}return this.container;},getProperty:function(N){for(var t in this.subItems){var P=this.subItems[t];var m=P.getProperty(N);if(m){return m;}}return false;},setProperty:function(P,j,w,N){var t=true;for(var m in this.subItems){var B=this.subItems[m];B.setProperty(P,j,N);var n=B.applyProperty(P,w,N);if(!n){t=false;}}return t;},removeAll:function(){var t=true;for(var N in this.subItems){var P=this.subItems[N];var m=P.remove();if(!m){t=false;}}return t;},applyProperty:function(m,w,t){var n;if(!this.entArr instanceof Array){n=this.subItems[this.entArr].applyProperty(m,w,t);}else{for(var P=0;P<this.entArr.length;P++){var N=this.entArr[P];n=this.subItems[N].applyProperty(m,w,t);if(!n){return n;}}}return n;}});QMW2.ui.Legend.LegendNode.implementations["item"]=function(N,P,t){var m=new QMW2.ui.Legend.LegendItem(P.id,t?$L(P.description,true):P.description,N,P.entity);m.initClasses();if(P.LegendNode){N.populateLegend(P,m,t);}return m;};QMW2.declare("QMW2.ui.Legend.LegendSubItem",null,{initializer:function(P,N,t,n,m){this.map=P;this.layer=N;this.feature=t;this.boundSelector=n;this.renderer=m;},isVisible:function(){var t=this.map.realRange.getDeltaX();return this.getProperty("visibility")&&this.layer.visibleInScale(t,this.feature,this.boundSelector);},getProperty:function(N,t){var t=t||this.boundSelector;if(!t){return this.renderer.getAnyProperty(N);}else{return this.renderer.getProperty(N,t);}},setProperty:function(N,m,t){var t=t||this.boundSelector;if(!t){this.renderer.setAllProperty(N,m);}else{this.renderer.setProperty(N,m,t);}},applyProperty:function(N,m,t){var t=t||this.boundSelector;if(!t){return this.renderer.applyAllProperty(N,this.layer,m);}else{return this.renderer.applyProperty(N,this.layer,t,m);}},remove:function(){return this.layer.removeFeature(this.feature);}});QMW2.controlLoaded("legend",QMW2.ui.Legend);QMW2.loadWidget("blackboard");QMW2.decorate(QMW2.ui.Legend.LegendNode,{print:function(){var P=[];for(var N=0;N<this.childs.length;N++){var m=this.childs[N].print();if(m instanceof Array){for(var t=0;t<m.length;t++){P.push(m[t]);}}else{if(m){P.push(m);}}}return P;}});QMW2.decorate(QMW2.ui.Legend.LegendItem,{print:function(){var n={};var P=false;var t=[];for(var N in this.subItems){var w=this.subItems[N];if(w.layer.isPrintable()){var m=new QMW2.blackboard.ui.PrintBlackboard();w.renderer.drawSample(m,this.legend.cfg.iconWidth,this.legend.cfg.iconHeight,w.boundSelector);t.push({name:N,icon:m.icon});if(w.isVisible()){P=true;}}}if(P){n.name=this.name;n.items=t;return n;}return null;}});QMW2.declare("QMW2.blackboard.ui.PrintBlackboard",QMW2.blackboard.ui.Blackboard,{initializer:function(){QMW2.blackboard.ui.PrintBlackboard.superclass.constructor.apply(this,[""]);this.icon=[];},getClip:function(){if(this.clip){return {x:this.clip.minX,y:this.clip.minY,width:this.clip.getDeltaX(),height:this.clip.getDeltaY()};}return null;},drawImage:function(n,N,w,P,t,m){this.icon.push({type:"image",src:n,x:N,y:w,width:P,height:t,clip:this.getClip()});},drawString:function(w,t,j,P,n,m,N){this.icon.push({type:"text",text:w,x:t,y:j,font:P,size:n,color:m,clip:this.getClip()});},drawPolyline:function(N,m,t){this.icon.push({type:"polyline",points:N,stroke:m,clip:this.getClip()});},drawEllipse:function(N,j,P,t,w,n,m){this.icon.push({type:"ellipse",x:N,y:j,width:P,height:t,stroke:w,fill:n,clip:this.getClip()});},drawArea:function(t,N){this.icon.push({type:"area",points:t,fill:N,clip:this.getClip()});},begin:function(){},commit:function(){this.clip=null;}});QMW2.decorate(QMW2.ui.Legend.LegendCategory,{drawHeader:{flow:function(t){return t.replace(/^(<li[^>]+>)(.*?)$/gi,"$1<div id=\"legendCategoryCheck"+this.id+"\" class=\"qmw2-legendCategoryCheck\"></div>$2");}},registerHandlers:{after:function(){this.legend.addHandler("mouseup","legendCategoryCheck"+this.id,this.toggleVisibility.createDelegate(this));}},toggleVisibility:function(){var t=Ext.get(this.getContainer());var N=false;if(t.hasClass("qmw2-legendcategoryinvisible")){N=true;}if(this.setProperty("visibility",N)){this.updateMap();}this.stylize("mapupdated");return true;}});QMW2.declare("QMW2.ui.Legend.UserVisibilityStyle",null,{initializer:function(){this.types={mapupdated:true,nodeshown:true};},isOfType:function(t){return this.types[t];},getCategoryVisibility:function(t){var P=t.childs.length==0?false:true;for(var m=0;m<t.childs.length&&P;m++){var N=t.childs[m];if(N.type=="category"&&!this.getCategoryVisibility(N)){P=false;}else{if(!N.getProperty("visibility")){P=false;}}}return P;},applyStyle:function(t){var m=false;if(t.type=="item"){m=t.getProperty("visibility");}else{if(t.type=="category"){m=this.getCategoryVisibility(t);}}if(t.parent&&t.parent.type!="root"){this.applyStyle(t.parent);}var N=Ext.get(t.getContainer());if(m){N.addClass("qmw2-legend"+t.type+"visible");N.removeClass("qmw2-legend"+t.type+"invisible");}else{N.removeClass("qmw2-legend"+t.type+"visible");N.addClass("qmw2-legend"+t.type+"invisible");}}});QMW2.ui.Legend.stylerTypes["uservisibility"]=function(){return new QMW2.ui.Legend.UserVisibilityStyle();};QMW2.decorate(QMW2.ui.Legend.LegendSubItem,{applyProperty:function(){return true;}});QMW2.decorate(QMW2.ui.Legend,{updateMap:function(){this.eventManager.fireEvent("legendUpdated",this.map.mapName);}});QMW2.declare("QMW2.ui.Legend.LegendQueryCategory",QMW2.ui.Legend.LegendCategory,{initializer:function(P,N,m,t){QMW2.ui.Legend.LegendQueryCategory.superclass.constructor.call(this,P,N,m,t);},drawHeader:function(){return "<li id=\"legendCategory"+this.id+"\" class=\""+this.getCssClasses("category")+"\"><table width=\"94%\" cellpadding=\"2\"><tr><td width=\"99%\"><div id=\"legendCategoryCheck"+this.id+"\" class=\"qmw2-legendCategoryCheck\"></div><div class=\""+this.getCssClasses("categoryname")+"\">"+this.name+"</div></td><td width=\"1%\"><div id=\"legendCategoryRemove"+this.id+"\" class=\"qmw2-legendCategoryRemove\"></div><div class=\"clear\"></div></td></tr></table>";},registerHandlers:function(){QMW2.ui.Legend.LegendCategory.prototype.registerHandlers.apply(this,arguments);this.legend.addHandler("mouseup","legendCategoryRemove"+this.id,this.removeCategoryItems.createDelegate(this));},removeAllQueries:function(){for(var N=0;N<this.childs.length;N++){var t=this.childs[N];t.removeAll();}this.childs=[];this.legend.draw(true);},removeCategoryItems:function(){if(this.childs.length>0&&QMW2.Application.yesNo($L("confirm_delete_items"))){this.removeAllQueries();this.legend.eventManager.fireEvent("mapUpdated",this.legend.map.mapName);}return true;},addChild:function(m){for(var N=0;N<this.childs.length;N++){var t=this.childs[N];if(t.getProperty("visibility")){t.toggleVisibility();}}QMW2.ui.Legend.LegendCategory.prototype.addChild.apply(this,arguments);}});QMW2.ui.Legend.LegendNode.implementations["querycategory"]=function(N,P,t){var m=new QMW2.ui.Legend.LegendQueryCategory(P.id,t?$L(P.description,true):P.description,N,P.open);m.initClasses();if(P.LegendNode){N.populateLegend(P,m,t);}return m;};QMW2.declare("QMW2.ui.Legend.LegendQueryItem",QMW2.ui.Legend.LegendItem,{initializer:function(n,m,P,N,t){QMW2.ui.Legend.LegendQueryItem.superclass.constructor.call(this,n,m,P,N);this.range=t;},drawHeader:function(){var t="<li class=\""+this.getCssClasses("item")+"\" id=\"legendItem"+this.id+"\"><table width=\"94%\"><tr><td width=\"1%\"><div class=\""+this.getCssClasses("itemicon")+"\" id=\"legendItem"+this.id+"Icon\">";t+=this.getIcon();t+="</div></td><td width=\"97%\"><div class=\""+this.getCssClasses("itemname")+"\">"+this.name+"</div></td>";t+="<td width=\"1%\"><div id=\"legendItemRemove"+this.id+"\" class=\"qmw2-legendItemRemove\"></div></td><td width=\"1%\"><div id=\"legendItemZoom"+this.id+"\" class=\"qmw2-legendItemZoom\"></div><div class=\"clear\"><img src=\""+QMW2.resourcesPath+"/images/spacer.gif\" width=\"1\" height=\"1\"/></div></td></tr></table>";return t;},registerHandlers:function(){this.legend.addHandler("mouseup","legendItem"+this.id,this.toggleVisibility.createDelegate(this));this.legend.addHandler("mouseup","legendItemRemove"+this.id,this.removeItem.createDelegate(this));this.legend.addHandler("mouseup","legendItemZoom"+this.id,this.zoomOnItem.createDelegate(this));},zoomOnItem:function(){if(!this.range.dontChange){var t=new QMW2.map.Range(this.range.minX,this.range.maxX,this.range.minY,this.range.maxY);if(!this.getProperty("visibility")){this.toggleVisibility();}this.legend.map.zoomBox(t);this.legend.eventManager.fireEvent("mapUpdated",this.legend.map.mapName);}return true;},remove:function(){this.removeAll();this.parent.removeChild(this);},removeItem:function(){if(QMW2.Application.yesNo($L("confirm_delete_item"))){this.remove();this.legend.draw(true);this.legend.eventManager.fireEvent("mapUpdated",this.legend.map.mapName);}return true;}});QMW2.ui.Legend.LegendNode.implementations["query"]=function(N,P,t){var m=new QMW2.ui.Legend.LegendQueryItem(P.id,t?$L(P.description,true):P.description,N,P.entity,P.range);m.initClasses();if(P.LegendNode){N.populateLegend(P,m,t);}return m;};QMW2.blackboard.ui.Blackboard.SymbologyEncoders["sld"]=function(){function N(P,n,m,w){if(w&&m){P.drawPolygon(n,{color:w},{color:m,weight:1,dashed:""});}else{if(w){P.drawPolygon(n,{color:w});}else{if(m){P.drawPolyline(n,{color:m,weight:1,dashed:""});}}}}var t={circle:function(n,P,f,w,m,B,j){n.drawEllipse(P,f,w,m,B,j);},square:function(n,P,p,j,m,f,B){var w=[{x:P,y:p},{x:P+j,y:p},{x:P+j,y:p+m},{x:P,y:p+m},{x:P,y:p}];n.drawPolygon(w,B,f);},star:function(P,B,w,m,p,F,e){var j=B+m/2;var n=w+p/2;var f=[{x:j,y:w},{x:j+m/4,y:w+p/4},{x:B+m,y:w+p/4},{x:j+m/4,y:n},{x:B+m,y:w+p},{x:j,y:n+p/4},{x:B,y:w+p},{x:B+m/4,y:n},{x:B,y:n-p/4},{x:j-m/4,y:n-p/4},{x:j,y:w}];P.drawPolygon(f,e,F);},cross:function(P,B,w,m,p,F,e){var j=B+m/2;var n=w+p/2;var f=[{x:j-1,y:w},{x:j+1,y:w},{x:j+1,y:n-1},{x:B+m,y:n-1},{x:B+m,y:n+1},{x:j+1,y:n+1},{x:j+1,y:w+p},{x:j-1,y:w+p},{x:j-1,y:n+1},{x:B,y:n+1},{x:B,y:n-1},{x:j-1,y:n-1},{x:j-1,y:w}];P.drawPolygon(f,e,F);},triangle:function(n,P,p,j,m,f,B){var w=[{x:P+j/2,y:p},{x:P+j,y:p+m},{x:P,y:p+m},{x:P+j/2,y:p}];n.drawPolygon(w,B,f);},x:function(P,B,w,m,p,F,e){var j=B+m/2;var n=w+p/2;var f=[{x:B,y:w+1},{x:B+1,y:w},{x:j,y:n-1},{x:B+m-1,y:w},{x:B+m,y:w+1},{x:j+1,y:n},{x:B+m,y:w+p-1},{x:B+m-1,y:w+p},{x:j,y:n+1},{x:B+1,y:w+p},{x:B,y:w+p-1},{x:j-1,y:n},{x:B,y:w+1}];P.drawPolygon(f,e,F);}};return {canProcess:function(m){return t[m];},drawSymbol:function(n,j,P,p,w,m,f,B){t[j](n,P,p,w,m,f,B);}};}();QMW2.blackboard.ui.Blackboard.SymbologyEncoders["custom"]=function(){var N={};var t={};function P(e,B){var D=t.getScaleX(B);var F=t.getScaleY(B);var J=[];for(var j=0;j<e.length;j++){var p=e[j][0];var f=e[j][1];var w=(p-t.minX)*D+B.minX;var n=(-f+t.maxY)*F+B.minY;J.push({x:w,y:n});}return J;}function m(w,p,F,f,n,D,J,X){switch(p.type){case "MultiLineString":for(var B=0;B<p.coordinates.length;B++){var j={type:"LineString",coordinates:p.coordinates[B]};m(w,j,F,f,n,D,J,X);}break;case "MultiPolygon":for(var B=0;B<p.coordinates.length;B++){var j={type:"Polygon",coordinates:p.coordinates[B]};m(w,j,F,f,n,D,J,X);}break;case "LineString":var e=P(p.coordinates,new QMW2.map.Range(F,F+n,f,f+D));w.drawPolyline(e,{color:X.color,weight:1,dashed:""});break;case "Polygon":break;default:QMW2.Application.error(p.type+" not supported");break;}}return {canProcess:function(n){return N[n];},drawSymbol:function(w,j,p,f,n,F,e,D){var B=N[j];w.setClip(new QMW2.map.Range(p,p+n,f,f+F));m(w,B,p,f,n,F,e,D);w.setClip(null);},initSymbols:function(n){for(var j=0;j<n.features.length;j++){var w=n.features[j];N[w.properties.TYPE]=w.geometry;}var B=n.bbox;t=new QMW2.map.Range(B[0],B[2],B[1],B[3],n.crs.properties.code);t.zoom(2);}};}();QMW2.decorate(QMW2.Application,{readConfiguration:{before:function(t){if(t.symbols){QMW2.blackboard.ui.Blackboard.SymbologyEncoders["custom"].initSymbols(t.symbols);}}}});QMW2.declare("QMW2.ui.ChangeLanguage",null,{initializer:function(){this.type="changelanguage";this.languages=null;},init:function(t){this.name=t.name||"changelanguage";this.container=Ext.get(this.name);var N=t.applicationCfg;if(N.Languages&&N.Languages.Language){this.languages=QMW2.getArray(N.Languages.Language);var m=[];for(var P=0;P<this.languages.length;P++){var n="changelang";if(this.languages[P].value==QMW2.Application.language){n+=" changelang-current";}m.push({tag:"div",cls:n,id:"changelang"+this.languages[P].value});}m.push({tag:"div",cls:"clear"});Ext.DomHelper.append(this.container,{tag:"div",id:"changelangcontainer",children:m},true);for(var P=0;P<this.languages.length;P++){if(this.languages[P].value!=QMW2.Application.language){Ext.fly("changelang"+this.languages[P].value).on("click",function(w,B){var x=B.id.substring(10);var f=QMW2.Application.applicationParameters;f["language"]=x;var j=window.location.pathname+"?"+Ext.urlEncode(f);window.location.href=j;});}}}}});QMW2.controlLoaded("changelanguage",QMW2.ui.ChangeLanguage);QMW2.declare("QMW2.ui.AccessCounter",null,{initializer:function(){this.type="accesscounter";},init:function(t){this.name=t.name||"accesscounter";this.container=Ext.get(this.name);this.container.update($L(t.message)+t.counter);}});QMW2.controlLoaded("accesscounter",QMW2.ui.AccessCounter);QMW2.declare("QMW2.ui.TooltipChooser",null,{initializer:function(N,P,m,t){this.type="tooltipchooser";},init:function(t){this.name=t.name||"tooltipchooser";this.container=Ext.get(t.container||this.name);this.map=t.map;this.eventManager=t.eventManager;this.localized=t.localized||false;this.initTooltips();},initTooltips:function(){var n=null;for(var N in this.map.layers){if(this.map.layers[N].tooltips){n=this.map.layers[N];}}if(n){this.tooltipLayer=n;var P=[[0,$L("tooltipchoose_empty")]];for(var t in n.tooltips){var m=n.tooltips[t].description;P.push([t,this.localized?$L(m,true):m]);}this.createCombo(P);}},createCombo:function(m){Ext.DomHelper.append(this.container,{tag:"table",cls:"qmw2-tooltipchoose",children:[{tag:"tr",children:[{tag:"td",children:[{tag:"div",cls:"qmw2-tooltipchooselogo",children:[{tag:"img",src:QMW2.resourcesPath+"/images/spacer.gif",title:$L("tooltipchooselogo_tooltip")}]}]},{tag:"td",children:[{tag:"input",id:this.name+"tooltipCombo",cls:"qmw2-tooltipchoose"}]}]}]});var t=new Ext.data.SimpleStore({fields:["feature","description"],data:m});var P=new Ext.form.ComboBox({store:t,displayField:"description",valueField:"feature",mode:"local",triggerAction:"all",forceSelection:true,width:140,editable:false});P.applyTo(this.name+"tooltipCombo");P.setValue(this.tooltipLayer.activeTooltip||0);var N=this.tooltipLayer;P.on("select",this.activateTooltip.createDelegate(this));},activateTooltip:function(m,t,N){this.tooltipLayer.activateTooltip(t.data["feature"]||null);QMW2.Application.eventManager.fireEvent("mapUpdated",this.map.mapName);}});QMW2.controlLoaded("tooltipchooser",QMW2.ui.TooltipChooser);QMW2.loadWidget("canvas");QMW2.declare("QMW2.ui.Toolbar",null,{initializer:function(N,n,P,t,m){this.canvas=null;this.controls={};this.dynamicControls=[];this.type="toolbar";},getCanvasContainer:function(){return document.body;},getMinimumSize:function(){var t=0;Ext.fly(this.container).select(">*").each(function(N){t+=N.getWidth();});return t;},requireObject:function(t,N){if(t=="canvas"){this.canvas=N;}return null;},init:function(t){this.name=t.name||"toolbar";this.container=Ext.get(t.container||this.name);this.map=t.map;this.eventManager=t.eventManager;this.defaultControl=t["default"]||null;if(t.width){this.container.setWidth(t.width);}if(t.height){this.container.setHeight(t.height);}if(t.controls){this.dynamicControls=t.controls;}this.container.on("selectstart",function(N){var m=N.getTarget();if(m.tagName.toUpperCase()!="INPUT"||m.type!="text"){N.stopEvent();}});this.attachFrameworkEvents();},attachFrameworkEvents:function(){this.eventManager.attachToEvent("tooloff",this.handleDefaultControl.createDelegate(this));},handleDefaultControl:function(){if(this.defaultControl){this.controls[this.defaultControl].controlOn();}},postInit:function(){for(var m=0;m<this.dynamicControls.length;m++){var N=this.dynamicControls[m];var t=QMW2.ui.Toolbar.Control.implementations[N.type];if(!t){QMW2.loadControl("toolbarcontrols."+N.type);t=QMW2.ui.Toolbar.Control.implementations[N.type];}if(t){this.addControl(t(N.id,this,this.canvas,N));}else{QMW2.Application.error($L("toolbar_controltype_unknown")+": "+N.type);}}this.dynamicControls=[];this.attachEvents();},endInit:function(){for(var N in this.controls){var t=this.controls[N];if(t.endInit){t.endInit();}}this.handleDefaultControl();},toolbarEvent:function(P,t){var N=P.getTarget();while(N&&N.id&&!this.controls[N.id]){N=N.parentNode;}if(N&&N.id&&this.controls[N.id]){var m=this.controls[N.id];if(m.multiple){if(t=="mousedown"){m.choosing=true;m.multipleToggle.defer(700,m);}else{if(t=="mouseup"){if(m.choosing){m.choosing=false;if(m.fastMultipleToggle(P)){m.doMultipleToggle();t="dummy";}else{t="click";}}}}}else{if(t=="mouseup"){t="click";}}if(m.isEnabled(t)){if(t=="click"){m.doCommand();}else{m.setStatus(t=="mouseover"?"roll":"off");}}}},attachEvents:function(){this.container.mon("mouseover",function(t){this.toolbarEvent(t,"mouseover");},this,true);this.container.mon("mouseout",function(t){this.toolbarEvent(t,"mouseout");},this,true);this.container.mon("mousedown",function(t){this.toolbarEvent(t,"mousedown");},this,true);this.container.mon("mouseup",function(t){this.toolbarEvent(t,"mouseup");},this,true);},addControl:function(m,N){this.controls[m.name]=m;if(N&&N.length){for(var t=0;t<N.length;t++){this.controls[N[t]]=m;}}},getControl:function(t){return this.controls[t];},clear:function(){for(var t in this.controls){this.controls[t].clear();}},doCommand:function(t){if(this.controls[t]){this.controls[t].doCommand(t);}else{alert("Command not recognized: "+t);}}});QMW2.declare("QMW2.ui.Toolbar.Control",null,{initializer:function(m,n,N,t){this.name=m;this.toolbar=n;this.canvas=N;this.config=t;this.container=null;this.posX=0;this.visible=t.visible;if(this.visible){this.container=Ext.get(this.name);}this.open=false;this.multiple=t.alternatives?true:false;if(this.multiple){this.multipleAlign=t.align;this.alternatives=[t];for(var P=0;P<t.alternatives.length;P++){this.alternatives.push(t.alternatives[P]);}this.choice=0;}if(t.isButton&&this.visible){if(this.multiple){this.multipleContainer=Ext.DomHelper.append(document.body,{tag:"div",id:this.name+"MultipleContainer",cls:"qmw2-toolbarmultiple"},true).setPositioning({position:"absolute",left:0,top:0}).setSize(this.container.getWidth(),this.container.getHeight()*(this.alternatives.length-1)).setDisplayed("none");this.fillMultipleContainer();}this.configButton(t);}this.setInitialStatus(t.status||"off");},setInitialStatus:function(t){if(t!="on"){this.updateStatus(t);}},endInit:function(){if(this.config.status=="on"){this.controlOn();}},configButton:function(t){this.container.removeAllChilds();Ext.DomHelper.append(this.container,{tag:"img",id:this.name+"Img",cls:"qmw2-toolbarcontrolimg",src:QMW2.resourcesPath+"/images/spacer.gif",title:(t.tip||(t.localizedTip?$L(t.localizedTip):""))});if(this.multiple){Ext.DomHelper.append(this.container,{tag:"img",id:this.name+"ImgMultiple",cls:"qmw2-toolbarcontrolimgmultiple",src:QMW2.resourcesPath+"/images/multiplebutton.gif",title:(t.tip||(t.localizedTip?$L(t.localizedTip):""))});}this.posX=-((t.spriteColumn||1)-1)*this.container.getWidth();},fastMultipleToggle:function(t){return t.getTarget().id==this.name+"ImgMultiple";},switchMultiple:function(N){this.choice=N;var t=this.alternatives[N];this.configButton(t);this.fillMultipleContainer();this.doCommand(true);},fillMultipleContainer:function(){this.multipleContainer.removeAllChilds();for(var P=0;P<this.alternatives.length;P++){if(P!=this.choice){var N=this.alternatives[P];var w=-((N.spriteColumn||1)-1)*this.container.getWidth();var m=Ext.DomHelper.append(this.multipleContainer,{tag:"div",id:this.name+P,cls:"qmw2-toolbarcontrol",children:[{tag:"img",id:this.name+"Img",cls:"qmw2-toolbarcontrolimg",src:QMW2.resourcesPath+"/images/spacer.gif",title:(N.tip||(N.localizedTip?$L(N.localizedTip):""))}]},true).setStyle("backgroundPosition",w+"px 0px");var t=this;var n=P;m.on("click",function(){t.switchMultiple(n);});}}},doMultipleToggle:function(){this.choosing=false;this.open=!this.open;if(this.open){this.multipleContainer.setDisplayed("block");this.multipleContainer.alignTo(this.container,this.multipleAlign);}else{this.multipleContainer.setDisplayed("none");}},multipleToggle:function(t){if(this.choosing||(t===true&&this.open)){this.doMultipleToggle();}},setStatus:function(t){if(this.container){if(t=="invisible"){this.container.setDisplayed("none");}else{this.container.setDisplayed("block");if(t=="off"||t=="disabled"){this.container.setStyle("backgroundPosition",this.posX+"px 0px");}else{if(t=="roll"){this.container.setStyle("backgroundPosition",this.posX+"px -"+(this.container.getHeight())+"px");}else{if(t=="on"){this.container.setStyle("backgroundPosition",this.posX+"px -"+(this.container.getHeight()*2)+"px");}}}if(t=="disabled"){this.container.addClass("qmw2-toolbarcontroldisabled");}else{this.container.removeClass("qmw2-toolbarcontroldisabled");}}}},clear:function(){if(this.status!="disabled"&&this.status!="invisible"){this.controlOff(true);}},doCommand:function(t){if(this.multiple&&this.open){this.multipleToggle(true);}if(this.type=="toggle"){if(this.status=="off"||t){this.controlOn();}else{this.controlOff();}}},isEnabled:function(t){if(this.status=="disabled"||this.status=="invisible"){return false;}if(t=="click"){return true;}if((t=="mouseover"||t=="mouseout"||t=="mousemove")&&(this.type=="oneshot"||this.type=="toggle"&&this.status=="off")){return true;}return false;},controlOff:function(t){this.updateStatus("off");if(this.canvas){this.canvas.clear();}if(!t){this.toolbar.eventManager.fireEvent("tooloff",this.name);}},controlOn:function(){this.toolbar.clear();this.updateStatus("on");if(this.canvas){this.canvas.clear();}},updateStatus:function(t){this.status=t;this.setStatus(this.status);}});QMW2.ui.Toolbar.Control.implementations={};QMW2.controlLoaded("toolbar",QMW2.ui.Toolbar);QMW2.loadWidget("polygonselector");QMW2.declare("QMW2.ui.Toolbar.CaptureControl",QMW2.ui.Toolbar.Control,{initializer:function(m,P,N,t){this.type="toggle";this.cursor=t.cursor;this.persistent=t.persistent||false;this.onmove=t.onMove;this.onclick=t.onClick;this.tollerance=t.tollerance||0;this.selector=null;this.createSelector(t,N);QMW2.ui.Toolbar.CaptureControl.superclass.constructor.call(this,m,P,N,t);},createSelector:function(N,t){if(N.selectBox){this.selector=new QMW2.widgets.ui.PolygonSelector("captureSelector",toolbar.cfg,toolbar.map,toolbar.eventManager,false,t,N.cursor,N.style,true,true);this.selector.on("select",this.capturedBox.createDelegate(this));}else{if(N.selectPolygon){this.selector=new QMW2.widgets.ui.PolygonSelector("captureSelector",toolbar.cfg,toolbar.map,toolbar.eventManager,false,t,N.cursor,N.style,false);this.selector.on("select",this.capturedPolygon.createDelegate(this));}}if(this.selector){this.selector.on("undo",this.controlOff.createDelegate(this));}},switchMultiple:function(N){var t=this.alternatives[N];this.createSelector(t,this.canvas);QMW2.ui.Toolbar.Control.prototype.switchMultiple.apply(this,[N]);},capturedPolygon:function(m){if(!this.persistent){this.controlOff();}var N=this.toolbar.map.realRange;var t=[];for(var P=0;P<m.length;P++){t.push({x:this.canvas.getRealX(m[P].x,N),y:this.canvas.getRealY(m[P].y,N)});}this.toolbar.eventManager.fireEvent(this.onclick,t);},capturedBox:function(P,m,F,p){if(!this.persistent){this.controlOff();}var x=this.toolbar.map.realRange;var j=this.canvas.getRealX(P,x);var N=this.canvas.getRealX(m,x);var t=this.canvas.getRealY(F,x);var n=this.canvas.getRealY(p,x);var f=this.getTolleranceBuffer(x);if((N-j)<f*2){var B=(j+N)/2;j=B-f;N=B+f;}if((t-n)<f*2){var w=(n+t)/2;n=w-f;t=w+f;}var x=new QMW2.map.Range(j,N,n,t,this.canvas.getCRS());this.toolbar.eventManager.fireEvent(this.onclick,x);},getTolleranceBuffer:function(m){if(this.tollerance){var N="m";var P=new RegExp("^([0-9]+)([a-zA-Z]*)$","gi");var t;if((t=P.exec(this.tollerance))){tollValue=parseFloat(t[1]);if(t[2]){N=t[2].toLowerCase();}}if(N=="m"){return tollValue;}else{return tollValue/this.canvas.getWidth()*m.getDeltaX();}}else{return 0;}},captured:function(p,N,t,m){var f=p.getOffsetX();var B=p.getOffsetY();var j=this.toolbar.map.realRange;var w=this.canvas.getRealX(f,j);var n=this.canvas.getRealY(B,j);var P=this.getTolleranceBuffer(j);this.toolbar.eventManager.fireEvent(m,w,n,P,this.canvas.getCRS());},controlOff:function(){QMW2.ui.Toolbar.Control.prototype.controlOff.apply(this,arguments);if(this.selector){this.selector.disableSelect();}},controlOn:function(){QMW2.ui.Toolbar.Control.prototype.controlOn.apply(this,arguments);if(this.selector){this.selector.enableSelect();}else{this.canvas.show(this.cursor);if(this.onmove){this.canvas.onmousemove(this.captured.createDelegate(this,[this.onmove],true));}if(this.onclick){this.canvas.onclick(this.captured.createDelegate(this,[this.onclick],true));}}}});QMW2.ui.Toolbar.Control.implementations["capturecontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.CaptureControl(P,m,N,t);};QMW2.declare("QMW2.ui.Toolbar.CommandControl",QMW2.ui.Toolbar.Control,{initializer:function(m,P,N,t){this.type="oneshot";this.command=t.command;QMW2.ui.Toolbar.CommandControl.superclass.constructor.call(this,m,P,N,t);},doCommand:function(){this.toolbar.eventManager.fireEvent(this.command,this.toolbar.map.mapName);}});QMW2.ui.Toolbar.Control.implementations["commandcontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.CommandControl(P,m,N,t);};QMW2.loadWidget("polyline");QMW2.declare("QMW2.ui.Toolbar.MeasureControl",QMW2.ui.Toolbar.Control,{initializer:function(n,B,P,m,j){this.type="toggle";this.cursor=m.cursor;var t=m.style.split(",");this.stroke={color:t[0],weight:t[1],opacity:parseInt(t[2],10)/100};this.measureType=m.measureType;this.outputType=m.outputType;this.crs=m.crs;if(m.onCanvas){var N=Ext.DomHelper.append(B.getCanvasContainer(),{tag:"div",id:"measureContainer"+n,cls:"qmw2-measurecontainer"},true);N.alignTo(P.container,m.onCanvas+"-"+m.onCanvas,[m.alignX||0,m.alignY||0]);N.addClass("qmw2-measuredisabled");}else{var w=Ext.get(j);if(m.alignX){w.setLeft(m.alignX);}if(m.alignY){w.setTop(m.alignY);}}this.measureContainer=$(j);QMW2.ui.Toolbar.MeasureControl.superclass.constructor.call(this,n,B,P,m);this.attachFrameworkEvents();},attachFrameworkEvents:function(){},draw:function(){var N=Ext.get("newMeasure"+this.name);if(N){N.removeAllListeners();}N=Ext.get("stopMeasure"+this.name);if(N){N.removeAllListeners();}var t="<div class=\"qmw2-measureOutput\" id=\"measureOutput"+this.name+"\"></div>";t+="<div id=\"newMeasure"+this.name+"\" class=\"qmw2-newMeasure\"><img src=\""+QMW2.resourcePath+"/images/spacer.gif\" class=\"qmw2-newMeasureImg\" title=\""+$L("newMeasuremeasure"+this.measureType+"_tooltip")+"\"/></div>";t+="<div id=\"stopMeasure"+this.name+"\" class=\"qmw2-stopMeasure\"><img src=\""+QMW2.resourcePath+"/images/spacer.gif\" class=\"qmw2-stopMeasureImg\" title=\""+$L("stopMeasuremeasure"+this.measureType+"_tooltip")+"\"/></div>";this.measureContainer.innerHTML=t;},beginMeasure:function(N){this.canvas.beginDraw();this.canvas.on("click",this.nextMeasure.createDelegate(this));this.canvas.on("dblclick",this.endMeasure.createDelegate(this));this.canvas.on("mousemove",this.moveMeasure.createDelegate(this));this.polyline=new QMW2.widgets.ui.Polyline(this.canvas.blackboard);var t=N.getOffsetX(this.canvas.getCapturer());var m=N.getOffsetY(this.canvas.getCapturer());this.polyline.addPoints({x:t,y:m},{x:t,y:m});},moveMeasure:function(t){this.polyline.changeLastPoint(t.getOffsetX(this.canvas.getCapturer()),t.getOffsetY(this.canvas.getCapturer()));this.polyline.draw(this.measureType!="distance",this.stroke);},getAffineDistance:function(n,P){var t=this.toolbar.map.realRange;var m=this.toolbar.map.realRange.getDeltaX()/this.canvas.getWidth();var N=Math.pow((P.x-n.x)*(P.x-n.x)+(P.y-n.y)*(P.y-n.y),1/2);this.distance[0]+=N*m;return Math.round(this.distance[0]);},getRealDistance:function(P,m){var N=this.getReal(P);var w=this.getReal(m);var t=this.toolbar.map.projection.toGeographic(N);var n=this.toolbar.map.projection.toGeographic(w);this.distance[1]+=this.getEarthDistance(n,t);return Math.round(this.distance[1]);},updateDistance:function(){var N=this.polyline.points[this.polyline.points.length-2];var t=this.polyline.points[this.polyline.points.length-1];if(this.outputType=="affine"||this.crs==this.toolbar.map.crs){$("measureOutput"+this.name).innerHTML=this.getAffineDistance(N,t)+" m";}else{if(this.outputType=="real"){$("measureOutput"+this.name).innerHTML=this.getRealDistance(N,t)+" m";}else{if(this.outputType=="both"){$("measureOutput"+this.name).innerHTML=this.getRealDistance(N,t)+" ("+this.getAffineDistance(N,t)+") m";}}}},getEarthDistance:function(n,w){var N=QMW2.coordinates.degToRad(w.y);var P=QMW2.coordinates.degToRad(w.x);var t=QMW2.coordinates.degToRad(n.y);var m=QMW2.coordinates.degToRad(n.x);return Math.acos(Math.cos(N)*Math.cos(P)*Math.cos(t)*Math.cos(m)+Math.cos(N)*Math.sin(P)*Math.cos(t)*Math.sin(m)+Math.sin(N)*Math.sin(t))*6378000;},getRealArea:function(w,n,j,m,t){var P=QMW2.coordinates.Projections[this.crs];var N=this.toolbar.map.projection;w=P.fromGeographic(N.toGeographic(w));n=P.fromGeographic(N.toGeographic(n));j=P.fromGeographic(N.toGeographic(j));m=P.fromGeographic(N.toGeographic(m));return this.getAffineArea(w,n,j,m,t);},getAffineArea:function(P,m,n,N,t){this.distance[t]+=(m.x-P.x)*(P.y+m.y);return Math.round(Math.abs((this.distance[t]+((n.x-m.x)*(m.y+n.y)))/2));},getReal:function(N){var t=this.toolbar.map.realRange;return {x:this.canvas.getRealX(N.x,t),y:this.canvas.getRealY(N.y,t)};},updateArea:function(){var m=this.getReal(this.polyline.points[this.polyline.points.length-2]);var N=this.getReal(this.polyline.points[this.polyline.points.length-1]);var P=this.getReal(this.polyline.points[0]);var t=this.getReal(this.polyline.points[this.polyline.points.length-1]);if(this.outputType=="affine"||this.crs==this.toolbar.map.crs){$("measureOutput"+this.name).innerHTML=this.getAffineArea(m,N,P,t,0)+" mq";}else{if(this.outputType=="real"){$("measureOutput"+this.name).innerHTML=this.getRealArea(m,N,P,t,1)+" mq";}else{if(this.outputType=="both"){$("measureOutput"+this.name).innerHTML=this.getRealArea(m,N,P,t,1)+" ("+this.getAffineArea(m,N,P,t,0)+" ) mq";}}}},addNewPoint:function(t){if(this.measureType=="distance"){this.updateDistance();}else{this.updateArea();}this.polyline.addPoints({x:t.getOffsetX(this.canvas.getCapturer()),y:t.getOffsetY(this.canvas.getCapturer())});},nextMeasure:function(t){this.addNewPoint(t);},endMeasure:function(t){this.addNewPoint(t);this.canvas.un("mousemove");this.canvas.un("click");this.canvas.un("dblclick");this.canvas.endDraw();},getScaleFactor:function(){return this.toolbar.map.realRange.getDeltaX()/this.canvas.getWidth();},sumArea:function(N,t){return Math.abs(Math.round((this.distance[0]+((N.x-t.x)*(t.y+N.y)))/2));},disable:function(){Ext.get(this.measureContainer).addClass("qmw2-measuredisabled");},enable:function(){Ext.get(this.measureContainer).removeClass("qmw2-measuredisabled");},refresh:function(){if(this.status=="off"){this.disable();}else{this.enable();}},controlOff:function(){QMW2.ui.Toolbar.Control.prototype.controlOff.apply(this,arguments);this.disable();},controlOn:function(){QMW2.ui.Toolbar.Control.prototype.controlOn.apply(this,arguments);this.draw();this.attachEvents();this.newMeasure();},attachEvents:function(){Ext.get("newMeasure"+this.name).mon("click",function(t){this.canvas.clear();this.newMeasure();t.stopPropagation();},this,true);Ext.get("stopMeasure"+this.name).mon("click",function(t){this.controlOff();t.stopPropagation();},this,true);},newMeasure:function(){this.polyline=new QMW2.widgets.ui.Polyline(this.canvas.blackboard);this.distance=[0,0];this.enable();this.canvas.show(this.cursor);if(this.measureType=="distance"){$("measureOutput"+this.name).innerHTML="0 m";}else{$("measureOutput"+this.name).innerHTML="0 mq";}this.canvas.on("click",this.beginMeasure.createDelegate(this));}});QMW2.ui.Toolbar.Control.implementations["measurecontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.MeasureControl(P,m,N,t,t.container);};QMW2.decorate(QMW2.ui.Toolbar.MeasureControl,{attachFrameworkEvents:{after:function(){this.toolbar.eventManager.attachToEvent("mapResized",this.realign.createDelegate(this));}},controlOn:{after:function(){this.realign();}},realign:function(){var t=Ext.get(this.measureContainer);if(!t.hasClass("qmw2-measuredisabled")){t.alignTo(this.canvas.container,this.config.onCanvas+"-"+this.config.onCanvas,[this.config.alignX||0,this.config.alignY||0]);}}});QMW2.loadWidget("polygonselector");QMW2.declare("QMW2.ui.Toolbar.SmartNavigateControl",QMW2.ui.Toolbar.Control,{initializer:function(m,P,N,t){this.type="toggle";this.cursor=t.cursor;this.persistent=t.persistent||false;this.hasDynamicZoom=t.dynamicZoom;this.hasPan=t.pan;this.hasZoom=t.zoom;this.hasZoomWindow=t.zoomWindow;this.totalDelta=0;this.factor=t.factor||2;if(this.hasDynamicZoom){this.dynamicZoomDelay=t.delay||500;this.dynamicZoomTask=new Ext.util.DelayedTask(this.doDynamicZoom.createDelegate(this));}if(this.hasZoomWindow){this.boxSelector=new QMW2.widgets.ui.PolygonSelector("zoomBoxSelector",P.cfg,P.map,P.eventManager,t.constraint,N,t.cursor,t.style,true);this.boxSelector.on("select",this.zoomWindow.createDelegate(this));this.boxSelector.on("undo",this.controlOff.createDelegate(this));}QMW2.ui.Toolbar.SmartNavigateControl.superclass.constructor.call(this,m,P,N,t);},zoomWindow:function(P,m,f,B){if(!this.toolbar.map.isLocked()){if(!this.persistent){this.controlOff();}var j=this.toolbar.map.realRange;var w=this.canvas.getRealX(P,j);var N=this.canvas.getRealX(m,j);var t=this.canvas.getRealY(f,j);var n=this.canvas.getRealY(B,j);var j=new QMW2.map.Range(w,N,n,t);j.adjustAspectRatio(this.canvas.getWidth(),this.canvas.getHeight());this.toolbar.map.zoomBox(j);this.toolbar.eventManager.fireEvent("mapUpdated",this.toolbar.map.mapName);}},panOrZoomWindow:function(t){if(this.hasPan&&!t.hasModifier()){this.beginPan(t);}else{if(this.hasZoomWindow){this.boxSelector.beginPolygonSelect(t);}}},beginPan:function(t){if(this.toolbar.map.isPannable()&&!this.toolbar.map.isLocked()){t.preventDefault();this.movingPan=false;this.canvas.on("mousedown",this.undoPan.createDelegate(this));this.canvas.on("mousemove",this.movePan.createDelegate(this));this.canvas.on("mouseup",this.endPan.createDelegate(this),this.undoPan.createDelegate(this));this.x1=t.getOffsetX();this.y1=t.getOffsetY();this.x2=this.x1;this.y2=this.y1;Ext.get(document).swallowEvent("selectstart",true);Ext.get(document).swallowEvent("dragstart",true);this.toolbar.eventManager.fireEvent("startInteractivePan");}},movePan:function(t){if(!t.isLeftClicked()){this.undoPan();}else{if(!this.movingPan){this.movingPan=true;this.canvas.beginDraw();}t.preventDefault();this.x2=t.getOffsetX();this.y2=t.getOffsetY();if(!isNaN(this.x2)&&!isNaN(this.x1)&&this.canvas.within(t)){this.toolbar.eventManager.fireEvent("interactivePan",this.x1,this.y1,this.x2,this.y2);}}},endPan:function(t){this.canvas.un("mousemove");this.canvas.un("mouseup",true);if(!this.persistent){this.controlOff();}else{this.canvas.on("mousedown",this.panOrZoomWindow.createDelegate(this));}this.toolbar.eventManager.fireEvent("endInteractivePan");var N=0.5+(this.x2-this.x1)/this.canvas.getWidth();var m=0.5+(this.y2-this.y1)/this.canvas.getHeight();this.pan(N,m,true);this.canvas.erase();},undoPan:function(){this.canvas.un("mousemove");this.canvas.un("mouseup",true);if(!this.persistent){this.controlOff();}else{this.canvas.on("mousedown",this.panOrZoomWindow.createDelegate(this));}this.toolbar.eventManager.fireEvent("undoInteractivePan");this.canvas.erase();},pan:function(t,m,N){if(this.toolbar.map.pan(t,1-m)){this.toolbar.eventManager.fireEvent("mapUpdated",this.toolbar.map.mapName,null,N);}else{this.toolbar.eventManager.fireEvent("undoInteractivePan");}},dynamicZoom:function(t){if(!this.toolbar.map.isLocked()){var N=t.getWheelDelta();this.totalDelta+=N;this.toolbar.eventManager.fireEvent("interactiveZoom",this.fromDeltaToFactor(N));this.dynamicZoomTask.delay(this.dynamicZoomDelay);}},fromDeltaToFactor:function(t){return Math.pow(this.factor,t);},doDynamicZoom:function(){this.toolbar.map.zoom(this.fromDeltaToFactor(this.totalDelta));this.toolbar.eventManager.fireEvent("mapUpdated",this.toolbar.map.mapName);this.totalDelta=0;if(!this.persistent){this.controlOff();}},zoomOnPoint:function(N){if(!this.toolbar.map.isLocked()){var t=this.canvas.getRealX(N.getOffsetX(),this.toolbar.map.realRange);var m=this.canvas.getRealY(N.getOffsetY(),this.toolbar.map.realRange);this.toolbar.map.zoomOnPoint(t,m,this.factor);this.toolbar.eventManager.fireEvent("mapUpdated",this.toolbar.map.mapName);if(!this.persistent){this.controlOff();}}},controlOn:function(){QMW2.ui.Toolbar.Control.prototype.controlOn.apply(this,arguments);this.canvas.show(this.cursor);if(this.hasPan||this.hasZoomWindow){this.canvas.on("mousedown",this.panOrZoomWindow.createDelegate(this));}if(this.hasDynamicZoom){this.canvas.on("mousewheel",this.dynamicZoom.createDelegate(this));}if(this.hasZoom){this.canvas.on("dblclick",this.zoomOnPoint.createDelegate(this));}},controlOff:function(){this.canvas.un("mousedown");this.canvas.un("mousewheel");this.canvas.un("dblclick");if(this.hasZoomWindow){this.boxSelector.disableSelect();}QMW2.ui.Toolbar.Control.prototype.controlOff.apply(this,arguments);},doCommand:function(){if(this.status=="off"){this.controlOn();}else{this.controlOff();}}});QMW2.ui.Toolbar.Control.implementations["smartnavigatecontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.SmartNavigateControl(P,m,N,t);};QMW2.declare("QMW2.ui.Toolbar.QualityControl",QMW2.ui.Toolbar.Control,{initializer:function(m,n,N,t){this.type="oneshot";this.updateEnabled=false;this.formats=t.formats.split(",");this.initialformat=t.initialformat;this.currentPos=0;for(var P=0;P<this.formats.length;P++){if(this.formats[P]==this.initialformat){this.currentPos=P;}}QMW2.ui.Toolbar.QualityControl.superclass.constructor.call(this,m,n,N,t);Ext.fly("qualityChangeButton"+this.name).on("click",function(w){if(this.updateEnabled){this.toolbar.eventManager.fireEvent("mapUpdated",this.toolbar.map.mapName);}},this,true);this.toolbar.eventManager.attachToEvent("mapUpdated",this.disableUpdate.createDelegate(this));},setStatus:function(t){if(t=="invisible"){this.container.setDisplayed("none");}else{this.container.setDisplayed("block");}},enableUpdate:function(){this.updateEnabled=true;$("qualityChangeButton"+this.name).style.backgroundPosition="0px 0px";$("qualityChangeButton"+this.name).style.cursor="pointer";},disableUpdate:function(){this.updateEnabled=false;var t=Ext.get("qualityChangeButton"+this.name);$("qualityChangeButton"+this.name).style.backgroundPosition="0px -"+t.getHeight()+"px";$("qualityChangeButton"+this.name).style.cursor="default";},isEnabled:function(t){if(t=="mouseover"||t=="mouseout"||t=="mousemove"){return false;}return QMW2.ui.Toolbar.Control.prototype.isEnabled.apply(this,arguments);},doCommand:function(){for(var t=0;t<this.formats.length;t++){this.container.removeClass("qmw2-qualitychange-"+this.formats[t]);}this.currentPos++;if(this.currentPos==this.formats.length){this.currentPos=0;}this.container.addClass("qmw2-qualitychange-"+this.formats[this.currentPos]);this.toolbar.eventManager.fireEvent("updatemapquality",this.formats[this.currentPos]);this.enableUpdate();}});QMW2.ui.Toolbar.Control.implementations["qualitycontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.QualityControl(P,m,N,t);};QMW2.declare("QMW2.ui.Toolbar.ReloadControl",QMW2.ui.Toolbar.Control,{initializer:function(m,P,N,t){this.type="oneshot";this.stopSpriteColumn=t.stopSpriteColumn;this.spriteColumn=t.spriteColumn;this.mode="reload";this.tip="";if(t.tip){this.tip=t.tip;}if(t.localizedTip){this.tip=$L(t.localizedTip);}if(t.stopTip){this.stopTip=t.stopTip;}if(t.localizedStopTip){this.stopTip=$L(t.localizedStopTip);}QMW2.ui.Toolbar.ReloadControl.superclass.constructor.call(this,m,P,N,t);this.toolbar.eventManager.attachToEvent("mapIsLoading",this.mapIsLoading.createDelegate(this));this.toolbar.eventManager.attachToEvent("mapLoaded",this.mapLoaded.createDelegate(this));},mapIsLoading:function(N){if(N==this.toolbar.map.mapName){var t=Ext.get(this.name);this.posX=-((this.stopSpriteColumn||1)-1)*t.getWidth();this.setStatus("off");this.mode="stop";}},mapLoaded:function(N){if(N==this.toolbar.map.mapName){var t=Ext.get(this.name);this.posX=-((this.spriteColumn||1)-1)*t.getWidth();this.setStatus("off");this.mode="reload";}},doCommand:function(){var t=Ext.get(this.name);if(this.mode=="stop"){this.toolbar.eventManager.fireEvent("mapStopped",this.toolbar.map.mapName);}else{this.toolbar.eventManager.fireEvent("mapUpdated",this.toolbar.map.mapName);}}});QMW2.ui.Toolbar.Control.implementations["reloadcontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.ReloadControl(P,m,N,t);};QMW2.declare("QMW2.ui.Toolbar.ScaleChangeControl",QMW2.ui.Toolbar.Control,{initializer:function(n,j,P,m){this.type="oneshot";QMW2.ui.Toolbar.ScaleChangeControl.superclass.constructor.call(this,n,j,P,m);this.scaleChangeEnabled=false;var B=Ext.get("scaleValue"+this.name);var t=Ext.get("scaleChangeButton"+this.name);B.on("keydown",function(f){var x=f.getCharCode();if(x==f.BACKSPACE||x==f.DELETE){this.enableScaleChange();}},this,true);B.on("keypress",function(f){var x=f.getCharCode();if(x==13){this.changeScale($("scaleValue"+this.name).value);f.stopEvent();}else{if(x==f.ESC){this.updateScale();$("scaleValue"+this.name).blur();}else{if(x>=48&&x<=58){this.enableScaleChange();}else{if(x!=f.BACKSPACE&&x!=f.DELETE){f.stopEvent();}}}}},this,true);t.on("click",function(f){this.changeScale($("scaleValue"+this.name).value);},this,true);var N=document.createElement("img");N.id=this.name+"Img";N.src=QMW2.resourcesPath+"/images/spacer.gif";$("scaleChangeButton"+this.name).appendChild(N);var w=Ext.get(N);w.setWidth(t.getWidth());w.setHeight(t.getHeight());this.tip="";if(m.tip){this.tip=m.tip;}if(m.localizedTip){this.tip=$L(m.localizedTip);}this.toolbar.eventManager.attachToEvent("mapUpdated",this.updateScale.createDelegate(this));},enableScaleChange:function(){this.scaleChangeEnabled=true;$("scaleChangeButton"+this.name).style.backgroundPosition="0px 0px";$("scaleChangeButton"+this.name).style.cursor="pointer";if(this.tip){$(this.name+"Img").title=this.tip;}},disableScaleChange:function(){this.scaleChangeEnabled=false;var t=Ext.get("scaleChangeButton"+this.name);$("scaleChangeButton"+this.name).style.backgroundPosition="0px -"+t.getHeight()+"px";$("scaleChangeButton"+this.name).style.cursor="default";$(this.name+"Img").title="";},changeScale:function(t){if(this.scaleChangeEnabled){this.disableScaleChange();this.toolbar.map.zoomToMetricScale(t);this.toolbar.eventManager.fireEvent("mapUpdated",this.toolbar.map.mapName);}},updateScale:function(){var t=this.toolbar.map.getMetricScale();$("scaleValue"+this.name).value=Math.round(t);this.disableScaleChange();}});QMW2.ui.Toolbar.Control.implementations["scalechangecontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.ScaleChangeControl(P,m,N,t);};QMW2.declare("QMW2.ui.Toolbar.ScalebarControl",QMW2.ui.Toolbar.Control,{initializer:function(n,j,P,m,N){this.type="oneshot";this.scaleContainer=N;this.canvas=P;this.width=m.width;this.bars=m.barNumber;QMW2.ui.Toolbar.ScalebarControl.superclass.constructor.call(this,n,j,P,m);if(m.onCanvas){var N=Ext.DomHelper.append(j.getCanvasContainer(),{tag:"div",id:"scaleContainer"+this.name,cls:"qmw2-scalecontainer"},true);N.alignTo(this.canvas.container,m.onCanvas+"-"+m.onCanvas,[m.alignX||0,m.alignY||0]);N.addClass("qmw2-scaledisabled");}else{var w=Ext.get(this.scaleContainer);if(m.alignX){w.setLeft(m.alignX);}if(m.alignY){w.setTop(m.alignY);}}if($("scaleViewText"+this.name)){var B=m.tip||(m.localizedTip?$L(m.localizedTip):"");$("scaleViewText"+this.name).innerHTML=B;}if($("scaleCheck"+this.name)){var t=Ext.get("scaleCheck"+this.name);t.checked=false;t.on("click",function(x){var f=x.getTarget();this.toggle(f);x.stopPropagation();},this,true);}this.attachFrameworkEvents();this.drawScale();},disable:function(){Ext.get(this.scaleContainer).addClass("qmw2-scaledisabled");},enable:function(){Ext.get(this.scaleContainer).removeClass("qmw2-scaledisabled");},refresh:function(){this.toggle($("scaleCheck"+this.name));},toggle:function(t){if(t.checked){this.enable();}else{this.disable();}},attachFrameworkEvents:function(){this.toolbar.eventManager.attachToEvent("mapUpdated",this.updateScale.createDelegate(this));},drawScale:function(){var t="<div id=\"scaleText\" class=\"qmw2-scaletext\">";for(var N=0;N<=this.bars;N++){t+="<div id=\"scaleText"+N+this.name+"\" class=\"qmw2-scalebarText\"></div>";}t+="</div><div class=\"clear\"></div><div id=\"scaleBar\"  class=\"qmw2-scalebar\">";var m=true;for(var N=1;N<=this.bars;N++){m=!m;t+="<div id=\"scaleBar"+N+this.name+"\" class=\"qmw2-scalebar"+(m?"Even":"Odd")+"\"></div>";}t+="</div>";$(this.scaleContainer).innerHTML=t;this.updateScale();},updateScale:function(f){if(f==this.toolbar.map.mapName){var t=this.toolbar.map.realRange;var p=t.getDeltaX();var m,B;var j="";var P=this.width||(this.canvas&&this.canvas.getWidth())||100;var x=p/10;var B=30;var m;if(x>1000){j="km";m=Math.floor(x/1000);var N=Math.floor(Math.LOG10E*Math.log(m));var w=Math.pow(10,N);m=Math.floor(m/w)*w;B=Math.floor(m*P/(p/1000));}else{if(x>=1){j="m";m=Math.floor(x);var N=Math.floor(Math.LOG10E*Math.log(m));var w=Math.pow(10,N);m=Math.floor(m/w)*w;B=Math.floor(m*P/(p));}else{j="mm";m=Math.floor(x*1000);var N=Math.floor(Math.LOG10E*Math.log(m));var w=Math.pow(10,N);m=Math.floor(m/w)*w;B=Math.floor(m*P/(p*1000));}}if(B&&!isNaN(B)&&isFinite(B)){for(var n=1;n<=this.bars;n++){$("scaleBar"+n+this.name).style.width=B+"px";}for(var n=0;n<=this.bars;n++){if(n!=this.bars){$("scaleText"+n+this.name).style.width=B+"px";}$("scaleText"+n+this.name).style.marginLeft="-2px";var F="";if(n==this.bars){F=" "+j;}$("scaleText"+n+this.name).innerHTML=n*m+F;}}}},doCommand:function(){if(this.status=="off"){this.status="on";Ext.get(this.scaleContainer).removeClass("qmw2-scaledisabled");}else{this.status="off";Ext.get(this.scaleContainer).addClass("qmw2-scaledisabled");}}});QMW2.ui.Toolbar.Control.implementations["scalecontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.ScalebarControl(P,m,N,t,t.container);};QMW2.decorate(QMW2.ui.Toolbar.ScalebarControl,{attachFrameworkEvents:{after:function(){this.toolbar.eventManager.attachToEvent("mapResized",this.realign.createDelegate(this));}},toggle:{after:function(){this.realign();}},realign:function(){var t=Ext.get(this.scaleContainer);if(!t.hasClass("qmw2-scaledisabled")){t.alignTo(this.canvas.container,this.config.onCanvas+"-"+this.config.onCanvas,[this.config.alignX||0,this.config.alignY||0]);}}});QMW2.declare("QMW2.ui.Toolbar.ZoomControl",QMW2.ui.Toolbar.Control,{initializer:function(m,P,N,t){this.type="oneshot";this.factor=t.factor;QMW2.ui.Toolbar.ZoomControl.superclass.constructor.call(this,m,P,N,t);},doCommand:function(){this.toolbar.map.zoom(this.factor);this.toolbar.eventManager.fireEvent("mapUpdated",this.toolbar.map.mapName);}});QMW2.ui.Toolbar.Control.implementations["zoomcontrol"]=function(P,m,N,t){return new QMW2.ui.Toolbar.ZoomControl(P,m,N,t);};