text: Ext.onReady(function(){Ext.define("Ext.ux.button.ColorButton",{extend:"Ext.button.Button",alias:"widget.colorbutton",width:109,height:22,defaultValue:null,value:"f1f1f1",getValue:function(){return this.value},setValue:function(j){this.value=j;if(Ext.isDefined(this.getEl())){this.getEl().dom.style.background="#"+j}},reset:function(){this.setValue(this.defaultValue)},menu:{},menuHandler:function(){},initComponent:function(){var j=this;this.defaultValue=this.value;this.menu=Ext.create("Ext.menu.Menu",{showSeparator:false,items:{xtype:"colorpicker",closeAction:"hide",listeners:{select:function(l,k){j.setValue(k);j.menu.hide();j.menuHandler(l,k)}}}});this.callParent()},listeners:{render:function(){this.setValue(this.value)}}});Ext.define("Ext.ux.layout.component.form.MultiSelect",{extend:"Ext.layout.component.field.Field",alias:["layout.multiselectfield"],type:"multiselectfield",defaultHeight:200,sizeBodyContents:function(k,j){var l=this;if(!Ext.isNumber(j)){j=l.defaultHeight}l.owner.panel.setSize(k,j)}});Ext.define("Ext.ux.form.MultiSelect",{extend:"Ext.form.field.Base",alternateClassName:"Ext.ux.Multiselect",alias:["widget.multiselect","widget.multiselectfield"],uses:["Ext.view.BoundList","Ext.form.FieldSet","Ext.ux.layout.component.form.MultiSelect","Ext.view.DragZone","Ext.view.DropZone"],ddReorder:false,appendOnly:false,displayField:"text",allowBlank:true,minSelections:0,maxSelections:Number.MAX_VALUE,blankText:"This field is required",minSelectionsText:"Minimum {0} item(s) required",maxSelectionsText:"Maximum {0} item(s) allowed",delimiter:",",componentLayout:"multiselectfield",fieldBodyCls:Ext.baseCSSPrefix+"form-multiselect-body",initComponent:function(){var j=this;j.bindStore(j.store,true);if(j.store.autoCreated){j.valueField=j.displayField="field1";if(!j.store.expanded){j.displayField="field2"}}if(!Ext.isDefined(j.valueField)){j.valueField=j.displayField}j.callParent()},bindStore:function(j,l){var m=this,n=m.store,k=m.boundList;if(n&&!l&&n!==j&&n.autoDestroy){n.destroy()}m.store=j?Ext.data.StoreManager.lookup(j):null;if(k){k.bindStore(j||null)}},onRender:function(n,j){var o=this,k,m,l;o.callParent(arguments);m=o.boundList=Ext.create("Ext.view.BoundList",{multiSelect:true,store:o.store,displayField:o.displayField,border:false});l=m.getSelectionModel();o.mon(l,{selectionChange:o.onSelectionChange,scope:o});k=o.panel=Ext.create("Ext.panel.Panel",{title:o.listTitle,tbar:o.tbar,items:[m],renderTo:o.bodyEl,layout:"fit"});k.ownerCt=o;o.setRawValue(o.rawValue)},getSubTplMarkup:function(){return""},afterRender:function(){var j=this;j.callParent();if(j.ddReorder&&!j.dragGroup&&!j.dropGroup){j.dragGroup=j.dropGroup="MultiselectDD-"+Ext.id()}if(j.draggable||j.dragGroup){j.dragZone=Ext.create("Ext.view.DragZone",{view:j.boundList,ddGroup:j.dragGroup,dragText:"{0} Item{1}"})}if(j.droppable||j.dropGroup){j.dropZone=Ext.create("Ext.view.DropZone",{view:j.boundList,ddGroup:j.dropGroup,handleNodeDrop:function(q,p,k){var l=this.view,n=l.getStore(),m=q.records,o;q.view.store.remove(m);o=n.indexOf(p);if(k==="after"){o++}n.insert(o,m);l.getSelectionModel().select(m)}})}},onSelectionChange:function(){this.checkChange()},clearValue:function(){this.setValue([])},getSubmitValue:function(){var k=this,j=k.delimiter,l=k.getValue();return Ext.isString(j)?l.join(j):l},getRawValue:function(){var k=this,j=k.boundList;if(j){k.rawValue=Ext.Array.map(j.getSelectionModel().getSelection(),function(l){return l.get(k.valueField)})}return k.rawValue},setRawValue:function(l){var k=this,j=k.boundList,m;l=Ext.Array.from(l);k.rawValue=l;if(j){m=[];Ext.Array.forEach(l,function(p){var o,n=k.store.findRecord(k.valueField,p,o,o,true,true);if(n){m.push(n)}});j.getSelectionModel().select(m,false,true)}return l},valueToRaw:function(j){return j},isEqual:function(n,m){var k=Ext.Array.from,l,j;n=k(n);m=k(m);j=n.length;if(j!==m.length){return false}for(l=0;l<j;l++){if(m[l]!==n[l]){return false}}return true},getErrors:function(k){var j=this,l=Ext.String.format,n=j.callParent(arguments),m;k=Ext.Array.from(k||j.getValue());m=k.length;if(!j.allowBlank&&m<1){n.push(j.blankText)}if(m<this.minSelections){n.push(l(j.minSelectionsText,j.minSelections))}if(m>this.maxSelections){n.push(l(j.maxSelectionsText,j.maxSelections))}return n},onDisable:function(){this.callParent();this.disabled=true;this.updateReadOnly()},onEnable:function(){this.callParent();this.disabled=false;this.updateReadOnly()},setReadOnly:function(j){this.readOnly=j;this.updateReadOnly()},updateReadOnly:function(){var k=this,j=k.boundList,l=k.readOnly||k.disabled;if(j){j.getSelectionModel().setLocked(l)}},onDestroy:function(){Ext.destroyMembers(this,"panel","boundList","dragZone","dropZone");this.callParent()}});OpenLayers.Util.OSM={};OpenLayers.Util.OSM.MISSING_TILE_URL="http://www.openstreetmap.org/openlayers/img/404.png";OpenLayers.Util.OSM.originalOnImageLoadError=OpenLayers.Util.onImageLoadError;OpenLayers.Util.onImageLoadError=function(){if(this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)){this.src=OpenLayers.Util.OSM.MISSING_TILE_URL}else{if(this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)){}else{OpenLayers.Util.OSM.originalOnImageLoadError}}};OpenLayers.Layer.OSM.Mapnik=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(l,m){var j=["http://a.tile.openstreetmap.org/${z}/${x}/${y}.png","http://b.tile.openstreetmap.org/${z}/${x}/${y}.png","http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"];m=OpenLayers.Util.extend({numZoomLevels:19,buffer:0,transitionEffect:"resize"},m);var k=[l,j,m];OpenLayers.Layer.OSM.prototype.initialize.apply(this,k)},CLASS_NAME:"OpenLayers.Layer.OSM.Mapnik"});OpenLayers.Layer.OSM.Osmarender=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(l,m){var j=["http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png","http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png","http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"];m=OpenLayers.Util.extend({numZoomLevels:18,buffer:0,transitionEffect:"resize"},m);var k=[l,j,m];OpenLayers.Layer.OSM.prototype.initialize.apply(this,k)},CLASS_NAME:"OpenLayers.Layer.OSM.Osmarender"});OpenLayers.Layer.OSM.CycleMap=OpenLayers.Class(OpenLayers.Layer.OSM,{initialize:function(l,m){var j=["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png","http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png","http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"];m=OpenLayers.Util.extend({numZoomLevels:19,buffer:0,transitionEffect:"resize"},m);var k=[l,j,m];OpenLayers.Layer.OSM.prototype.initialize.apply(this,k)},CLASS_NAME:"OpenLayers.Layer.OSM.CycleMap"});OpenLayers.Control.Circle=OpenLayers.Class(OpenLayers.Control,{feature:null,layer:null,radius:5,origin:null,sides:40,angle:null,snapAngle:null,dragControl:null,initialize:function(j){OpenLayers.Control.prototype.initialize.apply(this,arguments)},activate:function(){var k=OpenLayers.Control.prototype.activate.call(this);if(k){var j={displayInLayerSwitcher:false,calculateInRange:function(){return true}};this.map.addLayer(this.layer)}return k},deactivate:function(){var j=OpenLayers.Control.prototype.deactivate.call(this);if(j){if(this.layer.map!=null){this.layer.destroy(false);if(this.feature){this.feature.destroy()}}this.layer=null;this.feature=null}return j},createGeometry:function(){this.angle=Math.PI*((1/this.sides)-(1/2));if(this.snapAngle){this.angle+=this.snapAngle*(Math.PI/180)}this.feature.geometry=OpenLayers.Geometry.Polygon.createRegularPolygon(this.origin,this.radius,this.sides,this.snapAngle)},modifyGeometry:function(){var l,o,j,k;var n=this.feature.geometry.components[0];if(n.components.length!=(this.sides+1)){this.createGeometry();n=this.feature.geometry.components[0]}for(var m=0;m<this.sides;++m){k=n.components[m];l=this.angle+(m*2*Math.PI/this.sides);k.x=this.origin.x+(this.radius*Math.cos(l));k.y=this.origin.y+(this.radius*Math.sin(l));k.clearBounds()}},updateCircle:function(j,k){this.origin=new OpenLayers.Geometry.Point(j.lon,j.lat);this.radius=k*1;if(!this.feature){this.feature=new OpenLayers.Feature.Vector();this.createGeometry();this.layer.addFeatures([this.feature],{silent:true})}else{this.modifyGeometry()}this.layer.drawFeature(this.feature,this.style)},CLASS_NAME:"Meteorage.Circle"});OpenLayers.Control.newSelectFeature=OpenLayers.Class(OpenLayers.Control,{multipleKey:null,toggleKey:null,multiple:false,clickout:true,toggle:false,hover:false,onSelect:function(){},onUnselect:function(){},onHoverSelect:function(){},onHoverUnselect:function(){},onClickSelect:function(){},onClickUnselect:function(){},geometryTypes:null,layer:null,callbacks:null,selectStyle:null,renderIntent:"select",handler:null,initialize:function(l,k){OpenLayers.Control.prototype.initialize.apply(this,[k]);this.layer=l;this.callbacks=OpenLayers.Util.extend({click:this.clickFeature,clickout:this.clickoutFeature,over:this.overFeature,out:this.outFeature},this.callbacks);var j={geometryTypes:this.geometryTypes};this.handler=new OpenLayers.Handler.Feature(this,l,this.callbacks,j)},unselectAll:function(j){var l;for(var k=this.layer.selectedFeatures.length-1;k>=0;--k){l=this.layer.selectedFeatures[k];if(!j||j.except!=l){this.unselect(l,"click")}}},clickFeature:function(j){if((this.onSelect.name!=""||this.onClickSelect.name!="")&&!this.hover){var k=(OpenLayers.Util.indexOf(this.layer.selectedFeatures,j)>-1);if(k){if(this.toggleSelect()){this.unselect(j)}else{if(!this.multipleSelect()){this.unselectAll({except:j})}}}else{if(!this.multipleSelect()){this.unselectAll({except:j})}}this.select(j,"click")}},multipleSelect:function(){return this.multiple||this.handler.evt[this.multipleKey]},toggleSelect:function(){return this.toggle||this.handler.evt[this.toggleKey]},clickoutFeature:function(j){if(((this.onClickUnselect.name!=""||this.onHoverSelect.name=="")&&!this.hover)&&this.clickout){this.unselectAll()}},overFeature:function(j){if((this.onHoverSelect.name!=""||this.hover)&&(OpenLayers.Util.indexOf(this.layer.selectedFeatures,j)==-1)){this.select(j,"hover")}},outFeature:function(j){if(this.onHoverUnselect.name!=""||this.hover){this.unselect(j,"hover")}},select:function(l,j){this.layer.selectedFeatures.push(l);var k=this.selectStyle||this.renderIntent;this.layer.drawFeature(l,k);this.layer.events.triggerEvent("featureselected",{feature:l});switch(j){case"hover":this.onHoverSelect(l);break;case"click":if(this.onClickSelect.name!=""){this.onClickSelect(l)}else{if(this.onSelect.name!=""){this.onSelect(l)}}break;default:this.onSelect(l);break}},unselect:function(k,j){this.layer.drawFeature(k,"default");OpenLayers.Util.removeItem(this.layer.selectedFeatures,k);this.layer.events.triggerEvent("featureunselected",{feature:k});switch(j){case"hover":this.onHoverUnselect(k);break;case"click":if(this.onClickUnselect.name!=""){this.onClickUnselect(k)}else{if(this.onUnselect.name!=""){this.onUnselect(k)}}break;default:this.onUnselect(k);break}},setMap:function(j){this.handler.setMap(j);OpenLayers.Control.prototype.setMap.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.newSelectFeature"});Ext.define("GeoExt.data.LayerModel",{alternateClassName:"GeoExt.data.LayerRecord",extend:"Ext.data.Model",requires:["Ext.data.proxy.Memory","Ext.data.reader.Json"],alias:"model.gx_layer",statics:{createFromLayer:function(j){return this.proxy.reader.readRecords([j]).records[0]}},fields:["id",{name:"title",type:"string",mapping:"name"},{name:"legendURL",type:"string",mapping:"metadata.legendURL"},{name:"hideTitle",type:"bool",mapping:"metadata.hideTitle"},{name:"hideInLegend",type:"bool",mapping:"metadata.hideInLegend"}],proxy:{type:"memory",reader:{type:"json"}},getLayer:function(){return this.raw}});Ext.define("GeoExt.data.LayerStore",{requires:["GeoExt.data.LayerModel"],extend:"Ext.data.Store",model:"GeoExt.data.LayerModel",statics:{MAP_TO_STORE:1,STORE_TO_MAP:2},map:null,constructor:function(j){var m=this;j=Ext.apply({},j);var l=(GeoExt.MapPanel&&j.map instanceof GeoExt.MapPanel)?j.map.map:j.map;delete j.map;if(j.layers){j.data=j.layers}delete j.layers;var k={initDir:j.initDir};delete j.initDir;m.callParent([j]);if(l){this.bind(l,k)}},bind:function(l,k){var j=this;if(j.map){return}j.map=l;k=Ext.apply({},k);var n=k.initDir;if(k.initDir==undefined){n=GeoExt.data.LayerStore.MAP_TO_STORE|GeoExt.data.LayerStore.STORE_TO_MAP}var m=l.layers.slice(0);if(n&GeoExt.data.LayerStore.STORE_TO_MAP){j.each(function(o){j.map.addLayer(o.getLayer())},j)}if(n&GeoExt.data.LayerStore.MAP_TO_STORE){j.loadRawData(m,true)}l.events.on({changelayer:j.onChangeLayer,addlayer:j.onAddLayer,removelayer:j.onRemoveLayer,scope:j});j.on({load:j.onLoad,clear:j.onClear,add:j.onAdd,remove:j.onRemove,update:j.onUpdate,scope:j});j.data.on({replace:j.onReplace,scope:j});j.fireEvent("bind",j,l)},unbind:function(){var j=this;if(j.map){j.map.events.un({changelayer:j.onChangeLayer,addlayer:j.onAddLayer,removelayer:j.onRemoveLayer,scope:j});j.un("load",j.onLoad,j);j.un("clear",j.onClear,j);j.un("add",j.onAdd,j);j.un("remove",j.onRemove,j);j.data.un("replace",j.onReplace,j);j.map=null}},onChangeLayer:function(j){var l=j.layer;var n=this.findBy(function(p,o){return p.getLayer()===l});if(n>-1){var k=this.getAt(n);if(j.property==="order"){if(!this._adding&&!this._removing){var m=this.map.getLayerIndex(l);if(m!==n){this._removing=true;this.remove(k);delete this._removing;this._adding=true;this.insert(m,[k]);delete this._adding}}}else{if(j.property==="name"){k.set("title",l.name)}else{this.fireEvent("update",this,k,Ext.data.Record.EDIT)}}}},onAddLayer:function(j){var l=this;if(!l._adding){l._adding=true;var k=l.proxy.reader.read(j.layer);l.add(k.records);delete l._adding}},onRemoveLayer:function(k){if(this.map.unloadDestroy){if(!this._removing){var j=k.layer;this._removing=true;this.remove(this.getByLayer(j));delete this._removing}}else{this.unbind()}},onLoad:function(p,j,l){if(l){if(!Ext.isArray(j)){j=[j]}if(!this._addRecords){this._removing=true;for(var n=this.map.layers.length-1;n>=0;n--){this.map.removeLayer(this.map.layers[n])}delete this._removing}var k=j.length;if(k>0){var m=new Array(k);for(var o=0;o<k;o++){m[o]=j[o].getLayer()}this._adding=true;this.map.addLayers(m);delete this._adding}}delete this._addRecords},onClear:function(k){this._removing=true;for(var j=this.map.layers.length-1;j>=0;j--){this.map.removeLayer(this.map.layers[j])}delete this._removing},onAdd:function(j,k,n){if(!this._adding){this._adding=true;var l;for(var m=k.length-1;m>=0;--m){l=k[m].getLayer();this.map.addLayer(l);if(n!==this.map.layers.length-1){this.map.setLayerIndex(l,n)}}delete this._adding}},onRemove:function(j,k,m){if(!this._removing){var l=k.getLayer();if(this.map.getLayer(l.id)!=null){this._removing=true;this.removeMapLayer(k);delete this._removing}}},onUpdate:function(n,k,j){if(j===Ext.data.Record.EDIT){if(k.modified&&k.modified.title){var m=k.getLayer();var l=k.get("title");if(l!==m.name){m.setName(l)}}}},removeMapLayer:function(j){this.map.removeLayer(j.getLayer())},onReplace:function(l,k,j){this.removeMapLayer(k)},getByLayer:function(j){var k=this.findBy(function(l){return l.getLayer()===j});if(k>-1){return this.getAt(k)}},destroy:function(){var j=this;j.unbind();j.callParent()},loadRecords:function(k,j){if(j&&j.addRecords){this._addRecords=true}this.callParent(arguments)}});Ext.define("GeoExt.panel.Map",{extend:"Ext.panel.Panel",requires:["GeoExt.data.LayerStore"],alias:"widget.gx_mappanel",alternateClassName:"GeoExt.MapPanel",statics:{guess:function(){var j=Ext.ComponentQuery.query("gx_mappanel");return((j&&j.length>0)?j[0]:null)}},center:null,zoom:null,extent:null,prettyStateKeys:false,map:null,layers:null,stateEvents:["aftermapmove","afterlayervisibilitychange","afterlayeropacitychange","afterlayerorderchange","afterlayernamechange","afterlayeradd","afterlayerremove"],initComponent:function(){if(!(this.map instanceof OpenLayers.Map)){this.map=new OpenLayers.Map(Ext.applyIf(this.map||{},{allOverlays:true}))}var j=this.layers;if(!j||j instanceof Array){this.layers=Ext.create("GeoExt.data.LayerStore",{layers:j,map:this.map.layers.length>0?this.map:null})}if(Ext.isString(this.center)){this.center=OpenLayers.LonLat.fromString(this.center)}else{if(Ext.isArray(this.center)){this.center=new OpenLayers.LonLat(this.center[0],this.center[1])}}if(Ext.isString(this.extent)){this.extent=OpenLayers.Bounds.fromString(this.extent)}else{if(Ext.isArray(this.extent)){this.extent=OpenLayers.Bounds.fromArray(this.extent)}}this.callParent(arguments);this.on("resize",this.onResize,this);this.on("afterlayout",function(){if(typeof this.map.getViewport==="function"){this.items.each(function(k){if(typeof k.addToMapPanel==="function"){k.getEl().appendTo(this.map.getViewport())}},this)}},this);this.map.events.on({moveend:this.onMoveend,changelayer:this.onChangelayer,addlayer:this.onAddlayer,removelayer:this.onRemovelayer,scope:this})},onMoveend:function(j){this.fireEvent("aftermapmove",this,this.map,j)},onChangelayer:function(j){var k=this.map;if(j.property){if(j.property==="visibility"){this.fireEvent("afterlayervisibilitychange",this,k,j)}else{if(j.property==="order"){this.fireEvent("afterlayerorderchange",this,k,j)}else{if(j.property==="nathis"){this.fireEvent("afterlayernathischange",this,k,j)}else{if(j.property==="opacity"){this.fireEvent("afterlayeropacitychange",this,k,j)}}}}}},onAddlayer:function(){this.fireEvent("afterlayeradd")},onRemovelayer:function(){this.fireEvent("afterlayerremove")},onResize:function(){var j=this.map;if(this.body.dom!==j.div){j.render(this.body.dom);this.layers.bind(j);if(j.layers.length>0){this.setInitialExtent()}else{this.layers.on("add",this.setInitialExtent,this,{single:true})}}else{j.updateSize()}},setInitialExtent:function(){var j=this.map;if(!j.getCenter()){if(this.center||this.zoom){j.setCenter(this.center,this.zoom)}else{if(this.extent instanceof OpenLayers.Bounds){j.zoomToExtent(this.extent,true)}else{j.zoomToMaxExtent()}}}},getState:function(){var n=this,l=n.map,m=n.callParent(arguments)||{},j;if(!l){return}var k=l.getCenter();k&&Ext.applyIf(m,{x:k.lon,y:k.lat,zoom:l.getZoom()});n.layers.each(function(o){j=o.getLayer();layerId=this.prettyStateKeys?o.get("title"):o.get("id");m=n.addPropertyToState(m,"visibility_"+layerId,j.getVisibility());m=n.addPropertyToState(m,"opacity_"+layerId,(j.opacity===null)?1:j.opacity)},n);return m},applyState:function(s){var k=this;map=k.map;k.center=new OpenLayers.LonLat(s.x,s.y);k.zoom=s.zoom;var n,q,m,p,r,l;var o=map.layers;for(n=0,q=o.length;n<q;n++){m=o[n];p=k.prettyStateKeys?m.name:m.id;r=s["visibility_"+p];if(r!==undefined){r=(/^true$/i).test(r);if(m.isBaseLayer){if(r){map.setBaseLayer(m)}}else{m.setVisibility(r)}}l=s["opacity_"+p];if(l!==undefined){m.setOpacity(l)}}},onBeforeAdd:function(j){if(Ext.isFunction(j.addToMapPanel)){j.addToMapPanel(this)}this.callParent(arguments)},beforeDestroy:function(){if(this.map&&this.map.events){this.map.events.un({moveend:this.onMoveend,changelayer:this.onChangelayer,scope:this})}if(!this.initialConfig.map||!(this.initialConfig.map instanceof OpenLayers.Map)){if(this.map&&this.map.destroy){this.map.destroy()}}delete this.map;this.callParent(arguments)}});Ext.define("GeoExt.tree.Column",{extend:"Ext.tree.Column",alias:"widget.gx_treecolumn",initComponent:function(){var j=this;j.callParent();var k=j.renderer;this.renderer=function(m,q,r,n,l,p,s){var o=[k(m,q,r,n,l,p,s)];if(r.get("checkedGroup")){o[0]=o[0].replace(/class="([^-]+)-tree-checkbox([^"]+)?"/,'class="$1-tree-checkbox$2 gx-tree-radio"')}o.push('<div class="gx-tree-component gx-tree-component-off" id="tree-record-'+r.id+'"></div>');if(r.uiProvider&&r.uiProvider instanceof "string"){}return o.join("")}},defaultRenderer:function(j){return j}});Ext.define("GeoExt.tree.View",{extend:"Ext.tree.View",alias:"widget.gx_treeview",initComponent:function(){var j=this;j.on("itemupdate",this.onItem,this);j.on("itemadd",this.onItem,this);j.on("createchild",this.createChild,this);return j.callParent(arguments)},onItem:function(k,o,l,j){var m=this;if(!(k instanceof Array)){k=[k]}for(var n=0;n<k.length;n++){this.onNodeRendered(k[n])}},onNodeRendered:function(l){var j=this;var k=Ext.get("tree-record-"+l.id);if(!k){return}if(l.get("layer")){j.fireEvent("createchild",k,l)}if(l.hasChildNodes()){l.eachChild(function(m){j.onNodeRendered(m)},j)}},createChild:function(j,l){var k=l.get("component");if(k){cmpObj=Ext.ComponentManager.create(k);cmpObj.render(j);j.removeCls("gx-tree-component-off")}}});Ext.define("GeoExt.tree.LayerNode",{extend:"Ext.AbstractPlugin",alias:"plugin.gx_layer",init:function(j){this.target=j;var k=j.get("layer");j.set("checked",k.getVisibility());if(!j.get("checkedGroup")&&k.isBaseLayer){j.set("checkedGroup","gx_baselayer")}j.set("fixedText",!!j.text);j.set("leaf",true);if(!j.get("iconCls")){j.set("iconCls","gx-tree-layer-icon")}j.on("afteredit",this.onAfterEdit,this);k.events.on({visibilitychanged:this.onLayerVisibilityChanged,scope:this})},onAfterEdit:function(l,k){var j=this;if(~Ext.Array.indexOf(k,"checked")){j.onCheckChange()}},onLayerVisibilityChanged:function(){if(!this._visibilityChanging){this.target.set("checked",this.target.get("layer").getVisibility())}},onCheckChange:function(){var l=this.target,j=this.target.get("checked");if(j!=l.get("layer").getVisibility()){l._visibilityChanging=true;var k=l.get("layer");if(j&&k.isBaseLayer&&k.map){k.map.setBaseLayer(k)}else{k.setVisibility(j)}delete l._visibilityChanging}}});Ext.define("GeoExt.tree.LayerLoader",{extend:"Ext.util.Observable",requires:["GeoExt.tree.LayerNode"],store:null,filter:function(j){return j.getLayer().displayInLayerSwitcher===true},baseAttrs:null,load:function(j){if(this.fireEvent("beforeload",this,j)){this.removeStoreHandlers();while(j.firstChild){j.removeChild(j.firstChild)}if(!this.store){this.store=GeoExt.MapPanel.guess().layers}this.store.each(function(k){this.addLayerNode(j,k)},this);this.addStoreHandlers(j);this.fireEvent("load",this,j)}},onStoreAdd:function(j,k,p,m){if(!this._reordering){var l=m.get("container").recordIndexToNodeIndex(p+k.length-1,m);for(var o=0,n=k.length;o<n;++o){this.addLayerNode(m,k[o],l)}}},onStoreRemove:function(k,j){if(!this._reordering){this.removeLayerNode(j,k)}},addLayerNode:function(m,k,j){j=j||0;if(this.filter(k)===true){var n=k.getLayer();var l=this.createNode({plugins:[{ptype:"gx_layer"}],layer:n,text:n.name,listeners:{move:this.onChildMove,scope:this}});if(j!==undefined){m.insertChild(j,l)}else{m.appendChild(l)}m.getChildAt(j).on("move",this.onChildMove,this)}},removeLayerNode:function(j,k){if(this.filter(k)===true){var l=j.findChildBy(function(m){return m.get("layer")==k.getLayer()});if(l){l.un("move",this.onChildMove,this);l.remove()}}},onChildMove:function(v,n,m,q){var p=this,r=p.store.getByLayer(v.get("layer")),w=m.get("container"),s=w.loader;p._reordering=true;if(s instanceof p.self&&p.store===s.store){s._reordering=true;p.store.remove(r);var x;if(m.childNodes.length>1){var o=(q===0)?q+1:q-1;x=p.store.findBy(function(j){return m.childNodes[o].get("layer")===j.getLayer()});if(q===0){x++}}else{if(n.parentNode===m.parentNode){var u=m;do{u=u.previousSibling}while(u&&!(u.get("container") instanceof w.self&&u.lastChild));if(u){x=p.store.findBy(function(j){return u.lastChild.get("layer")===j.getLayer()})}else{var t=m;do{t=t.nextSibling}while(t&&!(t.get("container") instanceof w.self&&t.firstChild));if(t){x=p.store.findBy(function(j){return t.firstChild.get("layer")===j.getLayer()})}x++}}}if(x!==undefined){p.store.insert(x,[r])}else{p.store.insert(oldRecordIndex,[r])}delete s._reordering}delete p._reordering},addStoreHandlers:function(j){if(!this._storeHandlers){this._storeHandlers={add:function(n,l,m){this.onStoreAdd(n,l,m,j)},remove:function(m,l){this.onStoreRemove(l,j)}};for(var k in this._storeHandlers){this.store.on(k,this._storeHandlers[k],this)}}},removeStoreHandlers:function(){if(this._storeHandlers){for(var j in this._storeHandlers){this.store.un(j,this._storeHandlers[j],this)}delete this._storeHandlers}},createNode:function(j){if(this.baseAttrs){Ext.apply(j,this.baseAttrs)}return j},destroy:function(){this.removeStoreHandlers()}});Ext.define("GeoExt.tree.LayerContainer",{extend:"Ext.AbstractPlugin",requires:["GeoExt.tree.LayerLoader"],alias:"plugin.gx_layercontainer",defaultText:"Layers",init:function(l){var j=this;var k=j.loader;j.loader=(k&&k instanceof GeoExt.tree.LayerLoader)?k:new GeoExt.tree.LayerLoader(k);l.set("container",j);if(!l.get("text")){l.set("text",j.defaultText);l.commit()}j.loader.load(l)},recordIndexToNodeIndex:function(q,m){var n=this;var j=n.loader.store;var o=j.getCount();var k=m.childNodes.length;var l=-1;for(var p=o-1;p>=0;--p){if(n.loader.filter(j.getAt(p))===true){++l;if(q===p||l>k-1){break}}}return l}});Ext.define("GeoExt.tree.BaseLayerContainer",{extend:"GeoExt.tree.LayerContainer",alias:"plugin.gx_baselayercontainer",defaultText:"Base Layers",init:function(l){var j=this;var k=j.loader;j.loader=Ext.applyIf(k||{},{baseAttrs:Ext.applyIf((k&&k.baseAttrs)||{},{iconCls:"gx-tree-baselayer-icon",checkedGroup:"baselayer"}),filter:function(n){var m=n.getLayer();return m.displayInLayerSwitcher===true&&m.isBaseLayer===true}});j.callParent(arguments)}});Ext.define("GeoExt.tree.Panel",{extend:"Ext.tree.Panel",alias:"widget.gx_treepanel",requires:["GeoExt.tree.Column","GeoExt.tree.View"],viewType:"gx_treeview",initComponent:function(){var j=this;if(!j.columns){if(j.initialConfig.hideHeaders===undefined){j.hideHeaders=true}j.addCls(Ext.baseCSSPrefix+"autowidth-table");j.columns=[{xtype:"gx_treecolumn",text:"Name",width:Ext.isIE6?null:10000,dataIndex:j.displayField}]}j.callParent()}});Ext.Ajax.method="GET";Ext.isIE=(/trident/.test(Ext.userAgent));Ext.isIE11=Ext.isIE&&(/rv:11.0/.test(Ext.userAgent));GIS={core:{instances:[]},i18n:{},isDebug:false,isSessionStorage:"sessionStorage" in window&&window.sessionStorage!==null,logg:[]};GIS.core.getOLMap=function(m,j){var p,l,k=j.dashboard?"google-logo-small":"google-logo",o,n=true;l=function(r,t){var s,q;s=new OpenLayers.Control.Button({displayClass:"olControlButton",trigger:function(){t.call(m.olmap)}});q=new OpenLayers.Control.Panel({defaultControl:s});q.addControls([s]);p.addControl(q);q.div.className+=" "+r;q.div.childNodes[0].className+=" "+r+"Button";return q};p=new OpenLayers.Map({controls:[new OpenLayers.Control.Navigation({zoomWheelEnabled:j.dashboard?false:true,documentDrag:true}),new OpenLayers.Control.MousePosition({prefix:'<span id="mouseposition" class="el-fontsize-10"><span class="text-mouseposition-lonlat">LON </span>',separator:'<span class="text-mouseposition-lonlat">,&nbsp;LAT </span>',suffix:'<div class="'+k+'" name="http://www.google.com/intl/en-US_US/help/terms_maps.html" onclick="window.open(Ext.get(this).dom.attributes.name.nodeValue);"></div></span>'}),new OpenLayers.Control.Permalink(),new OpenLayers.Control.ScaleLine({geodesic:true,maxWidth:170,minWidth:100})],displayProjection:new OpenLayers.Projection("EPSG:4326"),mouseMove:{},relocate:{}});p.events.register("mousemove",null,function(t){m.olmap.mouseMove.x=t.clientX;m.olmap.mouseMove.y=t.clientY;if(n&&j.dashboard){n=false;var r=Ext.get(o.div),q=r.first().first(),s;q.on("mousemove",function(){if(s&&!s.isVisible()){s.show()}else{if(!s){var x=m.util.map.getRenderedVectorLayers().reverse(),w='<div id="legendWrapper">';for(var v=0,u,y;v<x.length;v++){u=x[v];y=u.core.updateLegend().innerHTML;if(y){w+='<div style="font-size:10px; font-weight:bold">'+u.name+"</div>"+y+(v<x.length-1?'<div style="padding:5px"></div>':"")}}w+="</div>";s=Ext.create("Ext.window.Window",{title:"Legend",cls:"gis-plugin",bodyStyle:"background-color: #fff; padding: 3px",width:100,height:100,html:w,preventHeader:true,shadow:false,listeners:{show:function(){var A=this.getEl(),z=A.first().first(),B=Ext.get(p.buttonControls[0].div).getAnchorXY();A.setStyle("opacity",0.92);this.setHeight(z.getHeight()+8+9);this.setPosition(B[0]-this.getWidth(),B[1]-1)}}})}}});q.on("mouseleave",function(){if(s&&s.hide){s.hide()}})}});p.zoomToVisibleExtent=function(){m.util.map.zoomToVisibleExtent(this)};p.closeAllLayers=function(){m.layer.event.core.reset();m.layer.facility.core.reset();m.layer.boundary.core.reset();m.layer.thematic1.core.reset();m.layer.thematic2.core.reset();m.layer.thematic3.core.reset();m.layer.thematic4.core.reset()};p.buttonControls=[];p.buttonControls.push(l("zoomIn"+(j.dashboard?"-vertical":""),p.zoomIn));p.buttonControls.push(l("zoomOut"+(j.dashboard?"-vertical":""),p.zoomOut));p.buttonControls.push(l("zoomVisible"+(j.dashboard?"-vertical":""),p.zoomToVisibleExtent));o=l("legend"+(j.dashboard?"-vertical":""),function(){});p.buttonControls.push(o);p.addButtonControl=l;return p};GIS.core.getLayers=function(j){var o={},k,m=["1","2","3","4"];o.openStreetMap=new OpenLayers.Layer.OSM.Mapnik("OpenStreetMap",{layerType:j.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(p){if(p){this.layerOpacity=parseFloat(p)}this.setOpacity(this.layerOpacity)}});o.openStreetMap.id="openStreetMap";o.event=GIS.core.VectorLayer(j,"event",GIS.i18n.event_layer,{opacity:j.conf.layout.layer.opacity});o.event.core=new mapfish.GeoStat.Event(j.olmap,{layer:o.event,gis:j});o.facility=GIS.core.VectorLayer(j,"facility",GIS.i18n.facility_layer,{opacity:1});o.facility.core=new mapfish.GeoStat.Facility(j.olmap,{layer:o.facility,gis:j});o.boundary=GIS.core.VectorLayer(j,"boundary",GIS.i18n.boundary_layer,{opacity:1});o.boundary.core=new mapfish.GeoStat.Boundary(j.olmap,{layer:o.boundary,gis:j});for(var l=0,n;l<m.length;l++){n=m[l];o["thematic"+n]=GIS.core.VectorLayer(j,"thematic"+n,GIS.i18n.thematic_layer+" "+n,{opacity:j.conf.layout.layer.opacity});o["thematic"+n].layerCategory=j.conf.finals.layer.category_thematic,o["thematic"+n].core=new mapfish.GeoStat["Thematic"+n](j.olmap,{layer:o["thematic"+n],gis:j})}return o};GIS.core.createSelectHandlers=function(t,m){var w=!!GIS.app?!!t.init.user.isAdmin:false,x={},p,j,l,k,n,s=t.conf.finals.dimension,u,r,o=m.id==="boundary",v=m.id==="event";j=function q(B){if(o){var C=m.core.getDefaultFeatureStyle();C.fillOpacity=0.15;C.strokeColor=B.style.strokeColor;C.strokeWidth=B.style.strokeWidth;C.label=B.style.label;C.fontFamily=B.style.fontFamily;C.fontWeight=B.style.strokeWidth>1?"bold":"normal";C.labelAlign=B.style.labelAlign;C.labelYOffset=B.style.labelYOffset;m.drawFeature(B,C)}if(u){u.destroy()}u=Ext.create("Ext.window.Window",{cls:"gis-window-widget-feature gis-plugin",preventHeader:true,shadow:false,resizable:false,items:{html:B.attributes.popupText}});u.show();t.viewport.centerRegion.trash.push(u);var E=t.viewport.centerRegion,F=E.getPosition()[0],D=F+(E.getWidth()/2),A=E.getPosition()[1]+(t.plugin?0:32),z=D-(u.getWidth()/2),G=A;u.setPosition(z,G)};l=function q(y){u.destroy()};k=function q(H){var G,F,z,A,C,E=H.geometry.CLASS_NAME===t.conf.finals.openLayers.point_classname,D=H.attributes,B=Ext.get(document.body);F=function(){if(t.olmap.relocate.window){t.olmap.relocate.window.destroy()}t.olmap.relocate.window=Ext.create("Ext.window.Window",{title:"Relocate facility",layout:"fit",iconCls:"gis-window-title-icon-relocate",cls:"gis-container-default",setMinWidth:function(I){this.setWidth(this.getWidth()<I?I:this.getWidth())},items:{html:D.name,cls:"gis-container-inner"},bbar:["->",{xtype:"button",hideLabel:true,text:GIS.i18n.cancel,handler:function(){t.olmap.relocate.active=false;t.olmap.relocate.window.destroy();t.olmap.getViewport().style.cursor="auto"}}],listeners:{close:function(){t.olmap.relocate.active=false;t.olmap.getViewport().style.cursor="auto"}}});t.olmap.relocate.window.show();t.olmap.relocate.window.setMinWidth(220);t.util.gui.window.setPositionTopRight(t.olmap.relocate.window)};G=function(){t.ajax({url:t.init.contextPath+"/api/organisationUnits/"+D.id+".json?links=false",disableCaching:false,success:function(J){var I=Ext.decode(J.responseText);if(m.infrastructuralWindow){m.infrastructuralWindow.destroy()}m.infrastructuralWindow=Ext.create("Ext.window.Window",{title:GIS.i18n.information,layout:"column",iconCls:"gis-window-title-icon-information",cls:"gis-container-default",width:460,height:400,period:null,items:[{cls:"gis-container-inner",columnWidth:0.4,bodyStyle:"padding-right:4px",items:function(){var K=[];if(D.name){K.push({html:GIS.i18n.name,cls:"gis-panel-html-title"},{html:D.name,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(I.parent){K.push({html:GIS.i18n.parent_unit,cls:"gis-panel-html-title"},{html:I.parent.name,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(I.code){K.push({html:GIS.i18n.code,cls:"gis-panel-html-title"},{html:I.code,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(I.address){K.push({html:GIS.i18n.address,cls:"gis-panel-html-title"},{html:I.address,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(I.email){K.push({html:GIS.i18n.email,cls:"gis-panel-html-title"},{html:I.email,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(I.phoneNumber){K.push({html:GIS.i18n.phone_number,cls:"gis-panel-html-title"},{html:I.phoneNumber,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(Ext.isString(I.coordinates)){var N=I.coordinates.replace("[","").replace("]","").replace(",",", ");K.push({html:GIS.i18n.coordinate,cls:"gis-panel-html-title"},{html:N,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}if(Ext.isArray(I.organisationUnitGroups)&&I.organisationUnitGroups.length){var M="";for(var L=0;L<I.organisationUnitGroups.length;L++){M+=I.organisationUnitGroups[L].name;M+=L<I.organisationUnitGroups.length-1?"<br/>":""}K.push({html:GIS.i18n.groups,cls:"gis-panel-html-title"},{html:M,cls:"gis-panel-html"},{cls:"gis-panel-html-separator"})}return K}()},{xtype:"form",cls:"gis-container-inner gis-form-widget",columnWidth:0.6,bodyStyle:"padding-left:4px",items:[{html:GIS.i18n.infrastructural_data,cls:"gis-panel-html-title"},{cls:"gis-panel-html-separator"},{xtype:"combo",fieldLabel:GIS.i18n.period,editable:false,valueField:"id",displayField:"name",emptyText:"Select period",forceSelection:true,width:258,labelWidth:70,store:{fields:["id","name"],data:function(){var K=t.init.systemSettings.infrastructuralPeriodType.id,N=t.init.periodGenerator,M=N.filterFuturePeriodsExceptCurrent(N.generateReversedPeriods(K,this.periodOffset))||[];if(Ext.isArray(M)&&M.length){for(var L=0;L<M.length;L++){M[L].id=M[L].iso}M=M.slice(0,5)}return M}()},lockPosition:false,listeners:{select:function(M){var O=M.getValue(),K=t.init.contextPath+"/api/analytics.json?",N=t.init.systemSettings.infrastructuralDataElementGroup;if(N&&N.dataElements){K+="dimension=dx:";for(var L=0;L<N.dataElements.length;L++){K+=N.dataElements[L].id;K+=L<N.dataElements.length-1?";":""}}K+="&filter=pe:"+O;K+="&filter=ou:"+D.id;t.ajax({url:K,disableCaching:false,success:function(R){var P=Ext.decode(R.responseText),S=[];if(Ext.isArray(P.rows)){for(var Q=0;Q<P.rows.length;Q++){S.push({name:P.metaData.names[P.rows[Q][0]],value:P.rows[Q][1]})}}m.widget.infrastructuralDataElementValuesStore.loadData(S)}})}}},{xtype:"grid",cls:"gis-grid",height:300,width:258,scroll:"vertical",columns:[{id:"name",text:"Data element",dataIndex:"name",sortable:true,width:195},{id:"value",header:"Value",dataIndex:"value",sortable:true,width:63}],disableSelection:true,store:m.widget.infrastructuralDataElementValuesStore}]}],listeners:{show:function(){if(p){this.down("combo").setValue(p);infrastructuralDataElementValuesStore.load({params:{periodId:p,organisationUnitId:D.internalId}})}}}});m.infrastructuralWindow.show();t.util.gui.window.setPositionTopRight(m.infrastructuralWindow)}})};z=function(M,K,L){var J=Ext.clone(m.core.view),I;J.parentGraphMap={};J.parentGraphMap[M]=K;J.rows=[{dimension:s.organisationUnit.objectName,items:[{id:M},{id:"LEVEL-"+L}]}];if(J){I=m.core.getLoader();I.updateGui=true;I.zoomToVisibleExtent=true;I.hideMask=true;I.load(J)}};var y=[];if(m.id!=="facility"){y.push(Ext.create("Ext.menu.Item",{text:"Float up",iconCls:"gis-menu-item-icon-float",cls:"gis-plugin",disabled:!D.hasCoordinatesUp,handler:function(){z(D.grandParentId,D.grandParentParentGraph,parseInt(D.level)-1)}}));y.push(Ext.create("Ext.menu.Item",{text:"Drill down",iconCls:"gis-menu-item-icon-drill",cls:"gis-menu-item-first gis-plugin",disabled:!D.hasCoordinatesDown,handler:function(){z(D.id,D.parentGraph,parseInt(D.level)+1)}}))}if(w&&E){if(m.id!=="facility"){y.push({xtype:"menuseparator"})}y.push(Ext.create("Ext.menu.Item",{text:GIS.i18n.relocate,iconCls:"gis-menu-item-icon-relocate",disabled:!t.init.user.isAdmin,handler:function(I){t.olmap.relocate.active=true;t.olmap.relocate.feature=H;t.olmap.getViewport().style.cursor="crosshair";F()}}));y.push(Ext.create("Ext.menu.Item",{text:"Swap lon/lat",iconCls:"gis-menu-item-icon-relocate",disabled:!t.init.user.isAdmin,handler:function(I){var K=H.attributes.id,J=Ext.clone(H.geometry).transform("EPSG:900913","EPSG:4326");if(Ext.isNumber(J.x)&&Ext.isNumber(J.y)&&t.init.user.isAdmin){t.ajax({url:t.init.contextPath+"/api/organisationUnits/"+K+".json?links=false",disableCaching:false,success:function(L){var M=Ext.decode(L.responseText);M.coordinates="["+J.y.toFixed(5)+","+J.x.toFixed(5)+"]";t.ajax({url:t.init.contextPath+"/api/metaData?preheatCache=false",method:"POST",headers:{"Content-Type":"application/json"},params:Ext.encode({organisationUnits:[M]}),success:function(O){var N=H.geometry.x,P=H.geometry.y;delete H.geometry.bounds;H.geometry.x=P;H.geometry.y=N;m.redraw();console.log(H.attributes.name+" relocated to "+M.coordinates)}})}})}}}));y.push(Ext.create("Ext.menu.Item",{text:GIS.i18n.show_information_sheet,iconCls:"gis-menu-item-icon-information",handler:function(I){G()}}))}if(y.length){y[y.length-1].addCls("gis-menu-item-last")}A=new Ext.menu.Menu({baseCls:"gis-plugin gis-popupmenu",shadow:false,showSeparator:false,defaults:{bodyStyle:"padding-right:6px"},items:y});A.showAt([t.olmap.mouseMove.x+(B.dom.scrollLeft||0),t.olmap.mouseMove.y+(B.dom.scrollTop||0)])};x={onHoverSelect:j,onHoverUnselect:l,onClickSelect:k};if(v){x.onClickSelect=function q(G){var C=["label","value","nameColumnMap","psi","ps","longitude","latitude","eventdate","ou","oucode","ouname","popupText"],A=G.attributes,y=A.nameColumnMap,B='<table class="padding1">',E=' style="font-weight:bold; padding-right:10px; vertical-align:top"',z=' style="max-width:170px"',D;B+="<tr><td"+E+">"+y.ou+"</td><td"+z+">"+A.ouname+"</td></tr>";B+="<tr><td"+E+">"+y.eventdate+"</td><td"+z+">"+A.eventdate+"</td></tr>";B+="<tr><td"+E+">"+y.longitude+"</td><td"+z+">"+A.longitude+"</td></tr>";B+="<tr><td"+E+">"+y.latitude+"</td><td"+z+">"+A.latitude+"</td></tr>";for(var F in A){if(A.hasOwnProperty(F)&&!Ext.Array.contains(C,F)){B+="<tr><td"+E+">"+y[F]+"</td><td>"+A[F]+"</td></tr>"}}B+="</table>";if(Ext.isObject(r)&&r.destroy){D=r.getPosition();r.destroy();r=null}r=Ext.create("Ext.window.Window",{title:"Event",layout:"fit",resizable:false,bodyStyle:"background-color:#fff; padding:5px",html:B,autoShow:true,listeners:{show:function(H){if(D){H.setPosition(D)}else{t.util.gui.window.setPositionTopRight(H)}},destroy:function(){r=null}}})}}n=new OpenLayers.Control.newSelectFeature(m,x);t.olmap.addControl(n);n.activate()};GIS.core.StyleMap=function(k){var l={fillOpacity:1,strokeColor:"#fff",strokeWidth:1,pointRadius:8,labelAlign:"cr",labelYOffset:13,fontFamily:'"Arial","Sans-serif","Roboto","Helvetica","Consolas"'},j={fillOpacity:0.9,strokeColor:"#fff",strokeWidth:1,cursor:"pointer",labelAlign:"cr",labelYOffset:13};if(Ext.isObject(k)&&k.labels){l.label="${label}";l.fontSize=k.labelFontSize;l.fontWeight=k.labelFontWeight;l.fontStyle=k.labelFontStyle;l.fontColor=k.labelFontColor}return new OpenLayers.StyleMap({"default":l,select:j})};GIS.core.VectorLayer=function(j,n,l,k){var m=new OpenLayers.Layer.Vector(l,{strategies:[new OpenLayers.Strategy.Refresh({force:true})],styleMap:GIS.core.StyleMap(),visibility:false,displayInLayerSwitcher:false,layerType:j.conf.finals.layer.type_vector,layerOpacity:k?k.opacity||1:1,setLayerOpacity:function(o){if(o){this.layerOpacity=parseFloat(o)}this.setOpacity(this.layerOpacity)},hasLabels:false});m.id=n;return m};GIS.core.MeasureWindow=function(j){var l,k,m,o,n;n=new OpenLayers.StyleMap({"default":new OpenLayers.Style()});o=new OpenLayers.Control.Measure(OpenLayers.Handler.Path,{persist:true,immediate:true,handlerOption:{layerOptions:{styleMap:n}}});m=function(p){if(p.measure){k.setText(p.measure.toFixed(2)+" "+p.units)}};j.olmap.addControl(o);o.events.on({measurepartial:m,measure:m});o.geodesic=true;o.activate();k=Ext.create("Ext.form.Label",{style:"height: 20px",text:"0 km"});l=Ext.create("Ext.window.Window",{title:GIS.i18n.measure_distance,layout:"fit",cls:"gis-container-default gis-plugin",bodyStyle:"text-align: center",width:130,minWidth:130,resizable:false,items:k,listeners:{show:function(){var p=j.viewport.eastRegion.getPosition()[0]-this.getWidth()-3,q=j.viewport.centerRegion.getPosition()[1]+26;this.setPosition(p,q)},destroy:function(){o.deactivate();j.olmap.removeControl(o)}}});return l};GIS.core.MapLoader=function(s,j,m){var n,l,q,k,r=[],p,o=Ext.isObject(m)&&Ext.Array.from(m.mapViews).length?m.mapViews:null;n=function(){var v="json",u=s.init.contextPath+"/api/maps/"+s.map.id+"."+v+"?fields="+s.conf.url.mapFields.join(","),w,t;s.ajax({url:u,success:function(A){A=Ext.decode(A.responseText);if(Ext.isArray(A.mapViews)){for(var y=0,x,B;y<A.mapViews.length;y++){x=A.mapViews[y];if(Ext.isArray(x.dataDimensionItems)&&x.dataDimensionItems.length&&Ext.isObject(x.dataDimensionItems[0])){var z=x.dataDimensionItems[0];if(z.hasOwnProperty("dataElement")){B="de"}else{if(z.hasOwnProperty("dataSet")){B="ds"}else{B="in"}}}}}s.map=A;l()},failure:function(x){s.olmap.mask.hide();x=Ext.decode(x.responseText);if(Ext.Array.contains([403],parseInt(x.httpStatusCode))){x.message=GIS.i18n.you_do_not_have_access_to_all_items_in_this_favorite||x.message}s.alert(x)}})};l=function(){var u=s.map.mapViews,t;if(s.dashboard&&s.viewport.northRegion&&s.map&&s.map.name){s.viewport.northRegion.update(s.map.name)}if(!(Ext.isArray(u)&&u.length)){s.olmap.mask.hide();s.alert(GIS.i18n.favorite_outdated_create_new);return}for(var w=0,v;w<u.length;w++){v=o?o[w]:null;u[w]=s.api.layout.Layout(u[w],v)}u=Ext.Array.clean(u);if(!u.length){s.olmap.mask.hide();return}if(s.viewport&&s.viewport.favoriteWindow&&s.viewport.favoriteWindow.isVisible()){s.viewport.favoriteWindow.destroy()}s.olmap.closeAllLayers();for(var w=0,x;w<u.length;w++){x=u[w];t=s.layer[x.layer].core.getLoader();t.updateGui=!s.el;t.callBack=k;t.load(x)}};k=function(t){r.push(t);if(r.length===s.map.mapViews.length){q()}};q=function(){var w=parseFloat(s.map.longitude)||0,v=parseFloat(s.map.latitude)||20,t=s.map.zoom||3;r=[];if((w>=-180&&w<=180)&&(v>=-90&&v<=90)){var u=new OpenLayers.Geometry.Point(w,v).transform("EPSG:4326","EPSG:900913");w=u.x;v=u.y}if(s.el||j){s.olmap.zoomToVisibleExtent()}else{s.olmap.setCenter(new OpenLayers.LonLat(w,v),t)}if(s.viewport.shareButton){s.viewport.shareButton.enable()}if(GIS.isSessionStorage){s.util.layout.setSessionStorage("map",s.util.layout.getAnalytical())}s.olmap.mask.hide()};p={load:function(t){if(s.olmap.mask&&!s.skipMask){s.olmap.mask.show()}if(s.map&&s.map.id){n()}else{if(t){s.map={mapViews:t}}l()}}};return p};GIS.core.LayerLoaderEvent=function(s,l){var k=l.map,m,o,n,j,r,p,q=s.conf.finals.dimension;o=function(t){n(t)};n=function(t){var y="?",w=[],x;t=t||l.core.view;y+="stage="+t.stage.id;y+="&startDate="+t.startDate;y+="&endDate="+t.endDate;if(Ext.isArray(t.organisationUnits)){y+="&dimension=ou:";for(var v=0;v<t.organisationUnits.length;v++){y+=t.organisationUnits[v].id;y+=v<t.organisationUnits.length-1?";":""}}for(var v=0,u;v<t.dataElements.length;v++){u=t.dataElements[v];y+="&dimension="+u.dimension+(u.filter?":"+u.filter:"")}x=function(A){var K=[],B=[],M=[],z,C,J,D,H=Ext.clone(A.metaData.names),I={"true":GIS.i18n.yes||"Yes","false":GIS.i18n.no||"No"},G;G=function(){for(var P=0,U;P<A.headers.length;P++){U=A.headers[P];H[U.name]=U.column}for(var P=0,T,S;P<M.length;P++){T=M[P];S={};for(var O=0,R;O<T.length;O++){R=T[O];S[A.headers[O].name]=I[R]||A.metaData.optionNames[R]||H[R]||R}S[s.conf.finals.widget.value]=0;S.label=S.ouname;S.popupText=S.ouname;S.nameColumnMap=Ext.apply(H,A.metaData.optionNames,A.metaData.booleanNames);K.push(S)}for(var P=0,Q,N;P<K.length;P++){Q=K[P];N=s.util.map.getTransformedPointByXY(Q.longitude,Q.latitude);B.push(new OpenLayers.Feature.Vector(N,Q))}l.removeFeatures(l.features);l.addFeatures(B);j(t)};getOptionSets=function(){if(!D){G()}else{dhis2.gis.store.get("optionSets",D.optionSet).done(function(N){Ext.apply(A.metaData.optionNames,s.util.array.getObjectMap(N.options,"code","name"));G()})}};A.metaData.optionNames={};for(var E=0,F;E<A.headers.length;E++){F=A.headers[E];H[F.name]=F.column;if(F.name==="longitude"){z=E}if(F.name==="latitude"){C=E}if(Ext.isString(F.optionSet)&&F.optionSet.length){J=E;D=F}}if(Ext.isArray(A.rows)&&A.rows.length){for(var E=0,L;E<A.rows.length;E++){L=A.rows[E];if(L[z]&&L[C]){M.push(L)}}}if(!M.length){s.alert("No event coordinates found");k.mask.hide();return}getOptionSets()};s.ajax({url:s.init.contextPath+"/api/analytics/events/query/"+t.program.id+".json"+y,disableCaching:false,failure:function(z){s.alert(z)},success:function(z){x(Ext.decode(z.responseText))}})};j=function(t){t=t||l.core.view;var u={indicator:s.conf.finals.widget.value,method:2,numClasses:5,colors:l.core.getColors("000000","222222"),minSize:5,maxSize:5};l.core.view=t;l.core.applyClassification(u);r(t)};r=function(t){if(l.item){l.item.setValue(true,t.opacity)}else{l.setLayerOpacity(t.opacity)}if(p.updateGui&&Ext.isObject(l.widget)){l.widget.setGui(t)}if(p.zoomToVisibleExtent){k.zoomToVisibleExtent()}if(p.hideMask){k.mask.hide()}if(p.callBack){p.callBack(l)}else{s.map=null}};p={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(t){if(s.olmap.mask&&!s.skipMask){s.olmap.mask.show()}o(t)},loadData:n,loadLegend:j};return p};GIS.core.LayerLoaderFacility=function(s,m){var k=m.map,n,p,o,j,l,r,q;n=function(v,y){var A=m.core.view,z,u,t,w;q.zoomToVisibleExtent=true;if(!A){if(y){p(v)}return s.conf.finals.widget.loadtype_organisationunit}z=[];u=v.rows[0];t=[];w=A.rows[0];if(u.items.length===w.items.length){for(var x=0;x<u.items.length;x++){z.push(u.items[x].id)}for(var x=0;x<w.items.length;x++){t.push(w.items[x].id)}if(Ext.Array.difference(z,t).length!==0){if(y){p(v)}return s.conf.finals.widget.loadtype_organisationunit}}else{if(y){p(v)}return s.conf.finals.widget.loadtype_organisationunit}q.zoomToVisibleExtent=false;if(v.organisationUnitGroupSet.id!==A.organisationUnitGroupSet.id){if(y){p(v)}return s.conf.finals.widget.loadtype_organisationunit}if(y){j(v);return s.conf.finals.widget.loadtype_legend}};p=function(t){var u=t.rows[0].items,w=function(){var z="?ou=ou:";for(var y=0;y<u.length;y++){z+=u[y].id;z+=y!==u.length-1?";":""}z+="&displayProperty="+s.init.userAccount.settings.keyAnalysisDisplayProperty.toUpperCase();if(Ext.isArray(t.userOrgUnit)&&t.userOrgUnit.length){z+="&userOrgUnit=";for(var y=0;y<t.userOrgUnit.length;y++){z+=t.userOrgUnit[y]+(y<t.userOrgUnit.length-1?";":"")}}return s.init.contextPath+"/api/geoFeatures.json"+z+"&includeGroupSets=true"}(),x,v;x=function(A){var y=m.core.decode(A),B=new OpenLayers.Format.GeoJSON(),z=s.util.map.getTransformedFeatureArray(B.read(y));if(!Ext.isArray(z)){k.mask.hide();s.alert(GIS.i18n.invalid_coordinates);return}if(!z.length){k.mask.hide();s.alert(GIS.i18n.no_valid_coordinates_found);return}m.core.featureStore.loadFeatures(z.slice(0));o(t,z)};v=function(){k.mask.hide();s.alert(GIS.i18n.coordinates_could_not_be_loaded)};s.ajax({url:w,disableCaching:false,success:function(y){x(y)}})};o=function(t,v){t=t||m.core.view;v=v||m.core.featureStore.features;for(var u=0;u<v.length;u++){v[u].attributes.popupText=v[u].attributes.name+" ("+v[u].attributes[t.organisationUnitGroupSet.id]+")"}m.removeFeatures(m.features);m.addFeatures(v);j(t)};j=function(u){var w=GIS.plugin&&!GIS.app,y="json",v=s.init.contextPath+"/api/organisationUnitGroupSets/"+u.organisationUnitGroupSet.id+"."+y+"?fields=organisationUnitGroups[id,name,symbol]",z;u=u||m.core.view;for(var x=0,t;x<m.features.length;x++){t=m.features[x].attributes;t.label=u.labels?t.name:""}m.styleMap=GIS.core.StyleMap(u);z=function(B){var C=B.organisationUnitGroups,A={indicator:u.organisationUnitGroupSet.id};s.store.groupsByGroupSet.loadData(C);m.core.view=u;m.core.applyClassification({indicator:u.organisationUnitGroupSet.id});l(u);r(u)};s.ajax({url:v,success:function(A){z(A)}})};l=function(u){var t=u.areaRadius;if(m.circleLayer){m.circleLayer.deactivateControls();m.circleLayer=null}if(Ext.isDefined(t)&&t){m.circleLayer=GIS.core.CircleLayer(s,m.features,t);nissa=m.circleLayer}};r=function(t){s.viewport.eastRegion.doLayout();if(m.legendPanel){m.legendPanel.expand()}if(m.item){m.item.setValue(true,t.opacity)}else{m.setLayerOpacity(t.opacity)}if(q.updateGui&&Ext.isObject(m.widget)){m.widget.setGui(t)}if(q.zoomToVisibleExtent){k.zoomToVisibleExtent()}if(q.hideMask){k.mask.hide()}if(q.callBack){q.callBack(m)}else{s.map=null;if(s.viewport.shareButton){s.viewport.shareButton.enable()}}};q={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(t){if(s.olmap.mask&&!s.skipMask){s.olmap.mask.show()}if(this.compare){n(t,true)}else{p(t)}},loadData:o,loadLegend:j};return q};GIS.core.LayerLoaderBoundary=function(r,l){var k=l.map,m,o,n,j,q,p;m=function(u,x){var z=l.core.view,y,t,s,v;if(!z){if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}y=[];t=u.rows[0];s=[];v=z.rows[0];if(t.items.length===v.items.length){for(var w=0;w<t.items.length;w++){y.push(t.items[w].id)}for(var w=0;w<v.items.length;w++){s.push(v.items[w].id)}if(Ext.Array.difference(y,s).length!==0){if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}if(x){p.zoomToVisibleExtent=false;j(u)}return r.conf.finals.widget.loadtype_legend}else{if(x){o(u)}return r.conf.finals.widget.loadtype_organisationunit}r.olmap.mask.hide()};o=function(s){var t=s.rows[0].items,v=function(){var y="?ou=ou:";for(var x=0;x<t.length;x++){y+=t[x].id;y+=x!==t.length-1?";":""}y+="&displayProperty="+r.init.userAccount.settings.keyAnalysisDisplayProperty.toUpperCase();if(Ext.isArray(s.userOrgUnit)&&s.userOrgUnit.length){y+="&userOrgUnit=";for(var x=0;x<s.userOrgUnit.length;x++){y+=s.userOrgUnit[x]+(x<s.userOrgUnit.length-1?";":"")}}return r.init.contextPath+"/api/geoFeatures.json"+y}(),w,u;w=function(x){var y=r.util.geojson.decode(Ext.decode(x.responseText),"DESC"),F=new OpenLayers.Format.GeoJSON(),A=r.util.map.getTransformedFeatureArray(F.read(y)),z=["black","blue","red","green","yellow"],G=[],B={};if(!Ext.isArray(A)){k.mask.hide();r.alert(GIS.i18n.invalid_coordinates);return}if(!A.length){k.mask.hide();r.alert(GIS.i18n.no_valid_coordinates_found);return}for(var D=0;D<A.length;D++){G.push(parseFloat(A[D].attributes.level))}G=Ext.Array.unique(G).sort();for(var D=0;D<G.length;D++){B[G[D]]={strokeColor:z[D]}}for(var D=0,H,C,E;D<A.length;D++){H=A[D];C=B[H.attributes.level];E=G.length===1?1:H.attributes.level==2?2:1;H.style={strokeColor:C.strokeColor||"black",strokeWidth:E,fillOpacity:0,pointRadius:5,labelAlign:"cr",labelYOffset:13}}l.core.featureStore.loadFeatures(A.slice(0));n(s,A)};u=function(){k.mask.hide();r.alert(GIS.i18n.coordinates_could_not_be_loaded)};r.ajax({url:v,disableCaching:false,success:function(x){w(x)}})};n=function(s,u){s=s||l.core.view;u=u||l.core.featureStore.features;for(var t=0;t<u.length;t++){u[t].attributes.value=0;u[t].attributes.popupText=u[t].attributes.name}l.removeFeatures(l.features);l.addFeatures(u);j(s)};j=function(s){s=s||l.core.view;for(var v=0,u;v<l.features.length;v++){attr=l.features[v].attributes;attr.label=s.labels?attr.name:""}var t={indicator:r.conf.finals.widget.value,method:2,numClasses:5,colors:l.core.getColors("000000","000000"),minSize:6,maxSize:6};l.core.view=s;l.core.applyClassification(t);l.core.setFeatureLabelStyle(s.labels,false,s);q(s)};q=function(s){if(l.item){l.item.setValue(true,s.opacity)}else{l.setLayerOpacity(s.opacity)}if(p.updateGui&&Ext.isObject(l.widget)){l.widget.setGui(s)}if(p.zoomToVisibleExtent){k.zoomToVisibleExtent()}if(p.hideMask){k.mask.hide()}if(p.callBack){p.callBack(l)}else{r.map=null;if(r.viewport.shareButton){r.viewport.shareButton.enable()}}if(l.unregisterMouseDownEvent){l.unregisterMouseDownEvent()}};p={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(s){if(r.olmap.mask&&!r.skipMask){r.olmap.mask.show()}if(this.compare){m(s,true)}else{o(s)}},loadData:n,loadLegend:j};return p};GIS.core.LayerLoaderThematic=function(s,l){var k=l.map,m,o,n,j,r,p,q=s.conf.finals.dimension;m=function(v,y){var A=l.core.view,z,u,t,w;p.zoomToVisibleExtent=true;if(!A){if(y){o(v)}return s.conf.finals.widget.loadtype_organisationunit}z=[];u=v.rows[0];t=[];w=A.rows[0];if(u.items.length===w.items.length){for(var x=0;x<u.items.length;x++){z.push(u.items[x].id)}for(var x=0;x<w.items.length;x++){t.push(w.items[x].id)}if(Ext.Array.difference(z,t).length!==0){if(y){o(v)}return s.conf.finals.widget.loadtype_organisationunit}}else{if(y){o(v)}return s.conf.finals.widget.loadtype_organisationunit}p.zoomToVisibleExtent=false;z=[];u=v.columns[0];t=[];w=A.columns[0];if(u.items.length===w.items.length){for(var x=0;x<u.items.length;x++){z.push(u.items[x].id)}for(var x=0;x<w.items.length;x++){t.push(w.items[x].id)}if(Ext.Array.difference(z,t).length!==0){if(y){n(v)}return s.conf.finals.widget.loadtype_organisationunit}}else{if(y){n(v)}return s.conf.finals.widget.loadtype_organisationunit}z=[];u=v.filters[0];t=[];w=A.filters[0];if(u.items.length===w.items.length){for(var x=0;x<u.items.length;x++){z.push(u.items[x].id)}for(var x=0;x<w.items.length;x++){t.push(w.items[x].id)}if(Ext.Array.difference(z,t).length!==0){if(y){n(v)}return s.conf.finals.widget.loadtype_organisationunit}}else{if(y){n(v)}return s.conf.finals.widget.loadtype_organisationunit}if(y){p.zoomToVisibleExtent=false;j(v);return s.conf.finals.widget.loadtype_legend}};o=function(t){var u=t.rows[0].items,w=function(){var z="?ou=ou:";for(var y=0;y<u.length;y++){z+=u[y].id;z+=y!==u.length-1?";":""}z+="&displayProperty="+s.init.userAccount.settings.keyAnalysisDisplayProperty.toUpperCase();if(Ext.isArray(t.userOrgUnit)&&t.userOrgUnit.length){z+="&userOrgUnit=";for(var y=0;y<t.userOrgUnit.length;y++){z+=t.userOrgUnit[y]+(y<t.userOrgUnit.length-1?";":"")}}return s.init.contextPath+"/api/geoFeatures.json"+z}(),x,v;x=function(A){var y=s.util.geojson.decode(Ext.decode(A.responseText)),B=new OpenLayers.Format.GeoJSON(),z=s.util.map.getTransformedFeatureArray(B.read(y));if(!Ext.isArray(z)){k.mask.hide();s.alert(GIS.i18n.invalid_coordinates);return}if(!z.length){k.mask.hide();s.alert(GIS.i18n.no_valid_coordinates_found);return}l.core.featureStore.loadFeatures(z.slice(0));n(t,z)};v=function(){k.mask.hide();s.alert(GIS.i18n.coordinates_could_not_be_loaded)};s.ajax({url:w,disableCaching:false,success:function(y){x(y)},failure:function(){v()}})};n=function(A,v){var C;A=A||l.core.view;v=v||l.core.featureStore.features;var B=s.conf.finals.dimension,w="?",x=A.columns[0].items,t=A.columns[0].dimension===B.operand.objectName,u=A.filters[0].items,z=A.rows[0].items;w+="dimension=ou:";for(var y=0;y<z.length;y++){w+=z[y].id;w+=y<z.length-1?";":""}w+="&dimension=dx:";for(var y=0;y<x.length;y++){w+=t?x[y].id.split(".")[0]:x[y].id;w+=y<x.length-1?";":""}if(A.program){w+="&program="+A.program.id}w+=t?"&dimension=co":"";w+="&filter=pe:";for(var y=0;y<u.length;y++){w+=u[y].id;w+=y<u.length-1?";":""}w+="&displayProperty="+s.init.userAccount.settings.keyAnalysisDisplayProperty.toUpperCase();if(Ext.isArray(A.userOrgUnit)&&A.userOrgUnit.length){w+="&userOrgUnit=";for(var y=0;y<A.userOrgUnit.length;y++){w+=A.userOrgUnit[y]+(y<A.userOrgUnit.length-1?";":"")}}if(A.relativePeriodDate){w+="&relativePeriodDate="+A.relativePeriodDate}C=function(P){var I=s.api.response.Response(P),N={},F={},K,H,M,G=[],D,L=[];if(!I){k.mask.hide();return}for(var J=0;J<I.headers.length;J++){if(I.headers[J].name===B.organisationUnit.dimensionName){K=J}else{if(I.headers[J].name===B.value.dimensionName){M=J}}}for(var J=0,E;J<v.length;J++){var E=v[J].attributes.id;N[E]=true}for(var J=0;J<I.rows.length;J++){var E=I.rows[J][K],O=parseFloat(I.rows[J][M]);F[E]=O}for(var J=0;J<v.length;J++){var Q=v[J],E=Q.attributes.id;if(N.hasOwnProperty(E)&&F.hasOwnProperty(E)){Q.attributes.value=F[E];Q.attributes.popupText=Q.attributes.name+" ("+Q.attributes.value+")";G.push(Q)}}l.removeFeatures(l.features);l.addFeatures(G);s.response=I;j(A)};s.ajax({url:s.init.contextPath+"/api/analytics.json"+w,disableCaching:false,failure:function(D){s.alert(D)},success:function(D){C(Ext.decode(D.responseText))}})};j=function(C){var t=[],u=[],A=[],x=[],E,B;C=C||l.core.view;for(var w=0,D;w<l.features.length;w++){attr=l.features[w].attributes;attr.label=C.labels?attr.name+" ("+attr.value+")":""}l.styleMap=GIS.core.StyleMap(C);E=function(I){var G=Ext.Array.clean([].concat(C.columns||[],C.rows||[],C.filters||[])),H=I.metaData,N=H[q.period.objectName];for(var L=0,J;L<G.length;L++){J=G[L];for(var K=0,M;K<J.items.length;K++){M=J.items[K];if(M.id.indexOf(".")!==-1){var F=M.id.split(".");M.name=H.names[F[0]]+" "+H.names[F[1]]}else{M.name=H.names[M.id]}}}C.filters[0].items[0].name=H.names[N[N.length-1]]};B=function(){E(s.response);var F={indicator:s.conf.finals.widget.value,method:C.legendSet?mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS:C.method,numClasses:C.classes,bounds:t,colors:l.core.getColors(C.colorLow,C.colorHigh),minSize:C.radiusLow,maxSize:C.radiusHigh};l.core.view=C;l.core.colorInterpolation=u;l.core.applyClassification(F);r(C)};loadLegendSet=function(F){s.ajax({url:s.init.contextPath+"/api/legendSets/"+F.legendSet.id+".json?fields="+s.conf.url.legendSetFields.join(","),scope:this,disableCaching:false,success:function(H){x=Ext.decode(H.responseText).legends;Ext.Array.sort(x,function(J,I){return J.startValue-I.startValue});for(var G=0;G<x.length;G++){if(t[t.length-1]!==x[G].startValue){if(t.length!==0){u.push(new mapfish.ColorRgb(240,240,240));A.push("")}t.push(x[G].startValue)}u.push(new mapfish.ColorRgb());u[u.length-1].setFromHex(x[G].color);A.push(x[G].name);t.push(x[G].endValue)}F.legendSet.names=A;F.legendSet.bounds=t;F.legendSet.colors=u},callback:function(){B()}})};if(C.legendSet){loadLegendSet(C)}else{var z={"in":"indicators",de:"dataElements",ds:"dataSets"},y=z[C.columns[0].objectName],v=C.columns[0].items[0].id;if(!y){B();return}s.ajax({url:s.init.contextPath+"/api/"+y+".json?fields=legendSet[id,name]&paging=false&filter=id:eq:"+v,success:function(F){var G=Ext.decode(F.responseText)[y],H;if(Ext.Array.from(G).length){H=Ext.isObject(G[0])?G[0].legendSet||null:null}if(H){C.legendSet=H;loadLegendSet(C)}else{B()}},failure:function(){B()}})}};r=function(t){s.viewport.eastRegion.doLayout();if(l.legendPanel){l.legendPanel.expand()}l.setLayerOpacity(t.opacity);if(l.item){l.item.setValue(true)}if(l.filterWindow&&l.filterWindow.isVisible()){l.filterWindow.filter()}if(p.updateGui&&Ext.isObject(l.widget)){l.widget.setGui(t)}if(p.zoomToVisibleExtent){k.zoomToVisibleExtent()}if(p.hideMask){k.mask.hide()}if(p.callBack){p.callBack(l)}else{s.map=null;if(s.viewport.shareButton){s.viewport.shareButton.enable()}}if(GIS.isSessionStorage){s.util.layout.setSessionStorage("map",s.util.layout.getAnalytical())}};p={compare:false,updateGui:false,zoomToVisibleExtent:false,hideMask:false,callBack:null,load:function(t){if(s.olmap.mask&&!s.skipMask){s.olmap.mask.show()}if(this.compare){m(t,true)}else{o(t)}},loadData:n,loadLegend:j};return p};GIS.core.CircleLayer=function(t,k,q){var r=t.util.map.getPointsByFeatures(k),j=t.util.map.getLonLatsByPoints(r),s=[],o,p=new OpenLayers.Layer.Vector(),n,m,l={};q=q&&Ext.isNumber(parseInt(q))?parseInt(q):5;n=function(){for(var u=0;u<s.length;u++){s[u].deactivate()}};m=function(){if(j.length){for(var u=0;u<j.length;u++){o=new OpenLayers.Control.Circle({layer:p});o.lonLat=j[u];s.push(o)}t.olmap.addControls(s);for(var u=0;u<s.length;u++){o=s[u];o.activate();o.updateCircle(o.lonLat,q)}}}();p.deactivateControls=n;return p};GIS.core.getInstance=function(q,j){var n={},l={},o={},m={},p=[],k={};k.alert=function(){console.log(".")};(function(){n.finals={url:{path_commons:"/dhis-web-commons-ajax-json/"},layer:{type_base:"base",type_vector:"vector",category_thematic:"thematic"},dimension:{data:{id:"data",value:"data",param:"dx",dimensionName:"dx",objectName:"dx"},category:{name:GIS.i18n.categories,dimensionName:"co",objectName:"co"},indicator:{id:"indicator",value:"indicators",param:"in",dimensionName:"dx",objectName:"in"},dataElement:{id:"dataElement",value:"dataElement",param:"de",dimensionName:"dx",objectName:"de"},operand:{id:"operand",value:"operand",param:"dc",dimensionName:"dx",objectName:"dc"},dataSet:{value:"dataSets",dimensionName:"dx",objectName:"ds"},period:{id:"period",value:"period",param:"pe",dimensionName:"pe",objectName:"pe"},organisationUnit:{id:"organisationUnit",value:"organisationUnit",param:"ou",dimensionName:"ou",objectName:"ou"},value:{id:"value",value:"value",param:"value",dimensionName:"value",objectName:"value"}},widget:{value:"value",legendtype_automatic:"automatic",legendtype_predefined:"predefined",symbolizer_color:"color",symbolizer_image:"image",loadtype_organisationunit:"organisationUnit",loadtype_data:"data",loadtype_legend:"legend"},openLayers:{point_classname:"OpenLayers.Geometry.Point"},mapfish:{classify_with_bounds:1,classify_by_equal_intervals:2,classify_by_quantils:3},root:{id:"root"}};n.layout={widget:{item_width:288,itemlabel_width:95,window_width:306},tool:{item_width:228,itemlabel_width:95,window_width:250},grid:{row_height:27},layer:{opacity:0.8}};n.period={periodTypes:[{id:"relativePeriods",name:GIS.i18n.relative},{id:"Daily",name:GIS.i18n.daily},{id:"Weekly",name:GIS.i18n.weekly},{id:"Monthly",name:GIS.i18n.monthly},{id:"BiMonthly",name:GIS.i18n.bimonthly},{id:"Quarterly",name:GIS.i18n.quarterly},{id:"SixMonthly",name:GIS.i18n.sixmonthly},{id:"SixMonthlyApril",name:GIS.i18n.sixmonthly_april},{id:"Yearly",name:GIS.i18n.yearly},{id:"FinancialOct",name:GIS.i18n.financial_oct},{id:"FinancialJuly",name:GIS.i18n.financial_july},{id:"FinancialApril",name:GIS.i18n.financial_april}],relativePeriods:[{id:"THIS_WEEK",name:GIS.i18n.this_week},{id:"LAST_WEEK",name:GIS.i18n.last_week},{id:"THIS_MONTH",name:GIS.i18n.this_month},{id:"LAST_MONTH",name:GIS.i18n.last_month},{id:"THIS_BIMONTH",name:GIS.i18n.this_bimonth},{id:"LAST_BIMONTH",name:GIS.i18n.last_bimonth},{id:"THIS_QUARTER",name:GIS.i18n.this_quarter},{id:"LAST_QUARTER",name:GIS.i18n.last_quarter},{id:"THIS_SIX_MONTH",name:GIS.i18n.this_sixmonth},{id:"LAST_SIX_MONTH",name:GIS.i18n.last_sixmonth},{id:"THIS_FINANCIAL_YEAR",name:GIS.i18n.this_financial_year},{id:"LAST_FINANCIAL_YEAR",name:GIS.i18n.last_financial_year},{id:"THIS_YEAR",name:GIS.i18n.this_year},{id:"LAST_YEAR",name:GIS.i18n.last_year}],relativePeriodsMap:{},relativePeriodRecordsMap:{},integratedRelativePeriodsMap:{THIS_WEEK:"THIS_WEEK",LAST_WEEK:"LAST_WEEK",LAST_4_WEEKS:"LAST_WEEK",LAST_12_WEEKS:"LAST_WEEK",THIS_MONTH:"THIS_MONTH",LAST_MONTH:"LAST_MONTH",LAST_3_MONTHS:"LAST_MONTH",LAST_12_MONTHS:"LAST_MONTH",THIS_BIMONTH:"THIS_BIMONTH",LAST_BIMONTH:"LAST_BIMONTH",LAST_6_BIMONTHS:"LAST_BIMONTH",THIS_QUARTER:"THIS_QUARTER",LAST_QUARTER:"LAST_QUARTER",LAST_4_QUARTERS:"LAST_QUARTER",THIS_SIX_MONTH:"THIS_SIX_MONTH",LAST_SIX_MONTH:"LAST_SIX_MONTH",LAST_2_SIXMONTHS:"LAST_SIX_MONTH",LAST_FINANCIAL_YEAR:"LAST_FINANCIAL_YEAR",LAST_5_FINANCIAL_YEARS:"LAST_FINANCIAL_YEAR",THIS_YEAR:"THIS_YEAR",LAST_YEAR:"LAST_YEAR",LAST_5_YEARS:"LAST_YEAR"}};for(var r=0,s;r<n.period.relativePeriods.length;r++){s=n.period.relativePeriods[r];n.period.relativePeriodsMap[s.id]=s.name;n.period.relativePeriodRecordsMap[s.id]={id:s.id,name:s.name}}n.url={};n.url.analysisFields=["*","columns[dimension,filter,items[id,"+q.namePropertyUrl+"]]","rows[dimension,filter,items[id,"+q.namePropertyUrl+"]]","filters[dimension,filter,items[id,"+q.namePropertyUrl+"]]","!lastUpdated","!href","!created","!publicAccess","!rewindRelativePeriods","!userOrganisationUnit","!userOrganisationUnitChildren","!userOrganisationUnitGrandChildren","!externalAccess","!access","!relativePeriods","!columnDimensions","!rowDimensions","!filterDimensions","!user","!organisationUnitGroups","!itemOrganisationUnitGroups","!userGroupAccesses","!indicators","!dataElements","!dataElementOperands","!dataElementGroups","!dataSets","!periods","!organisationUnitLevels","!organisationUnits","!sortOrder","!topLimit"];n.url.mapFields=[n.url.analysisFields.join(","),"mapViews["+n.url.analysisFields.join(",")+"]"];n.url.legendFields=["*","!created","!lastUpdated","!displayName","!externalAccess","!access","!userGroupAccesses"];n.url.legendSetFields=["id,name,legends["+n.url.legendFields.join(",")+"]"]}());(function(){l.map={};l.map.getVisibleVectorLayers=function(){var t=[];for(var s=0,r;s<k.olmap.layers.length;s++){r=k.olmap.layers[s];if(r.layerType===n.finals.layer.type_vector&&r.visibility&&r.features.length){t.push(r)}}return t};l.map.getRenderedVectorLayers=function(){var t=[];for(var s=0,r;s<k.olmap.layers.length;s++){r=k.olmap.layers[s];if(r.layerType===n.finals.layer.type_vector&&r.features.length){t.push(r)}}return t};l.map.getExtendedBounds=function(t){var s=null;if(t.length){s=t[0].getDataExtent();if(t.length>1){for(var r=1;r<t.length;r++){s.extend(t[r].getDataExtent())}}}return s};l.map.zoomToVisibleExtent=function(s){var r=l.map.getExtendedBounds(l.map.getVisibleVectorLayers(s));if(r){s.zoomToExtent(r)}};l.map.getTransformedFeatureArray=function(u){var r=new OpenLayers.Projection("EPSG:4326"),s=new OpenLayers.Projection("EPSG:900913");for(var t=0;t<u.length;t++){u[t].geometry.transform(r,s)}return u};l.map.getPointsByFeatures=function(t){var r=[];for(var s=0;s<t.length;s++){if(t[s].geometry.CLASS_NAME===k.conf.finals.openLayers.point_classname){r.push(t[s])}}return r};l.map.getLonLatsByPoints=function(v){var t,r,s=[];for(var u=0;u<v.length;u++){r=v[u];t=new OpenLayers.LonLat(r.geometry.x,r.geometry.y);s.push(t)}return s};l.geojson={};l.geojson.decode=function(x,y){var t={type:"FeatureCollection",crs:{type:"EPSG",properties:{code:"4326"}},features:[]};y=y||"ASC";l.array.sort(x,y,"le");for(var u=0,w,s="",r="";u<x.length;u++){w=x[u];if(Ext.isString(w.pg)&&w.pg.length){var v=Ext.Array.clean(w.pg.split("/"));if(v.length>=2){s=v[v.length-2]}if(v.length>2){r="/"+v.slice(0,v.length-2).join("/")}}t.features.push({type:"Feature",geometry:{type:parseInt(w.ty)===1?"Point":"MultiPolygon",coordinates:JSON.parse(w.co)},properties:{id:w.id,name:w.na,hasCoordinatesDown:w.hcd,hasCoordinatesUp:w.hcu,level:w.le,grandParentParentGraph:r,grandParentId:s,parentGraph:w.pg,parentId:w.pi,parentName:w.pn}})}return t};l.gui={};l.gui.combo={};l.gui.combo.setQueryMode=function(r,t){for(var s=0;s<r.length;s++){r[s].queryMode=t}};l.object={};l.object.getLength=function(r){var t=0;for(var s in r){if(r.hasOwnProperty(s)){t++}}return t};l.array={};l.array.getLength=function(s,r){if(!Ext.isArray(s)){if(!r){console.log("support.prototype.array.getLength: not an array")}return null}return s.length};l.array.sort=function(u,t,s,r){if(!l.array.getLength(u,true)){return}s=!!s||Ext.isNumber(s)?s:"name";u.sort(function(w,v){if(Ext.isObject(w)&&Ext.isObject(v)){w=w[s];v=v[s]}if(Ext.isArray(w)&&Ext.isArray(v)){w=w[s];v=v[s]}if(Ext.isString(w)&&Ext.isString(v)){w=w.toLowerCase();v=v.toLowerCase();if(t==="DESC"){return w<v?1:(w>v?-1:0)}else{return w<v?-1:(w>v?1:0)}}else{if(Ext.isNumber(w)&&Ext.isNumber(v)){return t==="DESC"?v-w:w-v}else{if(w===undefined||w===null){return r?-1:1}else{if(v===undefined||v===null){return r?1:-1}}}}return -1});return u};l.array.getObjectMap=function(x,s,r,w){if(!(Ext.isArray(x)&&x.length)){return{}}var v={};s=s||"id";r=r||"name";w=w||"";for(var t=0,u;t<x.length;t++){u=x[t];v[w+u[s]]=u[r]}return v};l.layout={};l.layout.getAnalytical=function(w){var v,u;if(Ext.isObject(w)&&Ext.isArray(w.mapViews)&&w.mapViews.length){for(var t=0,r,x;t<w.mapViews.length;t++){r=w.mapViews[t];x=r.layer;if(k.layer.hasOwnProperty(x)&&k.layer[x].layerCategory===k.conf.finals.layer.category_thematic){v=k.api.layout.Layout(r);if(v){return v}}}}else{for(var s in k.layer){if(k.layer.hasOwnProperty(s)&&k.layer[s].layerCategory===k.conf.finals.layer.category_thematic&&k.layer[s].core.view){u=k.layer[s];v=k.api.layout.Layout(u.core.view);if(v){if(!v.parentGraphMap&&u.widget){v.parentGraphMap=u.widget.getParentGraphMap()}return v}}}}return};l.layout.getPluginConfig=function(){var u=k.util.map.getVisibleVectorLayers(),t={};if(k.map){return k.map}t.mapViews=[];for(var s=0,r;s<u.length;s++){r=u[s];if(r.core.view){r.core.view.layer=r.id;t.mapViews.push(r.core.view)}}return t};l.layout.setSessionStorage=function(u,t,s){if(GIS.isSessionStorage){var r=JSON.parse(sessionStorage.getItem("dhis2"))||{};r[u]=t;sessionStorage.setItem("dhis2",JSON.stringify(r));if(Ext.isString(s)){window.location.href=s}}};l.layout.getDataDimensionsFromLayout=function(v){var u=Ext.Array.clean([].concat(v.columns||[],v.rows||[],v.filters||[])),t=["pe","ou"],r=[];for(var s=0;s<u.length;s++){if(!Ext.Array.contains(t,u[s].dimension)){r.push(u[s])}}return r};l.date={};l.date.getYYYYMMDD=function(u){if(!Ext.isString(u)){if(!(Object.prototype.toString.call(u)==="[object Date]"&&u.toString()!=="Invalid date")){return null}}var s=new Date(u),t=""+(1+s.getMonth()),r=""+s.getDate();t=t.length===1?"0"+t:t;r=r.length===1?"0"+r:r;return s.getFullYear()+"-"+t+"-"+r};l.message={};l.message.alert=function(u){var r={},s,t;if(!u||(Ext.isObject(u)&&!u.message&&!u.responseText)){return}if(Ext.isObject(u)&&u.responseText&&!u.message){u=Ext.decode(u.responseText)}if(Ext.isString(u)){u={status:"ERROR",message:u}}if(k.dashboard){k.viewport.centerRegion.update('<div class="ns-plugin-alert">'+u.message+"</div>");return}s=(u.status||"INFO").toLowerCase();r.title=u.status;r.iconCls="gis-window-title-messagebox "+s;r.html="";r.html+=u.httpStatusCode?"Code: "+u.httpStatusCode+"<br>":"";r.html+=u.httpStatus?"Status: "+u.httpStatus+"<br><br>":"";r.html+=u.message+(u.message.substr(u.message.length-1)==="."?"":".");r.bodyStyle="padding: 12px; background: #fff; max-width: 600px; max-height: "+k.viewport.centerRegion.getHeight()/2+"px";r.modal=true;r.destroyOnBlur=true;r.listeners={show:function(v){v.setPosition(v.getPosition()[0],v.getPosition()[1]/2);if(!v.hasDestroyOnBlurHandler){k.util.gui.window.addDestroyOnBlurHandler(v)}}};t=Ext.create("Ext.window.Window",r);t.show()};l.connection={};l.connection.ajax=function(r,s){var t=s||j||{};if(t.crossDomain&&Ext.isString(t.username)&&Ext.isString(t.password)){r.headers=Ext.isObject(t.headers)?t.headers:{};r.headers.Authorization="Basic "+btoa(t.username+":"+t.password)}Ext.Ajax.request(r)}}());k.init=q;k.conf=n;k.util=l;(function(){var r=k.conf.finals.dimension;o.layout={};o.response={};o.layout.Record=function(t){var s;if(!Ext.isObject(t)){console.log("Record config is not an object",t);return}if(!Ext.isString(t.id)){console.log("Record id is not text",t);return}s=Ext.clone(t);if(Ext.isString(t.name)){s.name=t.name}return s};o.layout.Dimension=function(t){var v={};if(!Ext.isObject(t)){return}if(!Ext.isString(t.dimension)){console.log("Dimension name is not text",t);return}if(t.dimension!==n.finals.dimension.category.objectName){var s=[];if(!Ext.isArray(t.items)){console.log("Dimension items is not an array",t);return}for(var u=0;u<t.items.length;u++){record=o.layout.Record(t.items[u]);if(record){s.push(record)}}t.items=s;if(!t.items.length){console.log("Dimension has no valid items",t);return}}v.dimension=t.dimension;v.items=t.items;if(t.objectName){v.objectName=t.objectName}return Ext.clone(v)};o.layout.Layout=function(v,u,t){v=Ext.apply(v,u);var w={},s,x;s=function(B){var z=[];if(!(B&&Ext.isArray(B)&&B.length)){return}for(var y=0,A;y<B.length;y++){A=o.layout.Dimension(B[y]);if(A){z.push(A)}}B=z;return B.length?B:null};x=function(A){var C=Ext.Array.clean([].concat(A.columns||[],A.rows||[],A.filters||[])),E=n.period.integratedRelativePeriodsMap,z,F,y;for(var B=0,D;B<C.length;B++){D=C[B];if(D.dimension===r.data.objectName){z=D}else{if(D.dimension===r.period.objectName){F=D}else{if(D.dimension===r.organisationUnit.objectName){y=D}}}}if(!y){k.alert("No organisation units specified");return}if(z){z.items=[z.items[0]]}if(F){F.items=[F.items[0]];F.items[0].id=E[F.items[0].id]?E[F.items[0].id]:F.items[0].id}A.columns=[z];A.rows=[y];A.filters=[F];return A};return function(){var E=[],D=[],G=n.finals.dimension,z=isOu=false,y=false,H=false;v=x(v);if(!v){return}v.columns=s(v.columns);v.rows=s(v.rows);v.filters=s(v.filters);if(!v.rows){console.log("Organisation unit dimension is invalid",v.rows);return}if(Ext.Array.contains([k.layer.thematic1.id,k.layer.thematic2.id,k.layer.thematic3.id,k.layer.thematic4.id],v.layer)){if(!v.columns){return}}for(var B=0,C,F=Ext.Array.clean([].concat(v.columns,v.rows,v.filters));B<F.length;B++){C=F[B];if(C){if(Ext.isString(C.dimension)){D.push(C.dimension)}if(C.dimension===G.organisationUnit.objectName&&Ext.isArray(C.items)){for(var A=0;A<C.items.length;A++){if(C.items[A].id==="USER_ORGUNIT"){isOu=true}else{if(C.items[A].id==="USER_ORGUNIT_CHILDREN"){y=true}else{if(C.items[A].id==="USER_ORGUNIT_GRANDCHILDREN"){H=true}}}}}}}w.columns=v.columns;w.rows=v.rows;w.filters=v.filters;if(Ext.isObject(v.program)&&v.program.id){w.program=v.program}w.layer=Ext.isString(v.layer)&&!Ext.isEmpty(v.layer)?v.layer:"thematic1";w.classes=Ext.isNumber(v.classes)&&!Ext.isEmpty(v.classes)?v.classes:5;w.method=Ext.isNumber(v.method)&&!Ext.isEmpty(v.method)?v.method:2;w.colorLow=Ext.isString(v.colorLow)&&!Ext.isEmpty(v.colorLow)?v.colorLow:"ff0000";w.colorHigh=Ext.isString(v.colorHigh)&&!Ext.isEmpty(v.colorHigh)?v.colorHigh:"00ff00";w.radiusLow=Ext.isNumber(v.radiusLow)&&!Ext.isEmpty(v.radiusLow)?v.radiusLow:5;w.radiusHigh=Ext.isNumber(v.radiusHigh)&&!Ext.isEmpty(v.radiusHigh)?v.radiusHigh:15;w.opacity=Ext.isNumber(v.opacity)&&!Ext.isEmpty(v.opacity)?v.opacity:k.conf.layout.layer.opacity;w.areaRadius=v.areaRadius;w.labels=!!v.labels;w.labelFontSize=v.labelFontSize||"11px";w.labelFontSize=parseInt(w.labelFontSize)+"px";w.labelFontWeight=Ext.isString(v.labelFontWeight)||Ext.isNumber(v.labelFontWeight)?v.labelFontWeight:"normal";w.labelFontWeight=Ext.Array.contains(["normal","bold","bolder","lighter"],w.labelFontWeight)?w.labelFontWeight:"normal";w.labelFontWeight=Ext.isNumber(parseInt(w.labelFontWeight))&&parseInt(w.labelFontWeight)<=1000?w.labelFontWeight.toString():w.labelFontWeight;w.labelFontStyle=Ext.Array.contains(["normal","italic","oblique"],v.labelFontStyle)?v.labelFontStyle:"normal";w.labelFontColor=Ext.isString(v.labelFontColor)||Ext.isNumber(v.labelFontColor)?v.labelFontColor:"normal";w.labelFontColor=Ext.isNumber(w.labelFontColor)?w.labelFontColor.toString():w.labelFontColor;w.labelFontColor=w.labelFontColor.charAt(0)!=="#"?"#"+w.labelFontColor:w.labelFontColor;w.hidden=!!v.hidden;w.userOrganisationUnit=isOu;w.userOrganisationUnitChildren=y;w.userOrganisationUnitGrandChildren=H;w.parentGraphMap=Ext.isObject(v.parentGraphMap)?v.parentGraphMap:null;w.legendSet=v.legendSet;w.organisationUnitGroupSet=v.organisationUnitGroupSet;if(Ext.Array.from(v.userOrgUnit).length){w.userOrgUnit=Ext.Array.from(v.userOrgUnit)}if(l.date.getYYYYMMDD(v.relativePeriodDate)){w.relativePeriodDate=support.prototype.date.getYYYYMMDD(v.relativePeriodDate)}return Ext.apply(w,t)}()};o.response.Header=function(s){var t={};return function(){if(!Ext.isObject(s)){console.log("Header is not an object",s);return}if(!Ext.isString(s.name)){console.log("Header name is not text",s);return}if(!Ext.isBoolean(s.meta)){console.log("Header meta is not boolean",s);return}t.name=s.name;t.meta=s.meta;return Ext.clone(t)}()};o.response.Response=function(t){var s={};return function(){var v=[];if(!(t&&Ext.isObject(t))){k.alert("Data response invalid",t);return false}if(!(t.headers&&Ext.isArray(t.headers))){k.alert("Data response invalid",t);return false}for(var u=0,w;u<t.headers.length;u++){w=o.response.Header(t.headers[u]);if(w){v.push(w)}}t.headers=v;if(!t.headers.length){k.alert("No valid response headers",t);return}if(!(Ext.isArray(t.rows)&&t.rows.length>0)){k.alert("No values found",t);return false}if(t.headers.length!==t.rows[0].length){k.alert("Data invalid",t);return false}s.headers=t.headers;s.metaData=t.metaData;s.width=t.width;s.height=t.height;s.rows=t.rows;return s}()}}());k.alert=l.message.alert;k.api=o;k.store=m;k.olmap=GIS.core.getOLMap(k,j);k.layer=GIS.core.getLayers(k);k.thematicLayers=[k.layer.thematic1,k.layer.thematic2,k.layer.thematic3,k.layer.thematic4];p.push(k.layer.openStreetMap,k.layer.boundary,k.layer.thematic4,k.layer.thematic3,k.layer.thematic2,k.layer.thematic1,k.layer.facility,k.layer.event);k.olmap.addLayers(p);GIS.core.instances.push(k);return k};(function(){window.mapfish={_scriptName:"MapFish.js",_getScriptLocation:function(){if(window.gMfLocation){return window.gMfLocation}var m="";var n=mapfish._scriptName;var j=document.getElementsByTagName("script");for(var l=0;l<j.length;l++){var o=j[l].getAttribute("src");if(o){var k=o.lastIndexOf(n);if((k>-1)&&(k+n.length==o.length)){m=o.slice(0,-n.length);break}}}return m}};mapfish.Color=OpenLayers.Class({getColorRgb:function(){}});mapfish.ColorRgb=OpenLayers.Class(mapfish.Color,{redLevel:null,greenLevel:null,blueLevel:null,initialize:function(l,k,j){this.redLevel=l;this.greenLevel=k;this.blueLevel=j},equals:function(j){return j.redLevel==this.redLevel&&j.greenLevel==this.greenLevel&&j.blueLevel==this.blueLevel},getColorRgb:function(){return this},getRgbArray:function(){return[this.redLevel,this.greenLevel,this.blueLevel]},hex2rgbArray:function(j){if(j.charAt(0)=="#"){j=j.substr(1)}var k=[parseInt(j.substring(0,2),16),parseInt(j.substring(2,4),16),parseInt(j.substring(4,6),16)];for(var l=0;l<k.length;l++){if(k[l]<0||k[l]>255){OpenLayers.Console.error("Invalid rgb hex color string: rgbHexString")}}return k},setFromHex:function(j){var k=this.hex2rgbArray(j);this.redLevel=k[0];this.greenLevel=k[1];this.blueLevel=k[2]},setFromRgb:function(k){var j=dojo.colorFromString(k);this.redLevel=j.r;this.greenLevel=j.g;this.blueLevel=j.b},toHexString:function(){var l=this.toHex(this.redLevel);var k=this.toHex(this.greenLevel);var j=this.toHex(this.blueLevel);return"#"+l+k+j},toHex:function(o){var l="0123456789ABCDEF";if(o<0||o>255){var n="Invalid decimal value for color level";OpenLayers.Console.error(n)}var m=Math.floor(o/16);var k=o%16;return l.charAt(m)+l.charAt(k)},CLASS_NAME:"mapfish.ColorRgb"});mapfish.ColorRgb.getColorsArrayByRgbInterpolation=function(r,m,o){var s=[];var k=r.getColorRgb();var j=m.getColorRgb();var q=k.getRgbArray();var p=j.getRgbArray();if(o==1){return[k]}for(var n=0;n<o;n++){var l=[];l[0]=q[0]+n*(p[0]-q[0])/(o-1);l[1]=q[1]+n*(p[1]-q[1])/(o-1);l[2]=q[2]+n*(p[2]-q[2])/(o-1);s[n]=new mapfish.ColorRgb(parseInt(l[0]),parseInt(l[1]),parseInt(l[2]))}return s};mapfish.Util={};mapfish.Util.sum=function(l){for(var j=0,k=0;j<l.length;k+=l[j++]){}return k};mapfish.Util.max=function(j){return Math.max.apply({},j)};mapfish.Util.min=function(j){return Math.min.apply({},j)};mapfish.Util.getIconUrl=function(k,j){if(!j.layer){OpenLayers.Console.warn("Missing required layer option in mapfish.Util.getIconUrl");return""}if(!j.rule){j.rule=j.layer}if(k.indexOf("?")<0){k+="?"}else{if(k.lastIndexOf("&")!=(k.length-1)){if(k.indexOf("?")!=(k.length-1)){k+="&"}}}var j=OpenLayers.Util.extend({layer:"",rule:"",service:"WMS",version:"1.1.1",request:"GetLegendGraphic",format:"image/png",width:16,height:16},j);j=OpenLayers.Util.upperCaseObject(j);return k+OpenLayers.Util.getParameterString(j)};mapfish.Util.arrayEqual=function(k,j){if(k==null||j==null){return false}if(typeof(k)!="object"||typeof(j)!="object"){return false}if(k.length!=j.length){return false}for(var l=0;l<k.length;l++){if(typeof(k[l])!=typeof(j[l])){return false}if(k[l]!=j[l]){return false}}return true};mapfish.Util.isIE7=function(){var j=navigator.userAgent.toLowerCase();return j.indexOf("msie 7")>-1};mapfish.Util.relativeToAbsoluteURL=function(k){if(/^\w+:/.test(k)||!k){return k}var j=location.protocol+"//"+location.host;if(k.indexOf("/")==0){return j+k}var l=location.pathname.replace(/\/[^\/]*$/,"");return j+l+"/"+k};mapfish.Util.fixArray=function(j){if(j==""||j==null){return[]}else{if(j instanceof Array){return j}else{return j.split(",")}}};mapfish.GeoStat=OpenLayers.Class({layer:null,format:null,url:null,requestSuccess:function(j){},requestFailure:function(j){},indicator:null,defaultSymbolizer:{},legendDiv:null,initialize:function(l,j){this.map=l;this.addOptions(j);if(!this.layer){var k=new OpenLayers.Layer.Vector("geostat",{displayInLayerSwitcher:false,visibility:false});l.addLayer(k);this.layer=k}this.setUrl(this.url);this.legendDiv=Ext.get(j.legendDiv)},setUrl:function(j){this.url=j;if(this.url){OpenLayers.Request.GET({url:this.url,scope:this,success:this.requestSuccess,failure:this.requestFailure})}},getColors:function(j,l){var m=new mapfish.ColorRgb(),k=new mapfish.ColorRgb();m.setFromHex(j);k.setFromHex(l);return[m,k]},addOptions:function(j){if(j){if(!this.options){this.options={}}OpenLayers.Util.extend(this.options,j);OpenLayers.Util.extend(this,j)}},extendStyle:function(m,l,j){var k=this.layer.styleMap.styles["default"];if(m){k.rules=m}if(l){k.setDefaultStyle(OpenLayers.Util.applyDefaults(l,k.defaultStyle))}if(j){if(!k.context){k.context={}}OpenLayers.Util.extend(k.context,j)}},applyClassification:function(j){this.layer.renderer.clear();this.layer.redraw();this.updateLegend();this.layer.setVisibility(true)},showDetails:function(j){},hideDetails:function(j){},CLASS_NAME:"mapfish.GeoStat"});mapfish.GeoStat.Distribution=OpenLayers.Class({labelGenerator:function(k,m,n){var j=parseFloat(k.lowerBound).toFixed(1),l=parseFloat(k.upperBound).toFixed(1);return j+" - "+l+"&nbsp;&nbsp;("+k.nbVal+")"},values:null,nbVal:null,minVal:null,maxVal:null,initialize:function(j,k){OpenLayers.Util.extend(this,k);this.values=j;this.nbVal=j.length;this.minVal=this.nbVal?mapfish.Util.min(this.values):0;this.maxVal=this.nbVal?mapfish.Util.max(this.values):0},classifyWithBounds:function(l){var v=[];var s=[];var u=[];for(var r=0;r<this.values.length;r++){u.push(this.values[r])}u.sort(function(k,j){return k-j});var t=l.length-1;for(var q=0;q<t;q++){s[q]=0}for(var p=0;p<t-1;p){if(u[0]<l[p+1]){s[p]=s[p]+1;u.shift()}else{p++}}s[t-1]=this.nbVal-mapfish.Util.sum(s);for(var o=0;o<t;o++){v[o]=new mapfish.GeoStat.Bin(s[o],l[o],l[o+1],o==(t-1));var n=this.labelGenerator||this.defaultLabelGenerator;v[o].label=n(v[o],o,t)}return new mapfish.GeoStat.Classification(v)},classifyByEqIntervals:function(l){var k=[];for(var j=0;j<=l;j++){k[j]=this.minVal+j*(this.maxVal-this.minVal)/l}return this.classifyWithBounds(k)},classifyByQuantils:function(p){var k=this.values;k.sort(function(q,j){return q-j});var o=Math.round(this.values.length/p);var n=[];var m=(o===0)?0:o;if(k.length>0){n[0]=k[0];for(i=1;i<p;i++){n[i]=k[m];m+=o}n.push(k[k.length-1])}for(var l=0;l<n.length;l++){n[l]=parseFloat(n[l])}return this.classifyWithBounds(n)},sturgesRule:function(){return Math.floor(1+3.3*Math.log(this.nbVal,10))},classify:function(m,l,j){var k=null;if(!l){l=this.sturgesRule()}switch(parseFloat(m)){case mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS:k=this.classifyWithBounds(j);break;case mapfish.GeoStat.Distribution.CLASSIFY_BY_EQUAL_INTERVALS:k=this.classifyByEqIntervals(l);break;case mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS:k=this.classifyByQuantils(l);break;default:OpenLayers.Console.error("Unsupported or invalid classification method")}return k},CLASS_NAME:"mapfish.GeoStat.Distribution"});mapfish.GeoStat.Distribution.CLASSIFY_WITH_BOUNDS=1;mapfish.GeoStat.Distribution.CLASSIFY_BY_EQUAL_INTERVALS=2;mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS=3;mapfish.GeoStat.Bin=OpenLayers.Class({label:null,nbVal:null,lowerBound:null,upperBound:null,isLast:false,initialize:function(l,m,k,j){this.nbVal=l;this.lowerBound=m;this.upperBound=k;this.isLast=j},CLASS_NAME:"mapfish.GeoStat.Bin"});mapfish.GeoStat.Classification=OpenLayers.Class({bins:[],initialize:function(j){this.bins=j},getBoundsArray:function(){var k=[];for(var j=0;j<this.bins.length;j++){k.push(this.bins[j].lowerBound)}if(this.bins.length>0){k.push(this.bins[this.bins.length-1].upperBound)}return k},CLASS_NAME:"mapfish.GeoStat.Classification"});mapfish.GeoStat.Facility=OpenLayers.Class(mapfish.GeoStat,{classification:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(k){if(k&&k.length){var l=[];for(var j=0;j<k.length;j++){l.push([k[j].attributes.id,k[j].attributes.name])}this.loadData(l);this.sortStore();this.features=k}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(k,j){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderFacility(this.gis,this.layer)},decode:function(n){var m,o,j,k={type:"FeatureCollection",crs:{type:"EPSG",properties:{code:"4326"}},features:[]};for(var l=0;l<n.length;l++){j=n[l];m={type:"Feature",geometry:{type:parseInt(j.ty)===1?"Point":"MultiPolygon",coordinates:JSON.parse(j.co)},properties:{id:j.id,name:j.na}};m.properties=Ext.Object.merge(m.properties,j.dimensions);k.features.push(m)}return k},reset:function(){this.layer.destroyFeatures();if(this.layer.legendPanel){this.layer.legendPanel.update("");this.layer.legendPanel.collapse()}if(this.layer.widget){this.layer.widget.reset()}},extendView:function(j,k){j=j||this.view;j.organisationUnitGroupSet=k.organisationUnitGroupSet||j.organisationUnitGroupSet;j.organisationUnitLevel=k.organisationUnitLevel||j.organisationUnitLevel;j.parentOrganisationUnit=k.parentOrganisationUnit||j.parentOrganisationUnit;j.parentLevel=k.parentLevel||j.parentLevel;j.parentGraph=k.parentGraph||j.parentGraph;j.opacity=k.opacity||j.opacity;return j},updateOptions:function(j){this.addOptions(j)},applyClassification:function(k){this.updateOptions(k);var j=this.gis.store.groupsByGroupSet.data.items;var n=new Array(j.length);for(var l=0;l<j.length;l++){var m=new OpenLayers.Rule({symbolizer:{pointRadius:8,externalGraphic:"../images/orgunitgroup/"+j[l].data.symbol},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:this.indicator,value:j[l].data.name})});n[l]=m}this.extendStyle(n);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){var l=document.createElement("div"),m=document.createElement("div"),j=this.gis.store.groupsByGroupSet.data.items;for(var k=0;k<j.length;k++){m=document.createElement("div");m.style.backgroundImage="url(../images/orgunitgroup/"+j[k].data.symbol+")";m.style.backgroundRepeat="no-repeat";m.style.width="21px";m.style.height="16px";m.style.marginBottom="2px";m.style.cssFloat="left";l.appendChild(m);m=document.createElement("div");m.innerHTML=j[k].data.name;m.style.height="16px";m.style.lineHeight="17px";l.appendChild(m);m=document.createElement("div");m.style.clear="left";l.appendChild(m)}if(this.layer.legendPanel){this.layer.legendPanel.update(l.outerHTML)}return l},CLASS_NAME:"mapfish.GeoStat.Facility"});mapfish.GeoStat.Event=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,minSize:4,maxSize:4,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(k){if(k&&k.length){var l=[];for(var j=0;j<k.length;j++){l.push([k[j].attributes.id,k[j].attributes.name])}this.loadData(l);this.sortStore();this.features=k}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(k,j){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderEvent(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(j,k){j=j||this.view;j.organisationUnitLevel=k.organisationUnitLevel||j.organisationUnitLevel;j.parentOrganisationUnit=k.parentOrganisationUnit||j.parentOrganisationUnit;j.parentLevel=k.parentLevel||j.parentLevel;j.parentGraph=k.parentGraph||j.parentGraph;j.opacity=k.opacity||j.opacity;return j},getLegendConfig:function(){return},getImageLegendConfig:function(){return},updateOptions:function(k){var j=OpenLayers.Util.extend({},this.options);this.addOptions(k);if(k){this.setClassification()}},createColorInterpolation:function(){var j=this.classification.bins.length;this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],j)},setClassification:function(){var k=[];for(var l=0;l<this.layer.features.length;l++){k.push(this.layer.features[l].attributes[this.indicator])}var j={labelGenerator:this.options.labelGenerator};var m=new mapfish.GeoStat.Distribution(k,j);this.minVal=m.minVal;this.maxVal=m.maxVal;this.classification=m.classify(this.method,this.numClasses,null);this.createColorInterpolation()},applyClassification:function(j){this.updateOptions(j);var o=OpenLayers.Function.bind(function(q){var r=q.attributes[this.indicator];var p=(r-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return p||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:o});var m=this.classification.getBoundsArray();var n=new Array(m.length-1);for(var k=0;k<m.length-1;k++){var l=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[k].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:m[k],upperBoundary:m[k+1]})});n[k]=l}this.extendStyle(n);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){return{}},CLASS_NAME:"mapfish.GeoStat.Event"});mapfish.GeoStat.Boundary=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,minSize:3,maxSize:20,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(k){if(k&&k.length){var l=[];for(var j=0;j<k.length;j++){l.push([k[j].attributes.id,k[j].attributes.name])}this.loadData(l);this.sortStore();this.features=k}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(k,j){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderBoundary(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();if(this.layer.widget){this.layer.widget.reset()}},extendView:function(j,k){j=j||this.view;j.organisationUnitLevel=k.organisationUnitLevel||j.organisationUnitLevel;j.parentOrganisationUnit=k.parentOrganisationUnit||j.parentOrganisationUnit;j.parentLevel=k.parentLevel||j.parentLevel;j.parentGraph=k.parentGraph||j.parentGraph;j.opacity=k.opacity||j.opacity;return j},getLegendConfig:function(){return},getImageLegendConfig:function(){return},getDefaultFeatureStyle:function(){return{fillOpacity:0,fillColor:"#000",strokeColor:"#000",strokeWidth:1,pointRadius:5,cursor:"pointer"}},setFeatureStyle:function(k){for(var j=0;j<this.layer.features.length;j++){this.layer.features[j].style=k}this.layer.redraw()},setFeatureLabelStyle:function(o,p,j){for(var m=0,l,n,k;m<this.layer.features.length;m++){l=this.layer.features[m];n=l.style;if(o){n.label=l.attributes.label;n.fontColor=n.strokeColor;n.fontWeight=n.strokeWidth>1?"bold":"normal";n.labelAlign="cr";n.labelYOffset=13;if(j.labelFontSize){n.fontSize=j.labelFontSize}if(j.labelFontStyle){n.fontStyle=j.labelFontStyle}}else{n.label=null}}if(!p){this.layer.redraw()}},updateOptions:function(k){var j=OpenLayers.Util.extend({},this.options);this.addOptions(k);if(k){this.setClassification()}},createColorInterpolation:function(){var j=this.classification.bins.length;this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],j)},setClassification:function(){var k=[];for(var l=0;l<this.layer.features.length;l++){k.push(this.layer.features[l].attributes[this.indicator])}var j={labelGenerator:this.options.labelGenerator};var m=new mapfish.GeoStat.Distribution(k,j);this.minVal=m.minVal;this.maxVal=m.maxVal;this.classification=m.classify(this.method,this.numClasses,null);this.createColorInterpolation()},applyClassification:function(j){this.updateOptions(j);var o=OpenLayers.Function.bind(function(q){var r=q.attributes[this.indicator];var p=(r-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return p||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:o});var m=this.classification.getBoundsArray();var n=new Array(m.length-1);for(var k=0;k<m.length-1;k++){var l=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[k].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:m[k],upperBoundary:m[k+1]})});n[k]=l}this.extendStyle(n);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){return{}},CLASS_NAME:"mapfish.GeoStat.Boundary"});mapfish.GeoStat.createThematic=function(j){mapfish.GeoStat[j]=OpenLayers.Class(mapfish.GeoStat,{colors:[new mapfish.ColorRgb(120,120,0),new mapfish.ColorRgb(255,0,0)],method:mapfish.GeoStat.Distribution.CLASSIFY_BY_QUANTILS,numClasses:5,bounds:null,minSize:3,maxSize:20,minVal:null,maxVal:null,defaultSymbolizer:{fillOpacity:1},classification:null,colorInterpolation:null,gis:null,view:null,featureStore:Ext.create("Ext.data.Store",{fields:["id","name"],features:[],loadFeatures:function(l){if(l&&l.length){var m=[];this.features=l;for(var k=0;k<l.length;k++){m.push([l[k].attributes.id,l[k].attributes.name])}this.loadData(m);this.sortStore()}else{this.removeAll()}},sortStore:function(){this.sort("name","ASC")}}),initialize:function(l,k){mapfish.GeoStat.prototype.initialize.apply(this,arguments)},getLoader:function(){return GIS.core.LayerLoaderThematic(this.gis,this.layer)},reset:function(){this.layer.destroyFeatures();this.featureStore.loadFeatures(this.layer.features.slice(0));if(this.layer.legendPanel){this.layer.legendPanel.update("");this.layer.legendPanel.collapse()}if(this.layer.widget){this.layer.widget.reset()}},extendView:function(k,l){k=k||this.view;k.valueType=l.valueType||k.valueType;k.indicatorGroup=l.indicatorGroup||k.indicatorGroup;k.indicator=l.indicator||k.indicator;k.dataElementGroup=l.dataElementGroup||k.dataElementGroup;k.dataElement=l.dataElement||k.dataElement;k.periodType=l.periodType||k.periodType;k.period=l.period||k.period;k.legendType=l.legendType||k.legendType;k.legendSet=l.legendSet||k.legendSet;k.classes=l.classes||k.classes;k.method=l.method||k.method;k.colorLow=l.colorLow||k.colorLow;k.colorHigh=l.colorHigh||k.colorHigh;k.radiusLow=l.radiusLow||k.radiusLow;k.radiusHigh=l.radiusHigh||k.radiusHigh;k.organisationUnitLevel=l.organisationUnitLevel||k.organisationUnitLevel;k.parentOrganisationUnit=l.parentOrganisationUnit||k.parentOrganisationUnit;k.parentLevel=l.parentLevel||k.parentLevel;k.parentGraph=l.parentGraph||k.parentGraph;k.opacity=l.opacity||k.opacity;return k},getImageLegendConfig:function(){var n=this.classification.bins,l=this.colorInterpolation,k=[];for(var m=0;m<n.length;m++){k.push({color:l[m].toHexString(),label:n[m].lowerBound.toFixed(1)+" - "+n[m].upperBound.toFixed(1)+" ("+n[m].nbVal+")"})}return k},updateOptions:function(l){var k=OpenLayers.Util.extend({},this.options);this.addOptions(l);if(l){this.setClassification()}},createColorInterpolation:function(){var k=this.classification.bins.length;if(!this.view.legendSet){this.colorInterpolation=mapfish.ColorRgb.getColorsArrayByRgbInterpolation(this.colors[0],this.colors[1],k)}},setClassification:function(){var l=[];for(var m=0;m<this.layer.features.length;m++){l.push(this.layer.features[m].attributes[this.indicator])}var k={labelGenerator:this.options.labelGenerator};var n=new mapfish.GeoStat.Distribution(l,k);this.minVal=n.minVal;this.maxVal=n.maxVal;if(this.view.legendType===this.gis.conf.finals.widget.legendtype_predefined){if(this.bounds[0]>this.minVal){this.bounds.unshift(this.minVal);this.colorInterpolation.unshift(new mapfish.ColorRgb(240,240,240))}if(this.bounds[this.bounds.length-1]<this.maxVal){this.bounds.push(this.maxVal);this.colorInterpolation.push(new mapfish.ColorRgb(240,240,240))}}this.classification=n.classify(this.method,this.numClasses,this.bounds);this.createColorInterpolation()},applyClassification:function(k,m){this.updateOptions(k,m);var q=OpenLayers.Function.bind(function(s){var t=s.attributes[this.indicator];var r=(t-this.minVal)/(this.maxVal-this.minVal)*(this.maxSize-this.minSize)+this.minSize;return r||this.minSize},this);this.extendStyle(null,{pointRadius:"${calculateRadius}"},{calculateRadius:q});var o=this.classification.getBoundsArray();var p=new Array(o.length-1);for(var l=0;l<o.length-1;l++){var n=new OpenLayers.Rule({symbolizer:{fillColor:this.colorInterpolation[l].toHexString()},filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN,property:this.indicator,lowerBoundary:o[l],upperBoundary:o[l+1]})});p[l]=n}this.extendStyle(p);mapfish.GeoStat.prototype.applyClassification.apply(this,arguments)},updateLegend:function(){var t=this.view,p=this.gis.response,n=this.gis.plugin,r=document.createElement("div"),s=t.legendSet?t.legendSet.names||{}:{},l={},o,m,k;l.dataLineHeight=n?"12px":"14px";l.dataPaddingBottom=n?"2px":"3px";l.colorWidth=n?"15px":"30px";l.colorHeight=n?"13px":"15px";l.colorMarginRight=n?"5px":"8px";l.fontSize=n?"10px":"11px";m=t.columns[0].items[0].id;k=t.columns[0].items[0].name;o=document.createElement("div");o.style.fontSize=l.fontSize;o.style.lineHeight=l.dataLineHeight;o.style.paddingBottom=l.dataPaddingBottom;o.innerHTML+='<div style="color:#222; font-size:10px !important">'+(p.metaData.names[m]||k||m)+"</div>";m=t.filters[0].items[0].id;k=t.filters[0].items[0].name;o.innerHTML+=p.metaData.names[m]||k||m;r.appendChild(o);o=document.createElement("div");o.style.clear="left";r.appendChild(o);if(t.legendSet){for(var q=0;q<this.classification.bins.length;q++){o=document.createElement("div");o.style.fontSize=l.fontSize;o.style.backgroundColor=this.colorInterpolation[q].toHexString();o.style.width=l.colorWidth;o.style.height=s[q]?"22px":l.colorHeight;o.style.cssFloat="left";o.style.marginRight=l.colorMarginRight;r.appendChild(o);o=document.createElement("div");o.style.height=s[q]?"22px":l.colorHeight;o.style.fontSize=l.fontSize;o.style.lineHeight=s[q]?"12px":"7px";o.innerHTML='<div style="color:#222; font-size:10px !important; height:11px; line-height:12px; font-weight:bold;">'+(s[q]||"")+"</div>";o.innerHTML+='<div style="color:#222; font-size:10px !important; height:11px; line-height:12px">'+this.classification.bins[q].label+"</div>";r.appendChild(o);o=document.createElement("div");o.style.clear="left";r.appendChild(o)}}else{for(var q=0;q<this.classification.bins.length;q++){o=document.createElement("div");o.style.backgroundColor=this.colorInterpolation[q].toHexString();o.style.width=l.colorWidth;o.style.height=l.colorHeight;o.style.cssFloat="left";o.style.marginRight=l.colorMarginRight;r.appendChild(o);o=document.createElement("div");o.style.height=l.colorHeight;o.style.fontSize=l.fontSize;o.innerHTML=this.classification.bins[q].label;r.appendChild(o);o=document.createElement("div");o.style.clear="left";r.appendChild(o)}}if(this.layer.legendPanel){this.layer.legendPanel.update(r.outerHTML)}return r},CLASS_NAME:"mapfish.GeoStat."+j})};mapfish.GeoStat.createThematic("Thematic1");mapfish.GeoStat.createThematic("Thematic2");mapfish.GeoStat.createThematic("Thematic3");mapfish.GeoStat.createThematic("Thematic4")}());var g={user:{},systemInfo:{}},f=[],h=false,b=false,d=false,a,c,e;GIS.i18n={event_layer:"Event layer",boundary_layer:"Boundary layer",facility_layer:"Facility layer",thematic_layer:"Thematic layer",measure_distance:"Measure distance",coordinates_could_not_be_loaded:"Coordinates could not be loaded",invalid_coordinates:"Invalid coordinates",no_valid_coordinates_found:"No valid coordinates found"};GIS.plugin={};a=function(j){var q=false,p=[],n=0,m="json",o,l;g.contextPath=j.url;l=function(){if(++n===p.length){b=true;for(var r=0;r<f.length;r++){e(f[r])}}};o=function(r,s){s=s||j;if(s.crossDomain&&Ext.isString(s.username)&&Ext.isString(s.password)){r.headers=Ext.isObject(s.headers)?s.headers:{};r.headers.Authorization="Basic "+btoa(s.username+":"+s.password)}Ext.Ajax.request(r)};p.push({url:g.contextPath+"/api/systemSettings."+m+"?key=keyCalendar&key=keyDateFormat",disableCaching:false,success:function(u){var t=u.responseText?Ext.decode(u.responseText):u,s;g.systemInfo.dateFormat=Ext.isString(t.keyDateFormat)?t.keyDateFormat.toLowerCase():"yyyy-mm-dd";g.systemInfo.calendar=t.keyCalendar;s={url:g.contextPath+"/api/me/user-account."+m,disableCaching:false,success:function(w){g.userAccount=w.responseText?Ext.decode(w.responseText):w;var v=function(){var C="en",A="name",z,B,y,r,x;g.userAccount.settings.keyUiLocale=g.userAccount.settings.keyUiLocale||C;g.userAccount.settings.keyAnalysisDisplayProperty=g.userAccount.settings.keyAnalysisDisplayProperty||A;B=g.contextPath;y=g.userAccount.settings.keyUiLocale;keyAnalysisDisplayProperty=g.userAccount.settings.keyAnalysisDisplayProperty;z=keyAnalysisDisplayProperty===A?keyAnalysisDisplayProperty:keyAnalysisDisplayProperty+"|rename("+A+")";r=g.systemInfo.dateFormat;g.namePropertyUrl=z;dhis2.util.namespace("dhis2.gis");dhis2.gis.store=dhis2.gis.store||new dhis2.storage.Store({name:"dhis2",adapters:[dhis2.storage.IndexedDBAdapter,dhis2.storage.DomSessionStorageAdapter,dhis2.storage.InMemoryAdapter],objectStores:["optionSets"]});x={url:B+"/api/optionSets."+m+"?fields=id,version&paging=false",disableCaching:false,success:function(D){var G=(D.responseText?Ext.decode(D.responseText).optionSets:D.optionSets)||[],J=dhis2.gis.store,E=[],F="",H=0,K,I,L;if(!G.length){l();return}L={url:B+"/api/optionSets."+m+"?fields=id,name,version,options[code,name]&paging=false"+F,disableCaching:false,success:function(N){var M=N.responseText?Ext.decode(N.responseText).optionSets:N.optionSets;J.setAll("optionSets",M).done(l)}};I=function(){if(++H===G.length){if(!E.length){l();return}for(var M=0;M<E.length;M++){F+="&filter=id:eq:"+E[M]}o(L)}};K=function(M){J.get("optionSets",M.id).done(function(N){if(!Ext.isObject(N)||N.version!==M.version){E.push(M.id)}I()})};J.open().done(function(){for(var M=0;M<G.length;M++){K(G[M])}})}};o(x)};if(window.dhis2&&window.jQuery){v()}else{Ext.Loader.injectScriptElement(g.contextPath+"/dhis-web-commons/javascripts/jQuery/jquery.min.js",function(){Ext.Loader.injectScriptElement(g.contextPath+"/dhis-web-commons/javascripts/dhis2/dhis2.util.js",function(){Ext.Loader.injectScriptElement(g.contextPath+"/dhis-web-commons/javascripts/dhis2/dhis2.storage.js",function(){Ext.Loader.injectScriptElement(g.contextPath+"/dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js",function(){Ext.Loader.injectScriptElement(g.contextPath+"/dhis-web-commons/javascripts/dhis2/dhis2.storage.ss.js",function(){Ext.Loader.injectScriptElement(g.contextPath+"/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js",function(){v()})})})})})})}}};o(s)}});p.push({url:g.contextPath+"/api/organisationUnits."+m+"?userOnly=true&fields=id,name,children[id,name]&paging=false",disableCaching:false,success:function(v){var u=(v.responseText?Ext.decode(v.responseText).organisationUnits:v)||[],t=[],w=[];if(u.length){for(var s=0,x;s<u.length;s++){x=u[s];t.push(x.id);if(x.children){w=Ext.Array.clean(w.concat(Ext.Array.pluck(x.children,"id")||[]))}}g.user=g.user||{};g.user.ou=t;g.user.ouc=w}else{gis.alert("User is not assigned to any organisation units")}l()}});p.push({url:g.contextPath+"/api/dimensions."+m+"?fields=id,name&paging=false",disableCaching:false,success:function(s){g.dimensions=s.responseText?Ext.decode(s.responseText).dimensions:s.dimensions;l()}});for(var k=0;k<p.length;k++){o(p[k])}};c=function(){var j="";j+=".x-border-box .gis-plugin * {box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;-webkit-box-sizing:border-box} \n";j+=".gis-plugin, .gis-plugin * { font-family: arial, sans-serif, liberation sans, consolas; } \n";j+="table{border-collapse:collapse;border-spacing:0} \n";j+="fieldset,img{border:0} \n";j+="*:focus{outline:none}";j+=".x-clear{overflow:hidden;clear:both;height:0;width:0;font-size:0;line-height:0} \n";j+=".x-layer{position:absolute;overflow:hidden;zoom:1} \n";j+=".x-css-shadow{position:absolute;-moz-border-radius:5px 5px;-webkit-border-radius:5px 5px;-o-border-radius:5px 5px;-ms-border-radius:5px 5px;-khtml-border-radius:5px 5px;border-radius:5px 5px} \n";j+=".x-frame-shadow *{overflow:hidden} \n";j+=".x-frame-shadow *{padding:0;border:0;margin:0;clear:none;zoom:1} \n";j+=".x-mask{z-index:100;position:absolute;top:0;left:0;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=50);opacity:0.5;width:100%;height:100%;zoom:1;background:#cccccc} \n";j+=".x-mask-msg{z-index:20001;position:absolute;top:0;left:0;padding:2px;border:1px solid;border-color:#d0d0d0;background-image:none;background-color:#e0e0e0} \n";j+='.x-mask-msg div{padding:5px 10px 5px 25px;background-image:url("'+g.contextPath+'/dhis-web-commons/javascripts/plugin/images/loading.gif");background-repeat:no-repeat;background-position:5px center;cursor:wait;border:1px solid #b3b3b3;background-color:#eeeeee;color:#222222;font:normal 11px tahoma, arial, verdana, sans-serif} \n';j+=".x-btn *{cursor:pointer;cursor:hand} \n";j+=".x-btn em a{text-decoration:none;display:inline-block;color:inherit} \n";j+=".x-btn-disabled span{filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=50);opacity:0.5} \n";j+=".x-ie6 .x-btn-disabled span,.x-ie7 .x-btn-disabled span{filter:none} \n";j+=".x-btn button,.x-btn a{position:relative} \n";j+=".x-item-disabled,.x-item-disabled *{cursor:default} \n";j+=".x-datepicker a{-moz-outline:0 none;outline:0 none;color:#523a39;text-decoration:none;border-width:0} \n";j+=".x-datepicker-prev a,.x-datepicker-next a{display:block;width:16px;height:16px;background-position:top;background-repeat:no-repeat;cursor:pointer;text-decoration:none !important;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=70);opacity:0.7} \n";j+=".x-datepicker-prev a:hover,.x-datepicker-next a:hover{filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);opacity:1} \n";j+='.x-datepicker-next a{background-image:url("images/right-btn.gif")} \n';j+='.x-datepicker-prev a{background-image:url("images/left-btn.gif")} \n';j+=".x-item-disabled .x-datepicker-prev a:hover,.x-item-disabled .x-datepicker-next a:hover{filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=60);opacity:0.6} \n";j+=".x-datepicker-month span{color:#fff !important} \n";j+="table.x-datepicker-inner th span{display:block;padding-right:7px} \n";j+="table.x-datepicker-inner a{padding-right:4px;display:block;zoom:1;font:normal 11px tahoma, arial, verdana, sans-serif;color:black;text-decoration:none;text-align:right} \n";j+="table.x-datepicker-inner .x-datepicker-selected a{background:repeat-x left top;background-color:#d8d8d8;border:1px solid #b2aaa9} \n";j+="table.x-datepicker-inner .x-datepicker-selected span{font-weight:bold} \n";j+="table.x-datepicker-inner .x-datepicker-today a{border:1px solid;border-color:darkred} \n";j+="table.x-datepicker-inner .x-datepicker-prevday a,table.x-datepicker-inner .x-datepicker-nextday a{text-decoration:none !important;color:#aaa} \n";j+="table.x-datepicker-inner a:hover,table.x-datepicker-inner .x-datepicker-disabled a:hover{text-decoration:none !important;color:#000;background-color:transparent} \n";j+="table.x-datepicker-inner .x-datepicker-disabled a{cursor:default;background-color:#eee;color:#bbb} \n";j+=".x-item-disabled .x-datepicker-inner a:hover{background:none} \n";j+=".x-monthpicker-item a{display:block;margin:0 5px 0 5px;text-decoration:none;color:#523a39;border:1px solid white;line-height:17px} \n";j+=".x-monthpicker-item a:hover{background-color:transparent} \n";j+=".x-color-picker a{border:1px solid #fff;float:left;padding:2px;text-decoration:none;-moz-outline:0 none;outline:0 none;cursor:pointer} \n";j+=".x-color-picker a:hover,.x-color-picker a.x-color-picker-selected{border-color:#8bb8f3;background-color:#deecfd} \n";j+=".x-color-picker em span{cursor:pointer;display:block;height:10px;width:10px;line-height:10px} \n";j+=".x-menu-body{user-select:none;-o-user-select:none;-ms-user-select:none;-moz-user-select:-moz-none;-webkit-user-select:none;cursor:default;background:#f0f0f0 !important;padding:2px} \n";j+=".x-menu-focus{display:block;position:absolute;top:-10px;left:-10px;width:0px;height:0px} \n";j+=".x-menu-item{white-space:nowrap;overflow:hidden;z-index:1} \n";j+=".x-menu-item-link{display:block;margin:1px;padding:6px 2px 3px 32px;text-decoration:none !important;line-height:16px;cursor:default} \n";j+=".x-opera .x-menu-item-link{position:relative} \n";j+=".x-menu-item-icon{width:16px;height:16px;position:absolute;top:5px;left:4px;background:no-repeat center center} \n";j+=".x-menu-item-text{font-size:11px;color:#222222} \n";j+=".x-menu-item-active .x-menu-item-link{background-image:none;background-color:#e6e6e6;background-image:-webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #eeeeee), color-stop(100%, #dcdcdc));background-image:-webkit-linear-gradient(top, #eeeeee,#dcdcdc);background-image:-moz-linear-gradient(top, #eeeeee,#dcdcdc);background-image:-o-linear-gradient(top, #eeeeee,#dcdcdc);background-image:-ms-linear-gradient(top, #eeeeee,#dcdcdc);background-image:linear-gradient(top, #eeeeee,#dcdcdc);margin:0px;border:1px solid #9d9d9d;cursor:pointer;-moz-border-radius:3px;-webkit-border-radius:3px;-o-border-radius:3px;-ms-border-radius:3px;-khtml-border-radius:3px;border-radius:3px} \n";j+=".x-menu-item-disabled{filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=50);opacity:0.5} \n";j+=".x-ie6 .x-menu-item-link,.x-ie7 .x-menu-item-link,.x-quirks .x-ie8 .x-menu-item-link{padding-bottom:2px} \n";j+='.x-nlg .x-menu-item-active .x-menu-item-link{background:#e6e6e6 repeat-x left top;background-image:url("images/menu-item-active-bg.gif")} \n';j+=".x-unselectable{user-select:none;-o-user-select:none;-ms-user-select:none;-moz-user-select:-moz-none;-webkit-user-select:none;cursor:default} \n";j+=".x-grid-row-editor .x-panel-body{background-color:#ebe6e6;border-top:1px solid #d0d0d0 !important;border-bottom:1px solid #d0d0d0 !important} \n";j+=".x-webkit *:focus{outline:none !important} \n";j+=".x-ie .x-fieldset-noborder legend span{position:absolute;left:16px} \n";j+=".x-panel,.x-plain{overflow:hidden;position:relative} \n";j+=".x-panel-header{padding:5px 4px 4px 5px} \n";j+=".x-panel-header-horizontal .x-panel-header-body,.x-panel-header-horizontal .x-window-header-body,.x-panel-header-horizontal .x-btn-group-header-body,.x-window-header-horizontal .x-panel-header-body,.x-window-header-horizontal .x-window-header-body,.x-window-header-horizontal .x-btn-group-header-body,.x-btn-group-header-horizontal .x-panel-header-body,.x-btn-group-header-horizontal .x-window-header-body,.x-btn-group-header-horizontal .x-btn-group-header-body{width:100%} \n";j+=".x-panel-header-text-container{overflow:hidden;-o-text-overflow:ellipsis;text-overflow:ellipsis} \n";j+=".x-panel-header-text{user-select:none;-o-user-select:none;-ms-user-select:none;-moz-user-select:-moz-none;-webkit-user-select:none;cursor:default;white-space:nowrap} \n";j+=".x-panel-body{overflow:hidden;position:relative;font-size:12px} \n";j+=".x-panel-collapsed .x-panel-header-collapsed-border-top{border-bottom-width:1px !important} \n";j+=".x-panel-default{border-color:#d0d0d0} \n";j+=".x-panel-header-default{font-size:11px;line-height:15px;border-color:#d0d0d0;border-width:1px;border-style:solid;background-image:none;background-color:#d7d2d2;background-image:-webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #f0f0f0), color-stop(100%, #d7d7d7));background-image:-webkit-linear-gradient(top, #f0f0f0,#d7d7d7);background-image:-moz-linear-gradient(top, #f0f0f0,#d7d7d7);background-image:-o-linear-gradient(top, #f0f0f0,#d7d7d7);background-image:-ms-linear-gradient(top, #f0f0f0,#d7d7d7);background-image:linear-gradient(top, #f0f0f0,#d7d7d7);-moz-box-shadow:#efeded 0 1px 0px 0 inset;-webkit-box-shadow:#efeded 0 1px 0px 0 inset;-o-box-shadow:#efeded 0 1px 0px 0 inset;box-shadow:#efeded 0 1px 0px 0 inset} \n";j+=".x-panel-header-text-default{color:#333333;font-size:11px;font-weight:bold;font-family:tahoma, arial, verdana, sans-serif} \n";j+=".x-panel-collapsed .x-window-header-default,.x-panel-collapsed .x-panel-header-default{border-color:#d0d0d0} \n";j+=".x-panel-collapsed .x-panel-header-default-top{-moz-border-radius-bottomleft:null;-webkit-border-bottom-left-radius:null;-o-border-bottom-left-radius:null;-ms-border-bottom-left-radius:null;-khtml-border-bottom-left-radius:null;border-bottom-left-radius:null;-moz-border-radius-bottomright:null;-webkit-border-bottom-right-radius:null;-o-border-bottom-right-radius:null;-ms-border-bottom-right-radius:null;-khtml-border-bottom-right-radius:null;border-bottom-right-radius:null} \n";j+=".x-panel-header-default-top{-moz-box-shadow:#efeded 0 1px 0px 0 inset;-webkit-box-shadow:#efeded 0 1px 0px 0 inset;-o-box-shadow:#efeded 0 1px 0px 0 inset;box-shadow:#efeded 0 1px 0px 0 inset} \n";j+=".x-tip-header a,.x-tip-body a,.x-form-invalid-tip-body a{color:#2a2a2a} \n";j+=".x-toolbar-footer .x-box-inner{border-width:0} \n";j+=".x-window-default{-moz-border-radius-topleft:5px; -webkit-border-top-left-radius:5px; -o-border-top-left-radius:5px; -ms-border-top-left-radius:5px; -khtml-border-top-left-radius:5px; border-top-left-radius:5px; -moz-border-radius-topright:5px; -webkit-border-top-right-radius:5px; -o-border-top-right-radius:5px; -ms-border-top-right-radius:5px; -khtml-border-top-right-radius:5px; border-top-right-radius:5px; -moz-border-radius-bottomright:5px; -webkit-border-bottom-right-radius:5px; -o-border-bottom-right-radius:5px; -ms-border-bottom-right-radius:5px; -khtml-border-bottom-right-radius:5px; border-bottom-right-radius:5px; -moz-border-radius-bottomleft:5px; -webkit-border-bottom-left-radius:5px; -o-border-bottom-left-radius:5px; -ms-border-bottom-left-radius:5px; -khtml-border-bottom-left-radius:5px; border-bottom-left-radius:5px; -moz-box-shadow:#ebe7e7 0 1px 0px 0 inset, #ebe7e7 0 -1px 0px 0 inset, #ebe7e7 -1px 0 0px 0 inset, #ebe7e7 1px 0 0px 0 inset; -webkit-box-shadow:#ebe7e7 0 1px 0px 0 inset, #ebe7e7 0 -1px 0px 0 inset, #ebe7e7 -1px 0 0px 0 inset, #ebe7e7 1px 0 0px 0 inset; -o-box-shadow:#ebe7e7 0 1px 0px 0 inset, #ebe7e7 0 -1px 0px 0 inset, #ebe7e7 -1px 0 0px 0 inset, #ebe7e7 1px 0 0px 0 inset; box-shadow:#ebe7e7 0 1px 0px 0 inset, #ebe7e7 0 -1px 0px 0 inset, #ebe7e7 -1px 0 0px 0 inset, #ebe7e7 1px 0 0px 0 inset; padding:4px 4px 4px 4px; border-color:#a9a9a9; border-width:1px; border-style:solid; background-color:#e8e8e8; } \n";j+=".x-window{outline:none} \n";j+=".x-window-header-default { border-color: #a9a9a9; zoom: 1; } \n";j+=".x-window-header-default-top { box-shadow: #ebe7e7 0 1px 0px 0 inset, #ebe7e7 -1px 0 0px 0 inset, #ebe7e7 1px 0 0px 0 inset; border-bottom-left-radius: 0; padding: 5px 5px 0 5px; border-width: 1px; border-style: solid; background-color: #e8e8e8; } \n";j+=".x-window .x-window-wrap .x-window-body{overflow:hidden} \n";j+=".x-window-body-default{border-color:#bcb1b0;border-width:1px;background:#e0e0e0;color:black} \n";j+=".x-window-body{position:relative;border-style:solid} \n";j+=".x-message-box .x-window-body{background-color:#e8e8e8;border:none} \n";j+=".x-tab-bar-bottom .x-tab-bar-body .x-box-inner{position:relative;top:-1px} \n";j+=".x-tab-bar-bottom .x-tab-bar-body-default-plain .x-box-inner{position:relative;top:-1px} \n";j+=".x-tab *{cursor:pointer;cursor:hand} \n";j+=".x-tab-default-disabled *{cursor:default} \n";j+=".x-tab button,.x-tab a{position:relative} \n";j+=".x-grid-tree-loading span{font-style:italic;color:#444444} \n";j+=".x-proxy-el{position:absolute;background:#b4b4b4;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=80);opacity:0.8} \n";j+=".x-docked{position:absolute;z-index:1} \n";j+=".x-docked-top{border-bottom-width:0 !important} \n";j+=".x-box-inner{overflow:hidden;zoom:1;position:relative;left:0;top:0} \n";j+=".x-box-item{position:absolute !important;left:0;top:0} \n";j+=".x-box-layout-ct,.x-border-layout-ct{overflow:hidden;zoom:1} \n";j+=".x-inline-children > *{display:inline-block !important} \n";j+=".x-tool{height:15px} \n";j+='.x-tool img{overflow:hidden;width:15px;height:15px;cursor:pointer;background-color:transparent;background-repeat:no-repeat;background-image:url("images/tool-sprites.gif");margin:0} \n';j+=".x-panel-header-horizontal .x-tool,.x-window-header-horizontal .x-tool{margin-left:2px} \n";j+=".x-tool-expand-bottom,.x-tool-collapse-bottom{background-position:0 -195px} \n";j+=".x-tool-expand-top,.x-tool-collapse-top{background-position:0 -210px} \n";j+=".x-html html,.x-html address,.x-html blockquote,.x-html body,.x-html dd,.x-html div,.x-html dl,.x-html dt,.x-html fieldset,.x-html form,.x-html frame,.x-html frameset,.x-html h1,.x-html h2,.x-html h3,.x-html h4,.x-html h5,.x-html h6,.x-html noframes,.x-html ol,.x-html p,.x-html ul,.x-html center,.x-html dir,.x-html hr,.x-html menu,.x-html pre{display:block} \n";j+=".x-html :before,.x-html :after{white-space:pre-line} \n";j+=".x-html :link,.x-html :visited{text-decoration:underline} \n";j+=".x-panel-header-draggable,.x-panel-header-draggable .x-panel-header-text,.x-window-header-draggable,.x-window-header-draggable .x-window-header-text,.x-tip-header-draggable .x-tip-header-text { cursor:move; } \n";j+=".x-panel-header-vertical,.x-panel-header-vertical .x-panel-header-body,.x-btn-group-header-vertical,.x-btn-group-header-vertical .x-btn-group-header-body,.x-window-header-vertical,.x-window-header-vertical .x-window-header-body,.x-html button,.x-html textarea,.x-html input,.x-html select { display:inline-block; } \n";j+=".x-window-header-text { user-select:none; -o-user-select:none; -ms-user-select:none; -moz-user-select:0; -webkit-user-select:none; cursor:default; white-space:nowrap; display:block; } \n";j+=".x-box-inner { zoom: 1; } \n";j+=".x-panel-defaultÃ‚ { border-color: #d0d0d0; } \n";j+=".x-panel { overflow: hidden; } \n";j+=".x-panel-body { overflow: hidden; position: relative; } \n";j+=".x-panel-body, .x-window-body * { font-size: 11px; } \n";j+=".x-panel-header-default { line-height: 15px; border-color: #d0d0d0; border-width: 1px; border-style: solid; } \n";j+=".x-panel-header { height: 30px; padding: 7px 4px 4px 7px; border: 0 none; } \n";j+=".x-panel-header-text-default { color: #333333; font-weight: bold; } \n";j+=".x-panel-header-text { -webkit-user-select: none; cursor: default; white-space: nowrap; } \n";j+=".x-box-itemÃ‚ { position: absolute !important; } \n";j+=".x-unselectable { -webkit-user-select: none; cursor: default; } \n";j+=".x-docked { position: absolute; z-index: 1; } \n";j+=".x-docked-top { border-bottom-width: 0 !important; } \n";j+=".gis-container-default .x-window-body { padding: 5px; background: #fff; } \n";j+=".olControlPanel { position: absolute; top: 0; right: 0; border: 0 none; } \n";j+='.olControlButtonItemActive { background: #556; color: #fff; width: 24px; height: 24px; opacity: 0.75; filter: alpha(opacity=75); -ms-filter: "alpha(opacity=75)"; cursor: pointer; cursor: hand; text-align: center; font-size: 21px !important; text-shadow: 0 0 1px #ddd; } \n';j+=".olControlPanel.zoomIn { right: 76px; top: 4px; } \n";j+=".olControlPanel.zoomIn .olControlButtonItemActive { border-top-left-radius: 3px; border-bottom-left-radius: 3px; } \n";j+=".olControlPanel.zoomOut { right: 52px; top: 4px; } \n";j+=".olControlPanel.zoomVisible { right: 28px; top: 4px; } \n";j+=".olControlPanel.legend { right: 4px; top: 4px; } \n";j+=".olControlPanel.legend .olControlButtonItemActive { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } \n";j+=".olControlPanel.zoomIn-vertical { right: 4px; top: 4px; } \n";j+=".olControlPanel.zoomIn-vertical .olControlButtonItemActive { border-top-left-radius: 3px; border-top-right-radius: 3px; } \n";j+=".olControlPanel.zoomOut-vertical { right: 4px; top: 28px; } \n";j+=".olControlPanel.zoomVisible-vertical { right: 4px; top: 52px; } \n";j+=".olControlPanel.legend-vertical { right: 4px; top: 76px; } \n";j+=".olControlPanel.legend-vertical .olControlButtonItemActive { border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; } \n";j+=".olControlPermalink { display: none !important; } \n";j+='.olControlMousePosition { background: #fff !important; line-height: 14px; opacity: 0.8 !important; filter: alpha(opacity=80) !important; -ms-filter: "alpha(opacity=80)" !important; right: 0 !important; bottom: 0 !important; border-top-left-radius: 2px !important; padding: 2px 2px 1px 5px !important; color: #000 !important; -webkit-text-stroke-width: 0.1px; -webkit-text-stroke-color: #555; } \n';j+=".olControlMousePosition * { font-size: 10px !important; } \n";j+=".text-mouseposition-lonlat { color: #555; } \n";j+=".olLayerGoogleCopyright, .olLayerGoogleV3.olLayerGooglePoweredBy { display: none; } \n";j+='.google-logo { background: url("'+g.contextPath+'/dhis-web-commons/javascripts/plugin/images/google-logo.png") no-repeat; width: 40px; height: 13px; margin-left: 6px; display: inline-block; vertical-align: bottom; cursor: pointer; cursor: hand; } \n';j+='.google-logo-small { background: url("'+g.contextPath+'/dhis-web-commons/javascripts/plugin/images/google-logo-small.png") no-repeat; width: 13px; height: 13px; margin-left: 4px; display: inline-block; vertical-align: bottom; cursor: pointer; cursor: hand; } \n';j+=".olControlScaleLine { left: 5px !important; bottom: 5px !important; } \n";j+=".olControlScaleLineBottom { display: none; } \n";j+=".olControlScaleLineTop { font-weight: bold; } \n";j+=".x-mask-msg { padding: 0; border: 0 none; background-image: none; background-color: transparent; } \n";j+=".x-mask-msg div { background-position: 11px center; } \n";j+=".x-mask-msg .x-mask-loading { border: 0 none; background-color: #000; color: #fff; border-radius: 2px; padding: 12px 14px 12px 30px; opacity: 0.65; } \n";j+=".gis-window-widget-feature { padding: 0; border: 0 none; border-radius: 0; background: transparent; box-shadow: none; } \n";j+=".gis-window-widget-feature .x-window-body-default { border: 0 none; background: transparent; } \n";j+='.gis-window-widget-feature .x-window-body-default .x-panel-body-default { border: 0 none; background: #556; opacity: 0.92; filter: alpha(opacity=92); -ms-filter: "alpha(opacity=92)"; padding: 5px 8px 4px 8px; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; color: #fff; font-weight: bold; letter-spacing: 1px; } \n';j+=".x-menu-body { border:1px solid #bbb; border-radius: 2px; padding: 0; background-color: #fff !important; } \n";j+=".x-menu-item-active .x-menu-item-link {	border-radius: 0; border-color: #e1e1e1; background-color: #e1e1e1; background-image: none; } \n";j+=".x-menu-item-link { padding: 4px 5px 4px 26px; } \n";j+=".x-menu-item-text { color: #111; } \n";j+=".disabled { opacity: 0.4; cursor: default !important; } \n";j+=".el-opacity-1 { opacity: 1 !important; } \n";j+=".el-border-0, .el-border-0 .x-panel-body { border: 0 none !important; } \n";j+=".el-fontsize-10 { font-size: 10px !important; } \n";j+=".gis-grid-row-icon-disabled * { cursor: default !important; } \n";j+=".gis-toolbar-btn-menu { margin-top: 4px; } \n";j+=".gis-toolbar-btn-menu .x-panel-body-default { border-radius: 2px; border-color: #999; } \n";j+=".gis-grid .link, .gis-grid .link * { cursor: pointer; cursor: hand; color: blue; text-decoration: underline; } \n";j+=".gis-menu-item-icon-drill, .gis-menu-item-icon-float { left: 6px; } \n";j+=".gis-menu-item-first.x-menu-item-active .x-menu-item-link {	border-radius: 0; border-top-left-radius: 2px; border-top-right-radius: 2px; } \n";j+=".gis-menu-item-last.x-menu-item-active .x-menu-item-link { border-radius: 0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } \n";j+='.gis-menu-item-icon-drill { background: url("'+g.contextPath+'/dhis-web-commons/javascripts/plugin/images/drill_16.png") no-repeat; } \n';j+='.gis-menu-item-icon-float { background: url("'+g.contextPath+'/dhis-web-commons/javascripts/plugin/images/float_16.png") no-repeat; } \n';j+=".x-color-picker a { padding: 0; } \n";j+=".x-color-picker em span { width: 14px; height: 14px; } \n";j+=".gis-panel-legend .x-panel-header { height: 23px; background: #f1f1f1; padding: 4px 4px 0 5px} \n";j+=".gis-panel-legend .x-panel-header .x-panel-header-text { font-size: 10px; } \n";j+=".ns-plugin-alert { width: 90%; padding: 5%; color: #777 } \n";Ext.util.CSS.createStyleSheet(j)};e=function(n){var p,m,k,o,j,l;p=function(){if(!Ext.isString(n.url)){alert("Invalid url ("+n.el+")");return}if(n.url.split("").pop()==="/"){n.url=n.url.substr(0,n.url.length-1)}if(!Ext.isString(n.el)){alert("Invalid html element id ("+n.el+")");return}n.id=n.id||n.uid;if(n.id&&!Ext.isString(n.id)){alert("Invalid map id ("+n.el+")");return}return true};m=function(x,z){var y=x.init,s=x.api,t=x.conf,w=x.store,r=x.util,v="json",u={json:"application/json"},q={"Content-Type":u[v],Accepts:u[v]};y.el=n.el;x.plugin=z.plugin;x.dashboard=z.dashboard;x.crossDomain=z.crossDomain;x.skipMask=z.skipMask;x.skipFade=z.skipFade;x.el=z.el;x.username=z.username;x.password=z.password;x.ajax=r.connection.ajax;w.groupsByGroupSet=Ext.create("Ext.data.Store",{fields:["id","name","symbol"]})};k=function(y){var t,v=[],x,q,u,s=Ext.get(l.el),r=l.map.hideLegend?0:(y.plugin?120:200),w=[];if(y.dashboard){v.push(x=Ext.create("Ext.panel.Panel",{region:"north",width:s.getWidth(),height:19,bodyStyle:"background-color: #fff; border: 0 none; font: bold 12px LiberationSans, arial, sans-serif; color: #333; text-align: center; line-height: 14px; letter-spacing: -0.1px",html:""}))}v.push(q=new GeoExt.MapPanel({region:"center",map:l.olmap,bodyStyle:"border: 1px solid #d0d0d0",width:s.getWidth()-r}));if(y.dashboard){v.push(u=Ext.create("Ext.panel.Panel",{width:0,height:0}))}else{v.push(u=Ext.create("Ext.panel.Panel",{region:"east",layout:"anchor",bodyStyle:"border-top:0 none; border-bottom:0 none",width:r,preventHeader:true,defaults:{bodyStyle:"padding: 6px; border: 0 none",collapsible:true,collapsed:true,animCollapse:false},items:[{title:GIS.i18n.thematic_layer_1_legend,cls:"gis-panel-legend",bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){l.layer.thematic1.legendPanel=this}}},{title:GIS.i18n.thematic_layer_2_legend,cls:"gis-panel-legend",bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){l.layer.thematic2.legendPanel=this}}},{title:GIS.i18n.thematic_layer_3_legend,cls:"gis-panel-legend",bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){l.layer.thematic3.legendPanel=this}}},{title:GIS.i18n.thematic_layer_4_legend,cls:"gis-panel-legend",bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){l.layer.thematic4.legendPanel=this}}},{title:GIS.i18n.facility_layer_legend,cls:"gis-panel-legend",bodyStyle:"padding:3px 0 4px 5px; border-width:1px 0 1px 0; border-color:#d0d0d0;",listeners:{added:function(){l.layer.facility.legendPanel=this}}}]}))}t=Ext.create("Ext.panel.Panel",{renderTo:s,width:s.getWidth(),height:s.getHeight(),cls:"gis-plugin",layout:"border",bodyStyle:"border: 0 none",items:v,listeners:{afterrender:function(){o()}}});t.northRegion=x;t.centerRegion=q;t.eastRegion=u;t.centerRegion.trash=w;t.centerRegion.getEl().on("mouseleave",function(){for(var z=0,A;z<w.length;z++){A=t.centerRegion.trash[z];if(A&&A.destroy){A.destroy()}}});return t};o=function(r){var x=["zoomInButton","zoomIn-verticalButton","zoomOutButton","zoomOut-verticalButton","zoomVisibleButton","zoomVisible-verticalButton","measureButton","measure-verticalButton","legendButton","legend-verticalButton"],q={"zoomIn-verticalButton":"zoomin_24.png","zoomOut-verticalButton":"zoomout_24.png","zoomVisible-verticalButton":"zoomvisible_24.png","measure-verticalButton":"measure_24.png","legend-verticalButton":"legend_24.png",zoomInButton:"zoomin_24.png",zoomOutButton:"zoomout_24.png",zoomVisibleButton:"zoomvisible_24.png",measureButton:"measure_24.png",legendButton:"legend_24.png"};for(var w=0,y,u;w<x.length;w++){y=x[w];u=Ext.query("."+y);for(var v=0,t;v<u.length;v++){t=u[v];if(t){t.innerHTML='<img src="'+g.contextPath+"/dhis-web-commons/javascripts/plugin/images/"+q[y]+'" />'}}}if(Ext.isDefined(l.map.baseLayer)){var s=Ext.isString(l.map.baseLayer)?l.map.baseLayer.split(" ").join("").toLowerCase():l.map.baseLayer;if(!s||s==="none"||s==="off"){l.layer.openStreetMap.setVisibility(false)}else{if(s==="gh"||s==="googlehybrid"){l.olmap.setBaseLayer(l.layer.googleHybrid)}else{if(s==="osm"||s==="openstreetmap"){l.olmap.setBaseLayer(l.layer.openStreetMap)}}}}};j=function(){var s=Ext.get(n.el),q;if(!p()){return}q={plugin:true,dashboard:Ext.isBoolean(n.dashboard)?n.dashboard:false,crossDomain:Ext.isBoolean(n.crossDomain)?n.crossDomain:true,skipMask:Ext.isBoolean(n.skipMask)?n.skipMask:false,skipFade:Ext.isBoolean(n.skipFade)?n.skipFade:false,el:Ext.isString(n.el)?n.el:null,username:Ext.isString(n.username)?n.username:null,password:Ext.isString(n.password)?n.password:null};c();l=GIS.core.getInstance(g,q);m(l,q);var r=function(){var t=new OpenLayers.Layer.Google("Google Streets",{numZoomLevels:20,animationEnabled:true,layerType:l.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(v){if(v){this.layerOpacity=parseFloat(v)}this.setOpacity(this.layerOpacity)}});t.id="googleStreets";var u=new OpenLayers.Layer.Google("Google Hybrid",{type:google.maps.MapTypeId.HYBRID,numZoomLevels:20,animationEnabled:true,layerType:l.conf.finals.layer.type_base,layerOpacity:1,setLayerOpacity:function(v){if(v){this.layerOpacity=parseFloat(v)}this.setOpacity(this.layerOpacity)}});u.id="googleHybrid";l.olmap.addLayers([t,u]);if(n.baseLayer==="osm"){l.olmap.setBaseLayer(l.layer.openStreetMap)}else{if(n.baseLayer==="gh"){l.olmap.setBaseLayer(u)}else{l.olmap.setBaseLayer(t)}}};if(GIS_GM.ready){console.log("(Item "+n.el+") GM is ready -> skip queue, add layers, set as baselayer");r()}else{if(GIS_GM.offline){console.log("Deactivate base layer");l.olmap.baseLayer.setVisibility(false)}else{console.log("GM is not ready -> add to queue");GIS_GM.array.push({scope:this,fn:r})}}GIS.core.createSelectHandlers(l,l.layer.boundary);GIS.core.createSelectHandlers(l,l.layer.thematic1);GIS.core.createSelectHandlers(l,l.layer.thematic2);GIS.core.createSelectHandlers(l,l.layer.thematic3);GIS.core.createSelectHandlers(l,l.layer.thematic4);GIS.core.createSelectHandlers(l,l.layer.facility);l.map=n;l.viewport=k(q);if(s){s.setViewportWidth=function(t){l.viewport.setWidth(t);l.viewport.centerRegion.setWidth(t);if(l.viewport.northRegion){l.viewport.northRegion.setWidth(t)}}}l.olmap.mask=Ext.create("Ext.LoadMask",l.viewport.centerRegion.getEl(),{msg:"Loading"});GIS.core.MapLoader(l,n).load()}()};GIS.plugin.getMap=function(j){if(Ext.isString(j.url)&&j.url.split("").pop()==="/"){j.url=j.url.substr(0,j.url.length-1)}if(b){e(j)}else{f.push(j);if(!h){h=true;GIS_GM={ready:false,offline:false,array:[]};GIS_GM_fn=function(){console.log("GM called back, queue length: "+GIS_GM.array.length);GIS_GM.ready=true;for(var k=0,l;k<GIS_GM.array.length;k++){l=GIS_GM.array[k];if(l){console.log("Running queue obj "+(k+1));l.fn.call(l.scope)}}};if(!Ext.Array.contains(["osm","none"],j.baseLayer)){Ext.Loader.injectScriptElement("//maps.googleapis.com/maps/api/js?callback=GIS_GM_fn",function(){console.log("GM available (online)")},function(){console.log("GM not available (offline)");GIS_GM.offline=true})}a(j)}}};DHIS=Ext.isObject(window.DHIS)?DHIS:{};DHIS.getMap=GIS.plugin.getMap});