/*
 * Tine 2.0 - Tinebase 
 * Copyright (c) 2007-2012 Metaways Infosystems GmbH (http://www.metaways.de)
 * http://www.gnu.org/licenses/agpl.html AGPL Version 3
 */
Ext.override(Ext.data.Store,{indexOfId:function(a){return this.data.indexOfKey(String(a))}});Ext.apply(Ext.form.HtmlEditor.prototype,{fixKeys:function(){if(Ext.isIE){return function(f){var a=f.getKey(),d=this.getDoc(),b;if(a==f.TAB){f.stopEvent();b=d.selection.createRange();if(b){b.collapse(true);b.pasteHTML("&nbsp;&nbsp;&nbsp;&nbsp;");this.deferFocus()}}else{if(a==f.ENTER){b=d.selection.createRange();if(b){var c=b.parentElement();if(!c||c.tagName.toLowerCase()!="li"){f.stopEvent();b.pasteHTML("<br />");b.collapse(false);b.select()}}}}}}else{if(Ext.isOpera){return function(b){var a=b.getKey();if(a==b.TAB){b.stopEvent();this.win.focus();this.execCmd("InsertHTML","&nbsp;&nbsp;&nbsp;&nbsp;");this.deferFocus()}}}else{if(Ext.isWebKit){return function(b){var a=b.getKey();if(a==b.TAB){b.stopEvent();this.execCmd("InsertText","\t");this.deferFocus()}}}}}}()});Ext.apply(Ext.form.VTypes,{emailFixed:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:([^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]|-)+\.)*[^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]([^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]|-){0,66})\.([^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]{2,6}?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,urlFixed:/(((^https?)|(^ftp)):\/\/(([^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]|-)+\.)+[^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]{2,3}(\/([^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]|-|%)+(\.[^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]{2,})?)*((([^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]|[\-\.\?\\\/+@&#;`~=%!])*)(\.[^\s,\x00-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x7F]{2,})?)*\/?)/i,email:function(a){return this.emailFixed.test(a)},url:function(a){return this.urlFixed.test(a)}});Ext.override(Ext.form.TextField,{validator:function(a){return this.allowBlank!==false||Ext.util.Format.trim(a).length>0}});Ext.applyIf(Ext.tree.MultiSelectionModel.prototype,{getSelectedNode:function(){var a=this.getSelectedNodes();return Ext.isArray(a)?a[0]:null}});Ext.form.DateField.prototype.setValue=function(b){if(Ext.isString(b)){var a=Date.parseDate(b,Date.patterns.ISO8601Long);if(Ext.isDate(a)){b=a}else{b=Ext.form.DateField.prototype.parseDate.call(this,b)}}this.fullDateTime=b;Ext.form.DateField.superclass.setValue.call(this,this.formatDate(this.parseDate(b)))};Ext.form.DateField.prototype.getValue=function(){var a=this.fullDateTime;return a||""};Ext.form.TimeField.prototype.setValue=function(a){this.fullDateTime=a;Ext.form.TimeField.superclass.setValue.call(this,this.formatDate(this.parseDate(a)))};Ext.form.TimeField.prototype.getValue=function(){var a=this.fullDateTime;return a?this.parseDate(a).dateFormat("H:i"):""};Ext.grid.GridPanel.prototype.applyState=Ext.grid.GridPanel.prototype.applyState.createInterceptor(function(c){var a=this.colModel,b=c.sort;if(b&&a.getIndexById(b.field)<0){delete c.sort}});Date.parseIso=function(a){return Date.parseDate(a.replace(/\+\d{2}\d{2}/,""),"Y-m-d\\Th:i:s")};Ext.Window.prototype.rename=function(a){var b=this.manager||Ext.WindowMgr;b.unregister(this);this.id=a;b.register(this)};Ext.ButtonToggleMgr=function(){var a={};function b(f,j){if(j){var h=a[f.toggleGroup];for(var d=0,c=h.length;d<c;d++){if(h[d]!=f){h[d].toggle(false)}}}}return{register:function(c){if(!c.toggleGroup){return}var d=a[c.toggleGroup];if(!d){d=a[c.toggleGroup]=[]}d.push(c);c.on("toggle",b)},unregister:function(c){if(!c.toggleGroup){return}var d=a[c.toggleGroup];if(d){d.remove(c);c.un("toggle",b)}},getSelected:function(f,j,h){var k=a[f];for(var d=0,c=k.length;d<c;d++){if(k[d].pressed===true){if(j){j.call(h||k[d],k[d])}return k[d]}}return}}}();Ext.data.Store.prototype.loadRecords=Ext.data.Store.prototype.loadRecords.createInterceptor(function(c,a,b){return this.fireEvent("beforeloadrecords",c,a,b,this)});
/*
 * Ext JS Library 3.2.1
 * Copyright(c) 2006-2010 Ext JS, Inc.
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.ux.Portal=Ext.extend(Ext.Panel,{layout:"column",autoScroll:true,cls:"x-portal",defaultType:"portalcolumn",initComponent:function(){Ext.ux.Portal.superclass.initComponent.call(this);this.addEvents({validatedrop:true,beforedragover:true,dragover:true,beforedrop:true,drop:true})},initEvents:function(){Ext.ux.Portal.superclass.initEvents.call(this);this.dd=new Ext.ux.Portal.DropZone(this,this.dropConfig)},beforeDestroy:function(){if(this.dd){this.dd.unreg()}Ext.ux.Portal.superclass.beforeDestroy.call(this)}});Ext.reg("portal",Ext.ux.Portal);Ext.ux.Portal.DropZone=Ext.extend(Ext.dd.DropTarget,{constructor:function(a,b){this.portal=a;Ext.dd.ScrollManager.register(a.body);Ext.ux.Portal.DropZone.superclass.constructor.call(this,a.bwrap.dom,b);a.body.ddScrollConfig=this.ddScrollConfig},ddScrollConfig:{vthresh:50,hthresh:-1,animate:true,increment:200},createEvent:function(a,f,d,b,h,g){return{portal:this.portal,panel:d.panel,columnIndex:b,column:h,position:g,data:d,source:a,rawEvent:f,status:this.dropAllowed}},notifyOver:function(z,v,A){var f=v.getXY(),a=this.portal,q=z.proxy;if(!this.grid){this.grid=this.getGrid()}var b=a.body.dom.clientWidth;if(!this.lastCW){this.lastCW=b}else{if(this.lastCW!=b){this.lastCW=b;a.doLayout();this.grid=this.getGrid()}}var d=0,m=this.grid.columnX,o=false;for(var u=m.length;d<u;d++){if(f[0]<(m[d].x+m[d].w)){o=true;break}}if(!o){d--}var s,l=false,j=0,w=a.items.itemAt(d),r=w.items.items,k=false;for(var u=r.length;j<u;j++){s=r[j];var t=s.el.getHeight();if(t===0){k=true}else{if((s.el.getY()+(t/2))>f[1]){l=true;break}}}j=(l&&s?j:w.items.getCount())+(k?-1:0);var g=this.createEvent(z,v,A,d,w,j);if(a.fireEvent("validatedrop",g)!==false&&a.fireEvent("beforedragover",g)!==false){q.getProxy().setWidth("auto");if(s){q.moveProxy(s.el.dom.parentNode,l?s.el.dom:null)}else{q.moveProxy(w.el.dom,null)}this.lastPos={c:w,col:d,p:k||(l&&s)?j:false};this.scrollPos=a.body.getScroll();a.fireEvent("dragover",g);return g.status}else{return g.status}},notifyOut:function(){delete this.grid},notifyDrop:function(m,h,g){delete this.grid;if(!this.lastPos){return}var k=this.lastPos.c,f=this.lastPos.col,l=this.lastPos.p,a=m.panel,b=this.createEvent(m,h,g,f,k,l!==false?l:k.items.getCount());if(this.portal.fireEvent("validatedrop",b)!==false&&this.portal.fireEvent("beforedrop",b)!==false){m.proxy.getProxy().remove();a.el.dom.parentNode.removeChild(m.panel.el.dom);if(l!==false){k.insert(l,a)}else{k.add(a)}k.doLayout();this.portal.fireEvent("drop",b);var o=this.scrollPos.top;if(o){var j=this.portal.body.dom;setTimeout(function(){j.scrollTop=o},10)}}delete this.lastPos},getGrid:function(){var a=this.portal.bwrap.getBox();a.columnX=[];this.portal.items.each(function(b){a.columnX.push({x:b.el.getX(),w:b.el.getWidth()})});return a},unreg:function(){Ext.dd.ScrollManager.unregister(this.portal.body);Ext.ux.Portal.DropZone.superclass.unreg.call(this)}});
/*
 * Ext JS Library 3.2.1
 * Copyright(c) 2006-2010 Ext JS, Inc.
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.ux.PortalColumn=Ext.extend(Ext.Container,{layout:"anchor",defaultType:"portlet",cls:"x-portal-column"});Ext.reg("portalcolumn",Ext.ux.PortalColumn);
/*
 * Ext JS Library 3.2.1
 * Copyright(c) 2006-2010 Ext JS, Inc.
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.ux.Portlet=Ext.extend(Ext.Panel,{anchor:"100%",frame:true,collapsible:true,draggable:true,cls:"x-portlet"});Ext.reg("portlet",Ext.ux.Portlet);if(!window.console){window.console={}}for(fn in {log:null,debug:null,info:null,warn:null,error:null,assert:null,dir:null,dirxml:null,group:null,groupEnd:null,time:null,timeEnd:null,count:null,trace:null,profile:null,profileEnd:null}){window.console[fn]=window.console[fn]||function(){}}Ext.BLANK_IMAGE_URL="library/ExtJS/resources/images/default/s.gif";Ext.SSL_SECURE_URL="library/ExtJS/resources/images/default/s.gif";Ext.chart.Chart.CHART_URL="library/ExtJS/resources/charts.swf";Ext.USE_NATIVE_JSON=!Ext.isIE;Ext.QuickTips.init();Ext.grid.ColumnModel.defaultRenderer=Ext.util.Format.htmlEncode;Ext.grid.Column.prototype.renderer=function(b){var a=Ext.util.Format.htmlEncode(b);return a};Ext.apply(Ext.data.JsonStore.prototype,{url:"index.php",root:"results",idProperty:"id",totalProperty:"totalcount"});Ext.form.ComboBox.prototype.initComponent=Ext.form.ComboBox.prototype.initComponent.createSequence(function(){if(this.expandOnFocus){this.lazyInit=false;this.on("focus",function(){this.onTriggerClick()})}if(this.blurOnSelect){this.on("select",function(){this.blur(true);this.fireEvent("blur",this)},this)}});Ext.form.ComboBox.prototype.triggerAction="all";Date.patterns={ISO8601Long:"Y-m-d H:i:s",ISO8601Short:"Y-m-d",ISO8601Time:"H:i:s",ShortDate:"n/j/Y",LongDate:"l, F d, Y",FullDateTime:"l, F d, Y g:i:s A",MonthDay:"F d",ShortTime:"g:i A",LongTime:"g:i:s A",SortableDateTime:"Y-m-d\\TH:i:s",UniversalSortableDateTime:"Y-m-d H:i:sO",YearMonth:"F, Y"};Ext.util.JSON.encodeDate=function(b){var a=function(c){return c<10?"0"+c:c};return'"'+b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())+'"'};Date.prototype.toJSON=function(a){var b=function(c){return c<10?"0"+c:c};return this.getFullYear()+"-"+b(this.getMonth()+1)+"-"+b(this.getDate())+" "+b(this.getHours())+":"+b(this.getMinutes())+":"+b(this.getSeconds())};Ext.util.Format=Ext.apply(Ext.util.Format,{euMoney:function(a){a.toString().replace(/,/,".");a=(Math.round(parseFloat(a)*100))/100;a=(a==Math.floor(a))?a+".00":((a*10==Math.floor(a*10))?a+"0":a);a=String(a);var f=a.split(".");var d=f[0];var b=f[1]?"."+f[1]:".00";var c=/(\d+)(\d{3})/;while(c.test(d)){d=d.replace(c,"$1.$2")}a=d+b;if(a.charAt(0)=="-"){return a.substr(1)+" -€"}return a+" €"},percentage:function(a){if(a===null){return"none"}if(!isNaN(a)){return a+" %"}},pad:function(b,a,f){if(!f){f="&nbsp;"}var d=a-b.length;for(var c=0;c<d;c++){b+=f}return b}});if(typeof Locale=="undefined"){var Locale=function(b,a){this._instance=true;this.LC_ALL="C";this.LC_COLLATE="C";this.LC_CTYPE="C";this.LC_MESSAGES="C";this.LC_MONETARY="C";this.LC_NUMERIC="C";this.LC_TIME="C";this.setlocale(b,a)}}Locale.VERSION="0.0.3";Locale.EXPORT=["LC_ALL","LC_COLLATE","LC_CTYPE","LC_MESSAGES","LC_MONETARY","LC_NUMERIC","LC_TIME"];Locale.EXPORT_OK=["setlocale"];Locale.EXPORT_TAGS={":common":Locale.EXPORT,":all":Locale.EXPORT.concat(Locale.EXPORT_OK)};Locale.prototype.TranslationLists={};Locale.LC_ALL="LC_ALL";Locale.LC_COLLATE="LC_COLLATE";Locale.LC_CTYPE="LC_CTYPE";Locale.LC_MESSAGES="LC_MESSAGES";Locale.LC_MONETARY="LC_MONETARY";Locale.LC_NUMERIC="LC_NUMERIC";Locale.LC_TIME="LC_TIME";Locale.setlocale=Locale.prototype.setlocale=function(b,a){return function(){if(a===null||typeof a=="undefined"){return this[b]}if(a==""){a=(window.navigator.browserLanguage||window.navigator.language||"C").replace(/^(.{2}).?(.{2})?.*$/,function(c,d,f){return d.toLowerCase()+(f?"_"+f.toUpperCase():"")})}switch(b){case Locale.LC_ALL:this.LC_ALL=a;this.LC_COLLATE=a;this.LC_CTYPE=a;this.LC_MESSAGES=a;this.LC_MONETARY=a;this.LC_NUMERIC=a;this.LC_TIME=a;break;case Locale.LC_COLLATE:case Locale.LC_CTYPE:case Locale.LC_MESSAGES:case Locale.LC_MONETARY:case Locale.LC_NUMERIC:case Locale.LC_TIME:this[b]=a;break;default:return false}return a}.call(this._instance?this:arguments.callee)};Locale.setlocale.LC_ALL="C";Locale.setlocale.LC_COLLATE="C";Locale.setlocale.LC_CTYPE="C";Locale.setlocale.LC_MESSAGES="C";Locale.setlocale.LC_MONETARY="C";Locale.setlocale.LC_NUMERIC="C";Locale.setlocale.LC_TIME="C";Locale.getTranslationData=function(b,a){var c="";if(Locale.prototype.TranslationLists[b]&&Locale.prototype.TranslationLists[b][a]){c=Locale.prototype.TranslationLists[b][a]}return c};Locale.getTranslationList=function(a){return Locale.prototype.TranslationLists[a]};Locale.Gettext=function(a){this.locale=typeof a=="string"?new Locale(Locale.LC_ALL,a):a||Locale;this.domain="messages";this.category=Locale.LC_MESSAGES;this.suffix="po";this.dir="."};Locale.Gettext.prototype.bindtextdomain=function(b,a){this.dir=a;this.domain=b};Locale.Gettext.prototype.textdomain=function(a){this.domain=a};Locale.Gettext.prototype.getmsg=function(d,c,b){var a=this._getkey(c,d);return Locale.Gettext.prototype._msgs[a]};Locale.Gettext.prototype._msgs={};Locale.Gettext.prototype._getkey=function(a,b){return this.dir+"/"+a+"/"+b};Locale.Gettext.prototype.dcgettext=function(c,b,a){var d=this.getmsg(c,a);return d?d.get(b)||b:b};Locale.Gettext.prototype.dcngettext=function(d,c,a,g,b){var f=this.getmsg(d,b);if(f){return(f.get(c,a)||[c,a])[f.plural(g)]||(g>1?a:c)}else{return g>1?a:c}};Locale.Gettext.prototype.dgettext=function(b,a){return this.dcgettext(b,a,this.category)};Locale.Gettext.prototype.dngettext=function(c,b,a,d){return this.dcngettext(c,b,a,d,this.category)};Locale.Gettext.prototype.gettext=Locale.Gettext.prototype._=Locale.Gettext.prototype._hidden=function(a){return this.dcgettext(this.domain,a,this.category)};Locale.Gettext.prototype.ngettext=Locale.Gettext.prototype.n_=Locale.Gettext.prototype.n_hidden=function(b,a,c){return this.dcngettext(this.domain,b,a,c,this.category)};Locale.Gettext.prototype.gettext_noop=Locale.Gettext.prototype.N_=function(a){return a};(function(){for(var a in Locale.Gettext.prototype){Locale.Gettext[a]=function(b){return function(){return b.apply(Locale.Gettext,arguments)}}(Locale.Gettext.prototype[a])}})();if(typeof Locale.Gettext.PO=="undefined"){Locale.Gettext.PO=function(a){if(typeof a=="string"||a instanceof String){this.msg=Locale.Gettext.PO.po2object(a)}else{if(a instanceof Object){this.msg=a}else{this.msg={}}}}}Locale.Gettext.PO.prototype.get=function(b,a){return typeof a!="undefined"?this.msg[b+", "+a]:this.msg[b]};Locale.Gettext.PO.prototype.plural=function(n){var nplurals,plural;eval((this.msg[""]+"Plural-Forms: nplurals=2; plural=n != 1\n").match(/Plural-Forms:(.*)\n/)[1]);return plural===true?1:plural===false?0:plural};Locale.Gettext.prototype._msgs.emptyDomain=new Locale.Gettext.PO(({}));var OpenLayers={singleFile:true};(function(){var j=(typeof OpenLayers=="object"&&OpenLayers.singleFile);window.OpenLayers={_scriptName:(!j)?"lib/OpenLayers.js":"OpenLayers.js",_getScriptLocation:function(){var s="";var u=new RegExp("(^|(.*?\\/))("+OpenLayers._scriptName+")(\\?|$)");var o=document.getElementsByTagName("script");for(var r=0,h=o.length;r<h;r++){var t=o[r].getAttribute("src");if(t){var q=t.match(u);if(q){s=q[1];break}}}return s}};if(!j){var k=new Array("OpenLayers/Util.js","OpenLayers/BaseTypes.js","OpenLayers/BaseTypes/Class.js","OpenLayers/BaseTypes/Bounds.js","OpenLayers/BaseTypes/Element.js","OpenLayers/BaseTypes/LonLat.js","OpenLayers/BaseTypes/Pixel.js","OpenLayers/BaseTypes/Size.js","OpenLayers/Console.js","OpenLayers/Tween.js","Rico/Corner.js","Rico/Color.js","OpenLayers/Ajax.js","OpenLayers/Events.js","OpenLayers/Request.js","OpenLayers/Request/XMLHttpRequest.js","OpenLayers/Projection.js","OpenLayers/Map.js","OpenLayers/Layer.js","OpenLayers/Icon.js","OpenLayers/Marker.js","OpenLayers/Marker/Box.js","OpenLayers/Popup.js","OpenLayers/Tile.js","OpenLayers/Tile/Image.js","OpenLayers/Tile/WFS.js","OpenLayers/Layer/Image.js","OpenLayers/Layer/SphericalMercator.js","OpenLayers/Layer/EventPane.js","OpenLayers/Layer/FixedZoomLevels.js","OpenLayers/Layer/Google.js","OpenLayers/Layer/VirtualEarth.js","OpenLayers/Layer/Yahoo.js","OpenLayers/Layer/HTTPRequest.js","OpenLayers/Layer/Grid.js","OpenLayers/Layer/MapGuide.js","OpenLayers/Layer/MapServer.js","OpenLayers/Layer/MapServer/Untiled.js","OpenLayers/Layer/KaMap.js","OpenLayers/Layer/KaMapCache.js","OpenLayers/Layer/MultiMap.js","OpenLayers/Layer/Markers.js","OpenLayers/Layer/Text.js","OpenLayers/Layer/WorldWind.js","OpenLayers/Layer/ArcGIS93Rest.js","OpenLayers/Layer/WMS.js","OpenLayers/Layer/WMS/Untiled.js","OpenLayers/Layer/ArcIMS.js","OpenLayers/Layer/GeoRSS.js","OpenLayers/Layer/Boxes.js","OpenLayers/Layer/XYZ.js","OpenLayers/Layer/TMS.js","OpenLayers/Layer/TileCache.js","OpenLayers/Popup/Anchored.js","OpenLayers/Popup/AnchoredBubble.js","OpenLayers/Popup/Framed.js","OpenLayers/Popup/FramedCloud.js","OpenLayers/Feature.js","OpenLayers/Feature/Vector.js","OpenLayers/Feature/WFS.js","OpenLayers/Handler.js","OpenLayers/Handler/Click.js","OpenLayers/Handler/Hover.js","OpenLayers/Handler/Point.js","OpenLayers/Handler/Path.js","OpenLayers/Handler/Polygon.js","OpenLayers/Handler/Feature.js","OpenLayers/Handler/Drag.js","OpenLayers/Handler/RegularPolygon.js","OpenLayers/Handler/Box.js","OpenLayers/Handler/MouseWheel.js","OpenLayers/Handler/Keyboard.js","OpenLayers/Control.js","OpenLayers/Control/Attribution.js","OpenLayers/Control/Button.js","OpenLayers/Control/ZoomBox.js","OpenLayers/Control/ZoomToMaxExtent.js","OpenLayers/Control/DragPan.js","OpenLayers/Control/Navigation.js","OpenLayers/Control/MouseDefaults.js","OpenLayers/Control/MousePosition.js","OpenLayers/Control/OverviewMap.js","OpenLayers/Control/KeyboardDefaults.js","OpenLayers/Control/PanZoom.js","OpenLayers/Control/PanZoomBar.js","OpenLayers/Control/ArgParser.js","OpenLayers/Control/Permalink.js","OpenLayers/Control/Scale.js","OpenLayers/Control/ScaleLine.js","OpenLayers/Control/Snapping.js","OpenLayers/Control/Split.js","OpenLayers/Control/LayerSwitcher.js","OpenLayers/Control/DrawFeature.js","OpenLayers/Control/DragFeature.js","OpenLayers/Control/ModifyFeature.js","OpenLayers/Control/Panel.js","OpenLayers/Control/SelectFeature.js","OpenLayers/Control/NavigationHistory.js","OpenLayers/Control/Measure.js","OpenLayers/Control/WMSGetFeatureInfo.js","OpenLayers/Geometry.js","OpenLayers/Geometry/Rectangle.js","OpenLayers/Geometry/Collection.js","OpenLayers/Geometry/Point.js","OpenLayers/Geometry/MultiPoint.js","OpenLayers/Geometry/Curve.js","OpenLayers/Geometry/LineString.js","OpenLayers/Geometry/LinearRing.js","OpenLayers/Geometry/Polygon.js","OpenLayers/Geometry/MultiLineString.js","OpenLayers/Geometry/MultiPolygon.js","OpenLayers/Geometry/Surface.js","OpenLayers/Renderer.js","OpenLayers/Renderer/Elements.js","OpenLayers/Renderer/SVG.js","OpenLayers/Renderer/Canvas.js","OpenLayers/Renderer/VML.js","OpenLayers/Layer/Vector.js","OpenLayers/Layer/Vector/RootContainer.js","OpenLayers/Strategy.js","OpenLayers/Strategy/Fixed.js","OpenLayers/Strategy/Cluster.js","OpenLayers/Strategy/Paging.js","OpenLayers/Strategy/BBOX.js","OpenLayers/Strategy/Save.js","OpenLayers/Protocol.js","OpenLayers/Protocol/HTTP.js","OpenLayers/Protocol/SQL.js","OpenLayers/Protocol/SQL/Gears.js","OpenLayers/Protocol/WFS.js","OpenLayers/Protocol/WFS/v1.js","OpenLayers/Protocol/WFS/v1_0_0.js","OpenLayers/Protocol/WFS/v1_1_0.js","OpenLayers/Layer/PointTrack.js","OpenLayers/Layer/GML.js","OpenLayers/Style.js","OpenLayers/StyleMap.js","OpenLayers/Rule.js","OpenLayers/Filter.js","OpenLayers/Filter/FeatureId.js","OpenLayers/Filter/Logical.js","OpenLayers/Filter/Comparison.js","OpenLayers/Filter/Spatial.js","OpenLayers/Format.js","OpenLayers/Format/XML.js","OpenLayers/Format/ArcXML.js","OpenLayers/Format/ArcXML/Features.js","OpenLayers/Format/GML.js","OpenLayers/Format/GML/Base.js","OpenLayers/Format/GML/v2.js","OpenLayers/Format/GML/v3.js","OpenLayers/Format/KML.js","OpenLayers/Format/GeoRSS.js","OpenLayers/Format/WFS.js","OpenLayers/Format/WFSCapabilities.js","OpenLayers/Format/WFSCapabilities/v1.js","OpenLayers/Format/WFSCapabilities/v1_0_0.js","OpenLayers/Format/WFSCapabilities/v1_1_0.js","OpenLayers/Format/WFSDescribeFeatureType.js","OpenLayers/Format/WMSDescribeLayer.js","OpenLayers/Format/WMSDescribeLayer/v1_1.js","OpenLayers/Format/WKT.js","OpenLayers/Format/OSM.js","OpenLayers/Format/GPX.js","OpenLayers/Format/Filter.js","OpenLayers/Format/Filter/v1.js","OpenLayers/Format/Filter/v1_0_0.js","OpenLayers/Format/Filter/v1_1_0.js","OpenLayers/Format/SLD.js","OpenLayers/Format/SLD/v1.js","OpenLayers/Format/SLD/v1_0_0.js","OpenLayers/Format/SLD/v1.js","OpenLayers/Format/WFST.js","OpenLayers/Format/WFST/v1.js","OpenLayers/Format/WFST/v1_0_0.js","OpenLayers/Format/WFST/v1_1_0.js","OpenLayers/Format/Text.js","OpenLayers/Format/JSON.js","OpenLayers/Format/GeoJSON.js","OpenLayers/Format/WMC.js","OpenLayers/Format/WMC/v1.js","OpenLayers/Format/WMC/v1_0_0.js","OpenLayers/Format/WMC/v1_1_0.js","OpenLayers/Format/WMSCapabilities.js","OpenLayers/Format/WMSCapabilities/v1_1.js","OpenLayers/Format/WMSCapabilities/v1_1_0.js","OpenLayers/Format/WMSCapabilities/v1_1_1.js","OpenLayers/Format/WMSGetFeatureInfo.js","OpenLayers/Layer/WFS.js","OpenLayers/Control/GetFeature.js","OpenLayers/Control/MouseToolbar.js","OpenLayers/Control/NavToolbar.js","OpenLayers/Control/PanPanel.js","OpenLayers/Control/Pan.js","OpenLayers/Control/ZoomIn.js","OpenLayers/Control/ZoomOut.js","OpenLayers/Control/ZoomPanel.js","OpenLayers/Control/EditingToolbar.js","OpenLayers/Lang.js","OpenLayers/Lang/en.js");var b=navigator.userAgent;var d=(b.match("MSIE")||b.match("Safari"));if(d){var a=new Array(k.length)}var l=OpenLayers._getScriptLocation()+"lib/";for(var c=0,g=k.length;c<g;c++){if(d){a[c]="<script src='"+l+k[c]+"'><\/script>"}else{var m=document.createElement("script");m.src=l+k[c];var f=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;f.appendChild(m)}}if(d){document.write(a.join(""))}}})();OpenLayers.VERSION_NUMBER="OpenLayers 2.8 -- $Revision: 9492 $";OpenLayers.String={startsWith:function(b,a){return(b.indexOf(a)==0)},contains:function(b,a){return(b.indexOf(a)!=-1)},trim:function(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},camelize:function(g){var d=g.split("-");var b=d[0];for(var c=1,a=d.length;c<a;c++){var f=d[c];b+=f.charAt(0).toUpperCase()+f.substring(1)}return b},format:function(d,c,a){if(!c){c=window}var b=function(k,f){var j;var h=f.split(/\.+/);for(var g=0;g<h.length;g++){if(g==0){j=c}j=j[h[g]]}if(typeof j=="function"){j=a?j.apply(null,a):j()}if(typeof j=="undefined"){return"undefined"}else{return j}};return d.replace(OpenLayers.String.tokenRegEx,b)},tokenRegEx:/\$\{([\w.]+?)\}/g,numberRegEx:/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/,isNumeric:function(a){return OpenLayers.String.numberRegEx.test(a)},numericIf:function(a){return OpenLayers.String.isNumeric(a)?parseFloat(a):a}};if(!String.prototype.startsWith){String.prototype.startsWith=function(a){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"OpenLayers.String.startsWith"}));return OpenLayers.String.startsWith(this,a)}}if(!String.prototype.contains){String.prototype.contains=function(a){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"OpenLayers.String.contains"}));return OpenLayers.String.contains(this,a)}}if(!String.prototype.trim){String.prototype.trim=function(){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"OpenLayers.String.trim"}));return OpenLayers.String.trim(this)}}if(!String.prototype.camelize){String.prototype.camelize=function(){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"OpenLayers.String.camelize"}));return OpenLayers.String.camelize(this)}}OpenLayers.Number={decimalSeparator:".",thousandsSeparator:",",limitSigDigs:function(a,c){var b=0;if(c>0){b=parseFloat(a.toPrecision(c))}return b},format:function(c,a,h,k){a=(typeof a!="undefined")?a:0;h=(typeof h!="undefined")?h:OpenLayers.Number.thousandsSeparator;k=(typeof k!="undefined")?k:OpenLayers.Number.decimalSeparator;if(a!=null){c=parseFloat(c.toFixed(a))}var b=c.toString().split(".");if(b.length==1&&a==null){a=0}var d=b[0];if(h){var f=/(-?[0-9]+)([0-9]{3})/;while(f.test(d)){d=d.replace(f,"$1"+h+"$2")}}var g;if(a==0){g=d}else{var j=b.length>1?b[1]:"0";if(a!=null){j=j+new Array(a-j.length+1).join("0")}g=d+k+j}return g}};if(!Number.prototype.limitSigDigs){Number.prototype.limitSigDigs=function(a){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"OpenLayers.Number.limitSigDigs"}));return OpenLayers.Number.limitSigDigs(this,a)}}OpenLayers.Function={bind:function(c,b){var a=Array.prototype.slice.apply(arguments,[2]);return function(){var d=a.concat(Array.prototype.slice.apply(arguments,[0]));return c.apply(b,d)}},bindAsEventListener:function(b,a){return function(c){return b.call(a,c||window.event)}}};if(!Function.prototype.bind){Function.prototype.bind=function(){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"OpenLayers.Function.bind"}));Array.prototype.unshift.apply(arguments,[this]);return OpenLayers.Function.bind.apply(null,arguments)}}if(!Function.prototype.bindAsEventListener){Function.prototype.bindAsEventListener=function(a){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"OpenLayers.Function.bindAsEventListener"}));return OpenLayers.Function.bindAsEventListener(this,a)}}OpenLayers.Array={filter:function(h,g,b){var d=[];if(Array.prototype.filter){d=h.filter(g,b)}else{var a=h.length;if(typeof g!="function"){throw new TypeError()}for(var c=0;c<a;c++){if(c in h){var f=h[c];if(g.call(b,f,c,h)){d.push(f)}}}}return d}};OpenLayers.Class=function(){var d=function(){if(arguments&&arguments[0]!=OpenLayers.Class.isPrototype){this.initialize.apply(this,arguments)}};var c={};var g,b;for(var f=0,a=arguments.length;f<a;++f){if(typeof arguments[f]=="function"){if(f==0&&a>1){b=arguments[f].prototype.initialize;arguments[f].prototype.initialize=function(){};c=new arguments[f];if(b===undefined){delete arguments[f].prototype.initialize}else{arguments[f].prototype.initialize=b}}g=arguments[f].prototype}else{g=arguments[f]}OpenLayers.Util.extend(c,g)}d.prototype=c;return d};OpenLayers.Class.isPrototype=function(){};OpenLayers.Class.create=function(){return function(){if(arguments&&arguments[0]!=OpenLayers.Class.isPrototype){this.initialize.apply(this,arguments)}}};OpenLayers.Class.inherit=function(){var d=arguments[0];var f=new d(OpenLayers.Class.isPrototype);for(var c=1,a=arguments.length;c<a;c++){if(typeof arguments[c]=="function"){var b=arguments[c];arguments[c]=new b(OpenLayers.Class.isPrototype)}OpenLayers.Util.extend(f,arguments[c])}return f};OpenLayers.Util={};OpenLayers.Util.getElement=function(){var d=[];for(var c=0,a=arguments.length;c<a;c++){var b=arguments[c];if(typeof b=="string"){b=document.getElementById(b)}if(arguments.length==1){return b}d.push(b)}return d};if(typeof window.$==="undefined"){window.$=OpenLayers.Util.getElement}OpenLayers.Util.extend=function(a,f){a=a||{};if(f){for(var d in f){var c=f[d];if(c!==undefined){a[d]=c}}var b=typeof window.Event=="function"&&f instanceof window.Event;if(!b&&f.hasOwnProperty&&f.hasOwnProperty("toString")){a.toString=f.toString}}return a};OpenLayers.Util.removeItem=function(c,b){for(var a=c.length-1;a>=0;a--){if(c[a]==b){c.splice(a,1)}}return c};OpenLayers.Util.clearArray=function(a){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"array = []"}));a.length=0};OpenLayers.Util.indexOf=function(d,c){for(var b=0,a=d.length;b<a;b++){if(d[b]==c){return b}}return -1};OpenLayers.Util.modifyDOMElement=function(f,j,d,g,a,c,h,b){if(j){f.id=j}if(d){f.style.left=d.x+"px";f.style.top=d.y+"px"}if(g){f.style.width=g.w+"px";f.style.height=g.h+"px"}if(a){f.style.position=a}if(c){f.style.border=c}if(h){f.style.overflow=h}if(parseFloat(b)>=0&&parseFloat(b)<1){f.style.filter="alpha(opacity="+(b*100)+")";f.style.opacity=b}else{if(parseFloat(b)==1){f.style.filter="";f.style.opacity=""}}};OpenLayers.Util.createDiv=function(a,k,j,g,f,c,b,h){var d=document.createElement("div");if(g){d.style.backgroundImage="url("+g+")"}if(!a){a=OpenLayers.Util.createUniqueID("OpenLayersDiv")}if(!f){f="absolute"}OpenLayers.Util.modifyDOMElement(d,a,k,j,f,c,b,h);return d};OpenLayers.Util.createImage=function(a,j,h,f,d,c,g,k){var b=document.createElement("img");if(!a){a=OpenLayers.Util.createUniqueID("OpenLayersDiv")}if(!d){d="relative"}OpenLayers.Util.modifyDOMElement(b,a,j,h,d,c,null,g);if(k){b.style.display="none";OpenLayers.Event.observe(b,"load",OpenLayers.Function.bind(OpenLayers.Util.onImageLoad,b));OpenLayers.Event.observe(b,"error",OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError,b))}b.style.alt=a;b.galleryImg="no";if(f){b.src=f}return b};OpenLayers.Util.setOpacity=function(b,a){OpenLayers.Util.modifyDOMElement(b,null,null,null,null,null,null,a)};OpenLayers.Util.onImageLoad=function(){if(!this.viewRequestID||(this.map&&this.viewRequestID==this.map.viewRequestID)){this.style.backgroundColor="transparent";this.style.display=""}};OpenLayers.Util.onImageLoadErrorColor="pink";OpenLayers.IMAGE_RELOAD_ATTEMPTS=0;OpenLayers.Util.onImageLoadError=function(){this._attempts=(this._attempts)?(this._attempts+1):1;if(this._attempts<=OpenLayers.IMAGE_RELOAD_ATTEMPTS){var d=this.urls;if(d&&d instanceof Array&&d.length>1){var f=this.src.toString();var c,a;for(a=0;c=d[a];a++){if(f.indexOf(c)!=-1){break}}var g=Math.floor(d.length*Math.random());var b=d[g];a=0;while(b==c&&a++<4){g=Math.floor(d.length*Math.random());b=d[g]}this.src=f.replace(c,b)}else{this.src=this.src}}else{this.style.backgroundColor=OpenLayers.Util.onImageLoadErrorColor}this.style.display=""};OpenLayers.Util.alphaHackNeeded=null;OpenLayers.Util.alphaHack=function(){if(OpenLayers.Util.alphaHackNeeded==null){var d=navigator.appVersion.split("MSIE");var a=parseFloat(d[1]);var b=false;try{b=!!(document.body.filters)}catch(c){}OpenLayers.Util.alphaHackNeeded=(b&&(a>=5.5)&&(a<7))}return OpenLayers.Util.alphaHackNeeded};OpenLayers.Util.modifyAlphaImageDiv=function(a,b,l,k,h,g,c,d,j){OpenLayers.Util.modifyDOMElement(a,b,l,k,g,null,null,j);var f=a.childNodes[0];if(h){f.src=h}OpenLayers.Util.modifyDOMElement(f,a.id+"_innerImage",null,k,"relative",c);if(OpenLayers.Util.alphaHack()){if(a.style.display!="none"){a.style.display="inline-block"}if(d==null){d="scale"}a.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+f.src+"', sizingMethod='"+d+"')";if(parseFloat(a.style.opacity)>=0&&parseFloat(a.style.opacity)<1){a.style.filter+=" alpha(opacity="+a.style.opacity*100+")"}f.style.filter="alpha(opacity=0)"}};OpenLayers.Util.createAlphaImageDiv=function(b,l,k,h,g,c,d,j,m){var a=OpenLayers.Util.createDiv();var f=OpenLayers.Util.createImage(null,null,null,null,null,null,null,false);a.appendChild(f);if(m){f.style.display="none";OpenLayers.Event.observe(f,"load",OpenLayers.Function.bind(OpenLayers.Util.onImageLoad,a));OpenLayers.Event.observe(f,"error",OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError,a))}OpenLayers.Util.modifyAlphaImageDiv(a,b,l,k,h,g,c,d,j);return a};OpenLayers.Util.upperCaseObject=function(b){var a={};for(var c in b){a[c.toUpperCase()]=b[c]}return a};OpenLayers.Util.applyDefaults=function(d,c){d=d||{};var b=typeof window.Event=="function"&&c instanceof window.Event;for(var a in c){if(d[a]===undefined||(!b&&c.hasOwnProperty&&c.hasOwnProperty(a)&&!d.hasOwnProperty(a))){d[a]=c[a]}}if(!b&&c&&c.hasOwnProperty&&c.hasOwnProperty("toString")&&!d.hasOwnProperty("toString")){d.toString=c.toString}return d};OpenLayers.Util.getParameterString=function(j){var h=[];for(var c in j){var f=j[c];if((f!=null)&&(typeof f!="function")){var b;if(typeof f=="object"&&f.constructor==Array){var g=[];for(var d=0,a=f.length;d<a;d++){g.push(encodeURIComponent(f[d]))}b=g.join(",")}else{b=encodeURIComponent(f)}h.push(encodeURIComponent(c)+"="+b)}}return h.join("&")};OpenLayers.ImgPath="";OpenLayers.Util.getImagesLocation=function(){return OpenLayers.ImgPath||(OpenLayers._getScriptLocation()+"img/")};OpenLayers.Util.Try=function(){var d=null;for(var c=0,a=arguments.length;c<a;c++){var b=arguments[c];try{d=b();break}catch(f){}}return d};OpenLayers.Util.getNodes=function(c,b){var a=OpenLayers.Util.Try(function(){return OpenLayers.Util._getNodes(c.documentElement.childNodes,b)},function(){return OpenLayers.Util._getNodes(c.childNodes,b)});return a};OpenLayers.Util._getNodes=function(c,f){var b=[];for(var d=0,a=c.length;d<a;d++){if(c[d].nodeName==f){b.push(c[d])}}return b};OpenLayers.Util.getTagText=function(c,d,b){var a=OpenLayers.Util.getNodes(c,d);if(a&&(a.length>0)){if(!b){b=0}if(a[b].childNodes.length>1){return a.childNodes[1].nodeValue}else{if(a[b].childNodes.length==1){return a[b].firstChild.nodeValue}}}else{return""}};OpenLayers.Util.getXmlNodeValue=function(a){var b=null;OpenLayers.Util.Try(function(){b=a.text;if(!b){b=a.textContent}if(!b){b=a.firstChild.nodeValue}},function(){b=a.textContent});return b};OpenLayers.Util.mouseLeft=function(a,c){var b=(a.relatedTarget)?a.relatedTarget:a.toElement;while(b!=c&&b!=null){b=b.parentNode}return(b!=c)};OpenLayers.Util.DEFAULT_PRECISION=14;OpenLayers.Util.toFloat=function(b,a){if(a==null){a=OpenLayers.Util.DEFAULT_PRECISION}var b;if(a==0){b=parseFloat(b)}else{b=parseFloat(parseFloat(b).toPrecision(a))}return b};OpenLayers.Util.rad=function(a){return a*Math.PI/180};OpenLayers.Util.distVincenty=function(h,c){var R=6378137,Q=6356752.3142,M=1/298.257223563;var q=OpenLayers.Util.rad(c.lon-h.lon);var P=Math.atan((1-M)*Math.tan(OpenLayers.Util.rad(h.lat)));var O=Math.atan((1-M)*Math.tan(OpenLayers.Util.rad(c.lat)));var o=Math.sin(P),k=Math.cos(P);var m=Math.sin(O),j=Math.cos(O);var v=q,r=2*Math.PI;var u=20;while(Math.abs(v-r)>1e-12&&--u>0){var H=Math.sin(v),g=Math.cos(v);var S=Math.sqrt((j*H)*(j*H)+(k*m-o*j*g)*(k*m-o*j*g));if(S==0){return 0}var J=o*m+k*j*g;var G=Math.atan2(S,J);var l=Math.asin(k*j*H/S);var K=Math.cos(l)*Math.cos(l);var t=J-2*o*m/K;var D=M/16*K*(4+M*(4-3*K));r=v;v=q+(1-D)*M*Math.sin(l)*(G+D*S*(t+D*J*(-1+2*t*t)))}if(u==0){return NaN}var z=K*(R*R-Q*Q)/(Q*Q);var F=1+z/16384*(4096+z*(-768+z*(320-175*z)));var E=z/1024*(256+z*(-128+z*(74-47*z)));var I=E*S*(t+E/4*(J*(-1+2*t*t)-E/6*t*(-3+4*S*S)*(-3+4*t*t)));var w=Q*F*(G-I);var N=w.toFixed(3)/1000;return N};OpenLayers.Util.getParameters=function(b){b=b||window.location.href;var a="";if(OpenLayers.String.contains(b,"?")){var c=b.indexOf("?")+1;var f=OpenLayers.String.contains(b,"#")?b.indexOf("#"):b.length;a=b.substring(c,f)}var r={};var d=a.split(/[&;]/);for(var k=0,l=d.length;k<l;++k){var h=d[k].split("=");if(h[0]){var o=decodeURIComponent(h[0]);var m=h[1]||"";m=m.split(",");for(var g=0,q=m.length;g<q;g++){m[g]=decodeURIComponent(m[g])}if(m.length==1){m=m[0]}r[o]=m}}return r};OpenLayers.Util.getArgs=function(a){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{newMethod:"OpenLayers.Util.getParameters"}));return OpenLayers.Util.getParameters(a)};OpenLayers.Util.lastSeqID=0;OpenLayers.Util.createUniqueID=function(a){if(a==null){a="id_"}OpenLayers.Util.lastSeqID+=1;return a+OpenLayers.Util.lastSeqID};OpenLayers.INCHES_PER_UNIT={inches:1,ft:12,mi:63360,m:39.3701,km:39370.1,dd:4374754,yd:36};OpenLayers.INCHES_PER_UNIT["in"]=OpenLayers.INCHES_PER_UNIT.inches;OpenLayers.INCHES_PER_UNIT.degrees=OpenLayers.INCHES_PER_UNIT.dd;OpenLayers.INCHES_PER_UNIT.nmi=1852*OpenLayers.INCHES_PER_UNIT.m;OpenLayers.METERS_PER_INCH=0.0254000508001016;OpenLayers.Util.extend(OpenLayers.INCHES_PER_UNIT,{Inch:OpenLayers.INCHES_PER_UNIT.inches,Meter:1/OpenLayers.METERS_PER_INCH,Foot:0.3048006096012192/OpenLayers.METERS_PER_INCH,IFoot:0.3048/OpenLayers.METERS_PER_INCH,ClarkeFoot:0.3047972651151/OpenLayers.METERS_PER_INCH,SearsFoot:0.30479947153867626/OpenLayers.METERS_PER_INCH,GoldCoastFoot:0.3047997101815088/OpenLayers.METERS_PER_INCH,IInch:0.0254/OpenLayers.METERS_PER_INCH,MicroInch:0.0000254/OpenLayers.METERS_PER_INCH,Mil:2.54e-8/OpenLayers.METERS_PER_INCH,Centimeter:0.01/OpenLayers.METERS_PER_INCH,Kilometer:1000/OpenLayers.METERS_PER_INCH,Yard:0.9144018288036576/OpenLayers.METERS_PER_INCH,SearsYard:0.914398414616029/OpenLayers.METERS_PER_INCH,IndianYard:0.9143985307444408/OpenLayers.METERS_PER_INCH,IndianYd37:0.91439523/OpenLayers.METERS_PER_INCH,IndianYd62:0.9143988/OpenLayers.METERS_PER_INCH,IndianYd75:0.9143985/OpenLayers.METERS_PER_INCH,IndianFoot:0.30479951/OpenLayers.METERS_PER_INCH,IndianFt37:0.30479841/OpenLayers.METERS_PER_INCH,IndianFt62:0.3047996/OpenLayers.METERS_PER_INCH,IndianFt75:0.3047995/OpenLayers.METERS_PER_INCH,Mile:1609.3472186944373/OpenLayers.METERS_PER_INCH,IYard:0.9144/OpenLayers.METERS_PER_INCH,IMile:1609.344/OpenLayers.METERS_PER_INCH,NautM:1852/OpenLayers.METERS_PER_INCH,"Lat-66":110943.31648893273/OpenLayers.METERS_PER_INCH,"Lat-83":110946.25736872235/OpenLayers.METERS_PER_INCH,Decimeter:0.1/OpenLayers.METERS_PER_INCH,Millimeter:0.001/OpenLayers.METERS_PER_INCH,Dekameter:10/OpenLayers.METERS_PER_INCH,Decameter:10/OpenLayers.METERS_PER_INCH,Hectometer:100/OpenLayers.METERS_PER_INCH,GermanMeter:1.0000135965/OpenLayers.METERS_PER_INCH,CaGrid:0.999738/OpenLayers.METERS_PER_INCH,ClarkeChain:20.1166194976/OpenLayers.METERS_PER_INCH,GunterChain:20.11684023368047/OpenLayers.METERS_PER_INCH,BenoitChain:20.116782494375872/OpenLayers.METERS_PER_INCH,SearsChain:20.11676512155/OpenLayers.METERS_PER_INCH,ClarkeLink:0.201166194976/OpenLayers.METERS_PER_INCH,GunterLink:0.2011684023368047/OpenLayers.METERS_PER_INCH,BenoitLink:0.20116782494375873/OpenLayers.METERS_PER_INCH,SearsLink:0.2011676512155/OpenLayers.METERS_PER_INCH,Rod:5.02921005842012/OpenLayers.METERS_PER_INCH,IntnlChain:20.1168/OpenLayers.METERS_PER_INCH,IntnlLink:0.201168/OpenLayers.METERS_PER_INCH,Perch:5.02921005842012/OpenLayers.METERS_PER_INCH,Pole:5.02921005842012/OpenLayers.METERS_PER_INCH,Furlong:201.1684023368046/OpenLayers.METERS_PER_INCH,Rood:3.778266898/OpenLayers.METERS_PER_INCH,CapeFoot:0.3047972615/OpenLayers.METERS_PER_INCH,Brealey:375/OpenLayers.METERS_PER_INCH,ModAmFt:0.304812252984506/OpenLayers.METERS_PER_INCH,Fathom:1.8288/OpenLayers.METERS_PER_INCH,"NautM-UK":1853.184/OpenLayers.METERS_PER_INCH,"50kilometers":50000/OpenLayers.METERS_PER_INCH,"150kilometers":150000/OpenLayers.METERS_PER_INCH});OpenLayers.Util.extend(OpenLayers.INCHES_PER_UNIT,{mm:OpenLayers.INCHES_PER_UNIT.Meter/1000,cm:OpenLayers.INCHES_PER_UNIT.Meter/100,dm:OpenLayers.INCHES_PER_UNIT.Meter*100,km:OpenLayers.INCHES_PER_UNIT.Meter*1000,kmi:OpenLayers.INCHES_PER_UNIT.nmi,fath:OpenLayers.INCHES_PER_UNIT.Fathom,ch:OpenLayers.INCHES_PER_UNIT.IntnlChain,link:OpenLayers.INCHES_PER_UNIT.IntnlLink,"us-in":OpenLayers.INCHES_PER_UNIT.inches,"us-ft":OpenLayers.INCHES_PER_UNIT.Foot,"us-yd":OpenLayers.INCHES_PER_UNIT.Yard,"us-ch":OpenLayers.INCHES_PER_UNIT.GunterChain,"us-mi":OpenLayers.INCHES_PER_UNIT.Mile,"ind-yd":OpenLayers.INCHES_PER_UNIT.IndianYd37,"ind-ft":OpenLayers.INCHES_PER_UNIT.IndianFt37,"ind-ch":20.11669506/OpenLayers.METERS_PER_INCH});OpenLayers.DOTS_PER_INCH=72;OpenLayers.Util.normalizeScale=function(b){var a=(b>1)?(1/b):b;return a};OpenLayers.Util.getResolutionFromScale=function(d,a){if(a==null){a="degrees"}var c=OpenLayers.Util.normalizeScale(d);var b=1/(c*OpenLayers.INCHES_PER_UNIT[a]*OpenLayers.DOTS_PER_INCH);return b};OpenLayers.Util.getScaleFromResolution=function(b,a){if(a==null){a="degrees"}var c=b*OpenLayers.INCHES_PER_UNIT[a]*OpenLayers.DOTS_PER_INCH;return c};OpenLayers.Util.safeStopPropagation=function(a){OpenLayers.Event.stop(a,true)};OpenLayers.Util.pagePosition=function(f){var a=0,d=0;var b=f;var g=f;while(b){if(b==document.body){if(OpenLayers.Element.getStyle(g,"position")=="absolute"){break}}a+=b.offsetTop||0;d+=b.offsetLeft||0;g=b;try{b=b.offsetParent}catch(c){OpenLayers.Console.error(OpenLayers.i18n("pagePositionFailed",{elemId:b.id}));break}}b=f;while(b){a-=b.scrollTop||0;d-=b.scrollLeft||0;b=b.parentNode}return[d,a]};OpenLayers.Util.isEquivalentUrl=function(g,f,c){c=c||{};OpenLayers.Util.applyDefaults(c,{ignoreCase:true,ignorePort80:true,ignoreHash:true});var b=OpenLayers.Util.createUrlObject(g,c);var a=OpenLayers.Util.createUrlObject(f,c);for(var d in b){if(d!=="args"){if(b[d]!=a[d]){return false}}}for(var d in b.args){if(b.args[d]!=a.args[d]){return false}delete a.args[d]}for(var d in a.args){return false}return true};OpenLayers.Util.createUrlObject=function(c,m){m=m||{};if(!(/^\w+:\/\//).test(c)){var h=window.location;var f=h.port?":"+h.port:"";var j=h.protocol+"//"+h.host.split(":").shift()+f;if(c.indexOf("/")===0){c=j+c}else{var g=h.pathname.split("/");g.pop();c=j+g.join("/")+"/"+c}}if(m.ignoreCase){c=c.toLowerCase()}var k=document.createElement("a");k.href=c;var d={};d.host=k.host.split(":").shift();d.protocol=k.protocol;if(m.ignorePort80){d.port=(k.port=="80"||k.port=="0")?"":k.port}else{d.port=(k.port==""||k.port=="0")?"80":k.port}d.hash=(m.ignoreHash||k.hash==="#")?"":k.hash;var b=k.search;if(!b){var l=c.indexOf("?");b=(l!=-1)?c.substr(l):""}d.args=OpenLayers.Util.getParameters(b);d.pathname=(k.pathname.charAt(0)=="/")?k.pathname:"/"+k.pathname;return d};OpenLayers.Util.removeTail=function(b){var c=null;var a=b.indexOf("?");var d=b.indexOf("#");if(a==-1){c=(d!=-1)?b.substr(0,d):b}else{c=(d!=-1)?b.substr(0,Math.min(a,d)):b.substr(0,a)}return c};OpenLayers.Util.getBrowserName=function(){var b="";var a=navigator.userAgent.toLowerCase();if(a.indexOf("opera")!=-1){b="opera"}else{if(a.indexOf("msie")!=-1){b="msie"}else{if(a.indexOf("safari")!=-1){b="safari"}else{if(a.indexOf("mozilla")!=-1){if(a.indexOf("firefox")!=-1){b="firefox"}else{b="mozilla"}}}}}return b};OpenLayers.Util.getRenderedDimensions=function(b,r,s){var m,f;var a=document.createElement("div");a.style.visibility="hidden";var q=(s&&s.containerElement)?s.containerElement:document.body;if(r){if(r.w){m=r.w;a.style.width=m+"px"}else{if(r.h){f=r.h;a.style.height=f+"px"}}}if(s&&s.displayClass){a.className=s.displayClass}var g=document.createElement("div");g.innerHTML=b;g.style.overflow="visible";if(g.childNodes){for(var d=0,c=g.childNodes.length;d<c;d++){if(!g.childNodes[d].style){continue}g.childNodes[d].style.overflow="visible"}}a.appendChild(g);q.appendChild(a);var o=false;var k=a.parentNode;while(k&&k.tagName.toLowerCase()!="body"){var j=OpenLayers.Element.getStyle(k,"position");if(j=="absolute"){o=true;break}else{if(j&&j!="static"){break}}k=k.parentNode}if(!o){a.style.position="absolute"}if(!m){m=parseInt(g.scrollWidth);a.style.width=m+"px"}if(!f){f=parseInt(g.scrollHeight)}a.removeChild(g);q.removeChild(a);return new OpenLayers.Size(m,f)};OpenLayers.Util.getScrollbarWidth=function(){var c=OpenLayers.Util._scrollbarWidth;if(c==null){var f=null;var d=null;var a=0;var b=0;f=document.createElement("div");f.style.position="absolute";f.style.top="-1000px";f.style.left="-1000px";f.style.width="100px";f.style.height="50px";f.style.overflow="hidden";d=document.createElement("div");d.style.width="100%";d.style.height="200px";f.appendChild(d);document.body.appendChild(f);a=d.offsetWidth;f.style.overflow="scroll";b=d.offsetWidth;document.body.removeChild(document.body.lastChild);OpenLayers.Util._scrollbarWidth=(a-b);c=OpenLayers.Util._scrollbarWidth}return c};OpenLayers.Rico=new Object();OpenLayers.Rico.Corner={round:function(d,b){d=OpenLayers.Util.getElement(d);this._setOptions(b);var a=this.options.color;if(this.options.color=="fromElement"){a=this._background(d)}var c=this.options.bgColor;if(this.options.bgColor=="fromParent"){c=this._background(d.offsetParent)}this._roundCornersImpl(d,a,c)},changeColor:function(c,b){c.style.backgroundColor=b;var a=c.parentNode.getElementsByTagName("span");for(var d=0;d<a.length;d++){a[d].style.backgroundColor=b}},changeOpacity:function(c,g){var d=g;var a="alpha(opacity="+g*100+")";c.style.opacity=d;c.style.filter=a;var b=c.parentNode.getElementsByTagName("span");for(var f=0;f<b.length;f++){b[f].style.opacity=d;b[f].style.filter=a}},reRound:function(d,c){var b=d.parentNode.childNodes[0];var a=d.parentNode.childNodes[2];d.parentNode.removeChild(b);d.parentNode.removeChild(a);this.round(d.parentNode,c)},_roundCornersImpl:function(c,a,b){if(this.options.border){this._renderBorder(c,b)}if(this._isTopRounded()){this._roundTopCorners(c,a,b)}if(this._isBottomRounded()){this._roundBottomCorners(c,a,b)}},_renderBorder:function(d,f){var b="1px solid "+this._borderColor(f);var a="border-left: "+b;var g="border-right: "+b;var c="style='"+a+";"+g+"'";d.innerHTML="<div "+c+">"+d.innerHTML+"</div>"},_roundTopCorners:function(c,a,f){var d=this._createCorner(f);for(var b=0;b<this.options.numSlices;b++){d.appendChild(this._createCornerSlice(a,f,b,"top"))}c.style.paddingTop=0;c.insertBefore(d,c.firstChild)},_roundBottomCorners:function(c,a,f){var d=this._createCorner(f);for(var b=(this.options.numSlices-1);b>=0;b--){d.appendChild(this._createCornerSlice(a,f,b,"bottom"))}c.style.paddingBottom=0;c.appendChild(d)},_createCorner:function(b){var a=document.createElement("div");a.style.backgroundColor=(this._isTransparent()?"transparent":b);return a},_createCornerSlice:function(c,d,h,a){var f=document.createElement("span");var b=f.style;b.backgroundColor=c;b.display="block";b.height="1px";b.overflow="hidden";b.fontSize="1px";var g=this._borderColor(c,d);if(this.options.border&&h==0){b.borderTopStyle="solid";b.borderTopWidth="1px";b.borderLeftWidth="0px";b.borderRightWidth="0px";b.borderBottomWidth="0px";b.height="0px";b.borderColor=g}else{if(g){b.borderColor=g;b.borderStyle="solid";b.borderWidth="0px 1px"}}if(!this.options.compact&&(h==(this.options.numSlices-1))){b.height="2px"}this._setMargin(f,h,a);this._setBorder(f,h,a);return f},_setOptions:function(a){this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false};OpenLayers.Util.extend(this.options,a||{});this.options.numSlices=this.options.compact?2:4;if(this._isTransparent()){this.options.blend=false}},_whichSideTop:function(){if(this._hasString(this.options.corners,"all","top")){return""}if(this.options.corners.indexOf("tl")>=0&&this.options.corners.indexOf("tr")>=0){return""}if(this.options.corners.indexOf("tl")>=0){return"left"}else{if(this.options.corners.indexOf("tr")>=0){return"right"}}return""},_whichSideBottom:function(){if(this._hasString(this.options.corners,"all","bottom")){return""}if(this.options.corners.indexOf("bl")>=0&&this.options.corners.indexOf("br")>=0){return""}if(this.options.corners.indexOf("bl")>=0){return"left"}else{if(this.options.corners.indexOf("br")>=0){return"right"}}return""},_borderColor:function(a,b){if(a=="transparent"){return b}else{if(this.options.border){return this.options.border}else{if(this.options.blend){return this._blend(b,a)}else{return""}}}},_setMargin:function(d,f,b){var c=this._marginSize(f);var a=b=="top"?this._whichSideTop():this._whichSideBottom();if(a=="left"){d.style.marginLeft=c+"px";d.style.marginRight="0px"}else{if(a=="right"){d.style.marginRight=c+"px";d.style.marginLeft="0px"}else{d.style.marginLeft=c+"px";d.style.marginRight=c+"px"}}},_setBorder:function(d,f,b){var c=this._borderSize(f);var a=b=="top"?this._whichSideTop():this._whichSideBottom();if(a=="left"){d.style.borderLeftWidth=c+"px";d.style.borderRightWidth="0px"}else{if(a=="right"){d.style.borderRightWidth=c+"px";d.style.borderLeftWidth="0px"}else{d.style.borderLeftWidth=c+"px";d.style.borderRightWidth=c+"px"}}if(this.options.border!=false){d.style.borderLeftWidth=c+"px";d.style.borderRightWidth=c+"px"}},_marginSize:function(f){if(this._isTransparent()){return 0}var d=[5,3,2,1];var a=[3,2,1,0];var c=[2,1];var b=[1,0];if(this.options.compact&&this.options.blend){return b[f]}else{if(this.options.compact){return c[f]}else{if(this.options.blend){return a[f]}else{return d[f]}}}},_borderSize:function(f){var d=[5,3,2,1];var b=[2,1,1,1];var a=[1,0];var c=[0,2,0,0];if(this.options.compact&&(this.options.blend||this._isTransparent())){return 1}else{if(this.options.compact){return a[f]}else{if(this.options.blend){return b[f]}else{if(this.options.border){return c[f]}else{if(this._isTransparent()){return d[f]}}}}}return 0},_hasString:function(b){for(var a=1;a<arguments.length;a++){if(b.indexOf(arguments[a])>=0){return true}}return false},_blend:function(c,a){var b=OpenLayers.Rico.Color.createFromHex(c);b.blend(OpenLayers.Rico.Color.createFromHex(a));return b},_background:function(a){try{return OpenLayers.Rico.Color.createColorFromBackground(a).asHex()}catch(b){return"#ffffff"}},_isTransparent:function(){return this.options.color=="transparent"},_isTopRounded:function(){return this._hasString(this.options.corners,"all","top","tl","tr")},_isBottomRounded:function(){return this._hasString(this.options.corners,"all","bottom","bl","br")},_hasSingleTextChild:function(a){return a.childNodes.length==1&&a.childNodes[0].nodeType==3}};(function(){if(window.google&&google.gears){return}var a=null;if(typeof GearsFactory!="undefined"){a=new GearsFactory()}else{try{a=new ActiveXObject("Gears.Factory");if(a.getBuildInfo().indexOf("ie_mobile")!=-1){a.privateSetGlobalObject(this)}}catch(b){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");a.style.display="none";a.width=0;a.height=0;a.type="application/x-googlegears";document.documentElement.appendChild(a)}}}if(!a){return}if(!window.google){google={}}if(!google.gears){google.gears={factory:a}}})();OpenLayers.Element={visible:function(a){return OpenLayers.Util.getElement(a).style.display!="none"},toggle:function(){for(var c=0,a=arguments.length;c<a;c++){var b=OpenLayers.Util.getElement(arguments[c]);var d=OpenLayers.Element.visible(b)?"hide":"show";OpenLayers.Element[d](b)}},hide:function(){for(var c=0,a=arguments.length;c<a;c++){var b=OpenLayers.Util.getElement(arguments[c]);b.style.display="none"}},show:function(){for(var c=0,a=arguments.length;c<a;c++){var b=OpenLayers.Util.getElement(arguments[c]);b.style.display=""}},remove:function(a){a=OpenLayers.Util.getElement(a);a.parentNode.removeChild(a)},getHeight:function(a){a=OpenLayers.Util.getElement(a);return a.offsetHeight},getDimensions:function(b){b=OpenLayers.Util.getElement(b);if(OpenLayers.Element.getStyle(b,"display")!="none"){return{width:b.offsetWidth,height:b.offsetHeight}}var a=b.style;var f=a.visibility;var c=a.position;a.visibility="hidden";a.position="absolute";a.display="";var g=b.clientWidth;var d=b.clientHeight;a.display="none";a.position=c;a.visibility=f;return{width:g,height:d}},hasClass:function(b,a){var c=b.className;return(!!c&&new RegExp("(^|\\s)"+a+"(\\s|$)").test(c))},addClass:function(b,a){if(!OpenLayers.Element.hasClass(b,a)){b.className+=(b.className?" ":"")+a}return b},removeClass:function(b,a){var c=b.className;if(c){b.className=OpenLayers.String.trim(c.replace(new RegExp("(^|\\s+)"+a+"(\\s+|$)")," "))}return b},toggleClass:function(b,a){if(OpenLayers.Element.hasClass(b,a)){OpenLayers.Element.removeClass(b,a)}else{OpenLayers.Element.addClass(b,a)}return b},getStyle:function(c,d){c=OpenLayers.Util.getElement(c);var f=null;if(c&&c.style){f=c.style[OpenLayers.String.camelize(d)];if(!f){if(document.defaultView&&document.defaultView.getComputedStyle){var b=document.defaultView.getComputedStyle(c,null);f=b?b.getPropertyValue(d):null}else{if(c.currentStyle){f=c.currentStyle[OpenLayers.String.camelize(d)]}}}var a=["left","top","right","bottom"];if(window.opera&&(OpenLayers.Util.indexOf(a,d)!=-1)&&(OpenLayers.Element.getStyle(c,"position")=="static")){f="auto"}}return f=="auto"?null:f}};OpenLayers.Size=OpenLayers.Class({w:0,h:0,initialize:function(a,b){this.w=parseFloat(a);this.h=parseFloat(b)},toString:function(){return("w="+this.w+",h="+this.h)},clone:function(){return new OpenLayers.Size(this.w,this.h)},equals:function(b){var a=false;if(b!=null){a=((this.w==b.w&&this.h==b.h)||(isNaN(this.w)&&isNaN(this.h)&&isNaN(b.w)&&isNaN(b.h)))}return a},CLASS_NAME:"OpenLayers.Size"});OpenLayers.Console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){},userError:function(a){alert(a)},assert:function(){},dir:function(){},dirxml:function(){},trace:function(){},group:function(){},groupEnd:function(){},time:function(){},timeEnd:function(){},profile:function(){},profileEnd:function(){},count:function(){},CLASS_NAME:"OpenLayers.Console"};(function(){var b=document.getElementsByTagName("script");for(var c=0,a=b.length;c<a;++c){if(b[c].src.indexOf("firebug.js")!=-1){if(console){OpenLayers.Util.extend(OpenLayers.Console,console);break}}}})();OpenLayers.Icon=OpenLayers.Class({url:null,size:null,offset:null,calculateOffset:null,imageDiv:null,px:null,initialize:function(a,b,d,c){this.url=a;this.size=(b)?b:new OpenLayers.Size(20,20);this.offset=d?d:new OpenLayers.Pixel(-(this.size.w/2),-(this.size.h/2));this.calculateOffset=c;var f=OpenLayers.Util.createUniqueID("OL_Icon_");this.imageDiv=OpenLayers.Util.createAlphaImageDiv(f)},destroy:function(){this.erase();OpenLayers.Event.stopObservingElement(this.imageDiv.firstChild);this.imageDiv.innerHTML="";this.imageDiv=null},clone:function(){return new OpenLayers.Icon(this.url,this.size,this.offset,this.calculateOffset)},setSize:function(a){if(a!=null){this.size=a}this.draw()},setUrl:function(a){if(a!=null){this.url=a}this.draw()},draw:function(a){OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,null,this.size,this.url,"absolute");this.moveTo(a);return this.imageDiv},erase:function(){if(this.imageDiv!=null&&this.imageDiv.parentNode!=null){OpenLayers.Element.remove(this.imageDiv)}},setOpacity:function(a){OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,null,null,null,null,null,null,a)},moveTo:function(a){if(a!=null){this.px=a}if(this.imageDiv!=null){if(this.px==null){this.display(false)}else{if(this.calculateOffset){this.offset=this.calculateOffset(this.size)}var b=this.px.offset(this.offset);OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,b)}}},display:function(a){this.imageDiv.style.display=(a)?"":"none"},isDrawn:function(){var a=(this.imageDiv&&this.imageDiv.parentNode&&(this.imageDiv.parentNode.nodeType!=11));return a},CLASS_NAME:"OpenLayers.Icon"});OpenLayers.Popup=OpenLayers.Class({events:null,id:"",lonlat:null,div:null,contentSize:null,size:null,contentHTML:null,backgroundColor:"",opacity:"",border:"",contentDiv:null,groupDiv:null,closeDiv:null,autoSize:false,minSize:null,maxSize:null,displayClass:"olPopup",contentDisplayClass:"olPopupContent",padding:0,disableFirefoxOverflowHack:false,fixPadding:function(){if(typeof this.padding=="number"){this.padding=new OpenLayers.Bounds(this.padding,this.padding,this.padding,this.padding)}},panMapIfOutOfView:false,keepInMap:false,closeOnMove:false,map:null,initialize:function(h,c,g,b,f,d){if(h==null){h=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_")}this.id=h;this.lonlat=c;this.contentSize=(g!=null)?g:new OpenLayers.Size(OpenLayers.Popup.WIDTH,OpenLayers.Popup.HEIGHT);if(b!=null){this.contentHTML=b}this.backgroundColor=OpenLayers.Popup.COLOR;this.opacity=OpenLayers.Popup.OPACITY;this.border=OpenLayers.Popup.BORDER;this.div=OpenLayers.Util.createDiv(this.id,null,null,null,null,null,"hidden");this.div.className=this.displayClass;var a=this.id+"_GroupDiv";this.groupDiv=OpenLayers.Util.createDiv(a,null,null,null,"relative",null,"hidden");var h=this.div.id+"_contentDiv";this.contentDiv=OpenLayers.Util.createDiv(h,null,this.contentSize.clone(),null,"relative");this.contentDiv.className=this.contentDisplayClass;this.groupDiv.appendChild(this.contentDiv);this.div.appendChild(this.groupDiv);if(f){this.addCloseBox(d)}this.registerEvents()},destroy:function(){this.id=null;this.lonlat=null;this.size=null;this.contentHTML=null;this.backgroundColor=null;this.opacity=null;this.border=null;if(this.closeOnMove&&this.map){this.map.events.unregister("movestart",this,this.hide)}this.events.destroy();this.events=null;if(this.closeDiv){OpenLayers.Event.stopObservingElement(this.closeDiv);this.groupDiv.removeChild(this.closeDiv)}this.closeDiv=null;this.div.removeChild(this.groupDiv);this.groupDiv=null;if(this.map!=null){this.map.removePopup(this)}this.map=null;this.div=null;this.autoSize=null;this.minSize=null;this.maxSize=null;this.padding=null;this.panMapIfOutOfView=null},draw:function(a){if(a==null){if((this.lonlat!=null)&&(this.map!=null)){a=this.map.getLayerPxFromLonLat(this.lonlat)}}if(this.closeOnMove){this.map.events.register("movestart",this,this.hide)}if(!this.disableFirefoxOverflowHack&&OpenLayers.Util.getBrowserName()=="firefox"){this.map.events.register("movestart",this,function(){var b=document.defaultView.getComputedStyle(this.contentDiv,null);var c=b.getPropertyValue("overflow");if(c!="hidden"){this.contentDiv._oldOverflow=c;this.contentDiv.style.overflow="hidden"}});this.map.events.register("moveend",this,function(){var b=this.contentDiv._oldOverflow;if(b){this.contentDiv.style.overflow=b;this.contentDiv._oldOverflow=null}})}this.moveTo(a);if(!this.autoSize&&!this.size){this.setSize(this.contentSize)}this.setBackgroundColor();this.setOpacity();this.setBorder();this.setContentHTML();if(this.panMapIfOutOfView){this.panIntoView()}return this.div},updatePosition:function(){if((this.lonlat)&&(this.map)){var a=this.map.getLayerPxFromLonLat(this.lonlat);if(a){this.moveTo(a)}}},moveTo:function(a){if((a!=null)&&(this.div!=null)){this.div.style.left=a.x+"px";this.div.style.top=a.y+"px"}},visible:function(){return OpenLayers.Element.visible(this.div)},toggle:function(){if(this.visible()){this.hide()}else{this.show()}},show:function(){OpenLayers.Element.show(this.div);if(this.panMapIfOutOfView){this.panIntoView()}},hide:function(){OpenLayers.Element.hide(this.div)},setSize:function(c){this.size=c.clone();var b=this.getContentDivPadding();var a=b.left+b.right;var f=b.top+b.bottom;this.fixPadding();a+=this.padding.left+this.padding.right;f+=this.padding.top+this.padding.bottom;if(this.closeDiv){var d=parseInt(this.closeDiv.style.width);a+=d+b.right}this.size.w+=a;this.size.h+=f;if(OpenLayers.Util.getBrowserName()=="msie"){this.contentSize.w+=b.left+b.right;this.contentSize.h+=b.bottom+b.top}if(this.div!=null){this.div.style.width=this.size.w+"px";this.div.style.height=this.size.h+"px"}if(this.contentDiv!=null){this.contentDiv.style.width=c.w+"px";this.contentDiv.style.height=c.h+"px"}},updateSize:function(){var f="<div class='"+this.contentDisplayClass+"'>"+this.contentDiv.innerHTML+"</div>";var j=(this.map)?this.map.layerContainerDiv:document.body;var k=OpenLayers.Util.getRenderedDimensions(f,null,{displayClass:this.displayClass,containerElement:j});var h=this.getSafeContentSize(k);var g=null;if(h.equals(k)){g=k}else{var b=new OpenLayers.Size();b.w=(h.w<k.w)?h.w:null;b.h=(h.h<k.h)?h.h:null;if(b.w&&b.h){g=h}else{var d=OpenLayers.Util.getRenderedDimensions(f,b,{displayClass:this.contentDisplayClass,containerElement:j});var c=OpenLayers.Element.getStyle(this.contentDiv,"overflow");if((c!="hidden")&&(d.equals(h))){var a=OpenLayers.Util.getScrollbarWidth();if(b.w){d.h+=a}else{d.w+=a}}g=this.getSafeContentSize(d)}}this.setSize(g)},setBackgroundColor:function(a){if(a!=undefined){this.backgroundColor=a}if(this.div!=null){this.div.style.backgroundColor=this.backgroundColor}},setOpacity:function(a){if(a!=undefined){this.opacity=a}if(this.div!=null){this.div.style.opacity=this.opacity;this.div.style.filter="alpha(opacity="+this.opacity*100+")"}},setBorder:function(a){if(a!=undefined){this.border=a}if(this.div!=null){this.div.style.border=this.border}},setContentHTML:function(a){if(a!=null){this.contentHTML=a}if((this.contentDiv!=null)&&(this.contentHTML!=null)&&(this.contentHTML!=this.contentDiv.innerHTML)){this.contentDiv.innerHTML=this.contentHTML;if(this.autoSize){this.registerImageListeners();this.updateSize()}}},registerImageListeners:function(){var g=function(){this.popup.updateSize();if(this.popup.visible()&&this.popup.panMapIfOutOfView){this.popup.panIntoView()}OpenLayers.Event.stopObserving(this.img,"load",this.img._onImageLoad)};var b=this.contentDiv.getElementsByTagName("img");for(var f=0,a=b.length;f<a;f++){var c=b[f];if(c.width==0||c.height==0){var d={popup:this,img:c};c._onImgLoad=OpenLayers.Function.bind(g,d);OpenLayers.Event.observe(c,"load",c._onImgLoad)}}},getSafeContentSize:function(m){var d=m.clone();var k=this.getContentDivPadding();var l=k.left+k.right;var h=k.top+k.bottom;this.fixPadding();l+=this.padding.left+this.padding.right;h+=this.padding.top+this.padding.bottom;if(this.closeDiv){var c=parseInt(this.closeDiv.style.width);l+=c+k.right}if(this.minSize){d.w=Math.max(d.w,(this.minSize.w-l));d.h=Math.max(d.h,(this.minSize.h-h))}if(this.maxSize){d.w=Math.min(d.w,(this.maxSize.w-l));d.h=Math.min(d.h,(this.maxSize.h-h))}if(this.map&&this.map.size){var g=0,f=0;if(this.keepInMap&&!this.panMapIfOutOfView){var j=this.map.getPixelFromLonLat(this.lonlat);switch(this.relativePosition){case"tr":g=j.x;f=this.map.size.h-j.y;break;case"tl":g=this.map.size.w-j.x;f=this.map.size.h-j.y;break;case"bl":g=this.map.size.w-j.x;f=j.y;break;case"br":g=j.x;f=j.y;break;default:g=j.x;f=this.map.size.h-j.y;break}}var a=this.map.size.h-this.map.paddingForPopups.top-this.map.paddingForPopups.bottom-h-f;var b=this.map.size.w-this.map.paddingForPopups.left-this.map.paddingForPopups.right-l-g;d.w=Math.min(d.w,b);d.h=Math.min(d.h,a)}return d},getContentDivPadding:function(){var a=this._contentDivPadding;if(!a){if(this.div.parentNode==null){this.div.style.display="none";document.body.appendChild(this.div)}a=new OpenLayers.Bounds(OpenLayers.Element.getStyle(this.contentDiv,"padding-left"),OpenLayers.Element.getStyle(this.contentDiv,"padding-bottom"),OpenLayers.Element.getStyle(this.contentDiv,"padding-right"),OpenLayers.Element.getStyle(this.contentDiv,"padding-top"));this._contentDivPadding=a;if(this.div.parentNode==document.body){document.body.removeChild(this.div);this.div.style.display=""}}return a},addCloseBox:function(c){this.closeDiv=OpenLayers.Util.createDiv(this.id+"_close",null,new OpenLayers.Size(17,17));this.closeDiv.className="olPopupCloseBox";var b=this.getContentDivPadding();this.closeDiv.style.right=b.right+"px";this.closeDiv.style.top=b.top+"px";this.groupDiv.appendChild(this.closeDiv);var a=c||function(d){this.hide();OpenLayers.Event.stop(d)};OpenLayers.Event.observe(this.closeDiv,"click",OpenLayers.Function.bindAsEventListener(a,this))},panIntoView:function(){var f=this.map.getSize();var d=this.map.getViewPortPxFromLayerPx(new OpenLayers.Pixel(parseInt(this.div.style.left),parseInt(this.div.style.top)));var c=d.clone();if(d.x<this.map.paddingForPopups.left){c.x=this.map.paddingForPopups.left}else{if((d.x+this.size.w)>(f.w-this.map.paddingForPopups.right)){c.x=f.w-this.map.paddingForPopups.right-this.size.w}}if(d.y<this.map.paddingForPopups.top){c.y=this.map.paddingForPopups.top}else{if((d.y+this.size.h)>(f.h-this.map.paddingForPopups.bottom)){c.y=f.h-this.map.paddingForPopups.bottom-this.size.h}}var b=d.x-c.x;var a=d.y-c.y;this.map.pan(b,a)},registerEvents:function(){this.events=new OpenLayers.Events(this,this.div,null,true);this.events.on({mousedown:this.onmousedown,mousemove:this.onmousemove,mouseup:this.onmouseup,click:this.onclick,mouseout:this.onmouseout,dblclick:this.ondblclick,scope:this})},onmousedown:function(a){this.mousedown=true;OpenLayers.Event.stop(a,true)},onmousemove:function(a){if(this.mousedown){OpenLayers.Event.stop(a,true)}},onmouseup:function(a){if(this.mousedown){this.mousedown=false;OpenLayers.Event.stop(a,true)}},onclick:function(a){OpenLayers.Event.stop(a,true)},onmouseout:function(a){this.mousedown=false},ondblclick:function(a){OpenLayers.Event.stop(a,true)},CLASS_NAME:"OpenLayers.Popup"});OpenLayers.Popup.WIDTH=200;OpenLayers.Popup.HEIGHT=200;OpenLayers.Popup.COLOR="white";OpenLayers.Popup.OPACITY=1;OpenLayers.Popup.BORDER="0px";OpenLayers.Protocol=OpenLayers.Class({format:null,options:null,autoDestroy:true,initialize:function(a){a=a||{};OpenLayers.Util.extend(this,a);this.options=a},destroy:function(){this.options=null;this.format=null},read:function(){},create:function(){},update:function(){},"delete":function(){},commit:function(){},abort:function(a){},CLASS_NAME:"OpenLayers.Protocol"});OpenLayers.Protocol.Response=OpenLayers.Class({code:null,requestType:null,last:true,features:null,reqFeatures:null,priv:null,initialize:function(a){OpenLayers.Util.extend(this,a)},success:function(){return this.code>0},CLASS_NAME:"OpenLayers.Protocol.Response"});OpenLayers.Protocol.Response.SUCCESS=1;OpenLayers.Protocol.Response.FAILURE=0;OpenLayers.Renderer=OpenLayers.Class({container:null,root:null,extent:null,locked:false,size:null,resolution:null,map:null,initialize:function(a,b){this.container=OpenLayers.Util.getElement(a)},destroy:function(){this.container=null;this.extent=null;this.size=null;this.resolution=null;this.map=null},supported:function(){return false},setExtent:function(a,b){this.extent=a.clone();if(b){this.resolution=null}},setSize:function(a){this.size=a.clone();this.resolution=null},getResolution:function(){this.resolution=this.resolution||this.map.getResolution();return this.resolution},drawFeature:function(a,b){if(b==null){b=a.style}if(a.geometry){var c=a.geometry.getBounds();if(c){if(!c.intersectsBounds(this.extent)){b={display:"none"}}var d=this.drawGeometry(a.geometry,b,a.id);if(b.display!="none"&&b.label&&d!==false){this.drawText(a.id,b,a.geometry.getCentroid())}else{this.removeText(a.id)}return d}}},drawGeometry:function(c,a,b){},drawText:function(c,b,a){},removeText:function(a){},clear:function(){},getFeatureIdFromEvent:function(a){},eraseFeatures:function(c){if(!(c instanceof Array)){c=[c]}for(var b=0,a=c.length;b<a;++b){this.eraseGeometry(c[b].geometry);this.removeText(c[b].id)}},eraseGeometry:function(a){},moveRoot:function(a){},getRenderLayerId:function(){return this.container.id},CLASS_NAME:"OpenLayers.Renderer"});OpenLayers.Strategy=OpenLayers.Class({layer:null,options:null,active:null,autoActivate:true,autoDestroy:true,initialize:function(a){OpenLayers.Util.extend(this,a);this.options=a;this.active=false},destroy:function(){this.deactivate();this.layer=null;this.options=null},setLayer:function(a){this.layer=a},activate:function(){if(!this.active){this.active=true;return true}return false},deactivate:function(){if(this.active){this.active=false;return true}return false},CLASS_NAME:"OpenLayers.Strategy"});OpenLayers.Rico.Color=OpenLayers.Class({initialize:function(c,b,a){this.rgb={r:c,g:b,b:a}},setRed:function(a){this.rgb.r=a},setGreen:function(a){this.rgb.g=a},setBlue:function(a){this.rgb.b=a},setHue:function(b){var a=this.asHSB();a.h=b;this.rgb=OpenLayers.Rico.Color.HSBtoRGB(a.h,a.s,a.b)},setSaturation:function(b){var a=this.asHSB();a.s=b;this.rgb=OpenLayers.Rico.Color.HSBtoRGB(a.h,a.s,a.b)},setBrightness:function(a){var c=this.asHSB();c.b=a;this.rgb=OpenLayers.Rico.Color.HSBtoRGB(c.h,c.s,c.b)},darken:function(b){var a=this.asHSB();this.rgb=OpenLayers.Rico.Color.HSBtoRGB(a.h,a.s,Math.max(a.b-b,0))},brighten:function(b){var a=this.asHSB();this.rgb=OpenLayers.Rico.Color.HSBtoRGB(a.h,a.s,Math.min(a.b+b,1))},blend:function(a){this.rgb.r=Math.floor((this.rgb.r+a.rgb.r)/2);this.rgb.g=Math.floor((this.rgb.g+a.rgb.g)/2);this.rgb.b=Math.floor((this.rgb.b+a.rgb.b)/2)},isBright:function(){var a=this.asHSB();return this.asHSB().b>0.5},isDark:function(){return !this.isBright()},asRGB:function(){return"rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")"},asHex:function(){return"#"+this.rgb.r.toColorPart()+this.rgb.g.toColorPart()+this.rgb.b.toColorPart()},asHSB:function(){return OpenLayers.Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b)},toString:function(){return this.asHex()}});OpenLayers.Rico.Color.createFromHex=function(d){if(d.length==4){var b=d;var d="#";for(var c=1;c<4;c++){d+=(b.charAt(c)+b.charAt(c))}}if(d.indexOf("#")==0){d=d.substring(1)}var g=d.substring(0,2);var f=d.substring(2,4);var a=d.substring(4,6);return new OpenLayers.Rico.Color(parseInt(g,16),parseInt(f,16),parseInt(a,16))};OpenLayers.Rico.Color.createColorFromBackground=function(d){var b=RicoUtil.getElementsComputedStyle(OpenLayers.Util.getElement(d),"backgroundColor","background-color");if(b=="transparent"&&d.parentNode){return OpenLayers.Rico.Color.createColorFromBackground(d.parentNode)}if(b==null){return new OpenLayers.Rico.Color(255,255,255)}if(b.indexOf("rgb(")==0){var a=b.substring(4,b.length-1);var c=a.split(",");return new OpenLayers.Rico.Color(parseInt(c[0]),parseInt(c[1]),parseInt(c[2]))}else{if(b.indexOf("#")==0){return OpenLayers.Rico.Color.createFromHex(b)}else{return new OpenLayers.Rico.Color(255,255,255)}}};OpenLayers.Rico.Color.HSBtoRGB=function(k,g,m){var c=0;var d=0;var o=0;if(g==0){c=parseInt(m*255+0.5);d=c;o=c}else{var j=(k-Math.floor(k))*6;var l=j-Math.floor(j);var b=m*(1-g);var a=m*(1-g*l);var r=m*(1-(g*(1-l)));switch(parseInt(j)){case 0:c=(m*255+0.5);d=(r*255+0.5);o=(b*255+0.5);break;case 1:c=(a*255+0.5);d=(m*255+0.5);o=(b*255+0.5);break;case 2:c=(b*255+0.5);d=(m*255+0.5);o=(r*255+0.5);break;case 3:c=(b*255+0.5);d=(a*255+0.5);o=(m*255+0.5);break;case 4:c=(r*255+0.5);d=(b*255+0.5);o=(m*255+0.5);break;case 5:c=(m*255+0.5);d=(b*255+0.5);o=(a*255+0.5);break}}return{r:parseInt(c),g:parseInt(d),b:parseInt(o)}};OpenLayers.Rico.Color.RGBtoHSB=function(a,h,o){var j;var f;var m;var q=(a>h)?a:h;if(o>q){q=o}var k=(a<h)?a:h;if(o<k){k=o}m=q/255;if(q!=0){f=(q-k)/q}else{f=0}if(f==0){j=0}else{var c=(q-a)/(q-k);var l=(q-h)/(q-k);var d=(q-o)/(q-k);if(a==q){j=d-l}else{if(h==q){j=2+c-d}else{j=4+l-c}}j=j/6;if(j<0){j=j+1}}return{h:j,s:f,b:m}};OpenLayers.Bounds=OpenLayers.Class({left:null,bottom:null,right:null,top:null,centerLonLat:null,initialize:function(d,a,b,c){if(d!=null){this.left=OpenLayers.Util.toFloat(d)}if(a!=null){this.bottom=OpenLayers.Util.toFloat(a)}if(b!=null){this.right=OpenLayers.Util.toFloat(b)}if(c!=null){this.top=OpenLayers.Util.toFloat(c)}},clone:function(){return new OpenLayers.Bounds(this.left,this.bottom,this.right,this.top)},equals:function(b){var a=false;if(b!=null){a=((this.left==b.left)&&(this.right==b.right)&&(this.top==b.top)&&(this.bottom==b.bottom))}return a},toString:function(){return("left-bottom=("+this.left+","+this.bottom+") right-top=("+this.right+","+this.top+")")},toArray:function(){return[this.left,this.bottom,this.right,this.top]},toBBOX:function(a){if(a==null){a=6}var b=Math.pow(10,a);var c=Math.round(this.left*b)/b+","+Math.round(this.bottom*b)/b+","+Math.round(this.right*b)/b+","+Math.round(this.top*b)/b;return c},toGeometry:function(){return new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(this.left,this.bottom),new OpenLayers.Geometry.Point(this.right,this.bottom),new OpenLayers.Geometry.Point(this.right,this.top),new OpenLayers.Geometry.Point(this.left,this.top)])])},getWidth:function(){return(this.right-this.left)},getHeight:function(){return(this.top-this.bottom)},getSize:function(){return new OpenLayers.Size(this.getWidth(),this.getHeight())},getCenterPixel:function(){return new OpenLayers.Pixel((this.left+this.right)/2,(this.bottom+this.top)/2)},getCenterLonLat:function(){if(!this.centerLonLat){this.centerLonLat=new OpenLayers.LonLat((this.left+this.right)/2,(this.bottom+this.top)/2)}return this.centerLonLat},scale:function(g,j){if(j==null){j=this.getCenterLonLat()}var a=[];var f,d;if(j.CLASS_NAME=="OpenLayers.LonLat"){f=j.lon;d=j.lat}else{f=j.x;d=j.y}var c=(this.left-f)*g+f;var b=(this.bottom-d)*g+d;var k=(this.right-f)*g+f;var h=(this.top-d)*g+d;return new OpenLayers.Bounds(c,b,k,h)},add:function(a,c){if((a==null)||(c==null)){var b=OpenLayers.i18n("boundsAddError");OpenLayers.Console.error(b);return null}return new OpenLayers.Bounds(this.left+a,this.bottom+c,this.right+a,this.top+c)},extend:function(a){var b=null;if(a){switch(a.CLASS_NAME){case"OpenLayers.LonLat":b=new OpenLayers.Bounds(a.lon,a.lat,a.lon,a.lat);break;case"OpenLayers.Geometry.Point":b=new OpenLayers.Bounds(a.x,a.y,a.x,a.y);break;case"OpenLayers.Bounds":b=a;break}if(b){this.centerLonLat=null;if((this.left==null)||(b.left<this.left)){this.left=b.left}if((this.bottom==null)||(b.bottom<this.bottom)){this.bottom=b.bottom}if((this.right==null)||(b.right>this.right)){this.right=b.right}if((this.top==null)||(b.top>this.top)){this.top=b.top}}}},containsLonLat:function(b,a){return this.contains(b.lon,b.lat,a)},containsPixel:function(b,a){return this.contains(b.x,b.y,a)},contains:function(b,d,a){if(a==null){a=true}if(b==null||d==null){return false}b=OpenLayers.Util.toFloat(b);d=OpenLayers.Util.toFloat(d);var c=false;if(a){c=((b>=this.left)&&(b<=this.right)&&(d>=this.bottom)&&(d<=this.top))}else{c=((b>this.left)&&(b<this.right)&&(d>this.bottom)&&(d<this.top))}return c},intersectsBounds:function(f,b){if(b==null){b=true}var d=false;var j=(this.left==f.right||this.right==f.left||this.top==f.bottom||this.bottom==f.top);if(b||!j){var h=(((f.bottom>=this.bottom)&&(f.bottom<=this.top))||((this.bottom>=f.bottom)&&(this.bottom<=f.top)));var g=(((f.top>=this.bottom)&&(f.top<=this.top))||((this.top>f.bottom)&&(this.top<f.top)));var c=(((f.left>=this.left)&&(f.left<=this.right))||((this.left>=f.left)&&(this.left<=f.right)));var a=(((f.right>=this.left)&&(f.right<=this.right))||((this.right>=f.left)&&(this.right<=f.right)));d=((h||g)&&(c||a))}return d},containsBounds:function(h,b,a){if(b==null){b=false}if(a==null){a=true}var c=this.contains(h.left,h.bottom,a);var d=this.contains(h.right,h.bottom,a);var g=this.contains(h.left,h.top,a);var f=this.contains(h.right,h.top,a);return(b)?(c||d||g||f):(c&&d&&g&&f)},determineQuadrant:function(c){var b="";var a=this.getCenterLonLat();b+=(c.lat<a.lat)?"b":"t";b+=(c.lon<a.lon)?"l":"r";return b},transform:function(d,b){this.centerLonLat=null;var f=OpenLayers.Projection.transform({x:this.left,y:this.bottom},d,b);var a=OpenLayers.Projection.transform({x:this.right,y:this.bottom},d,b);var c=OpenLayers.Projection.transform({x:this.left,y:this.top},d,b);var g=OpenLayers.Projection.transform({x:this.right,y:this.top},d,b);this.left=Math.min(f.x,c.x);this.bottom=Math.min(f.y,a.y);this.right=Math.max(a.x,g.x);this.top=Math.max(c.y,g.y);return this},wrapDateLine:function(a,c){c=c||{};var d=c.leftTolerance||0;var b=c.rightTolerance||0;var f=this.clone();if(a){while(f.left<a.left&&(f.right-b)<=a.left){f=f.add(a.getWidth(),0)}while((f.left+d)>=a.right&&f.right>a.right){f=f.add(-a.getWidth(),0)}}return f},CLASS_NAME:"OpenLayers.Bounds"});OpenLayers.Bounds.fromString=function(b){var a=b.split(",");return OpenLayers.Bounds.fromArray(a)};OpenLayers.Bounds.fromArray=function(a){return new OpenLayers.Bounds(parseFloat(a[0]),parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3]))};OpenLayers.Bounds.fromSize=function(a){return new OpenLayers.Bounds(0,a.h,a.w,0)};OpenLayers.Bounds.oppositeQuadrant=function(a){var b="";b+=(a.charAt(0)=="t")?"b":"t";b+=(a.charAt(1)=="l")?"r":"l";return b};OpenLayers.LonLat=OpenLayers.Class({lon:0,lat:0,initialize:function(b,a){this.lon=OpenLayers.Util.toFloat(b);this.lat=OpenLayers.Util.toFloat(a)},toString:function(){return("lon="+this.lon+",lat="+this.lat)},toShortString:function(){return(this.lon+", "+this.lat)},clone:function(){return new OpenLayers.LonLat(this.lon,this.lat)},add:function(c,a){if((c==null)||(a==null)){var b=OpenLayers.i18n("lonlatAddError");OpenLayers.Console.error(b);return null}return new OpenLayers.LonLat(this.lon+c,this.lat+a)},equals:function(b){var a=false;if(b!=null){a=((this.lon==b.lon&&this.lat==b.lat)||(isNaN(this.lon)&&isNaN(this.lat)&&isNaN(b.lon)&&isNaN(b.lat)))}return a},transform:function(c,b){var a=OpenLayers.Projection.transform({x:this.lon,y:this.lat},c,b);this.lon=a.x;this.lat=a.y;return this},wrapDateLine:function(a){var b=this.clone();if(a){while(b.lon<a.left){b.lon+=a.getWidth()}while(b.lon>a.right){b.lon-=a.getWidth()}}return b},CLASS_NAME:"OpenLayers.LonLat"});OpenLayers.LonLat.fromString=function(b){var a=b.split(",");return new OpenLayers.LonLat(parseFloat(a[0]),parseFloat(a[1]))};OpenLayers.Pixel=OpenLayers.Class({x:0,y:0,initialize:function(a,b){this.x=parseFloat(a);this.y=parseFloat(b)},toString:function(){return("x="+this.x+",y="+this.y)},clone:function(){return new OpenLayers.Pixel(this.x,this.y)},equals:function(a){var b=false;if(a!=null){b=((this.x==a.x&&this.y==a.y)||(isNaN(this.x)&&isNaN(this.y)&&isNaN(a.x)&&isNaN(a.y)))}return b},add:function(a,c){if((a==null)||(c==null)){var b=OpenLayers.i18n("pixelAddError");OpenLayers.Console.error(b);return null}return new OpenLayers.Pixel(this.x+a,this.y+c)},offset:function(a){var b=this.clone();if(a){b=this.add(a.x,a.y)}return b},CLASS_NAME:"OpenLayers.Pixel"});OpenLayers.Control=OpenLayers.Class({id:null,map:null,div:null,type:null,allowSelection:false,displayClass:"",title:"",active:null,handler:null,eventListeners:null,events:null,EVENT_TYPES:["activate","deactivate"],initialize:function(a){this.displayClass=this.CLASS_NAME.replace("OpenLayers.","ol").replace(/\./g,"");OpenLayers.Util.extend(this,a);this.events=new OpenLayers.Events(this,null,this.EVENT_TYPES);if(this.eventListeners instanceof Object){this.events.on(this.eventListeners)}if(this.id==null){this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_")}},destroy:function(){if(this.events){if(this.eventListeners){this.events.un(this.eventListeners)}this.events.destroy();this.events=null}this.eventListeners=null;if(this.handler){this.handler.destroy();this.handler=null}if(this.handlers){for(var a in this.handlers){if(this.handlers.hasOwnProperty(a)&&typeof this.handlers[a].destroy=="function"){this.handlers[a].destroy()}}this.handlers=null}if(this.map){this.map.removeControl(this);this.map=null}},setMap:function(a){this.map=a;if(this.handler){this.handler.setMap(a)}},draw:function(a){if(this.div==null){this.div=OpenLayers.Util.createDiv(this.id);this.div.className=this.displayClass;if(!this.allowSelection){this.div.className+=" olControlNoSelect";this.div.setAttribute("unselectable","on",0);this.div.onselectstart=function(){return(false)}}if(this.title!=""){this.div.title=this.title}}if(a!=null){this.position=a.clone()}this.moveTo(this.position);return this.div},moveTo:function(a){if((a!=null)&&(this.div!=null)){this.div.style.left=a.x+"px";this.div.style.top=a.y+"px"}},activate:function(){if(this.active){return false}if(this.handler){this.handler.activate()}this.active=true;if(this.map){OpenLayers.Element.addClass(this.map.viewPortDiv,this.displayClass.replace(/ /g,"")+"Active")}this.events.triggerEvent("activate");return true},deactivate:function(){if(this.active){if(this.handler){this.handler.deactivate()}this.active=false;if(this.map){OpenLayers.Element.removeClass(this.map.viewPortDiv,this.displayClass.replace(/ /g,"")+"Active")}this.events.triggerEvent("deactivate");return true}return false},CLASS_NAME:"OpenLayers.Control"});OpenLayers.Control.TYPE_BUTTON=1;OpenLayers.Control.TYPE_TOGGLE=2;OpenLayers.Control.TYPE_TOOL=3;OpenLayers.Lang={code:null,defaultCode:"en",getCode:function(){if(!OpenLayers.Lang.code){OpenLayers.Lang.setCode()}return OpenLayers.Lang.code},setCode:function(b){var d;if(!b){b=(OpenLayers.Util.getBrowserName()=="msie")?navigator.userLanguage:navigator.language}var c=b.split("-");c[0]=c[0].toLowerCase();if(typeof OpenLayers.Lang[c[0]]=="object"){d=c[0]}if(c[1]){var a=c[0]+"-"+c[1].toUpperCase();if(typeof OpenLayers.Lang[a]=="object"){d=a}}if(!d){OpenLayers.Console.warn("Failed to find OpenLayers.Lang."+c.join("-")+" dictionary, falling back to default language");d=OpenLayers.Lang.defaultCode}OpenLayers.Lang.code=d},translate:function(b,a){var d=OpenLayers.Lang[OpenLayers.Lang.getCode()];var c=d[b];if(!c){c=b}if(a){c=OpenLayers.String.format(c,a)}return c}};OpenLayers.i18n=OpenLayers.Lang.translate;OpenLayers.Popup.Anchored=OpenLayers.Class(OpenLayers.Popup,{relativePosition:null,keepInMap:true,anchor:null,initialize:function(j,d,h,c,b,g,f){var a=[j,d,h,c,g,f];OpenLayers.Popup.prototype.initialize.apply(this,a);this.anchor=(b!=null)?b:{size:new OpenLayers.Size(0,0),offset:new OpenLayers.Pixel(0,0)}},destroy:function(){this.anchor=null;this.relativePosition=null;OpenLayers.Popup.prototype.destroy.apply(this,arguments)},show:function(){this.updatePosition();OpenLayers.Popup.prototype.show.apply(this,arguments)},moveTo:function(c){var b=this.relativePosition;this.relativePosition=this.calculateRelativePosition(c);var d=this.calculateNewPx(c);var a=new Array(d);OpenLayers.Popup.prototype.moveTo.apply(this,a);if(this.relativePosition!=b){this.updateRelativePosition()}},setSize:function(b){OpenLayers.Popup.prototype.setSize.apply(this,arguments);if((this.lonlat)&&(this.map)){var a=this.map.getLayerPxFromLonLat(this.lonlat);this.moveTo(a)}},calculateRelativePosition:function(b){var d=this.map.getLonLatFromLayerPx(b);var c=this.map.getExtent();var a=c.determineQuadrant(d);return OpenLayers.Bounds.oppositeQuadrant(a)},updateRelativePosition:function(){},calculateNewPx:function(b){var f=b.offset(this.anchor.offset);var a=this.size||this.contentSize;var d=(this.relativePosition.charAt(0)=="t");f.y+=(d)?-a.h:this.anchor.size.h;var c=(this.relativePosition.charAt(1)=="l");f.x+=(c)?-a.w:this.anchor.size.w;return f},CLASS_NAME:"OpenLayers.Popup.Anchored"});OpenLayers.Protocol.SQL=OpenLayers.Class(OpenLayers.Protocol,{databaseName:"ol",tableName:"ol_vector_features",postReadFiltering:true,initialize:function(a){OpenLayers.Protocol.prototype.initialize.apply(this,[a])},destroy:function(){OpenLayers.Protocol.prototype.destroy.apply(this)},supported:function(){return false},evaluateFilter:function(a,b){return b&&this.postReadFiltering?b.evaluate(a):true},CLASS_NAME:"OpenLayers.Protocol.SQL"});OpenLayers.Protocol.WFS=function(b){b=OpenLayers.Util.applyDefaults(b,OpenLayers.Protocol.WFS.DEFAULTS);var a=OpenLayers.Protocol.WFS["v"+b.version.replace(/\./g,"_")];if(!a){throw"Unsupported WFS version: "+b.version}return new a(b)};OpenLayers.Protocol.WFS.fromWMSLayer=function(d,c){var a,f;var h=d.params.LAYERS;var g=(h instanceof Array?h[0]:h).split(":");if(g.length>1){f=g[0]}a=g.pop();var b={url:d.url,featureType:a,featurePrefix:f,srsName:d.projection&&d.projection.getCode()||d.map&&d.map.getProjectionObject().getCode(),version:"1.1.0"};return new OpenLayers.Protocol.WFS(OpenLayers.Util.applyDefaults(c,b))};OpenLayers.Protocol.WFS.DEFAULTS={version:"1.0.0"};OpenLayers.Renderer.Canvas=OpenLayers.Class(OpenLayers.Renderer,{canvas:null,features:null,geometryMap:null,initialize:function(a){OpenLayers.Renderer.prototype.initialize.apply(this,arguments);this.root=document.createElement("canvas");this.container.appendChild(this.root);this.canvas=this.root.getContext("2d");this.features={};this.geometryMap={}},eraseGeometry:function(a){this.eraseFeatures(this.features[this.geometryMap[a.id]][0])},supported:function(){var a=document.createElement("canvas");return !!a.getContext},setExtent:function(a){this.extent=a.clone();this.resolution=null;this.redraw()},setSize:function(a){this.size=a.clone();this.root.style.width=a.w+"px";this.root.style.height=a.h+"px";this.root.width=a.w;this.root.height=a.h;this.resolution=null},drawFeature:function(a,b){if(b==null){b=a.style}b=OpenLayers.Util.extend({fillColor:"#000000",strokeColor:"#000000",strokeWidth:2,fillOpacity:1,strokeOpacity:1},b);this.features[a.id]=[a,b];if(a.geometry){this.geometryMap[a.geometry.id]=a.id}this.redraw()},drawGeometry:function(d,c){var b=d.CLASS_NAME;if((b=="OpenLayers.Geometry.Collection")||(b=="OpenLayers.Geometry.MultiPoint")||(b=="OpenLayers.Geometry.MultiLineString")||(b=="OpenLayers.Geometry.MultiPolygon")){for(var a=0;a<d.components.length;a++){this.drawGeometry(d.components[a],c)}return}switch(d.CLASS_NAME){case"OpenLayers.Geometry.Point":this.drawPoint(d,c);break;case"OpenLayers.Geometry.LineString":this.drawLineString(d,c);break;case"OpenLayers.Geometry.LinearRing":this.drawLinearRing(d,c);break;case"OpenLayers.Geometry.Polygon":this.drawPolygon(d,c);break;default:break}},drawExternalGraphic:function(k,a){var f=new Image();f.src=a.externalGraphic;if(a.graphicTitle){f.title=a.graphicTitle}var c=a.graphicWidth||a.graphicHeight;var j=a.graphicHeight||a.graphicWidth;c=c?c:a.pointRadius*2;j=j?j:a.pointRadius*2;var h=(a.graphicXOffset!=undefined)?a.graphicXOffset:-(0.5*c);var d=(a.graphicYOffset!=undefined)?a.graphicYOffset:-(0.5*j);var g=a.graphicOpacity||a.fillOpacity;var b={img:f,x:(k[0]+h),y:(k[1]+d),width:c,height:j,canvas:this.canvas};f.onload=OpenLayers.Function.bind(function(){this.canvas.drawImage(this.img,this.x,this.y,this.width,this.height)},b)},setCanvasStyle:function(b,a){if(b=="fill"){this.canvas.globalAlpha=a.fillOpacity;this.canvas.fillStyle=a.fillColor}else{if(b=="stroke"){this.canvas.globalAlpha=a.strokeOpacity;this.canvas.strokeStyle=a.strokeColor;this.canvas.lineWidth=a.strokeWidth}else{this.canvas.globalAlpha=0;this.canvas.lineWidth=1}}},drawPoint:function(c,a){if(a.graphic!==false){var b=this.getLocalXY(c);if(a.externalGraphic){this.drawExternalGraphic(b,a)}else{if(a.fill!==false){this.setCanvasStyle("fill",a);this.canvas.beginPath();this.canvas.arc(b[0],b[1],6,0,Math.PI*2,true);this.canvas.fill()}if(a.stroke!==false){this.setCanvasStyle("stroke",a);this.canvas.beginPath();this.canvas.arc(b[0],b[1],6,0,Math.PI*2,true);this.canvas.stroke();this.setCanvasStyle("reset")}}}},drawLineString:function(d,b){if(b.stroke!==false){this.setCanvasStyle("stroke",b);this.canvas.beginPath();var f=this.getLocalXY(d.components[0]);this.canvas.moveTo(f[0],f[1]);for(var a=1;a<d.components.length;a++){var c=this.getLocalXY(d.components[a]);this.canvas.lineTo(c[0],c[1])}this.canvas.stroke()}this.setCanvasStyle("reset")},drawLinearRing:function(f,c){if(c.fill!==false){this.setCanvasStyle("fill",c);this.canvas.beginPath();var g=this.getLocalXY(f.components[0]);this.canvas.moveTo(g[0],g[1]);for(var b=1;b<f.components.length-1;b++){var d=this.getLocalXY(f.components[b]);this.canvas.lineTo(d[0],d[1])}this.canvas.fill()}if(c.stroke!==false){var a=this.canvas.lineWidth;this.setCanvasStyle("stroke",c);this.canvas.beginPath();var g=this.getLocalXY(f.components[0]);this.canvas.moveTo(g[0],g[1]);for(var b=1;b<f.components.length;b++){var d=this.getLocalXY(f.components[b]);this.canvas.lineTo(d[0],d[1])}this.canvas.stroke()}this.setCanvasStyle("reset")},drawPolygon:function(c,b){this.drawLinearRing(c.components[0],b);for(var a=1;a<c.components.length;a++){this.drawLinearRing(c.components[a],{fillOpacity:0,strokeWidth:0,strokeOpacity:0,strokeColor:"#000000",fillColor:"#000000"})}},drawText:function(b,d){d=OpenLayers.Util.extend({fontColor:"#000000",labelAlign:"cm"},d);var f=this.getLocalXY(b);this.setCanvasStyle("reset");this.canvas.fillStyle=d.fontColor;this.canvas.globalAlpha=1;var g=d.fontWeight+" "+d.fontSize+" "+d.fontFamily;if(this.canvas.fillText){var c=OpenLayers.Renderer.Canvas.LABEL_ALIGN[d.labelAlign[0]]||"middle";this.canvas.font=g;this.canvas.textAlign=c;this.canvas.fillText(d.label,f[0],f[1])}else{if(this.canvas.mozDrawText){this.canvas.mozTextStyle=g;var a=this.canvas.mozMeasureText(d.label);switch(d.labelAlign[0]){case"l":break;case"r":f[0]-=a;break;case"c":default:f[0]-=a/2}this.canvas.translate(f[0],f[1]);this.canvas.mozDrawText(d.label);this.canvas.translate(-1*f[0],-1*f[1])}}this.setCanvasStyle("reset")},getLocalXY:function(b){var c=this.getResolution();var d=this.extent;var a=(b.x/c+(-d.left/c));var f=((d.top/c)-b.y/c);return[a,f]},clear:function(){this.canvas.clearRect(0,0,this.root.width,this.root.height)},getFeatureIdFromEvent:function(a){var g=this.map.getLonLatFromPixel(a.xy);var b=this.getResolution();var f=new OpenLayers.Bounds(g.lon-b*5,g.lat-b*5,g.lon+b*5,g.lat+b*5);var c=f.toGeometry();for(var d in this.features){if(!this.features.hasOwnProperty(d)){continue}if(this.features[d][0].geometry.intersects(c)){return d}}return null},eraseFeatures:function(b){if(!(b instanceof Array)){b=[b]}for(var a=0;a<b.length;++a){delete this.features[b[a].id]}this.redraw()},redraw:function(){if(!this.locked){this.clear();var f=[];var b,c;for(var g in this.features){if(!this.features.hasOwnProperty(g)){continue}b=this.features[g][0];c=this.features[g][1];if(!b.geometry){continue}this.drawGeometry(b.geometry,c);if(c.label){f.push([b,c])}}var d;for(var a=0;len=f.length,a<len;++a){d=f[a];this.drawText(d[0].geometry.getCentroid(),d[1])}}},CLASS_NAME:"OpenLayers.Renderer.Canvas"});OpenLayers.Renderer.Canvas.LABEL_ALIGN={l:"left",r:"right"};OpenLayers.ElementsIndexer=OpenLayers.Class({maxZIndex:null,order:null,indices:null,compare:null,initialize:function(a){this.compare=a?OpenLayers.ElementsIndexer.IndexingMethods.Z_ORDER_Y_ORDER:OpenLayers.ElementsIndexer.IndexingMethods.Z_ORDER_DRAWING_ORDER;this.order=[];this.indices={};this.maxZIndex=0},insert:function(c){if(this.exists(c)){this.remove(c)}var g=c.id;this.determineZIndex(c);var d=-1;var f=this.order.length;var a;while(f-d>1){a=parseInt((d+f)/2);var b=this.compare(this,c,OpenLayers.Util.getElement(this.order[a]));if(b>0){d=a}else{f=a}}this.order.splice(f,0,g);this.indices[g]=this.getZIndex(c);return this.getNextElement(f)},remove:function(b){var d=b.id;var a=OpenLayers.Util.indexOf(this.order,d);if(a>=0){this.order.splice(a,1);delete this.indices[d];if(this.order.length>0){var c=this.order[this.order.length-1];this.maxZIndex=this.indices[c]}else{this.maxZIndex=0}}},clear:function(){this.order=[];this.indices={};this.maxZIndex=0},exists:function(a){return(this.indices[a.id]!=null)},getZIndex:function(a){return a._style.graphicZIndex},determineZIndex:function(a){var b=a._style.graphicZIndex;if(b==null){b=this.maxZIndex;a._style.graphicZIndex=b}else{if(b>this.maxZIndex){this.maxZIndex=b}}},getNextElement:function(b){var a=b+1;if(a<this.order.length){var c=OpenLayers.Util.getElement(this.order[a]);if(c==undefined){c=this.getNextElement(a)}return c}else{return null}},CLASS_NAME:"OpenLayers.ElementsIndexer"});OpenLayers.ElementsIndexer.IndexingMethods={Z_ORDER:function(f,d,b){var a=f.getZIndex(d);var g=0;if(b){var c=f.getZIndex(b);g=a-c}return g},Z_ORDER_DRAWING_ORDER:function(c,b,a){var d=OpenLayers.ElementsIndexer.IndexingMethods.Z_ORDER(c,b,a);if(a&&d==0){d=1}return d},Z_ORDER_Y_ORDER:function(g,f,b){var h=OpenLayers.ElementsIndexer.IndexingMethods.Z_ORDER(g,f,b);if(b&&h==0){var c=f._geometry.getBounds().bottom;var d=b._geometry.getBounds().bottom;var a=d-c;h=(a==0)?1:a}return h}};OpenLayers.Renderer.Elements=OpenLayers.Class(OpenLayers.Renderer,{rendererRoot:null,root:null,vectorRoot:null,textRoot:null,xmlns:null,indexer:null,BACKGROUND_ID_SUFFIX:"_background",LABEL_ID_SUFFIX:"_label",minimumSymbolizer:{strokeLinecap:"round",strokeOpacity:1,strokeDashstyle:"solid",fillOpacity:1,pointRadius:0},initialize:function(a,b){OpenLayers.Renderer.prototype.initialize.apply(this,arguments);this.rendererRoot=this.createRenderRoot();this.root=this.createRoot("_root");this.vectorRoot=this.createRoot("_vroot");this.textRoot=this.createRoot("_troot");this.root.appendChild(this.vectorRoot);this.root.appendChild(this.textRoot);this.rendererRoot.appendChild(this.root);this.container.appendChild(this.rendererRoot);if(b&&(b.zIndexing||b.yOrdering)){this.indexer=new OpenLayers.ElementsIndexer(b.yOrdering)}},destroy:function(){this.clear();this.rendererRoot=null;this.root=null;this.xmlns=null;OpenLayers.Renderer.prototype.destroy.apply(this,arguments)},clear:function(){if(this.vectorRoot){while(this.vectorRoot.childNodes.length>0){this.vectorRoot.removeChild(this.vectorRoot.firstChild)}}if(this.textRoot){while(this.textRoot.childNodes.length>0){this.textRoot.removeChild(this.textRoot.firstChild)}}if(this.indexer){this.indexer.clear()}},getNodeType:function(b,a){},drawGeometry:function(h,d,g){var c=h.CLASS_NAME;var j=true;if((c=="OpenLayers.Geometry.Collection")||(c=="OpenLayers.Geometry.MultiPoint")||(c=="OpenLayers.Geometry.MultiLineString")||(c=="OpenLayers.Geometry.MultiPolygon")){for(var b=0,a=h.components.length;b<a;b++){j=this.drawGeometry(h.components[b],d,g)&&j}return j}j=false;if(d.display!="none"){if(d.backgroundGraphic){this.redrawBackgroundNode(h.id,h,d,g)}j=this.redrawNode(h.id,h,d,g)}if(j==false){var f=document.getElementById(h.id);if(f){if(f._style.backgroundGraphic){f.parentNode.removeChild(document.getElementById(h.id+this.BACKGROUND_ID_SUFFIX))}f.parentNode.removeChild(f)}}return j},redrawNode:function(h,g,b,f){var c=this.nodeFactory(h,this.getNodeType(g,b));c._featureId=f;c._geometry=g;c._geometryClass=g.CLASS_NAME;c._style=b;var a=this.drawGeometryNode(c,g,b);if(a===false){return false}c=a.node;if(this.indexer){var d=this.indexer.insert(c);if(d){this.vectorRoot.insertBefore(c,d)}else{this.vectorRoot.appendChild(c)}}else{if(c.parentNode!==this.vectorRoot){this.vectorRoot.appendChild(c)}}this.postDraw(c);return a.complete},redrawBackgroundNode:function(f,d,b,c){var a=OpenLayers.Util.extend({},b);a.externalGraphic=a.backgroundGraphic;a.graphicXOffset=a.backgroundXOffset;a.graphicYOffset=a.backgroundYOffset;a.graphicZIndex=a.backgroundGraphicZIndex;a.graphicWidth=a.backgroundWidth||a.graphicWidth;a.graphicHeight=a.backgroundHeight||a.graphicHeight;a.backgroundGraphic=null;a.backgroundXOffset=null;a.backgroundYOffset=null;a.backgroundGraphicZIndex=null;return this.redrawNode(f+this.BACKGROUND_ID_SUFFIX,d,a,null)},drawGeometryNode:function(c,f,b){b=b||c._style;OpenLayers.Util.applyDefaults(b,this.minimumSymbolizer);var a={isFilled:b.fill===undefined?true:b.fill,isStroked:b.stroke===undefined?!!b.strokeWidth:b.stroke};var d;switch(f.CLASS_NAME){case"OpenLayers.Geometry.Point":if(b.graphic===false){a.isFilled=false;a.isStroked=false}d=this.drawPoint(c,f);break;case"OpenLayers.Geometry.LineString":a.isFilled=false;d=this.drawLineString(c,f);break;case"OpenLayers.Geometry.LinearRing":d=this.drawLinearRing(c,f);break;case"OpenLayers.Geometry.Polygon":d=this.drawPolygon(c,f);break;case"OpenLayers.Geometry.Surface":d=this.drawSurface(c,f);break;case"OpenLayers.Geometry.Rectangle":d=this.drawRectangle(c,f);break;default:break}c._style=b;c._options=a;if(d!=false){return{node:this.setStyle(c,b,a,f),complete:d}}else{return false}},postDraw:function(a){},drawPoint:function(a,b){},drawLineString:function(a,b){},drawLinearRing:function(a,b){},drawPolygon:function(a,b){},drawRectangle:function(a,b){},drawCircle:function(a,b){},drawSurface:function(a,b){},removeText:function(b){var a=document.getElementById(b+this.LABEL_ID_SUFFIX);if(a){this.textRoot.removeChild(a)}},getFeatureIdFromEvent:function(a){var d=a.target;var b=d&&d.correspondingUseElement;var c=b?b:(d||a.srcElement);var f=c._featureId;return f},eraseGeometry:function(g){if((g.CLASS_NAME=="OpenLayers.Geometry.MultiPoint")||(g.CLASS_NAME=="OpenLayers.Geometry.MultiLineString")||(g.CLASS_NAME=="OpenLayers.Geometry.MultiPolygon")||(g.CLASS_NAME=="OpenLayers.Geometry.Collection")){for(var d=0,a=g.components.length;d<a;d++){this.eraseGeometry(g.components[d])}}else{var c=OpenLayers.Util.getElement(g.id);if(c&&c.parentNode){if(c.geometry){c.geometry.destroy();c.geometry=null}c.parentNode.removeChild(c);if(this.indexer){this.indexer.remove(c)}if(c._style.backgroundGraphic){var b=g.id+this.BACKGROUND_ID_SUFFIX;var f=OpenLayers.Util.getElement(b);if(f&&f.parentNode){f.parentNode.removeChild(f)}}}}},nodeFactory:function(c,a){var b=OpenLayers.Util.getElement(c);if(b){if(!this.nodeTypeCompare(b,a)){b.parentNode.removeChild(b);b=this.nodeFactory(c,a)}}else{b=this.createNode(a,c)}return b},nodeTypeCompare:function(b,a){},createNode:function(a,b){},moveRoot:function(b){var a=this.root;if(b.root.parentNode==this.rendererRoot){a=b.root}a.parentNode.removeChild(a);b.rendererRoot.appendChild(a)},getRenderLayerId:function(){return this.root.parentNode.parentNode.id},isComplexSymbol:function(a){return(a!="circle")&&!!a},CLASS_NAME:"OpenLayers.Renderer.Elements"});OpenLayers.Renderer.symbol={star:[350,75,379,161,469,161,397,215,423,301,350,250,277,301,303,215,231,161,321,161,350,75],cross:[4,0,6,0,6,4,10,4,10,6,6,6,6,10,4,10,4,6,0,6,0,4,4,4,4,0],x:[0,0,25,0,50,35,75,0,100,0,65,50,100,100,75,100,50,65,25,100,0,100,35,50,0,0],square:[0,0,0,1,1,1,1,0,0,0],triangle:[0,10,10,10,5,0,0,10]};OpenLayers.Strategy.Cluster=OpenLayers.Class(OpenLayers.Strategy,{distance:20,threshold:null,features:null,clusters:null,clustering:false,resolution:null,initialize:function(a){OpenLayers.Strategy.prototype.initialize.apply(this,[a])},activate:function(){var a=OpenLayers.Strategy.prototype.activate.call(this);if(a){this.layer.events.on({beforefeaturesadded:this.cacheFeatures,moveend:this.cluster,scope:this})}return a},deactivate:function(){var a=OpenLayers.Strategy.prototype.deactivate.call(this);if(a){this.clearCache();this.layer.events.un({beforefeaturesadded:this.cacheFeatures,moveend:this.cluster,scope:this})}return a},cacheFeatures:function(b){var a=true;if(!this.clustering){this.clearCache();this.features=b.features;this.cluster();a=false}return a},clearCache:function(){this.features=null},cluster:function(a){if((!a||a.zoomChanged)&&this.features){var c=this.layer.map.getResolution();if(c!=this.resolution||!this.clustersExist()){this.resolution=c;var k=[];var o,b,l;for(var f=0;f<this.features.length;++f){o=this.features[f];if(o.geometry){b=false;for(var d=0;d<k.length;++d){l=k[d];if(this.shouldCluster(l,o)){this.addToCluster(l,o);b=true;break}}if(!b){k.push(this.createCluster(this.features[f]))}}}this.layer.destroyFeatures();if(k.length>0){if(this.threshold>1){var h=k.slice();k=[];var m;for(var f=0,g=h.length;f<g;++f){m=h[f];if(m.attributes.count<this.threshold){Array.prototype.push.apply(k,m.cluster)}else{k.push(m)}}}this.clustering=true;this.layer.addFeatures(k);this.clustering=false}this.clusters=k}}},clustersExist:function(){var b=false;if(this.clusters&&this.clusters.length>0&&this.clusters.length==this.layer.features.length){b=true;for(var a=0;a<this.clusters.length;++a){if(this.clusters[a]!=this.layer.features[a]){b=false;break}}}return b},shouldCluster:function(a,b){var f=a.geometry.getBounds().getCenterLonLat();var c=b.geometry.getBounds().getCenterLonLat();var d=(Math.sqrt(Math.pow((f.lon-c.lon),2)+Math.pow((f.lat-c.lat),2))/this.resolution);return(d<=this.distance)},addToCluster:function(a,b){a.cluster.push(b);a.attributes.count+=1},createCluster:function(c){var b=c.geometry.getBounds().getCenterLonLat();var a=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(b.lon,b.lat),{count:1});a.cluster=[c];return a},CLASS_NAME:"OpenLayers.Strategy.Cluster"});OpenLayers.Strategy.Fixed=OpenLayers.Class(OpenLayers.Strategy,{preload:false,initialize:function(a){OpenLayers.Strategy.prototype.initialize.apply(this,[a])},destroy:function(){OpenLayers.Strategy.prototype.destroy.apply(this,arguments)},activate:function(){if(OpenLayers.Strategy.prototype.activate.apply(this,arguments)){this.layer.events.on({refresh:this.load,scope:this});if(this.layer.visibility==true||this.preload){this.load()}else{this.layer.events.on({visibilitychanged:this.load,scope:this})}return true}return false},deactivate:function(){var a=OpenLayers.Strategy.prototype.deactivate.call(this);if(a){this.layer.events.un({refresh:this.load,visibilitychanged:this.load,scope:this})}return a},load:function(a){this.layer.events.triggerEvent("loadstart");this.layer.protocol.read(OpenLayers.Util.applyDefaults({callback:this.merge,scope:this},a));this.layer.events.un({visibilitychanged:this.load,scope:this})},merge:function(h){this.layer.destroyFeatures();var f=h.features;if(f&&f.length>0){var g=this.layer.projection;var d=this.layer.map.getProjectionObject();if(!d.equals(g)){var c;for(var b=0,a=f.length;b<a;++b){c=f[b].geometry;if(c){c.transform(g,d)}}}this.layer.addFeatures(f)}this.layer.events.triggerEvent("loadend")},CLASS_NAME:"OpenLayers.Strategy.Fixed"});OpenLayers.Strategy.Paging=OpenLayers.Class(OpenLayers.Strategy,{features:null,length:10,num:null,paging:false,initialize:function(a){OpenLayers.Strategy.prototype.initialize.apply(this,[a])},activate:function(){var a=OpenLayers.Strategy.prototype.activate.call(this);if(a){this.layer.events.on({beforefeaturesadded:this.cacheFeatures,scope:this})}return a},deactivate:function(){var a=OpenLayers.Strategy.prototype.deactivate.call(this);if(a){this.clearCache();this.layer.events.un({beforefeaturesadded:this.cacheFeatures,scope:this})}return a},cacheFeatures:function(a){if(!this.paging){this.clearCache();this.features=a.features;this.pageNext(a)}},clearCache:function(){if(this.features){for(var a=0;a<this.features.length;++a){this.features[a].destroy()}}this.features=null;this.num=null},pageCount:function(){var a=this.features?this.features.length:0;return Math.ceil(a/this.length)},pageNum:function(){return this.num},pageLength:function(a){if(a&&a>0){this.length=a}return this.length},pageNext:function(a){var b=false;if(this.features){if(this.num===null){this.num=-1}var c=(this.num+1)*this.length;b=this.page(c,a)}return b},pagePrevious:function(){var a=false;if(this.features){if(this.num===null){this.num=this.pageCount()}var b=(this.num-1)*this.length;a=this.page(b)}return a},page:function(f,c){var d=false;if(this.features){if(f>=0&&f<this.features.length){var a=Math.floor(f/this.length);if(a!=this.num){this.paging=true;var b=this.features.slice(f,f+this.length);this.layer.removeFeatures(this.layer.features);this.num=a;if(c&&c.features){c.features=b}else{this.layer.addFeatures(b)}this.paging=false;d=true}}}return d},CLASS_NAME:"OpenLayers.Strategy.Paging"});OpenLayers.Strategy.Save=OpenLayers.Class(OpenLayers.Strategy,{auto:false,timer:null,initialize:function(a){OpenLayers.Strategy.prototype.initialize.apply(this,[a])},activate:function(){var a=OpenLayers.Strategy.prototype.activate.call(this);if(a){if(this.auto){if(typeof this.auto==="number"){this.timer=window.setInterval(OpenLayers.Function.bind(this.save,this),this.auto*1000)}else{this.layer.events.on({featureadded:this.triggerSave,afterfeaturemodified:this.triggerSave,scope:this})}}}return a},deactivate:function(){var a=OpenLayers.Strategy.prototype.deactivate.call(this);if(a){if(this.auto){if(typeof this.auto==="number"){window.clearInterval(this.timer)}else{this.layer.events.un({featureadded:this.triggerSave,afterfeaturemodified:this.triggerSave,scope:this})}}}return a},triggerSave:function(b){var a=b.feature;if(a.state===OpenLayers.State.INSERT||a.state===OpenLayers.State.UPDATE||a.state===OpenLayers.State.DELETE){this.save([b.feature])}},save:function(d){if(!d){d=this.layer.features}var g=this.layer.projection;var c=this.layer.map.getProjectionObject();if(!c.equals(g)){var a=d.length;var f=new Array(a);var j,h;for(var b=0;b<a;++b){j=d[b];h=j.clone();h.fid=j.fid;h.state=j.state;h._original=j;h.geometry.transform(c,g);f[b]=h}d=f}this.layer.protocol.commit(d,{callback:this.onCommit,scope:this})},onCommit:function(d){if(d.success()){var b=d.reqFeatures;var a,l;var c=[];var k=d.insertIds||[];var f=0;for(var g=0,h=b.length;g<h;++g){l=b[g];l=l._original||l;a=l.state;if(a){if(a==OpenLayers.State.DELETE){c.push(l)}else{if(a==OpenLayers.State.INSERT){l.fid=k[f];++f}}l.state=null}}if(c.length>0){this.layer.destroyFeatures(c)}}},CLASS_NAME:"OpenLayers.Strategy.Save"});OpenLayers.Tween=OpenLayers.Class({INTERVAL:10,easing:null,begin:null,finish:null,duration:null,callbacks:null,time:null,interval:null,playing:false,initialize:function(a){this.easing=(a)?a:OpenLayers.Easing.Expo.easeOut},start:function(c,b,d,a){this.playing=true;this.begin=c;this.finish=b;this.duration=d;this.callbacks=a.callbacks;this.time=0;if(this.interval){window.clearInterval(this.interval);this.interval=null}if(this.callbacks&&this.callbacks.start){this.callbacks.start.call(this,this.begin)}this.interval=window.setInterval(OpenLayers.Function.bind(this.play,this),this.INTERVAL)},stop:function(){if(!this.playing){return}if(this.callbacks&&this.callbacks.done){this.callbacks.done.call(this,this.finish)}window.clearInterval(this.interval);this.interval=null;this.playing=false},play:function(){var h={};for(var d in this.begin){var a=this.begin[d];var g=this.finish[d];if(a==null||g==null||isNaN(a)||isNaN(g)){OpenLayers.Console.error("invalid value for Tween")}var j=g-a;h[d]=this.easing.apply(this,[this.time,a,j,this.duration])}this.time++;if(this.callbacks&&this.callbacks.eachStep){this.callbacks.eachStep.call(this,h)}if(this.time>this.duration){if(this.callbacks&&this.callbacks.done){this.callbacks.done.call(this,this.finish);this.playing=false}window.clearInterval(this.interval);this.interval=null}},CLASS_NAME:"OpenLayers.Tween"});OpenLayers.Easing={CLASS_NAME:"OpenLayers.Easing"};OpenLayers.Easing.Linear={easeIn:function(f,a,h,g){return h*f/g+a},easeOut:function(f,a,h,g){return h*f/g+a},easeInOut:function(f,a,h,g){return h*f/g+a},CLASS_NAME:"OpenLayers.Easing.Linear"};OpenLayers.Easing.Expo={easeIn:function(f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOut:function(f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOut:function(f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},CLASS_NAME:"OpenLayers.Easing.Expo"};OpenLayers.Easing.Quad={easeIn:function(f,a,h,g){return h*(f/=g)*f+a},easeOut:function(f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOut:function(f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},CLASS_NAME:"OpenLayers.Easing.Quad"};OpenLayers.Control.ArgParser=OpenLayers.Class(OpenLayers.Control,{center:null,zoom:null,layers:null,displayProjection:null,initialize:function(a){OpenLayers.Control.prototype.initialize.apply(this,arguments)},setMap:function(f){OpenLayers.Control.prototype.setMap.apply(this,arguments);for(var c=0,a=this.map.controls.length;c<a;c++){var d=this.map.controls[c];if((d!=this)&&(d.CLASS_NAME=="OpenLayers.Control.ArgParser")){if(d.displayProjection!=this.displayProjection){this.displayProjection=d.displayProjection}break}}if(c==this.map.controls.length){var b=OpenLayers.Util.getParameters();if(b.layers){this.layers=b.layers;this.map.events.register("addlayer",this,this.configureLayers);this.configureLayers()}if(b.lat&&b.lon){this.center=new OpenLayers.LonLat(parseFloat(b.lon),parseFloat(b.lat));if(b.zoom){this.zoom=parseInt(b.zoom)}this.map.events.register("changebaselayer",this,this.setCenter);this.setCenter()}}},setCenter:function(){if(this.map.baseLayer){this.map.events.unregister("changebaselayer",this,this.setCenter);if(this.displayProjection){this.center.transform(this.displayProjection,this.map.getProjectionObject())}this.map.setCenter(this.center,this.zoom)}},configureLayers:function(){if(this.layers.length==this.map.layers.length){this.map.events.unregister("addlayer",this,this.configureLayers);for(var d=0,a=this.layers.length;d<a;d++){var b=this.map.layers[d];var f=this.layers.charAt(d);if(f=="B"){this.map.setBaseLayer(b)}else{if((f=="T")||(f=="F")){b.setVisibility(f=="T")}}}}},CLASS_NAME:"OpenLayers.Control.ArgParser"});OpenLayers.Control.Attribution=OpenLayers.Class(OpenLayers.Control,{separator:", ",initialize:function(a){OpenLayers.Control.prototype.initialize.apply(this,arguments)},destroy:function(){this.map.events.un({removelayer:this.updateAttribution,addlayer:this.updateAttribution,changelayer:this.updateAttribution,changebaselayer:this.updateAttribution,scope:this});OpenLayers.Control.prototype.destroy.apply(this,arguments)},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);this.map.events.on({changebaselayer:this.updateAttribution,changelayer:this.updateAttribution,addlayer:this.updateAttribution,removelayer:this.updateAttribution,scope:this});this.updateAttribution();return this.div},updateAttribution:function(){var d=[];if(this.map&&this.map.layers){for(var c=0,a=this.map.layers.length;c<a;c++){var b=this.map.layers[c];if(b.attribution&&b.getVisibility()){d.push(b.attribution)}}this.div.innerHTML=d.join(this.separator)}},CLASS_NAME:"OpenLayers.Control.Attribution"});OpenLayers.Control.Button=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){},CLASS_NAME:"OpenLayers.Control.Button"});OpenLayers.Control.LayerSwitcher=OpenLayers.Class(OpenLayers.Control,{activeColor:"darkblue",layerStates:null,layersDiv:null,baseLayersDiv:null,baseLayers:null,dataLbl:null,dataLayersDiv:null,dataLayers:null,minimizeDiv:null,maximizeDiv:null,ascending:true,initialize:function(a){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.layerStates=[]},destroy:function(){OpenLayers.Event.stopObservingElement(this.div);OpenLayers.Event.stopObservingElement(this.minimizeDiv);OpenLayers.Event.stopObservingElement(this.maximizeDiv);this.clearLayersArray("base");this.clearLayersArray("data");this.map.events.un({addlayer:this.redraw,changelayer:this.redraw,removelayer:this.redraw,changebaselayer:this.redraw,scope:this});OpenLayers.Control.prototype.destroy.apply(this,arguments)},setMap:function(a){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.on({addlayer:this.redraw,changelayer:this.redraw,removelayer:this.redraw,changebaselayer:this.redraw,scope:this})},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();if(!this.outsideViewport){this.minimizeControl()}this.redraw();return this.div},clearLayersArray:function(d){var f=this[d+"Layers"];if(f){for(var c=0,a=f.length;c<a;c++){var b=f[c];OpenLayers.Event.stopObservingElement(b.inputElem);OpenLayers.Event.stopObservingElement(b.labelSpan)}}this[d+"LayersDiv"].innerHTML="";this[d+"Layers"]=[]},checkRedraw:function(){var f=false;if(!this.layerStates.length||(this.map.layers.length!=this.layerStates.length)){f=true}else{for(var c=0,a=this.layerStates.length;c<a;c++){var d=this.layerStates[c];var b=this.map.layers[c];if((d.name!=b.name)||(d.inRange!=b.inRange)||(d.id!=b.id)||(d.visibility!=b.visibility)){f=true;break}}}return f},redraw:function(){if(!this.checkRedraw()){return this.div}this.clearLayersArray("base");this.clearLayersArray("data");var d=false;var o=false;var j=this.map.layers.length;this.layerStates=new Array(j);for(var g=0;g<j;g++){var h=this.map.layers[g];this.layerStates[g]={name:h.name,visibility:h.visibility,inRange:h.inRange,id:h.id}}var f=this.map.layers.slice();if(!this.ascending){f.reverse()}for(var g=0,j=f.length;g<j;g++){var h=f[g];var k=h.isBaseLayer;if(h.displayInLayerSwitcher){if(k){o=true}else{d=true}var m=(k)?(h==this.map.baseLayer):h.getVisibility();var l=document.createElement("input");l.id=this.id+"_input_"+h.name;l.name=(k)?"baseLayers":h.name;l.type=(k)?"radio":"checkbox";l.value=h.name;l.checked=m;l.defaultChecked=m;if(!k&&!h.inRange){l.disabled=true}var a={inputElem:l,layer:h,layerSwitcher:this};OpenLayers.Event.observe(l,"mouseup",OpenLayers.Function.bindAsEventListener(this.onInputClick,a));var b=document.createElement("span");if(!k&&!h.inRange){b.style.color="gray"}b.innerHTML=h.name;b.style.verticalAlign=(k)?"bottom":"baseline";OpenLayers.Event.observe(b,"click",OpenLayers.Function.bindAsEventListener(this.onInputClick,a));var r=document.createElement("br");var q=(k)?this.baseLayers:this.dataLayers;q.push({layer:h,inputElem:l,labelSpan:b});var c=(k)?this.baseLayersDiv:this.dataLayersDiv;c.appendChild(l);c.appendChild(b);c.appendChild(r)}}this.dataLbl.style.display=(d)?"":"none";this.baseLbl.style.display=(o)?"":"none";return this.div},onInputClick:function(a){if(!this.inputElem.disabled){if(this.inputElem.type=="radio"){this.inputElem.checked=true;this.layer.map.setBaseLayer(this.layer)}else{this.inputElem.checked=!this.inputElem.checked;this.layerSwitcher.updateMap()}}OpenLayers.Event.stop(a)},onLayerClick:function(a){this.updateMap()},updateMap:function(){for(var b=0,a=this.baseLayers.length;b<a;b++){var c=this.baseLayers[b];if(c.inputElem.checked){this.map.setBaseLayer(c.layer,false)}}for(var b=0,a=this.dataLayers.length;b<a;b++){var c=this.dataLayers[b];c.layer.setVisibility(c.inputElem.checked)}},maximizeControl:function(a){this.div.style.width="20em";this.div.style.height="";this.showControls(false);if(a!=null){OpenLayers.Event.stop(a)}},minimizeControl:function(a){this.div.style.width="0px";this.div.style.height="0px";this.showControls(true);if(a!=null){OpenLayers.Event.stop(a)}},showControls:function(a){this.maximizeDiv.style.display=a?"":"none";this.minimizeDiv.style.display=a?"none":"";this.layersDiv.style.display=a?"none":""},loadContents:function(){this.div.style.position="absolute";this.div.style.top="25px";this.div.style.right="0px";this.div.style.left="";this.div.style.fontFamily="sans-serif";this.div.style.fontWeight="bold";this.div.style.marginTop="3px";this.div.style.marginLeft="3px";this.div.style.marginBottom="3px";this.div.style.fontSize="smaller";this.div.style.color="white";this.div.style.backgroundColor="transparent";OpenLayers.Event.observe(this.div,"mouseup",OpenLayers.Function.bindAsEventListener(this.mouseUp,this));OpenLayers.Event.observe(this.div,"click",this.ignoreEvent);OpenLayers.Event.observe(this.div,"mousedown",OpenLayers.Function.bindAsEventListener(this.mouseDown,this));OpenLayers.Event.observe(this.div,"dblclick",this.ignoreEvent);this.layersDiv=document.createElement("div");this.layersDiv.id=this.id+"_layersDiv";this.layersDiv.style.paddingTop="5px";this.layersDiv.style.paddingLeft="10px";this.layersDiv.style.paddingBottom="5px";this.layersDiv.style.paddingRight="75px";this.layersDiv.style.backgroundColor=this.activeColor;this.layersDiv.style.width="100%";this.layersDiv.style.height="100%";this.baseLbl=document.createElement("div");this.baseLbl.innerHTML=OpenLayers.i18n("baseLayer");this.baseLbl.style.marginTop="3px";this.baseLbl.style.marginLeft="3px";this.baseLbl.style.marginBottom="3px";this.baseLayersDiv=document.createElement("div");this.baseLayersDiv.style.paddingLeft="10px";this.dataLbl=document.createElement("div");this.dataLbl.innerHTML=OpenLayers.i18n("overlays");this.dataLbl.style.marginTop="3px";this.dataLbl.style.marginLeft="3px";this.dataLbl.style.marginBottom="3px";this.dataLayersDiv=document.createElement("div");this.dataLayersDiv.style.paddingLeft="10px";if(this.ascending){this.layersDiv.appendChild(this.baseLbl);this.layersDiv.appendChild(this.baseLayersDiv);this.layersDiv.appendChild(this.dataLbl);this.layersDiv.appendChild(this.dataLayersDiv)}else{this.layersDiv.appendChild(this.dataLbl);this.layersDiv.appendChild(this.dataLayersDiv);this.layersDiv.appendChild(this.baseLbl);this.layersDiv.appendChild(this.baseLayersDiv)}this.div.appendChild(this.layersDiv);OpenLayers.Rico.Corner.round(this.div,{corners:"tl bl",bgColor:"transparent",color:this.activeColor,blend:false});OpenLayers.Rico.Corner.changeOpacity(this.layersDiv,0.75);var c=OpenLayers.Util.getImagesLocation();var b=new OpenLayers.Size(18,18);var a=c+"layer-switcher-maximize.png";this.maximizeDiv=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_MaximizeDiv",null,b,a,"absolute");this.maximizeDiv.style.top="5px";this.maximizeDiv.style.right="0px";this.maximizeDiv.style.left="";this.maximizeDiv.style.display="none";OpenLayers.Event.observe(this.maximizeDiv,"click",OpenLayers.Function.bindAsEventListener(this.maximizeControl,this));this.div.appendChild(this.maximizeDiv);var a=c+"layer-switcher-minimize.png";var b=new OpenLayers.Size(18,18);this.minimizeDiv=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_MinimizeDiv",null,b,a,"absolute");this.minimizeDiv.style.top="5px";this.minimizeDiv.style.right="0px";this.minimizeDiv.style.left="";this.minimizeDiv.style.display="none";OpenLayers.Event.observe(this.minimizeDiv,"click",OpenLayers.Function.bindAsEventListener(this.minimizeControl,this));this.div.appendChild(this.minimizeDiv)},ignoreEvent:function(a){OpenLayers.Event.stop(a)},mouseDown:function(a){this.isMouseDown=true;this.ignoreEvent(a)},mouseUp:function(a){if(this.isMouseDown){this.isMouseDown=false;this.ignoreEvent(a)}},CLASS_NAME:"OpenLayers.Control.LayerSwitcher"});OpenLayers.Control.MouseDefaults=OpenLayers.Class(OpenLayers.Control,{performedDrag:false,wheelObserver:null,initialize:function(){OpenLayers.Control.prototype.initialize.apply(this,arguments)},destroy:function(){if(this.handler){this.handler.destroy()}this.handler=null;this.map.events.un({click:this.defaultClick,dblclick:this.defaultDblClick,mousedown:this.defaultMouseDown,mouseup:this.defaultMouseUp,mousemove:this.defaultMouseMove,mouseout:this.defaultMouseOut,scope:this});OpenLayers.Event.stopObserving(window,"DOMMouseScroll",this.wheelObserver);OpenLayers.Event.stopObserving(window,"mousewheel",this.wheelObserver);OpenLayers.Event.stopObserving(document,"mousewheel",this.wheelObserver);this.wheelObserver=null;OpenLayers.Control.prototype.destroy.apply(this,arguments)},draw:function(){this.map.events.on({click:this.defaultClick,dblclick:this.defaultDblClick,mousedown:this.defaultMouseDown,mouseup:this.defaultMouseUp,mousemove:this.defaultMouseMove,mouseout:this.defaultMouseOut,scope:this});this.registerWheelEvents()},registerWheelEvents:function(){this.wheelObserver=OpenLayers.Function.bindAsEventListener(this.onWheelEvent,this);OpenLayers.Event.observe(window,"DOMMouseScroll",this.wheelObserver);OpenLayers.Event.observe(window,"mousewheel",this.wheelObserver);OpenLayers.Event.observe(document,"mousewheel",this.wheelObserver)},defaultClick:function(b){if(!OpenLayers.Event.isLeftClick(b)){return}var a=!this.performedDrag;this.performedDrag=false;return a},defaultDblClick:function(b){var a=this.map.getLonLatFromViewPortPx(b.xy);this.map.setCenter(a,this.map.zoom+1);OpenLayers.Event.stop(b);return false},defaultMouseDown:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}this.mouseDragStart=a.xy.clone();this.performedDrag=false;if(a.shiftKey){this.map.div.style.cursor="crosshair";this.zoomBox=OpenLayers.Util.createDiv("zoomBox",this.mouseDragStart,null,null,"absolute","2px solid red");this.zoomBox.style.backgroundColor="white";this.zoomBox.style.filter="alpha(opacity=50)";this.zoomBox.style.opacity="0.50";this.zoomBox.style.fontSize="1px";this.zoomBox.style.zIndex=this.map.Z_INDEX_BASE.Popup-1;this.map.viewPortDiv.appendChild(this.zoomBox)}document.onselectstart=function(){return false};OpenLayers.Event.stop(a)},defaultMouseMove:function(f){this.mousePosition=f.xy.clone();if(this.mouseDragStart!=null){if(this.zoomBox){var d=Math.abs(this.mouseDragStart.x-f.xy.x);var b=Math.abs(this.mouseDragStart.y-f.xy.y);this.zoomBox.style.width=Math.max(1,d)+"px";this.zoomBox.style.height=Math.max(1,b)+"px";if(f.xy.x<this.mouseDragStart.x){this.zoomBox.style.left=f.xy.x+"px"}if(f.xy.y<this.mouseDragStart.y){this.zoomBox.style.top=f.xy.y+"px"}}else{var d=this.mouseDragStart.x-f.xy.x;var b=this.mouseDragStart.y-f.xy.y;var g=this.map.getSize();var a=new OpenLayers.Pixel(g.w/2+d,g.h/2+b);var c=this.map.getLonLatFromViewPortPx(a);this.map.setCenter(c,null,true);this.mouseDragStart=f.xy.clone();this.map.div.style.cursor="move"}this.performedDrag=true}},defaultMouseUp:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}if(this.zoomBox){this.zoomBoxEnd(a)}else{if(this.performedDrag){this.map.setCenter(this.map.center)}}document.onselectstart=null;this.mouseDragStart=null;this.map.div.style.cursor=""},defaultMouseOut:function(a){if(this.mouseDragStart!=null&&OpenLayers.Util.mouseLeft(a,this.map.div)){if(this.zoomBox){this.removeZoomBox()}this.mouseDragStart=null}},defaultWheelUp:function(a){if(this.map.getZoom()<=this.map.getNumZoomLevels()){this.map.setCenter(this.map.getLonLatFromPixel(a.xy),this.map.getZoom()+1)}},defaultWheelDown:function(a){if(this.map.getZoom()>0){this.map.setCenter(this.map.getLonLatFromPixel(a.xy),this.map.getZoom()-1)}},zoomBoxEnd:function(b){if(this.mouseDragStart!=null){if(Math.abs(this.mouseDragStart.x-b.xy.x)>5||Math.abs(this.mouseDragStart.y-b.xy.y)>5){var j=this.map.getLonLatFromViewPortPx(this.mouseDragStart);var a=this.map.getLonLatFromViewPortPx(b.xy);var h=Math.max(j.lat,a.lat);var c=Math.min(j.lat,a.lat);var g=Math.min(j.lon,a.lon);var d=Math.max(j.lon,a.lon);var f=new OpenLayers.Bounds(g,c,d,h);this.map.zoomToExtent(f)}else{var a=this.map.getLonLatFromViewPortPx(b.xy);this.map.setCenter(new OpenLayers.LonLat((a.lon),(a.lat)),this.map.getZoom()+1)}this.removeZoomBox()}},removeZoomBox:function(){this.map.viewPortDiv.removeChild(this.zoomBox);this.zoomBox=null},onWheelEvent:function(c){var b=false;var a=OpenLayers.Event.element(c);while(a!=null){if(this.map&&a==this.map.div){b=true;break}a=a.parentNode}if(b){var d=0;if(!c){c=window.event}if(c.wheelDelta){d=c.wheelDelta/120;if(window.opera&&window.opera.version()<9.2){d=-d}}else{if(c.detail){d=-c.detail/3}}if(d){c.xy=this.mousePosition;if(d<0){this.defaultWheelDown(c)}else{this.defaultWheelUp(c)}}OpenLayers.Event.stop(c)}},CLASS_NAME:"OpenLayers.Control.MouseDefaults"});OpenLayers.Control.MousePosition=OpenLayers.Class(OpenLayers.Control,{element:null,prefix:"",separator:", ",suffix:"",numDigits:5,granularity:10,lastXy:null,displayProjection:null,initialize:function(a){OpenLayers.Control.prototype.initialize.apply(this,arguments)},destroy:function(){if(this.map){this.map.events.unregister("mousemove",this,this.redraw)}OpenLayers.Control.prototype.destroy.apply(this,arguments)},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!this.element){this.div.left="";this.div.top="";this.element=this.div}this.redraw();return this.div},redraw:function(a){var c;if(a==null){c=new OpenLayers.LonLat(0,0)}else{if(this.lastXy==null||Math.abs(a.xy.x-this.lastXy.x)>this.granularity||Math.abs(a.xy.y-this.lastXy.y)>this.granularity){this.lastXy=a.xy;return}c=this.map.getLonLatFromPixel(a.xy);if(!c){return}if(this.displayProjection){c.transform(this.map.getProjectionObject(),this.displayProjection)}this.lastXy=a.xy}var b=this.formatOutput(c);if(b!=this.element.innerHTML){this.element.innerHTML=b}},formatOutput:function(b){var c=parseInt(this.numDigits);var a=this.prefix+b.lon.toFixed(c)+this.separator+b.lat.toFixed(c)+this.suffix;return a},setMap:function(){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("mousemove",this,this.redraw)},CLASS_NAME:"OpenLayers.Control.MousePosition"});OpenLayers.Control.Pan=OpenLayers.Class(OpenLayers.Control,{slideFactor:50,direction:null,type:OpenLayers.Control.TYPE_BUTTON,initialize:function(b,a){this.direction=b;this.CLASS_NAME+=this.direction;OpenLayers.Control.prototype.initialize.apply(this,[a])},trigger:function(){switch(this.direction){case OpenLayers.Control.Pan.NORTH:this.map.pan(0,-this.slideFactor);break;case OpenLayers.Control.Pan.SOUTH:this.map.pan(0,this.slideFactor);break;case OpenLayers.Control.Pan.WEST:this.map.pan(-this.slideFactor,0);break;case OpenLayers.Control.Pan.EAST:this.map.pan(this.slideFactor,0);break}},CLASS_NAME:"OpenLayers.Control.Pan"});OpenLayers.Control.Pan.NORTH="North";OpenLayers.Control.Pan.SOUTH="South";OpenLayers.Control.Pan.EAST="East";OpenLayers.Control.Pan.WEST="West";OpenLayers.Control.PanZoom=OpenLayers.Class(OpenLayers.Control,{slideFactor:50,slideRatio:null,buttons:null,position:null,initialize:function(a){this.position=new OpenLayers.Pixel(OpenLayers.Control.PanZoom.X,OpenLayers.Control.PanZoom.Y);OpenLayers.Control.prototype.initialize.apply(this,arguments)},destroy:function(){OpenLayers.Control.prototype.destroy.apply(this,arguments);this.removeButtons();this.buttons=null;this.position=null},draw:function(b){OpenLayers.Control.prototype.draw.apply(this,arguments);b=this.position;this.buttons=[];var c=new OpenLayers.Size(18,18);var a=new OpenLayers.Pixel(b.x+c.w/2,b.y);this._addButton("panup","north-mini.png",a,c);b.y=a.y+c.h;this._addButton("panleft","west-mini.png",b,c);this._addButton("panright","east-mini.png",b.add(c.w,0),c);this._addButton("pandown","south-mini.png",a.add(0,c.h*2),c);this._addButton("zoomin","zoom-plus-mini.png",a.add(0,c.h*3+5),c);this._addButton("zoomworld","zoom-world-mini.png",a.add(0,c.h*4+5),c);this._addButton("zoomout","zoom-minus-mini.png",a.add(0,c.h*5+5),c);return this.div},_addButton:function(a,d,k,h){var g=OpenLayers.Util.getImagesLocation()+d;var b=OpenLayers.Util.createAlphaImageDiv(this.id+"_"+a,k,h,g,"absolute");this.div.appendChild(b);OpenLayers.Event.observe(b,"mousedown",OpenLayers.Function.bindAsEventListener(this.buttonDown,b));OpenLayers.Event.observe(b,"dblclick",OpenLayers.Function.bindAsEventListener(this.doubleClick,b));OpenLayers.Event.observe(b,"click",OpenLayers.Function.bindAsEventListener(this.doubleClick,b));b.action=a;b.map=this.map;if(!this.slideRatio){var c=this.slideFactor;var f=function(){return c}}else{var j=this.slideRatio;var f=function(l){return this.map.getSize()[l]*j}}b.getSlideFactor=f;this.buttons.push(b);return b},_removeButton:function(a){OpenLayers.Event.stopObservingElement(a);a.map=null;this.div.removeChild(a);OpenLayers.Util.removeItem(this.buttons,a)},removeButtons:function(){for(var a=this.buttons.length-1;a>=0;--a){this._removeButton(this.buttons[a])}},doubleClick:function(a){OpenLayers.Event.stop(a);return false},buttonDown:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}switch(this.action){case"panup":this.map.pan(0,-this.getSlideFactor("h"));break;case"pandown":this.map.pan(0,this.getSlideFactor("h"));break;case"panleft":this.map.pan(-this.getSlideFactor("w"),0);break;case"panright":this.map.pan(this.getSlideFactor("w"),0);break;case"zoomin":this.map.zoomIn();break;case"zoomout":this.map.zoomOut();break;case"zoomworld":this.map.zoomToMaxExtent();break}OpenLayers.Event.stop(a)},CLASS_NAME:"OpenLayers.Control.PanZoom"});OpenLayers.Control.PanZoom.X=4;OpenLayers.Control.PanZoom.Y=4;OpenLayers.Control.Panel=OpenLayers.Class(OpenLayers.Control,{controls:null,defaultControl:null,initialize:function(a){OpenLayers.Control.prototype.initialize.apply(this,[a]);this.controls=[]},destroy:function(){OpenLayers.Control.prototype.destroy.apply(this,arguments);for(var a=this.controls.length-1;a>=0;a--){if(this.controls[a].events){this.controls[a].events.un({activate:this.redraw,deactivate:this.redraw,scope:this})}OpenLayers.Event.stopObservingElement(this.controls[a].panel_div);this.controls[a].panel_div=null}},activate:function(){if(OpenLayers.Control.prototype.activate.apply(this,arguments)){for(var b=0,a=this.controls.length;b<a;b++){if(this.controls[b]==this.defaultControl){this.controls[b].activate()}}this.redraw();return true}else{return false}},deactivate:function(){if(OpenLayers.Control.prototype.deactivate.apply(this,arguments)){for(var b=0,a=this.controls.length;b<a;b++){this.controls[b].deactivate()}return true}else{return false}},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);for(var b=0,a=this.controls.length;b<a;b++){this.map.addControl(this.controls[b]);this.controls[b].deactivate();this.controls[b].events.on({activate:this.redraw,deactivate:this.redraw,scope:this})}this.activate();return this.div},redraw:function(){this.div.innerHTML="";if(this.active){for(var c=0,a=this.controls.length;c<a;c++){var b=this.controls[c].panel_div;if(this.controls[c].active){b.className=this.controls[c].displayClass+"ItemActive"}else{b.className=this.controls[c].displayClass+"ItemInactive"}this.div.appendChild(b)}}},activateControl:function(c){if(!this.active){return false}if(c.type==OpenLayers.Control.TYPE_BUTTON){c.trigger();this.redraw();return}if(c.type==OpenLayers.Control.TYPE_TOGGLE){if(c.active){c.deactivate()}else{c.activate()}this.redraw();return}for(var b=0,a=this.controls.length;b<a;b++){if(this.controls[b]!=c){if(this.controls[b].type!=OpenLayers.Control.TYPE_TOGGLE){this.controls[b].deactivate()}}}c.activate()},addControls:function(b){if(!(b instanceof Array)){b=[b]}this.controls=this.controls.concat(b);for(var d=0,a=b.length;d<a;d++){var c=document.createElement("div");var f=document.createTextNode(" ");b[d].panel_div=c;if(b[d].title!=""){b[d].panel_div.title=b[d].title}OpenLayers.Event.observe(b[d].panel_div,"click",OpenLayers.Function.bind(this.onClick,this,b[d]));OpenLayers.Event.observe(b[d].panel_div,"mousedown",OpenLayers.Function.bindAsEventListener(OpenLayers.Event.stop))}if(this.map){for(var d=0,a=b.length;d<a;d++){this.map.addControl(b[d]);b[d].deactivate();b[d].events.on({activate:this.redraw,deactivate:this.redraw,scope:this})}this.redraw()}},onClick:function(b,a){OpenLayers.Event.stop(a?a:window.event);this.activateControl(b)},getControlsBy:function(c,a){var d=(typeof a.test=="function");var b=OpenLayers.Array.filter(this.controls,function(f){return f[c]==a||(d&&a.test(f[c]))});return b},getControlsByName:function(a){return this.getControlsBy("name",a)},getControlsByClass:function(a){return this.getControlsBy("CLASS_NAME",a)},CLASS_NAME:"OpenLayers.Control.Panel"});OpenLayers.Control.Scale=OpenLayers.Class(OpenLayers.Control,{element:null,initialize:function(b,a){OpenLayers.Control.prototype.initialize.apply(this,[a]);this.element=OpenLayers.Util.getElement(b)},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!this.element){this.element=document.createElement("div");this.div.appendChild(this.element)}this.map.events.register("moveend",this,this.updateScale);this.updateScale();return this.div},updateScale:function(){var a=this.map.getScale();if(!a){return}if(a>=9500&&a<=950000){a=Math.round(a/1000)+"K"}else{if(a>=950000){a=Math.round(a/1000000)+"M"}else{a=Math.round(a)}}this.element.innerHTML=OpenLayers.i18n("scale",{scaleDenom:a})},CLASS_NAME:"OpenLayers.Control.Scale"});OpenLayers.Control.ScaleLine=OpenLayers.Class(OpenLayers.Control,{maxWidth:100,topOutUnits:"km",topInUnits:"m",bottomOutUnits:"mi",bottomInUnits:"ft",eTop:null,eBottom:null,initialize:function(a){OpenLayers.Control.prototype.initialize.apply(this,[a])},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!this.eTop){this.div.style.display="block";this.div.style.position="absolute";this.eTop=document.createElement("div");this.eTop.className=this.displayClass+"Top";var a=this.topInUnits.length;this.div.appendChild(this.eTop);if((this.topOutUnits=="")||(this.topInUnits=="")){this.eTop.style.visibility="hidden"}else{this.eTop.style.visibility="visible"}this.eBottom=document.createElement("div");this.eBottom.className=this.displayClass+"Bottom";this.div.appendChild(this.eBottom);if((this.bottomOutUnits=="")||(this.bottomInUnits=="")){this.eBottom.style.visibility="hidden"}else{this.eBottom.style.visibility="visible"}}this.map.events.register("moveend",this,this.update);this.update();return this.div},getBarLen:function(b){var d=parseInt(Math.log(b)/Math.log(10));var a=Math.pow(10,d);var c=parseInt(b/a);var f;if(c>5){f=5}else{if(c>2){f=2}else{f=1}}return f*a},update:function(){var j=this.map.getResolution();if(!j){return}var o=this.map.getUnits();var c=OpenLayers.INCHES_PER_UNIT;var k=this.maxWidth*j*c[o];var a;var d;if(k>100000){a=this.topOutUnits;d=this.bottomOutUnits}else{a=this.topInUnits;d=this.bottomInUnits}var g=k/c[a];var l=k/c[d];var h=this.getBarLen(g);var f=this.getBarLen(l);g=h/c[o]*c[a];l=f/c[o]*c[d];var b=g/j;var m=l/j;if(this.eBottom.style.visibility=="visible"){this.eBottom.style.width=Math.round(m)+"px";this.eBottom.innerHTML=f+" "+d}if(this.eTop.style.visibility=="visible"){this.eTop.style.width=Math.round(b)+"px";this.eTop.innerHTML=h+" "+a}},CLASS_NAME:"OpenLayers.Control.ScaleLine"});OpenLayers.Control.ZoomIn=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){this.map.zoomIn()},CLASS_NAME:"OpenLayers.Control.ZoomIn"});OpenLayers.Control.ZoomOut=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){this.map.zoomOut()},CLASS_NAME:"OpenLayers.Control.ZoomOut"});OpenLayers.Control.ZoomToMaxExtent=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){if(this.map){this.map.zoomToMaxExtent()}},CLASS_NAME:"OpenLayers.Control.ZoomToMaxExtent"});OpenLayers.Event={observers:false,KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,element:function(a){return a.target||a.srcElement},isLeftClick:function(a){return(((a.which)&&(a.which==1))||((a.button)&&(a.button==1)))},isRightClick:function(a){return(((a.which)&&(a.which==3))||((a.button)&&(a.button==2)))},stop:function(b,a){if(!a){if(b.preventDefault){b.preventDefault()}else{b.returnValue=false}}if(b.stopPropagation){b.stopPropagation()}else{b.cancelBubble=true}},findElement:function(c,b){var a=OpenLayers.Event.element(c);while(a.parentNode&&(!a.tagName||(a.tagName.toUpperCase()!=b.toUpperCase()))){a=a.parentNode}return a},observe:function(b,d,c,a){var f=OpenLayers.Util.getElement(b);a=a||false;if(d=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||f.attachEvent)){d="keydown"}if(!this.observers){this.observers={}}if(!f._eventCacheID){var g="eventCacheID_";if(f.id){g=f.id+"_"+g}f._eventCacheID=OpenLayers.Util.createUniqueID(g)}var h=f._eventCacheID;if(!this.observers[h]){this.observers[h]=[]}this.observers[h].push({element:f,name:d,observer:c,useCapture:a});if(f.addEventListener){f.addEventListener(d,c,a)}else{if(f.attachEvent){f.attachEvent("on"+d,c)}}},stopObservingElement:function(a){var b=OpenLayers.Util.getElement(a);var c=b._eventCacheID;this._removeElementObservers(OpenLayers.Event.observers[c])},_removeElementObservers:function(f){if(f){for(var b=f.length-1;b>=0;b--){var c=f[b];var a=new Array(c.element,c.name,c.observer,c.useCapture);var d=OpenLayers.Event.stopObserving.apply(this,a)}}},stopObserving:function(j,a,h,b){b=b||false;var g=OpenLayers.Util.getElement(j);var d=g._eventCacheID;if(a=="keypress"){if(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||g.detachEvent){a="keydown"}}var l=false;var c=OpenLayers.Event.observers[d];if(c){var f=0;while(!l&&f<c.length){var k=c[f];if((k.name==a)&&(k.observer==h)&&(k.useCapture==b)){c.splice(f,1);if(c.length==0){delete OpenLayers.Event.observers[d]}l=true;break}f++}}if(l){if(g.removeEventListener){g.removeEventListener(a,h,b)}else{if(g&&g.detachEvent){g.detachEvent("on"+a,h)}}}return l},unloadCache:function(){if(OpenLayers.Event&&OpenLayers.Event.observers){for(var a in OpenLayers.Event.observers){var b=OpenLayers.Event.observers[a];OpenLayers.Event._removeElementObservers.apply(this,[b])}OpenLayers.Event.observers=false}},CLASS_NAME:"OpenLayers.Event"};OpenLayers.Event.observe(window,"unload",OpenLayers.Event.unloadCache,false);if(window.Event){OpenLayers.Util.applyDefaults(window.Event,OpenLayers.Event)}else{var Event=OpenLayers.Event}OpenLayers.Events=OpenLayers.Class({BROWSER_EVENTS:["mouseover","mouseout","mousedown","mouseup","mousemove","click","dblclick","rightclick","dblrightclick","resize","focus","blur"],listeners:null,object:null,element:null,eventTypes:null,eventHandler:null,fallThrough:null,includeXY:false,clearMouseListener:null,initialize:function(c,f,h,g,b){OpenLayers.Util.extend(this,b);this.object=c;this.fallThrough=g;this.listeners={};this.eventHandler=OpenLayers.Function.bindAsEventListener(this.handleBrowserEvent,this);this.clearMouseListener=OpenLayers.Function.bind(this.clearMouseCache,this);this.eventTypes=[];if(h!=null){for(var d=0,a=h.length;d<a;d++){this.addEventType(h[d])}}if(f!=null){this.attachToElement(f)}},destroy:function(){if(this.element){OpenLayers.Event.stopObservingElement(this.element);if(this.element.hasScrollEvent){OpenLayers.Event.stopObserving(window,"scroll",this.clearMouseListener)}}this.element=null;this.listeners=null;this.object=null;this.eventTypes=null;this.fallThrough=null;this.eventHandler=null},addEventType:function(a){if(!this.listeners[a]){this.eventTypes.push(a);this.listeners[a]=[]}},attachToElement:function(d){if(this.element){OpenLayers.Event.stopObservingElement(this.element)}this.element=d;for(var c=0,a=this.BROWSER_EVENTS.length;c<a;c++){var b=this.BROWSER_EVENTS[c];this.addEventType(b);OpenLayers.Event.observe(d,b,this.eventHandler)}OpenLayers.Event.observe(d,"dragstart",OpenLayers.Event.stop)},on:function(a){for(var b in a){if(b!="scope"){this.register(b,a.scope,a[b])}}},register:function(b,d,c){if((c!=null)&&(OpenLayers.Util.indexOf(this.eventTypes,b)!=-1)){if(d==null){d=this.object}var a=this.listeners[b];a.push({obj:d,func:c})}},registerPriority:function(b,d,c){if(c!=null){if(d==null){d=this.object}var a=this.listeners[b];if(a!=null){a.unshift({obj:d,func:c})}}},un:function(a){for(var b in a){if(b!="scope"){this.unregister(b,a.scope,a[b])}}},unregister:function(d,g,f){if(g==null){g=this.object}var c=this.listeners[d];if(c!=null){for(var b=0,a=c.length;b<a;b++){if(c[b].obj==g&&c[b].func==f){c.splice(b,1);break}}}},remove:function(a){if(this.listeners[a]!=null){this.listeners[a]=[]}},triggerEvent:function(f,b){var d=this.listeners[f];if(!d||d.length==0){return}if(b==null){b={}}b.object=this.object;b.element=this.element;if(!b.type){b.type=f}var d=d.slice(),g;for(var c=0,a=d.length;c<a;c++){var h=d[c];g=h.func.apply(h.obj,[b]);if((g!=undefined)&&(g==false)){break}}if(!this.fallThrough){OpenLayers.Event.stop(b,true)}return g},handleBrowserEvent:function(a){if(this.includeXY){a.xy=this.getMousePosition(a)}this.triggerEvent(a.type,a)},clearMouseCache:function(){this.element.scrolls=null;this.element.lefttop=null;this.element.offsets=null},getMousePosition:function(a){if(!this.includeXY){this.clearMouseCache()}else{if(!this.element.hasScrollEvent){OpenLayers.Event.observe(window,"scroll",this.clearMouseListener);this.element.hasScrollEvent=true}}if(!this.element.scrolls){this.element.scrolls=[(document.documentElement.scrollLeft||document.body.scrollLeft),(document.documentElement.scrollTop||document.body.scrollTop)]}if(!this.element.lefttop){this.element.lefttop=[(document.documentElement.clientLeft||0),(document.documentElement.clientTop||0)]}if(!this.element.offsets){this.element.offsets=OpenLayers.Util.pagePosition(this.element);this.element.offsets[0]+=this.element.scrolls[0];this.element.offsets[1]+=this.element.scrolls[1]}return new OpenLayers.Pixel((a.clientX+this.element.scrolls[0])-this.element.offsets[0]-this.element.lefttop[0],(a.clientY+this.element.scrolls[1])-this.element.offsets[1]-this.element.lefttop[1])},CLASS_NAME:"OpenLayers.Events"});OpenLayers.Format=OpenLayers.Class({options:null,externalProjection:null,internalProjection:null,data:null,keepData:false,initialize:function(a){OpenLayers.Util.extend(this,a);this.options=a},destroy:function(){},read:function(a){OpenLayers.Console.userError(OpenLayers.i18n("readNotImplemented"))},write:function(a){OpenLayers.Console.userError(OpenLayers.i18n("writeNotImplemented"))},CLASS_NAME:"OpenLayers.Format"});OpenLayers.Lang.en={unhandledRequest:"Unhandled request return ${statusText}",permalink:"Permalink",overlays:"Overlays",baseLayer:"Base Layer",sameProjection:"The overview map only works when it is in the same projection as the main map",readNotImplemented:"Read not implemented.",writeNotImplemented:"Write not implemented.",noFID:"Can't update a feature for which there is no FID.",errorLoadingGML:"Error in loading GML file ${url}",browserNotSupported:"Your browser does not support vector rendering. Currently supported renderers are:\n${renderers}",componentShouldBe:"addFeatures : component should be an ${geomType}",getFeatureError:"getFeatureFromEvent called on layer with no renderer. This usually means you destroyed a layer, but not some handler which is associated with it.",minZoomLevelError:"The minZoomLevel property is only intended for use with the FixedZoomLevels-descendent layers. That this wfs layer checks for minZoomLevel is a relic of thepast. We cannot, however, remove it without possibly breaking OL based applications that may depend on it. Therefore we are deprecating it -- the minZoomLevel check below will be removed at 3.0. Please instead use min/max resolution setting as described here: http://trac.openlayers.org/wiki/SettingZoomLevels",commitSuccess:"WFS Transaction: SUCCESS ${response}",commitFailed:"WFS Transaction: FAILED ${response}",googleWarning:"The Google Layer was unable to load correctly.<br><br>To get rid of this message, select a new BaseLayer in the layer switcher in the upper-right corner.<br><br>Most likely, this is because the Google Maps library script was either not included, or does not contain the correct API key for your site.<br><br>Developers: For help getting this working correctly, <a href='http://trac.openlayers.org/wiki/Google' target='_blank'>click here</a>",getLayerWarning:"The ${layerType} Layer was unable to load correctly.<br><br>To get rid of this message, select a new BaseLayer in the layer switcher in the upper-right corner.<br><br>Most likely, this is because the ${layerLib} library script was not correctly included.<br><br>Developers: For help getting this working correctly, <a href='http://trac.openlayers.org/wiki/${layerLib}' target='_blank'>click here</a>",scale:"Scale = 1 : ${scaleDenom}",layerAlreadyAdded:"You tried to add the layer: ${layerName} to the map, but it has already been added",reprojectDeprecated:"You are using the 'reproject' option on the ${layerName} layer. This option is deprecated: its use was designed to support displaying data over commercial basemaps, but that functionality should now be achieved by using Spherical Mercator support. More information is available from http://trac.openlayers.org/wiki/SphericalMercator.",methodDeprecated:"This method has been deprecated and will be removed in 3.0. Please use ${newMethod} instead.",boundsAddError:"You must pass both x and y values to the add function.",lonlatAddError:"You must pass both lon and lat values to the add function.",pixelAddError:"You must pass both x and y values to the add function.",unsupportedGeometryType:"Unsupported geometry type: ${geomType}",pagePositionFailed:"OpenLayers.Util.pagePosition failed: element with id ${elemId} may be misplaced.",end:"",filterEvaluateNotImplemented:"evaluate is not implemented for this filter type."};OpenLayers.Popup.AnchoredBubble=OpenLayers.Class(OpenLayers.Popup.Anchored,{rounded:false,initialize:function(h,c,g,b,a,f,d){this.padding=new OpenLayers.Bounds(0,OpenLayers.Popup.AnchoredBubble.CORNER_SIZE,0,OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);OpenLayers.Popup.Anchored.prototype.initialize.apply(this,arguments)},draw:function(a){OpenLayers.Popup.Anchored.prototype.draw.apply(this,arguments);this.setContentHTML();this.setBackgroundColor();this.setOpacity();return this.div},updateRelativePosition:function(){this.setRicoCorners()},setSize:function(a){OpenLayers.Popup.Anchored.prototype.setSize.apply(this,arguments);this.setRicoCorners()},setBackgroundColor:function(a){if(a!=undefined){this.backgroundColor=a}if(this.div!=null){if(this.contentDiv!=null){this.div.style.background="transparent";OpenLayers.Rico.Corner.changeColor(this.groupDiv,this.backgroundColor)}}},setOpacity:function(a){OpenLayers.Popup.Anchored.prototype.setOpacity.call(this,a);if(this.div!=null){if(this.groupDiv!=null){OpenLayers.Rico.Corner.changeOpacity(this.groupDiv,this.opacity)}}},setBorder:function(a){this.border=0},setRicoCorners:function(){var a=this.getCornersToRound(this.relativePosition);var b={corners:a,color:this.backgroundColor,bgColor:"transparent",blend:false};if(!this.rounded){OpenLayers.Rico.Corner.round(this.div,b);this.rounded=true}else{OpenLayers.Rico.Corner.reRound(this.groupDiv,b);this.setBackgroundColor();this.setOpacity()}},getCornersToRound:function(){var a=["tl","tr","bl","br"];var b=OpenLayers.Bounds.oppositeQuadrant(this.relativePosition);OpenLayers.Util.removeItem(a,b);return a.join(" ")},CLASS_NAME:"OpenLayers.Popup.AnchoredBubble"});OpenLayers.Popup.AnchoredBubble.CORNER_SIZE=5;OpenLayers.Popup.Framed=OpenLayers.Class(OpenLayers.Popup.Anchored,{imageSrc:null,imageSize:null,isAlphaImage:false,positionBlocks:null,blocks:null,fixedRelativePosition:false,initialize:function(h,c,g,b,a,f,d){OpenLayers.Popup.Anchored.prototype.initialize.apply(this,arguments);if(this.fixedRelativePosition){this.updateRelativePosition();this.calculateRelativePosition=function(j){return this.relativePosition}}this.contentDiv.style.position="absolute";this.contentDiv.style.zIndex=1;if(f){this.closeDiv.style.zIndex=1}this.groupDiv.style.position="absolute";this.groupDiv.style.top="0px";this.groupDiv.style.left="0px";this.groupDiv.style.height="100%";this.groupDiv.style.width="100%"},destroy:function(){this.imageSrc=null;this.imageSize=null;this.isAlphaImage=null;this.fixedRelativePosition=false;this.positionBlocks=null;for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if(b.image){b.div.removeChild(b.image)}b.image=null;if(b.div){this.groupDiv.removeChild(b.div)}b.div=null}this.blocks=null;OpenLayers.Popup.Anchored.prototype.destroy.apply(this,arguments)},setBackgroundColor:function(a){},setBorder:function(){},setOpacity:function(a){},setSize:function(a){OpenLayers.Popup.Anchored.prototype.setSize.apply(this,arguments);this.updateBlocks()},updateRelativePosition:function(){this.padding=this.positionBlocks[this.relativePosition].padding;if(this.closeDiv){var a=this.getContentDivPadding();this.closeDiv.style.right=a.right+this.padding.right+"px";this.closeDiv.style.top=a.top+this.padding.top+"px"}this.updateBlocks()},calculateNewPx:function(a){var b=OpenLayers.Popup.Anchored.prototype.calculateNewPx.apply(this,arguments);b=b.offset(this.positionBlocks[this.relativePosition].offset);return b},createBlocks:function(){this.blocks=[];var g=null;for(var f in this.positionBlocks){g=f;break}var a=this.positionBlocks[g];for(var d=0;d<a.blocks.length;d++){var j={};this.blocks.push(j);var b=this.id+"_FrameDecorationDiv_"+d;j.div=OpenLayers.Util.createDiv(b,null,null,null,"absolute",null,"hidden",null);var c=this.id+"_FrameDecorationImg_"+d;var h=(this.isAlphaImage)?OpenLayers.Util.createAlphaImageDiv:OpenLayers.Util.createImage;j.image=h(c,null,this.imageSize,this.imageSrc,"absolute",null,null,null);j.div.appendChild(j.image);this.groupDiv.appendChild(j.div)}},updateBlocks:function(){if(!this.blocks){this.createBlocks()}if(this.size&&this.relativePosition){var k=this.positionBlocks[this.relativePosition];for(var g=0;g<k.blocks.length;g++){var c=k.blocks[g];var f=this.blocks[g];var d=c.anchor.left;var m=c.anchor.bottom;var a=c.anchor.right;var q=c.anchor.top;var o=(isNaN(c.size.w))?this.size.w-(a+d):c.size.w;var j=(isNaN(c.size.h))?this.size.h-(m+q):c.size.h;f.div.style.width=(o<0?0:o)+"px";f.div.style.height=(j<0?0:j)+"px";f.div.style.left=(d!=null)?d+"px":"";f.div.style.bottom=(m!=null)?m+"px":"";f.div.style.right=(a!=null)?a+"px":"";f.div.style.top=(q!=null)?q+"px":"";f.image.style.left=c.position.x+"px";f.image.style.top=c.position.y+"px"}this.contentDiv.style.left=this.padding.left+"px";this.contentDiv.style.top=this.padding.top+"px"}},CLASS_NAME:"OpenLayers.Popup.Framed"});OpenLayers.Projection=OpenLayers.Class({proj:null,projCode:null,initialize:function(b,a){OpenLayers.Util.extend(this,a);this.projCode=b;if(window.Proj4js){this.proj=new Proj4js.Proj(b)}},getCode:function(){return this.proj?this.proj.srsCode:this.projCode},getUnits:function(){return this.proj?this.proj.units:null},toString:function(){return this.getCode()},equals:function(a){if(a&&a.getCode){return this.getCode()==a.getCode()}else{return false}},destroy:function(){delete this.proj;delete this.projCode},CLASS_NAME:"OpenLayers.Projection"});OpenLayers.Projection.transforms={};OpenLayers.Projection.addTransform=function(c,b,a){if(!OpenLayers.Projection.transforms[c]){OpenLayers.Projection.transforms[c]={}}OpenLayers.Projection.transforms[c][b]=a};OpenLayers.Projection.transform=function(a,c,b){if(c.proj&&b.proj){a=Proj4js.transform(c.proj,b.proj,a)}else{if(c&&b&&OpenLayers.Projection.transforms[c.getCode()]&&OpenLayers.Projection.transforms[c.getCode()][b.getCode()]){OpenLayers.Projection.transforms[c.getCode()][b.getCode()](a)}}return a};OpenLayers.Protocol.WFS.v1=OpenLayers.Class(OpenLayers.Protocol,{version:null,srsName:"EPSG:4326",featureType:null,featureNS:null,geometryName:"the_geom",schema:null,featurePrefix:"feature",formatOptions:null,initialize:function(b){OpenLayers.Protocol.prototype.initialize.apply(this,[b]);if(!b.format){this.format=OpenLayers.Format.WFST(OpenLayers.Util.extend({version:this.version,featureType:this.featureType,featureNS:this.featureNS,featurePrefix:this.featurePrefix,geometryName:this.geometryName,srsName:this.srsName,schema:this.schema},this.formatOptions))}if(!this.featureNS){var a=this.format.readNode;this.format.readNode=function(c,d){if(!this.featureNS&&c.prefix==this.featurePrefix){this.featureNS=c.namespaceURI;this.setNamespace("feature",this.featureNS)}return a.apply(this,arguments)}}},destroy:function(){if(this.options&&!this.options.format){this.format.destroy()}this.format=null;OpenLayers.Protocol.prototype.destroy.apply(this)},createCallback:function(c,a,b){return OpenLayers.Function.bind(function(){c.apply(this,[a,b])},this)},read:function(b){b=OpenLayers.Util.extend({},b);OpenLayers.Util.applyDefaults(b,this.options||{});var a=new OpenLayers.Protocol.Response({requestType:"read"});var c=OpenLayers.Format.XML.prototype.write.apply(this.format,[this.format.writeNode("wfs:GetFeature",b)]);a.priv=OpenLayers.Request.POST({url:b.url,callback:this.createCallback(this.handleRead,a,b),params:b.params,headers:b.headers,data:c});return a},handleRead:function(a,b){if(b.callback){var c=a.priv;if(c.status>=200&&c.status<300){a.features=this.parseFeatures(c);a.code=OpenLayers.Protocol.Response.SUCCESS}else{a.code=OpenLayers.Protocol.Response.FAILURE}b.callback.call(b.scope,a)}},parseFeatures:function(a){var b=a.responseXML;if(!b||!b.documentElement){b=a.responseText}if(!b||b.length<=0){return null}return this.format.read(b)},commit:function(c,b){b=OpenLayers.Util.extend({},b);OpenLayers.Util.applyDefaults(b,this.options);var a=new OpenLayers.Protocol.Response({requestType:"commit",reqFeatures:c});a.priv=OpenLayers.Request.POST({url:b.url,data:this.format.write(c,b),callback:this.createCallback(this.handleCommit,a,b)});return a},handleCommit:function(a,b){if(b.callback){var c=a.priv;var d=c.responseXML;if(!d||!d.documentElement){d=c.responseText}var f=this.format.read(d)||{};a.insertIds=f.insertIds||[];a.code=(f.success)?OpenLayers.Protocol.Response.SUCCESS:OpenLayers.Protocol.Response.FAILURE;b.callback.call(b.scope,a)}},filterDelete:function(f,c){c=OpenLayers.Util.extend({},c);OpenLayers.Util.applyDefaults(c,this.options);var b=new OpenLayers.Protocol.Response({requestType:"commit"});var a=this.format.createElementNSPlus("wfs:Transaction",{attributes:{service:"WFS",version:this.version}});var d=this.format.createElementNSPlus("wfs:Delete",{attributes:{typeName:(c.featureNS?this.featurePrefix+":":"")+c.featureType}});if(c.featureNS){d.setAttribute("xmlns:"+this.featurePrefix,c.featureNS)}var h=this.format.writeNode("ogc:Filter",f);d.appendChild(h);a.appendChild(d);var g=OpenLayers.Format.XML.prototype.write.apply(this.format,[a]);return OpenLayers.Request.POST({url:this.url,callback:c.callback||function(){},data:g})},abort:function(a){if(a){a.priv.abort()}},CLASS_NAME:"OpenLayers.Protocol.WFS.v1"});OpenLayers.Renderer.SVG=OpenLayers.Class(OpenLayers.Renderer.Elements,{xmlns:"http://www.w3.org/2000/svg",xlinkns:"http://www.w3.org/1999/xlink",MAX_PIXEL:15000,translationParameters:null,symbolSize:{},isGecko:null,initialize:function(a){if(!this.supported()){return}OpenLayers.Renderer.Elements.prototype.initialize.apply(this,arguments);this.translationParameters={x:0,y:0};this.isGecko=(navigator.userAgent.toLowerCase().indexOf("gecko/")!=-1)},destroy:function(){OpenLayers.Renderer.Elements.prototype.destroy.apply(this,arguments)},supported:function(){var a="http://www.w3.org/TR/SVG11/feature#";return(document.implementation&&(document.implementation.hasFeature("org.w3c.svg","1.0")||document.implementation.hasFeature(a+"SVG","1.1")||document.implementation.hasFeature(a+"BasicStructure","1.1")))},inValidRange:function(a,f,b){var d=a+(b?0:this.translationParameters.x);var c=f+(b?0:this.translationParameters.y);return(d>=-this.MAX_PIXEL&&d<=this.MAX_PIXEL&&c>=-this.MAX_PIXEL&&c<=this.MAX_PIXEL)},setExtent:function(b,d){OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,arguments);var a=this.getResolution();var g=-b.left/a;var f=b.top/a;if(d){this.left=g;this.top=f;var c="0 0 "+this.size.w+" "+this.size.h;this.rendererRoot.setAttributeNS(null,"viewBox",c);this.translate(0,0);return true}else{var h=this.translate(g-this.left,f-this.top);if(!h){this.setExtent(b,true)}return h}},translate:function(a,c){if(!this.inValidRange(a,c,true)){return false}else{var b="";if(a||c){b="translate("+a+","+c+")"}this.root.setAttributeNS(null,"transform",b);this.translationParameters={x:a,y:c};return true}},setSize:function(a){OpenLayers.Renderer.prototype.setSize.apply(this,arguments);this.rendererRoot.setAttributeNS(null,"width",this.size.w);this.rendererRoot.setAttributeNS(null,"height",this.size.h)},getNodeType:function(c,b){var a=null;switch(c.CLASS_NAME){case"OpenLayers.Geometry.Point":if(b.externalGraphic){a="image"}else{if(this.isComplexSymbol(b.graphicName)){a="use"}else{a="circle"}}break;case"OpenLayers.Geometry.Rectangle":a="rect";break;case"OpenLayers.Geometry.LineString":a="polyline";break;case"OpenLayers.Geometry.LinearRing":a="polygon";break;case"OpenLayers.Geometry.Polygon":case"OpenLayers.Geometry.Curve":case"OpenLayers.Geometry.Surface":a="path";break;default:break}return a},setStyle:function(s,v,b){v=v||s._style;b=b||s._options;var k=parseFloat(s.getAttributeNS(null,"r"));var j=1;var d;if(s._geometryClass=="OpenLayers.Geometry.Point"&&k){s.style.visibility="";if(v.graphic===false){s.style.visibility="hidden"}else{if(v.externalGraphic){d=this.getPosition(s);if(v.graphicTitle){s.setAttributeNS(null,"title",v.graphicTitle)}if(v.graphicWidth&&v.graphicHeight){s.setAttributeNS(null,"preserveAspectRatio","none")}var q=v.graphicWidth||v.graphicHeight;var m=v.graphicHeight||v.graphicWidth;q=q?q:v.pointRadius*2;m=m?m:v.pointRadius*2;var w=(v.graphicXOffset!=undefined)?v.graphicXOffset:-(0.5*q);var f=(v.graphicYOffset!=undefined)?v.graphicYOffset:-(0.5*m);var a=v.graphicOpacity||v.fillOpacity;s.setAttributeNS(null,"x",(d.x+w).toFixed());s.setAttributeNS(null,"y",(d.y+f).toFixed());s.setAttributeNS(null,"width",q);s.setAttributeNS(null,"height",m);s.setAttributeNS(this.xlinkns,"href",v.externalGraphic);s.setAttributeNS(null,"style","opacity: "+a)}else{if(this.isComplexSymbol(v.graphicName)){var c=v.pointRadius*3;var l=c*2;var o=this.importSymbol(v.graphicName);var u="#"+o;d=this.getPosition(s);j=this.symbolSize[o]/l;var g=s.parentNode;var h=s.nextSibling;if(g){g.removeChild(s)}s.setAttributeNS(this.xlinkns,"href",u);s.setAttributeNS(null,"width",l);s.setAttributeNS(null,"height",l);s.setAttributeNS(null,"x",d.x-c);s.setAttributeNS(null,"y",d.y-c);if(h){g.insertBefore(s,h)}else{if(g){g.appendChild(s)}}}else{s.setAttributeNS(null,"r",v.pointRadius)}}}if(typeof v.rotation!="undefined"&&d){var t=OpenLayers.String.format("rotate(${0} ${1} ${2})",[v.rotation,d.x,d.y]);s.setAttributeNS(null,"transform",t)}}if(b.isFilled){s.setAttributeNS(null,"fill",v.fillColor);s.setAttributeNS(null,"fill-opacity",v.fillOpacity)}else{s.setAttributeNS(null,"fill","none")}if(b.isStroked){s.setAttributeNS(null,"stroke",v.strokeColor);s.setAttributeNS(null,"stroke-opacity",v.strokeOpacity);s.setAttributeNS(null,"stroke-width",v.strokeWidth*j);s.setAttributeNS(null,"stroke-linecap",v.strokeLinecap);s.setAttributeNS(null,"stroke-linejoin","round");s.setAttributeNS(null,"stroke-dasharray",this.dashStyle(v,j))}else{s.setAttributeNS(null,"stroke","none")}if(v.pointerEvents){s.setAttributeNS(null,"pointer-events",v.pointerEvents)}if(v.cursor!=null){s.setAttributeNS(null,"cursor",v.cursor)}return s},dashStyle:function(c,b){var a=c.strokeWidth*b;switch(c.strokeDashstyle){case"solid":return"none";case"dot":return[1,4*a].join();case"dash":return[4*a,4*a].join();case"dashdot":return[4*a,4*a,1,4*a].join();case"longdash":return[8*a,4*a].join();case"longdashdot":return[8*a,4*a,1,4*a].join();default:return c.strokeDashstyle.replace(/ /g,",")}},createNode:function(a,c){var b=document.createElementNS(this.xmlns,a);if(c){b.setAttributeNS(null,"id",c)}return b},nodeTypeCompare:function(b,a){return(a==b.nodeName)},createRenderRoot:function(){return this.nodeFactory(this.container.id+"_svgRoot","svg")},createRoot:function(a){return this.nodeFactory(this.container.id+a,"g")},createDefs:function(){var a=this.nodeFactory(this.container.id+"_defs","defs");this.rendererRoot.appendChild(a);return a},drawPoint:function(a,b){return this.drawCircle(a,b,1)},drawCircle:function(d,f,b){var c=this.getResolution();var a=(f.x/c+this.left);var g=(this.top-f.y/c);if(this.inValidRange(a,g)){d.setAttributeNS(null,"cx",a);d.setAttributeNS(null,"cy",g);d.setAttributeNS(null,"r",b);return d}else{return false}},drawLineString:function(b,c){var a=this.getComponentsString(c.components);if(a.path){b.setAttributeNS(null,"points",a.path);return(a.complete?b:null)}else{return false}},drawLinearRing:function(b,c){var a=this.getComponentsString(c.components);if(a.path){b.setAttributeNS(null,"points",a.path);return(a.complete?b:null)}else{return false}},drawPolygon:function(b,k){var h="";var l=true;var a=true;var c,m;for(var f=0,g=k.components.length;f<g;f++){h+=" M";c=this.getComponentsString(k.components[f].components," ");m=c.path;if(m){h+=" "+m;a=c.complete&&a}else{l=false}}h+=" z";if(l){b.setAttributeNS(null,"d",h);b.setAttributeNS(null,"fill-rule","evenodd");return a?b:null}else{return false}},drawRectangle:function(c,d){var b=this.getResolution();var a=(d.x/b+this.left);var f=(this.top-d.y/b);if(this.inValidRange(a,f)){c.setAttributeNS(null,"x",a);c.setAttributeNS(null,"y",f);c.setAttributeNS(null,"width",d.width/b);c.setAttributeNS(null,"height",d.height/b);return c}else{return false}},drawSurface:function(g,j){var h=null;var b=true;for(var f=0,a=j.components.length;f<a;f++){if((f%3)==0&&(f/3)==0){var c=this.getShortString(j.components[f]);if(!c){b=false}h="M "+c}else{if((f%3)==1){var c=this.getShortString(j.components[f]);if(!c){b=false}h+=" C "+c}else{var c=this.getShortString(j.components[f]);if(!c){b=false}h+=" "+c}}}h+=" Z";if(b){g.setAttributeNS(null,"d",h);return g}else{return false}},drawText:function(c,a,k){var b=this.getResolution();var j=(k.x/b+this.left);var f=(k.y/b-this.top);var h=this.nodeFactory(c+this.LABEL_ID_SUFFIX,"text");var g=this.nodeFactory(c+this.LABEL_ID_SUFFIX+"_tspan","tspan");h.setAttributeNS(null,"x",j);h.setAttributeNS(null,"y",-f);h.setAttributeNS(null,"pointer-events","none");if(a.fontColor){h.setAttributeNS(null,"fill",a.fontColor)}if(a.fontFamily){h.setAttributeNS(null,"font-family",a.fontFamily)}if(a.fontSize){h.setAttributeNS(null,"font-size",a.fontSize)}if(a.fontWeight){h.setAttributeNS(null,"font-weight",a.fontWeight)}var d=a.labelAlign||"cm";h.setAttributeNS(null,"text-anchor",OpenLayers.Renderer.SVG.LABEL_ALIGN[d[0]]||"middle");if(this.isGecko){h.setAttributeNS(null,"dominant-baseline",OpenLayers.Renderer.SVG.LABEL_ALIGN[d[1]]||"central")}else{g.setAttributeNS(null,"baseline-shift",OpenLayers.Renderer.SVG.LABEL_VSHIFT[d[1]]||"-35%")}g.textContent=a.label;if(!h.parentNode){h.appendChild(g);this.textRoot.appendChild(h)}},getComponentsString:function(f,d){var h=[];var a=true;var g=f.length;var m=[];var k,l,b;for(var c=0;c<g;c++){l=f[c];h.push(l);k=this.getShortString(l);if(k){m.push(k)}else{if(c>0){if(this.getShortString(f[c-1])){m.push(this.clipLine(f[c],f[c-1]))}}if(c<g-1){if(this.getShortString(f[c+1])){m.push(this.clipLine(f[c],f[c+1]))}}a=false}}return{path:m.join(d||","),complete:a}},clipLine:function(f,j){if(j.equals(f)){return""}var g=this.getResolution();var b=this.MAX_PIXEL-this.translationParameters.x;var a=this.MAX_PIXEL-this.translationParameters.y;var d=j.x/g+this.left;var m=this.top-j.y/g;var c=f.x/g+this.left;var l=this.top-f.y/g;var h;if(c<-b||c>b){h=(l-m)/(c-d);c=c<0?-b:b;l=m+(c-d)*h}if(l<-a||l>a){h=(c-d)/(l-m);l=l<0?-a:a;c=d+(l-m)*h}return c+","+l},getShortString:function(b){var c=this.getResolution();var a=(b.x/c+this.left);var d=(this.top-b.y/c);if(this.inValidRange(a,d)){return a+","+d}else{return false}},getPosition:function(a){return({x:parseFloat(a.getAttributeNS(null,"cx")),y:parseFloat(a.getAttributeNS(null,"cy"))})},importSymbol:function(f){if(!this.defs){this.defs=this.createDefs()}var b=this.container.id+"-"+f;if(document.getElementById(b)!=null){return b}var d=OpenLayers.Renderer.symbol[f];if(!d){throw new Error(f+" is not a valid symbol name");return}var h=this.nodeFactory(b,"symbol");var c=this.nodeFactory(null,"polygon");h.appendChild(c);var o=new OpenLayers.Bounds(Number.MAX_VALUE,Number.MAX_VALUE,0,0);var l="";var k,j;for(var g=0;g<d.length;g=g+2){k=d[g];j=d[g+1];o.left=Math.min(o.left,k);o.bottom=Math.min(o.bottom,j);o.right=Math.max(o.right,k);o.top=Math.max(o.top,j);l+=" "+k+","+j}c.setAttributeNS(null,"points",l);var a=o.getWidth();var m=o.getHeight();var q=[o.left-a,o.bottom-m,a*3,m*3];h.setAttributeNS(null,"viewBox",q.join(" "));this.symbolSize[b]=Math.max(a,m)*3;this.defs.appendChild(h);return h.id},CLASS_NAME:"OpenLayers.Renderer.SVG"});OpenLayers.Renderer.SVG.LABEL_ALIGN={l:"start",r:"end",b:"bottom",t:"hanging"};OpenLayers.Renderer.SVG.LABEL_VSHIFT={t:"-70%",b:"0"};OpenLayers.Renderer.VML=OpenLayers.Class(OpenLayers.Renderer.Elements,{xmlns:"urn:schemas-microsoft-com:vml",symbolCache:{},offset:null,initialize:function(b){if(!this.supported()){return}if(!document.namespaces.olv){document.namespaces.add("olv",this.xmlns);var f=document.createStyleSheet();var c=["shape","rect","oval","fill","stroke","imagedata","group","textbox"];for(var d=0,a=c.length;d<a;d++){f.addRule("olv\\:"+c[d],"behavior: url(#default#VML); position: absolute; display: inline-block;")}}OpenLayers.Renderer.Elements.prototype.initialize.apply(this,arguments);this.offset={x:0,y:0}},destroy:function(){OpenLayers.Renderer.Elements.prototype.destroy.apply(this,arguments)},supported:function(){return !!(document.namespaces)},setExtent:function(k,a){OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,arguments);var c=this.getResolution();var b=k.left/c;var g=k.top/c-this.size.h;if(a){this.offset={x:b,y:g};b=0;g=0}else{b=b-this.offset.x;g=g-this.offset.y}var m=b+" "+g;this.root.coordorigin=m;var j=[this.root,this.vectorRoot,this.textRoot];var h;for(var d=0,f=j.length;d<f;++d){h=j[d];var l=this.size.w+" "+this.size.h;h.coordsize=l}this.root.style.flip="y";return true},setSize:function(g){OpenLayers.Renderer.prototype.setSize.apply(this,arguments);var d=[this.rendererRoot,this.root,this.vectorRoot,this.textRoot];var c=this.size.w+"px";var j=this.size.h+"px";var b;for(var f=0,a=d.length;f<a;++f){b=d[f];b.style.width=c;b.style.height=j}},getNodeType:function(c,b){var a=null;switch(c.CLASS_NAME){case"OpenLayers.Geometry.Point":if(b.externalGraphic){a="olv:rect"}else{if(this.isComplexSymbol(b.graphicName)){a="olv:shape"}else{a="olv:oval"}}break;case"OpenLayers.Geometry.Rectangle":a="olv:rect";break;case"OpenLayers.Geometry.LineString":case"OpenLayers.Geometry.LinearRing":case"OpenLayers.Geometry.Polygon":case"OpenLayers.Geometry.Curve":case"OpenLayers.Geometry.Surface":a="olv:shape";break;default:break}return a},setStyle:function(d,b,t,m){b=b||d._style;t=t||d._options;var k=1;if(d._geometryClass=="OpenLayers.Geometry.Point"){if(b.externalGraphic){if(b.graphicTitle){d.title=b.graphicTitle}var c=b.graphicWidth||b.graphicHeight;var o=b.graphicHeight||b.graphicWidth;c=c?c:b.pointRadius*2;o=o?o:b.pointRadius*2;var g=this.getResolution();var j=(b.graphicXOffset!=undefined)?b.graphicXOffset:-(0.5*c);var f=(b.graphicYOffset!=undefined)?b.graphicYOffset:-(0.5*o);d.style.left=((m.x/g-this.offset.x)+j).toFixed();d.style.top=((m.y/g-this.offset.y)-(f+o)).toFixed();d.style.width=c+"px";d.style.height=o+"px";d.style.flip="y";b.fillColor="none";t.isStroked=false}else{if(this.isComplexSymbol(b.graphicName)){var a=this.importSymbol(b.graphicName);d.path=a.path;d.coordorigin=a.left+","+a.bottom;var s=a.size;d.coordsize=s+","+s;this.drawCircle(d,m,b.pointRadius);d.style.flip="y"}else{this.drawCircle(d,m,b.pointRadius)}}}if(t.isFilled){d.fillcolor=b.fillColor}else{d.filled="false"}var l=d.getElementsByTagName("fill");var r=(l.length==0)?null:l[0];if(!t.isFilled){if(r){d.removeChild(r)}}else{if(!r){r=this.createNode("olv:fill",d.id+"_fill")}r.opacity=b.fillOpacity;if(d._geometryClass=="OpenLayers.Geometry.Point"&&b.externalGraphic){if(b.graphicOpacity){r.opacity=b.graphicOpacity}r.src=b.externalGraphic;r.type="frame";if(!(b.graphicWidth&&b.graphicHeight)){r.aspect="atmost"}}if(r.parentNode!=d){d.appendChild(r)}}if(typeof b.rotation!="undefined"){if(b.externalGraphic){this.graphicRotate(d,j,f);r.opacity=0}else{d.style.rotation=b.rotation}}if(t.isStroked){d.strokecolor=b.strokeColor;d.strokeweight=b.strokeWidth+"px"}else{d.stroked=false}var h=d.getElementsByTagName("stroke");var q=(h.length==0)?null:h[0];if(!t.isStroked){if(q){d.removeChild(q)}}else{if(!q){q=this.createNode("olv:stroke",d.id+"_stroke");d.appendChild(q)}q.opacity=b.strokeOpacity;q.endcap=!b.strokeLinecap||b.strokeLinecap=="butt"?"flat":b.strokeLinecap;q.dashstyle=this.dashStyle(b)}if(b.cursor!="inherit"&&b.cursor!=null){d.style.cursor=b.cursor}return d},graphicRotate:function(r,v,g){var u=u||r._style;var d=r._options;var a,l;if(!(u.graphicWidth&&u.graphicHeight)){var w=new Image();w.onreadystatechange=OpenLayers.Function.bind(function(){if(w.readyState=="complete"||w.readyState=="interactive"){a=w.width/w.height;l=Math.max(u.pointRadius*2,u.graphicWidth||0,u.graphicHeight||0);v=v*a;u.graphicWidth=l*a;u.graphicHeight=l;this.graphicRotate(r,v,g)}},this);w.src=u.externalGraphic;return}else{l=Math.max(u.graphicWidth,u.graphicHeight);a=u.graphicWidth/u.graphicHeight}var q=Math.round(u.graphicWidth||l*a);var m=Math.round(u.graphicHeight||l);r.style.width=q+"px";r.style.height=m+"px";var o=document.getElementById(r.id+"_image");if(!o){o=this.createNode("olv:imagedata",r.id+"_image");r.appendChild(o)}o.style.width=q+"px";o.style.height=m+"px";o.src=u.externalGraphic;o.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='', sizingMethod='scale')";var s=u.rotation*Math.PI/180;var j=Math.sin(s);var f=Math.cos(s);var h="progid:DXImageTransform.Microsoft.Matrix(M11="+f+",M12="+(-j)+",M21="+j+",M22="+f+",SizingMethod='auto expand')\n";var b=u.graphicOpacity||u.fillOpacity;if(b&&b!=1){h+="progid:DXImageTransform.Microsoft.BasicImage(opacity="+b+")\n"}r.style.filter=h;var t=new OpenLayers.Geometry.Point(-v,-g);var c=new OpenLayers.Bounds(0,0,q,m).toGeometry();c.rotate(u.rotation,t);var k=c.getBounds();r.style.left=Math.round(parseInt(r.style.left)+k.left)+"px";r.style.top=Math.round(parseInt(r.style.top)-k.bottom)+"px"},postDraw:function(a){var c=a._style.fillColor;var b=a._style.strokeColor;if(c=="none"&&a.fillcolor!=c){a.fillcolor=c}if(b=="none"&&a.strokecolor!=b){a.strokecolor=b}},setNodeDimension:function(b,f){var d=f.getBounds();if(d){var a=this.getResolution();var c=new OpenLayers.Bounds((d.left/a-this.offset.x).toFixed(),(d.bottom/a-this.offset.y).toFixed(),(d.right/a-this.offset.x).toFixed(),(d.top/a-this.offset.y).toFixed());b.style.left=c.left+"px";b.style.top=c.top+"px";b.style.width=c.getWidth()+"px";b.style.height=c.getHeight()+"px";b.coordorigin=c.left+" "+c.top;b.coordsize=c.getWidth()+" "+c.getHeight()}},dashStyle:function(a){var c=a.strokeDashstyle;switch(c){case"solid":case"dot":case"dash":case"dashdot":case"longdash":case"longdashdot":return c;default:var b=c.split(/[ ,]/);if(b.length==2){if(1*b[0]>=2*b[1]){return"longdash"}return(b[0]==1||b[1]==1)?"dot":"dash"}else{if(b.length==4){return(1*b[0]>=2*b[1])?"longdashdot":"dashdot"}}return"solid"}},createNode:function(a,c){var b=document.createElement(a);if(c){b.id=c}b.unselectable="on";b.onselectstart=function(){return(false)};return b},nodeTypeCompare:function(c,b){var d=b;var a=d.indexOf(":");if(a!=-1){d=d.substr(a+1)}var f=c.nodeName;a=f.indexOf(":");if(a!=-1){f=f.substr(a+1)}return(d==f)},createRenderRoot:function(){return this.nodeFactory(this.container.id+"_vmlRoot","div")},createRoot:function(a){return this.nodeFactory(this.container.id+a,"olv:group")},drawPoint:function(a,b){return this.drawCircle(a,b,1)},drawCircle:function(d,f,a){if(!isNaN(f.x)&&!isNaN(f.y)){var b=this.getResolution();d.style.left=((f.x/b-this.offset.x).toFixed()-a)+"px";d.style.top=((f.y/b-this.offset.y).toFixed()-a)+"px";var c=a*2;d.style.width=c+"px";d.style.height=c+"px";return d}return false},drawLineString:function(a,b){return this.drawLine(a,b,false)},drawLinearRing:function(a,b){return this.drawLine(a,b,true)},drawLine:function(b,l,h){this.setNodeDimension(b,l);var c=this.getResolution();var a=l.components.length;var f=new Array(a);var j,m,k;for(var g=0;g<a;g++){j=l.components[g];m=(j.x/c-this.offset.x);k=(j.y/c-this.offset.y);f[g]=" "+m.toFixed()+","+k.toFixed()+" l "}var d=(h)?" x e":" e";b.path="m"+f.join("")+d;return b},drawPolygon:function(b,m){this.setNodeDimension(b,m);var c=this.getResolution();var q=[];var g,f,d,k,a,h,o,l;for(d=0,k=m.components.length;d<k;d++){g=m.components[d];q.push("m");for(f=0,a=g.components.length;f<a;f++){h=g.components[f];o=h.x/c-this.offset.x;l=h.y/c-this.offset.y;q.push(" "+o.toFixed()+","+l.toFixed());if(f==0){q.push(" l")}}q.push(" x ")}q.push("e");b.path=q.join("");return b},drawRectangle:function(b,c){var a=this.getResolution();b.style.left=(c.x/a-this.offset.x)+"px";b.style.top=(c.y/a-this.offset.y)+"px";b.style.width=c.width/a+"px";b.style.height=c.height/a+"px";return b},drawText:function(d,a,j){var h=this.nodeFactory(d+this.LABEL_ID_SUFFIX,"olv:rect");var g=this.nodeFactory(d+this.LABEL_ID_SUFFIX+"_textbox","olv:textbox");var c=this.getResolution();h.style.left=(j.x/c-this.offset.x).toFixed()+"px";h.style.top=(j.y/c-this.offset.y).toFixed()+"px";h.style.flip="y";g.innerText=a.label;if(a.fillColor){g.style.color=a.fontColor}if(a.fontFamily){g.style.fontFamily=a.fontFamily}if(a.fontSize){g.style.fontSize=a.fontSize}if(a.fontWeight){g.style.fontWeight=a.fontWeight}g.style.whiteSpace="nowrap";g.inset="1px,0px,0px,0px";if(!h.parentNode){h.appendChild(g);this.textRoot.appendChild(h)}var f=a.labelAlign||"cm";var k=g.clientWidth*(OpenLayers.Renderer.VML.LABEL_SHIFT[f.substr(0,1)]);var b=g.clientHeight*(OpenLayers.Renderer.VML.LABEL_SHIFT[f.substr(1,1)]);h.style.left=parseInt(h.style.left)-k-1+"px";h.style.top=parseInt(h.style.top)+b+"px"},drawSurface:function(a,h){this.setNodeDimension(a,h);var b=this.getResolution();var k=[];var d,j,g;for(var c=0,f=h.components.length;c<f;c++){d=h.components[c];j=d.x/b-this.offset.x;g=d.y/b-this.offset.y;if((c%3)==0&&(c/3)==0){k.push("m")}else{if((c%3)==1){k.push(" c")}}k.push(" "+j+","+g)}k.push(" x e");a.path=k.join("");return a},moveRoot:function(b){var a=this.map.getLayer(b.container.id);if(a instanceof OpenLayers.Layer.Vector.RootContainer){a=this.map.getLayer(this.container.id)}a&&a.renderer.clear();OpenLayers.Renderer.Elements.prototype.moveRoot.apply(this,arguments);a&&a.redraw()},importSymbol:function(d){var b=this.container.id+"-"+d;var a=this.symbolCache[b];if(a){return a}var c=OpenLayers.Renderer.symbol[d];if(!c){throw new Error(d+" is not a valid symbol name");return}var j=new OpenLayers.Bounds(Number.MAX_VALUE,Number.MAX_VALUE,0,0);var f=["m"];for(var g=0;g<c.length;g=g+2){x=c[g];y=c[g+1];j.left=Math.min(j.left,x);j.bottom=Math.min(j.bottom,y);j.right=Math.max(j.right,x);j.top=Math.max(j.top,y);f.push(x);f.push(y);if(g==0){f.push("l")}}f.push("x e");var k=f.join(" ");var h=(j.getWidth()-j.getHeight())/2;if(h>0){j.bottom=j.bottom-h;j.top=j.top+h}else{j.left=j.left-h;j.right=j.right+h}a={path:k,size:j.getWidth(),left:j.left,bottom:j.bottom};this.symbolCache[b]=a;return a},CLASS_NAME:"OpenLayers.Renderer.VML"});OpenLayers.Renderer.VML.LABEL_SHIFT={l:0,c:0.5,r:1,t:0,m:0.5,b:1};OpenLayers.Tile=OpenLayers.Class({EVENT_TYPES:["loadstart","loadend","reload","unload"],events:null,id:null,layer:null,url:null,bounds:null,size:null,position:null,isLoading:false,initialize:function(d,a,f,b,c){this.layer=d;this.position=a.clone();this.bounds=f.clone();this.url=b;this.size=c.clone();this.id=OpenLayers.Util.createUniqueID("Tile_");this.events=new OpenLayers.Events(this,null,this.EVENT_TYPES)},unload:function(){if(this.isLoading){this.isLoading=false;this.events.triggerEvent("unload")}},destroy:function(){this.layer=null;this.bounds=null;this.size=null;this.position=null;this.events.destroy();this.events=null},clone:function(a){if(a==null){a=new OpenLayers.Tile(this.layer,this.position,this.bounds,this.url,this.size)}OpenLayers.Util.applyDefaults(a,this);return a},draw:function(){var a=this.layer.maxExtent;var b=(a&&this.bounds.intersectsBounds(a,false));this.shouldDraw=(b||this.layer.displayOutsideMaxExtent);this.clear();return this.shouldDraw},moveTo:function(b,a,c){if(c==null){c=true}this.bounds=b.clone();this.position=a.clone();if(c){this.draw()}},clear:function(){},getBoundsFromBaseLayer:function(a){var g=OpenLayers.i18n("reprojectDeprecated",{layerName:this.layer.name});OpenLayers.Console.warn(g);var d=this.layer.map.getLonLatFromLayerPx(a);var c=a.clone();c.x+=this.size.w;c.y+=this.size.h;var b=this.layer.map.getLonLatFromLayerPx(c);if(d.lon>b.lon){if(d.lon<0){d.lon=-180-(d.lon+180)}else{b.lon=180+b.lon+180}}var f=new OpenLayers.Bounds(d.lon,b.lat,b.lon,d.lat);return f},showTile:function(){if(this.shouldDraw){this.show()}},show:function(){},hide:function(){},CLASS_NAME:"OpenLayers.Tile"});OpenLayers.Control.MouseToolbar=OpenLayers.Class(OpenLayers.Control.MouseDefaults,{mode:null,buttons:null,direction:"vertical",buttonClicked:null,initialize:function(a,b){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.position=new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,OpenLayers.Control.MouseToolbar.Y);if(a){this.position=a}if(b){this.direction=b}this.measureDivs=[]},destroy:function(){for(var b in this.buttons){var a=this.buttons[b];a.map=null;a.events.destroy()}OpenLayers.Control.MouseDefaults.prototype.destroy.apply(this,arguments)},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);OpenLayers.Control.MouseDefaults.prototype.draw.apply(this,arguments);this.buttons={};var b=new OpenLayers.Size(28,28);var a=new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,0);this._addButton("zoombox","drag-rectangle-off.png","drag-rectangle-on.png",a,b,"Shift->Drag to zoom to area");a=a.add((this.direction=="vertical"?0:b.w),(this.direction=="vertical"?b.h:0));this._addButton("pan","panning-hand-off.png","panning-hand-on.png",a,b,"Drag the map to pan.");a=a.add((this.direction=="vertical"?0:b.w),(this.direction=="vertical"?b.h:0));this.switchModeTo("pan");return this.div},_addButton:function(a,f,d,k,h,j){var g=OpenLayers.Util.getImagesLocation()+f;var c=OpenLayers.Util.getImagesLocation()+d;var b=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_MouseToolbar_"+a,k,h,g,"absolute");this.div.appendChild(b);b.imgLocation=g;b.activeImgLocation=c;b.events=new OpenLayers.Events(this,b,null,true);b.events.on({mousedown:this.buttonDown,mouseup:this.buttonUp,dblclick:OpenLayers.Event.stop,scope:this});b.action=a;b.title=j;b.alt=j;b.map=this.map;this.buttons[a]=b;return b},buttonDown:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}this.buttonClicked=a.element.action;OpenLayers.Event.stop(a)},buttonUp:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}if(this.buttonClicked!=null){if(this.buttonClicked==a.element.action){this.switchModeTo(a.element.action)}OpenLayers.Event.stop(a);this.buttonClicked=null}},defaultDblClick:function(b){this.switchModeTo("pan");this.performedDrag=false;var a=this.map.getLonLatFromViewPortPx(b.xy);this.map.setCenter(a,this.map.zoom+1);OpenLayers.Event.stop(b);return false},defaultMouseDown:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}this.mouseDragStart=a.xy.clone();this.performedDrag=false;this.startViaKeyboard=false;if(a.shiftKey&&this.mode!="zoombox"){this.switchModeTo("zoombox");this.startViaKeyboard=true}else{if(a.altKey&&this.mode!="measure"){this.switchModeTo("measure")}else{if(!this.mode){this.switchModeTo("pan")}}}switch(this.mode){case"zoombox":this.map.div.style.cursor="crosshair";this.zoomBox=OpenLayers.Util.createDiv("zoomBox",this.mouseDragStart,null,null,"absolute","2px solid red");this.zoomBox.style.backgroundColor="white";this.zoomBox.style.filter="alpha(opacity=50)";this.zoomBox.style.opacity="0.50";this.zoomBox.style.fontSize="1px";this.zoomBox.style.zIndex=this.map.Z_INDEX_BASE.Popup-1;this.map.viewPortDiv.appendChild(this.zoomBox);this.performedDrag=true;break;case"measure":var c="";if(this.measureStart){var b=this.map.getLonLatFromViewPortPx(this.mouseDragStart);c=OpenLayers.Util.distVincenty(this.measureStart,b);c=Math.round(c*100)/100;c=c+"km";this.measureStartBox=this.measureBox}this.measureStart=this.map.getLonLatFromViewPortPx(this.mouseDragStart);this.measureBox=OpenLayers.Util.createDiv(null,this.mouseDragStart.add(-2-parseInt(this.map.layerContainerDiv.style.left),-2-parseInt(this.map.layerContainerDiv.style.top)),null,null,"absolute");this.measureBox.style.width="4px";this.measureBox.style.height="4px";this.measureBox.style.fontSize="1px";this.measureBox.style.backgroundColor="red";this.measureBox.style.zIndex=this.map.Z_INDEX_BASE.Popup-1;this.map.layerContainerDiv.appendChild(this.measureBox);if(c){this.measureBoxDistance=OpenLayers.Util.createDiv(null,this.mouseDragStart.add(-2-parseInt(this.map.layerContainerDiv.style.left),2-parseInt(this.map.layerContainerDiv.style.top)),null,null,"absolute");this.measureBoxDistance.innerHTML=c;this.measureBoxDistance.style.zIndex=this.map.Z_INDEX_BASE.Popup-1;this.map.layerContainerDiv.appendChild(this.measureBoxDistance);this.measureDivs.push(this.measureBoxDistance)}this.measureBox.style.zIndex=this.map.Z_INDEX_BASE.Popup-1;this.map.layerContainerDiv.appendChild(this.measureBox);this.measureDivs.push(this.measureBox);break;default:this.map.div.style.cursor="move";break}document.onselectstart=function(){return false};OpenLayers.Event.stop(a)},switchModeTo:function(c){if(c!=this.mode){if(this.mode&&this.buttons[this.mode]){OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode],null,null,null,this.buttons[this.mode].imgLocation)}if(this.mode=="measure"&&c!="measure"){for(var b=0,a=this.measureDivs.length;b<a;b++){if(this.measureDivs[b]){this.map.layerContainerDiv.removeChild(this.measureDivs[b])}}this.measureDivs=[];this.measureStart=null}this.mode=c;if(this.buttons[c]){OpenLayers.Util.modifyAlphaImageDiv(this.buttons[c],null,null,null,this.buttons[c].activeImgLocation)}switch(this.mode){case"zoombox":this.map.div.style.cursor="crosshair";break;default:this.map.div.style.cursor="";break}}},leaveMode:function(){this.switchModeTo("pan")},defaultMouseMove:function(f){if(this.mouseDragStart!=null){switch(this.mode){case"zoombox":var d=Math.abs(this.mouseDragStart.x-f.xy.x);var b=Math.abs(this.mouseDragStart.y-f.xy.y);this.zoomBox.style.width=Math.max(1,d)+"px";this.zoomBox.style.height=Math.max(1,b)+"px";if(f.xy.x<this.mouseDragStart.x){this.zoomBox.style.left=f.xy.x+"px"}if(f.xy.y<this.mouseDragStart.y){this.zoomBox.style.top=f.xy.y+"px"}break;default:var d=this.mouseDragStart.x-f.xy.x;var b=this.mouseDragStart.y-f.xy.y;var g=this.map.getSize();var a=new OpenLayers.Pixel(g.w/2+d,g.h/2+b);var c=this.map.getLonLatFromViewPortPx(a);this.map.setCenter(c,null,true);this.mouseDragStart=f.xy.clone()}this.performedDrag=true}},defaultMouseUp:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}switch(this.mode){case"zoombox":this.zoomBoxEnd(a);if(this.startViaKeyboard){this.leaveMode()}break;case"pan":if(this.performedDrag){this.map.setCenter(this.map.center)}}document.onselectstart=null;this.mouseDragStart=null;this.map.div.style.cursor="default"},defaultMouseOut:function(a){if(this.mouseDragStart!=null&&OpenLayers.Util.mouseLeft(a,this.map.div)){if(this.zoomBox){this.removeZoomBox();if(this.startViaKeyboard){this.leaveMode()}}this.mouseDragStart=null;this.map.div.style.cursor="default"}},defaultClick:function(a){if(this.performedDrag){this.performedDrag=false;return false}},CLASS_NAME:"OpenLayers.Control.MouseToolbar"});OpenLayers.Control.MouseToolbar.X=6;OpenLayers.Control.MouseToolbar.Y=300;OpenLayers.Control.NavigationHistory=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOGGLE,previous:null,previousOptions:null,next:null,nextOptions:null,limit:50,activateOnDraw:true,clearOnDeactivate:false,registry:null,nextStack:null,previousStack:null,listeners:null,restoring:false,initialize:function(a){OpenLayers.Control.prototype.initialize.apply(this,[a]);this.registry=OpenLayers.Util.extend({moveend:function(){return{center:this.map.getCenter(),resolution:this.map.getResolution()}}},this.registry);this.clear();var b={trigger:OpenLayers.Function.bind(this.previousTrigger,this),displayClass:this.displayClass+" "+this.displayClass+"Previous"};OpenLayers.Util.extend(b,this.previousOptions);this.previous=new OpenLayers.Control.Button(b);var c={trigger:OpenLayers.Function.bind(this.nextTrigger,this),displayClass:this.displayClass+" "+this.displayClass+"Next"};OpenLayers.Util.extend(c,this.nextOptions);this.next=new OpenLayers.Control.Button(c)},onPreviousChange:function(b,a){if(b&&!this.previous.active){this.previous.activate()}else{if(!b&&this.previous.active){this.previous.deactivate()}}},onNextChange:function(b,a){if(b&&!this.next.active){this.next.activate()}else{if(!b&&this.next.active){this.next.deactivate()}}},destroy:function(){OpenLayers.Control.prototype.destroy.apply(this);this.previous.destroy();this.next.destroy();this.deactivate();for(var a in this){this[a]=null}},setMap:function(a){this.map=a;this.next.setMap(a);this.previous.setMap(a)},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);this.next.draw();this.previous.draw();if(this.activateOnDraw){this.activate()}},previousTrigger:function(){var b=this.previousStack.shift();var a=this.previousStack.shift();if(a!=undefined){this.nextStack.unshift(b);this.previousStack.unshift(a);this.restoring=true;this.restore(a);this.restoring=false;this.onNextChange(this.nextStack[0],this.nextStack.length);this.onPreviousChange(this.previousStack[1],this.previousStack.length-1)}else{this.previousStack.unshift(b)}return a},nextTrigger:function(){var a=this.nextStack.shift();if(a!=undefined){this.previousStack.unshift(a);this.restoring=true;this.restore(a);this.restoring=false;this.onNextChange(this.nextStack[0],this.nextStack.length);this.onPreviousChange(this.previousStack[1],this.previousStack.length-1)}return a},clear:function(){this.previousStack=[];this.nextStack=[]},restore:function(b){var a=this.map.getZoomForResolution(b.resolution);this.map.setCenter(b.center,a)},setListeners:function(){this.listeners={};for(var a in this.registry){this.listeners[a]=OpenLayers.Function.bind(function(){if(!this.restoring){var b=this.registry[a].apply(this,arguments);this.previousStack.unshift(b);if(this.previousStack.length>1){this.onPreviousChange(this.previousStack[1],this.previousStack.length-1)}if(this.previousStack.length>(this.limit+1)){this.previousStack.pop()}if(this.nextStack.length>0){this.nextStack=[];this.onNextChange(null,0)}}return true},this)}},activate:function(){var a=false;if(this.map){if(OpenLayers.Control.prototype.activate.apply(this)){if(this.listeners==null){this.setListeners()}for(var b in this.listeners){this.map.events.register(b,this,this.listeners[b])}a=true;if(this.previousStack.length==0){this.initStack()}}}return a},initStack:function(){if(this.map.getCenter()){this.listeners.moveend()}},deactivate:function(){var b=false;if(this.map){if(OpenLayers.Control.prototype.deactivate.apply(this)){for(var a in this.listeners){this.map.events.unregister(a,this,this.listeners[a])}if(this.clearOnDeactivate){this.clear()}b=true}}return b},CLASS_NAME:"OpenLayers.Control.NavigationHistory"});OpenLayers.Control.PanPanel=OpenLayers.Class(OpenLayers.Control.Panel,{initialize:function(a){OpenLayers.Control.Panel.prototype.initialize.apply(this,[a]);this.addControls([new OpenLayers.Control.Pan(OpenLayers.Control.Pan.NORTH),new OpenLayers.Control.Pan(OpenLayers.Control.Pan.SOUTH),new OpenLayers.Control.Pan(OpenLayers.Control.Pan.EAST),new OpenLayers.Control.Pan(OpenLayers.Control.Pan.WEST)])},CLASS_NAME:"OpenLayers.Control.PanPanel"});OpenLayers.Control.PanZoomBar=OpenLayers.Class(OpenLayers.Control.PanZoom,{zoomStopWidth:18,zoomStopHeight:11,slider:null,sliderEvents:null,zoomBarDiv:null,divEvents:null,zoomWorldIcon:false,initialize:function(){OpenLayers.Control.PanZoom.prototype.initialize.apply(this,arguments)},destroy:function(){this._removeZoomBar();this.map.events.un({changebaselayer:this.redraw,scope:this});OpenLayers.Control.PanZoom.prototype.destroy.apply(this,arguments)},setMap:function(a){OpenLayers.Control.PanZoom.prototype.setMap.apply(this,arguments);this.map.events.register("changebaselayer",this,this.redraw)},redraw:function(){if(this.div!=null){this.removeButtons();this._removeZoomBar()}this.draw()},draw:function(b){OpenLayers.Control.prototype.draw.apply(this,arguments);b=this.position.clone();this.buttons=[];var d=new OpenLayers.Size(18,18);var a=new OpenLayers.Pixel(b.x+d.w/2,b.y);var c=d.w;if(this.zoomWorldIcon){a=new OpenLayers.Pixel(b.x+d.w,b.y)}this._addButton("panup","north-mini.png",a,d);b.y=a.y+d.h;this._addButton("panleft","west-mini.png",b,d);if(this.zoomWorldIcon){this._addButton("zoomworld","zoom-world-mini.png",b.add(d.w,0),d);c*=2}this._addButton("panright","east-mini.png",b.add(c,0),d);this._addButton("pandown","south-mini.png",a.add(0,d.h*2),d);this._addButton("zoomin","zoom-plus-mini.png",a.add(0,d.h*3+5),d);a=this._addZoomBar(a.add(0,d.h*4+5));this._addButton("zoomout","zoom-minus-mini.png",a,d);return this.div},_addZoomBar:function(a){var f=OpenLayers.Util.getImagesLocation();var h=this.id+"_"+this.map.id;var b=this.map.getNumZoomLevels()-1-this.map.getZoom();var c=OpenLayers.Util.createAlphaImageDiv(h,a.add(-1,b*this.zoomStopHeight),new OpenLayers.Size(20,9),f+"slider.png","absolute");this.slider=c;this.sliderEvents=new OpenLayers.Events(this,c,null,true,{includeXY:true});this.sliderEvents.on({mousedown:this.zoomBarDown,mousemove:this.zoomBarDrag,mouseup:this.zoomBarUp,dblclick:this.doubleClick,click:this.doubleClick});var d=new OpenLayers.Size();d.h=this.zoomStopHeight*this.map.getNumZoomLevels();d.w=this.zoomStopWidth;var g=null;if(OpenLayers.Util.alphaHack()){var h=this.id+"_"+this.map.id;g=OpenLayers.Util.createAlphaImageDiv(h,a,new OpenLayers.Size(d.w,this.zoomStopHeight),f+"zoombar.png","absolute",null,"crop");g.style.height=d.h+"px"}else{g=OpenLayers.Util.createDiv("OpenLayers_Control_PanZoomBar_Zoombar"+this.map.id,a,d,f+"zoombar.png")}this.zoombarDiv=g;this.divEvents=new OpenLayers.Events(this,g,null,true,{includeXY:true});this.divEvents.on({mousedown:this.divClick,mousemove:this.passEventToSlider,dblclick:this.doubleClick,click:this.doubleClick});this.div.appendChild(g);this.startTop=parseInt(g.style.top);this.div.appendChild(c);this.map.events.register("zoomend",this,this.moveZoomBar);a=a.add(0,this.zoomStopHeight*this.map.getNumZoomLevels());return a},_removeZoomBar:function(){this.sliderEvents.un({mousedown:this.zoomBarDown,mousemove:this.zoomBarDrag,mouseup:this.zoomBarUp,dblclick:this.doubleClick,click:this.doubleClick});this.sliderEvents.destroy();this.divEvents.un({mousedown:this.divClick,mousemove:this.passEventToSlider,dblclick:this.doubleClick,click:this.doubleClick});this.divEvents.destroy();this.div.removeChild(this.zoombarDiv);this.zoombarDiv=null;this.div.removeChild(this.slider);this.slider=null;this.map.events.unregister("zoomend",this,this.moveZoomBar)},passEventToSlider:function(a){this.sliderEvents.handleBrowserEvent(a)},divClick:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}var f=a.xy.y;var d=OpenLayers.Util.pagePosition(a.object)[1];var c=(f-d)/this.zoomStopHeight;if(!this.map.fractionalZoom){c=Math.floor(c)}var b=(this.map.getNumZoomLevels()-1)-c;b=Math.min(Math.max(b,0),this.map.getNumZoomLevels()-1);this.map.zoomTo(b);OpenLayers.Event.stop(a)},zoomBarDown:function(a){if(!OpenLayers.Event.isLeftClick(a)){return}this.map.events.on({mousemove:this.passEventToSlider,mouseup:this.passEventToSlider,scope:this});this.mouseDragStart=a.xy.clone();this.zoomStart=a.xy.clone();this.div.style.cursor="move";this.zoombarDiv.offsets=null;OpenLayers.Event.stop(a)},zoomBarDrag:function(b){if(this.mouseDragStart!=null){var a=this.mouseDragStart.y-b.xy.y;var d=OpenLayers.Util.pagePosition(this.zoombarDiv);if((b.clientY-d[1])>0&&(b.clientY-d[1])<parseInt(this.zoombarDiv.style.height)-2){var c=parseInt(this.slider.style.top)-a;this.slider.style.top=c+"px";this.mouseDragStart=b.xy.clone()}OpenLayers.Event.stop(b)}},zoomBarUp:function(b){if(!OpenLayers.Event.isLeftClick(b)){return}if(this.zoomStart){this.div.style.cursor="";this.map.events.un({mouseup:this.passEventToSlider,mousemove:this.passEventToSlider,scope:this});var a=this.zoomStart.y-b.xy.y;var c=this.map.zoom;if(this.map.fractionalZoom){c+=a/this.zoomStopHeight;c=Math.min(Math.max(c,0),this.map.getNumZoomLevels()-1)}else{c+=Math.round(a/this.zoomStopHeight)}this.map.zoomTo(c);this.moveZoomBar();this.mouseDragStart=null;OpenLayers.Event.stop(b)}},moveZoomBar:function(){var a=((this.map.getNumZoomLevels()-1)-this.map.getZoom())*this.zoomStopHeight+this.startTop+1;this.slider.style.top=a+"px"},CLASS_NAME:"OpenLayers.Control.PanZoomBar"});OpenLayers.Control.Permalink=OpenLayers.Class(OpenLayers.Control,{argParserClass:OpenLayers.Control.ArgParser,element:null,base:"",displayProjection:null,initialize:function(b,c,a){OpenLayers.Control.prototype.initialize.apply(this,[a]);this.element=OpenLayers.Util.getElement(b);this.base=c||document.location.href},destroy:function(){if(this.element.parentNode==this.div){this.div.removeChild(this.element)}this.element=null;this.map.events.unregister("moveend",this,this.updateLink);OpenLayers.Control.prototype.destroy.apply(this,arguments)},setMap:function(d){OpenLayers.Control.prototype.setMap.apply(this,arguments);for(var b=0,a=this.map.controls.length;b<a;b++){var c=this.map.controls[b];if(c.CLASS_NAME==this.argParserClass.CLASS_NAME){if(c.displayProjection!=this.displayProjection){this.displayProjection=c.displayProjection}break}}if(b==this.map.controls.length){this.map.addControl(new this.argParserClass({displayProjection:this.displayProjection}))}},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!this.element){this.div.className=this.displayClass;this.element=document.createElement("a");this.element.innerHTML=OpenLayers.i18n("permalink");this.element.href="";this.div.appendChild(this.element)}this.map.events.on({moveend:this.updateLink,changelayer:this.updateLink,changebaselayer:this.updateLink,scope:this});this.updateLink();return this.div},updateLink:function(){var a=this.base;if(a.indexOf("?")!=-1){a=a.substring(0,a.indexOf("?"))}a+="?"+OpenLayers.Util.getParameterString(this.createParams());this.element.href=a},createParams:function(a,l,f){a=a||this.map.getCenter();var d=OpenLayers.Util.getParameters(this.base);if(a){d.zoom=l||this.map.getZoom();var k=a.lat;var b=a.lon;if(this.displayProjection){var c=OpenLayers.Projection.transform({x:b,y:k},this.map.getProjectionObject(),this.displayProjection);b=c.x;k=c.y}d.lat=Math.round(k*100000)/100000;d.lon=Math.round(b*100000)/100000;f=f||this.map.layers;d.layers="";for(var g=0,j=f.length;g<j;g++){var h=f[g];if(h.isBaseLayer){d.layers+=(h==this.map.baseLayer)?"B":"0"}else{d.layers+=(h.getVisibility())?"T":"F"}}}return d},CLASS_NAME:"OpenLayers.Control.Permalink"});OpenLayers.Control.ZoomPanel=OpenLayers.Class(OpenLayers.Control.Panel,{initialize:function(a){OpenLayers.Control.Panel.prototype.initialize.apply(this,[a]);this.addControls([new OpenLayers.Control.ZoomIn(),new OpenLayers.Control.ZoomToMaxExtent(),new OpenLayers.Control.ZoomOut()])},CLASS_NAME:"OpenLayers.Control.ZoomPanel"});OpenLayers.Format.JSON=OpenLayers.Class(OpenLayers.Format,{indent:"    ",space:" ",newline:"\n",level:0,pretty:false,initialize:function(a){OpenLayers.Format.prototype.initialize.apply(this,[a])},read:function(json,filter){try{if(/^[\],:{}\s]*$/.test(json.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){var object=eval("("+json+")");if(typeof filter==="function"){function walk(k,v){if(v&&typeof v==="object"){for(var i in v){if(v.hasOwnProperty(i)){v[i]=walk(i,v[i])}}}return filter(k,v)}object=walk("",object)}if(this.keepData){this.data=object}return object}}catch(e){}return null},write:function(f,c){this.pretty=!!c;var a=null;var b=typeof f;if(this.serialize[b]){try{a=this.serialize[b].apply(this,[f])}catch(d){OpenLayers.Console.error("Trouble serializing: "+d)}}return a},writeIndent:function(){var b=[];if(this.pretty){for(var a=0;a<this.level;++a){b.push(this.indent)}}return b.join("")},writeNewline:function(){return(this.pretty)?this.newline:""},writeSpace:function(){return(this.pretty)?this.space:""},serialize:{object:function(c){if(c==null){return"null"}if(c.constructor==Date){return this.serialize.date.apply(this,[c])}if(c.constructor==Array){return this.serialize.array.apply(this,[c])}var g=["{"];this.level+=1;var d,b,f;var a=false;for(d in c){if(c.hasOwnProperty(d)){b=OpenLayers.Format.JSON.prototype.write.apply(this,[d,this.pretty]);f=OpenLayers.Format.JSON.prototype.write.apply(this,[c[d],this.pretty]);if(b!=null&&f!=null){if(a){g.push(",")}g.push(this.writeNewline(),this.writeIndent(),b,":",this.writeSpace(),f);a=true}}}this.level-=1;g.push(this.writeNewline(),this.writeIndent(),"}");return g.join("")},array:function(f){var c;var d=["["];this.level+=1;for(var b=0,a=f.length;b<a;++b){c=OpenLayers.Format.JSON.prototype.write.apply(this,[f[b],this.pretty]);if(c!=null){if(b>0){d.push(",")}d.push(this.writeNewline(),this.writeIndent(),c)}}this.level-=1;d.push(this.writeNewline(),this.writeIndent(),"]");return d.join("")},string:function(b){var a={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};if(/["\\\x00-\x1f]/.test(b)){return'"'+b.replace(/([\x00-\x1f\\"])/g,function(f,d){var g=a[d];if(g){return g}g=d.charCodeAt();return"\\u00"+Math.floor(g/16).toString(16)+(g%16).toString(16)})+'"'}return'"'+b+'"'},number:function(a){return isFinite(a)?String(a):"null"},"boolean":function(a){return String(a)},date:function(a){function b(c){return(c<10)?"0"+c:c}return'"'+a.getFullYear()+"-"+b(a.getMonth()+1)+"-"+b(a.getDate())+"T"+b(a.getHours())+":"+b(a.getMinutes())+":"+b(a.getSeconds())+'"'}},CLASS_NAME:"OpenLayers.Format.JSON"});OpenLayers.Format.WFST=function(b){b=OpenLayers.Util.applyDefaults(b,OpenLayers.Format.WFST.DEFAULTS);var a=OpenLayers.Format.WFST["v"+b.version.replace(/\./g,"_")];if(!a){throw"Unsupported WFST version: "+b.version}return new a(b)};OpenLayers.Format.WFST.DEFAULTS={version:"1.0.0"};OpenLayers.Format.WMSCapabilities=OpenLayers.Class(OpenLayers.Format.XML,{defaultVersion:"1.1.1",version:null,parser:null,initialize:function(a){OpenLayers.Format.prototype.initialize.apply(this,[a]);this.options=a},read:function(f){if(typeof f=="string"){f=OpenLayers.Format.XML.prototype.read.apply(this,[f])}var c=f.documentElement;var b=this.version||c.getAttribute("version")||this.defaultVersion;if(!this.parser||this.parser.version!==b){var d=OpenLayers.Format.WMSCapabilities["v"+b.replace(/\./g,"_")];if(!d){throw"Can't find a WMS capabilities parser for version "+b}var g=new d(this.options)}var a=g.read(f);a.version=b;return a},CLASS_NAME:"OpenLayers.Format.WMSCapabilities"});OpenLayers.Format.XML=OpenLayers.Class(OpenLayers.Format,{namespaces:null,namespaceAlias:null,defaultPrefix:null,readers:{},writers:{},xmldom:null,initialize:function(a){if(window.ActiveXObject){this.xmldom=new ActiveXObject("Microsoft.XMLDOM")}OpenLayers.Format.prototype.initialize.apply(this,[a]);this.namespaces=OpenLayers.Util.extend({},this.namespaces);this.namespaceAlias={};for(var b in this.namespaces){this.namespaceAlias[this.namespaces[b]]=b}},destroy:function(){this.xmldom=null;OpenLayers.Format.prototype.destroy.apply(this,arguments)},setNamespace:function(a,b){this.namespaces[a]=b;this.namespaceAlias[b]=a},read:function(c){var a=c.indexOf("<");if(a>0){c=c.substring(a)}var b=OpenLayers.Util.Try(OpenLayers.Function.bind((function(){var d;if(window.ActiveXObject&&!this.xmldom){d=new ActiveXObject("Microsoft.XMLDOM")}else{d=this.xmldom}d.loadXML(c);return d}),this),function(){return new DOMParser().parseFromString(c,"text/xml")},function(){var d=new XMLHttpRequest();d.open("GET","data:text/xml;charset=utf-8,"+encodeURIComponent(c),false);if(d.overrideMimeType){d.overrideMimeType("text/xml")}d.send(null);return d.responseXML});if(this.keepData){this.data=b}return b},write:function(b){var c;if(this.xmldom){c=b.xml}else{var a=new XMLSerializer();if(b.nodeType==1){var d=document.implementation.createDocument("","",null);if(d.importNode){b=d.importNode(b,true)}d.appendChild(b);c=a.serializeToString(d)}else{c=a.serializeToString(b)}}return c},createElementNS:function(c,a){var b;if(this.xmldom){if(typeof c=="string"){b=this.xmldom.createNode(1,a,c)}else{b=this.xmldom.createNode(1,a,"")}}else{b=document.createElementNS(c,a)}return b},createTextNode:function(b){var a;if(this.xmldom){a=this.xmldom.createTextNode(b)}else{a=document.createTextNode(b)}return a},getElementsByTagNameNS:function(f,d,c){var a=[];if(f.getElementsByTagNameNS){a=f.getElementsByTagNameNS(d,c)}else{var b=f.getElementsByTagName("*");var k,g;for(var h=0,j=b.length;h<j;++h){k=b[h];g=(k.prefix)?(k.prefix+":"+c):c;if((c=="*")||(g==k.nodeName)){if((d=="*")||(d==k.namespaceURI)){a.push(k)}}}}return a},getAttributeNodeNS:function(c,b,a){var k=null;if(c.getAttributeNodeNS){k=c.getAttributeNodeNS(b,a)}else{var f=c.attributes;var j,d;for(var g=0,h=f.length;g<h;++g){j=f[g];if(j.namespaceURI==b){d=(j.prefix)?(j.prefix+":"+a):a;if(d==j.nodeName){k=j;break}}}}return k},getAttributeNS:function(f,d,a){var b="";if(f.getAttributeNS){b=f.getAttributeNS(d,a)||""}else{var c=this.getAttributeNodeNS(f,d,a);if(c){b=c.nodeValue}}return b},getChildValue:function(a,c){var b=c||"";if(a){for(var d=a.firstChild;d;d=d.nextSibling){switch(d.nodeType){case 3:case 4:b+=d.nodeValue}}}return b},concatChildValues:function(b,d){var c="";var f=b.firstChild;var a;while(f){a=f.nodeValue;if(a){c+=a}f=f.nextSibling}if(c==""&&d!=undefined){c=d}return c},isSimpleContent:function(a){var c=true;for(var b=a.firstChild;b;b=b.nextSibling){if(b.nodeType===1){c=false;break}}return c},contentType:function(c){var f=false,b=false;var a=OpenLayers.Format.XML.CONTENT_TYPE.EMPTY;for(var d=c.firstChild;d;d=d.nextSibling){switch(d.nodeType){case 1:b=true;break;case 8:break;default:f=true}if(b&&f){break}}if(b&&f){a=OpenLayers.Format.XML.CONTENT_TYPE.MIXED}else{if(b){return OpenLayers.Format.XML.CONTENT_TYPE.COMPLEX}else{if(f){return OpenLayers.Format.XML.CONTENT_TYPE.SIMPLE}}}return a},hasAttributeNS:function(c,b,a){var d=false;if(c.hasAttributeNS){d=c.hasAttributeNS(b,a)}else{d=!!this.getAttributeNodeNS(c,b,a)}return d},setAttributeNS:function(d,c,a,f){if(d.setAttributeNS){d.setAttributeNS(c,a,f)}else{if(this.xmldom){if(c){var b=d.ownerDocument.createNode(2,a,c);b.nodeValue=f;d.setAttributeNode(b)}else{d.setAttribute(a,f)}}else{throw"setAttributeNS not implemented"}}},createElementNSPlus:function(b,a){a=a||{};var d=a.uri||this.namespaces[a.prefix];if(!d){var g=b.indexOf(":");d=this.namespaces[b.substring(0,g)]}if(!d){d=this.namespaces[this.defaultPrefix]}var c=this.createElementNS(d,b);if(a.attributes){this.setAttributes(c,a.attributes)}var f=a.value;if(f!=null){if(typeof f=="boolean"){f=String(f)}c.appendChild(this.createTextNode(f))}return c},setAttributes:function(c,f){var d,b;for(var a in f){if(f[a]!=null&&f[a].toString){d=f[a].toString();b=this.namespaces[a.substring(0,a.indexOf(":"))]||null;this.setAttributeNS(c,b,a,d)}}},readNode:function(c,f){if(!f){f={}}var d=this.readers[this.namespaceAlias[c.namespaceURI]];if(d){var b=c.localName||c.nodeName.split(":").pop();var a=d[b]||d["*"];if(a){a.apply(this,[c,f])}}return f},readChildNodes:function(d,f){if(!f){f={}}var c=d.childNodes;var g;for(var b=0,a=c.length;b<a;++b){g=c[b];if(g.nodeType==1){this.readNode(g,f)}}return f},writeNode:function(a,g,d){var f,c;var b=a.indexOf(":");if(b>0){f=a.substring(0,b);c=a.substring(b+1)}else{if(d){f=this.namespaceAlias[d.namespaceURI]}else{f=this.defaultPrefix}c=a}var h=this.writers[f][c].apply(this,[g]);if(d){d.appendChild(h)}return h},getChildEl:function(c,a,b){return c&&this.getThisOrNextEl(c.firstChild,a,b)},getNextEl:function(c,a,b){return c&&this.getThisOrNextEl(c.nextSibling,a,b)},getThisOrNextEl:function(d,a,c){outer:for(var b=d;b;b=b.nextSibling){switch(b.nodeType){case 1:if((!a||a===(b.localName||b.nodeName.split(":").pop()))&&(!c||c===b.namespaceURI)){break outer}b=null;break outer;case 3:if(/^\s*$/.test(b.nodeValue)){break}case 4:case 6:case 12:case 10:case 11:b=null;break outer}}return b||null},lookupNamespaceURI:function(f,g){var d=null;if(f){if(f.lookupNamespaceURI){d=f.lookupNamespaceURI(g)}else{outer:switch(f.nodeType){case 1:if(f.namespaceURI!==null&&f.prefix===g){d=f.namespaceURI;break outer}var b=f.attributes.length;if(b){var a;for(var c=0;c<b;++c){a=f.attributes[c];if(a.prefix==="xmlns"&&a.name==="xmlns:"+g){d=a.value||null;break outer}else{if(a.name==="xmlns"&&g===null){d=a.value||null;break outer}}}}d=this.lookupNamespaceURI(f.parentNode,g);break outer;case 2:d=this.lookupNamespaceURI(f.ownerElement,g);break outer;case 9:d=this.lookupNamespaceURI(f.documentElement,g);break outer;case 6:case 12:case 10:case 11:break outer;default:d=this.lookupNamespaceURI(f.parentNode,g);break outer}}}return d},CLASS_NAME:"OpenLayers.Format.XML"});OpenLayers.Format.XML.CONTENT_TYPE={EMPTY:0,SIMPLE:1,COMPLEX:2,MIXED:3};OpenLayers.Format.XML.lookupNamespaceURI=OpenLayers.Function.bind(OpenLayers.Format.XML.prototype.lookupNamespaceURI,OpenLayers.Format.XML.prototype);OpenLayers.Handler=OpenLayers.Class({id:null,control:null,map:null,keyMask:null,active:false,evt:null,initialize:function(c,b,a){OpenLayers.Util.extend(this,a);this.control=c;this.callbacks=b;if(c.map){this.setMap(c.map)}OpenLayers.Util.extend(this,a);this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_")},setMap:function(a){this.map=a},checkModifiers:function(a){if(this.keyMask==null){return true}var b=(a.shiftKey?OpenLayers.Handler.MOD_SHIFT:0)|(a.ctrlKey?OpenLayers.Handler.MOD_CTRL:0)|(a.altKey?OpenLayers.Handler.MOD_ALT:0);return(b==this.keyMask)},activate:function(){if(this.active){return false}var c=OpenLayers.Events.prototype.BROWSER_EVENTS;for(var b=0,a=c.length;b<a;b++){if(this[c[b]]){this.register(c[b],this[c[b]])}}this.active=true;return true},deactivate:function(){if(!this.active){return false}var c=OpenLayers.Events.prototype.BROWSER_EVENTS;for(var b=0,a=c.length;b<a;b++){if(this[c[b]]){this.unregister(c[b],this[c[b]])}}this.active=false;return true},callback:function(b,a){if(b&&this.callbacks[b]){this.callbacks[b].apply(this.control,a)}},register:function(a,b){this.map.events.registerPriority(a,this,b);this.map.events.registerPriority(a,this,this.setEvent)},unregister:function(a,b){this.map.events.unregister(a,this,b);this.map.events.unregister(a,this,this.setEvent)},setEvent:function(a){this.evt=a;return true},destroy:function(){this.deactivate();this.control=this.map=null},CLASS_NAME:"OpenLayers.Handler"});OpenLayers.Handler.MOD_NONE=0;OpenLayers.Handler.MOD_SHIFT=1;OpenLayers.Handler.MOD_CTRL=2;OpenLayers.Handler.MOD_ALT=4;OpenLayers.Map=OpenLayers.Class({Z_INDEX_BASE:{BaseLayer:100,Overlay:325,Feature:725,Popup:750,Control:1000},EVENT_TYPES:["preaddlayer","addlayer","removelayer","changelayer","movestart","move","moveend","zoomend","popupopen","popupclose","addmarker","removemarker","clearmarkers","mouseover","mouseout","mousemove","dragstart","drag","dragend","changebaselayer"],id:null,fractionalZoom:false,events:null,allOverlays:false,div:null,dragging:false,size:null,viewPortDiv:null,layerContainerOrigin:null,layerContainerDiv:null,layers:null,controls:null,popups:null,baseLayer:null,center:null,resolution:null,zoom:0,panRatio:1.5,viewRequestID:0,tileSize:null,projection:"EPSG:4326",units:"degrees",resolutions:null,maxResolution:1.40625,minResolution:null,maxScale:null,minScale:null,maxExtent:null,minExtent:null,restrictedExtent:null,numZoomLevels:16,theme:null,displayProjection:null,fallThrough:true,panTween:null,eventListeners:null,panMethod:OpenLayers.Easing.Expo.easeOut,panDuration:50,paddingForPopups:null,initialize:function(j,d){if(arguments.length===1&&typeof j==="object"){d=j;j=d&&d.div}this.tileSize=new OpenLayers.Size(OpenLayers.Map.TILE_WIDTH,OpenLayers.Map.TILE_HEIGHT);this.maxExtent=new OpenLayers.Bounds(-180,-90,180,90);this.paddingForPopups=new OpenLayers.Bounds(15,15,15,15);this.theme=OpenLayers._getScriptLocation()+"theme/default/style.css";OpenLayers.Util.extend(this,d);this.id=OpenLayers.Util.createUniqueID("OpenLayers.Map_");this.div=OpenLayers.Util.getElement(j);if(!this.div){this.div=document.createElement("div");this.div.style.height="1px";this.div.style.width="1px"}OpenLayers.Element.addClass(this.div,"olMap");var h=this.div.id+"_OpenLayers_ViewPort";this.viewPortDiv=OpenLayers.Util.createDiv(h,null,null,null,"relative",null,"hidden");this.viewPortDiv.style.width="100%";this.viewPortDiv.style.height="100%";this.viewPortDiv.className="olMapViewport";this.div.appendChild(this.viewPortDiv);h=this.div.id+"_OpenLayers_Container";this.layerContainerDiv=OpenLayers.Util.createDiv(h);this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE.Popup-1;this.viewPortDiv.appendChild(this.layerContainerDiv);this.events=new OpenLayers.Events(this,this.div,this.EVENT_TYPES,this.fallThrough,{includeXY:true});this.updateSize();if(this.eventListeners instanceof Object){this.events.on(this.eventListeners)}this.events.register("movestart",this,this.updateSize);if(OpenLayers.String.contains(navigator.appName,"Microsoft")){this.events.register("resize",this,this.updateSize)}else{this.updateSizeDestroy=OpenLayers.Function.bind(this.updateSize,this);OpenLayers.Event.observe(window,"resize",this.updateSizeDestroy)}if(this.theme){var g=true;var c=document.getElementsByTagName("link");for(var f=0,a=c.length;f<a;++f){if(OpenLayers.Util.isEquivalentUrl(c.item(f).href,this.theme)){g=false;break}}if(g){var b=document.createElement("link");b.setAttribute("rel","stylesheet");b.setAttribute("type","text/css");b.setAttribute("href",this.theme);document.getElementsByTagName("head")[0].appendChild(b)}}this.layers=[];if(this.controls==null){if(OpenLayers.Control!=null){this.controls=[new OpenLayers.Control.Navigation(),new OpenLayers.Control.PanZoom(),new OpenLayers.Control.ArgParser(),new OpenLayers.Control.Attribution()]}else{this.controls=[]}}for(var f=0,a=this.controls.length;f<a;f++){this.addControlToMap(this.controls[f])}this.popups=[];this.unloadDestroy=OpenLayers.Function.bind(this.destroy,this);OpenLayers.Event.observe(window,"unload",this.unloadDestroy)},render:function(a){this.div=OpenLayers.Util.getElement(a);OpenLayers.Element.addClass(this.div,"olMap");this.events.attachToElement(this.div);this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);this.div.appendChild(this.viewPortDiv);this.updateSize()},unloadDestroy:null,updateSizeDestroy:null,destroy:function(){if(!this.unloadDestroy){return false}OpenLayers.Event.stopObserving(window,"unload",this.unloadDestroy);this.unloadDestroy=null;if(this.updateSizeDestroy){OpenLayers.Event.stopObserving(window,"resize",this.updateSizeDestroy)}else{this.events.unregister("resize",this,this.updateSize)}this.paddingForPopups=null;if(this.controls!=null){for(var a=this.controls.length-1;a>=0;--a){this.controls[a].destroy()}this.controls=null}if(this.layers!=null){for(var a=this.layers.length-1;a>=0;--a){this.layers[a].destroy(false)}this.layers=null}if(this.viewPortDiv){this.div.removeChild(this.viewPortDiv)}this.viewPortDiv=null;if(this.eventListeners){this.events.un(this.eventListeners);this.eventListeners=null}this.events.destroy();this.events=null},setOptions:function(a){OpenLayers.Util.extend(this,a)},getTileSize:function(){return this.tileSize},getBy:function(f,c,a){var d=(typeof a.test=="function");var b=OpenLayers.Array.filter(this[f],function(g){return g[c]==a||(d&&a.test(g[c]))});return b},getLayersBy:function(b,a){return this.getBy("layers",b,a)},getLayersByName:function(a){return this.getLayersBy("name",a)},getLayersByClass:function(a){return this.getLayersBy("CLASS_NAME",a)},getControlsBy:function(b,a){return this.getBy("controls",b,a)},getControlsByClass:function(a){return this.getControlsBy("CLASS_NAME",a)},getLayer:function(f){var b=null;for(var d=0,a=this.layers.length;d<a;d++){var c=this.layers[d];if(c.id==f){b=c;break}}return b},setLayerZIndex:function(b,a){b.setZIndex(this.Z_INDEX_BASE[b.isBaseLayer?"BaseLayer":"Overlay"]+a*5)},resetLayersZIndex:function(){for(var c=0,a=this.layers.length;c<a;c++){var b=this.layers[c];this.setLayerZIndex(b,c)}},addLayer:function(c){for(var b=0,a=this.layers.length;b<a;b++){if(this.layers[b]==c){var d=OpenLayers.i18n("layerAlreadyAdded",{layerName:c.name});OpenLayers.Console.warn(d);return false}}if(this.allOverlays){c.isBaseLayer=false}this.events.triggerEvent("preaddlayer",{layer:c});c.div.className="olLayerDiv";c.div.style.overflow="";this.setLayerZIndex(c,this.layers.length);if(c.isFixed){this.viewPortDiv.appendChild(c.div)}else{this.layerContainerDiv.appendChild(c.div)}this.layers.push(c);c.setMap(this);if(c.isBaseLayer||(this.allOverlays&&!this.baseLayer)){if(this.baseLayer==null){this.setBaseLayer(c)}else{c.setVisibility(false)}}else{c.redraw()}this.events.triggerEvent("addlayer",{layer:c});c.afterAdd()},addLayers:function(c){for(var b=0,a=c.length;b<a;b++){this.addLayer(c[b])}},removeLayer:function(c,f){if(f==null){f=true}if(c.isFixed){this.viewPortDiv.removeChild(c.div)}else{this.layerContainerDiv.removeChild(c.div)}OpenLayers.Util.removeItem(this.layers,c);c.removeMap(this);c.map=null;if(this.baseLayer==c){this.baseLayer=null;if(f){for(var b=0,a=this.layers.length;b<a;b++){var d=this.layers[b];if(d.isBaseLayer||this.allOverlays){this.setBaseLayer(d);break}}}}this.resetLayersZIndex();this.events.triggerEvent("removelayer",{layer:c})},getNumLayers:function(){return this.layers.length},getLayerIndex:function(a){return OpenLayers.Util.indexOf(this.layers,a)},setLayerIndex:function(d,b){var f=this.getLayerIndex(d);if(b<0){b=0}else{if(b>this.layers.length){b=this.layers.length}}if(f!=b){this.layers.splice(f,1);this.layers.splice(b,0,d);for(var c=0,a=this.layers.length;c<a;c++){this.setLayerZIndex(this.layers[c],c)}this.events.triggerEvent("changelayer",{layer:d,property:"order"});if(this.allOverlays){if(b===0){this.setBaseLayer(d)}else{if(this.baseLayer!==this.layers[0]){this.setBaseLayer(this.layers[0])}}}}},raiseLayer:function(b,c){var a=this.getLayerIndex(b)+c;this.setLayerIndex(b,a)},setBaseLayer:function(f){var d=null;if(this.baseLayer){d=this.baseLayer.getExtent()}if(f!=this.baseLayer){if(OpenLayers.Util.indexOf(this.layers,f)!=-1){if(this.baseLayer!=null&&!this.allOverlays){this.baseLayer.setVisibility(false)}this.baseLayer=f;this.viewRequestID++;if(!this.allOverlays){this.baseLayer.visibility=true}var a=this.getCenter();if(a!=null){var b=(d)?d.getCenterLonLat():a;var c=(d)?this.getZoomForExtent(d,true):this.getZoomForResolution(this.resolution,true);this.setCenter(b,c,false,true)}this.events.triggerEvent("changebaselayer",{layer:this.baseLayer})}}},addControl:function(b,a){this.controls.push(b);this.addControlToMap(b,a)},addControlToMap:function(b,a){b.outsideViewport=(b.div!=null);if(this.displayProjection&&!b.displayProjection){b.displayProjection=this.displayProjection}b.setMap(this);var c=b.draw(a);if(c){if(!b.outsideViewport){c.style.zIndex=this.Z_INDEX_BASE.Control+this.controls.length;this.viewPortDiv.appendChild(c)}}},getControl:function(f){var b=null;for(var c=0,a=this.controls.length;c<a;c++){var d=this.controls[c];if(d.id==f){b=d;break}}return b},removeControl:function(a){if((a)&&(a==this.getControl(a.id))){if(a.div&&(a.div.parentNode==this.viewPortDiv)){this.viewPortDiv.removeChild(a.div)}OpenLayers.Util.removeItem(this.controls,a)}},addPopup:function(a,d){if(d){for(var b=this.popups.length-1;b>=0;--b){this.removePopup(this.popups[b])}}a.map=this;this.popups.push(a);var c=a.draw();if(c){c.style.zIndex=this.Z_INDEX_BASE.Popup+this.popups.length;this.layerContainerDiv.appendChild(c)}},removePopup:function(a){OpenLayers.Util.removeItem(this.popups,a);if(a.div){try{this.layerContainerDiv.removeChild(a.div)}catch(b){}}a.map=null},getSize:function(){var a=null;if(this.size!=null){a=this.size.clone()}return a},updateSize:function(){this.events.clearMouseCache();var c=this.getCurrentSize();var g=this.getSize();if(g==null){this.size=g=c}if(!c.equals(g)){this.size=c;for(var d=0,b=this.layers.length;d<b;d++){this.layers[d].onMapResize()}if(this.baseLayer!=null){var a=new OpenLayers.Pixel(c.w/2,c.h/2);var h=this.getLonLatFromViewPortPx(a);var f=this.getZoom();this.zoom=null;this.setCenter(this.getCenter(),f)}}},getCurrentSize:function(){var a=new OpenLayers.Size(this.div.clientWidth,this.div.clientHeight);if(a.w==0&&a.h==0||isNaN(a.w)&&isNaN(a.h)){var b=OpenLayers.Element.getDimensions(this.div);a.w=b.width;a.h=b.height}if(a.w==0&&a.h==0||isNaN(a.w)&&isNaN(a.h)){a.w=parseInt(this.div.style.width);a.h=parseInt(this.div.style.height)}return a},calculateBounds:function(a,b){var f=null;if(a==null){a=this.getCenter()}if(b==null){b=this.getResolution()}if((a!=null)&&(b!=null)){var d=this.getSize();var g=d.w*b;var c=d.h*b;f=new OpenLayers.Bounds(a.lon-g/2,a.lat-c/2,a.lon+g/2,a.lat+c/2)}return f},getCenter:function(){var a=null;if(this.center){a=this.center.clone()}return a},getZoom:function(){return this.zoom},pan:function(d,c,f){f=OpenLayers.Util.applyDefaults(f,{animate:true,dragging:false});var g=this.getViewPortPxFromLonLat(this.getCenter());var b=g.add(d,c);if(!f.dragging||!b.equals(g)){var a=this.getLonLatFromViewPortPx(b);if(f.animate){this.panTo(a)}else{this.setCenter(a,null,f.dragging)}}},panTo:function(b){if(this.panMethod&&this.getExtent().scale(this.panRatio).containsLonLat(b)){if(!this.panTween){this.panTween=new OpenLayers.Tween(this.panMethod)}var a=this.getCenter();if(b.lon==a.lon&&b.lat==a.lat){return}var d={lon:a.lon,lat:a.lat};var c={lon:b.lon,lat:b.lat};this.panTween.start(d,c,this.panDuration,{callbacks:{start:OpenLayers.Function.bind(function(f){this.events.triggerEvent("movestart")},this),eachStep:OpenLayers.Function.bind(function(f){f=new OpenLayers.LonLat(f.lon,f.lat);this.moveTo(f,this.zoom,{dragging:true,noEvent:true})},this),done:OpenLayers.Function.bind(function(f){f=new OpenLayers.LonLat(f.lon,f.lat);this.moveTo(f,this.zoom,{noEvent:true});this.events.triggerEvent("moveend")},this)}})}else{this.setCenter(b)}},setCenter:function(c,a,b,d){this.moveTo(c,a,{dragging:b,forceZoomChange:d,caller:"setCenter"})},moveTo:function(h,q,t){if(!t){t={}}var o=t.dragging;var c=t.forceZoomChange;var j=t.noEvent;if(this.panTween&&t.caller=="setCenter"){this.panTween.stop()}if(!this.center&&!this.isValidLonLat(h)){h=this.maxExtent.getCenterLonLat()}if(this.restrictedExtent!=null){if(h==null){h=this.getCenter()}if(q==null){q=this.getZoom()}var d=this.getResolutionForZoom(q);var r=this.calculateBounds(h,d);if(!this.restrictedExtent.containsBounds(r)){var s=this.restrictedExtent.getCenterLonLat();if(r.getWidth()>this.restrictedExtent.getWidth()){h=new OpenLayers.LonLat(s.lon,h.lat)}else{if(r.left<this.restrictedExtent.left){h=h.add(this.restrictedExtent.left-r.left,0)}else{if(r.right>this.restrictedExtent.right){h=h.add(this.restrictedExtent.right-r.right,0)}}}if(r.getHeight()>this.restrictedExtent.getHeight()){h=new OpenLayers.LonLat(h.lon,s.lat)}else{if(r.bottom<this.restrictedExtent.bottom){h=h.add(0,this.restrictedExtent.bottom-r.bottom)}else{if(r.top>this.restrictedExtent.top){h=h.add(0,this.restrictedExtent.top-r.top)}}}}}var b=c||((this.isValidZoomLevel(q))&&(q!=this.getZoom()));var f=(this.isValidLonLat(h))&&(!h.equals(this.center));if(b||f||!o){if(!this.dragging&&!j){this.events.triggerEvent("movestart")}if(f){if((!b)&&(this.center)){this.centerLayerContainer(h)}this.center=h.clone()}if((b)||(this.layerContainerOrigin==null)){this.layerContainerOrigin=this.center.clone();this.layerContainerDiv.style.left="0px";this.layerContainerDiv.style.top="0px"}if(b){this.zoom=q;this.resolution=this.getResolutionForZoom(q);this.viewRequestID++}var a=this.getExtent();if(this.baseLayer.visibility){this.baseLayer.moveTo(a,b,o);if(o){this.baseLayer.events.triggerEvent("move")}else{this.baseLayer.events.triggerEvent("moveend",{zoomChanged:b})}}a=this.baseLayer.getExtent();for(var g=0,l=this.layers.length;g<l;g++){var k=this.layers[g];if(k!==this.baseLayer&&!k.isBaseLayer){var m=k.calculateInRange();if(k.inRange!=m){k.inRange=m;if(!m){k.display(false)}this.events.triggerEvent("changelayer",{layer:k,property:"visibility"})}if(m&&k.visibility){k.moveTo(a,b,o);if(o){k.events.triggerEvent("move")}else{k.events.triggerEvent("moveend",{zoomChanged:b})}}}}if(b){for(var g=0,l=this.popups.length;g<l;g++){this.popups[g].updatePosition()}}this.events.triggerEvent("move");if(b){this.events.triggerEvent("zoomend")}}if(!o&&!j){this.events.triggerEvent("moveend")}this.dragging=!!o},centerLayerContainer:function(b){var a=this.getViewPortPxFromLonLat(this.layerContainerOrigin);var c=this.getViewPortPxFromLonLat(b);if((a!=null)&&(c!=null)){this.layerContainerDiv.style.left=Math.round(a.x-c.x)+"px";this.layerContainerDiv.style.top=Math.round(a.y-c.y)+"px"}},isValidZoomLevel:function(a){return((a!=null)&&(a>=0)&&(a<this.getNumZoomLevels()))},isValidLonLat:function(c){var b=false;if(c!=null){var a=this.getMaxExtent();b=a.containsLonLat(c)}return b},getProjection:function(){var a=this.getProjectionObject();return a?a.getCode():null},getProjectionObject:function(){var a=null;if(this.baseLayer!=null){a=this.baseLayer.projection}return a},getMaxResolution:function(){var a=null;if(this.baseLayer!=null){a=this.baseLayer.maxResolution}return a},getMaxExtent:function(b){var a=null;if(b&&b.restricted&&this.restrictedExtent){a=this.restrictedExtent}else{if(this.baseLayer!=null){a=this.baseLayer.maxExtent}}return a},getNumZoomLevels:function(){var a=null;if(this.baseLayer!=null){a=this.baseLayer.numZoomLevels}return a},getExtent:function(){var a=null;if(this.baseLayer!=null){a=this.baseLayer.getExtent()}return a},getResolution:function(){var a=null;if(this.baseLayer!=null){a=this.baseLayer.getResolution()}return a},getUnits:function(){var a=null;if(this.baseLayer!=null){a=this.baseLayer.units}return a},getScale:function(){var c=null;if(this.baseLayer!=null){var b=this.getResolution();var a=this.baseLayer.units;c=OpenLayers.Util.getScaleFromResolution(b,a)}return c},getZoomForExtent:function(c,b){var a=null;if(this.baseLayer!=null){a=this.baseLayer.getZoomForExtent(c,b)}return a},getResolutionForZoom:function(b){var a=null;if(this.baseLayer){a=this.baseLayer.getResolutionForZoom(b)}return a},getZoomForResolution:function(a,c){var b=null;if(this.baseLayer!=null){b=this.baseLayer.getZoomForResolution(a,c)}return b},zoomTo:function(a){if(this.isValidZoomLevel(a)){this.setCenter(null,a)}},zoomIn:function(){this.zoomTo(this.getZoom()+1)},zoomOut:function(){this.zoomTo(this.getZoom()-1)},zoomToExtent:function(d,c){var b=d.getCenterLonLat();if(this.baseLayer.wrapDateLine){var a=this.getMaxExtent();d=d.clone();while(d.right<d.left){d.right+=a.getWidth()}b=d.getCenterLonLat().wrapDateLine(a)}this.setCenter(b,this.getZoomForExtent(d,c))},zoomToMaxExtent:function(c){var b=(c)?c.restricted:true;var a=this.getMaxExtent({restricted:b});this.zoomToExtent(a)},zoomToScale:function(j,h){var d=OpenLayers.Util.getResolutionFromScale(j,this.baseLayer.units);var c=this.getSize();var g=c.w*d;var b=c.h*d;var a=this.getCenter();var f=new OpenLayers.Bounds(a.lon-g/2,a.lat-b/2,a.lon+g/2,a.lat+b/2);this.zoomToExtent(f,h)},getLonLatFromViewPortPx:function(a){var b=null;if(this.baseLayer!=null){b=this.baseLayer.getLonLatFromViewPortPx(a)}return b},getViewPortPxFromLonLat:function(b){var a=null;if(this.baseLayer!=null){a=this.baseLayer.getViewPortPxFromLonLat(b)}return a},getLonLatFromPixel:function(a){return this.getLonLatFromViewPortPx(a)},getPixelFromLonLat:function(b){var a=this.getViewPortPxFromLonLat(b);a.x=Math.round(a.x);a.y=Math.round(a.y);return a},getViewPortPxFromLayerPx:function(d){var c=null;if(d!=null){var b=parseInt(this.layerContainerDiv.style.left);var a=parseInt(this.layerContainerDiv.style.top);c=d.add(b,a)}return c},getLayerPxFromViewPortPx:function(c){var d=null;if(c!=null){var b=-parseInt(this.layerContainerDiv.style.left);var a=-parseInt(this.layerContainerDiv.style.top);d=c.add(b,a);if(isNaN(d.x)||isNaN(d.y)){d=null}}return d},getLonLatFromLayerPx:function(a){a=this.getViewPortPxFromLayerPx(a);return this.getLonLatFromViewPortPx(a)},getLayerPxFromLonLat:function(b){var a=this.getPixelFromLonLat(b);return this.getLayerPxFromViewPortPx(a)},CLASS_NAME:"OpenLayers.Map"});OpenLayers.Map.TILE_WIDTH=256;OpenLayers.Map.TILE_HEIGHT=256;OpenLayers.Marker=OpenLayers.Class({icon:null,lonlat:null,events:null,map:null,initialize:function(c,b){this.lonlat=c;var a=(b)?b:OpenLayers.Marker.defaultIcon();if(this.icon==null){this.icon=a}else{this.icon.url=a.url;this.icon.size=a.size;this.icon.offset=a.offset;this.icon.calculateOffset=a.calculateOffset}this.events=new OpenLayers.Events(this,this.icon.imageDiv,null)},destroy:function(){this.erase();this.map=null;this.events.destroy();this.events=null;if(this.icon!=null){this.icon.destroy();this.icon=null}},draw:function(a){return this.icon.draw(a)},erase:function(){if(this.icon!=null){this.icon.erase()}},moveTo:function(a){if((a!=null)&&(this.icon!=null)){this.icon.moveTo(a)}this.lonlat=this.map.getLonLatFromLayerPx(a)},isDrawn:function(){var a=(this.icon&&this.icon.isDrawn());return a},onScreen:function(){var b=false;if(this.map){var a=this.map.getExtent();b=a.containsLonLat(this.lonlat)}return b},inflate:function(b){if(this.icon){var a=new OpenLayers.Size(this.icon.size.w*b,this.icon.size.h*b);this.icon.setSize(a)}},setOpacity:function(a){this.icon.setOpacity(a)},setUrl:function(a){this.icon.setUrl(a)},display:function(a){this.icon.display(a)},CLASS_NAME:"OpenLayers.Marker"});OpenLayers.Marker.defaultIcon=function(){var a=OpenLayers.Util.getImagesLocation()+"marker.png";var b=new OpenLayers.Size(21,25);var c=function(d){return new OpenLayers.Pixel(-(d.w/2),-d.h)};return new OpenLayers.Icon(a,b,null,c)};OpenLayers.Popup.FramedCloud=OpenLayers.Class(OpenLayers.Popup.Framed,{contentDisplayClass:"olFramedCloudPopupContent",autoSize:true,panMapIfOutOfView:true,imageSize:new OpenLayers.Size(676,736),isAlphaImage:false,fixedRelativePosition:false,positionBlocks:{tl:{offset:new OpenLayers.Pixel(44,0),padding:new OpenLayers.Bounds(8,40,8,9),blocks:[{size:new OpenLayers.Size("auto","auto"),anchor:new OpenLayers.Bounds(0,51,22,0),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,"auto"),anchor:new OpenLayers.Bounds(null,50,0,0),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size("auto",19),anchor:new OpenLayers.Bounds(0,32,22,null),position:new OpenLayers.Pixel(0,-631)},{size:new OpenLayers.Size(22,18),anchor:new OpenLayers.Bounds(null,32,0,null),position:new OpenLayers.Pixel(-638,-632)},{size:new OpenLayers.Size(81,35),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(0,-688)}]},tr:{offset:new OpenLayers.Pixel(-45,0),padding:new OpenLayers.Bounds(8,40,8,9),blocks:[{size:new OpenLayers.Size("auto","auto"),anchor:new OpenLayers.Bounds(0,51,22,0),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,"auto"),anchor:new OpenLayers.Bounds(null,50,0,0),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size("auto",19),anchor:new OpenLayers.Bounds(0,32,22,null),position:new OpenLayers.Pixel(0,-631)},{size:new OpenLayers.Size(22,19),anchor:new OpenLayers.Bounds(null,32,0,null),position:new OpenLayers.Pixel(-638,-631)},{size:new OpenLayers.Size(81,35),anchor:new OpenLayers.Bounds(0,0,null,null),position:new OpenLayers.Pixel(-215,-687)}]},bl:{offset:new OpenLayers.Pixel(45,0),padding:new OpenLayers.Bounds(8,9,8,40),blocks:[{size:new OpenLayers.Size("auto","auto"),anchor:new OpenLayers.Bounds(0,21,22,32),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,"auto"),anchor:new OpenLayers.Bounds(null,21,0,32),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size("auto",21),anchor:new OpenLayers.Bounds(0,0,22,null),position:new OpenLayers.Pixel(0,-629)},{size:new OpenLayers.Size(22,21),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(-638,-629)},{size:new OpenLayers.Size(81,33),anchor:new OpenLayers.Bounds(null,null,0,0),position:new OpenLayers.Pixel(-101,-674)}]},br:{offset:new OpenLayers.Pixel(-44,0),padding:new OpenLayers.Bounds(8,9,8,40),blocks:[{size:new OpenLayers.Size("auto","auto"),anchor:new OpenLayers.Bounds(0,21,22,32),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,"auto"),anchor:new OpenLayers.Bounds(null,21,0,32),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size("auto",21),anchor:new OpenLayers.Bounds(0,0,22,null),position:new OpenLayers.Pixel(0,-629)},{size:new OpenLayers.Size(22,21),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(-638,-629)},{size:new OpenLayers.Size(81,33),anchor:new OpenLayers.Bounds(0,null,null,0),position:new OpenLayers.Pixel(-311,-674)}]}},minSize:new OpenLayers.Size(105,10),maxSize:new OpenLayers.Size(600,660),initialize:function(h,c,g,b,a,f,d){this.imageSrc=OpenLayers.Util.getImagesLocation()+"cloud-popup-relative.png";OpenLayers.Popup.Framed.prototype.initialize.apply(this,arguments);this.contentDiv.className=this.contentDisplayClass},destroy:function(){OpenLayers.Popup.Framed.prototype.destroy.apply(this,arguments)},CLASS_NAME:"OpenLayers.Popup.FramedCloud"});OpenLayers.Request={DEFAULT_CONFIG:{method:"GET",url:window.location.href,async:true,user:undefined,password:undefined,params:null,proxy:OpenLayers.ProxyHost,headers:{},data:null,callback:function(){},success:null,failure:null,scope:null},events:new OpenLayers.Events(this,null,["complete","success","failure"]),issue:function(d){var h=OpenLayers.Util.extend(this.DEFAULT_CONFIG,{proxy:OpenLayers.ProxyHost});d=OpenLayers.Util.applyDefaults(d,h);var g=new OpenLayers.Request.XMLHttpRequest();var a=d.url;if(d.params){var f=OpenLayers.Util.getParameterString(d.params);if(f.length>0){var k=(a.indexOf("?")>-1)?"&":"?";a+=k+f}}if(d.proxy&&(a.indexOf("http")==0)){a=d.proxy+encodeURIComponent(a)}g.open(d.method,a,d.async,d.user,d.password);for(var j in d.headers){g.setRequestHeader(j,d.headers[j])}var b=(d.scope)?OpenLayers.Function.bind(d.callback,d.scope):d.callback;var l;if(d.success){l=(d.scope)?OpenLayers.Function.bind(d.success,d.scope):d.success}var c;if(d.failure){c=(d.scope)?OpenLayers.Function.bind(d.failure,d.scope):d.failure}var m=this.events;g.onreadystatechange=function(){if(g.readyState==OpenLayers.Request.XMLHttpRequest.DONE){var o=m.triggerEvent("complete",{request:g,config:d,requestUrl:a});if(o!==false){b(g);if(!g.status||(g.status>=200&&g.status<300)){m.triggerEvent("success",{request:g,config:d,requestUrl:a});if(l){l(g)}}if(g.status&&(g.status<200||g.status>=300)){m.triggerEvent("failure",{request:g,config:d,requestUrl:a});if(c){c(g)}}}}};if(d.async===false){g.send(d.data)}else{window.setTimeout(function(){g.send(d.data)},0)}return g},GET:function(a){a=OpenLayers.Util.extend(a,{method:"GET"});return OpenLayers.Request.issue(a)},POST:function(a){a=OpenLayers.Util.extend(a,{method:"POST"});a.headers=a.headers?a.headers:{};if(!("CONTENT-TYPE" in OpenLayers.Util.upperCaseObject(a.headers))){a.headers["Content-Type"]="application/xml"}return OpenLayers.Request.issue(a)},PUT:function(a){a=OpenLayers.Util.extend(a,{method:"PUT"});a.headers=a.headers?a.headers:{};if(!("CONTENT-TYPE" in OpenLayers.Util.upperCaseObject(a.headers))){a.headers["Content-Type"]="application/xml"}return OpenLayers.Request.issue(a)},DELETE:function(a){a=OpenLayers.Util.extend(a,{method:"DELETE"});return OpenLayers.Request.issue(a)},HEAD:function(a){a=OpenLayers.Util.extend(a,{method:"HEAD"});return OpenLayers.Request.issue(a)},OPTIONS:function(a){a=OpenLayers.Util.extend(a,{method:"OPTIONS"});return OpenLayers.Request.issue(a)}};OpenLayers.Tile.Image=OpenLayers.Class(OpenLayers.Tile,{url:null,imgDiv:null,frame:null,layerAlphaHack:null,isBackBuffer:false,lastRatio:1,isFirstDraw:true,backBufferTile:null,initialize:function(d,a,f,b,c){OpenLayers.Tile.prototype.initialize.apply(this,arguments);this.url=b;this.frame=document.createElement("div");this.frame.style.overflow="hidden";this.frame.style.position="absolute";this.layerAlphaHack=this.layer.alpha&&OpenLayers.Util.alphaHack()},destroy:function(){if(this.imgDiv!=null){if(this.layerAlphaHack){OpenLayers.Event.stopObservingElement(this.imgDiv.childNodes[0].id)}OpenLayers.Event.stopObservingElement(this.imgDiv.id);if(this.imgDiv.parentNode==this.frame){this.frame.removeChild(this.imgDiv);this.imgDiv.map=null}this.imgDiv.urls=null;this.imgDiv.src=OpenLayers.Util.getImagesLocation()+"blank.gif"}this.imgDiv=null;if((this.frame!=null)&&(this.frame.parentNode==this.layer.div)){this.layer.div.removeChild(this.frame)}this.frame=null;if(this.backBufferTile){this.backBufferTile.destroy();this.backBufferTile=null}this.layer.events.unregister("loadend",this,this.resetBackBuffer);OpenLayers.Tile.prototype.destroy.apply(this,arguments)},clone:function(a){if(a==null){a=new OpenLayers.Tile.Image(this.layer,this.position,this.bounds,this.url,this.size)}a=OpenLayers.Tile.prototype.clone.apply(this,[a]);a.imgDiv=null;return a},draw:function(){if(this.layer!=this.layer.map.baseLayer&&this.layer.reproject){this.bounds=this.getBoundsFromBaseLayer(this.position)}var a=OpenLayers.Tile.prototype.draw.apply(this,arguments);if(OpenLayers.Util.indexOf(this.layer.SUPPORTED_TRANSITIONS,this.layer.transitionEffect)!=-1){if(a){if(!this.backBufferTile){this.backBufferTile=this.clone();this.backBufferTile.hide();this.backBufferTile.isBackBuffer=true;this.events.register("loadend",this,this.resetBackBuffer);this.layer.events.register("loadend",this,this.resetBackBuffer)}this.startTransition()}else{if(this.backBufferTile){this.backBufferTile.clear()}}}else{if(a&&this.isFirstDraw){this.events.register("loadend",this,this.showTile);this.isFirstDraw=false}}if(!a){return false}if(this.isLoading){this.events.triggerEvent("reload")}else{this.isLoading=true;this.events.triggerEvent("loadstart")}return this.renderTile()},resetBackBuffer:function(){this.showTile();if(this.backBufferTile&&(this.isFirstDraw||!this.layer.numLoadingTiles)){this.isFirstDraw=false;var a=this.layer.maxExtent;var b=(a&&this.bounds.intersectsBounds(a,false));if(b){this.backBufferTile.position=this.position;this.backBufferTile.bounds=this.bounds;this.backBufferTile.size=this.size;this.backBufferTile.imageSize=this.layer.imageSize||this.size;this.backBufferTile.imageOffset=this.layer.imageOffset;this.backBufferTile.resolution=this.layer.getResolution();this.backBufferTile.renderTile()}this.backBufferTile.hide()}},renderTile:function(){if(this.imgDiv==null){this.initImgDiv()}this.imgDiv.viewRequestID=this.layer.map.viewRequestID;if(this.layer.async){this.layer.getURLasync(this.bounds,this,"url",this.positionImage)}else{if(this.layer.url instanceof Array){this.imgDiv.urls=this.layer.url.slice()}this.url=this.layer.getURL(this.bounds);this.positionImage()}return true},positionImage:function(){if(this.layer==null){return}OpenLayers.Util.modifyDOMElement(this.frame,null,this.position,this.size);var a=this.layer.getImageSize();if(this.layerAlphaHack){OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,null,null,a,this.url)}else{OpenLayers.Util.modifyDOMElement(this.imgDiv,null,null,a);this.imgDiv.src=this.url}},clear:function(){if(this.imgDiv){this.hide();if(OpenLayers.Tile.Image.useBlankTile){this.imgDiv.src=OpenLayers.Util.getImagesLocation()+"blank.gif"}}},initImgDiv:function(){var d=this.layer.imageOffset;var b=this.layer.getImageSize();if(this.layerAlphaHack){this.imgDiv=OpenLayers.Util.createAlphaImageDiv(null,d,b,null,"relative",null,null,null,true)}else{this.imgDiv=OpenLayers.Util.createImage(null,d,b,null,"relative",null,null,true)}this.imgDiv.className="olTileImage";this.frame.style.zIndex=this.isBackBuffer?0:1;this.frame.appendChild(this.imgDiv);this.layer.div.appendChild(this.frame);if(this.layer.opacity!=null){OpenLayers.Util.modifyDOMElement(this.imgDiv,null,null,null,null,null,null,this.layer.opacity)}this.imgDiv.map=this.layer.map;var c=function(){if(this.isLoading){this.isLoading=false;this.events.triggerEvent("loadend")}};if(this.layerAlphaHack){OpenLayers.Event.observe(this.imgDiv.childNodes[0],"load",OpenLayers.Function.bind(c,this))}else{OpenLayers.Event.observe(this.imgDiv,"load",OpenLayers.Function.bind(c,this))}var a=function(){if(this.imgDiv._attempts>OpenLayers.IMAGE_RELOAD_ATTEMPTS){c.call(this)}};OpenLayers.Event.observe(this.imgDiv,"error",OpenLayers.Function.bind(a,this))},checkImgURL:function(){if(this.layer){var a=this.layerAlphaHack?this.imgDiv.firstChild.src:this.imgDiv.src;if(!OpenLayers.Util.isEquivalentUrl(a,this.url)){this.hide()}}},startTransition:function(){if(!this.backBufferTile||!this.backBufferTile.imgDiv){return}var d=1;if(this.backBufferTile.resolution){d=this.backBufferTile.resolution/this.layer.getResolution()}if(d!=this.lastRatio){if(this.layer.transitionEffect=="resize"){var c=new OpenLayers.LonLat(this.backBufferTile.bounds.left,this.backBufferTile.bounds.top);var b=new OpenLayers.Size(this.backBufferTile.size.w*d,this.backBufferTile.size.h*d);var a=this.layer.map.getLayerPxFromLonLat(c);OpenLayers.Util.modifyDOMElement(this.backBufferTile.frame,null,a,b);var f=this.backBufferTile.imageSize;f=new OpenLayers.Size(f.w*d,f.h*d);var g=this.backBufferTile.imageOffset;if(g){g=new OpenLayers.Pixel(g.x*d,g.y*d)}OpenLayers.Util.modifyDOMElement(this.backBufferTile.imgDiv,null,g,f);this.backBufferTile.show()}}else{if(this.layer.singleTile){this.backBufferTile.show()}else{this.backBufferTile.hide()}}this.lastRatio=d},show:function(){this.frame.style.display="";if(OpenLayers.Util.indexOf(this.layer.SUPPORTED_TRANSITIONS,this.layer.transitionEffect)!=-1){if(navigator.userAgent.toLowerCase().indexOf("gecko")!=-1){this.frame.scrollLeft=this.frame.scrollLeft}}},hide:function(){this.frame.style.display="none"},CLASS_NAME:"OpenLayers.Tile.Image"});OpenLayers.Tile.Image.useBlankTile=(OpenLayers.Util.getBrowserName()=="safari"||OpenLayers.Util.getBrowserName()=="opera");OpenLayers.Control.OverviewMap=OpenLayers.Class(OpenLayers.Control,{element:null,ovmap:null,size:new OpenLayers.Size(180,90),layers:null,minRectSize:15,minRectDisplayClass:"RectReplacement",minRatio:8,maxRatio:32,mapOptions:null,autoPan:false,handlers:null,resolutionFactor:1,initialize:function(a){this.layers=[];this.handlers={};OpenLayers.Control.prototype.initialize.apply(this,[a])},destroy:function(){if(!this.mapDiv){return}this.handlers.click.destroy();this.mapDiv.removeChild(this.extentRectangle);this.extentRectangle=null;this.rectEvents.destroy();this.rectEvents=null;this.ovmap.destroy();this.ovmap=null;this.element.removeChild(this.mapDiv);this.mapDiv=null;this.div.removeChild(this.element);this.element=null;if(this.maximizeDiv){OpenLayers.Event.stopObservingElement(this.maximizeDiv);this.div.removeChild(this.maximizeDiv);this.maximizeDiv=null}if(this.minimizeDiv){OpenLayers.Event.stopObservingElement(this.minimizeDiv);this.div.removeChild(this.minimizeDiv);this.minimizeDiv=null}this.map.events.un({moveend:this.update,changebaselayer:this.baseLayerDraw,scope:this});OpenLayers.Control.prototype.destroy.apply(this,arguments)},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!(this.layers.length>0)){if(this.map.baseLayer){var d=this.map.baseLayer.clone();this.layers=[d]}else{this.map.events.register("changebaselayer",this,this.baseLayerDraw);return this.div}}this.element=document.createElement("div");this.element.className=this.displayClass+"Element";this.element.style.display="none";this.mapDiv=document.createElement("div");this.mapDiv.style.width=this.size.w+"px";this.mapDiv.style.height=this.size.h+"px";this.mapDiv.style.position="relative";this.mapDiv.style.overflow="hidden";this.mapDiv.id=OpenLayers.Util.createUniqueID("overviewMap");this.extentRectangle=document.createElement("div");this.extentRectangle.style.position="absolute";this.extentRectangle.style.zIndex=1000;this.extentRectangle.className=this.displayClass+"ExtentRectangle";this.mapDiv.appendChild(this.extentRectangle);this.element.appendChild(this.mapDiv);this.div.appendChild(this.element);if(!this.outsideViewport){this.div.className+=" "+this.displayClass+"Container";var f=OpenLayers.Util.getImagesLocation();var b=f+"layer-switcher-maximize.png";this.maximizeDiv=OpenLayers.Util.createAlphaImageDiv(this.displayClass+"MaximizeButton",null,new OpenLayers.Size(18,18),b,"absolute");this.maximizeDiv.style.display="none";this.maximizeDiv.className=this.displayClass+"MaximizeButton";OpenLayers.Event.observe(this.maximizeDiv,"click",OpenLayers.Function.bindAsEventListener(this.maximizeControl,this));this.div.appendChild(this.maximizeDiv);var b=f+"layer-switcher-minimize.png";this.minimizeDiv=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_minimizeDiv",null,new OpenLayers.Size(18,18),b,"absolute");this.minimizeDiv.style.display="none";this.minimizeDiv.className=this.displayClass+"MinimizeButton";OpenLayers.Event.observe(this.minimizeDiv,"click",OpenLayers.Function.bindAsEventListener(this.minimizeControl,this));this.div.appendChild(this.minimizeDiv);var g=["dblclick","mousedown"];for(var c=0,a=g.length;c<a;c++){OpenLayers.Event.observe(this.maximizeDiv,g[c],OpenLayers.Event.stop);OpenLayers.Event.observe(this.minimizeDiv,g[c],OpenLayers.Event.stop)}this.minimizeControl()}else{this.element.style.display=""}if(this.map.getExtent()){this.update()}this.map.events.register("moveend",this,this.update);return this.div},baseLayerDraw:function(){this.draw();this.map.events.unregister("changebaselayer",this,this.baseLayerDraw)},rectDrag:function(k){var d=this.handlers.drag.last.x-k.x;var b=this.handlers.drag.last.y-k.y;if(d!=0||b!=0){var h=this.rectPxBounds.top;var a=this.rectPxBounds.left;var f=Math.abs(this.rectPxBounds.getHeight());var c=this.rectPxBounds.getWidth();var g=Math.max(0,(h-b));g=Math.min(g,this.ovmap.size.h-this.hComp-f);var j=Math.max(0,(a-d));j=Math.min(j,this.ovmap.size.w-this.wComp-c);this.setRectPxBounds(new OpenLayers.Bounds(j,g+f,j+c,g))}},mapDivClick:function(k){var b=this.rectPxBounds.getCenterPixel();var f=k.xy.x-b.x;var d=k.xy.y-b.y;var h=this.rectPxBounds.top;var c=this.rectPxBounds.left;var l=Math.abs(this.rectPxBounds.getHeight());var a=this.rectPxBounds.getWidth();var g=Math.max(0,(h+d));g=Math.min(g,this.ovmap.size.h-l);var j=Math.max(0,(c+f));j=Math.min(j,this.ovmap.size.w-a);this.setRectPxBounds(new OpenLayers.Bounds(j,g+l,j+a,g));this.updateMapToRect()},maximizeControl:function(a){this.element.style.display="";this.showToggle(false);if(a!=null){OpenLayers.Event.stop(a)}},minimizeControl:function(a){this.element.style.display="none";this.showToggle(true);if(a!=null){OpenLayers.Event.stop(a)}},showToggle:function(a){this.maximizeDiv.style.display=a?"":"none";this.minimizeDiv.style.display=a?"none":""},update:function(){if(this.ovmap==null){this.createMap()}if(this.autoPan||!this.isSuitableOverview()){this.updateOverview()}this.updateRectToMap()},isSuitableOverview:function(){var b=this.map.getExtent();var a=this.map.maxExtent;var c=new OpenLayers.Bounds(Math.max(b.left,a.left),Math.max(b.bottom,a.bottom),Math.min(b.right,a.right),Math.min(b.top,a.top));if(this.ovmap.getProjection()!=this.map.getProjection()){c=c.transform(this.map.getProjectionObject(),this.ovmap.getProjectionObject())}var d=this.ovmap.getResolution()/this.map.getResolution();return((d>this.minRatio)&&(d<=this.maxRatio)&&(this.ovmap.getExtent().containsBounds(c)))},updateOverview:function(){var c=this.map.getResolution();var b=this.ovmap.getResolution();var d=b/c;if(d>this.maxRatio){b=this.minRatio*c}else{if(d<=this.minRatio){b=this.maxRatio*c}}var a;if(this.ovmap.getProjection()!=this.map.getProjection()){a=this.map.center.clone();a.transform(this.map.getProjectionObject(),this.ovmap.getProjectionObject())}else{a=this.map.center}this.ovmap.setCenter(a,this.ovmap.getZoomForResolution(b*this.resolutionFactor));this.updateRectToMap()},createMap:function(){var b=OpenLayers.Util.extend({controls:[],maxResolution:"auto",fallThrough:false},this.mapOptions);this.ovmap=new OpenLayers.Map(this.mapDiv,b);OpenLayers.Event.stopObserving(window,"unload",this.ovmap.unloadDestroy);this.ovmap.addLayers(this.layers);this.ovmap.zoomToMaxExtent();this.wComp=parseInt(OpenLayers.Element.getStyle(this.extentRectangle,"border-left-width"))+parseInt(OpenLayers.Element.getStyle(this.extentRectangle,"border-right-width"));this.wComp=(this.wComp)?this.wComp:2;this.hComp=parseInt(OpenLayers.Element.getStyle(this.extentRectangle,"border-top-width"))+parseInt(OpenLayers.Element.getStyle(this.extentRectangle,"border-bottom-width"));this.hComp=(this.hComp)?this.hComp:2;this.handlers.drag=new OpenLayers.Handler.Drag(this,{move:this.rectDrag,done:this.updateMapToRect},{map:this.ovmap});this.handlers.click=new OpenLayers.Handler.Click(this,{click:this.mapDivClick},{single:true,"double":false,stopSingle:true,stopDouble:true,pixelTolerance:1,map:this.ovmap});this.handlers.click.activate();this.rectEvents=new OpenLayers.Events(this,this.extentRectangle,null,true);this.rectEvents.register("mouseover",this,function(d){if(!this.handlers.drag.active&&!this.map.dragging){this.handlers.drag.activate()}});this.rectEvents.register("mouseout",this,function(d){if(!this.handlers.drag.dragging){this.handlers.drag.deactivate()}});if(this.ovmap.getProjection()!=this.map.getProjection()){var c=this.map.getProjectionObject().getUnits()||this.map.units||this.map.baseLayer.units;var a=this.ovmap.getProjectionObject().getUnits()||this.ovmap.units||this.ovmap.baseLayer.units;this.resolutionFactor=c&&a?OpenLayers.INCHES_PER_UNIT[c]/OpenLayers.INCHES_PER_UNIT[a]:1}},updateRectToMap:function(){var b;if(this.ovmap.getProjection()!=this.map.getProjection()){b=this.map.getExtent().transform(this.map.getProjectionObject(),this.ovmap.getProjectionObject())}else{b=this.map.getExtent()}var a=this.getRectBoundsFromMapBounds(b);if(a){this.setRectPxBounds(a)}},updateMapToRect:function(){var a=this.getMapBoundsFromRectBounds(this.rectPxBounds);if(this.ovmap.getProjection()!=this.map.getProjection()){a=a.transform(this.ovmap.getProjectionObject(),this.map.getProjectionObject())}this.map.panTo(a.getCenterLonLat())},setRectPxBounds:function(d){var h=Math.max(d.top,0);var f=Math.max(d.left,0);var b=Math.min(d.top+Math.abs(d.getHeight()),this.ovmap.size.h-this.hComp);var j=Math.min(d.left+d.getWidth(),this.ovmap.size.w-this.wComp);var c=Math.max(j-f,0);var k=Math.max(b-h,0);if(c<this.minRectSize||k<this.minRectSize){this.extentRectangle.className=this.displayClass+this.minRectDisplayClass;var g=f+(c/2)-(this.minRectSize/2);var a=h+(k/2)-(this.minRectSize/2);this.extentRectangle.style.top=Math.round(a)+"px";this.extentRectangle.style.left=Math.round(g)+"px";this.extentRectangle.style.height=this.minRectSize+"px";this.extentRectangle.style.width=this.minRectSize+"px"}else{this.extentRectangle.className=this.displayClass+"ExtentRectangle";this.extentRectangle.style.top=Math.round(h)+"px";this.extentRectangle.style.left=Math.round(f)+"px";this.extentRectangle.style.height=Math.round(k)+"px";this.extentRectangle.style.width=Math.round(c)+"px"}this.rectPxBounds=new OpenLayers.Bounds(Math.round(f),Math.round(b),Math.round(j),Math.round(h))},getRectBoundsFromMapBounds:function(d){var a=new OpenLayers.LonLat(d.left,d.bottom);var g=new OpenLayers.LonLat(d.right,d.top);var c=this.getOverviewPxFromLonLat(a);var b=this.getOverviewPxFromLonLat(g);var f=null;if(c&&b){f=new OpenLayers.Bounds(c.x,c.y,b.x,b.y)}return f},getMapBoundsFromRectBounds:function(d){var c=new OpenLayers.Pixel(d.left,d.bottom);var b=new OpenLayers.Pixel(d.right,d.top);var a=this.getLonLatFromOverviewPx(c);var f=this.getLonLatFromOverviewPx(b);return new OpenLayers.Bounds(a.lon,a.lat,f.lon,f.lat)},getLonLatFromOverviewPx:function(g){var c=this.ovmap.size;var b=this.ovmap.getResolution();var a=this.ovmap.getExtent().getCenterLonLat();var f=g.x-(c.w/2);var d=g.y-(c.h/2);return new OpenLayers.LonLat(a.lon+f*b,a.lat-d*b)},getOverviewPxFromLonLat:function(d){var b=this.ovmap.getResolution();var c=this.ovmap.getExtent();var a=null;if(c){a=new OpenLayers.Pixel(Math.round(1/b*(d.lon-c.left)),Math.round(1/b*(c.top-d.lat)))}return a},CLASS_NAME:"OpenLayers.Control.OverviewMap"});OpenLayers.Feature=OpenLayers.Class({layer:null,id:null,lonlat:null,data:null,marker:null,popupClass:OpenLayers.Popup.AnchoredBubble,popup:null,initialize:function(a,c,b){this.layer=a;this.lonlat=c;this.data=(b!=null)?b:{};this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_")},destroy:function(){if((this.layer!=null)&&(this.layer.map!=null)){if(this.popup!=null){this.layer.map.removePopup(this.popup)}}this.layer=null;this.id=null;this.lonlat=null;this.data=null;if(this.marker!=null){this.destroyMarker(this.marker);this.marker=null}if(this.popup!=null){this.destroyPopup(this.popup);this.popup=null}},onScreen:function(){var b=false;if((this.layer!=null)&&(this.layer.map!=null)){var a=this.layer.map.getExtent();b=a.containsLonLat(this.lonlat)}return b},createMarker:function(){if(this.lonlat!=null){this.marker=new OpenLayers.Marker(this.lonlat,this.data.icon)}return this.marker},destroyMarker:function(){this.marker.destroy()},createPopup:function(b){if(this.lonlat!=null){var c=this.id+"_popup";var a=(this.marker)?this.marker.icon:null;if(!this.popup){this.popup=new this.popupClass(c,this.lonlat,this.data.popupSize,this.data.popupContentHTML,a,b)}if(this.data.overflow!=null){this.popup.contentDiv.style.overflow=this.data.overflow}this.popup.feature=this}return this.popup},destroyPopup:function(){if(this.popup){this.popup.feature=null;this.popup.destroy();this.popup=null}},CLASS_NAME:"OpenLayers.Feature"});OpenLayers.Format.WFSCapabilities=OpenLayers.Class(OpenLayers.Format.XML,{defaultVersion:"1.1.0",version:null,initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a]);this.options=a},read:function(f){if(typeof f=="string"){f=OpenLayers.Format.XML.prototype.read.apply(this,[f])}var c=f.documentElement;var b=this.version;if(!b){b=c.getAttribute("version");if(!b){b=this.defaultVersion}}var d=OpenLayers.Format.WFSCapabilities["v"+b.replace(/\./g,"_")];if(!d){throw"Can't find a WFS capabilities parser for version "+b}var g=new d(this.options);var a=g.read(f);a.version=b;return a},CLASS_NAME:"OpenLayers.Format.WFSCapabilities"});OpenLayers.Format.WFSDescribeFeatureType=OpenLayers.Class(OpenLayers.Format.XML,{namespaces:{xsd:"http://www.w3.org/2001/XMLSchema"},initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},readers:{xsd:{schema:function(d,k){var f=[];var b={};var g={complexTypes:f,customTypes:b};this.readChildNodes(d,g);var h=d.attributes;var m,a;for(var j=0,l=h.length;j<l;++j){m=h[j];a=m.name;if(a.indexOf("xmlns")==0){this.setNamespace(a.split(":")[1]||"",m.value)}else{k[a]=m.value}}k.featureTypes=f;k.targetPrefix=this.namespaceAlias[k.targetNamespace];var o,c;for(var j=0,l=f.length;j<l;++j){o=f[j];c=b[o.typeName];if(b[o.typeName]){o.typeName=c.name}}},complexType:function(b,c){var a={typeName:b.getAttribute("name")};this.readChildNodes(b,a);c.complexTypes.push(a)},complexContent:function(a,b){this.readChildNodes(a,b)},extension:function(a,b){this.readChildNodes(a,b)},sequence:function(a,b){var c={elements:[]};this.readChildNodes(a,c);b.properties=c.elements},element:function(a,c){if(c.elements){var d={};var b=a.attributes;var h;for(var f=0,g=b.length;f<g;++f){h=b[f];d[h.name]=h.value}var j=d.type;if(!j){j={};this.readChildNodes(a,j);d.restriction=j;d.type=j.base}var l=j.base||j;d.localType=l.split(":").pop();c.elements.push(d)}if(c.complexTypes){var j=a.getAttribute("type");var k=j.split(":").pop();c.customTypes[k]={name:a.getAttribute("name"),type:j}}},simpleType:function(a,b){this.readChildNodes(a,b)},restriction:function(a,b){b.base=a.getAttribute("base");this.readRestriction(a,b)}}},readRestriction:function(d,g){var c=d.childNodes;var j,h,f;for(var b=0,a=c.length;b<a;++b){j=c[b];if(j.nodeType==1){h=j.nodeName.split(":").pop();f=j.getAttribute("value");if(!g[h]){g[h]=f}else{if(typeof g[h]=="string"){g[h]=[g[h]]}g[h].push(f)}}}},read:function(b){if(typeof b=="string"){b=OpenLayers.Format.XML.prototype.read.apply(this,[b])}if(b&&b.nodeType==9){b=b.documentElement}var a={};this.readNode(b,a);return a},CLASS_NAME:"OpenLayers.Format.WFSDescribeFeatureType"});OpenLayers.Format.WFST.v1=OpenLayers.Class(OpenLayers.Format.XML,{namespaces:{xlink:"http://www.w3.org/1999/xlink",xsi:"http://www.w3.org/2001/XMLSchema-instance",wfs:"http://www.opengis.net/wfs",gml:"http://www.opengis.net/gml",ogc:"http://www.opengis.net/ogc"},defaultPrefix:"wfs",version:null,schemaLocations:null,srsName:null,extractAttributes:true,xy:true,stateName:null,initialize:function(a){this.stateName={};this.stateName[OpenLayers.State.INSERT]="wfs:Insert";this.stateName[OpenLayers.State.UPDATE]="wfs:Update";this.stateName[OpenLayers.State.DELETE]="wfs:Delete";OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},getSrsName:function(c,b){var a=b&&b.srsName;if(!a){if(c&&c.layer){a=c.layer.projection.getCode()}else{a=this.srsName}}return a},read:function(a){if(typeof a=="string"){a=OpenLayers.Format.XML.prototype.read.apply(this,[a])}if(a&&a.nodeType==9){a=a.documentElement}var b={};this.readNode(a,b);if(b.features){b=b.features}return b},readers:{wfs:{FeatureCollection:function(a,b){b.features=[];this.readChildNodes(a,b)}}},write:function(a){var b=this.writeNode("wfs:Transaction",a);var c=this.schemaLocationAttr();if(c){this.setAttributeNS(b,this.namespaces.xsi,"xsi:schemaLocation",c)}return OpenLayers.Format.XML.prototype.write.apply(this,[b])},writers:{wfs:{GetFeature:function(a){var b=this.createElementNSPlus("wfs:GetFeature",{attributes:{service:"WFS",version:this.version,maxFeatures:a&&a.maxFeatures,"xsi:schemaLocation":this.schemaLocationAttr(a)}});this.writeNode("Query",a,b);return b},Query:function(a){a=OpenLayers.Util.extend({featureNS:this.featureNS,featurePrefix:this.featurePrefix,featureType:this.featureType,srsName:this.srsName},a);var b=this.createElementNSPlus("wfs:Query",{attributes:{typeName:(a.featureNS?a.featurePrefix+":":"")+a.featureType,srsName:a.srsName}});if(a.featureNS){b.setAttribute("xmlns:"+a.featurePrefix,a.featureNS)}if(a.filter){this.setFilterProperty(a.filter);this.writeNode("ogc:Filter",a.filter,b)}return b},Transaction:function(f){var g=this.createElementNSPlus("wfs:Transaction",{attributes:{service:"WFS",version:this.version}});if(f){var b,d;for(var c=0,a=f.length;c<a;++c){d=f[c];b=this.stateName[d.state];if(b){this.writeNode(b,d,g)}}}return g},Insert:function(a){var b=this.createElementNSPlus("wfs:Insert");this.srsName=this.getSrsName(a);this.writeNode("feature:_typeName",a,b);return b},Update:function(b){var c=this.createElementNSPlus("wfs:Update",{attributes:{typeName:(this.featureNS?this.featurePrefix+":":"")+this.featureType}});if(this.featureNS){c.setAttribute("xmlns:"+this.featurePrefix,this.featureNS)}this.writeNode("Property",{name:this.geometryName,value:b},c);for(var a in b.attributes){this.writeNode("Property",{name:a,value:b.attributes[a]},c)}this.writeNode("ogc:Filter",new OpenLayers.Filter.FeatureId({fids:[b.fid]}),c);return c},Property:function(b){var a=this.createElementNSPlus("wfs:Property");this.writeNode("Name",b.name,a);this.writeNode("Value",b.value,a);return a},Name:function(a){return this.createElementNSPlus("wfs:Name",{value:a})},Value:function(c){var b;if(c instanceof OpenLayers.Feature.Vector){b=this.createElementNSPlus("wfs:Value");this.srsName=this.getSrsName(c);var a=this.writeNode("feature:_geometry",c.geometry).firstChild;b.appendChild(a)}else{b=this.createElementNSPlus("wfs:Value",{value:c})}return b},Delete:function(a){var b=this.createElementNSPlus("wfs:Delete",{attributes:{typeName:(this.featureNS?this.featurePrefix+":":"")+this.featureType}});if(this.featureNS){b.setAttribute("xmlns:"+this.featurePrefix,this.featureNS)}this.writeNode("ogc:Filter",new OpenLayers.Filter.FeatureId({fids:[a.fid]}),b);return b}}},schemaLocationAttr:function(a){a=OpenLayers.Util.extend({featurePrefix:this.featurePrefix,schema:this.schema},a);var g=OpenLayers.Util.extend({},this.schemaLocations);if(a.schema){g[a.featurePrefix]=a.schema}var f=[];var c;for(var b in g){c=this.namespaces[b];if(c){f.push(c+" "+g[b])}}var d=f.join(" ")||undefined;return d},setFilterProperty:function(c){if(c.filters){for(var b=0,a=c.filters.length;b<a;++b){this.setFilterProperty(c.filters[b])}}else{if(c instanceof OpenLayers.Filter.Spatial){c.property=this.geometryName}}},CLASS_NAME:"OpenLayers.Format.WFST.v1"});OpenLayers.Format.WMC=OpenLayers.Class({defaultVersion:"1.1.0",version:null,layerOptions:null,layerParams:null,parser:null,initialize:function(a){OpenLayers.Util.extend(this,a);this.options=a},read:function(f,c){if(typeof f=="string"){f=OpenLayers.Format.XML.prototype.read.apply(this,[f])}var b=f.documentElement;var a=this.version;if(!a){a=b.getAttribute("version");if(!a){a=this.defaultVersion}}if(!this.parser||this.parser.VERSION!=a){var h=OpenLayers.Format.WMC["v"+a.replace(/\./g,"_")];if(!h){throw"Can't find a WMC parser for version "+a}this.parser=new h(this.options)}var d=this.parser.read(f,c);var g;if(c.map){this.context=d;if(c.map instanceof OpenLayers.Map){g=this.mergeContextToMap(d,c.map)}else{g=this.contextToMap(d,c.map)}}else{g=d}return g},contextToMap:function(a,c){var b=new OpenLayers.Map(c,{maxExtent:a.maxExtent,projection:a.projection});b.addLayers(a.layers);b.setCenter(a.bounds.getCenterLonLat(),b.getZoomForExtent(a.bounds,true));return b},mergeContextToMap:function(a,b){b.addLayers(a.layers);return b},write:function(f,b){if(f.CLASS_NAME=="OpenLayers.Map"){f=this.mapToContext(f)}var a=(b&&b.version)||this.version||this.defaultVersion;if(!this.parser||this.parser.VERSION!=a){var d=OpenLayers.Format.WMC["v"+a.replace(/\./g,"_")];if(!d){throw"Can't find a WMS capabilities parser for version "+a}this.parser=new d(this.options)}var c=this.parser.write(f,b);return c},mapToContext:function(b){var a={bounds:b.getExtent(),maxExtent:b.maxExtent,projection:b.projection,layers:b.layers,size:b.getSize()};return a},CLASS_NAME:"OpenLayers.Format.WMC"});OpenLayers.Format.WMSCapabilities.v1_1=OpenLayers.Class(OpenLayers.Format.XML,{initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a]);this.options=a},read:function(c){if(typeof c=="string"){c=OpenLayers.Format.XML.prototype.read.apply(this,[c])}var a={};var b=c.documentElement;this.runChildNodes(a,b);return a},runChildNodes:function(g,f){var c=f.childNodes;var b,d;for(var a=0;a<c.length;++a){b=c[a];if(b.nodeType==1){d=this["read_cap_"+b.nodeName];if(d){d.apply(this,[g,b])}}}},read_cap_Capability:function(a,c){var b={layers:[]};this.runChildNodes(b,c);a.capability=b},read_cap_Request:function(c,b){var a={};this.runChildNodes(a,b);c.request=a},read_cap_GetMap:function(c,b){var a={formats:[]};this.runChildNodes(a,b);c.getmap=a},read_cap_Format:function(b,a){if(b.formats){b.formats.push(this.getChildValue(a))}},read_cap_DCPType:function(c,b){var a=b.getElementsByTagName("OnlineResource");if(a.length>0){this.read_cap_OnlineResource(c,a[0])}},read_cap_Service:function(b,c){var a={};this.runChildNodes(a,c);b.service=a},read_cap_Layer:function(b,f,g){var j={formats:b.request.getmap.formats||[],styles:[],queryable:(f.getAttribute("queryable")==="1"||f.getAttribute("queryable")==="true")};if(g){j.styles=j.styles.concat(g.styles);j.llbbox=g.llbbox;j.minScale=g.minScale;j.maxScale=g.maxScale}var c=f.childNodes;var a,l,d;for(var h=0;h<c.length;++h){a=c[h];l=a.nodeName;d=this["read_cap_"+a.nodeName];if(d){if(l=="Layer"){d.apply(this,[b,a,j])}else{d.apply(this,[j,a])}}}if(j.name){var k=j.name.indexOf(":");if(k>0){j.prefix=j.name.substring(0,k)}b.layers.push(j)}},read_cap_ScaleHint:function(f,g){var d=g.getAttribute("min");var a=g.getAttribute("max");var c=Math.pow(2,0.5);var b=OpenLayers.INCHES_PER_UNIT.m;f.maxScale=parseFloat(((c*d)*b*OpenLayers.DOTS_PER_INCH).toPrecision(13));f.minScale=parseFloat(((c*a)*b*OpenLayers.DOTS_PER_INCH).toPrecision(13))},read_cap_Name:function(c,b){var a=this.getChildValue(b);if(a){c.name=a}},read_cap_Title:function(b,a){var c=this.getChildValue(a);if(c){b.title=c}},read_cap_Abstract:function(c,b){var a=this.getChildValue(b);if(a){c["abstract"]=a}},read_cap_LatLonBoundingBox:function(a,b){a.llbbox=[parseFloat(b.getAttribute("minx")),parseFloat(b.getAttribute("miny")),parseFloat(b.getAttribute("maxx")),parseFloat(b.getAttribute("maxy"))]},read_cap_Style:function(a,c){var b={};this.runChildNodes(b,c);a.styles.push(b)},read_cap_LegendURL:function(c,d){var b={width:d.getAttribute("width"),height:d.getAttribute("height")};var a=d.getElementsByTagName("OnlineResource");if(a.length>0){this.read_cap_OnlineResource(b,a[0])}c.legend=b},read_cap_OnlineResource:function(b,a){b.href=this.getAttributeNS(a,"http://www.w3.org/1999/xlink","href")},CLASS_NAME:"OpenLayers.Format.WMSCapabilities.v1_1"});OpenLayers.Format.WMSDescribeLayer=OpenLayers.Class(OpenLayers.Format.XML,{defaultVersion:"1.1.1",version:null,initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a]);this.options=a},read:function(f){if(typeof f=="string"){f=OpenLayers.Format.XML.prototype.read.apply(this,[f])}var c=f.documentElement;var b=this.version;if(!b){b=c.getAttribute("version");if(!b){b=this.defaultVersion}}if(b=="1.1.1"||b=="1.1.0"){b="1.1"}var d=OpenLayers.Format.WMSDescribeLayer["v"+b.replace(/\./g,"_")];if(!d){throw"Can't find a WMS DescribeLayer parser for version "+b}var g=new d(this.options);var a=g.read(f);a.version=b;return a},CLASS_NAME:"OpenLayers.Format.WMSDescribeLayer"});OpenLayers.Format.WMSGetFeatureInfo=OpenLayers.Class(OpenLayers.Format.XML,{layerIdentifier:"_layer",featureIdentifier:"_feature",regExes:{trimSpace:(/^\s*|\s*$/g),removeSpace:(/\s*/g),splitSpace:(/\s+/),trimComma:(/\s*,\s*/g)},gmlFormat:null,initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,arguments);OpenLayers.Util.extend(this,a);this.options=a},read:function(f){var a;if(typeof f=="string"){f=OpenLayers.Format.XML.prototype.read.apply(this,[f])}var b=f.documentElement;if(b){var c=this;var d=this["read_"+b.nodeName];if(d){a=d.call(this,b)}else{a=new OpenLayers.Format.GML((this.options?this.options:{})).read(f)}}else{a=f}return a},read_msGMLOutput:function(h){var d=[];var b=this.getSiblingNodesByTagCriteria(h,this.layerIdentifier);if(b){for(var k=0,o=b.length;k<o;++k){var c=b[k];var l=c.nodeName;if(c.prefix){l=l.split(":")[1]}var l=l.replace(this.layerIdentifier,"");var m=this.getSiblingNodesByTagCriteria(c,this.featureIdentifier);if(m){for(var g=0;g<m.length;g++){var a=m[g];var q=this.parseGeometry(a);var f=this.parseAttributes(a);var r=new OpenLayers.Feature.Vector(q,f,null);r.type=l;d.push(r)}}}}return d},read_FeatureInfoResponse:function(g){var c=[];var k=this.getElementsByTagNameNS(g,"*","FIELDS");for(var h=0,l=k.length;h<l;h++){var a=k[h];var m=null;var f={};for(var d=0,o=a.attributes.length;d<o;d++){var b=a.attributes[d];f[b.nodeName]=b.nodeValue}c.push(new OpenLayers.Feature.Vector(m,f,null))}return c},getSiblingNodesByTagCriteria:function(g,l){var a=[];var c,f,d,h,b;if(g&&g.hasChildNodes()){c=g.childNodes;d=c.length;for(var j=0;j<d;j++){b=c[j];while(b&&b.nodeType!=1){b=b.nextSibling;j++}f=(b?b.nodeName:"");if(f.length>0&&f.indexOf(l)>-1){a.push(b)}else{h=this.getSiblingNodesByTagCriteria(b,l);if(h.length>0){(a.length==0)?a=h:a.push(h)}}}}return a},parseAttributes:function(d){var f={};if(d.nodeType==1){var c=d.childNodes;n=c.length;for(var g=0;g<n;++g){var b=c[g];if(b.nodeType==1){var k=b.childNodes;if(k.length==1){var j=k[0];if(j.nodeType==3||j.nodeType==4){var a=(b.prefix)?b.nodeName.split(":")[1]:b.nodeName;var h=j.nodeValue.replace(this.regExes.trimSpace,"");f[a]=h}}}}}return f},parseGeometry:function(b){if(!this.gmlFormat){this.gmlFormat=new OpenLayers.Format.GML()}var a=this.gmlFormat.parseFeature(b);var c=null;if(a&&a.geometry){c=a.geometry.clone();a.destroy()}return c},CLASS_NAME:"OpenLayers.Format.WMSGetFeatureInfo"});OpenLayers.Handler.Click=OpenLayers.Class(OpenLayers.Handler,{delay:300,single:true,"double":false,pixelTolerance:0,stopSingle:false,stopDouble:false,timerId:null,down:null,rightclickTimerId:null,initialize:function(c,b,a){OpenLayers.Handler.prototype.initialize.apply(this,arguments);if(this.pixelTolerance!=null){this.mousedown=function(d){this.down=d.xy;return true}}},mousedown:null,mouseup:function(b){var a=true;if(this.checkModifiers(b)&&this.control.handleRightClicks&&OpenLayers.Event.isRightClick(b)){a=this.rightclick(b)}return a},rightclick:function(b){if(this.passesTolerance(b)){if(this.rightclickTimerId!=null){this.clearTimer();this.callback("dblrightclick",[b]);return !this.stopDouble}else{var a=this["double"]?OpenLayers.Util.extend({},b):this.callback("rightclick",[b]);var c=OpenLayers.Function.bind(this.delayedRightCall,this,a);this.rightclickTimerId=window.setTimeout(c,this.delay)}}return !this.stopSingle},delayedRightCall:function(a){this.rightclickTimerId=null;if(a){this.callback("rightclick",[a])}return !this.stopSingle},dblclick:function(a){if(this.passesTolerance(a)){if(this["double"]){this.callback("dblclick",[a])}this.clearTimer()}return !this.stopDouble},click:function(b){if(this.passesTolerance(b)){if(this.timerId!=null){this.clearTimer()}else{var a=this.single?OpenLayers.Util.extend({},b):null;this.timerId=window.setTimeout(OpenLayers.Function.bind(this.delayedCall,this,a),this.delay)}}return !this.stopSingle},passesTolerance:function(b){var c=true;if(this.pixelTolerance!=null&&this.down){var a=Math.sqrt(Math.pow(this.down.x-b.xy.x,2)+Math.pow(this.down.y-b.xy.y,2));if(a>this.pixelTolerance){c=false}}return c},clearTimer:function(){if(this.timerId!=null){window.clearTimeout(this.timerId);this.timerId=null}if(this.rightclickTimerId!=null){window.clearTimeout(this.rightclickTimerId);this.rightclickTimerId=null}},delayedCall:function(a){this.timerId=null;if(a){this.callback("click",[a])}},deactivate:function(){var a=false;if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){this.clearTimer();this.down=null;a=true}return a},CLASS_NAME:"OpenLayers.Handler.Click"});OpenLayers.Handler.Drag=OpenLayers.Class(OpenLayers.Handler,{started:false,stopDown:true,dragging:false,last:null,start:null,oldOnselectstart:null,interval:0,timeoutId:null,initialize:function(c,b,a){OpenLayers.Handler.prototype.initialize.apply(this,arguments)},down:function(a){},move:function(a){},up:function(a){},out:function(a){},mousedown:function(b){var a=true;this.dragging=false;if(this.checkModifiers(b)&&OpenLayers.Event.isLeftClick(b)){this.started=true;this.start=b.xy;this.last=b.xy;OpenLayers.Element.addClass(this.map.viewPortDiv,"olDragDown");this.down(b);this.callback("down",[b.xy]);OpenLayers.Event.stop(b);if(!this.oldOnselectstart){this.oldOnselectstart=(document.onselectstart)?document.onselectstart:function(){return true};document.onselectstart=function(){return false}}a=!this.stopDown}else{this.started=false;this.start=null;this.last=null}return a},mousemove:function(a){if(this.started&&!this.timeoutId&&(a.xy.x!=this.last.x||a.xy.y!=this.last.y)){if(this.interval>0){this.timeoutId=setTimeout(OpenLayers.Function.bind(this.removeTimeout,this),this.interval)}this.dragging=true;this.move(a);this.callback("move",[a.xy]);if(!this.oldOnselectstart){this.oldOnselectstart=document.onselectstart;document.onselectstart=function(){return false}}this.last=this.evt.xy}return true},removeTimeout:function(){this.timeoutId=null},mouseup:function(b){if(this.started){var a=(this.start!=this.last);this.started=false;this.dragging=false;OpenLayers.Element.removeClass(this.map.viewPortDiv,"olDragDown");this.up(b);this.callback("up",[b.xy]);if(a){this.callback("done",[b.xy])}document.onselectstart=this.oldOnselectstart}return true},mouseout:function(b){if(this.started&&OpenLayers.Util.mouseLeft(b,this.map.div)){var a=(this.start!=this.last);this.started=false;this.dragging=false;OpenLayers.Element.removeClass(this.map.viewPortDiv,"olDragDown");this.out(b);this.callback("out",[]);if(a){this.callback("done",[b.xy])}if(document.onselectstart){document.onselectstart=this.oldOnselectstart}}return true},click:function(a){return(this.start==this.last)},activate:function(){var a=false;if(OpenLayers.Handler.prototype.activate.apply(this,arguments)){this.dragging=false;a=true}return a},deactivate:function(){var a=false;if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){this.started=false;this.dragging=false;this.start=null;this.last=null;a=true;OpenLayers.Element.removeClass(this.map.viewPortDiv,"olDragDown")}return a},CLASS_NAME:"OpenLayers.Handler.Drag"});OpenLayers.Handler.Feature=OpenLayers.Class(OpenLayers.Handler,{EVENTMAP:{click:{"in":"click",out:"clickout"},mousemove:{"in":"over",out:"out"},dblclick:{"in":"dblclick",out:null},mousedown:{"in":null,out:null},mouseup:{"in":null,out:null}},feature:null,lastFeature:null,down:null,up:null,clickTolerance:4,geometryTypes:null,stopClick:true,stopDown:true,stopUp:false,initialize:function(d,b,c,a){OpenLayers.Handler.prototype.initialize.apply(this,[d,c,a]);this.layer=b},mousedown:function(a){this.down=a.xy;return this.handle(a)?!this.stopDown:true},mouseup:function(a){this.up=a.xy;return this.handle(a)?!this.stopUp:true},click:function(a){return this.handle(a)?!this.stopClick:true},mousemove:function(a){if(!this.callbacks.over&&!this.callbacks.out){return true}this.handle(a);return true},dblclick:function(a){return !this.handle(a)},geometryTypeMatches:function(a){return this.geometryTypes==null||OpenLayers.Util.indexOf(this.geometryTypes,a.geometry.CLASS_NAME)>-1},handle:function(a){if(this.feature&&!this.feature.layer){this.feature=null}var c=a.type;var g=false;var f=!!(this.feature);var d=(c=="click"||c=="dblclick");this.feature=this.layer.getFeatureFromEvent(a);if(this.feature&&!this.feature.layer){this.feature=null}if(this.lastFeature&&!this.lastFeature.layer){this.lastFeature=null}if(this.feature){var b=(this.feature!=this.lastFeature);if(this.geometryTypeMatches(this.feature)){if(f&&b){if(this.lastFeature){this.triggerCallback(c,"out",[this.lastFeature])}this.triggerCallback(c,"in",[this.feature])}else{if(!f||d){this.triggerCallback(c,"in",[this.feature])}}this.lastFeature=this.feature;g=true}else{if(this.lastFeature&&(f&&b||d)){this.triggerCallback(c,"out",[this.lastFeature])}this.feature=null}}else{if(this.lastFeature&&(f||d)){this.triggerCallback(c,"out",[this.lastFeature])}}return g},triggerCallback:function(d,f,b){var c=this.EVENTMAP[d][f];if(c){if(d=="click"&&this.up&&this.down){var a=Math.sqrt(Math.pow(this.up.x-this.down.x,2)+Math.pow(this.up.y-this.down.y,2));if(a<=this.clickTolerance){this.callback(c,b)}}else{this.callback(c,b)}}},activate:function(){var a=false;if(OpenLayers.Handler.prototype.activate.apply(this,arguments)){this.moveLayerToTop();this.map.events.on({removelayer:this.handleMapEvents,changelayer:this.handleMapEvents,scope:this});a=true}return a},deactivate:function(){var a=false;if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){this.moveLayerBack();this.feature=null;this.lastFeature=null;this.down=null;this.up=null;this.map.events.un({removelayer:this.handleMapEvents,changelayer:this.handleMapEvents,scope:this});a=true}return a},handleMapEvents:function(a){if(!a.property||a.property=="order"){this.moveLayerToTop()}},moveLayerToTop:function(){var a=Math.max(this.map.Z_INDEX_BASE.Feature-1,this.layer.getZIndex())+1;this.layer.setZIndex(a)},moveLayerBack:function(){var a=this.layer.getZIndex()-1;if(a>=this.map.Z_INDEX_BASE.Feature){this.layer.setZIndex(a)}else{this.map.setLayerZIndex(this.layer,this.map.getLayerIndex(this.layer))}},CLASS_NAME:"OpenLayers.Handler.Feature"});OpenLayers.Handler.Hover=OpenLayers.Class(OpenLayers.Handler,{delay:500,pixelTolerance:null,stopMove:false,px:null,timerId:null,initialize:function(c,b,a){OpenLayers.Handler.prototype.initialize.apply(this,arguments)},mousemove:function(a){if(this.passesTolerance(a.xy)){this.clearTimer();this.callback("move",[a]);this.px=a.xy;a=OpenLayers.Util.extend({},a);this.timerId=window.setTimeout(OpenLayers.Function.bind(this.delayedCall,this,a),this.delay)}return !this.stopMove},mouseout:function(a){if(OpenLayers.Util.mouseLeft(a,this.map.div)){this.clearTimer();this.callback("move",[a])}return true},passesTolerance:function(b){var c=true;if(this.pixelTolerance&&this.px){var a=Math.sqrt(Math.pow(this.px.x-b.x,2)+Math.pow(this.px.y-b.y,2));if(a<this.pixelTolerance){c=false}}return c},clearTimer:function(){if(this.timerId!=null){window.clearTimeout(this.timerId);this.timerId=null}},delayedCall:function(a){this.callback("pause",[a])},deactivate:function(){var a=false;if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){this.clearTimer();a=true}return a},CLASS_NAME:"OpenLayers.Handler.Hover"});OpenLayers.Handler.Keyboard=OpenLayers.Class(OpenLayers.Handler,{KEY_EVENTS:["keydown","keyup"],eventListener:null,initialize:function(c,b,a){OpenLayers.Handler.prototype.initialize.apply(this,arguments);this.eventListener=OpenLayers.Function.bindAsEventListener(this.handleKeyEvent,this)},destroy:function(){this.deactivate();this.eventListener=null;OpenLayers.Handler.prototype.destroy.apply(this,arguments)},activate:function(){if(OpenLayers.Handler.prototype.activate.apply(this,arguments)){for(var b=0,a=this.KEY_EVENTS.length;b<a;b++){OpenLayers.Event.observe(document,this.KEY_EVENTS[b],this.eventListener)}return true}else{return false}},deactivate:function(){var c=false;if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){for(var b=0,a=this.KEY_EVENTS.length;b<a;b++){OpenLayers.Event.stopObserving(document,this.KEY_EVENTS[b],this.eventListener)}c=true}return c},handleKeyEvent:function(a){if(this.checkModifiers(a)){this.callback(a.type,[a])}},CLASS_NAME:"OpenLayers.Handler.Keyboard"});OpenLayers.Handler.MouseWheel=OpenLayers.Class(OpenLayers.Handler,{wheelListener:null,mousePosition:null,initialize:function(c,b,a){OpenLayers.Handler.prototype.initialize.apply(this,arguments);this.wheelListener=OpenLayers.Function.bindAsEventListener(this.onWheelEvent,this)},destroy:function(){OpenLayers.Handler.prototype.destroy.apply(this,arguments);this.wheelListener=null},onWheelEvent:function(k){if(!this.map||!this.checkModifiers(k)){return}var g=false;var l=false;var f=false;var b=OpenLayers.Event.element(k);while((b!=null)&&!f&&!g){if(!g){try{if(b.currentStyle){c=b.currentStyle.overflow}else{var a=document.defaultView.getComputedStyle(b,null);var c=a.getPropertyValue("overflow")}g=(c&&(c=="auto")||(c=="scroll"))}catch(d){}}if(!l){for(var h=0,j=this.map.layers.length;h<j;h++){if(b==this.map.layers[h].div||b==this.map.layers[h].pane){l=true;break}}}f=(b==this.map.div);b=b.parentNode}if(!g&&f){if(l){this.wheelZoom(k)}OpenLayers.Event.stop(k)}},wheelZoom:function(a){var b=0;if(!a){a=window.event}if(a.wheelDelta){b=a.wheelDelta/120;if(window.opera&&window.opera.version()<9.2){b=-b}}else{if(a.detail){b=-a.detail/3}}if(b){if(this.mousePosition){a.xy=this.mousePosition}if(!a.xy){a.xy=this.map.getPixelFromLonLat(this.map.getCenter())}if(b<0){this.callback("down",[a,b])}else{this.callback("up",[a,b])}}},mousemove:function(a){this.mousePosition=a.xy},activate:function(a){if(OpenLayers.Handler.prototype.activate.apply(this,arguments)){var b=this.wheelListener;OpenLayers.Event.observe(window,"DOMMouseScroll",b);OpenLayers.Event.observe(window,"mousewheel",b);OpenLayers.Event.observe(document,"mousewheel",b);return true}else{return false}},deactivate:function(a){if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){var b=this.wheelListener;OpenLayers.Event.stopObserving(window,"DOMMouseScroll",b);OpenLayers.Event.stopObserving(window,"mousewheel",b);OpenLayers.Event.stopObserving(document,"mousewheel",b);return true}else{return false}},CLASS_NAME:"OpenLayers.Handler.MouseWheel"});OpenLayers.Layer=OpenLayers.Class({id:null,name:null,div:null,opacity:null,alwaysInRange:null,EVENT_TYPES:["loadstart","loadend","loadcancel","visibilitychanged","move","moveend"],events:null,map:null,isBaseLayer:false,alpha:false,displayInLayerSwitcher:true,visibility:true,attribution:null,inRange:false,imageSize:null,imageOffset:null,options:null,eventListeners:null,gutter:0,projection:null,units:null,scales:null,resolutions:null,maxExtent:null,minExtent:null,maxResolution:null,minResolution:null,numZoomLevels:null,minScale:null,maxScale:null,displayOutsideMaxExtent:false,wrapDateLine:false,transitionEffect:null,SUPPORTED_TRANSITIONS:["resize"],initialize:function(b,a){this.addOptions(a);this.name=b;if(this.id==null){this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");this.div=OpenLayers.Util.createDiv(this.id);this.div.style.width="100%";this.div.style.height="100%";this.div.dir="ltr";this.events=new OpenLayers.Events(this,this.div,this.EVENT_TYPES);if(this.eventListeners instanceof Object){this.events.on(this.eventListeners)}}if(this.wrapDateLine){this.displayOutsideMaxExtent=true}},destroy:function(a){if(a==null){a=true}if(this.map!=null){this.map.removeLayer(this,a)}this.projection=null;this.map=null;this.name=null;this.div=null;this.options=null;if(this.events){if(this.eventListeners){this.events.un(this.eventListeners)}this.events.destroy()}this.eventListeners=null;this.events=null},clone:function(a){if(a==null){a=new OpenLayers.Layer(this.name,this.options)}OpenLayers.Util.applyDefaults(a,this);a.map=null;return a},setName:function(a){if(a!=this.name){this.name=a;if(this.map!=null){this.map.events.triggerEvent("changelayer",{layer:this,property:"name"})}}},addOptions:function(a){if(this.options==null){this.options={}}OpenLayers.Util.extend(this.options,a);OpenLayers.Util.extend(this,a)},onMapResize:function(){},redraw:function(){var b=false;if(this.map){this.inRange=this.calculateInRange();var c=this.getExtent();if(c&&this.inRange&&this.visibility){var a=true;this.moveTo(c,a,false);this.events.triggerEvent("moveend",{zoomChanged:a});b=true}}return b},moveTo:function(b,a,c){var d=this.visibility;if(!this.isBaseLayer){d=d&&this.inRange}this.display(d)},setMap:function(b){if(this.map==null){this.map=b;this.maxExtent=this.maxExtent||this.map.maxExtent;this.projection=this.projection||this.map.projection;if(this.projection&&typeof this.projection=="string"){this.projection=new OpenLayers.Projection(this.projection)}this.units=this.projection.getUnits()||this.units||this.map.units;this.initResolutions();if(!this.isBaseLayer){this.inRange=this.calculateInRange();var a=((this.visibility)&&(this.inRange));this.div.style.display=a?"":"none"}this.setTileSize()}},afterAdd:function(){},removeMap:function(a){},getImageSize:function(){return(this.imageSize||this.tileSize)},setTileSize:function(a){var b=(a)?a:((this.tileSize)?this.tileSize:this.map.getTileSize());this.tileSize=b;if(this.gutter){this.imageOffset=new OpenLayers.Pixel(-this.gutter,-this.gutter);this.imageSize=new OpenLayers.Size(b.w+(2*this.gutter),b.h+(2*this.gutter))}},getVisibility:function(){return this.visibility},setVisibility:function(a){if(a!=this.visibility){this.visibility=a;this.display(a);this.redraw();if(this.map!=null){this.map.events.triggerEvent("changelayer",{layer:this,property:"visibility"})}this.events.triggerEvent("visibilitychanged")}},display:function(a){var b=this.calculateInRange();if(a!=(this.div.style.display!="none")){this.div.style.display=(a&&b)?"block":"none"}},calculateInRange:function(){var b=false;if(this.alwaysInRange){b=true}else{if(this.map){var a=this.map.getResolution();b=((a>=this.minResolution)&&(a<=this.maxResolution))}}return b},setIsBaseLayer:function(a){if(a!=this.isBaseLayer){this.isBaseLayer=a;if(this.map!=null){this.map.events.triggerEvent("changebaselayer",{layer:this})}}},initResolutions:function(){var q=new Array("projection","units","scales","resolutions","maxScale","minScale","maxResolution","minResolution","minExtent","maxExtent","numZoomLevels","maxZoomLevel");var b=["projection","units"];var f=false;var d={};for(var g=0,k=q.length;g<k;g++){var s=q[g];if(this.options[s]&&OpenLayers.Util.indexOf(b,s)==-1){f=true}d[s]=this.options[s]||this.map[s]}if(this.alwaysInRange==null){this.alwaysInRange=!f}if((this.options.minScale!=null||this.options.maxScale!=null)&&this.options.scales==null){d.scales=null}if((this.options.minResolution!=null||this.options.maxResolution!=null)&&this.options.resolutions==null){d.resolutions=null}if((!d.numZoomLevels)&&(d.maxZoomLevel)){d.numZoomLevels=d.maxZoomLevel+1}if((d.scales!=null)||(d.resolutions!=null)){if(d.scales!=null){d.resolutions=[];for(var g=0,k=d.scales.length;g<k;g++){var c=d.scales[g];d.resolutions[g]=OpenLayers.Util.getResolutionFromScale(c,d.units)}}d.numZoomLevels=d.resolutions.length}else{if(d.minScale){d.maxResolution=OpenLayers.Util.getResolutionFromScale(d.minScale,d.units)}else{if(d.maxResolution=="auto"){var r=this.map.getSize();var o=d.maxExtent.getWidth()/r.w;var j=d.maxExtent.getHeight()/r.h;d.maxResolution=Math.max(o,j)}}if(d.maxScale!=null){d.minResolution=OpenLayers.Util.getResolutionFromScale(d.maxScale,d.units)}else{if((d.minResolution=="auto")&&(d.minExtent!=null)){var r=this.map.getSize();var o=d.minExtent.getWidth()/r.w;var j=d.minExtent.getHeight()/r.h;d.minResolution=Math.max(o,j)}}if(d.minResolution!=null&&this.options.numZoomLevels==undefined){var m=d.maxResolution/d.minResolution;d.numZoomLevels=Math.floor(Math.log(m)/Math.log(2))+1}d.resolutions=new Array(d.numZoomLevels);var a=2;if(typeof d.minResolution=="number"&&d.numZoomLevels>1){a=Math.pow((d.maxResolution/d.minResolution),(1/(d.numZoomLevels-1)))}for(var g=0;g<d.numZoomLevels;g++){var l=d.maxResolution/Math.pow(a,g);d.resolutions[g]=l}}d.resolutions.sort(function(u,t){return(t-u)});this.resolutions=d.resolutions;this.maxResolution=d.resolutions[0];var h=d.resolutions.length-1;this.minResolution=d.resolutions[h];this.scales=[];for(var g=0,k=d.resolutions.length;g<k;g++){this.scales[g]=OpenLayers.Util.getScaleFromResolution(d.resolutions[g],d.units)}this.minScale=this.scales[0];this.maxScale=this.scales[this.scales.length-1];this.numZoomLevels=d.numZoomLevels},getResolution:function(){var a=this.map.getZoom();return this.getResolutionForZoom(a)},getExtent:function(){return this.map.calculateBounds()},getZoomForExtent:function(b,c){var d=this.map.getSize();var a=Math.max(b.getWidth()/d.w,b.getHeight()/d.h);return this.getZoomForResolution(a,c)},getDataExtent:function(){},getResolutionForZoom:function(c){c=Math.max(0,Math.min(c,this.resolutions.length-1));var b;if(this.map.fractionalZoom){var a=Math.floor(c);var d=Math.ceil(c);b=this.resolutions[a]-((c-a)*(this.resolutions[a]-this.resolutions[d]))}else{b=this.resolutions[Math.round(c)]}return b},getZoomForResolution:function(f,a){var q;if(this.map.fractionalZoom){var l=0;var c=this.resolutions.length-1;var d=this.resolutions[l];var b=this.resolutions[c];var k;for(var g=0,h=this.resolutions.length;g<h;++g){k=this.resolutions[g];if(k>=f){d=k;l=g}if(k<=f){b=k;c=g;break}}var j=d-b;if(j>0){q=l+((d-f)/j)}else{q=l}}else{var m;var o=Number.POSITIVE_INFINITY;for(var g=0,h=this.resolutions.length;g<h;g++){if(a){m=Math.abs(this.resolutions[g]-f);if(m>o){break}o=m}else{if(this.resolutions[g]<f){break}}}q=Math.max(0,g-1)}return q},getLonLatFromViewPortPx:function(b){var f=null;if(b!=null){var d=this.map.getSize();var a=this.map.getCenter();if(a){var c=this.map.getResolution();var h=b.x-(d.w/2);var g=b.y-(d.h/2);f=new OpenLayers.LonLat(a.lon+h*c,a.lat-g*c);if(this.wrapDateLine){f=f.wrapDateLine(this.maxExtent)}}}return f},getViewPortPxFromLonLat:function(d){var b=null;if(d!=null){var a=this.map.getResolution();var c=this.map.getExtent();b=new OpenLayers.Pixel((1/a*(d.lon-c.left)),(1/a*(c.top-d.lat)))}return b},setOpacity:function(b){if(b!=this.opacity){this.opacity=b;for(var d=0,a=this.div.childNodes.length;d<a;++d){var c=this.div.childNodes[d].firstChild;OpenLayers.Util.modifyDOMElement(c,null,null,null,null,null,null,b)}}},getZIndex:function(){return this.div.style.zIndex},setZIndex:function(a){this.div.style.zIndex=a},adjustBounds:function(b){if(this.gutter){var a=this.gutter*this.map.getResolution();b=new OpenLayers.Bounds(b.left-a,b.bottom-a,b.right+a,b.top+a)}if(this.wrapDateLine){var c={rightTolerance:this.getResolution()};b=b.wrapDateLine(this.maxExtent,c)}return b},CLASS_NAME:"OpenLayers.Layer"});OpenLayers.Marker.Box=OpenLayers.Class(OpenLayers.Marker,{bounds:null,div:null,initialize:function(b,c,a){this.bounds=b;this.div=OpenLayers.Util.createDiv();this.div.style.overflow="hidden";this.events=new OpenLayers.Events(this,this.div,null);this.setBorder(c,a)},destroy:function(){this.bounds=null;this.div=null;OpenLayers.Marker.prototype.destroy.apply(this,arguments)},setBorder:function(a,b){if(!a){a="red"}if(!b){b=2}this.div.style.border=b+"px solid "+a},draw:function(a,b){OpenLayers.Util.modifyDOMElement(this.div,null,a,b);return this.div},onScreen:function(){var b=false;if(this.map){var a=this.map.getExtent();b=a.containsBounds(this.bounds,true,true)}return b},display:function(a){this.div.style.display=(a)?"":"none"},CLASS_NAME:"OpenLayers.Marker.Box"});(function(){var d=window.XMLHttpRequest;var j=!!window.controllers,f=window.document.all&&!window.opera;function c(){this._object=d?new d:new window.ActiveXObject("Microsoft.XMLHTTP")}if(j&&d.wrapped){c.wrapped=d.wrapped}c.UNSENT=0;c.OPENED=1;c.HEADERS_RECEIVED=2;c.LOADING=3;c.DONE=4;c.prototype.readyState=c.UNSENT;c.prototype.responseText="";c.prototype.responseXML=null;c.prototype.status=0;c.prototype.statusText="";c.prototype.onreadystatechange=null;c.onreadystatechange=null;c.onopen=null;c.onsend=null;c.onabort=null;c.prototype.open=function(o,s,m,t,l){this._async=m;var r=this,q=this.readyState;if(f){var k=function(){if(r._object.readyState!=c.DONE){a(r)}};if(m){window.attachEvent("onunload",k)}}this._object.onreadystatechange=function(){if(j&&!m){return}r.readyState=r._object.readyState;h(r);if(r._aborted){r.readyState=c.UNSENT;return}if(r.readyState==c.DONE){a(r);if(f&&m){window.detachEvent("onunload",k)}}if(q!=r.readyState){g(r)}q=r.readyState};if(c.onopen){c.onopen.apply(this,arguments)}this._object.open(o,s,m,t,l);if(!m&&j){this.readyState=c.OPENED;g(this)}};c.prototype.send=function(k){if(c.onsend){c.onsend.apply(this,arguments)}if(k&&k.nodeType){k=window.XMLSerializer?new window.XMLSerializer().serializeToString(k):k.xml;if(!this._headers["Content-Type"]){this._object.setRequestHeader("Content-Type","application/xml")}}this._object.send(k);if(j&&!this._async){this.readyState=c.OPENED;h(this);while(this.readyState<c.DONE){this.readyState++;g(this);if(this._aborted){return}}}};c.prototype.abort=function(){if(c.onabort){c.onabort.apply(this,arguments)}if(this.readyState>c.UNSENT){this._aborted=true}this._object.abort();a(this)};c.prototype.getAllResponseHeaders=function(){return this._object.getAllResponseHeaders()};c.prototype.getResponseHeader=function(k){return this._object.getResponseHeader(k)};c.prototype.setRequestHeader=function(k,l){if(!this._headers){this._headers={}}this._headers[k]=l;return this._object.setRequestHeader(k,l)};c.prototype.toString=function(){return"[object XMLHttpRequest]"};c.toString=function(){return"[XMLHttpRequest]"};function g(k){if(k.onreadystatechange){k.onreadystatechange.apply(k)}if(c.onreadystatechange){c.onreadystatechange.apply(k)}}function b(l){var k=l.responseXML;if(f&&k&&!k.documentElement&&l.getResponseHeader("Content-Type").match(/[^\/]+\/[^\+]+\+xml/)){k=new ActiveXObject("Microsoft.XMLDOM");k.loadXML(l.responseText)}if(k){if((f&&k.parseError!=0)||(k.documentElement&&k.documentElement.tagName=="parsererror")){return null}}return k}function h(k){try{k.responseText=k._object.responseText}catch(l){}try{k.responseXML=b(k._object)}catch(l){}try{k.status=k._object.status}catch(l){}try{k.statusText=k._object.statusText}catch(l){}}function a(k){k._object.onreadystatechange=new window.Function;delete k._headers}if(!window.Function.prototype.apply){window.Function.prototype.apply=function(k,l){if(!l){l=[]}k.__func=this;k.__func(l[0],l[1],l[2],l[3],l[4]);delete k.__func}}OpenLayers.Request.XMLHttpRequest=c})();OpenLayers.ProxyHost="";OpenLayers.nullHandler=function(a){OpenLayers.Console.userError(OpenLayers.i18n("unhandledRequest",{statusText:a.statusText}))};OpenLayers.loadURL=function(d,h,b,f,c){if(typeof h=="string"){h=OpenLayers.Util.getParameters(h)}var g=(f)?f:OpenLayers.nullHandler;var a=(c)?c:OpenLayers.nullHandler;return OpenLayers.Request.GET({url:d,params:h,success:g,failure:a,scope:b})};OpenLayers.parseXMLString=function(c){var a=c.indexOf("<");if(a>0){c=c.substring(a)}var b=OpenLayers.Util.Try(function(){var d=new ActiveXObject("Microsoft.XMLDOM");d.loadXML(c);return d},function(){return new DOMParser().parseFromString(c,"text/xml")},function(){var d=new XMLHttpRequest();d.open("GET","data:text/xml;charset=utf-8,"+encodeURIComponent(c),false);if(d.overrideMimeType){d.overrideMimeType("text/xml")}d.send(null);return d.responseXML});return b};OpenLayers.Ajax={emptyFunction:function(){},getTransport:function(){return OpenLayers.Util.Try(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false},activeRequestCount:0};OpenLayers.Ajax.Responders={responders:[],register:function(b){for(var a=0;a<this.responders.length;a++){if(b==this.responders[a]){return}}this.responders.push(b)},unregister:function(a){OpenLayers.Util.removeItem(this.reponders,a)},dispatch:function(g,c,f){var a;for(var b=0;b<this.responders.length;b++){a=this.responders[b];if(a[g]&&typeof a[g]=="function"){try{a[g].apply(a,[c,f])}catch(d){}}}}};OpenLayers.Ajax.Responders.register({onCreate:function(){OpenLayers.Ajax.activeRequestCount++},onComplete:function(){OpenLayers.Ajax.activeRequestCount--}});OpenLayers.Ajax.Base=OpenLayers.Class({initialize:function(a){this.options={method:"post",asynchronous:true,contentType:"application/xml",parameters:""};OpenLayers.Util.extend(this.options,a||{});this.options.method=this.options.method.toLowerCase();if(typeof this.options.parameters=="string"){this.options.parameters=OpenLayers.Util.getParameters(this.options.parameters)}}});OpenLayers.Ajax.Request=OpenLayers.Class(OpenLayers.Ajax.Base,{_complete:false,initialize:function(b,a){OpenLayers.Ajax.Base.prototype.initialize.apply(this,[a]);if(OpenLayers.ProxyHost&&OpenLayers.String.startsWith(b,"http")){b=OpenLayers.ProxyHost+encodeURIComponent(b)}this.transport=OpenLayers.Ajax.getTransport();this.request(b)},request:function(b){this.url=b;this.method=this.options.method;var d=OpenLayers.Util.extend({},this.options.parameters);if(this.method!="get"&&this.method!="post"){d._method=this.method;this.method="post"}this.parameters=d;if(d=OpenLayers.Util.getParameterString(d)){if(this.method=="get"){this.url+=((this.url.indexOf("?")>-1)?"&":"?")+d}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){d+="&_="}}}try{var a=new OpenLayers.Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(a)}OpenLayers.Ajax.Responders.dispatch("onCreate",this,a);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){window.setTimeout(OpenLayers.Function.bind(this.respondToReadyState,this,1),10)}this.transport.onreadystatechange=OpenLayers.Function.bind(this.onStateChange,this);this.setRequestHeaders();this.body=this.method=="post"?(this.options.postBody||d):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}}catch(c){this.dispatchException(c)}},onStateChange:function(){var a=this.transport.readyState;if(a>1&&!((a==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var f={"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*",OpenLayers:true};if(this.method=="post"){f["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){f.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var c=this.options.requestHeaders;if(typeof c.push=="function"){for(var b=0,d=c.length;b<d;b+=2){f[c[b]]=c[b+1]}}else{for(var b in c){f[b]=c[b]}}}for(var a in f){this.transport.setRequestHeader(a,f[a])}},success:function(){var a=this.getStatus();return !a||(a>=200&&a<300)},getStatus:function(){try{return this.transport.status||0}catch(a){return 0}},respondToReadyState:function(a){var c=OpenLayers.Ajax.Request.Events[a];var b=new OpenLayers.Ajax.Response(this);if(c=="Complete"){try{this._complete=true;(this.options["on"+b.status]||this.options["on"+(this.success()?"Success":"Failure")]||OpenLayers.Ajax.emptyFunction)(b)}catch(d){this.dispatchException(d)}var f=b.getHeader("Content-type")}try{(this.options["on"+c]||OpenLayers.Ajax.emptyFunction)(b);OpenLayers.Ajax.Responders.dispatch("on"+c,this,b)}catch(d){this.dispatchException(d)}if(c=="Complete"){this.transport.onreadystatechange=OpenLayers.Ajax.emptyFunction}},getHeader:function(a){try{return this.transport.getResponseHeader(a)}catch(b){return null}},dispatchException:function(c){var d=this.options.onException;if(d){d(this,c);OpenLayers.Ajax.Responders.dispatch("onException",this,c)}else{var f=false;var a=OpenLayers.Ajax.Responders.responders;for(var b=0;b<a.length;b++){if(a[b].onException){f=true;break}}if(f){OpenLayers.Ajax.Responders.dispatch("onException",this,c)}else{throw c}}}});OpenLayers.Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];OpenLayers.Ajax.Response=OpenLayers.Class({status:0,statusText:"",initialize:function(c){this.request=c;var d=this.transport=c.transport,a=this.readyState=d.readyState;if((a>2&&!(!!(window.attachEvent&&!window.opera)))||a==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=d.responseText==null?"":String(d.responseText)}if(a==4){var b=d.responseXML;this.responseXML=b===undefined?null:b}},getStatus:OpenLayers.Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||""}catch(a){return""}},getHeader:OpenLayers.Ajax.Request.prototype.getHeader,getResponseHeader:function(a){return this.transport.getResponseHeader(a)}});OpenLayers.Ajax.getElementsByTagNameNS=function(b,a,c,f){var d=null;if(b.getElementsByTagNameNS){d=b.getElementsByTagNameNS(a,f)}else{d=b.getElementsByTagName(c+":"+f)}return d};OpenLayers.Ajax.serializeXMLToString=function(a){var b=new XMLSerializer();var c=b.serializeToString(a);return c};OpenLayers.Control.DragFeature=OpenLayers.Class(OpenLayers.Control,{geometryTypes:null,onStart:function(b,a){},onDrag:function(b,a){},onComplete:function(b,a){},layer:null,feature:null,dragCallbacks:{},featureCallbacks:{},lastPixel:null,initialize:function(b,a){OpenLayers.Control.prototype.initialize.apply(this,[a]);this.layer=b;this.handlers={drag:new OpenLayers.Handler.Drag(this,OpenLayers.Util.extend({down:this.downFeature,move:this.moveFeature,up:this.upFeature,out:this.cancel,done:this.doneDragging},this.dragCallbacks)),feature:new OpenLayers.Handler.Feature(this,this.layer,OpenLayers.Util.extend({over:this.overFeature,out:this.outFeature},this.featureCallbacks),{geometryTypes:this.geometryTypes})}},destroy:function(){this.layer=null;OpenLayers.Control.prototype.destroy.apply(this,[])},activate:function(){return(this.handlers.feature.activate()&&OpenLayers.Control.prototype.activate.apply(this,arguments))},deactivate:function(){this.handlers.drag.deactivate();this.handlers.feature.deactivate();this.feature=null;this.dragging=false;this.lastPixel=null;OpenLayers.Element.removeClass(this.map.viewPortDiv,this.displayClass+"Over");return OpenLayers.Control.prototype.deactivate.apply(this,arguments)},overFeature:function(a){if(!this.handlers.drag.dragging){this.feature=a;this.handlers.drag.activate();this.over=true;OpenLayers.Element.addClass(this.map.viewPortDiv,this.displayClass+"Over")}else{if(this.feature.id==a.id){this.over=true}else{this.over=false}}},downFeature:function(a){this.lastPixel=a;this.onStart(this.feature,a)},moveFeature:function(a){var b=this.map.getResolution();this.feature.geometry.move(b*(a.x-this.lastPixel.x),b*(this.lastPixel.y-a.y));this.layer.drawFeature(this.feature);this.lastPixel=a;this.onDrag(this.feature,a)},upFeature:function(a){if(!this.over){this.handlers.drag.deactivate()}},doneDragging:function(a){this.onComplete(this.feature,a)},outFeature:function(a){if(!this.handlers.drag.dragging){this.over=false;this.handlers.drag.deactivate();OpenLayers.Element.removeClass(this.map.viewPortDiv,this.displayClass+"Over");this.feature=null}else{if(this.feature.id==a.id){this.over=false}}},cancel:function(){this.handlers.drag.deactivate();this.over=false},setMap:function(a){this.handlers.drag.setMap(a);this.handlers.feature.setMap(a);OpenLayers.Control.prototype.setMap.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.DragFeature"});OpenLayers.Control.DragPan=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOOL,panned:false,interval:25,draw:function(){this.handler=new OpenLayers.Handler.Drag(this,{move:this.panMap,done:this.panMapDone},{interval:this.interval})},panMap:function(a){this.panned=true;this.map.pan(this.handler.last.x-a.x,this.handler.last.y-a.y,{dragging:this.handler.dragging,animate:false})},panMapDone:function(a){if(this.panned){this.panMap(a);this.panned=false}},CLASS_NAME:"OpenLayers.Control.DragPan"});OpenLayers.Control.KeyboardDefaults=OpenLayers.Class(OpenLayers.Control,{slideFactor:75,initialize:function(){OpenLayers.Control.prototype.initialize.apply(this,arguments)},destroy:function(){if(this.handler){this.handler.destroy()}this.handler=null;OpenLayers.Control.prototype.destroy.apply(this,arguments)},draw:function(){this.handler=new OpenLayers.Handler.Keyboard(this,{keydown:this.defaultKeyPress});this.activate()},defaultKeyPress:function(a){switch(a.keyCode){case OpenLayers.Event.KEY_LEFT:this.map.pan(-this.slideFactor,0);break;case OpenLayers.Event.KEY_RIGHT:this.map.pan(this.slideFactor,0);break;case OpenLayers.Event.KEY_UP:this.map.pan(0,-this.slideFactor);break;case OpenLayers.Event.KEY_DOWN:this.map.pan(0,this.slideFactor);break;case 33:var b=this.map.getSize();this.map.pan(0,-0.75*b.h);break;case 34:var b=this.map.getSize();this.map.pan(0,0.75*b.h);break;case 35:var b=this.map.getSize();this.map.pan(0.75*b.w,0);break;case 36:var b=this.map.getSize();this.map.pan(-0.75*b.w,0);break;case 43:case 61:case 187:case 107:this.map.zoomIn();break;case 45:case 109:case 189:case 95:this.map.zoomOut();break}},CLASS_NAME:"OpenLayers.Control.KeyboardDefaults"});OpenLayers.Control.WMSGetFeatureInfo=OpenLayers.Class(OpenLayers.Control,{hover:false,maxFeatures:10,layers:null,queryVisible:false,url:null,layerUrls:null,infoFormat:"text/html",vendorParams:{},format:null,formatOptions:null,handlerOptions:null,handler:null,hoverRequest:null,EVENT_TYPES:["getfeatureinfo"],initialize:function(a){this.EVENT_TYPES=OpenLayers.Control.WMSGetFeatureInfo.prototype.EVENT_TYPES.concat(OpenLayers.Control.prototype.EVENT_TYPES);a=a||{};a.handlerOptions=a.handlerOptions||{};OpenLayers.Control.prototype.initialize.apply(this,[a]);if(!this.format){this.format=new OpenLayers.Format.WMSGetFeatureInfo(a.formatOptions)}if(this.hover){this.handler=new OpenLayers.Handler.Hover(this,{move:this.cancelHover,pause:this.getInfoForHover},OpenLayers.Util.extend(this.handlerOptions.hover||{},{delay:250}))}else{this.handler=new OpenLayers.Handler.Click(this,{click:this.getInfoForClick},this.handlerOptions.click||{})}},activate:function(){if(!this.active){this.handler.activate()}return OpenLayers.Control.prototype.activate.apply(this,arguments)},deactivate:function(){return OpenLayers.Control.prototype.deactivate.apply(this,arguments)},getInfoForClick:function(a){OpenLayers.Element.addClass(this.map.viewPortDiv,"olCursorWait");this.request(a.xy,{})},getInfoForHover:function(a){this.request(a.xy,{hover:true})},cancelHover:function(){if(this.hoverRequest){this.hoverRequest.abort();this.hoverRequest=null}},findLayers:function(){var g=[];var f=this.layers||this.map.layers;var d,b;for(var c=0,a=f.length;c<a;++c){d=f[c];if(d instanceof OpenLayers.Layer.WMS&&(!this.queryVisible||d.getVisibility())){b=d.url instanceof Array?d.url[0]:d.url;if(!this.url){this.url=b}if(this.urlMatches(b)){g.push(d)}}}return g},urlMatches:function(b){var d=OpenLayers.Util.isEquivalentUrl(this.url,b);if(!d&&this.layerUrls){for(var c=0,a=this.layerUrls.length;c<a;++c){if(OpenLayers.Util.isEquivalentUrl(this.layerUrls[c],b)){d=true;break}}}return d},request:function(a,k){k=k||{};var g=[];var h=[];var c=this.findLayers();if(c.length>0){for(var d=0,f=c.length;d<f;d++){g=g.concat(c[d].params.LAYERS);if(c[d].params.STYLES){h=h.concat(c[d].params.STYLES)}else{if(c[d].params.LAYERS instanceof Array){h=h.concat(new Array(c[d].params.LAYERS.length))}else{h=h.concat(c[d].params.LAYERS.replace(/[^,]/g,""))}}}var j={url:this.url,params:OpenLayers.Util.applyDefaults({service:"WMS",version:"1.1.0",request:"GetFeatureInfo",layers:g,query_layers:g,styles:h,bbox:this.map.getExtent().toBBOX(),srs:this.map.getProjection(),feature_count:this.maxFeatures,x:a.x,y:a.y,height:this.map.getSize().h,width:this.map.getSize().w,info_format:this.infoFormat},this.vendorParams),callback:function(l){this.handleResponse(a,l)},scope:this};var b=OpenLayers.Request.GET(j);if(k.hover===true){this.hoverRequest=b.priv}}else{OpenLayers.Element.removeClass(this.map.viewPortDiv,"olCursorWait")}},handleResponse:function(d,b){var c=b.responseXML;if(!c||!c.documentElement){c=b.responseText}var a=this.format.read(c);this.events.triggerEvent("getfeatureinfo",{text:b.responseText,features:a,request:b,xy:d});OpenLayers.Element.removeClass(this.map.viewPortDiv,"olCursorWait")},setMap:function(a){this.handler.setMap(a);OpenLayers.Control.prototype.setMap.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.WMSGetFeatureInfo"});OpenLayers.State={UNKNOWN:"Unknown",INSERT:"Insert",UPDATE:"Update",DELETE:"Delete"};OpenLayers.Feature.Vector=OpenLayers.Class(OpenLayers.Feature,{fid:null,geometry:null,attributes:null,bounds:null,state:null,style:null,renderIntent:"default",initialize:function(c,a,b){OpenLayers.Feature.prototype.initialize.apply(this,[null,null,a]);this.lonlat=null;this.geometry=c?c:null;this.state=null;this.attributes={};if(a){this.attributes=OpenLayers.Util.extend(this.attributes,a)}this.style=b?b:null},destroy:function(){if(this.layer){this.layer.removeFeatures(this);this.layer=null}this.geometry=null;OpenLayers.Feature.prototype.destroy.apply(this,arguments)},clone:function(){return new OpenLayers.Feature.Vector(this.geometry?this.geometry.clone():null,this.attributes,this.style)},onScreen:function(d){var c=false;if(this.layer&&this.layer.map){var a=this.layer.map.getExtent();if(d){var b=this.geometry.getBounds();c=a.intersectsBounds(b)}else{var f=a.toGeometry();c=f.intersects(this.geometry)}}return c},createMarker:function(){return null},destroyMarker:function(){},createPopup:function(){return null},atPoint:function(b,d,c){var a=false;if(this.geometry){a=this.geometry.atPoint(b,d,c)}return a},destroyPopup:function(){},move:function(a){if(!this.layer||!this.geometry.move){return}var b;if(a.CLASS_NAME=="OpenLayers.LonLat"){b=this.layer.getViewPortPxFromLonLat(a)}else{b=a}var d=this.layer.getViewPortPxFromLonLat(this.geometry.getBounds().getCenterLonLat());var c=this.layer.map.getResolution();this.geometry.move(c*(b.x-d.x),c*(d.y-b.y));this.layer.drawFeature(this);return d},toState:function(a){if(a==OpenLayers.State.UPDATE){switch(this.state){case OpenLayers.State.UNKNOWN:case OpenLayers.State.DELETE:this.state=a;break;case OpenLayers.State.UPDATE:case OpenLayers.State.INSERT:break}}else{if(a==OpenLayers.State.INSERT){switch(this.state){case OpenLayers.State.UNKNOWN:break;default:this.state=a;break}}else{if(a==OpenLayers.State.DELETE){switch(this.state){case OpenLayers.State.INSERT:break;case OpenLayers.State.DELETE:break;case OpenLayers.State.UNKNOWN:case OpenLayers.State.UPDATE:this.state=a;break}}else{if(a==OpenLayers.State.UNKNOWN){this.state=a}}}}},CLASS_NAME:"OpenLayers.Feature.Vector"});OpenLayers.Feature.Vector.style={"default":{fillColor:"#ee9900",fillOpacity:0.4,hoverFillColor:"white",hoverFillOpacity:0.8,strokeColor:"#ee9900",strokeOpacity:1,strokeWidth:1,strokeLinecap:"round",strokeDashstyle:"solid",hoverStrokeColor:"red",hoverStrokeOpacity:1,hoverStrokeWidth:0.2,pointRadius:6,hoverPointRadius:1,hoverPointUnit:"%",pointerEvents:"visiblePainted",cursor:"inherit"},select:{fillColor:"blue",fillOpacity:0.4,hoverFillColor:"white",hoverFillOpacity:0.8,strokeColor:"blue",strokeOpacity:1,strokeWidth:2,strokeLinecap:"round",strokeDashstyle:"solid",hoverStrokeColor:"red",hoverStrokeOpacity:1,hoverStrokeWidth:0.2,pointRadius:6,hoverPointRadius:1,hoverPointUnit:"%",pointerEvents:"visiblePainted",cursor:"pointer"},temporary:{fillColor:"#66cccc",fillOpacity:0.2,hoverFillColor:"white",hoverFillOpacity:0.8,strokeColor:"#66cccc",strokeOpacity:1,strokeLinecap:"round",strokeWidth:2,strokeDashstyle:"solid",hoverStrokeColor:"red",hoverStrokeOpacity:1,hoverStrokeWidth:0.2,pointRadius:6,hoverPointRadius:1,hoverPointUnit:"%",pointerEvents:"visiblePainted",cursor:"inherit"},"delete":{display:"none"}};OpenLayers.Feature.WFS=OpenLayers.Class(OpenLayers.Feature,{initialize:function(c,b){var a=arguments;var d=this.processXMLNode(b);a=new Array(c,d.lonlat,d);OpenLayers.Feature.prototype.initialize.apply(this,a);this.createMarker();this.layer.addMarker(this.marker)},destroy:function(){if(this.marker!=null){this.layer.removeMarker(this.marker)}OpenLayers.Feature.prototype.destroy.apply(this,arguments)},processXMLNode:function(b){var a=OpenLayers.Ajax.getElementsByTagNameNS(b,"http://www.opengis.net/gml","gml","Point");var d=OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(a[0],"http://www.opengis.net/gml","gml","coordinates")[0]);var c=d.split(",");return{lonlat:new OpenLayers.LonLat(parseFloat(c[0]),parseFloat(c[1])),id:null}},CLASS_NAME:"OpenLayers.Feature.WFS"});OpenLayers.Format.WFSCapabilities.v1=OpenLayers.Class(OpenLayers.Format.WFSCapabilities,{initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a]);this.options=a},read:function(c){if(typeof c=="string"){c=OpenLayers.Format.XML.prototype.read.apply(this,[c])}var a={};var b=c.documentElement;this.runChildNodes(a,b);return a},runChildNodes:function(g,f){var c=f.childNodes;var b,d;for(var a=0;a<c.length;++a){b=c[a];if(b.nodeType==1){d=this["read_cap_"+b.nodeName];if(d){d.apply(this,[g,b])}}}},read_cap_FeatureTypeList:function(c,b){var a={featureTypes:[]};this.runChildNodes(a,b);c.featureTypeList=a},read_cap_FeatureType:function(a,d,b){var c={};this.runChildNodes(c,d);a.featureTypes.push(c)},read_cap_Name:function(c,b){var a=this.getChildValue(b);if(a){c.name=a}},read_cap_Title:function(b,a){var c=this.getChildValue(a);if(c){b.title=c}},read_cap_Abstract:function(c,b){var a=this.getChildValue(b);if(a){c["abstract"]=a}},CLASS_NAME:"OpenLayers.Format.WFSCapabilities.v1"});OpenLayers.Format.WMC.v1=OpenLayers.Class(OpenLayers.Format.XML,{namespaces:{ol:"http://openlayers.org/context",wmc:"http://www.opengis.net/context",sld:"http://www.opengis.net/sld",xlink:"http://www.w3.org/1999/xlink",xsi:"http://www.w3.org/2001/XMLSchema-instance"},schemaLocation:"",getNamespacePrefix:function(a){var b=null;if(a==null){b=this.namespaces[this.defaultPrefix]}else{for(b in this.namespaces){if(this.namespaces[b]==a){break}}}return b},defaultPrefix:"wmc",rootPrefix:null,defaultStyleName:"",defaultStyleTitle:"Default",initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},read:function(c){if(typeof c=="string"){c=OpenLayers.Format.XML.prototype.read.apply(this,[c])}var a=c.documentElement;this.rootPrefix=a.prefix;var b={version:a.getAttribute("version")};this.runChildNodes(b,a);return b},runChildNodes:function(f,d){var b=d.childNodes;var a,c,h,k;for(var g=0,j=b.length;g<j;++g){a=b[g];if(a.nodeType==1){h=this.getNamespacePrefix(a.namespaceURI);k=a.nodeName.split(":").pop();c=this["read_"+h+"_"+k];if(c){c.apply(this,[f,a])}}}},read_wmc_General:function(a,b){this.runChildNodes(a,b)},read_wmc_BoundingBox:function(a,b){a.projection=b.getAttribute("SRS");a.bounds=new OpenLayers.Bounds(parseFloat(b.getAttribute("minx")),parseFloat(b.getAttribute("miny")),parseFloat(b.getAttribute("maxx")),parseFloat(b.getAttribute("maxy")))},read_wmc_LayerList:function(a,b){a.layers=[];this.runChildNodes(a,b)},read_wmc_Layer:function(b,c){var d={params:this.layerParams||{},options:{visibility:(c.getAttribute("hidden")!="1"),queryable:(c.getAttribute("queryable")=="1")},formats:[],styles:[]};this.runChildNodes(d,c);d.params.layers=d.name;d.options.maxExtent=d.maxExtent;var a=this.getLayerFromInfo(d);b.layers.push(a)},getLayerFromInfo:function(c){var a=c.options;if(this.layerOptions){OpenLayers.Util.applyDefaults(a,this.layerOptions)}var b=new OpenLayers.Layer.WMS(c.title,c.href,c.params,a);return b},read_wmc_Extension:function(b,a){this.runChildNodes(b,a)},read_ol_units:function(b,a){b.options.units=this.getChildValue(a)},read_ol_maxExtent:function(c,b){var a=new OpenLayers.Bounds(b.getAttribute("minx"),b.getAttribute("miny"),b.getAttribute("maxx"),b.getAttribute("maxy"));c.maxExtent=a},read_ol_transparent:function(b,a){b.params.transparent=this.getChildValue(a)},read_ol_numZoomLevels:function(b,a){b.options.numZoomLevels=parseInt(this.getChildValue(a))},read_ol_opacity:function(b,a){b.options.opacity=parseFloat(this.getChildValue(a))},read_ol_singleTile:function(b,a){b.options.singleTile=(this.getChildValue(a)=="true")},read_ol_isBaseLayer:function(b,a){b.options.isBaseLayer=(this.getChildValue(a)=="true")},read_ol_displayInLayerSwitcher:function(b,a){b.options.displayInLayerSwitcher=(this.getChildValue(a)=="true")},read_wmc_Server:function(b,a){b.params.version=a.getAttribute("version");this.runChildNodes(b,a)},read_wmc_FormatList:function(b,a){this.runChildNodes(b,a)},read_wmc_Format:function(c,a){var b=this.getChildValue(a);c.formats.push(b);if(a.getAttribute("current")=="1"){c.params.format=b}},read_wmc_StyleList:function(b,a){this.runChildNodes(b,a)},read_wmc_Style:function(c,b){var a={};this.runChildNodes(a,b);if(b.getAttribute("current")=="1"){if(a.href){c.params.sld=a.href}else{if(a.body){c.params.sld_body=a.body}else{c.params.styles=a.name}}}c.styles.push(a)},read_wmc_SLD:function(a,b){this.runChildNodes(a,b)},read_sld_StyledLayerDescriptor:function(c,b){var a=OpenLayers.Format.XML.prototype.write.apply(this,[b]);c.body=a},read_wmc_OnlineResource:function(b,a){b.href=this.getAttributeNS(a,this.namespaces.xlink,"href")},read_wmc_Name:function(c,b){var a=this.getChildValue(b);if(a){c.name=a}},read_wmc_Title:function(b,a){var c=this.getChildValue(a);if(c){b.title=c}},read_wmc_MetadataURL:function(c,b){var d={};var a=b.getElementsByTagName("OnlineResource");if(a.length>0){this.read_wmc_OnlineResource(d,a[0])}c.options.metadataURL=d.href},read_wmc_Abstract:function(c,b){var a=this.getChildValue(b);if(a){c["abstract"]=a}},read_wmc_LatLonBoundingBox:function(a,b){a.llbbox=[parseFloat(b.getAttribute("minx")),parseFloat(b.getAttribute("miny")),parseFloat(b.getAttribute("maxx")),parseFloat(b.getAttribute("maxy"))]},read_wmc_LegendURL:function(c,d){var b={width:d.getAttribute("width"),height:d.getAttribute("height")};var a=d.getElementsByTagName("OnlineResource");if(a.length>0){this.read_wmc_OnlineResource(b,a[0])}c.legend=b},write:function(c,b){var a=this.createElementDefaultNS("ViewContext");this.setAttributes(a,{version:this.VERSION,id:(b&&typeof b.id=="string")?b.id:OpenLayers.Util.createUniqueID("OpenLayers_Context_")});this.setAttributeNS(a,this.namespaces.xsi,"xsi:schemaLocation",this.schemaLocation);a.appendChild(this.write_wmc_General(c));a.appendChild(this.write_wmc_LayerList(c));return OpenLayers.Format.XML.prototype.write.apply(this,[a])},createElementDefaultNS:function(c,b,a){var d=this.createElementNS(this.namespaces[this.defaultPrefix],c);if(b){d.appendChild(this.createTextNode(b))}if(a){this.setAttributes(d,a)}return d},setAttributes:function(b,d){var c;for(var a in d){c=d[a].toString();if(c.match(/[A-Z]/)){this.setAttributeNS(b,null,a,c)}else{b.setAttribute(a,c)}}},write_wmc_General:function(a){var c=this.createElementDefaultNS("General");if(a.size){c.appendChild(this.createElementDefaultNS("Window",null,{width:a.size.w,height:a.size.h}))}var b=a.bounds;c.appendChild(this.createElementDefaultNS("BoundingBox",null,{minx:b.left.toPrecision(10),miny:b.bottom.toPrecision(10),maxx:b.right.toPrecision(10),maxy:b.top.toPrecision(10),SRS:a.projection}));c.appendChild(this.createElementDefaultNS("Title",a.title));c.appendChild(this.write_ol_MapExtension(a));return c},write_ol_MapExtension:function(b){var d=this.createElementDefaultNS("Extension");var c=b.maxExtent;if(c){var a=this.createElementNS(this.namespaces.ol,"ol:maxExtent");this.setAttributes(a,{minx:c.left.toPrecision(10),miny:c.bottom.toPrecision(10),maxx:c.right.toPrecision(10),maxy:c.top.toPrecision(10)});d.appendChild(a)}return d},write_wmc_LayerList:function(d){var f=this.createElementDefaultNS("LayerList");var c;for(var b=0,a=d.layers.length;b<a;++b){c=d.layers[b];if(c instanceof OpenLayers.Layer.WMS){f.appendChild(this.write_wmc_Layer(c))}}return f},write_wmc_Layer:function(a){var b=this.createElementDefaultNS("Layer",null,{queryable:a.queryable?"1":"0",hidden:a.visibility?"0":"1"});b.appendChild(this.write_wmc_Server(a));b.appendChild(this.createElementDefaultNS("Name",a.params.LAYERS));b.appendChild(this.createElementDefaultNS("Title",a.name));if(a.metadataURL){b.appendChild(this.write_wmc_MetadataURL(a))}b.appendChild(this.write_wmc_FormatList(a));b.appendChild(this.write_wmc_StyleList(a));b.appendChild(this.write_wmc_LayerExtension(a));return b},write_wmc_LayerExtension:function(g){var d=this.createElementDefaultNS("Extension");var a=g.maxExtent;var k=this.createElementNS(this.namespaces.ol,"ol:maxExtent");this.setAttributes(k,{minx:a.left.toPrecision(10),miny:a.bottom.toPrecision(10),maxx:a.right.toPrecision(10),maxy:a.top.toPrecision(10)});d.appendChild(k);var c=g.params.TRANSPARENT;if(c){var l=this.createElementNS(this.namespaces.ol,"ol:transparent");l.appendChild(this.createTextNode(c));d.appendChild(l)}var j=["numZoomLevels","units","isBaseLayer","opacity","displayInLayerSwitcher","singleTile"];var b;for(var f=0,h=j.length;f<h;++f){b=this.createOLPropertyNode(g,j[f]);if(b){d.appendChild(b)}}return d},createOLPropertyNode:function(b,c){var a=null;if(b[c]!=null){a=this.createElementNS(this.namespaces.ol,"ol:"+c);a.appendChild(this.createTextNode(b[c].toString()))}return a},write_wmc_Server:function(a){var b=this.createElementDefaultNS("Server");this.setAttributes(b,{service:"OGC:WMS",version:a.params.VERSION});b.appendChild(this.write_wmc_OnlineResource(a.url));return b},write_wmc_MetadataURL:function(a){var b=this.createElementDefaultNS("MetadataURL");b.appendChild(this.write_wmc_OnlineResource(a.metadataURL));return b},write_wmc_FormatList:function(a){var b=this.createElementDefaultNS("FormatList");b.appendChild(this.createElementDefaultNS("Format",a.params.FORMAT,{current:"1"}));return b},write_wmc_StyleList:function(f){var d=this.createElementDefaultNS("StyleList");var c=this.createElementDefaultNS("Style",null,{current:"1"});if(f.params.SLD){var b=this.createElementDefaultNS("SLD");var h=this.write_wmc_OnlineResource(f.params.SLD);b.appendChild(h);c.appendChild(b)}else{if(f.params.SLD_BODY){var b=this.createElementDefaultNS("SLD");var g=f.params.SLD_BODY;var j=OpenLayers.Format.XML.prototype.read.apply(this,[g]);var k=j.documentElement;if(b.ownerDocument&&b.ownerDocument.importNode){k=b.ownerDocument.importNode(k,true)}b.appendChild(k);c.appendChild(b)}else{var a=f.params.STYLES?f.params.STYLES:this.defaultStyleName;c.appendChild(this.createElementDefaultNS("Name",a));c.appendChild(this.createElementDefaultNS("Title",this.defaultStyleTitle))}}d.appendChild(c);return d},write_wmc_OnlineResource:function(a){var b=this.createElementDefaultNS("OnlineResource");this.setAttributeNS(b,this.namespaces.xlink,"xlink:type","simple");this.setAttributeNS(b,this.namespaces.xlink,"xlink:href",a);return b},CLASS_NAME:"OpenLayers.Format.WMC.v1"});OpenLayers.Format.WMSCapabilities.v1_1_0=OpenLayers.Class(OpenLayers.Format.WMSCapabilities.v1_1,{version:"1.1.0",initialize:function(a){OpenLayers.Format.WMSCapabilities.v1_1.prototype.initialize.apply(this,[a])},CLASS_NAME:"OpenLayers.Format.WMSCapabilities.v1_1_0"});OpenLayers.Format.WMSCapabilities.v1_1_1=OpenLayers.Class(OpenLayers.Format.WMSCapabilities.v1_1,{version:"1.1.1",initialize:function(a){OpenLayers.Format.WMSCapabilities.v1_1.prototype.initialize.apply(this,[a])},CLASS_NAME:"OpenLayers.Format.WMSCapabilities.v1_1_1"});OpenLayers.Format.WMSDescribeLayer.v1_1=OpenLayers.Class(OpenLayers.Format.WMSDescribeLayer,{initialize:function(a){OpenLayers.Format.WMSDescribeLayer.prototype.initialize.apply(this,[a])},read:function(h){if(typeof h=="string"){h=OpenLayers.Format.XML.prototype.read.apply(this,[h])}var b=h.documentElement;var f=b.childNodes;var a=[];for(var d=0;d<f.length;++d){childNode=f[d];nodeName=childNode.nodeName;if(nodeName=="LayerDescription"){var j="";var g="";var c="";if(childNode.getAttribute("owsType")){j=childNode.getAttribute("owsType");g=childNode.getAttribute("owsURL")}else{if(childNode.getAttribute("wfs")!=""){j="WFS";g=childNode.getAttribute("wfs")}else{if(childNode.getAttribute("wcs")!=""){j="WCS";g=childNode.getAttribute("wcs")}}}query=childNode.getElementsByTagName("Query");if(query.length>0){c=query[0].getAttribute("typeName");if(!c){c=query[0].getAttribute("typename")}}a.push({owsType:j,owsURL:g,typeName:c})}}return a},CLASS_NAME:"OpenLayers.Format.WMSDescribeLayer.v1_1"});OpenLayers.Handler.Box=OpenLayers.Class(OpenLayers.Handler,{dragHandler:null,boxDivClassName:"olHandlerBoxZoomBox",boxCharacteristics:null,initialize:function(c,b,a){OpenLayers.Handler.prototype.initialize.apply(this,arguments);var b={down:this.startBox,move:this.moveBox,out:this.removeBox,up:this.endBox};this.dragHandler=new OpenLayers.Handler.Drag(this,b,{keyMask:this.keyMask})},setMap:function(a){OpenLayers.Handler.prototype.setMap.apply(this,arguments);if(this.dragHandler){this.dragHandler.setMap(a)}},startBox:function(a){this.zoomBox=OpenLayers.Util.createDiv("zoomBox",this.dragHandler.start);this.zoomBox.className=this.boxDivClassName;this.zoomBox.style.zIndex=this.map.Z_INDEX_BASE.Popup-1;this.map.viewPortDiv.appendChild(this.zoomBox);OpenLayers.Element.addClass(this.map.viewPortDiv,"olDrawBox")},moveBox:function(g){var d=this.dragHandler.start.x;var b=this.dragHandler.start.y;var c=Math.abs(d-g.x);var a=Math.abs(b-g.y);this.zoomBox.style.width=Math.max(1,c)+"px";this.zoomBox.style.height=Math.max(1,a)+"px";this.zoomBox.style.left=g.x<d?g.x+"px":d+"px";this.zoomBox.style.top=g.y<b?g.y+"px":b+"px";var f=this.getBoxCharacteristics();if(f.newBoxModel){if(g.x>d){this.zoomBox.style.width=Math.max(1,c-f.xOffset)+"px"}if(g.y>b){this.zoomBox.style.height=Math.max(1,a-f.yOffset)+"px"}}},endBox:function(b){var a;if(Math.abs(this.dragHandler.start.x-b.x)>5||Math.abs(this.dragHandler.start.y-b.y)>5){var h=this.dragHandler.start;var g=Math.min(h.y,b.y);var c=Math.max(h.y,b.y);var f=Math.min(h.x,b.x);var d=Math.max(h.x,b.x);a=new OpenLayers.Bounds(f,c,d,g)}else{a=this.dragHandler.start.clone()}this.removeBox();this.callback("done",[a])},removeBox:function(){this.map.viewPortDiv.removeChild(this.zoomBox);this.zoomBox=null;this.boxCharacteristics=null;OpenLayers.Element.removeClass(this.map.viewPortDiv,"olDrawBox")},activate:function(){if(OpenLayers.Handler.prototype.activate.apply(this,arguments)){this.dragHandler.activate();return true}else{return false}},deactivate:function(){if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){this.dragHandler.deactivate();return true}else{return false}},getBoxCharacteristics:function(){if(!this.boxCharacteristics){var a=parseInt(OpenLayers.Element.getStyle(this.zoomBox,"border-left-width"))+parseInt(OpenLayers.Element.getStyle(this.zoomBox,"border-right-width"))+1;var c=parseInt(OpenLayers.Element.getStyle(this.zoomBox,"border-top-width"))+parseInt(OpenLayers.Element.getStyle(this.zoomBox,"border-bottom-width"))+1;var b=OpenLayers.Util.getBrowserName()=="msie"?document.compatMode!="BackCompat":true;this.boxCharacteristics={xOffset:a,yOffset:c,newBoxModel:b}}return this.boxCharacteristics},CLASS_NAME:"OpenLayers.Handler.Box"});OpenLayers.Handler.RegularPolygon=OpenLayers.Class(OpenLayers.Handler.Drag,{sides:4,radius:null,snapAngle:null,snapToggle:"shiftKey",persist:false,irregular:false,angle:null,fixedRadius:false,feature:null,layer:null,origin:null,initialize:function(c,b,a){this.style=OpenLayers.Util.extend(OpenLayers.Feature.Vector.style["default"],{});OpenLayers.Handler.prototype.initialize.apply(this,[c,b,a]);this.options=(a)?a:new Object()},setOptions:function(a){OpenLayers.Util.extend(this.options,a);OpenLayers.Util.extend(this,a)},activate:function(){var a=false;if(OpenLayers.Handler.prototype.activate.apply(this,arguments)){var b={displayInLayerSwitcher:false,calculateInRange:function(){return true}};this.layer=new OpenLayers.Layer.Vector(this.CLASS_NAME,b);this.map.addLayer(this.layer);a=true}return a},deactivate:function(){var a=false;if(OpenLayers.Handler.Drag.prototype.deactivate.apply(this,arguments)){if(this.dragging){this.cancel()}if(this.layer.map!=null){this.layer.destroy(false);if(this.feature){this.feature.destroy()}}this.layer=null;this.feature=null;a=true}return a},down:function(a){this.fixedRadius=!!(this.radius);var b=this.map.getLonLatFromPixel(a.xy);this.origin=new OpenLayers.Geometry.Point(b.lon,b.lat);if(!this.fixedRadius||this.irregular){this.radius=this.map.getResolution()}if(this.persist){this.clear()}this.feature=new OpenLayers.Feature.Vector();this.createGeometry();this.callback("create",[this.origin,this.feature]);this.layer.addFeatures([this.feature],{silent:true});this.layer.drawFeature(this.feature,this.style)},move:function(c){var g=this.map.getLonLatFromPixel(c.xy);var a=new OpenLayers.Geometry.Point(g.lon,g.lat);if(this.irregular){var h=Math.sqrt(2)*Math.abs(a.y-this.origin.y)/2;this.radius=Math.max(this.map.getResolution()/2,h)}else{if(this.fixedRadius){this.origin=a}else{this.calculateAngle(a,c);this.radius=Math.max(this.map.getResolution()/2,a.distanceTo(this.origin))}}this.modifyGeometry();if(this.irregular){var d=a.x-this.origin.x;var b=a.y-this.origin.y;var f;if(b==0){f=d/(this.radius*Math.sqrt(2))}else{f=d/b}this.feature.geometry.resize(1,this.origin,f);this.feature.geometry.move(d/2,b/2)}this.layer.drawFeature(this.feature,this.style)},up:function(a){this.finalize();if(this.start==this.last){this.callback("done",[a.xy])}},out:function(a){this.finalize()},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 g,c,b,a;var d=this.feature.geometry.components[0];if(d.components.length!=(this.sides+1)){this.createGeometry();d=this.feature.geometry.components[0]}for(var f=0;f<this.sides;++f){a=d.components[f];g=this.angle+(f*2*Math.PI/this.sides);a.x=this.origin.x+(this.radius*Math.cos(g));a.y=this.origin.y+(this.radius*Math.sin(g));a.clearBounds()}},calculateAngle:function(a,b){var d=Math.atan2(a.y-this.origin.y,a.x-this.origin.x);if(this.snapAngle&&(this.snapToggle&&!b[this.snapToggle])){var c=(Math.PI/180)*this.snapAngle;this.angle=Math.round(d/c)*c}else{this.angle=d}},cancel:function(){this.callback("cancel",null);this.finalize()},finalize:function(){this.origin=null;this.radius=this.options.radius},clear:function(){this.layer.renderer.clear();this.layer.destroyFeatures()},callback:function(b,a){if(this.callbacks[b]){this.callbacks[b].apply(this.control,[this.feature.geometry.clone()])}if(!this.persist&&(b=="done"||b=="cancel")){this.clear()}},CLASS_NAME:"OpenLayers.Handler.RegularPolygon"});OpenLayers.Layer.EventPane=OpenLayers.Class(OpenLayers.Layer,{smoothDragPan:true,isBaseLayer:true,isFixed:true,pane:null,mapObject:null,initialize:function(b,a){OpenLayers.Layer.prototype.initialize.apply(this,arguments);if(this.pane==null){this.pane=OpenLayers.Util.createDiv(this.div.id+"_EventPane")}},destroy:function(){this.mapObject=null;OpenLayers.Layer.prototype.destroy.apply(this,arguments)},setMap:function(a){OpenLayers.Layer.prototype.setMap.apply(this,arguments);this.pane.style.zIndex=parseInt(this.div.style.zIndex)+1;this.pane.style.display=this.div.style.display;this.pane.style.width="100%";this.pane.style.height="100%";if(OpenLayers.Util.getBrowserName()=="msie"){this.pane.style.background="url("+OpenLayers.Util.getImagesLocation()+"blank.gif)"}if(this.isFixed){this.map.viewPortDiv.appendChild(this.pane)}else{this.map.layerContainerDiv.appendChild(this.pane)}this.loadMapObject();if(this.mapObject==null){this.loadWarningMessage()}},removeMap:function(a){if(this.pane&&this.pane.parentNode){this.pane.parentNode.removeChild(this.pane);this.pane=null}OpenLayers.Layer.prototype.removeMap.apply(this,arguments)},loadWarningMessage:function(){this.div.style.backgroundColor="darkblue";var h=this.map.getSize();var a=Math.min(h.w,300);var f=Math.min(h.h,200);var b=new OpenLayers.Size(a,f);var d=new OpenLayers.Pixel(h.w/2,h.h/2);var c=d.add(-b.w/2,-b.h/2);var g=OpenLayers.Util.createDiv(this.name+"_warning",c,b,null,null,null,"auto");g.style.padding="7px";g.style.backgroundColor="yellow";g.innerHTML=this.getWarningHTML();this.div.appendChild(g)},getWarningHTML:function(){return""},display:function(a){OpenLayers.Layer.prototype.display.apply(this,arguments);this.pane.style.display=this.div.style.display},setZIndex:function(a){OpenLayers.Layer.prototype.setZIndex.apply(this,arguments);this.pane.style.zIndex=parseInt(this.div.style.zIndex)+1},moveTo:function(c,d,l){OpenLayers.Layer.prototype.moveTo.apply(this,arguments);if(this.mapObject!=null){var f=this.map.getCenter();var h=this.map.getZoom();if(f!=null){var g=this.getMapObjectCenter();var b=this.getOLLonLatFromMapObjectLonLat(g);var j=this.getMapObjectZoom();var q=this.getOLZoomFromMapObjectZoom(j);if(!(f.equals(b))||!(h==q)){if(l&&this.dragPanMapObject&&this.smoothDragPan){var k=this.map.getViewPortPxFromLonLat(b);var m=this.map.getViewPortPxFromLonLat(f);this.dragPanMapObject(m.x-k.x,k.y-m.y)}else{var a=this.getMapObjectLonLatFromOLLonLat(f);var o=this.getMapObjectZoomFromOLZoom(h);this.setMapObjectCenter(a,o,l)}}}}},getLonLatFromViewPortPx:function(a){var b=null;if((this.mapObject!=null)&&(this.getMapObjectCenter()!=null)){var d=this.getMapObjectPixelFromOLPixel(a);var c=this.getMapObjectLonLatFromMapObjectPixel(d);b=this.getOLLonLatFromMapObjectLonLat(c)}return b},getViewPortPxFromLonLat:function(b){var a=null;if((this.mapObject!=null)&&(this.getMapObjectCenter()!=null)){var d=this.getMapObjectLonLatFromOLLonLat(b);var c=this.getMapObjectPixelFromMapObjectLonLat(d);a=this.getOLPixelFromMapObjectPixel(c)}return a},getOLLonLatFromMapObjectLonLat:function(d){var a=null;if(d!=null){var c=this.getLongitudeFromMapObjectLonLat(d);var b=this.getLatitudeFromMapObjectLonLat(d);a=new OpenLayers.LonLat(c,b)}return a},getMapObjectLonLatFromOLLonLat:function(a){var b=null;if(a!=null){b=this.getMapObjectLonLatFromLonLat(a.lon,a.lat)}return b},getOLPixelFromMapObjectPixel:function(d){var b=null;if(d!=null){var a=this.getXFromMapObjectPixel(d);var c=this.getYFromMapObjectPixel(d);b=new OpenLayers.Pixel(a,c)}return b},getMapObjectPixelFromOLPixel:function(a){var b=null;if(a!=null){b=this.getMapObjectPixelFromXY(a.x,a.y)}return b},CLASS_NAME:"OpenLayers.Layer.EventPane"});OpenLayers.Layer.FixedZoomLevels=OpenLayers.Class({initialize:function(){},initResolutions:function(){var c=new Array("minZoomLevel","maxZoomLevel","numZoomLevels");for(var b=0,a=c.length;b<a;b++){var g=c[b];this[g]=(this.options[g]!=null)?this.options[g]:this.map[g]}if((this.minZoomLevel==null)||(this.minZoomLevel<this.MIN_ZOOM_LEVEL)){this.minZoomLevel=this.MIN_ZOOM_LEVEL}var h;var f=this.MAX_ZOOM_LEVEL-this.minZoomLevel+1;if(((this.options.numZoomLevels==null)&&(this.options.maxZoomLevel!=null))||((this.numZoomLevels==null)&&(this.maxZoomLevel!=null))){h=this.maxZoomLevel-this.minZoomLevel+1}else{h=this.numZoomLevels}if(h!=null){this.numZoomLevels=Math.min(h,f)}else{this.numZoomLevels=f}this.maxZoomLevel=this.minZoomLevel+this.numZoomLevels-1;if(this.RESOLUTIONS!=null){var d=0;this.resolutions=[];for(var b=this.minZoomLevel;b<=this.maxZoomLevel;b++){this.resolutions[d++]=this.RESOLUTIONS[b]}this.maxResolution=this.resolutions[0];this.minResolution=this.resolutions[this.resolutions.length-1]}},getResolution:function(){if(this.resolutions!=null){return OpenLayers.Layer.prototype.getResolution.apply(this,arguments)}else{var a=null;var c=this.map.getSize();var b=this.getExtent();if((c!=null)&&(b!=null)){a=Math.max(b.getWidth()/c.w,b.getHeight()/c.h)}return a}},getExtent:function(){var c=null;var b=this.map.getSize();var f=new OpenLayers.Pixel(0,0);var g=this.getLonLatFromViewPortPx(f);var a=new OpenLayers.Pixel(b.w,b.h);var d=this.getLonLatFromViewPortPx(a);if((g!=null)&&(d!=null)){c=new OpenLayers.Bounds(g.lon,d.lat,d.lon,g.lat)}return c},getZoomForResolution:function(a){if(this.resolutions!=null){return OpenLayers.Layer.prototype.getZoomForResolution.apply(this,arguments)}else{var b=OpenLayers.Layer.prototype.getExtent.apply(this,[]);return this.getZoomForExtent(b)}},getOLZoomFromMapObjectZoom:function(a){var b=null;if(a!=null){b=a-this.minZoomLevel}return b},getMapObjectZoomFromOLZoom:function(a){var b=null;if(a!=null){b=a+this.minZoomLevel}return b},CLASS_NAME:"OpenLayers.Layer.FixedZoomLevels"});OpenLayers.Layer.HTTPRequest=OpenLayers.Class(OpenLayers.Layer,{URL_HASH_FACTOR:(Math.sqrt(5)-1)/2,url:null,params:null,reproject:false,initialize:function(d,c,f,b){var a=arguments;a=[d,b];OpenLayers.Layer.prototype.initialize.apply(this,a);this.url=c;this.params=OpenLayers.Util.extend({},f)},destroy:function(){this.url=null;this.params=null;OpenLayers.Layer.prototype.destroy.apply(this,arguments)},clone:function(a){if(a==null){a=new OpenLayers.Layer.HTTPRequest(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.prototype.clone.apply(this,[a]);return a},setUrl:function(a){this.url=a},mergeNewParams:function(a){this.params=OpenLayers.Util.extend(this.params,a);return this.redraw()},redraw:function(a){if(a){return this.mergeNewParams({_olSalt:Math.random()})}else{return OpenLayers.Layer.prototype.redraw.apply(this,[])}},selectUrl:function(f,d){var c=1;for(var b=0,a=f.length;b<a;b++){c*=f.charCodeAt(b)*this.URL_HASH_FACTOR;c-=Math.floor(c)}return d[Math.floor(c*d.length)]},getFullRequestString:function(g,f){var b=f||this.url;var h=OpenLayers.Util.extend({},this.params);h=OpenLayers.Util.extend(h,g);var a=OpenLayers.Util.getParameterString(h);if(b instanceof Array){b=this.selectUrl(a,b)}var d=OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(b));for(var j in h){if(j.toUpperCase() in d){delete h[j]}}a=OpenLayers.Util.getParameterString(h);var k=b;if(a!=""){var c=b.charAt(b.length-1);if((c=="&")||(c=="?")){k+=a}else{if(b.indexOf("?")==-1){k+="?"+a}else{k+="&"+a}}}return k},CLASS_NAME:"OpenLayers.Layer.HTTPRequest"});OpenLayers.Layer.Image=OpenLayers.Class(OpenLayers.Layer,{isBaseLayer:true,url:null,extent:null,size:null,tile:null,aspectRatio:null,initialize:function(c,b,f,d,a){this.url=b;this.extent=f;this.maxExtent=f;this.size=d;OpenLayers.Layer.prototype.initialize.apply(this,[c,a]);this.aspectRatio=(this.extent.getHeight()/this.size.h)/(this.extent.getWidth()/this.size.w)},destroy:function(){if(this.tile){this.removeTileMonitoringHooks(this.tile);this.tile.destroy();this.tile=null}OpenLayers.Layer.prototype.destroy.apply(this,arguments)},clone:function(a){if(a==null){a=new OpenLayers.Layer.Image(this.name,this.url,this.extent,this.size,this.options)}a=OpenLayers.Layer.prototype.clone.apply(this,[a]);return a},setMap:function(a){if(this.options.maxResolution==null){this.options.maxResolution=this.aspectRatio*this.extent.getWidth()/this.size.w}OpenLayers.Layer.prototype.setMap.apply(this,arguments)},moveTo:function(f,a,g){OpenLayers.Layer.prototype.moveTo.apply(this,arguments);var b=(this.tile==null);if(a||b){this.setTileSize();var d=new OpenLayers.LonLat(this.extent.left,this.extent.top);var c=this.map.getLayerPxFromLonLat(d);if(b){this.tile=new OpenLayers.Tile.Image(this,c,this.extent,null,this.tileSize);this.addTileMonitoringHooks(this.tile)}else{this.tile.size=this.tileSize.clone();this.tile.position=c.clone()}this.tile.draw()}},setTileSize:function(){var b=this.extent.getWidth()/this.map.getResolution();var a=this.extent.getHeight()/this.map.getResolution();this.tileSize=new OpenLayers.Size(b,a)},addTileMonitoringHooks:function(a){a.onLoadStart=function(){this.events.triggerEvent("loadstart")};a.events.register("loadstart",this,a.onLoadStart);a.onLoadEnd=function(){this.events.triggerEvent("loadend")};a.events.register("loadend",this,a.onLoadEnd);a.events.register("unload",this,a.onLoadEnd)},removeTileMonitoringHooks:function(a){a.unload();a.events.un({loadstart:a.onLoadStart,loadend:a.onLoadEnd,unload:a.onLoadEnd,scope:this})},setUrl:function(a){this.url=a;this.tile.draw()},getURL:function(a){return this.url},CLASS_NAME:"OpenLayers.Layer.Image"});OpenLayers.Layer.Markers=OpenLayers.Class(OpenLayers.Layer,{isBaseLayer:false,markers:null,drawn:false,initialize:function(b,a){OpenLayers.Layer.prototype.initialize.apply(this,arguments);this.markers=[]},destroy:function(){this.clearMarkers();this.markers=null;OpenLayers.Layer.prototype.destroy.apply(this,arguments)},setOpacity:function(b){if(b!=this.opacity){this.opacity=b;for(var c=0,a=this.markers.length;c<a;c++){this.markers[c].setOpacity(this.opacity)}}},moveTo:function(d,b,f){OpenLayers.Layer.prototype.moveTo.apply(this,arguments);if(b||!this.drawn){for(var c=0,a=this.markers.length;c<a;c++){this.drawMarker(this.markers[c])}this.drawn=true}},addMarker:function(a){this.markers.push(a);if(this.opacity!=null){a.setOpacity(this.opacity)}if(this.map&&this.map.getExtent()){a.map=this.map;this.drawMarker(a)}},removeMarker:function(a){if(this.markers&&this.markers.length){OpenLayers.Util.removeItem(this.markers,a);a.erase()}},clearMarkers:function(){if(this.markers!=null){while(this.markers.length>0){this.removeMarker(this.markers[0])}}},drawMarker:function(a){var b=this.map.getLayerPxFromLonLat(a.lonlat);if(b==null){a.display(false)}else{if(!a.isDrawn()){var c=a.draw(b);this.div.appendChild(c)}else{if(a.icon){a.icon.moveTo(b)}}}},getDataExtent:function(){var b=null;if(this.markers&&(this.markers.length>0)){var b=new OpenLayers.Bounds();for(var d=0,a=this.markers.length;d<a;d++){var c=this.markers[d];b.extend(c.lonlat)}}return b},CLASS_NAME:"OpenLayers.Layer.Markers"});OpenLayers.Layer.SphericalMercator={getExtent:function(){var a=null;if(this.sphericalMercator){a=this.map.calculateBounds()}else{a=OpenLayers.Layer.FixedZoomLevels.prototype.getExtent.apply(this)}return a},initMercatorParameters:function(){this.RESOLUTIONS=[];var a=156543.0339;for(var b=0;b<=this.MAX_ZOOM_LEVEL;++b){this.RESOLUTIONS[b]=a/Math.pow(2,b)}this.units="m";this.projection="EPSG:900913"},forwardMercator:function(c,b){var a=c*20037508.34/180;var d=Math.log(Math.tan((90+b)*Math.PI/360))/(Math.PI/180);d=d*20037508.34/180;return new OpenLayers.LonLat(a,d)},inverseMercator:function(a,d){var c=(a/20037508.34)*180;var b=(d/20037508.34)*180;b=180/Math.PI*(2*Math.atan(Math.exp(b*Math.PI/180))-Math.PI/2);return new OpenLayers.LonLat(c,b)},projectForward:function(a){var b=OpenLayers.Layer.SphericalMercator.forwardMercator(a.x,a.y);a.x=b.lon;a.y=b.lat;return a},projectInverse:function(a){var b=OpenLayers.Layer.SphericalMercator.inverseMercator(a.x,a.y);a.x=b.lon;a.y=b.lat;return a}};OpenLayers.Projection.addTransform("EPSG:4326","EPSG:900913",OpenLayers.Layer.SphericalMercator.projectForward);OpenLayers.Projection.addTransform("EPSG:900913","EPSG:4326",OpenLayers.Layer.SphericalMercator.projectInverse);OpenLayers.Tile.WFS=OpenLayers.Class(OpenLayers.Tile,{features:null,url:null,request:null,initialize:function(d,a,f,b,c){OpenLayers.Tile.prototype.initialize.apply(this,arguments);this.url=b;this.features=[]},destroy:function(){OpenLayers.Tile.prototype.destroy.apply(this,arguments);this.destroyAllFeatures();this.features=null;this.url=null;if(this.request){this.request.abort();this.request=null}},clear:function(){this.destroyAllFeatures()},draw:function(){if(OpenLayers.Tile.prototype.draw.apply(this,arguments)){if(this.isLoading){this.events.triggerEvent("reload")}else{this.isLoading=true;this.events.triggerEvent("loadstart")}this.loadFeaturesForRegion(this.requestSuccess)}},loadFeaturesForRegion:function(b,a){if(this.request){this.request.abort()}this.request=OpenLayers.Request.GET({url:this.url,success:b,failure:a,scope:this})},requestSuccess:function(b){if(this.features){var d=b.responseXML;if(!d||!d.documentElement){d=b.responseText}if(this.layer.vectorMode){this.layer.addFeatures(this.layer.formatObject.read(d))}else{var a=new OpenLayers.Format.XML();if(typeof d=="string"){d=a.read(d)}var c=a.getElementsByTagNameNS(d,"http://www.opengis.net/gml","featureMember");this.addResults(c)}}if(this.events){this.events.triggerEvent("loadend")}this.request=null},addResults:function(c){for(var b=0;b<c.length;b++){var a=new this.layer.featureClass(this.layer,c[b]);this.features.push(a)}},destroyAllFeatures:function(){while(this.features.length>0){var a=this.features.shift();a.destroy()}},CLASS_NAME:"OpenLayers.Tile.WFS"});OpenLayers.Control.DrawFeature=OpenLayers.Class(OpenLayers.Control,{layer:null,callbacks:null,EVENT_TYPES:["featureadded"],featureAdded:function(){},handlerOptions:null,initialize:function(b,c,a){this.EVENT_TYPES=OpenLayers.Control.DrawFeature.prototype.EVENT_TYPES.concat(OpenLayers.Control.prototype.EVENT_TYPES);OpenLayers.Control.prototype.initialize.apply(this,[a]);this.callbacks=OpenLayers.Util.extend({done:this.drawFeature,modify:function(g,f){this.layer.events.triggerEvent("sketchmodified",{vertex:g,feature:f})},create:function(g,f){this.layer.events.triggerEvent("sketchstarted",{vertex:g,feature:f})}},this.callbacks);this.layer=b;var d=this.layer.styleMap&&this.layer.styleMap.styles.temporary;if(d){this.handlerOptions=this.handlerOptions||{};this.handlerOptions.layerOptions=OpenLayers.Util.applyDefaults(this.handlerOptions.layerOptions,{styleMap:new OpenLayers.StyleMap({"default":d})})}this.handler=new c(this,this.callbacks,this.handlerOptions)},drawFeature:function(c){var a=new OpenLayers.Feature.Vector(c);var b=this.layer.events.triggerEvent("sketchcomplete",{feature:a});if(b!==false){a.state=OpenLayers.State.INSERT;this.layer.addFeatures([a]);this.featureAdded(a);this.events.triggerEvent("featureadded",{feature:a})}},CLASS_NAME:"OpenLayers.Control.DrawFeature"});OpenLayers.Control.Measure=OpenLayers.Class(OpenLayers.Control,{EVENT_TYPES:["measure","measurepartial"],handlerOptions:null,callbacks:null,displaySystem:"metric",geodesic:false,displaySystemUnits:{geographic:["dd"],english:["mi","ft","in"],metric:["km","m"]},partialDelay:300,delayedTrigger:null,persist:false,initialize:function(b,a){this.EVENT_TYPES=OpenLayers.Control.Measure.prototype.EVENT_TYPES.concat(OpenLayers.Control.prototype.EVENT_TYPES);OpenLayers.Control.prototype.initialize.apply(this,[a]);this.callbacks=OpenLayers.Util.extend({done:this.measureComplete,point:this.measurePartial},this.callbacks);this.handlerOptions=OpenLayers.Util.extend({persist:this.persist},this.handlerOptions);this.handler=new b(this,this.callbacks,this.handlerOptions)},cancel:function(){this.handler.cancel()},updateHandler:function(b,a){var c=this.active;if(c){this.deactivate()}this.handler=new b(this,this.callbacks,a);if(c){this.activate()}},measureComplete:function(a){if(this.delayedTrigger){window.clearTimeout(this.delayedTrigger)}this.measure(a,"measure")},measurePartial:function(a,b){this.delayedTrigger=window.setTimeout(OpenLayers.Function.bind(function(){this.measure(b,"measurepartial")},this),this.partialDelay)},measure:function(d,b){var c,a;if(d.CLASS_NAME.indexOf("LineString")>-1){c=this.getBestLength(d);a=1}else{c=this.getBestArea(d);a=2}this.events.triggerEvent(b,{measure:c[0],units:c[1],order:a,geometry:d})},getBestArea:function(g){var b=this.displaySystemUnits[this.displaySystem];var f,d;for(var c=0,a=b.length;c<a;++c){f=b[c];d=this.getArea(g,f);if(d>1){break}}return[d,f]},getArea:function(g,a){var b,c;if(this.geodesic){b=g.getGeodesicArea(this.map.getProjectionObject());c="m"}else{b=g.getArea();c=this.map.getUnits()}var f=OpenLayers.INCHES_PER_UNIT[a];if(f){var d=OpenLayers.INCHES_PER_UNIT[c];b*=Math.pow((d/f),2)}return b},getBestLength:function(g){var b=this.displaySystemUnits[this.displaySystem];var f,d;for(var c=0,a=b.length;c<a;++c){f=b[c];d=this.getLength(g,f);if(d>1){break}}return[d,f]},getLength:function(g,a){var b,c;if(this.geodesic){b=g.getGeodesicLength(this.map.getProjectionObject());c="m"}else{b=g.getLength();c=this.map.getUnits()}var f=OpenLayers.INCHES_PER_UNIT[a];if(f){var d=OpenLayers.INCHES_PER_UNIT[c];b*=(d/f)}return b},CLASS_NAME:"OpenLayers.Control.Measure"});OpenLayers.Control.ZoomBox=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOOL,out:false,alwaysZoom:false,draw:function(){this.handler=new OpenLayers.Handler.Box(this,{done:this.zoomBox},{keyMask:this.keyMask})},zoomBox:function(j){if(j instanceof OpenLayers.Bounds){if(!this.out){var k=this.map.getLonLatFromPixel(new OpenLayers.Pixel(j.left,j.bottom));var q=this.map.getLonLatFromPixel(new OpenLayers.Pixel(j.right,j.top));var b=new OpenLayers.Bounds(k.lon,k.lat,q.lon,q.lat)}else{var h=Math.abs(j.right-j.left);var l=Math.abs(j.top-j.bottom);var f=Math.min((this.map.size.h/l),(this.map.size.w/h));var r=this.map.getExtent();var a=this.map.getLonLatFromPixel(j.getCenterPixel());var c=a.lon-(r.getWidth()/2)*f;var g=a.lon+(r.getWidth()/2)*f;var o=a.lat-(r.getHeight()/2)*f;var d=a.lat+(r.getHeight()/2)*f;var b=new OpenLayers.Bounds(c,o,g,d)}var m=this.map.getZoom();this.map.zoomToExtent(b);if(m==this.map.getZoom()&&this.alwaysZoom==true){this.map.zoomTo(m+(this.out?-1:1))}}else{if(!this.out){this.map.setCenter(this.map.getLonLatFromPixel(j),this.map.getZoom()+1)}else{this.map.setCenter(this.map.getLonLatFromPixel(j),this.map.getZoom()-1)}}},CLASS_NAME:"OpenLayers.Control.ZoomBox"});OpenLayers.Format.WFSCapabilities.v1_0_0=OpenLayers.Class(OpenLayers.Format.WFSCapabilities.v1,{initialize:function(a){OpenLayers.Format.WFSCapabilities.v1.prototype.initialize.apply(this,[a])},CLASS_NAME:"OpenLayers.Format.WFSCapabilities.v1_0_0"});OpenLayers.Format.WFSCapabilities.v1_1_0=OpenLayers.Class(OpenLayers.Format.WFSCapabilities.v1,{initialize:function(a){OpenLayers.Format.WFSCapabilities.v1.prototype.initialize.apply(this,[a])},CLASS_NAME:"OpenLayers.Format.WFSCapabilities.v1_1_0"});OpenLayers.Format.WKT=OpenLayers.Class(OpenLayers.Format,{initialize:function(a){this.regExes={typeStr:/^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,spaces:/\s+/,parenComma:/\)\s*,\s*\(/,doubleParenComma:/\)\s*\)\s*,\s*\(\s*\(/,trimParens:/^\s*\(?(.*?)\)?\s*$/};OpenLayers.Format.prototype.initialize.apply(this,[a])},read:function(g){var f,d,j;var h=this.regExes.typeStr.exec(g);if(h){d=h[1].toLowerCase();j=h[2];if(this.parse[d]){f=this.parse[d].apply(this,[j])}if(this.internalProjection&&this.externalProjection){if(f&&f.CLASS_NAME=="OpenLayers.Feature.Vector"){f.geometry.transform(this.externalProjection,this.internalProjection)}else{if(f&&d!="geometrycollection"&&typeof f=="object"){for(var c=0,a=f.length;c<a;c++){var b=f[c];b.geometry.transform(this.externalProjection,this.internalProjection)}}}}}return f},write:function(a){var g,k,j,d,b;if(a.constructor==Array){g=a;b=true}else{g=[a];b=false}var c=[];if(b){c.push("GEOMETRYCOLLECTION(")}for(var f=0,h=g.length;f<h;++f){if(b&&f>0){c.push(",")}k=g[f].geometry;j=k.CLASS_NAME.split(".")[2].toLowerCase();if(!this.extract[j]){return null}if(this.internalProjection&&this.externalProjection){k=k.clone();k.transform(this.internalProjection,this.externalProjection)}d=this.extract[j].apply(this,[k]);c.push(j.toUpperCase()+"("+d+")")}if(b){c.push(")")}return c.join("")},extract:{point:function(a){return a.x+" "+a.y},multipoint:function(c){var d=[];for(var b=0,a=c.components.length;b<a;++b){d.push(this.extract.point.apply(this,[c.components[b]]))}return d.join(",")},linestring:function(b){var d=[];for(var c=0,a=b.components.length;c<a;++c){d.push(this.extract.point.apply(this,[b.components[c]]))}return d.join(",")},multilinestring:function(c){var d=[];for(var b=0,a=c.components.length;b<a;++b){d.push("("+this.extract.linestring.apply(this,[c.components[b]])+")")}return d.join(",")},polygon:function(c){var d=[];for(var b=0,a=c.components.length;b<a;++b){d.push("("+this.extract.linestring.apply(this,[c.components[b]])+")")}return d.join(",")},multipolygon:function(d){var c=[];for(var b=0,a=d.components.length;b<a;++b){c.push("("+this.extract.polygon.apply(this,[d.components[b]])+")")}return c.join(",")}},parse:{point:function(b){var a=OpenLayers.String.trim(b).split(this.regExes.spaces);return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(a[0],a[1]))},multipoint:function(f){var c=OpenLayers.String.trim(f).split(",");var d=[];for(var b=0,a=c.length;b<a;++b){d.push(this.parse.point.apply(this,[c[b]]).geometry)}return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPoint(d))},linestring:function(f){var c=OpenLayers.String.trim(f).split(",");var d=[];for(var b=0,a=c.length;b<a;++b){d.push(this.parse.point.apply(this,[c[b]]).geometry)}return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(d))},multilinestring:function(g){var c;var b=OpenLayers.String.trim(g).split(this.regExes.parenComma);var f=[];for(var d=0,a=b.length;d<a;++d){c=b[d].replace(this.regExes.trimParens,"$1");f.push(this.parse.linestring.apply(this,[c]).geometry)}return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiLineString(f))},polygon:function(j){var c,b,g;var h=OpenLayers.String.trim(j).split(this.regExes.parenComma);var f=[];for(var d=0,a=h.length;d<a;++d){c=h[d].replace(this.regExes.trimParens,"$1");b=this.parse.linestring.apply(this,[c]).geometry;g=new OpenLayers.Geometry.LinearRing(b.components);f.push(g)}return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon(f))},multipolygon:function(g){var d;var b=OpenLayers.String.trim(g).split(this.regExes.doubleParenComma);var f=[];for(var c=0,a=b.length;c<a;++c){d=b[c].replace(this.regExes.trimParens,"$1");f.push(this.parse.polygon.apply(this,[d]).geometry)}return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPolygon(f))},geometrycollection:function(f){f=f.replace(/,\s*([A-Za-z])/g,"|$1");var d=OpenLayers.String.trim(f).split("|");var c=[];for(var b=0,a=d.length;b<a;++b){c.push(OpenLayers.Format.WKT.prototype.read.apply(this,[d[b]]))}return c}},CLASS_NAME:"OpenLayers.Format.WKT"});OpenLayers.Format.WMC.v1_0_0=OpenLayers.Class(OpenLayers.Format.WMC.v1,{VERSION:"1.0.0",schemaLocation:"http://www.opengis.net/context http://schemas.opengis.net/context/1.0.0/context.xsd",initialize:function(a){OpenLayers.Format.WMC.v1.prototype.initialize.apply(this,[a])},CLASS_NAME:"OpenLayers.Format.WMC.v1_0_0"});OpenLayers.Format.WMC.v1_1_0=OpenLayers.Class(OpenLayers.Format.WMC.v1,{VERSION:"1.1.0",schemaLocation:"http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd",initialize:function(a){OpenLayers.Format.WMC.v1.prototype.initialize.apply(this,[a])},read_sld_MinScaleDenominator:function(b,a){b.options.maxScale=this.getChildValue(a)},read_sld_MaxScaleDenominator:function(b,a){b.options.minScale=this.getChildValue(a)},write_wmc_Layer:function(b){var c=OpenLayers.Format.WMC.v1.prototype.write_wmc_Layer.apply(this,[b]);if(b.options.resolutions||b.options.scales||b.options.minResolution||b.options.maxScale){var d=this.createElementNS(this.namespaces.sld,"sld:MinScaleDenominator");d.appendChild(this.createTextNode(b.maxScale.toPrecision(10)));c.insertBefore(d,c.childNodes[3])}if(b.options.resolutions||b.options.scales||b.options.maxResolution||b.options.minScale){var a=this.createElementNS(this.namespaces.sld,"sld:MaxScaleDenominator");a.appendChild(this.createTextNode(b.minScale.toPrecision(10)));c.insertBefore(a,c.childNodes[4])}return c},CLASS_NAME:"OpenLayers.Format.WMC.v1_1_0"});OpenLayers.Layer.Boxes=OpenLayers.Class(OpenLayers.Layer.Markers,{initialize:function(b,a){OpenLayers.Layer.Markers.prototype.initialize.apply(this,arguments)},drawMarker:function(a){var d=a.bounds;var g=this.map.getLayerPxFromLonLat(new OpenLayers.LonLat(d.left,d.top));var c=this.map.getLayerPxFromLonLat(new OpenLayers.LonLat(d.right,d.bottom));if(c==null||g==null){a.display(false)}else{var f=new OpenLayers.Size(Math.max(1,c.x-g.x),Math.max(1,c.y-g.y));var b=a.draw(g,f);if(!a.drawn){this.div.appendChild(b);a.drawn=true}}},removeMarker:function(a){OpenLayers.Util.removeItem(this.markers,a);if((a.div!=null)&&(a.div.parentNode==this.div)){this.div.removeChild(a.div)}},CLASS_NAME:"OpenLayers.Layer.Boxes"});OpenLayers.Layer.GeoRSS=OpenLayers.Class(OpenLayers.Layer.Markers,{location:null,features:null,formatOptions:null,selectedFeature:null,icon:null,popupSize:null,useFeedTitle:true,initialize:function(c,a,b){OpenLayers.Layer.Markers.prototype.initialize.apply(this,[c,b]);this.location=a;this.features=[]},destroy:function(){OpenLayers.Layer.Markers.prototype.destroy.apply(this,arguments);this.clearFeatures();this.features=null},loadRSS:function(){if(!this.loaded){this.events.triggerEvent("loadstart");OpenLayers.Request.GET({url:this.location,success:this.parseData,scope:this});this.loaded=true}},moveTo:function(c,a,b){OpenLayers.Layer.Markers.prototype.moveTo.apply(this,arguments);if(this.visibility&&!this.loaded){this.loadRSS()}},parseData:function(k){var q=k.responseXML;if(!q||!q.documentElement){q=OpenLayers.Format.XML.prototype.read(k.responseText)}if(this.useFeedTitle){var a=null;try{a=q.getElementsByTagNameNS("*","title")[0].firstChild.nodeValue}catch(j){a=q.getElementsByTagName("title")[0].firstChild.nodeValue}if(a){this.setName(a)}}var u={};OpenLayers.Util.extend(u,this.formatOptions);if(this.map&&!this.projection.equals(this.map.getProjectionObject())){u.externalProjection=this.projection;u.internalProjection=this.map.getProjectionObject()}var r=new OpenLayers.Format.GeoRSS(u);var b=r.read(q);for(var g=0,h=b.length;g<h;g++){var f={};var t=b[g];if(!t.geometry){continue}var m=t.attributes.title?t.attributes.title:"Untitled";var s=t.attributes.description?t.attributes.description:"No description.";var l=t.attributes.link?t.attributes.link:"";var o=t.geometry.getBounds().getCenterLonLat();f.icon=this.icon==null?OpenLayers.Marker.defaultIcon():this.icon.clone();f.popupSize=this.popupSize?this.popupSize.clone():new OpenLayers.Size(250,120);if(m||s){f.title=m;f.description=s;var c='<div class="olLayerGeoRSSClose">[x]</div>';c+='<div class="olLayerGeoRSSTitle">';if(l){c+='<a class="link" href="'+l+'" target="_blank">'}c+=m;if(l){c+="</a>"}c+="</div>";c+='<div style="" class="olLayerGeoRSSDescription">';c+=s;c+="</div>";f.popupContentHTML=c}var t=new OpenLayers.Feature(this,o,f);this.features.push(t);var d=t.createMarker();d.events.register("click",t,this.markerClick);this.addMarker(d)}this.events.triggerEvent("loadend")},markerClick:function(c){var f=(this==this.layer.selectedFeature);this.layer.selectedFeature=(!f)?this:null;for(var d=0,a=this.layer.map.popups.length;d<a;d++){this.layer.map.removePopup(this.layer.map.popups[d])}if(!f){var b=this.createPopup();OpenLayers.Event.observe(b.div,"click",OpenLayers.Function.bind(function(){for(var h=0,g=this.layer.map.popups.length;h<g;h++){this.layer.map.removePopup(this.layer.map.popups[h])}},this));this.layer.map.addPopup(b)}OpenLayers.Event.stop(c)},clearFeatures:function(){if(this.features!=null){while(this.features.length>0){var a=this.features[0];OpenLayers.Util.removeItem(this.features,a);a.destroy()}}},CLASS_NAME:"OpenLayers.Layer.GeoRSS"});OpenLayers.Layer.Google=OpenLayers.Class(OpenLayers.Layer.EventPane,OpenLayers.Layer.FixedZoomLevels,{MIN_ZOOM_LEVEL:0,MAX_ZOOM_LEVEL:19,RESOLUTIONS:[1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125,0.00002145767211914062,0.00001072883605957031,0.00000536441802978515,0.00000268220901489257],type:null,sphericalMercator:false,dragObject:null,termsOfUse:null,poweredBy:null,initialize:function(b,a){OpenLayers.Layer.EventPane.prototype.initialize.apply(this,arguments);OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,arguments);this.addContainerPxFunction();if(this.sphericalMercator){OpenLayers.Util.extend(this,OpenLayers.Layer.SphericalMercator);this.initMercatorParameters()}},loadMapObject:function(){try{this.mapObject=new GMap2(this.div);if(typeof this.mapObject.getDragObject=="function"){this.dragObject=this.mapObject.getDragObject()}else{this.dragPanMapObject=null}this.termsOfUse=this.div.lastChild;this.div.removeChild(this.termsOfUse);if(this.isFixed){this.map.viewPortDiv.appendChild(this.termsOfUse)}else{this.map.layerContainerDiv.appendChild(this.termsOfUse)}this.termsOfUse.style.zIndex="1100";this.termsOfUse.style.display=this.div.style.display;this.termsOfUse.style.right="";this.termsOfUse.style.bottom="";this.termsOfUse.className="olLayerGoogleCopyright";this.poweredBy=this.div.lastChild;this.div.removeChild(this.poweredBy);if(this.isFixed){this.map.viewPortDiv.appendChild(this.poweredBy)}else{this.map.layerContainerDiv.appendChild(this.poweredBy)}this.poweredBy.style.zIndex="1100";this.poweredBy.style.display=this.div.style.display;this.poweredBy.style.right="";this.poweredBy.style.bottom="";this.poweredBy.className="olLayerGooglePoweredBy gmnoprint"}catch(a){OpenLayers.Console.error(a)}},setMap:function(a){OpenLayers.Layer.EventPane.prototype.setMap.apply(this,arguments);if(this.type!=null){this.map.events.register("moveend",this,this.setMapType)}},setMapType:function(){if(this.mapObject.getCenter()!=null){if(OpenLayers.Util.indexOf(this.mapObject.getMapTypes(),this.type)==-1){this.mapObject.addMapType(this.type)}this.mapObject.setMapType(this.type);this.map.events.unregister("moveend",this,this.setMapType)}},onMapResize:function(){if(this.visibility&&this.mapObject.isLoaded()){this.mapObject.checkResize()}else{if(!this._resized){var a=this;var b=GEvent.addListener(this.mapObject,"load",function(){GEvent.removeListener(b);delete a._resized;a.mapObject.checkResize();a.moveTo(a.map.getCenter(),a.map.getZoom())})}this._resized=true}},display:function(a){OpenLayers.Layer.EventPane.prototype.display.apply(this,arguments);this.termsOfUse.style.display=this.div.style.display;this.poweredBy.style.display=this.div.style.display},removeMap:function(a){if(this.termsOfUse&&this.termsOfUse.parentNode){this.termsOfUse.parentNode.removeChild(this.termsOfUse);this.termsOfUse=null}if(this.poweredBy&&this.poweredBy.parentNode){this.poweredBy.parentNode.removeChild(this.poweredBy);this.poweredBy=null}OpenLayers.Layer.EventPane.prototype.removeMap.apply(this,arguments)},getOLBoundsFromMapObjectBounds:function(b){var c=null;if(b!=null){var a=b.getSouthWest();var d=b.getNorthEast();if(this.sphericalMercator){a=this.forwardMercator(a.lng(),a.lat());d=this.forwardMercator(d.lng(),d.lat())}else{a=new OpenLayers.LonLat(a.lng(),a.lat());d=new OpenLayers.LonLat(d.lng(),d.lat())}c=new OpenLayers.Bounds(a.lon,a.lat,d.lon,d.lat)}return c},getMapObjectBoundsFromOLBounds:function(c){var b=null;if(c!=null){var a=this.sphericalMercator?this.inverseMercator(c.bottom,c.left):new OpenLayers.LonLat(c.bottom,c.left);var d=this.sphericalMercator?this.inverseMercator(c.top,c.right):new OpenLayers.LonLat(c.top,c.right);b=new GLatLngBounds(new GLatLng(a.lat,a.lon),new GLatLng(d.lat,d.lon))}return b},addContainerPxFunction:function(){if((typeof GMap2!="undefined")&&!GMap2.prototype.fromLatLngToContainerPixel){GMap2.prototype.fromLatLngToContainerPixel=function(b){var a=this.fromLatLngToDivPixel(b);var c=this.getContainer().firstChild.firstChild;a.x+=c.offsetLeft;a.y+=c.offsetTop;return a}}},getWarningHTML:function(){return OpenLayers.i18n("googleWarning")},setMapObjectCenter:function(a,b){this.mapObject.setCenter(a,b)},dragPanMapObject:function(b,a){this.dragObject.moveBy(new GSize(-b,a))},getMapObjectCenter:function(){return this.mapObject.getCenter()},getMapObjectZoom:function(){return this.mapObject.getZoom()},getMapObjectLonLatFromMapObjectPixel:function(a){return this.mapObject.fromContainerPixelToLatLng(a)},getMapObjectPixelFromMapObjectLonLat:function(a){return this.mapObject.fromLatLngToContainerPixel(a)},getMapObjectZoomFromMapObjectBounds:function(a){return this.mapObject.getBoundsZoomLevel(a)},getLongitudeFromMapObjectLonLat:function(a){return this.sphericalMercator?this.forwardMercator(a.lng(),a.lat()).lon:a.lng()},getLatitudeFromMapObjectLonLat:function(b){var a=this.sphericalMercator?this.forwardMercator(b.lng(),b.lat()).lat:b.lat();return a},getMapObjectLonLatFromLonLat:function(d,b){var c;if(this.sphericalMercator){var a=this.inverseMercator(d,b);c=new GLatLng(a.lat,a.lon)}else{c=new GLatLng(b,d)}return c},getXFromMapObjectPixel:function(a){return a.x},getYFromMapObjectPixel:function(a){return a.y},getMapObjectPixelFromXY:function(a,b){return new GPoint(a,b)},CLASS_NAME:"OpenLayers.Layer.Google"});OpenLayers.Layer.Grid=OpenLayers.Class(OpenLayers.Layer.HTTPRequest,{tileSize:null,grid:null,singleTile:false,ratio:1.5,buffer:2,numLoadingTiles:0,initialize:function(c,b,d,a){OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,arguments);this.events.addEventType("tileloaded");this.grid=[]},destroy:function(){this.clearGrid();this.grid=null;this.tileSize=null;OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this,arguments)},clearGrid:function(){if(this.grid){for(var g=0,b=this.grid.length;g<b;g++){var f=this.grid[g];for(var c=0,a=f.length;c<a;c++){var d=f[c];this.removeTileMonitoringHooks(d);d.destroy()}}this.grid=[]}},clone:function(a){if(a==null){a=new OpenLayers.Layer.Grid(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this,[a]);if(this.tileSize!=null){a.tileSize=this.tileSize.clone()}a.grid=[];return a},moveTo:function(d,a,f){OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this,arguments);d=d||this.map.getExtent();if(d!=null){var c=!this.grid.length||a;var b=this.getTilesBounds();if(this.singleTile){if(c||(!f&&!b.containsBounds(d))){this.initSingleTile(d)}}else{if(c||!b.containsBounds(d,true)){this.initGriddedTiles(d)}else{this.moveGriddedTiles(d)}}}},setTileSize:function(a){if(this.singleTile){a=this.map.getSize().clone();a.h=parseInt(a.h*this.ratio);a.w=parseInt(a.w*this.ratio)}OpenLayers.Layer.HTTPRequest.prototype.setTileSize.apply(this,[a])},getGridBounds:function(){var a="The getGridBounds() function is deprecated. It will be removed in 3.0. Please use getTilesBounds() instead.";OpenLayers.Console.warn(a);return this.getTilesBounds()},getTilesBounds:function(){var f=null;if(this.grid.length){var a=this.grid.length-1;var d=this.grid[a][0];var b=this.grid[0].length-1;var c=this.grid[0][b];f=new OpenLayers.Bounds(d.bounds.left,d.bounds.bottom,c.bounds.right,c.bounds.top)}return f},initSingleTile:function(g){var a=g.getCenterLonLat();var j=g.getWidth()*this.ratio;var b=g.getHeight()*this.ratio;var h=new OpenLayers.Bounds(a.lon-(j/2),a.lat-(b/2),a.lon+(j/2),a.lat+(b/2));var d=new OpenLayers.LonLat(h.left,h.top);var c=this.map.getLayerPxFromLonLat(d);if(!this.grid.length){this.grid[0]=[]}var f=this.grid[0][0];if(!f){f=this.addTile(h,c);this.addTileMonitoringHooks(f);f.draw();this.grid[0][0]=f}else{f.moveTo(h,c)}this.removeExcessTiles(1,1)},calculateGridLayout:function(a,s,f){var m=f*this.tileSize.w;var c=f*this.tileSize.h;var k=a.left-s.left;var o=Math.floor(k/m)-this.buffer;var l=k/m-o;var g=-l*this.tileSize.w;var q=s.left+o*m;var b=a.top-(s.bottom+c);var j=Math.ceil(b/c)+this.buffer;var r=j-b/c;var d=-r*this.tileSize.h;var h=s.bottom+j*c;return{tilelon:m,tilelat:c,tileoffsetlon:q,tileoffsetlat:h,tileoffsetx:g,tileoffsety:d}},initGriddedTiles:function(k){var h=this.map.getSize();var B=Math.ceil(h.h/this.tileSize.h)+Math.max(1,2*this.buffer);var D=Math.ceil(h.w/this.tileSize.w)+Math.max(1,2*this.buffer);var s=this.maxExtent;var v=this.map.getResolution();var u=this.calculateGridLayout(k,s,v);var g=Math.round(u.tileoffsetx);var c=Math.round(u.tileoffsety);var m=u.tileoffsetlon;var r=u.tileoffsetlat;var f=u.tilelon;var l=u.tilelat;this.origin=new OpenLayers.Pixel(g,c);var A=g;var C=m;var z=0;var a=parseInt(this.map.layerContainerDiv.style.left);var w=parseInt(this.map.layerContainerDiv.style.top);do{var j=this.grid[z++];if(!j){j=[];this.grid.push(j)}m=C;g=A;var d=0;do{var b=new OpenLayers.Bounds(m,r,m+f,r+l);var q=g;q-=a;var o=c;o-=w;var t=new OpenLayers.Pixel(q,o);var E=j[d++];if(!E){E=this.addTile(b,t);this.addTileMonitoringHooks(E);j.push(E)}else{E.moveTo(b,t,false)}m+=f;g+=this.tileSize.w}while((m<=k.right+f*this.buffer)||d<D);r-=l;c+=this.tileSize.h}while((r>=k.bottom-l*this.buffer)||z<B);this.removeExcessTiles(z,d);this.spiralTileLoad()},spiralTileLoad:function(){var b=[];var j=["right","down","left","up"];var h=0;var a=-1;var l=OpenLayers.Util.indexOf(j,"right");var m=0;while(m<j.length){var k=h;var c=a;switch(j[l]){case"right":c++;break;case"down":k++;break;case"left":c--;break;case"up":k--;break}var g=null;if((k<this.grid.length)&&(k>=0)&&(c<this.grid[0].length)&&(c>=0)){g=this.grid[k][c]}if((g!=null)&&(!g.queued)){b.unshift(g);g.queued=true;m=0;h=k;a=c}else{l=(l+1)%4;m++}}for(var d=0,f=b.length;d<f;d++){var g=b[d];g.draw();g.queued=false}},addTile:function(b,a){},addTileMonitoringHooks:function(a){a.onLoadStart=function(){if(this.numLoadingTiles==0){this.events.triggerEvent("loadstart")}this.numLoadingTiles++};a.events.register("loadstart",this,a.onLoadStart);a.onLoadEnd=function(){this.numLoadingTiles--;this.events.triggerEvent("tileloaded");if(this.numLoadingTiles==0){this.events.triggerEvent("loadend")}};a.events.register("loadend",this,a.onLoadEnd);a.events.register("unload",this,a.onLoadEnd)},removeTileMonitoringHooks:function(a){a.unload();a.events.un({loadstart:a.onLoadStart,loadend:a.onLoadEnd,unload:a.onLoadEnd,scope:this})},moveGriddedTiles:function(c){var b=this.buffer||1;while(true){var a=this.grid[0][0].position;var d=this.map.getViewPortPxFromLayerPx(a);if(d.x>-this.tileSize.w*(b-1)){this.shiftColumn(true)}else{if(d.x<-this.tileSize.w*b){this.shiftColumn(false)}else{if(d.y>-this.tileSize.h*(b-1)){this.shiftRow(true)}else{if(d.y<-this.tileSize.h*b){this.shiftRow(false)}else{break}}}}}},shiftRow:function(q){var c=(q)?0:(this.grid.length-1);var b=this.grid;var g=b[c];var f=this.map.getResolution();var j=(q)?-this.tileSize.h:this.tileSize.h;var h=f*-j;var o=(q)?b.pop():b.shift();for(var k=0,m=g.length;k<m;k++){var d=g[k];var a=d.bounds.clone();var l=d.position.clone();a.bottom=a.bottom+h;a.top=a.top+h;l.y=l.y+j;o[k].moveTo(a,l)}if(q){b.unshift(o)}else{b.push(o)}},shiftColumn:function(o){var d=(o)?-this.tileSize.w:this.tileSize.w;var c=this.map.getResolution();var l=c*d;for(var f=0,h=this.grid.length;f<h;f++){var m=this.grid[f];var k=(o)?0:(m.length-1);var b=m[k];var a=b.bounds.clone();var g=b.position.clone();a.left=a.left+l;a.right=a.right+l;g.x=g.x+d;var j=o?this.grid[f].pop():this.grid[f].shift();j.moveTo(a,g);if(o){m.unshift(j)}else{m.push(j)}}},removeExcessTiles:function(f,c){while(this.grid.length>f){var g=this.grid.pop();for(var b=0,a=g.length;b<a;b++){var d=g[b];this.removeTileMonitoringHooks(d);d.destroy()}}while(this.grid[0].length>c){for(var b=0,a=this.grid.length;b<a;b++){var g=this.grid[b];var d=g.pop();this.removeTileMonitoringHooks(d);d.destroy()}}},onMapResize:function(){if(this.singleTile){this.clearGrid();this.setTileSize()}},getTileBounds:function(d){var c=this.maxExtent;var g=this.getResolution();var f=g*this.tileSize.w;var b=g*this.tileSize.h;var j=this.getLonLatFromViewPortPx(d);var a=c.left+(f*Math.floor((j.lon-c.left)/f));var h=c.bottom+(b*Math.floor((j.lat-c.bottom)/b));return new OpenLayers.Bounds(a,h,a+f,h+b)},CLASS_NAME:"OpenLayers.Layer.Grid"});OpenLayers.Layer.MultiMap=OpenLayers.Class(OpenLayers.Layer.EventPane,OpenLayers.Layer.FixedZoomLevels,{MIN_ZOOM_LEVEL:1,MAX_ZOOM_LEVEL:17,RESOLUTIONS:[9,1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],type:null,initialize:function(b,a){OpenLayers.Layer.EventPane.prototype.initialize.apply(this,arguments);OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,arguments);if(this.sphericalMercator){OpenLayers.Util.extend(this,OpenLayers.Layer.SphericalMercator);this.initMercatorParameters();this.RESOLUTIONS.unshift(10)}},loadMapObject:function(){try{this.mapObject=new MultimapViewer(this.div)}catch(a){}},getWarningHTML:function(){return OpenLayers.i18n("getLayerWarning",{layerType:"MM",layerLib:"MultiMap"})},setMapObjectCenter:function(a,b){this.mapObject.goToPosition(a,b)},getMapObjectCenter:function(){return this.mapObject.getCurrentPosition()},getMapObjectZoom:function(){return this.mapObject.getZoomFactor()},getMapObjectLonLatFromMapObjectPixel:function(a){a.x=a.x-(this.map.getSize().w/2);a.y=a.y-(this.map.getSize().h/2);return this.mapObject.getMapPositionAt(a)},getMapObjectPixelFromMapObjectLonLat:function(a){return this.mapObject.geoPosToContainerPixels(a)},getLongitudeFromMapObjectLonLat:function(a){return this.sphericalMercator?this.forwardMercator(a.lon,a.lat).lon:a.lon},getLatitudeFromMapObjectLonLat:function(a){return this.sphericalMercator?this.forwardMercator(a.lon,a.lat).lat:a.lat},getMapObjectLonLatFromLonLat:function(d,c){var a;if(this.sphericalMercator){var b=this.inverseMercator(d,c);a=new MMLatLon(b.lat,b.lon)}else{a=new MMLatLon(c,d)}return a},getXFromMapObjectPixel:function(a){return a.x},getYFromMapObjectPixel:function(a){return a.y},getMapObjectPixelFromXY:function(a,b){return new MMPoint(a,b)},CLASS_NAME:"OpenLayers.Layer.MultiMap"});OpenLayers.Layer.Text=OpenLayers.Class(OpenLayers.Layer.Markers,{location:null,features:null,formatOptions:null,selectedFeature:null,initialize:function(b,a){OpenLayers.Layer.Markers.prototype.initialize.apply(this,arguments);this.features=new Array()},destroy:function(){OpenLayers.Layer.Markers.prototype.destroy.apply(this,arguments);this.clearFeatures();this.features=null},loadText:function(){if(!this.loaded){if(this.location!=null){var a=function(b){this.events.triggerEvent("loadend")};this.events.triggerEvent("loadstart");OpenLayers.Request.GET({url:this.location,success:this.parseData,failure:a,scope:this});this.loaded=true}}},moveTo:function(c,a,b){OpenLayers.Layer.Markers.prototype.moveTo.apply(this,arguments);if(this.visibility&&!this.loaded){this.loadText()}},parseData:function(l){var o=l.responseText;var r={};OpenLayers.Util.extend(r,this.formatOptions);if(this.map&&!this.projection.equals(this.map.getProjectionObject())){r.externalProjection=this.projection;r.internalProjection=this.map.getProjectionObject()}var b=new OpenLayers.Format.Text(r);var c=b.read(o);for(var h=0,j=c.length;h<j;h++){var g={};var q=c[h];var m;var k,d;m=new OpenLayers.LonLat(q.geometry.x,q.geometry.y);if(q.style.graphicWidth&&q.style.graphicHeight){k=new OpenLayers.Size(q.style.graphicWidth,q.style.graphicHeight)}if(q.style.graphicXOffset!==undefined&&q.style.graphicYOffset!==undefined){d=new OpenLayers.Pixel(q.style.graphicXOffset,q.style.graphicYOffset)}if(q.style.externalGraphic!=null){g.icon=new OpenLayers.Icon(q.style.externalGraphic,k,d)}else{g.icon=OpenLayers.Marker.defaultIcon();if(k!=null){g.icon.setSize(k)}}if((q.attributes.title!=null)&&(q.attributes.description!=null)){g.popupContentHTML="<h2>"+q.attributes.title+"</h2><p>"+q.attributes.description+"</p>"}g.overflow=q.attributes.overflow||"auto";var a=new OpenLayers.Feature(this,m,g);this.features.push(a);var f=a.createMarker();if((q.attributes.title!=null)&&(q.attributes.description!=null)){f.events.register("click",a,this.markerClick)}this.addMarker(f)}this.events.triggerEvent("loadend")},markerClick:function(b){var d=(this==this.layer.selectedFeature);this.layer.selectedFeature=(!d)?this:null;for(var c=0,a=this.layer.map.popups.length;c<a;c++){this.layer.map.removePopup(this.layer.map.popups[c])}if(!d){this.layer.map.addPopup(this.createPopup())}OpenLayers.Event.stop(b)},clearFeatures:function(){if(this.features!=null){while(this.features.length>0){var a=this.features[0];OpenLayers.Util.removeItem(this.features,a);a.destroy()}}},CLASS_NAME:"OpenLayers.Layer.Text"});OpenLayers.Layer.VirtualEarth=OpenLayers.Class(OpenLayers.Layer.EventPane,OpenLayers.Layer.FixedZoomLevels,{MIN_ZOOM_LEVEL:1,MAX_ZOOM_LEVEL:17,RESOLUTIONS:[1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125,0.00002145767211914062],type:null,sphericalMercator:false,initialize:function(b,a){OpenLayers.Layer.EventPane.prototype.initialize.apply(this,arguments);OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,arguments);if(this.sphericalMercator){OpenLayers.Util.extend(this,OpenLayers.Layer.SphericalMercator);this.initMercatorParameters()}},loadMapObject:function(){var a=OpenLayers.Util.createDiv(this.name);var c=this.map.getSize();a.style.width=c.w+"px";a.style.height=c.h+"px";this.div.appendChild(a);try{this.mapObject=new VEMap(this.name)}catch(b){}if(this.mapObject!=null){try{this.mapObject.LoadMap(null,null,this.type,true);this.mapObject.AttachEvent("onmousedown",function(){return true})}catch(b){}this.mapObject.HideDashboard()}if(!this.mapObject||!this.mapObject.vemapcontrol||!this.mapObject.vemapcontrol.PanMap||(typeof this.mapObject.vemapcontrol.PanMap!="function")){this.dragPanMapObject=null}},getWarningHTML:function(){return OpenLayers.i18n("getLayerWarning",{layerType:"VE",layerLib:"VirtualEarth"})},setMapObjectCenter:function(a,b){this.mapObject.SetCenterAndZoom(a,b)},getMapObjectCenter:function(){return this.mapObject.GetCenter()},dragPanMapObject:function(b,a){this.mapObject.vemapcontrol.PanMap(b,-a)},getMapObjectZoom:function(){return this.mapObject.GetZoomLevel()},getMapObjectLonLatFromMapObjectPixel:function(a){return(typeof VEPixel!="undefined")?this.mapObject.PixelToLatLong(a):this.mapObject.PixelToLatLong(a.x,a.y)},getMapObjectPixelFromMapObjectLonLat:function(a){return this.mapObject.LatLongToPixel(a)},getLongitudeFromMapObjectLonLat:function(a){return this.sphericalMercator?this.forwardMercator(a.Longitude,a.Latitude).lon:a.Longitude},getLatitudeFromMapObjectLonLat:function(a){return this.sphericalMercator?this.forwardMercator(a.Longitude,a.Latitude).lat:a.Latitude},getMapObjectLonLatFromLonLat:function(d,b){var c;if(this.sphericalMercator){var a=this.inverseMercator(d,b);c=new VELatLong(a.lat,a.lon)}else{c=new VELatLong(b,d)}return c},getXFromMapObjectPixel:function(a){return a.x},getYFromMapObjectPixel:function(a){return a.y},getMapObjectPixelFromXY:function(a,b){return(typeof VEPixel!="undefined")?new VEPixel(a,b):new Msn.VE.Pixel(a,b)},CLASS_NAME:"OpenLayers.Layer.VirtualEarth"});OpenLayers.Layer.Yahoo=OpenLayers.Class(OpenLayers.Layer.EventPane,OpenLayers.Layer.FixedZoomLevels,{MIN_ZOOM_LEVEL:0,MAX_ZOOM_LEVEL:17,RESOLUTIONS:[1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125,0.00002145767211914062,0.00001072883605957031],type:null,sphericalMercator:false,initialize:function(b,a){OpenLayers.Layer.EventPane.prototype.initialize.apply(this,arguments);OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,arguments);if(this.sphericalMercator){OpenLayers.Util.extend(this,OpenLayers.Layer.SphericalMercator);this.initMercatorParameters()}},loadMapObject:function(){try{var a=this.getMapObjectSizeFromOLSize(this.map.getSize());this.mapObject=new YMap(this.div,this.type,a);this.mapObject.disableKeyControls();this.mapObject.disableDragMap();if(!this.mapObject.moveByXY||(typeof this.mapObject.moveByXY!="function")){this.dragPanMapObject=null}}catch(b){}},onMapResize:function(){try{var a=this.getMapObjectSizeFromOLSize(this.map.getSize());this.mapObject.resizeTo(a)}catch(b){}},setMap:function(a){OpenLayers.Layer.EventPane.prototype.setMap.apply(this,arguments);this.map.events.register("moveend",this,this.fixYahooEventPane)},fixYahooEventPane:function(){var a=OpenLayers.Util.getElement("ygddfdiv");if(a!=null){if(a.parentNode!=null){a.parentNode.removeChild(a)}this.map.events.unregister("moveend",this,this.fixYahooEventPane)}},getWarningHTML:function(){return OpenLayers.i18n("getLayerWarning",{layerType:"Yahoo",layerLib:"Yahoo"})},getOLZoomFromMapObjectZoom:function(a){var b=null;if(a!=null){b=OpenLayers.Layer.FixedZoomLevels.prototype.getOLZoomFromMapObjectZoom.apply(this,[a]);b=18-b}return b},getMapObjectZoomFromOLZoom:function(a){var b=null;if(a!=null){b=OpenLayers.Layer.FixedZoomLevels.prototype.getMapObjectZoomFromOLZoom.apply(this,[a]);b=18-b}return b},setMapObjectCenter:function(a,b){this.mapObject.drawZoomAndCenter(a,b)},getMapObjectCenter:function(){return this.mapObject.getCenterLatLon()},dragPanMapObject:function(b,a){this.mapObject.moveByXY({x:-b,y:a})},getMapObjectZoom:function(){return this.mapObject.getZoomLevel()},getMapObjectLonLatFromMapObjectPixel:function(a){return this.mapObject.convertXYLatLon(a)},getMapObjectPixelFromMapObjectLonLat:function(a){return this.mapObject.convertLatLonXY(a)},getLongitudeFromMapObjectLonLat:function(a){return this.sphericalMercator?this.forwardMercator(a.Lon,a.Lat).lon:a.Lon},getLatitudeFromMapObjectLonLat:function(a){return this.sphericalMercator?this.forwardMercator(a.Lon,a.Lat).lat:a.Lat},getMapObjectLonLatFromLonLat:function(d,c){var a;if(this.sphericalMercator){var b=this.inverseMercator(d,c);a=new YGeoPoint(b.lat,b.lon)}else{a=new YGeoPoint(c,d)}return a},getXFromMapObjectPixel:function(a){return a.x},getYFromMapObjectPixel:function(a){return a.y},getMapObjectPixelFromXY:function(a,b){return new YCoordPoint(a,b)},getMapObjectSizeFromOLSize:function(a){return new YSize(a.w,a.h)},CLASS_NAME:"OpenLayers.Layer.Yahoo"});OpenLayers.Protocol.HTTP=OpenLayers.Class(OpenLayers.Protocol,{url:null,headers:null,params:null,callback:null,scope:null,readWithPOST:false,initialize:function(a){this.params={};this.headers={};OpenLayers.Protocol.prototype.initialize.apply(this,arguments)},destroy:function(){this.params=null;this.headers=null;OpenLayers.Protocol.prototype.destroy.apply(this)},createCallback:function(c,a,b){return OpenLayers.Function.bind(function(){c.apply(this,[a,b])},this)},read:function(a){a=OpenLayers.Util.applyDefaults(a,this.options);var b=(a.readWithPOST!==undefined)?a.readWithPOST:this.readWithPOST;var c=new OpenLayers.Protocol.Response({requestType:"read"});if(a.filter&&a.filter instanceof OpenLayers.Filter.Spatial){if(a.filter.type==OpenLayers.Filter.Spatial.BBOX){a.params=OpenLayers.Util.extend(a.params,{bbox:a.filter.value.toArray()})}}if(b){c.priv=OpenLayers.Request.POST({url:a.url,callback:this.createCallback(this.handleRead,c,a),data:OpenLayers.Util.getParameterString(a.params),headers:{"Content-Type":"application/x-www-form-urlencoded"}})}else{c.priv=OpenLayers.Request.GET({url:a.url,callback:this.createCallback(this.handleRead,c,a),params:a.params,headers:a.headers})}return c},handleRead:function(b,a){this.handleResponse(b,a)},create:function(b,a){a=OpenLayers.Util.applyDefaults(a,this.options);var c=new OpenLayers.Protocol.Response({reqFeatures:b,requestType:"create"});c.priv=OpenLayers.Request.POST({url:a.url,callback:this.createCallback(this.handleCreate,c,a),headers:a.headers,data:this.format.write(b)});return c},handleCreate:function(b,a){this.handleResponse(b,a)},update:function(c,b){var a=b.url||c.url||this.options.url;b=OpenLayers.Util.applyDefaults(b,this.options);var d=new OpenLayers.Protocol.Response({reqFeatures:c,requestType:"update"});d.priv=OpenLayers.Request.PUT({url:a,callback:this.createCallback(this.handleUpdate,d,b),headers:b.headers,data:this.format.write(c)});return d},handleUpdate:function(b,a){this.handleResponse(b,a)},"delete":function(c,b){var a=b.url||c.url||this.options.url;b=OpenLayers.Util.applyDefaults(b,this.options);var d=new OpenLayers.Protocol.Response({reqFeatures:c,requestType:"delete"});d.priv=OpenLayers.Request.DELETE({url:a,callback:this.createCallback(this.handleDelete,d,b),headers:b.headers});return d},handleDelete:function(b,a){this.handleResponse(b,a)},handleResponse:function(c,a){var b=c.priv;if(a.callback){if(b.status>=200&&b.status<300){if(c.requestType!="delete"){c.features=this.parseFeatures(b)}c.code=OpenLayers.Protocol.Response.SUCCESS}else{c.code=OpenLayers.Protocol.Response.FAILURE}a.callback.call(a.scope,c)}},parseFeatures:function(a){var b=a.responseXML;if(!b||!b.documentElement){b=a.responseText}if(!b||b.length<=0){return null}return this.format.read(b)},commit:function(b,t){t=OpenLayers.Util.applyDefaults(t,this.options);var d=[],o=0;var l={};l[OpenLayers.State.INSERT]=[];l[OpenLayers.State.UPDATE]=[];l[OpenLayers.State.DELETE]=[];var s,m,c=[];for(var f=0,k=b.length;f<k;++f){s=b[f];m=l[s.state];if(m){m.push(s);c.push(s)}}var h=(l[OpenLayers.State.INSERT].length>0?1:0)+l[OpenLayers.State.UPDATE].length+l[OpenLayers.State.DELETE].length;var r=true;var a=new OpenLayers.Protocol.Response({reqFeatures:c});function j(v){var u=v.features?v.features.length:0;var z=new Array(u);for(var w=0;w<u;++w){z[w]=v.features[w].fid}a.insertIds=z;q.apply(this,[v])}function q(u){this.callUserCallback(u,t);r=r&&u.success();o++;if(o>=h){if(t.callback){a.code=r?OpenLayers.Protocol.Response.SUCCESS:OpenLayers.Protocol.Response.FAILURE;t.callback.apply(t.scope,[a])}}}var g=l[OpenLayers.State.INSERT];if(g.length>0){d.push(this.create(g,OpenLayers.Util.applyDefaults({callback:j,scope:this},t.create)))}g=l[OpenLayers.State.UPDATE];for(var f=g.length-1;f>=0;--f){d.push(this.update(g[f],OpenLayers.Util.applyDefaults({callback:q,scope:this},t.update)))}g=l[OpenLayers.State.DELETE];for(var f=g.length-1;f>=0;--f){d.push(this["delete"](g[f],OpenLayers.Util.applyDefaults({callback:q,scope:this},t["delete"])))}return d},abort:function(a){if(a){a.priv.abort()}},callUserCallback:function(c,a){var b=a[c.requestType];if(b&&b.callback){b.callback.call(b.scope,c)}},CLASS_NAME:"OpenLayers.Protocol.HTTP"});OpenLayers.Style=OpenLayers.Class({name:null,title:null,description:null,layerName:null,isDefault:false,rules:null,context:null,defaultStyle:null,defaultsPerSymbolizer:false,propertyStyles:null,initialize:function(b,a){OpenLayers.Util.extend(this,a);this.rules=[];if(a&&a.rules){this.addRules(a.rules)}this.setDefaultStyle(b||OpenLayers.Feature.Vector.style["default"])},destroy:function(){for(var b=0,a=this.rules.length;b<a;b++){this.rules[b].destroy();this.rules[b]=null}this.rules=null;this.defaultStyle=null},createSymbolizer:function(l){var a=this.defaultsPerSymbolizer?{}:this.createLiterals(OpenLayers.Util.extend({},this.defaultStyle),l);var k=this.rules;var j,b;var c=[];var g=false;for(var d=0,f=k.length;d<f;d++){j=k[d];var h=j.evaluate(l);if(h){if(j instanceof OpenLayers.Rule&&j.elseFilter){c.push(j)}else{g=true;this.applySymbolizer(j,a,l)}}}if(g==false&&c.length>0){g=true;for(var d=0,f=c.length;d<f;d++){this.applySymbolizer(c[d],a,l)}}if(k.length>0&&g==false){a.display="none"}return a},applySymbolizer:function(g,d,b){var a=b.geometry?this.getSymbolizerPrefix(b.geometry):OpenLayers.Style.SYMBOLIZER_PREFIXES[0];var c=g.symbolizer[a]||g.symbolizer;if(this.defaultsPerSymbolizer===true){var f=this.defaultStyle;OpenLayers.Util.applyDefaults(c,{pointRadius:f.pointRadius});if(c.stroke===true||c.graphic===true){OpenLayers.Util.applyDefaults(c,{strokeWidth:f.strokeWidth,strokeColor:f.strokeColor,strokeOpacity:f.strokeOpacity,strokeDashstyle:f.strokeDashstyle,strokeLinecap:f.strokeLinecap})}if(c.fill===true||c.graphic===true){OpenLayers.Util.applyDefaults(c,{fillColor:f.fillColor,fillOpacity:f.fillOpacity})}if(c.graphic===true){OpenLayers.Util.applyDefaults(c,{pointRadius:this.defaultStyle.pointRadius,externalGraphic:this.defaultStyle.externalGraphic,graphicName:this.defaultStyle.graphicName,graphicOpacity:this.defaultStyle.graphicOpacity,graphicWidth:this.defaultStyle.graphicWidth,graphicHeight:this.defaultStyle.graphicHeight,graphicXOffset:this.defaultStyle.graphicXOffset,graphicYOffset:this.defaultStyle.graphicYOffset})}}return this.createLiterals(OpenLayers.Util.extend(d,c),b)},createLiterals:function(d,c){var b=this.context||c.attributes||c.data;for(var a in this.propertyStyles){d[a]=OpenLayers.Style.createLiteral(d[a],b,c)}return d},findPropertyStyles:function(){var d={};var g=this.defaultStyle;this.addPropertyStyles(d,g);var j=this.rules;var f,h;for(var c=0,a=j.length;c<a;c++){f=j[c].symbolizer;for(var b in f){h=f[b];if(typeof h=="object"){this.addPropertyStyles(d,h)}else{this.addPropertyStyles(d,f);break}}}return d},addPropertyStyles:function(b,c){var d;for(var a in c){d=c[a];if(typeof d=="string"&&d.match(/\$\{\w+\}/)){b[a]=true}}return b},addRules:function(a){this.rules=this.rules.concat(a);this.propertyStyles=this.findPropertyStyles()},setDefaultStyle:function(a){this.defaultStyle=a;this.propertyStyles=this.findPropertyStyles()},getSymbolizerPrefix:function(d){var c=OpenLayers.Style.SYMBOLIZER_PREFIXES;for(var b=0,a=c.length;b<a;b++){if(d.CLASS_NAME.indexOf(c[b])!=-1){return c[b]}}},CLASS_NAME:"OpenLayers.Style"});OpenLayers.Style.createLiteral=function(c,b,a){if(typeof c=="string"&&c.indexOf("${")!=-1){c=OpenLayers.String.format(c,b,[a]);c=(isNaN(c)||!c)?c:parseFloat(c)}return c};OpenLayers.Style.SYMBOLIZER_PREFIXES=["Point","Line","Polygon","Text"];OpenLayers.Control.Navigation=OpenLayers.Class(OpenLayers.Control,{dragPan:null,dragPanOptions:null,zoomBox:null,zoomWheelEnabled:true,handleRightClicks:false,zoomBoxKeyMask:OpenLayers.Handler.MOD_SHIFT,initialize:function(a){this.handlers={};OpenLayers.Control.prototype.initialize.apply(this,arguments)},destroy:function(){this.deactivate();if(this.dragPan){this.dragPan.destroy()}this.dragPan=null;if(this.zoomBox){this.zoomBox.destroy()}this.zoomBox=null;OpenLayers.Control.prototype.destroy.apply(this,arguments)},activate:function(){this.dragPan.activate();if(this.zoomWheelEnabled){this.handlers.wheel.activate()}this.handlers.click.activate();this.zoomBox.activate();return OpenLayers.Control.prototype.activate.apply(this,arguments)},deactivate:function(){this.zoomBox.deactivate();this.dragPan.deactivate();this.handlers.click.deactivate();this.handlers.wheel.deactivate();return OpenLayers.Control.prototype.deactivate.apply(this,arguments)},draw:function(){if(this.handleRightClicks){this.map.viewPortDiv.oncontextmenu=function(){return false}}var a={dblclick:this.defaultDblClick,dblrightclick:this.defaultDblRightClick};var b={"double":true,stopDouble:true};this.handlers.click=new OpenLayers.Handler.Click(this,a,b);this.dragPan=new OpenLayers.Control.DragPan(OpenLayers.Util.extend({map:this.map},this.dragPanOptions));this.zoomBox=new OpenLayers.Control.ZoomBox({map:this.map,keyMask:this.zoomBoxKeyMask});this.dragPan.draw();this.zoomBox.draw();this.handlers.wheel=new OpenLayers.Handler.MouseWheel(this,{up:this.wheelUp,down:this.wheelDown});this.activate()},defaultDblClick:function(b){var a=this.map.getLonLatFromViewPortPx(b.xy);this.map.setCenter(a,this.map.zoom+1)},defaultDblRightClick:function(b){var a=this.map.getLonLatFromViewPortPx(b.xy);this.map.setCenter(a,this.map.zoom-1)},wheelChange:function(j,c){var g=this.map.getZoom()+c;if(!this.map.isValidZoomLevel(g)){return}var k=this.map.getSize();var f=k.w/2-j.xy.x;var d=j.xy.y-k.h/2;var h=this.map.baseLayer.getResolutionForZoom(g);var a=this.map.getLonLatFromPixel(j.xy);var b=new OpenLayers.LonLat(a.lon+f*h,a.lat+d*h);this.map.setCenter(b,g)},wheelUp:function(a){this.wheelChange(a,1)},wheelDown:function(a){this.wheelChange(a,-1)},disableZoomWheel:function(){this.zoomWheelEnabled=false;this.handlers.wheel.deactivate()},enableZoomWheel:function(){this.zoomWheelEnabled=true;if(this.active){this.handlers.wheel.activate()}},CLASS_NAME:"OpenLayers.Control.Navigation"});OpenLayers.Filter=OpenLayers.Class({initialize:function(a){OpenLayers.Util.extend(this,a)},destroy:function(){},evaluate:function(a){return true},clone:function(){return null},CLASS_NAME:"OpenLayers.Filter"});OpenLayers.Geometry=OpenLayers.Class({id:null,parent:null,bounds:null,initialize:function(){this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_")},destroy:function(){this.id=null;this.bounds=null},clone:function(){return new OpenLayers.Geometry()},setBounds:function(a){if(a){this.bounds=a.clone()}},clearBounds:function(){this.bounds=null;if(this.parent){this.parent.clearBounds()}},extendBounds:function(b){var a=this.getBounds();if(!a){this.setBounds(b)}else{this.bounds.extend(b)}},getBounds:function(){if(this.bounds==null){this.calculateBounds()}return this.bounds},calculateBounds:function(){},distanceTo:function(b,a){},getVertices:function(a){},atPoint:function(f,j,g){var c=false;var d=this.getBounds();if((d!=null)&&(f!=null)){var b=(j!=null)?j:0;var a=(g!=null)?g:0;var h=new OpenLayers.Bounds(this.bounds.left-b,this.bounds.bottom-a,this.bounds.right+b,this.bounds.top+a);c=h.containsLonLat(f)}return c},getLength:function(){return 0},getArea:function(){return 0},getCentroid:function(){return null},toString:function(){return OpenLayers.Format.WKT.prototype.write(new OpenLayers.Feature.Vector(this))},CLASS_NAME:"OpenLayers.Geometry"});OpenLayers.Geometry.fromWKT=function(g){var h=arguments.callee.format;if(!h){h=new OpenLayers.Format.WKT();arguments.callee.format=h}var d;var b=h.read(g);if(b instanceof OpenLayers.Feature.Vector){d=b.geometry}else{if(b instanceof Array){var a=b.length;var f=new Array(a);for(var c=0;c<a;++c){f[c]=b[c].geometry}d=new OpenLayers.Geometry.Collection(f)}}return d};OpenLayers.Geometry.segmentsIntersect=function(a,J,b){var u=b&&b.point;var B=b&&b.tolerance;var g=false;var D=a.x1-J.x1;var H=a.y1-J.y1;var r=a.x2-a.x1;var A=a.y2-a.y1;var v=J.y2-J.y1;var m=J.x2-J.x1;var F=(v*r)-(m*A);var f=(m*H)-(v*D);var c=(r*H)-(A*D);if(F==0){if(f==0&&c==0){g=true}}else{var G=f/F;var E=c/F;if(G>=0&&G<=1&&E>=0&&E<=1){if(!u){g=true}else{var k=a.x1+(G*r);var h=a.y1+(G*A);g=new OpenLayers.Geometry.Point(k,h)}}}if(B){var t;if(g){if(u){var q=[a,J];var C,k,h;outer:for(var z=0;z<2;++z){C=q[z];for(var w=1;w<3;++w){k=C["x"+w];h=C["y"+w];t=Math.sqrt(Math.pow(k-g.x,2)+Math.pow(h-g.y,2));if(t<B){g.x=k;g.y=h;break outer}}}}}else{var q=[a,J];var s,I,k,h,o,l;outer:for(var z=0;z<2;++z){s=q[z];I=q[(z+1)%2];for(var w=1;w<3;++w){o={x:s["x"+w],y:s["y"+w]};l=OpenLayers.Geometry.distanceToSegment(o,I);if(l.distance<B){if(u){g=new OpenLayers.Geometry.Point(o.x,o.y)}else{g=true}break outer}}}}}return g};OpenLayers.Geometry.distanceToSegment=function(m,d){var c=m.x;var l=m.y;var b=d.x1;var k=d.y1;var a=d.x2;var g=d.y2;var q=a-b;var o=g-k;var j=((q*(c-b))+(o*(l-k)))/(Math.pow(q,2)+Math.pow(o,2));var h,f;if(j<=0){h=b;f=k}else{if(j>=1){h=a;f=g}else{h=b+j*q;f=k+j*o}}return{distance:Math.sqrt(Math.pow(h-c,2)+Math.pow(f-l,2)),x:h,y:f}};OpenLayers.Layer.ArcGIS93Rest=OpenLayers.Class(OpenLayers.Layer.Grid,{DEFAULT_PARAMS:{format:"png"},isBaseLayer:true,initialize:function(d,c,f,b){var a=[];f=OpenLayers.Util.upperCaseObject(f);a.push(d,c,f,b);OpenLayers.Layer.Grid.prototype.initialize.apply(this,a);OpenLayers.Util.applyDefaults(this.params,OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS));if(this.params.TRANSPARENT&&this.params.TRANSPARENT.toString().toLowerCase()=="true"){if((b==null)||(!b.isBaseLayer)){this.isBaseLayer=false}if(this.params.FORMAT=="jpg"){this.params.FORMAT=OpenLayers.Util.alphaHack()?"gif":"png"}}},destroy:function(){OpenLayers.Layer.Grid.prototype.destroy.apply(this,arguments)},clone:function(a){if(a==null){a=new OpenLayers.Layer.ArcGIS93Rest(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a]);return a},getURL:function(f){f=this.adjustBounds(f);var d=this.projection.getCode().split(":");var c=d[d.length-1];var h=this.getImageSize();var j={BBOX:f.toBBOX(),SIZE:h.w+","+h.h,F:"image",BBOXSR:c,IMAGESR:c};if(this.layerDefs){var g=[];var a;for(a in this.layerDefs){if(this.layerDefs.hasOwnProperty(a)){if(this.layerDefs[a]){g.push(a);g.push(":");g.push(this.layerDefs[a]);g.push(";")}}}if(g.length>0){j.LAYERDEFS=g.join("")}}var b=this.getFullRequestString(j);return b},setLayerFilter:function(b,a){if(!this.layerDefs){this.layerDefs={}}if(a){this.layerDefs[b]=a}else{delete this.layerDefs[b]}},clearLayerFilter:function(a){if(a){delete this.layerDefs[a]}else{delete this.layerDefs}},mergeNewParams:function(c){var b=OpenLayers.Util.upperCaseObject(c);var a=[b];return OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,a)},addTile:function(b,a){return new OpenLayers.Tile.Image(this,a,b,null,this.tileSize)},CLASS_NAME:"OpenLayers.Layer.ArcGIS93Rest"});OpenLayers.Layer.KaMap=OpenLayers.Class(OpenLayers.Layer.Grid,{isBaseLayer:true,units:null,resolution:OpenLayers.DOTS_PER_INCH,DEFAULT_PARAMS:{i:"jpeg",map:""},initialize:function(d,c,f,b){var a=[];a.push(d,c,f,b);OpenLayers.Layer.Grid.prototype.initialize.apply(this,a);this.params=OpenLayers.Util.applyDefaults(this.params,this.DEFAULT_PARAMS)},getURL:function(c){c=this.adjustBounds(c);var d=this.map.getResolution();var f=Math.round((this.map.getScale()*10000))/10000;var b=Math.round(c.left/d);var a=-Math.round(c.top/d);return this.getFullRequestString({t:a,l:b,s:f})},addTile:function(c,a){var b=this.getURL(c);return new OpenLayers.Tile.Image(this,a,c,b,this.tileSize)},calculateGridLayout:function(a,s,f){var m=f*this.tileSize.w;var c=f*this.tileSize.h;var k=a.left;var o=Math.floor(k/m)-this.buffer;var l=k/m-o;var g=-l*this.tileSize.w;var q=o*m;var b=a.top;var j=Math.ceil(b/c)+this.buffer;var r=j-b/c;var d=-(r+1)*this.tileSize.h;var h=j*c;return{tilelon:m,tilelat:c,tileoffsetlon:q,tileoffsetlat:h,tileoffsetx:g,tileoffsety:d}},clone:function(a){if(a==null){a=new OpenLayers.Layer.KaMap(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a]);if(this.tileSize!=null){a.tileSize=this.tileSize.clone()}a.grid=[];return a},getTileBounds:function(c){var f=this.getResolution();var d=f*this.tileSize.w;var b=f*this.tileSize.h;var h=this.getLonLatFromViewPortPx(c);var a=d*Math.floor(h.lon/d);var g=b*Math.floor(h.lat/b);return new OpenLayers.Bounds(a,g,a+d,g+b)},CLASS_NAME:"OpenLayers.Layer.KaMap"});OpenLayers.Layer.MapGuide=OpenLayers.Class(OpenLayers.Layer.Grid,{isBaseLayer:true,useHttpTile:false,singleTile:false,useOverlay:false,useAsyncOverlay:true,TILE_PARAMS:{operation:"GETTILEIMAGE",version:"1.2.0"},SINGLE_TILE_PARAMS:{operation:"GETMAPIMAGE",format:"PNG",locale:"en",clip:"1",version:"1.0.0"},OVERLAY_PARAMS:{operation:"GETDYNAMICMAPOVERLAYIMAGE",format:"PNG",locale:"en",clip:"1",version:"2.0.0"},FOLDER_PARAMS:{tileColumnsPerFolder:30,tileRowsPerFolder:30,format:"png",querystring:null},defaultSize:new OpenLayers.Size(300,300),initialize:function(c,b,d,a){OpenLayers.Layer.Grid.prototype.initialize.apply(this,arguments);if(a==null||a.isBaseLayer==null){this.isBaseLayer=((this.transparent!="true")&&(this.transparent!=true))}if(a&&a.useOverlay!=null){this.useOverlay=a.useOverlay}if(this.singleTile){if(this.useOverlay){OpenLayers.Util.applyDefaults(this.params,this.OVERLAY_PARAMS);if(!this.useAsyncOverlay){this.params.version="1.0.0"}}else{OpenLayers.Util.applyDefaults(this.params,this.SINGLE_TILE_PARAMS)}}else{if(this.useHttpTile){OpenLayers.Util.applyDefaults(this.params,this.FOLDER_PARAMS)}else{OpenLayers.Util.applyDefaults(this.params,this.TILE_PARAMS)}this.setTileSize(this.defaultSize)}},clone:function(a){if(a==null){a=new OpenLayers.Layer.MapGuide(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a]);return a},addTile:function(b,a){return new OpenLayers.Tile.Image(this,a,b,null,this.tileSize)},getURL:function(a){var d;var b=a.getCenterLonLat();var j=this.map.getCurrentSize();if(this.singleTile){var f={setdisplaydpi:OpenLayers.DOTS_PER_INCH,setdisplayheight:j.h*this.ratio,setdisplaywidth:j.w*this.ratio,setviewcenterx:b.lon,setviewcentery:b.lat,setviewscale:this.map.getScale()};if(this.useOverlay&&!this.useAsyncOverlay){var k={};k=OpenLayers.Util.extend(k,f);k.operation="GETVISIBLEMAPEXTENT";k.version="1.0.0";k.session=this.params.session;k.mapName=this.params.mapName;k.format="text/xml";d=this.getFullRequestString(k);OpenLayers.Request.GET({url:d,async:false})}d=this.getFullRequestString(f)}else{var h=this.map.getResolution();var g=Math.floor((a.left-this.maxExtent.left)/h);g=Math.round(g/this.tileSize.w);var c=Math.floor((this.maxExtent.top-a.top)/h);c=Math.round(c/this.tileSize.h);if(this.useHttpTile){d=this.getImageFilePath({tilecol:g,tilerow:c,scaleindex:this.resolutions.length-this.map.zoom-1})}else{d=this.getFullRequestString({tilecol:g,tilerow:c,scaleindex:this.resolutions.length-this.map.zoom-1})}}return d},getFullRequestString:function(g,f){var b=(f==null)?this.url:f;if(typeof b=="object"){b=b[Math.floor(Math.random()*b.length)]}var k=b;var h=OpenLayers.Util.extend({},this.params);h=OpenLayers.Util.extend(h,g);var d=OpenLayers.Util.upperCaseObject(OpenLayers.Util.getArgs(b));for(var j in h){if(j.toUpperCase() in d){delete h[j]}}var a=OpenLayers.Util.getParameterString(h);a=a.replace(/,/g,"+");if(a!=""){var c=b.charAt(b.length-1);if((c=="&")||(c=="?")){k+=a}else{if(b.indexOf("?")==-1){k+="?"+a}else{k+="&"+a}}}return k},getImageFilePath:function(h,f){var c=(f==null)?this.url:f;if(typeof c=="object"){c=c[Math.floor(Math.random()*c.length)]}var b=c;var d="";var g="";if(h.tilerow<0){d="-"}if(h.tilerow==0){d+="0"}else{d+=Math.floor(Math.abs(h.tilerow/this.params.tileRowsPerFolder))*this.params.tileRowsPerFolder}if(h.tilecol<0){g="-"}if(h.tilecol==0){g+="0"}else{g+=Math.floor(Math.abs(h.tilecol/this.params.tileColumnsPerFolder))*this.params.tileColumnsPerFolder}var a="/S"+Math.floor(h.scaleindex)+"/"+this.params.basemaplayergroupname+"/R"+d+"/C"+g+"/"+(h.tilerow%this.params.tileRowsPerFolder)+"_"+(h.tilecol%this.params.tileColumnsPerFolder)+"."+this.params.format;if(this.params.querystring){a+="?"+this.params.querystring}b+=a;return b},calculateGridLayout:function(a,s,f){var m=f*this.tileSize.w;var c=f*this.tileSize.h;var k=a.left-s.left;var o=Math.floor(k/m)-this.buffer;var l=k/m-o;var g=-l*this.tileSize.w;var q=s.left+o*m;var b=s.top-a.top+c;var j=Math.floor(b/c)-this.buffer;var r=j-b/c;var d=r*this.tileSize.h;var h=s.top-c*j;return{tilelon:m,tilelat:c,tileoffsetlon:q,tileoffsetlat:h,tileoffsetx:g,tileoffsety:d}},CLASS_NAME:"OpenLayers.Layer.MapGuide"});OpenLayers.Layer.MapServer=OpenLayers.Class(OpenLayers.Layer.Grid,{DEFAULT_PARAMS:{mode:"map",map_imagetype:"png"},initialize:function(d,c,f,b){var a=[];a.push(d,c,f,b);OpenLayers.Layer.Grid.prototype.initialize.apply(this,a);this.params=OpenLayers.Util.applyDefaults(this.params,this.DEFAULT_PARAMS);if(b==null||b.isBaseLayer==null){this.isBaseLayer=((this.params.transparent!="true")&&(this.params.transparent!=true))}},clone:function(a){if(a==null){a=new OpenLayers.Layer.MapServer(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a]);return a},addTile:function(b,a){return new OpenLayers.Tile.Image(this,a,b,null,this.tileSize)},getURL:function(c){c=this.adjustBounds(c);var b=[c.left,c.bottom,c.right,c.top];var d=this.getImageSize();var a=this.getFullRequestString({mapext:b,imgext:b,map_size:[d.w,d.h],imgx:d.w/2,imgy:d.h/2,imgxy:[d.w,d.h]});return a},getFullRequestString:function(g,f){var b=(f==null)?this.url:f;var h=OpenLayers.Util.extend({},this.params);h=OpenLayers.Util.extend(h,g);var a=OpenLayers.Util.getParameterString(h);if(b instanceof Array){b=this.selectUrl(a,b)}var d=OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(b));for(var j in h){if(j.toUpperCase() in d){delete h[j]}}a=OpenLayers.Util.getParameterString(h);var k=b;a=a.replace(/,/g,"+");if(a!=""){var c=b.charAt(b.length-1);if((c=="&")||(c=="?")){k+=a}else{if(b.indexOf("?")==-1){k+="?"+a}else{k+="&"+a}}}return k},CLASS_NAME:"OpenLayers.Layer.MapServer"});OpenLayers.Layer.TMS=OpenLayers.Class(OpenLayers.Layer.Grid,{serviceVersion:"1.0.0",isBaseLayer:true,tileOrigin:null,serverResolutions:null,initialize:function(d,c,b){var a=[];a.push(d,c,{},b);OpenLayers.Layer.Grid.prototype.initialize.apply(this,a)},destroy:function(){OpenLayers.Layer.Grid.prototype.destroy.apply(this,arguments)},clone:function(a){if(a==null){a=new OpenLayers.Layer.TMS(this.name,this.url,this.options)}a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a]);return a},getURL:function(d){d=this.adjustBounds(d);var c=this.map.getResolution();var a=Math.round((d.left-this.tileOrigin.lon)/(c*this.tileSize.w));var h=Math.round((d.bottom-this.tileOrigin.lat)/(c*this.tileSize.h));var g=this.serverResolutions!=null?OpenLayers.Util.indexOf(this.serverResolutions,c):this.map.getZoom();var f=this.serviceVersion+"/"+this.layername+"/"+g+"/"+a+"/"+h+"."+this.type;var b=this.url;if(b instanceof Array){b=this.selectUrl(f,b)}return b+f},addTile:function(b,a){return new OpenLayers.Tile.Image(this,a,b,null,this.tileSize)},setMap:function(a){OpenLayers.Layer.Grid.prototype.setMap.apply(this,arguments);if(!this.tileOrigin){this.tileOrigin=new OpenLayers.LonLat(this.map.maxExtent.left,this.map.maxExtent.bottom)}},CLASS_NAME:"OpenLayers.Layer.TMS"});OpenLayers.Layer.TileCache=OpenLayers.Class(OpenLayers.Layer.Grid,{isBaseLayer:true,format:"image/png",serverResolutions:null,initialize:function(c,b,d,a){this.layername=d;OpenLayers.Layer.Grid.prototype.initialize.apply(this,[c,b,{},a]);this.extension=this.format.split("/")[1].toLowerCase();this.extension=(this.extension=="jpg")?"jpeg":this.extension},clone:function(a){if(a==null){a=new OpenLayers.Layer.TileCache(this.name,this.url,this.layername,this.options)}a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a]);return a},getURL:function(b){var g=this.map.getResolution();var h=this.maxExtent;var m=this.tileSize;var a=Math.round((b.left-h.left)/(g*m.w));var l=Math.round((b.bottom-h.bottom)/(g*m.h));var j=this.serverResolutions!=null?OpenLayers.Util.indexOf(this.serverResolutions,g):this.map.getZoom();function f(s,r){s=String(s);var o=[];for(var q=0;q<r;++q){o.push("0")}return o.join("").substring(0,r-s.length)+s}var d=[this.layername,f(j,2),f(parseInt(a/1000000),3),f((parseInt(a/1000)%1000),3),f((parseInt(a)%1000),3),f(parseInt(l/1000000),3),f((parseInt(l/1000)%1000),3),f((parseInt(l)%1000),3)+"."+this.extension];var k=d.join("/");var c=this.url;if(c instanceof Array){c=this.selectUrl(k,c)}c=(c.charAt(c.length-1)=="/")?c:c+"/";return c+k},addTile:function(c,a){var b=this.getURL(c);return new OpenLayers.Tile.Image(this,a,c,b,this.tileSize)},CLASS_NAME:"OpenLayers.Layer.TileCache"});OpenLayers.Layer.WMS=OpenLayers.Class(OpenLayers.Layer.Grid,{DEFAULT_PARAMS:{service:"WMS",version:"1.1.1",request:"GetMap",styles:"",exceptions:"application/vnd.ogc.se_inimage",format:"image/jpeg"},reproject:false,isBaseLayer:true,encodeBBOX:false,noMagic:false,initialize:function(d,c,f,b){var a=[];f=OpenLayers.Util.upperCaseObject(f);a.push(d,c,f,b);OpenLayers.Layer.Grid.prototype.initialize.apply(this,a);OpenLayers.Util.applyDefaults(this.params,OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS));if(!this.noMagic&&this.params.TRANSPARENT&&this.params.TRANSPARENT.toString().toLowerCase()=="true"){if((b==null)||(!b.isBaseLayer)){this.isBaseLayer=false}if(this.params.FORMAT=="image/jpeg"){this.params.FORMAT=OpenLayers.Util.alphaHack()?"image/gif":"image/png"}}},destroy:function(){OpenLayers.Layer.Grid.prototype.destroy.apply(this,arguments)},clone:function(a){if(a==null){a=new OpenLayers.Layer.WMS(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a]);return a},getURL:function(b){b=this.adjustBounds(b);var c=this.getImageSize();var d={BBOX:this.encodeBBOX?b.toBBOX():b.toArray(),WIDTH:c.w,HEIGHT:c.h};var a=this.getFullRequestString(d);return a},addTile:function(b,a){return new OpenLayers.Tile.Image(this,a,b,null,this.tileSize)},mergeNewParams:function(c){var b=OpenLayers.Util.upperCaseObject(c);var a=[b];return OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,a)},getFullRequestString:function(c,b){var a=this.map.getProjection();this.params.SRS=(a=="none")?null:a;return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(this,arguments)},CLASS_NAME:"OpenLayers.Layer.WMS"});OpenLayers.Layer.WorldWind=OpenLayers.Class(OpenLayers.Layer.Grid,{DEFAULT_PARAMS:{},isBaseLayer:true,lzd:null,zoomLevels:null,initialize:function(d,c,f,h,g,b){this.lzd=f;this.zoomLevels=h;var a=[];a.push(d,c,g,b);OpenLayers.Layer.Grid.prototype.initialize.apply(this,a);this.params=OpenLayers.Util.applyDefaults(this.params,this.DEFAULT_PARAMS)},addTile:function(b,a){return new OpenLayers.Tile.Image(this,a,b,null,this.tileSize)},getZoom:function(){var b=this.map.getZoom();var a=this.map.getMaxExtent();b=b-Math.log(this.maxResolution/(this.lzd/512))/Math.log(2);return b},getURL:function(f){f=this.adjustBounds(f);var d=this.getZoom();var b=this.map.getMaxExtent();var c=this.lzd/Math.pow(2,this.getZoom());var a=Math.floor((f.left-b.left)/c);var g=Math.floor((f.bottom-b.bottom)/c);if(this.map.getResolution()<=(this.lzd/512)&&this.getZoom()<=this.zoomLevels){return this.getFullRequestString({L:d,X:a,Y:g})}else{return OpenLayers.Util.getImagesLocation()+"blank.gif"}},CLASS_NAME:"OpenLayers.Layer.WorldWind"});OpenLayers.Layer.XYZ=OpenLayers.Class(OpenLayers.Layer.Grid,{isBaseLayer:true,sphericalMercator:false,initialize:function(d,c,b){if(b&&b.sphericalMercator||this.sphericalMercator){b=OpenLayers.Util.extend({maxExtent:new OpenLayers.Bounds(-128*156543.0339,-128*156543.0339,128*156543.0339,128*156543.0339),maxResolution:156543.0339,numZoomLevels:19,units:"m",projection:"EPSG:900913"},b)}c=c||this.url;d=d||this.name;var a=[d,c,{},b];OpenLayers.Layer.Grid.prototype.initialize.apply(this,a)},clone:function(a){if(a==null){a=new OpenLayers.Layer.XYZ(this.name,this.url,this.options)}a=OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this,[a]);if(this.tileSize!=null){a.tileSize=this.tileSize.clone()}a.grid=[];return a},getURL:function(a){var d=this.map.getResolution();var h=Math.round((a.left-this.maxExtent.left)/(d*this.tileSize.w));var g=Math.round((this.maxExtent.top-a.top)/(d*this.tileSize.h));var f=this.map.getZoom();var c=Math.pow(2,f);var b=this.url;var k=""+h+g+f;if(b instanceof Array){b=this.selectUrl(k,b)}var j=OpenLayers.String.format(b,{x:h,y:g,z:f});return j},addTile:function(b,a){return new OpenLayers.Tile.Image(this,a,b,null,this.tileSize)},setMap:function(a){OpenLayers.Layer.Grid.prototype.setMap.apply(this,arguments);if(!this.tileOrigin){this.tileOrigin=new OpenLayers.LonLat(this.maxExtent.left,this.maxExtent.bottom)}},CLASS_NAME:"OpenLayers.Layer.XYZ"});OpenLayers.Layer.OSM=OpenLayers.Class(OpenLayers.Layer.XYZ,{name:"OpenStreetMap",attribution:"Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",sphericalMercator:true,url:"http://tile.openstreetmap.org/${z}/${x}/${y}.png",CLASS_NAME:"OpenLayers.Layer.OSM"});OpenLayers.Protocol.SQL.Gears=OpenLayers.Class(OpenLayers.Protocol.SQL,{FID_PREFIX:"__gears_fid__",NULL_GEOMETRY:"__gears_null_geometry__",NULL_FEATURE_STATE:"__gears_null_feature_state__",jsonParser:null,wktParser:null,fidRegExp:null,saveFeatureState:true,typeOfFid:"string",db:null,initialize:function(a){if(!this.supported()){return}OpenLayers.Protocol.SQL.prototype.initialize.apply(this,[a]);this.jsonParser=new OpenLayers.Format.JSON();this.wktParser=new OpenLayers.Format.WKT();this.fidRegExp=new RegExp("^"+this.FID_PREFIX);this.initializeDatabase()},initializeDatabase:function(){this.db=google.gears.factory.create("beta.database");this.db.open(this.databaseName);this.db.execute("CREATE TABLE IF NOT EXISTS "+this.tableName+" (fid TEXT UNIQUE, geometry TEXT, properties TEXT,  state TEXT)")},destroy:function(){this.db.close();this.db=null;this.jsonParser=null;this.wktParser=null;OpenLayers.Protocol.SQL.prototype.destroy.apply(this)},supported:function(){return !!(window.google&&google.gears)},read:function(b){b=OpenLayers.Util.applyDefaults(b,this.options);var c,d=[];var a=this.db.execute("SELECT * FROM "+this.tableName);while(a.isValidRow()){c=this.unfreezeFeature(a);if(this.evaluateFilter(c,b.filter)){if(!b.noFeatureStateReset){c.state=null}d.push(c)}a.next()}a.close();var f=new OpenLayers.Protocol.Response({code:OpenLayers.Protocol.Response.SUCCESS,requestType:"read",features:d});if(b&&b.callback){b.callback.call(b.scope,f)}return f},unfreezeFeature:function(d){var a;var b=d.fieldByName("geometry");if(b==this.NULL_GEOMETRY){a=new OpenLayers.Feature.Vector()}else{a=this.wktParser.read(b)}a.attributes=this.jsonParser.read(d.fieldByName("properties"));a.fid=this.extractFidFromField(d.fieldByName("fid"));var c=d.fieldByName("state");if(c==this.NULL_FEATURE_STATE){c=null}a.state=c;return a},extractFidFromField:function(a){if(!a.match(this.fidRegExp)&&this.typeOfFid=="number"){a=parseFloat(a)}return a},create:function(b,a){a=OpenLayers.Util.applyDefaults(a,this.options);var c=this.createOrUpdate(b);c.requestType="create";if(a&&a.callback){a.callback.call(a.scope,c)}return c},update:function(b,a){a=OpenLayers.Util.applyDefaults(a,this.options);var c=this.createOrUpdate(b);c.requestType="update";if(a&&a.callback){a.callback.call(a.scope,c)}return c},createOrUpdate:function(f){if(!(f instanceof Array)){f=[f]}var c,a=f.length,b;var d=new Array(a);for(c=0;c<a;c++){b=f[c];var g=this.freezeFeature(b);this.db.execute("REPLACE INTO "+this.tableName+" (fid, geometry, properties, state) VALUES (?, ?, ?, ?)",g);var h=b.clone();h.fid=this.extractFidFromField(g[0]);d[c]=h}return new OpenLayers.Protocol.Response({code:OpenLayers.Protocol.Response.SUCCESS,features:d,reqFeatures:f})},freezeFeature:function(b){b.fid=b.fid!=null?""+b.fid:OpenLayers.Util.createUniqueID(this.FID_PREFIX);var d=b.geometry!=null?b.geometry.toString():this.NULL_GEOMETRY;var a=this.jsonParser.write(b.attributes);var c=this.getFeatureStateForFreeze(b);return[b.fid,d,a,c]},getFeatureStateForFreeze:function(a){var b;if(!this.saveFeatureState){b=this.NULL_FEATURE_STATE}else{if(this.createdOffline(a)){b=OpenLayers.State.INSERT}else{b=a.state}}return b},"delete":function(g,c){if(!(g instanceof Array)){g=[g]}c=OpenLayers.Util.applyDefaults(c,this.options);var f,a,d;for(f=0,a=g.length;f<a;f++){d=g[f];if(this.saveFeatureState&&!this.createdOffline(d)){var b=d.clone();b.fid=d.fid;if(b.geometry){b.geometry.destroy();b.geometry=null}b.state=d.state;this.createOrUpdate(b)}else{this.db.execute("DELETE FROM "+this.tableName+" WHERE fid = ?",[d.fid])}}var h=new OpenLayers.Protocol.Response({code:OpenLayers.Protocol.Response.SUCCESS,requestType:"delete",reqFeatures:g});if(c&&c.callback){c.callback.call(c.scope,h)}return h},createdOffline:function(a){return(typeof a.fid=="string"&&!!(a.fid.match(this.fidRegExp)))},commit:function(c,o){var b,f=[],h=0,j=0;function l(q){if(++j<h){q.last=false}this.callUserCallback(o,q)}var m,k=[],a=[],d=[];for(var g=c.length-1;g>=0;g--){m=c[g];switch(m.state){case OpenLayers.State.INSERT:k.push(m);break;case OpenLayers.State.UPDATE:a.push(m);break;case OpenLayers.State.DELETE:d.push(m);break}}if(k.length>0){h++;b=OpenLayers.Util.applyDefaults({callback:l,scope:this},o.create);f.push(this.create(k,b))}if(a.length>0){h++;b=OpenLayers.Util.applyDefaults({callback:l,scope:this},o.update);f.push(this.update(a,b))}if(d.length>0){h++;b=OpenLayers.Util.applyDefaults({callback:l,scope:this},o["delete"]);f.push(this["delete"](d,b))}return f},clear:function(){this.db.execute("DELETE FROM "+this.tableName)},callUserCallback:function(a,c){var b=a[c.requestType];if(b&&b.callback){b.callback.call(b.scope,c)}if(c.last&&a.callback){a.callback.call(a.scope)}},CLASS_NAME:"OpenLayers.Protocol.SQL.Gears"});OpenLayers.Rule=OpenLayers.Class({id:null,name:"default",title:null,description:null,context:null,filter:null,elseFilter:false,symbolizer:null,minScaleDenominator:null,maxScaleDenominator:null,initialize:function(a){this.symbolizer={};OpenLayers.Util.extend(this,a);this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_")},destroy:function(){for(var a in this.symbolizer){this.symbolizer[a]=null}this.symbolizer=null},evaluate:function(c){var b=this.getContext(c);var a=true;if(this.minScaleDenominator||this.maxScaleDenominator){var d=c.layer.map.getScale()}if(this.minScaleDenominator){a=d>=OpenLayers.Style.createLiteral(this.minScaleDenominator,b)}if(a&&this.maxScaleDenominator){a=d<OpenLayers.Style.createLiteral(this.maxScaleDenominator,b)}if(a&&this.filter){if(this.filter.CLASS_NAME=="OpenLayers.Filter.FeatureId"){a=this.filter.evaluate(c)}else{a=this.filter.evaluate(b)}}return a},getContext:function(b){var a=this.context;if(!a){a=b.attributes||b.data}if(typeof this.context=="function"){a=this.context(b)}return a},clone:function(){var a=OpenLayers.Util.extend({},this);a.symbolizer={};for(var b in this.symbolizer){value=this.symbolizer[b];type=typeof value;if(type==="object"){a.symbolizer[b]=OpenLayers.Util.extend({},value)}else{if(type==="string"){a.symbolizer[b]=value}}}a.filter=this.filter&&this.filter.clone();a.context=this.context&&OpenLayers.Util.extend({},this.context);return new OpenLayers.Rule(a)},CLASS_NAME:"OpenLayers.Rule"});OpenLayers.StyleMap=OpenLayers.Class({styles:null,extendDefault:true,initialize:function(c,a){this.styles={"default":new OpenLayers.Style(OpenLayers.Feature.Vector.style["default"]),select:new OpenLayers.Style(OpenLayers.Feature.Vector.style.select),temporary:new OpenLayers.Style(OpenLayers.Feature.Vector.style.temporary),"delete":new OpenLayers.Style(OpenLayers.Feature.Vector.style["delete"])};if(c instanceof OpenLayers.Style){this.styles["default"]=c;this.styles.select=c;this.styles.temporary=c;this.styles["delete"]=c}else{if(typeof c=="object"){for(var b in c){if(c[b] instanceof OpenLayers.Style){this.styles[b]=c[b]}else{if(typeof c[b]=="object"){this.styles[b]=new OpenLayers.Style(c[b])}else{this.styles["default"]=new OpenLayers.Style(c);this.styles.select=new OpenLayers.Style(c);this.styles.temporary=new OpenLayers.Style(c);this.styles["delete"]=new OpenLayers.Style(c);break}}}}}OpenLayers.Util.extend(this,a)},destroy:function(){for(var a in this.styles){this.styles[a].destroy()}this.styles=null},createSymbolizer:function(b,c){if(!b){b=new OpenLayers.Feature.Vector()}if(!this.styles[c]){c="default"}b.renderIntent=c;var a={};if(this.extendDefault&&c!="default"){a=this.styles["default"].createSymbolizer(b)}return OpenLayers.Util.extend(a,this.styles[c].createSymbolizer(b))},addUniqueValueRules:function(b,d,g,a){var f=[];for(var c in g){f.push(new OpenLayers.Rule({symbolizer:g[c],context:a,filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:d,value:c})}))}this.styles[b].addRules(f)},CLASS_NAME:"OpenLayers.StyleMap"});OpenLayers.Control.NavToolbar=OpenLayers.Class(OpenLayers.Control.Panel,{initialize:function(a){OpenLayers.Control.Panel.prototype.initialize.apply(this,[a]);this.addControls([new OpenLayers.Control.Navigation(),new OpenLayers.Control.ZoomBox()])},draw:function(){var a=OpenLayers.Control.Panel.prototype.draw.apply(this,arguments);this.activateControl(this.controls[0]);return a},CLASS_NAME:"OpenLayers.Control.NavToolbar"});OpenLayers.Filter.Comparison=OpenLayers.Class(OpenLayers.Filter,{type:null,property:null,value:null,matchCase:true,lowerBoundary:null,upperBoundary:null,initialize:function(a){OpenLayers.Filter.prototype.initialize.apply(this,[a])},evaluate:function(c){var a=false;switch(this.type){case OpenLayers.Filter.Comparison.EQUAL_TO:var b=c[this.property];var f=this.value;if(!this.matchCase&&typeof b=="string"&&typeof f=="string"){a=(b.toUpperCase()==f.toUpperCase())}else{a=(b==f)}break;case OpenLayers.Filter.Comparison.NOT_EQUAL_TO:var b=c[this.property];var f=this.value;if(!this.matchCase&&typeof b=="string"&&typeof f=="string"){a=(b.toUpperCase()!=f.toUpperCase())}else{a=(b!=f)}break;case OpenLayers.Filter.Comparison.LESS_THAN:a=c[this.property]<this.value;break;case OpenLayers.Filter.Comparison.GREATER_THAN:a=c[this.property]>this.value;break;case OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO:a=c[this.property]<=this.value;break;case OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO:a=c[this.property]>=this.value;break;case OpenLayers.Filter.Comparison.BETWEEN:a=(c[this.property]>=this.lowerBoundary)&&(c[this.property]<=this.upperBoundary);break;case OpenLayers.Filter.Comparison.LIKE:var d=new RegExp(this.value,"gi");a=d.test(c[this.property]);break}return a},value2regex:function(d,b,a){if(d=="."){var c="'.' is an unsupported wildCard character for OpenLayers.Filter.Comparison";OpenLayers.Console.error(c);return null}d=d?d:"*";b=b?b:".";a=a?a:"!";this.value=this.value.replace(new RegExp("\\"+a+"(.|$)","g"),"\\$1");this.value=this.value.replace(new RegExp("\\"+b,"g"),".");this.value=this.value.replace(new RegExp("\\"+d,"g"),".*");this.value=this.value.replace(new RegExp("\\\\.\\*","g"),"\\"+d);this.value=this.value.replace(new RegExp("\\\\\\.","g"),"\\"+b);return this.value},regex2value:function(){var a=this.value;a=a.replace(/!/g,"!!");a=a.replace(/(\\)?\\\./g,function(c,b){return b?c:"!."});a=a.replace(/(\\)?\\\*/g,function(c,b){return b?c:"!*"});a=a.replace(/\\\\/g,"\\");a=a.replace(/\.\*/g,"*");return a},clone:function(){return OpenLayers.Util.extend(new OpenLayers.Filter.Comparison(),this)},CLASS_NAME:"OpenLayers.Filter.Comparison"});OpenLayers.Filter.Comparison.EQUAL_TO="==";OpenLayers.Filter.Comparison.NOT_EQUAL_TO="!=";OpenLayers.Filter.Comparison.LESS_THAN="<";OpenLayers.Filter.Comparison.GREATER_THAN=">";OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO="<=";OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO=">=";OpenLayers.Filter.Comparison.BETWEEN="..";OpenLayers.Filter.Comparison.LIKE="~";OpenLayers.Filter.FeatureId=OpenLayers.Class(OpenLayers.Filter,{fids:null,initialize:function(a){this.fids=[];OpenLayers.Filter.prototype.initialize.apply(this,[a])},evaluate:function(c){for(var b=0,a=this.fids.length;b<a;b++){var d=c.fid||c.id;if(d==this.fids[b]){return true}}return false},clone:function(){var a=new OpenLayers.Filter.FeatureId();OpenLayers.Util.extend(a,this);a.fids=this.fids.slice();return a},CLASS_NAME:"OpenLayers.Filter.FeatureId"});OpenLayers.Filter.Logical=OpenLayers.Class(OpenLayers.Filter,{filters:null,type:null,initialize:function(a){this.filters=[];OpenLayers.Filter.prototype.initialize.apply(this,[a])},destroy:function(){this.filters=null;OpenLayers.Filter.prototype.destroy.apply(this)},evaluate:function(c){switch(this.type){case OpenLayers.Filter.Logical.AND:for(var b=0,a=this.filters.length;b<a;b++){if(this.filters[b].evaluate(c)==false){return false}}return true;case OpenLayers.Filter.Logical.OR:for(var b=0,a=this.filters.length;b<a;b++){if(this.filters[b].evaluate(c)==true){return true}}return false;case OpenLayers.Filter.Logical.NOT:return(!this.filters[0].evaluate(c))}},clone:function(){var c=[];for(var b=0,a=this.filters.length;b<a;++b){c.push(this.filters[b].clone())}return new OpenLayers.Filter.Logical({type:this.type,filters:c})},CLASS_NAME:"OpenLayers.Filter.Logical"});OpenLayers.Filter.Logical.AND="&&";OpenLayers.Filter.Logical.OR="||";OpenLayers.Filter.Logical.NOT="!";OpenLayers.Filter.Spatial=OpenLayers.Class(OpenLayers.Filter,{type:null,property:null,value:null,distance:null,distanceUnits:null,initialize:function(a){OpenLayers.Filter.prototype.initialize.apply(this,[a])},evaluate:function(c){var a=false;switch(this.type){case OpenLayers.Filter.Spatial.BBOX:case OpenLayers.Filter.Spatial.INTERSECTS:if(c.geometry){var b=this.value;if(this.value.CLASS_NAME=="OpenLayers.Bounds"){b=this.value.toGeometry()}if(c.geometry.intersects(b)){a=true}}break;default:OpenLayers.Console.error(OpenLayers.i18n("filterEvaluateNotImplemented"));break}return a},clone:function(){var a=OpenLayers.Util.applyDefaults({value:this.value&&this.value.clone&&this.value.clone()},this);return new OpenLayers.Filter.Spatial(a)},CLASS_NAME:"OpenLayers.Filter.Spatial"});OpenLayers.Filter.Spatial.BBOX="BBOX";OpenLayers.Filter.Spatial.INTERSECTS="INTERSECTS";OpenLayers.Filter.Spatial.DWITHIN="DWITHIN";OpenLayers.Filter.Spatial.WITHIN="WITHIN";OpenLayers.Filter.Spatial.CONTAINS="CONTAINS";OpenLayers.Geometry.Collection=OpenLayers.Class(OpenLayers.Geometry,{components:null,componentTypes:null,initialize:function(a){OpenLayers.Geometry.prototype.initialize.apply(this,arguments);this.components=[];if(a!=null){this.addComponents(a)}},destroy:function(){this.components.length=0;this.components=null},clone:function(){var geometry=eval("new "+this.CLASS_NAME+"()");for(var i=0,len=this.components.length;i<len;i++){geometry.addComponent(this.components[i].clone())}OpenLayers.Util.applyDefaults(geometry,this);return geometry},getComponentsString:function(){var b=[];for(var c=0,a=this.components.length;c<a;c++){b.push(this.components[c].toShortString())}return b.join(",")},calculateBounds:function(){this.bounds=null;if(this.components&&this.components.length>0){this.setBounds(this.components[0].getBounds());for(var b=1,a=this.components.length;b<a;b++){this.extendBounds(this.components[b].getBounds())}}},addComponents:function(c){if(!(c instanceof Array)){c=[c]}for(var b=0,a=c.length;b<a;b++){this.addComponent(c[b])}},addComponent:function(b,a){var d=false;if(b){if(this.componentTypes==null||(OpenLayers.Util.indexOf(this.componentTypes,b.CLASS_NAME)>-1)){if(a!=null&&(a<this.components.length)){var f=this.components.slice(0,a);var c=this.components.slice(a,this.components.length);f.push(b);this.components=f.concat(c)}else{this.components.push(b)}b.parent=this;this.clearBounds();d=true}}return d},removeComponents:function(b){if(!(b instanceof Array)){b=[b]}for(var a=b.length-1;a>=0;--a){this.removeComponent(b[a])}},removeComponent:function(a){OpenLayers.Util.removeItem(this.components,a);this.clearBounds()},getLength:function(){var c=0;for(var b=0,a=this.components.length;b<a;b++){c+=this.components[b].getLength()}return c},getArea:function(){var c=0;for(var b=0,a=this.components.length;b<a;b++){c+=this.components[b].getArea()}return c},getGeodesicArea:function(b){var d=0;for(var c=0,a=this.components.length;c<a;c++){d+=this.components[c].getGeodesicArea(b)}return d},getCentroid:function(){return this.components.length&&this.components[0].getCentroid()},getGeodesicLength:function(b){var d=0;for(var c=0,a=this.components.length;c<a;c++){d+=this.components[c].getGeodesicLength(b)}return d},move:function(b,d){for(var c=0,a=this.components.length;c<a;c++){this.components[c].move(b,d)}},rotate:function(d,b){for(var c=0,a=this.components.length;c<a;++c){this.components[c].rotate(d,b)}},resize:function(d,a,c){for(var b=0;b<this.components.length;++b){this.components[b].resize(d,a,c)}return this},distanceTo:function(h,j){var b=!(j&&j.edge===false);var a=b&&j&&j.details;var k,c;var d=Number.POSITIVE_INFINITY;for(var f=0,g=this.components.length;f<g;++f){k=this.components[f].distanceTo(h,j);distance=a?k.distance:k;if(distance<d){d=distance;c=k;if(d==0){break}}}return c},equals:function(d){var b=true;if(!d||!d.CLASS_NAME||(this.CLASS_NAME!=d.CLASS_NAME)){b=false}else{if(!(d.components instanceof Array)||(d.components.length!=this.components.length)){b=false}else{for(var c=0,a=this.components.length;c<a;++c){if(!this.components[c].equals(d.components[c])){b=false;break}}}}return b},transform:function(f,c){if(f&&c){for(var d=0,a=this.components.length;d<a;d++){var b=this.components[d];b.transform(f,c)}this.bounds=null}return this},intersects:function(d){var b=false;for(var c=0,a=this.components.length;c<a;++c){b=d.intersects(this.components[c]);if(b){break}}return b},getVertices:function(b){var c=[];for(var d=0,a=this.components.length;d<a;++d){Array.prototype.push.apply(c,this.components[d].getVertices(b))}return c},CLASS_NAME:"OpenLayers.Geometry.Collection"});OpenLayers.Geometry.Point=OpenLayers.Class(OpenLayers.Geometry,{x:null,y:null,initialize:function(a,b){OpenLayers.Geometry.prototype.initialize.apply(this,arguments);this.x=parseFloat(a);this.y=parseFloat(b)},clone:function(a){if(a==null){a=new OpenLayers.Geometry.Point(this.x,this.y)}OpenLayers.Util.applyDefaults(a,this);return a},calculateBounds:function(){this.bounds=new OpenLayers.Bounds(this.x,this.y,this.x,this.y)},distanceTo:function(g,l){var d=!(l&&l.edge===false);var a=d&&l&&l.details;var b,f,j,c,h,k;if(g instanceof OpenLayers.Geometry.Point){f=this.x;j=this.y;c=g.x;h=g.y;b=Math.sqrt(Math.pow(f-c,2)+Math.pow(j-h,2));k=!a?b:{x0:f,y0:j,x1:c,y1:h,distance:b}}else{k=g.distanceTo(this,l);if(a){k={x0:k.x1,y0:k.y1,x1:k.x0,y1:k.y0,distance:k.distance}}}return k},equals:function(a){var b=false;if(a!=null){b=((this.x==a.x&&this.y==a.y)||(isNaN(this.x)&&isNaN(this.y)&&isNaN(a.x)&&isNaN(a.y)))}return b},toShortString:function(){return(this.x+", "+this.y)},move:function(a,b){this.x=this.x+a;this.y=this.y+b;this.clearBounds()},rotate:function(d,b){d*=Math.PI/180;var a=this.distanceTo(b);var c=d+Math.atan2(this.y-b.y,this.x-b.x);this.x=b.x+(a*Math.cos(c));this.y=b.y+(a*Math.sin(c));this.clearBounds()},getCentroid:function(){return new OpenLayers.Geometry.Point(this.x,this.y)},resize:function(c,a,b){b=(b==undefined)?1:b;this.x=a.x+(c*b*(this.x-a.x));this.y=a.y+(c*(this.y-a.y));this.clearBounds();return this},intersects:function(b){var a=false;if(b.CLASS_NAME=="OpenLayers.Geometry.Point"){a=this.equals(b)}else{a=b.intersects(this)}return a},transform:function(b,a){if((b&&a)){OpenLayers.Projection.transform(this,b,a);this.bounds=null}return this},getVertices:function(a){return[this]},CLASS_NAME:"OpenLayers.Geometry.Point"});OpenLayers.Geometry.Rectangle=OpenLayers.Class(OpenLayers.Geometry,{x:null,y:null,width:null,height:null,initialize:function(b,d,c,a){OpenLayers.Geometry.prototype.initialize.apply(this,arguments);this.x=b;this.y=d;this.width=c;this.height=a},calculateBounds:function(){this.bounds=new OpenLayers.Bounds(this.x,this.y,this.x+this.width,this.y+this.height)},getLength:function(){var a=(2*this.width)+(2*this.height);return a},getArea:function(){var a=this.width*this.height;return a},CLASS_NAME:"OpenLayers.Geometry.Rectangle"});OpenLayers.Geometry.Surface=OpenLayers.Class(OpenLayers.Geometry,{initialize:function(){OpenLayers.Geometry.prototype.initialize.apply(this,arguments)},CLASS_NAME:"OpenLayers.Geometry.Surface"});OpenLayers.Layer.KaMapCache=OpenLayers.Class(OpenLayers.Layer.KaMap,{IMAGE_EXTENSIONS:{jpeg:"jpg",gif:"gif",png:"png",png8:"png",png24:"png",dithered:"png"},DEFAULT_FORMAT:"jpeg",initialize:function(c,b,d,a){OpenLayers.Layer.KaMap.prototype.initialize.apply(this,arguments);this.extension=this.IMAGE_EXTENSIONS[this.params.i.toLowerCase()||DEFAULT_FORMAT]},getURL:function(a){a=this.adjustBounds(a);var g=this.map.getResolution();var f=Math.round((this.map.getScale()*10000))/10000;var d=Math.round(a.left/g);var c=-Math.round(a.top/g);var k=Math.floor(d/this.tileSize.w/this.params.metaTileSize.w)*this.tileSize.w*this.params.metaTileSize.w;var j=Math.floor(c/this.tileSize.h/this.params.metaTileSize.h)*this.tileSize.h*this.params.metaTileSize.h;var b=this.url;if(b instanceof Array){b=this.selectUrl(paramsString,b)}var h=[b,"/",this.params.map,"/",f,"/",this.params.g.replace(/\s/g,"_"),"/def/t",j,"/l",k,"/t",c,"l",d,".",this.extension];return h.join("")},CLASS_NAME:"OpenLayers.Layer.KaMapCache"});OpenLayers.Layer.MapServer.Untiled=OpenLayers.Class(OpenLayers.Layer.MapServer,{singleTile:true,initialize:function(c,b,f,a){OpenLayers.Layer.MapServer.prototype.initialize.apply(this,arguments);var d="The OpenLayers.Layer.MapServer.Untiled class is deprecated and will be removed in 3.0. Instead, you should use the normal OpenLayers.Layer.MapServer class, passing it the option 'singleTile' as true.";OpenLayers.Console.warn(d)},clone:function(a){if(a==null){a=new OpenLayers.Layer.MapServer.Untiled(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.MapServer.prototype.clone.apply(this,[a]);return a},CLASS_NAME:"OpenLayers.Layer.MapServer.Untiled"});OpenLayers.Layer.Vector=OpenLayers.Class(OpenLayers.Layer,{EVENT_TYPES:["beforefeatureadded","beforefeaturesadded","featureadded","featuresadded","beforefeatureremoved","featureremoved","featuresremoved","beforefeatureselected","featureselected","featureunselected","beforefeaturemodified","featuremodified","afterfeaturemodified","vertexmodified","sketchstarted","sketchmodified","sketchcomplete","refresh"],isBaseLayer:false,isFixed:false,isVector:true,features:null,selectedFeatures:null,unrenderedFeatures:null,reportError:true,style:null,styleMap:null,strategies:null,protocol:null,renderers:["SVG","VML","Canvas"],renderer:null,rendererOptions:null,geometryType:null,drawn:false,initialize:function(c,b){this.EVENT_TYPES=OpenLayers.Layer.Vector.prototype.EVENT_TYPES.concat(OpenLayers.Layer.prototype.EVENT_TYPES);OpenLayers.Layer.prototype.initialize.apply(this,arguments);if(!this.renderer||!this.renderer.supported()){this.assignRenderer()}if(!this.renderer||!this.renderer.supported()){this.renderer=null;this.displayError()}if(!this.styleMap){this.styleMap=new OpenLayers.StyleMap()}this.features=[];this.selectedFeatures=[];this.unrenderedFeatures={};if(this.strategies){for(var d=0,a=this.strategies.length;d<a;d++){this.strategies[d].setLayer(this)}}},destroy:function(){if(this.strategies){var c,b,a;for(b=0,a=this.strategies.length;b<a;b++){c=this.strategies[b];if(c.autoDestroy){c.destroy()}}this.strategies=null}if(this.protocol){if(this.protocol.autoDestroy){this.protocol.destroy()}this.protocol=null}this.destroyFeatures();this.features=null;this.selectedFeatures=null;this.unrenderedFeatures=null;if(this.renderer){this.renderer.destroy()}this.renderer=null;this.geometryType=null;this.drawn=null;OpenLayers.Layer.prototype.destroy.apply(this,arguments)},refresh:function(a){if(this.calculateInRange()&&this.visibility){this.events.triggerEvent("refresh",a)}},assignRenderer:function(){for(var c=0,a=this.renderers.length;c<a;c++){var b=OpenLayers.Renderer[this.renderers[c]];if(b&&b.prototype.supported()){this.renderer=new b(this.div,this.rendererOptions);break}}},displayError:function(){if(this.reportError){OpenLayers.Console.userError(OpenLayers.i18n("browserNotSupported",{renderers:this.renderers.join("\n")}))}},setMap:function(a){OpenLayers.Layer.prototype.setMap.apply(this,arguments);if(!this.renderer){this.map.removeLayer(this)}else{this.renderer.map=this.map;this.renderer.setSize(this.map.getSize())}},afterAdd:function(){if(this.strategies){var c,b,a;for(b=0,a=this.strategies.length;b<a;b++){c=this.strategies[b];if(c.autoActivate){c.activate()}}}},removeMap:function(c){if(this.strategies){var d,b,a;for(b=0,a=this.strategies.length;b<a;b++){d=this.strategies[b];if(d.autoActivate){d.deactivate()}}}},onMapResize:function(){OpenLayers.Layer.prototype.onMapResize.apply(this,arguments);this.renderer.setSize(this.map.getSize())},moveTo:function(h,b,j){OpenLayers.Layer.prototype.moveTo.apply(this,arguments);var f=true;if(!j){this.renderer.root.style.visibility="hidden";this.div.style.left=-parseInt(this.map.layerContainerDiv.style.left)+"px";this.div.style.top=-parseInt(this.map.layerContainerDiv.style.top)+"px";var g=this.map.getExtent();f=this.renderer.setExtent(g,b);this.renderer.root.style.visibility="visible";if(navigator.userAgent.toLowerCase().indexOf("gecko")!=-1){this.div.scrollLeft=this.div.scrollLeft}if(!b&&f){for(var d in this.unrenderedFeatures){var c=this.unrenderedFeatures[d];this.drawFeature(c)}}}if(!this.drawn||b||!f){this.drawn=true;var c;for(var d=0,a=this.features.length;d<a;d++){this.renderer.locked=(d!==(a-1));c=this.features[d];this.drawFeature(c)}}},display:function(a){OpenLayers.Layer.prototype.display.apply(this,arguments);var b=this.div.style.display;if(b!=this.renderer.root.style.display){this.renderer.root.style.display=b}},addFeatures:function(b,k){if(!(b instanceof Array)){b=[b]}var h=!k||!k.silent;if(h){var a={features:b};var g=this.events.triggerEvent("beforefeaturesadded",a);if(g===false){return}b=a.features}for(var c=0,f=b.length;c<f;c++){if(c!=(b.length-1)){this.renderer.locked=true}else{this.renderer.locked=false}var j=b[c];if(this.geometryType&&!(j.geometry instanceof this.geometryType)){var d=OpenLayers.i18n("componentShouldBe",{geomType:this.geometryType.prototype.CLASS_NAME});throw d}this.features.push(j);j.layer=this;if(!j.style&&this.style){j.style=OpenLayers.Util.extend({},this.style)}if(h){if(this.events.triggerEvent("beforefeatureadded",{feature:j})===false){continue}this.preFeatureInsert(j)}this.drawFeature(j);if(h){this.events.triggerEvent("featureadded",{feature:j});this.onFeatureInsert(j)}}if(h){this.events.triggerEvent("featuresadded",{features:b})}},removeFeatures:function(f,a){if(!f||f.length===0){return}if(!(f instanceof Array)){f=[f]}if(f===this.features){f=f.slice()}var d=!a||!a.silent;for(var c=f.length-1;c>=0;c--){if(c!=0&&f[c-1].geometry){this.renderer.locked=true}else{this.renderer.locked=false}var b=f[c];delete this.unrenderedFeatures[b.id];if(d){this.events.triggerEvent("beforefeatureremoved",{feature:b})}this.features=OpenLayers.Util.removeItem(this.features,b);b.layer=null;if(b.geometry){this.renderer.eraseFeatures(b)}if(OpenLayers.Util.indexOf(this.selectedFeatures,b)!=-1){OpenLayers.Util.removeItem(this.selectedFeatures,b)}if(d){this.events.triggerEvent("featureremoved",{feature:b})}}if(d){this.events.triggerEvent("featuresremoved",{features:f})}},destroyFeatures:function(d,a){var c=(d==undefined);if(c){d=this.features}if(d){this.removeFeatures(d,a);for(var b=d.length-1;b>=0;b--){d[b].destroy()}}},drawFeature:function(a,b){if(!this.drawn){return}if(typeof b!="object"){if(!b&&a.state===OpenLayers.State.DELETE){b="delete"}var c=b||a.renderIntent;b=a.style||this.style;if(!b){b=this.styleMap.createSymbolizer(a,c)}}if(!this.renderer.drawFeature(a,b)){this.unrenderedFeatures[a.id]=a}else{delete this.unrenderedFeatures[a.id]}},eraseFeatures:function(a){this.renderer.eraseFeatures(a)},getFeatureFromEvent:function(a){if(!this.renderer){OpenLayers.Console.error(OpenLayers.i18n("getFeatureError"));return null}var b=this.renderer.getFeatureIdFromEvent(a);return this.getFeatureById(b)},getFeatureById:function(d){var c=null;for(var b=0,a=this.features.length;b<a;++b){if(this.features[b].id==d){c=this.features[b];break}}return c},onFeatureInsert:function(a){},preFeatureInsert:function(a){},getDataExtent:function(){var b=null;if(this.features&&(this.features.length>0)){b=new OpenLayers.Bounds();for(var c=0,a=this.features.length;c<a;c++){b.extend(this.features[c].geometry.getBounds())}}return b},CLASS_NAME:"OpenLayers.Layer.Vector"});OpenLayers.Layer.WMS.Untiled=OpenLayers.Class(OpenLayers.Layer.WMS,{singleTile:true,initialize:function(c,b,f,a){OpenLayers.Layer.WMS.prototype.initialize.apply(this,arguments);var d="The OpenLayers.Layer.WMS.Untiled class is deprecated and will be removed in 3.0. Instead, you should use the normal OpenLayers.Layer.WMS class, passing it the option 'singleTile' as true.";OpenLayers.Console.warn(d)},clone:function(a){if(a==null){a=new OpenLayers.Layer.WMS.Untiled(this.name,this.url,this.params,this.options)}a=OpenLayers.Layer.WMS.prototype.clone.apply(this,[a]);return a},CLASS_NAME:"OpenLayers.Layer.WMS.Untiled"});OpenLayers.Control.GetFeature=OpenLayers.Class(OpenLayers.Control,{protocol:null,multipleKey:null,toggleKey:null,modifiers:null,multiple:false,click:true,clickout:true,toggle:false,clickTolerance:5,hover:false,box:false,maxFeatures:10,features:null,hoverFeature:null,handlerOptions:null,handlers:null,hoverResponse:null,EVENT_TYPES:["featureselected","featureunselected","clickout","beforefeatureselected","hoverfeature","outfeature"],initialize:function(a){this.EVENT_TYPES=OpenLayers.Control.GetFeature.prototype.EVENT_TYPES.concat(OpenLayers.Control.prototype.EVENT_TYPES);a.handlerOptions=a.handlerOptions||{};OpenLayers.Control.prototype.initialize.apply(this,[a]);this.features={};this.handlers={};if(this.click){this.handlers.click=new OpenLayers.Handler.Click(this,{click:this.selectSingle},this.handlerOptions.click||{})}if(this.box){this.handlers.box=new OpenLayers.Handler.Box(this,{done:this.selectBox},OpenLayers.Util.extend(this.handlerOptions.box,{boxDivClassName:"olHandlerBoxSelectFeature"}))}if(this.hover){this.handlers.hover=new OpenLayers.Handler.Hover(this,{move:this.cancelHover,pause:this.selectHover},OpenLayers.Util.extend(this.handlerOptions.hover,{delay:250}))}},activate:function(){if(!this.active){for(var a in this.handlers){this.handlers[a].activate()}}return OpenLayers.Control.prototype.activate.apply(this,arguments)},deactivate:function(){if(this.active){for(var a in this.handlers){this.handlers[a].deactivate()}}return OpenLayers.Control.prototype.deactivate.apply(this,arguments)},unselectAll:function(a){var c;for(var b=this.features.length-1;b>=0;--b){c=this.features[b];if(!a||a.except!=c){this.unselect(c)}}},selectSingle:function(a){OpenLayers.Element.addClass(this.map.viewPortDiv,"olCursorWait");var b=this.pixelToBounds(a.xy);this.setModifiers(a);this.request(b,{single:true})},selectBox:function(a){if(a instanceof OpenLayers.Bounds){var d=this.map.getLonLatFromPixel(new OpenLayers.Pixel(a.left,a.bottom));var b=this.map.getLonLatFromPixel(new OpenLayers.Pixel(a.right,a.top));var c=new OpenLayers.Bounds(d.lon,d.lat,b.lon,b.lat);this.setModifiers(this.handlers.box.dragHandler.evt);this.request(c)}},selectHover:function(a){var b=this.pixelToBounds(a.xy);this.request(b,{single:true,hover:true})},cancelHover:function(){if(this.hoverResponse){this.protocol.abort(this.hoverResponse);this.hoverResponse=null}},request:function(d,b){b=b||{};var c=new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,value:d});var a=this.protocol.read({maxFeatures:b.single==true?this.maxFeatures:undefined,filter:c,callback:function(f){if(f.code==1){if(f.features.length){if(b.single==true){this.selectBestFeature(f.features,d.getCenterLonLat(),b)}else{this.select(f.features)}}else{if(b.hover){this.hoverSelect()}else{this.events.triggerEvent("clickout");if(this.clickout){this.unselectAll()}}}}OpenLayers.Element.removeClass(this.map.viewPortDiv,"olCursorWait")},scope:this});if(b.hover==true){this.hoverResponse=a}},selectBestFeature:function(b,a,k){k=k||{};if(b.length){var h=new OpenLayers.Geometry.Point(a.lon,a.lat);var j,d,f;var g=Number.MAX_VALUE;for(var c=0;c<b.length;++c){j=b[c];if(j.geometry){f=h.distanceTo(j.geometry,{edge:false});if(f<g){g=f;d=j;if(g==0){break}}}}if(k.hover==true){this.hoverSelect(d)}else{this.select(d||b)}}},setModifiers:function(a){this.modifiers={multiple:this.multiple||(this.multipleKey&&a[this.multipleKey]),toggle:this.toggle||(this.toggleKey&&a[this.toggleKey])}},select:function(d){if(!this.modifiers.multiple&&!this.modifiers.toggle){this.unselectAll()}if(!(d instanceof Array)){d=[d]}var c;for(var b=0,a=d.length;b<a;++b){c=d[b];if(this.features[c.fid||c.id]){if(this.modifiers.toggle){this.unselect(this.features[c.fid||c.id])}}else{cont=this.events.triggerEvent("beforefeatureselected",{feature:c});if(cont!==false){this.features[c.fid||c.id]=c;this.events.triggerEvent("featureselected",{feature:c})}}}},hoverSelect:function(a){var c=a?a.fid||a.id:null;var b=this.hoverFeature?this.hoverFeature.fid||this.hoverFeature.id:null;if(b&&b!=c){this.events.triggerEvent("outfeature",{feature:this.hoverFeature});this.hoverFeature=null}if(c&&c!=b){this.events.triggerEvent("hoverfeature",{feature:a});this.hoverFeature=a}},unselect:function(a){delete this.features[a.fid||a.id];this.events.triggerEvent("featureunselected",{feature:a})},unselectAll:function(){for(var a in this.features){this.unselect(this.features[a])}},setMap:function(b){for(var a in this.handlers){this.handlers[a].setMap(b)}OpenLayers.Control.prototype.setMap.apply(this,arguments)},pixelToBounds:function(b){var f=b.add(-this.clickTolerance/2,this.clickTolerance/2);var a=b.add(this.clickTolerance/2,-this.clickTolerance/2);var c=this.map.getLonLatFromPixel(f);var d=this.map.getLonLatFromPixel(a);return new OpenLayers.Bounds(c.lon,c.lat,d.lon,d.lat)},CLASS_NAME:"OpenLayers.Control.GetFeature"});OpenLayers.Control.Snapping=OpenLayers.Class(OpenLayers.Control,{EVENT_TYPES:["beforesnap","snap","unsnap"],DEFAULTS:{tolerance:10,node:true,edge:true,vertex:true},greedy:true,precedence:["node","vertex","edge"],resolution:null,geoToleranceCache:null,layer:null,feature:null,point:null,initialize:function(a){Array.prototype.push.apply(this.EVENT_TYPES,OpenLayers.Control.prototype.EVENT_TYPES);OpenLayers.Control.prototype.initialize.apply(this,[a]);this.options=a||{};if(this.options.layer){this.setLayer(this.options.layer)}var b=OpenLayers.Util.extend({},this.options.defaults);this.defaults=OpenLayers.Util.applyDefaults(b,this.DEFAULTS);this.setTargets(this.options.targets);if(this.targets.length===0&&this.layer){this.addTargetLayer(this.layer)}this.geoToleranceCache={}},setLayer:function(a){if(this.active){this.deactivate();this.layer=a;this.activate()}else{this.layer=a}},setTargets:function(b){this.targets=[];if(b&&b.length){var d;for(var c=0,a=b.length;c<a;++c){d=b[c];if(d instanceof OpenLayers.Layer.Vector){this.addTargetLayer(d)}else{this.addTarget(d)}}}},addTargetLayer:function(a){this.addTarget({layer:a})},addTarget:function(a){a=OpenLayers.Util.applyDefaults(a,this.defaults);a.nodeTolerance=a.nodeTolerance||a.tolerance;a.vertexTolerance=a.vertexTolerance||a.tolerance;a.edgeTolerance=a.edgeTolerance||a.tolerance;this.targets.push(a)},removeTargetLayer:function(b){var c;for(var a=this.targets.length-1;a>=0;--a){c=this.targets[a];if(c.layer===b){this.removeTarget(c)}}},removeTarget:function(a){return OpenLayers.Util.removeItem(this.targets,a)},activate:function(){var a=OpenLayers.Control.prototype.activate.call(this);if(a){if(this.layer&&this.layer.events){this.layer.events.on({sketchstarted:this.onSketchModified,sketchmodified:this.onSketchModified,vertexmodified:this.onVertexModified,scope:this})}}return a},deactivate:function(){var a=OpenLayers.Control.prototype.deactivate.call(this);if(a){if(this.layer&&this.layer.events){this.layer.events.un({sketchstarted:this.onSketchModified,sketchmodified:this.onSketchModified,vertexmodified:this.onVertexModified,scope:this})}}this.feature=null;this.point=null;return a},onSketchModified:function(a){this.feature=a.feature;this.considerSnapping(a.vertex,a.vertex)},onVertexModified:function(a){this.feature=a.feature;var b=this.layer.map.getLonLatFromViewPortPx(a.pixel);this.considerSnapping(a.vertex,new OpenLayers.Geometry.Point(b.lon,b.lat))},considerSnapping:function(j,d){var a={rank:Number.POSITIVE_INFINITY,dist:Number.POSITIVE_INFINITY,x:null,y:null};var c=false;var k,g;for(var b=0,f=this.targets.length;b<f;++b){g=this.targets[b];k=this.testTarget(g,d);if(k){if(this.greedy){a=k;a.target=g;c=true;break}else{if((k.rank<a.rank)||(k.rank===a.rank&&k.dist<a.dist)){a=k;a.target=g;c=true}}}}if(c){var h=this.events.triggerEvent("beforesnap",{point:j,x:a.x,y:a.y,distance:a.dist,layer:a.target.layer,snapType:this.precedence[a.rank]});if(h!==false){j.x=a.x;j.y=a.y;this.point=j;this.events.triggerEvent("snap",{point:j,snapType:this.precedence[a.rank],layer:a.target.layer,distance:a.dist})}else{c=false}}if(this.point&&!c){j.x=d.x;j.y=d.y;this.point=null;this.events.triggerEvent("unsnap",{point:j})}},testTarget:function(D,g){var B={node:this.getGeoTolerance(D.nodeTolerance),vertex:this.getGeoTolerance(D.vertexTolerance),edge:this.getGeoTolerance(D.edgeTolerance)};var h=Math.max(B.node,B.vertex,B.edge);var l={rank:Number.POSITIVE_INFINITY,dist:Number.POSITIVE_INFINITY};var f=false;var c=D.layer.features;var b,a,d,C,r,s,q;var o=this.precedence.length;var m=new OpenLayers.LonLat(g.x,g.y);for(var z=0,A=c.length;z<A;++z){b=c[z];if(b!==this.feature&&!b._sketch&&b.state!==OpenLayers.State.DELETE&&(!D.filter||D.filter.evaluate(b.attributes))){if(b.atPoint(m,h,h)){for(var w=0,t=Math.min(l.rank+1,o);w<t;++w){a=this.precedence[w];if(D[a]){if(a==="edge"){r=b.geometry.distanceTo(g,{details:true});s=r.distance;if(s<=B[a]&&s<l.dist){l={rank:w,dist:s,x:r.x0,y:r.y0};f=true;break}}else{d=b.geometry.getVertices(a==="node");q=false;for(var v=0,u=d.length;v<u;++v){C=d[v];s=C.distanceTo(g);if(s<=B[a]&&(w<l.rank||(w===l.rank&&s<l.dist))){l={rank:w,dist:s,x:C.x,y:C.y};f=true;q=true}}if(q){break}}}}}}}return f?l:null},getGeoTolerance:function(a){var b=this.layer.map.getResolution();if(b!==this.resolution){this.resolution=b;this.geoToleranceCache={}}var c=this.geoToleranceCache[a];if(c===undefined){c=a*b;this.geoToleranceCache[a]=c}return c},destroy:function(){if(this.active){this.deactivate()}delete this.layer;delete this.targets;OpenLayers.Control.prototype.destroy.call(this)},CLASS_NAME:"OpenLayers.Control.Snapping"});OpenLayers.Format.Filter=OpenLayers.Class(OpenLayers.Format.XML,{defaultVersion:"1.0.0",version:null,parser:null,initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},write:function(c,b){var a=(b&&b.version)||this.version||this.defaultVersion;if(!this.parser||this.parser.VERSION!=a){var d=OpenLayers.Format.Filter["v"+a.replace(/\./g,"_")];if(!d){throw"Can't find a Filter parser for version "+a}this.parser=new d(this.options)}return this.parser.write(c)},read:function(c){if(typeof c=="string"){c=OpenLayers.Format.XML.prototype.read.apply(this,[c])}var a=this.version;if(!a){a=this.defaultVersion}if(!this.parser||this.parser.VERSION!=a){var d=OpenLayers.Format.Filter["v"+a.replace(/\./g,"_")];if(!d){throw"Can't find a Filter parser for version "+a}this.parser=new d(this.options)}var b=this.parser.read(c);return b},CLASS_NAME:"OpenLayers.Format.Filter"});OpenLayers.Format.SLD=OpenLayers.Class(OpenLayers.Format.XML,{defaultVersion:"1.0.0",version:null,namedLayersAsArray:false,parser:null,initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},write:function(d,c){var b=(c&&c.version)||this.version||this.defaultVersion;if(!this.parser||this.parser.VERSION!=b){var f=OpenLayers.Format.SLD["v"+b.replace(/\./g,"_")];if(!f){throw"Can't find a SLD parser for version "+b}this.parser=new f(this.options)}var a=this.parser.write(d);return OpenLayers.Format.XML.prototype.write.apply(this,[a])},read:function(f,c){if(typeof f=="string"){f=OpenLayers.Format.XML.prototype.read.apply(this,[f])}var b=f.documentElement;var a=this.version;if(!a){a=b.getAttribute("version");if(!a){a=this.defaultVersion}}if(!this.parser||this.parser.VERSION!=a){var g=OpenLayers.Format.SLD["v"+a.replace(/\./g,"_")];if(!g){throw"Can't find a SLD parser for version "+a}this.parser=new g(this.options)}var d=this.parser.read(f,c);return d},CLASS_NAME:"OpenLayers.Format.SLD"});OpenLayers.Format.Text=OpenLayers.Class(OpenLayers.Format,{defaultStyle:null,extractStyles:true,initialize:function(a){a=a||{};if(a.extractStyles!==false){a.defaultStyle={externalGraphic:OpenLayers.Util.getImagesLocation()+"marker.png",graphicWidth:21,graphicHeight:25,graphicXOffset:-10.5,graphicYOffset:-12.5}}OpenLayers.Format.prototype.initialize.apply(this,[a])},read:function(l){var a=l.split("\n");var b;var h=[];for(var z=0;z<(a.length-1);z++){var w=a[z].replace(/^\s*/,"").replace(/\s*$/,"");if(w.charAt(0)!="#"){if(!b){b=w.split("\t")}else{var o=w.split("\t");var d=new OpenLayers.Geometry.Point(0,0);var j={};var t=this.defaultStyle?OpenLayers.Util.applyDefaults({},this.defaultStyle):null;var u,v,c,r;var m=false;for(var k=0;k<o.length;k++){if(o[k]){if(b[k]=="point"){var s=o[k].split(",");d.y=parseFloat(s[0]);d.x=parseFloat(s[1]);m=true}else{if(b[k]=="lat"){d.y=parseFloat(o[k]);m=true}else{if(b[k]=="lon"){d.x=parseFloat(o[k]);m=true}else{if(b[k]=="title"){j.title=o[k]}else{if(b[k]=="image"||b[k]=="icon"&&t){t.externalGraphic=o[k]}else{if(b[k]=="iconSize"&&t){var q=o[k].split(",");t.graphicWidth=parseFloat(q[0]);t.graphicHeight=parseFloat(q[1])}else{if(b[k]=="iconOffset"&&t){var g=o[k].split(",");t.graphicXOffset=parseFloat(g[0]);t.graphicYOffset=parseFloat(g[1])}else{if(b[k]=="description"){j.description=o[k]}else{if(b[k]=="overflow"){j.overflow=o[k]}else{j[b[k]]=o[k]}}}}}}}}}}}if(m){if(this.internalProjection&&this.externalProjection){d.transform(this.externalProjection,this.internalProjection)}var f=new OpenLayers.Feature.Vector(d,j,t);h.push(f)}}}}return h},CLASS_NAME:"OpenLayers.Format.Text"});OpenLayers.Geometry.MultiPoint=OpenLayers.Class(OpenLayers.Geometry.Collection,{componentTypes:["OpenLayers.Geometry.Point"],initialize:function(a){OpenLayers.Geometry.Collection.prototype.initialize.apply(this,arguments)},addPoint:function(a,b){this.addComponent(a,b)},removePoint:function(a){this.removeComponent(a)},CLASS_NAME:"OpenLayers.Geometry.MultiPoint"});OpenLayers.Handler.Point=OpenLayers.Class(OpenLayers.Handler,{point:null,layer:null,multi:false,drawing:false,mouseDown:false,lastDown:null,lastUp:null,persist:false,layerOptions:null,initialize:function(c,b,a){if(!(a&&a.layerOptions&&a.layerOptions.styleMap)){this.style=OpenLayers.Util.extend(OpenLayers.Feature.Vector.style["default"],{})}OpenLayers.Handler.prototype.initialize.apply(this,arguments)},activate:function(){if(!OpenLayers.Handler.prototype.activate.apply(this,arguments)){return false}var a=OpenLayers.Util.extend({displayInLayerSwitcher:false,calculateInRange:function(){return true}},this.layerOptions);this.layer=new OpenLayers.Layer.Vector(this.CLASS_NAME,a);this.map.addLayer(this.layer);return true},createFeature:function(a){var b=this.map.getLonLatFromPixel(a);this.point=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(b.lon,b.lat));this.callback("create",[this.point.geometry,this.point]);this.point.geometry.clearBounds();this.layer.addFeatures([this.point],{silent:true})},deactivate:function(){if(!OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){return false}if(this.drawing){this.cancel()}this.destroyFeature();if(this.layer.map!=null){this.layer.destroy(false)}this.layer=null;return true},destroyFeature:function(){if(this.layer){this.layer.destroyFeatures()}this.point=null},finalize:function(b){var a=b?"cancel":"done";this.drawing=false;this.mouseDown=false;this.lastDown=null;this.lastUp=null;this.callback(a,[this.geometryClone()]);if(b||!this.persist){this.destroyFeature()}},cancel:function(){this.finalize(true)},click:function(a){OpenLayers.Event.stop(a);return false},dblclick:function(a){OpenLayers.Event.stop(a);return false},modifyFeature:function(a){var b=this.map.getLonLatFromPixel(a);this.point.geometry.x=b.lon;this.point.geometry.y=b.lat;this.callback("modify",[this.point.geometry,this.point]);this.point.geometry.clearBounds();this.drawFeature()},drawFeature:function(){this.layer.drawFeature(this.point,this.style)},getGeometry:function(){var a=this.point&&this.point.geometry;if(a&&this.multi){a=new OpenLayers.Geometry.MultiPoint([a])}return a},geometryClone:function(){var a=this.getGeometry();return a&&a.clone()},mousedown:function(a){if(!this.checkModifiers(a)){return true}if(this.lastDown&&this.lastDown.equals(a.xy)){return true}this.drawing=true;if(this.lastDown==null){if(this.persist){this.destroyFeature()}this.createFeature(a.xy)}else{this.modifyFeature(a.xy)}this.lastDown=a.xy;return false},mousemove:function(a){if(this.drawing){this.modifyFeature(a.xy)}return true},mouseup:function(a){if(this.drawing){this.finalize();return false}else{return true}},CLASS_NAME:"OpenLayers.Handler.Point"});OpenLayers.Layer.GML=OpenLayers.Class(OpenLayers.Layer.Vector,{loaded:false,format:null,formatOptions:null,initialize:function(d,c,b){var a=[];a.push(d,b);OpenLayers.Layer.Vector.prototype.initialize.apply(this,a);this.url=c},setVisibility:function(a,b){OpenLayers.Layer.Vector.prototype.setVisibility.apply(this,arguments);if(this.visibility&&!this.loaded){this.loadGML()}},moveTo:function(c,a,b){OpenLayers.Layer.Vector.prototype.moveTo.apply(this,arguments);if(this.visibility&&!this.loaded){this.loadGML()}},loadGML:function(){if(!this.loaded){this.events.triggerEvent("loadstart");OpenLayers.Request.GET({url:this.url,success:this.requestSuccess,failure:this.requestFailure,scope:this});this.loaded=true}},setUrl:function(a){this.url=a;this.destroyFeatures();this.loaded=false;this.loadGML()},requestSuccess:function(c){var d=c.responseXML;if(!d||!d.documentElement){d=c.responseText}var a={};OpenLayers.Util.extend(a,this.formatOptions);if(this.map&&!this.projection.equals(this.map.getProjectionObject())){a.externalProjection=this.projection;a.internalProjection=this.map.getProjectionObject()}var b=this.format?new this.format(a):new OpenLayers.Format.GML(a);this.addFeatures(b.read(d));this.events.triggerEvent("loadend")},requestFailure:function(a){OpenLayers.Console.userError(OpenLayers.i18n("errorLoadingGML",{url:this.url}));this.events.triggerEvent("loadend")},CLASS_NAME:"OpenLayers.Layer.GML"});OpenLayers.Layer.PointTrack=OpenLayers.Class(OpenLayers.Layer.Vector,{dataFrom:null,initialize:function(b,a){OpenLayers.Layer.Vector.prototype.initialize.apply(this,arguments)},addNodes:function(g){if(g.length<2){OpenLayers.Console.error("At least two point features have to be added to createa line from");return}var l=new Array(g.length-1);var h,a,j;for(var c=0,f=g.length;c<f;c++){h=g[c];j=h.geometry;if(!j){var d=h.lonlat;j=new OpenLayers.Geometry.Point(d.lon,d.lat)}else{if(j.CLASS_NAME!="OpenLayers.Geometry.Point"){OpenLayers.Console.error("Only features with point geometries are supported.");return}}if(c>0){var b=(this.dataFrom!=null)?(g[c+this.dataFrom].data||g[c+this.dataFrom].attributes):null;var k=new OpenLayers.Geometry.LineString([a,j]);l[c-1]=new OpenLayers.Feature.Vector(k,b)}a=j}this.addFeatures(l)},CLASS_NAME:"OpenLayers.Layer.PointTrack"});OpenLayers.Layer.PointTrack.dataFrom={SOURCE_NODE:-1,TARGET_NODE:0};OpenLayers.Layer.Vector.RootContainer=OpenLayers.Class(OpenLayers.Layer.Vector,{displayInLayerSwitcher:false,layers:null,initialize:function(b,a){OpenLayers.Layer.Vector.prototype.initialize.apply(this,arguments)},display:function(){},getFeatureFromEvent:function(a){var d=this.layers;var c;for(var b=0;b<d.length;b++){c=d[b].getFeatureFromEvent(a);if(c){return c}}},setMap:function(a){OpenLayers.Layer.Vector.prototype.setMap.apply(this,arguments);this.collectRoots();a.events.register("changelayer",this,this.handleChangeLayer)},removeMap:function(a){a.events.unregister("changelayer",this,this.handleChangeLayer);this.resetRoots();OpenLayers.Layer.Vector.prototype.removeMap.apply(this,arguments)},collectRoots:function(){var b;for(var a=0;a<this.map.layers.length;++a){b=this.map.layers[a];if(OpenLayers.Util.indexOf(this.layers,b)!=-1){b.renderer.moveRoot(this.renderer)}}},resetRoots:function(){var b;for(var a=0;a<this.layers.length;++a){b=this.layers[a];if(this.renderer&&b.renderer.getRenderLayerId()==this.id){this.renderer.moveRoot(b.renderer)}}},handleChangeLayer:function(a){var b=a.layer;if(a.property=="order"&&OpenLayers.Util.indexOf(this.layers,b)!=-1){this.resetRoots();this.collectRoots()}},CLASS_NAME:"OpenLayers.Layer.Vector.RootContainer"});OpenLayers.Layer.WFS=OpenLayers.Class(OpenLayers.Layer.Vector,OpenLayers.Layer.Markers,{isBaseLayer:false,tile:null,ratio:2,DEFAULT_PARAMS:{service:"WFS",version:"1.0.0",request:"GetFeature"},featureClass:null,format:null,formatObject:null,formatOptions:null,vectorMode:true,encodeBBOX:false,extractAttributes:false,initialize:function(d,c,f,b){if(b==undefined){b={}}if(b.featureClass||!OpenLayers.Layer.Vector||!OpenLayers.Feature.Vector){this.vectorMode=false}OpenLayers.Util.extend(b,{reportError:false});var a=[];a.push(d,b);OpenLayers.Layer.Vector.prototype.initialize.apply(this,a);if(!this.renderer||!this.vectorMode){this.vectorMode=false;if(!b.featureClass){b.featureClass=OpenLayers.Feature.WFS}OpenLayers.Layer.Markers.prototype.initialize.apply(this,a)}if(this.params&&this.params.typename&&!this.options.typename){this.options.typename=this.params.typename}if(!this.options.geometry_column){this.options.geometry_column="the_geom"}this.params=OpenLayers.Util.applyDefaults(f,OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS));this.url=c},destroy:function(){if(this.vectorMode){OpenLayers.Layer.Vector.prototype.destroy.apply(this,arguments)}else{OpenLayers.Layer.Markers.prototype.destroy.apply(this,arguments)}if(this.tile){this.tile.destroy()}this.tile=null;this.ratio=null;this.featureClass=null;this.format=null;if(this.formatObject&&this.formatObject.destroy){this.formatObject.destroy()}this.formatObject=null;this.formatOptions=null;this.vectorMode=null;this.encodeBBOX=null;this.extractAttributes=null},setMap:function(b){if(this.vectorMode){OpenLayers.Layer.Vector.prototype.setMap.apply(this,arguments);var a={extractAttributes:this.extractAttributes};OpenLayers.Util.extend(a,this.formatOptions);if(this.map&&!this.projection.equals(this.map.getProjectionObject())){a.externalProjection=this.projection;a.internalProjection=this.map.getProjectionObject()}this.formatObject=this.format?new this.format(a):new OpenLayers.Format.GML(a)}else{OpenLayers.Layer.Markers.prototype.setMap.apply(this,arguments)}},moveTo:function(a,b,r){if(this.vectorMode){OpenLayers.Layer.Vector.prototype.moveTo.apply(this,arguments)}else{OpenLayers.Layer.Markers.prototype.moveTo.apply(this,arguments)}if(r){return false}if(b){if(this.vectorMode){this.renderer.clear()}}if(this.options.minZoomLevel){OpenLayers.Console.warn(OpenLayers.i18n("minZoomLevelError"));if(this.map.getZoom()<this.options.minZoomLevel){return null}}if(a==null){a=this.map.getExtent()}var q=(this.tile==null);var h=(!q&&!this.tile.bounds.containsBounds(a));if(b||q||(!r&&h)){var c=a.getCenterLonLat();var o=a.getWidth()*this.ratio;var j=a.getHeight()*this.ratio;var l=new OpenLayers.Bounds(c.lon-(o/2),c.lat-(j/2),c.lon+(o/2),c.lat+(j/2));var s=this.map.getSize();s.w=s.w*this.ratio;s.h=s.h*this.ratio;var k=new OpenLayers.LonLat(l.left,l.top);var m=this.map.getLayerPxFromLonLat(k);var d=this.getFullRequestString();var g=null;var f=this.params.filter||this.params.FILTER;if(f){g={FILTER:f}}else{g={BBOX:this.encodeBBOX?l.toBBOX():l.toArray()}}if(this.map&&!this.projection.equals(this.map.getProjectionObject())){var t=l.clone();t.transform(this.map.getProjectionObject(),this.projection);if(!f){g.BBOX=this.encodeBBOX?t.toBBOX():t.toArray()}}d+="&"+OpenLayers.Util.getParameterString(g);if(!this.tile){this.tile=new OpenLayers.Tile.WFS(this,m,l,d,s);this.addTileMonitoringHooks(this.tile);this.tile.draw()}else{if(this.vectorMode){this.destroyFeatures();this.renderer.clear()}else{this.clearMarkers()}this.removeTileMonitoringHooks(this.tile);this.tile.destroy();this.tile=null;this.tile=new OpenLayers.Tile.WFS(this,m,l,d,s);this.addTileMonitoringHooks(this.tile);this.tile.draw()}}},addTileMonitoringHooks:function(a){a.onLoadStart=function(){if(this==this.layer.tile){this.layer.events.triggerEvent("loadstart")}};a.events.register("loadstart",a,a.onLoadStart);a.onLoadEnd=function(){if(this==this.layer.tile){this.layer.events.triggerEvent("tileloaded");this.layer.events.triggerEvent("loadend")}};a.events.register("loadend",a,a.onLoadEnd);a.events.register("unload",a,a.onLoadEnd)},removeTileMonitoringHooks:function(a){a.unload();a.events.un({loadstart:a.onLoadStart,loadend:a.onLoadEnd,unload:a.onLoadEnd,scope:a})},onMapResize:function(){if(this.vectorMode){OpenLayers.Layer.Vector.prototype.onMapResize.apply(this,arguments)}else{OpenLayers.Layer.Markers.prototype.onMapResize.apply(this,arguments)}},display:function(){if(this.vectorMode){OpenLayers.Layer.Vector.prototype.display.apply(this,arguments)}else{OpenLayers.Layer.Markers.prototype.display.apply(this,arguments)}},mergeNewParams:function(c){var b=OpenLayers.Util.upperCaseObject(c);var a=[b];return OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,a)},clone:function(a){if(a==null){a=new OpenLayers.Layer.WFS(this.name,this.url,this.params,this.options)}if(this.vectorMode){a=OpenLayers.Layer.Vector.prototype.clone.apply(this,[a])}else{a=OpenLayers.Layer.Markers.prototype.clone.apply(this,[a])}return a},getFullRequestString:function(c,b){var a=this.projection.getCode()||this.map.getProjection();this.params.SRS=(a=="none")?null:a;return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(this,arguments)},commit:function(){if(!this.writer){var a={};if(this.map&&!this.projection.equals(this.map.getProjectionObject())){a.externalProjection=this.projection;a.internalProjection=this.map.getProjectionObject()}this.writer=new OpenLayers.Format.WFS(a,this)}var b=this.writer.write(this.features);OpenLayers.Request.POST({url:this.url,data:b,success:this.commitSuccess,failure:this.commitFailure,scope:this})},commitSuccess:function(c){var a=c.responseText;if(a.indexOf("SUCCESS")!=-1){this.commitReport(OpenLayers.i18n("commitSuccess",{response:a}));for(var b=0;b<this.features.length;b++){this.features[b].state=null}}else{if(a.indexOf("FAILED")!=-1||a.indexOf("Exception")!=-1){this.commitReport(OpenLayers.i18n("commitFailed",{response:a}))}}},commitFailure:function(a){},commitReport:function(b,a){OpenLayers.Console.userError(b)},refresh:function(){if(this.tile){if(this.vectorMode){this.renderer.clear();this.features.length=0}else{this.clearMarkers();this.markers.length=0}this.tile.draw()}},getDataExtent:function(){var a;if(this.vectorMode){a=OpenLayers.Layer.Vector.prototype.getDataExtent.apply(this)}else{a=OpenLayers.Layer.Markers.prototype.getDataExtent.apply(this)}return a},setOpacity:function(a){if(this.vectorMode){OpenLayers.Layer.Vector.prototype.setOpacity.apply(this,[a])}else{OpenLayers.Layer.Markers.prototype.setOpacity.apply(this,[a])}},CLASS_NAME:"OpenLayers.Layer.WFS"});OpenLayers.Strategy.BBOX=OpenLayers.Class(OpenLayers.Strategy,{bounds:null,resolution:null,ratio:2,resFactor:null,response:null,initialize:function(a){OpenLayers.Strategy.prototype.initialize.apply(this,[a])},activate:function(){var a=OpenLayers.Strategy.prototype.activate.call(this);if(a){this.layer.events.on({moveend:this.update,scope:this});this.layer.events.on({refresh:this.update,scope:this})}return a},deactivate:function(){var a=OpenLayers.Strategy.prototype.deactivate.call(this);if(a){this.layer.events.un({moveend:this.update,scope:this});this.layer.events.un({refresh:this.update,scope:this})}return a},update:function(b){var a=this.getMapBounds();if((b&&b.force)||this.invalidBounds(a)){this.calculateBounds(a);this.resolution=this.layer.map.getResolution();this.triggerRead()}},getMapBounds:function(){var a=this.layer.map.getExtent();if(!this.layer.projection.equals(this.layer.map.getProjectionObject())){a=a.clone().transform(this.layer.map.getProjectionObject(),this.layer.projection)}return a},invalidBounds:function(a){if(!a){a=this.getMapBounds()}var c=!this.bounds||!this.bounds.containsBounds(a);if(!c&&this.resFactor){var b=this.resolution/this.layer.map.getResolution();c=(b>=this.resFactor||b<=(1/this.resFactor))}return c},calculateBounds:function(b){if(!b){b=this.getMapBounds()}var a=b.getCenterLonLat();var d=b.getWidth()*this.ratio;var c=b.getHeight()*this.ratio;this.bounds=new OpenLayers.Bounds(a.lon-(d/2),a.lat-(c/2),a.lon+(d/2),a.lat+(c/2))},triggerRead:function(){this.layer.protocol.abort(this.response);this.layer.events.triggerEvent("loadstart");this.response=this.layer.protocol.read({filter:this.createFilter(),callback:this.merge,scope:this})},createFilter:function(){var a=new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,value:this.bounds,projection:this.layer.projection});if(this.layer.filter){a=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:[this.layer.filter,a]})}return a},merge:function(h){this.layer.destroyFeatures();var f=h.features;if(f&&f.length>0){var g=this.layer.projection;var d=this.layer.map.getProjectionObject();if(!d.equals(g)){var c;for(var b=0,a=f.length;b<a;++b){c=f[b].geometry;if(c){c.transform(g,d)}}}this.layer.addFeatures(f)}this.layer.events.triggerEvent("loadend")},CLASS_NAME:"OpenLayers.Strategy.BBOX"});OpenLayers.Control.SelectFeature=OpenLayers.Class(OpenLayers.Control,{EVENT_TYPES:["beforefeaturehighlighted","featurehighlighted","featureunhighlighted"],multipleKey:null,toggleKey:null,multiple:false,clickout:true,toggle:false,hover:false,highlightOnly:false,box:false,onBeforeSelect:function(){},onSelect:function(){},onUnselect:function(){},scope:null,geometryTypes:null,layer:null,layers:null,callbacks:null,selectStyle:null,renderIntent:"select",handlers:null,initialize:function(c,a){this.EVENT_TYPES=OpenLayers.Control.SelectFeature.prototype.EVENT_TYPES.concat(OpenLayers.Control.prototype.EVENT_TYPES);OpenLayers.Control.prototype.initialize.apply(this,[a]);if(this.scope===null){this.scope=this}if(c instanceof Array){this.layers=c;this.layer=new OpenLayers.Layer.Vector.RootContainer(this.id+"_container",{layers:c})}else{this.layer=c}var b={click:this.clickFeature,clickout:this.clickoutFeature};if(this.hover){b.over=this.overFeature;b.out=this.outFeature}this.callbacks=OpenLayers.Util.extend(b,this.callbacks);this.handlers={feature:new OpenLayers.Handler.Feature(this,this.layer,this.callbacks,{geometryTypes:this.geometryTypes})};if(this.box){this.handlers.box=new OpenLayers.Handler.Box(this,{done:this.selectBox},{boxDivClassName:"olHandlerBoxSelectFeature"})}},destroy:function(){OpenLayers.Control.prototype.destroy.apply(this,arguments);if(this.layers){this.layer.destroy()}},activate:function(){if(!this.active){if(this.layers){this.map.addLayer(this.layer)}this.handlers.feature.activate();if(this.box&&this.handlers.box){this.handlers.box.activate()}}return OpenLayers.Control.prototype.activate.apply(this,arguments)},deactivate:function(){if(this.active){this.handlers.feature.deactivate();if(this.handlers.box){this.handlers.box.deactivate()}if(this.layers){this.map.removeLayer(this.layer)}}return OpenLayers.Control.prototype.deactivate.apply(this,arguments)},unselectAll:function(b){var g=this.layers||[this.layer];var f,d;for(var a=0;a<g.length;++a){f=g[a];for(var c=f.selectedFeatures.length-1;c>=0;--c){d=f.selectedFeatures[c];if(!b||b.except!=d){this.unselect(d)}}}},clickFeature:function(a){if(!this.hover){var b=(OpenLayers.Util.indexOf(a.layer.selectedFeatures,a)>-1);if(b){if(this.toggleSelect()){this.unselect(a)}else{if(!this.multipleSelect()){this.unselectAll({except:a})}}}else{if(!this.multipleSelect()){this.unselectAll({except:a})}this.select(a)}}},multipleSelect:function(){return this.multiple||(this.handlers.feature.evt&&this.handlers.feature.evt[this.multipleKey])},toggleSelect:function(){return this.toggle||(this.handlers.feature.evt&&this.handlers.feature.evt[this.toggleKey])},clickoutFeature:function(a){if(!this.hover&&this.clickout){this.unselectAll()}},overFeature:function(b){var a=b.layer;if(this.hover){if(this.highlightOnly){this.highlight(b)}else{if(OpenLayers.Util.indexOf(a.selectedFeatures,b)==-1){this.select(b)}}}},outFeature:function(a){if(this.hover){if(this.highlightOnly){if(a._lastHighlighter==this.id){if(a._prevHighlighter&&a._prevHighlighter!=this.id){delete a._lastHighlighter;var b=this.map.getControl(a._prevHighlighter);if(b){b.highlight(a)}}else{this.unhighlight(a)}}}else{this.unselect(a)}}},highlight:function(c){var b=c.layer;var a=this.events.triggerEvent("beforefeaturehighlighted",{feature:c});if(a!==false){c._prevHighlighter=c._lastHighlighter;c._lastHighlighter=this.id;var d=this.selectStyle||this.renderIntent;b.drawFeature(c,d);this.events.triggerEvent("featurehighlighted",{feature:c})}},unhighlight:function(b){var a=b.layer;b._lastHighlighter=b._prevHighlighter;delete b._prevHighlighter;a.drawFeature(b,b.style||b.layer.style||"default");this.events.triggerEvent("featureunhighlighted",{feature:b})},select:function(c){var a=this.onBeforeSelect.call(this.scope,c);var b=c.layer;if(a!==false){a=b.events.triggerEvent("beforefeatureselected",{feature:c});if(a!==false){b.selectedFeatures.push(c);this.highlight(c);b.events.triggerEvent("featureselected",{feature:c});this.onSelect.call(this.scope,c)}}},unselect:function(b){var a=b.layer;this.unhighlight(b);OpenLayers.Util.removeItem(a.selectedFeatures,b);a.events.triggerEvent("featureunselected",{feature:b});this.onUnselect.call(this.scope,b)},selectBox:function(f){if(f instanceof OpenLayers.Bounds){var j=this.map.getLonLatFromPixel(new OpenLayers.Pixel(f.left,f.bottom));var m=this.map.getLonLatFromPixel(new OpenLayers.Pixel(f.right,f.top));var a=new OpenLayers.Bounds(j.lon,j.lat,m.lon,m.lat);if(!this.multipleSelect()){this.unselectAll()}var k=this.multiple;this.multiple=true;var d=this.layers||[this.layer];var g;for(var b=0;b<d.length;++b){g=d[b];for(var c=0,h=g.features.length;c<h;++c){var o=g.features[c];if(this.geometryTypes==null||OpenLayers.Util.indexOf(this.geometryTypes,o.geometry.CLASS_NAME)>-1){if(a.toGeometry().intersects(o.geometry)){if(OpenLayers.Util.indexOf(g.selectedFeatures,o)==-1){this.select(o)}}}}}this.multiple=k}},setMap:function(a){this.handlers.feature.setMap(a);if(this.box){this.handlers.box.setMap(a)}OpenLayers.Control.prototype.setMap.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.SelectFeature"});OpenLayers.Format.Filter.v1=OpenLayers.Class(OpenLayers.Format.XML,{namespaces:{ogc:"http://www.opengis.net/ogc",gml:"http://www.opengis.net/gml",xlink:"http://www.w3.org/1999/xlink",xsi:"http://www.w3.org/2001/XMLSchema-instance"},defaultPrefix:"ogc",schemaLocation:null,initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},read:function(a){var b={};this.readers.ogc.Filter.apply(this,[a,b]);return b.filter},readers:{ogc:{Filter:function(b,a){var c={fids:[],filters:[]};this.readChildNodes(b,c);if(c.fids.length>0){a.filter=new OpenLayers.Filter.FeatureId({fids:c.fids})}else{if(c.filters.length>0){a.filter=c.filters[0]}}},FeatureId:function(a,b){var c=a.getAttribute("fid");if(c){b.fids.push(c)}},And:function(b,c){var a=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND});this.readChildNodes(b,a);c.filters.push(a)},Or:function(b,c){var a=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.OR});this.readChildNodes(b,a);c.filters.push(a)},Not:function(b,c){var a=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.NOT});this.readChildNodes(b,a);c.filters.push(a)},PropertyIsLessThan:function(b,c){var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.LESS_THAN});this.readChildNodes(b,a);c.filters.push(a)},PropertyIsGreaterThan:function(b,c){var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.GREATER_THAN});this.readChildNodes(b,a);c.filters.push(a)},PropertyIsLessThanOrEqualTo:function(b,c){var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO});this.readChildNodes(b,a);c.filters.push(a)},PropertyIsGreaterThanOrEqualTo:function(b,c){var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO});this.readChildNodes(b,a);c.filters.push(a)},PropertyIsBetween:function(b,c){var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.BETWEEN});this.readChildNodes(b,a);c.filters.push(a)},PropertyIsLike:function(d,f){var c=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.LIKE});this.readChildNodes(d,c);var g=d.getAttribute("wildCard");var b=d.getAttribute("singleChar");var a=d.getAttribute("escape");c.value2regex(g,b,a);f.filters.push(c)},Literal:function(a,b){b.value=OpenLayers.String.numericIf(this.getChildValue(a))},PropertyName:function(b,a){a.property=this.getChildValue(b)},LowerBoundary:function(b,a){a.lowerBoundary=OpenLayers.String.numericIf(this.readOgcExpression(b))},UpperBoundary:function(b,a){a.upperBoundary=OpenLayers.String.numericIf(this.readOgcExpression(b))},Intersects:function(a,b){this.readSpatial(a,b,OpenLayers.Filter.Spatial.INTERSECTS)},Within:function(a,b){this.readSpatial(a,b,OpenLayers.Filter.Spatial.WITHIN)},Contains:function(a,b){this.readSpatial(a,b,OpenLayers.Filter.Spatial.CONTAINS)},DWithin:function(a,b){this.readSpatial(a,b,OpenLayers.Filter.Spatial.DWITHIN)},Distance:function(a,b){b.distance=parseInt(this.getChildValue(a));b.distanceUnits=a.getAttribute("units")}}},readSpatial:function(c,d,b){var a=new OpenLayers.Filter.Spatial({type:b});this.readChildNodes(c,a);a.value=a.components[0];delete a.components;d.filters.push(a)},readOgcExpression:function(a){var c={};this.readChildNodes(a,c);var b=c.value;if(!b){b=this.getChildValue(a)}return b},write:function(a){return this.writers.ogc.Filter.apply(this,[a])},writers:{ogc:{Filter:function(c){var d=this.createElementNSPlus("ogc:Filter");var b=c.CLASS_NAME.split(".").pop();if(b=="FeatureId"){for(var a=0;a<c.fids.length;++a){this.writeNode("FeatureId",c.fids[a],d)}}else{this.writeNode(this.getFilterType(c),c,d)}return d},FeatureId:function(a){return this.createElementNSPlus("ogc:FeatureId",{attributes:{fid:a}})},And:function(c){var d=this.createElementNSPlus("ogc:And");var b;for(var a=0;a<c.filters.length;++a){b=c.filters[a];this.writeNode(this.getFilterType(b),b,d)}return d},Or:function(c){var d=this.createElementNSPlus("ogc:Or");var b;for(var a=0;a<c.filters.length;++a){b=c.filters[a];this.writeNode(this.getFilterType(b),b,d)}return d},Not:function(b){var c=this.createElementNSPlus("ogc:Not");var a=b.filters[0];this.writeNode(this.getFilterType(a),a,c);return c},PropertyIsLessThan:function(a){var b=this.createElementNSPlus("ogc:PropertyIsLessThan");this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.value,b);return b},PropertyIsGreaterThan:function(a){var b=this.createElementNSPlus("ogc:PropertyIsGreaterThan");this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.value,b);return b},PropertyIsLessThanOrEqualTo:function(a){var b=this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo");this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.value,b);return b},PropertyIsGreaterThanOrEqualTo:function(a){var b=this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo");this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.value,b);return b},PropertyIsBetween:function(a){var b=this.createElementNSPlus("ogc:PropertyIsBetween");this.writeNode("PropertyName",a,b);this.writeNode("LowerBoundary",a,b);this.writeNode("UpperBoundary",a,b);return b},PropertyIsLike:function(a){var b=this.createElementNSPlus("ogc:PropertyIsLike",{attributes:{wildCard:"*",singleChar:".",escape:"!"}});this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.regex2value(),b);return b},PropertyName:function(a){return this.createElementNSPlus("ogc:PropertyName",{value:a.property})},Literal:function(a){return this.createElementNSPlus("ogc:Literal",{value:a})},LowerBoundary:function(a){var b=this.createElementNSPlus("ogc:LowerBoundary");this.writeNode("Literal",a.lowerBoundary,b);return b},UpperBoundary:function(a){var b=this.createElementNSPlus("ogc:UpperBoundary");this.writeNode("Literal",a.upperBoundary,b);return b},INTERSECTS:function(a){return this.writeSpatial(a,"Intersects")},WITHIN:function(a){return this.writeSpatial(a,"Within")},CONTAINS:function(a){return this.writeSpatial(a,"Contains")},DWITHIN:function(a){var b=this.writeSpatial(a,"DWithin");this.writeNode("Distance",a,b);return b},Distance:function(a){return this.createElementNSPlus("ogc:Distance",{attributes:{units:a.distanceUnits},value:a.distance})}}},getFilterType:function(a){var b=this.filterMap[a.type];if(!b){throw"Filter writing not supported for rule type: "+a.type}return b},filterMap:{"&&":"And","||":"Or","!":"Not","==":"PropertyIsEqualTo","!=":"PropertyIsNotEqualTo","<":"PropertyIsLessThan",">":"PropertyIsGreaterThan","<=":"PropertyIsLessThanOrEqualTo",">=":"PropertyIsGreaterThanOrEqualTo","..":"PropertyIsBetween","~":"PropertyIsLike",BBOX:"BBOX",DWITHIN:"DWITHIN",WITHIN:"WITHIN",CONTAINS:"CONTAINS",INTERSECTS:"INTERSECTS"},CLASS_NAME:"OpenLayers.Format.Filter.v1"});OpenLayers.Geometry.Curve=OpenLayers.Class(OpenLayers.Geometry.MultiPoint,{componentTypes:["OpenLayers.Geometry.Point"],initialize:function(a){OpenLayers.Geometry.MultiPoint.prototype.initialize.apply(this,arguments)},getLength:function(){var c=0;if(this.components&&(this.components.length>1)){for(var b=1,a=this.components.length;b<a;b++){c+=this.components[b-1].distanceTo(this.components[b])}}return c},getGeodesicLength:function(b){var f=this;if(b){var c=new OpenLayers.Projection("EPSG:4326");if(!c.equals(b)){f=this.clone().transform(b,c)}}var g=0;if(f.components&&(f.components.length>1)){var j,h;for(var d=1,a=f.components.length;d<a;d++){j=f.components[d-1];h=f.components[d];g+=OpenLayers.Util.distVincenty({lon:j.x,lat:j.y},{lon:h.x,lat:h.y})}}return g*1000},CLASS_NAME:"OpenLayers.Geometry.Curve"});OpenLayers.Control.ModifyFeature=OpenLayers.Class(OpenLayers.Control,{geometryTypes:null,clickout:true,toggle:true,layer:null,feature:null,vertices:null,virtualVertices:null,selectControl:null,dragControl:null,handlers:null,deleteCodes:null,virtualStyle:null,mode:null,modified:false,radiusHandle:null,dragHandle:null,onModificationStart:function(){},onModification:function(){},onModificationEnd:function(){},initialize:function(d,c){this.layer=d;this.vertices=[];this.virtualVertices=[];this.virtualStyle=OpenLayers.Util.extend({},this.layer.style||this.layer.styleMap.createSymbolizer());this.virtualStyle.fillOpacity=0.3;this.virtualStyle.strokeOpacity=0.3;this.deleteCodes=[46,68];this.mode=OpenLayers.Control.ModifyFeature.RESHAPE;OpenLayers.Control.prototype.initialize.apply(this,[c]);if(!(this.deleteCodes instanceof Array)){this.deleteCodes=[this.deleteCodes]}var g=this;var a={geometryTypes:this.geometryTypes,clickout:this.clickout,toggle:this.toggle,onBeforeSelect:this.beforeSelectFeature,onSelect:this.selectFeature,onUnselect:this.unselectFeature,scope:this};this.selectControl=new OpenLayers.Control.SelectFeature(d,a);var b={geometryTypes:["OpenLayers.Geometry.Point"],snappingOptions:this.snappingOptions,onStart:function(j,h){g.dragStart.apply(g,[j,h])},onDrag:function(j,h){g.dragVertex.apply(g,[j,h])},onComplete:function(h){g.dragComplete.apply(g,[h])}};this.dragControl=new OpenLayers.Control.DragFeature(d,b);var f={keydown:this.handleKeypress};this.handlers={keyboard:new OpenLayers.Handler.Keyboard(this,f)}},destroy:function(){this.layer=null;this.selectControl.destroy();this.dragControl.destroy();OpenLayers.Control.prototype.destroy.apply(this,[])},activate:function(){return(this.selectControl.activate()&&this.handlers.keyboard.activate()&&OpenLayers.Control.prototype.activate.apply(this,arguments))},deactivate:function(){var a=false;if(OpenLayers.Control.prototype.deactivate.apply(this,arguments)){this.layer.removeFeatures(this.vertices,{silent:true});this.layer.removeFeatures(this.virtualVertices,{silent:true});this.vertices=[];this.dragControl.deactivate();if(this.feature&&this.feature.geometry&&this.feature.layer){this.selectControl.unselect.apply(this.selectControl,[this.feature])}this.selectControl.deactivate();this.handlers.keyboard.deactivate();a=true}return a},beforeSelectFeature:function(a){return this.layer.events.triggerEvent("beforefeaturemodified",{feature:a})},selectFeature:function(a){this.feature=a;this.modified=false;this.resetVertices();this.dragControl.activate();this.onModificationStart(this.feature)},unselectFeature:function(a){this.layer.removeFeatures(this.vertices,{silent:true});this.vertices=[];this.layer.destroyFeatures(this.virtualVertices,{silent:true});this.virtualVertices=[];if(this.dragHandle){this.layer.destroyFeatures([this.dragHandle],{silent:true});delete this.dragHandle}if(this.radiusHandle){this.layer.destroyFeatures([this.radiusHandle],{silent:true});delete this.radiusHandle}this.feature=null;this.dragControl.deactivate();this.onModificationEnd(a);this.layer.events.triggerEvent("afterfeaturemodified",{feature:a,modified:this.modified});this.modified=false},dragStart:function(b,a){if(b!=this.feature&&!b.geometry.parent&&b!=this.dragHandle&&b!=this.radiusHandle){if(this.feature){this.selectControl.clickFeature.apply(this.selectControl,[this.feature])}if(this.geometryTypes==null||OpenLayers.Util.indexOf(this.geometryTypes,b.geometry.CLASS_NAME)!=-1){this.selectControl.clickFeature.apply(this.selectControl,[b]);this.dragControl.overFeature.apply(this.dragControl,[b]);this.dragControl.lastPixel=a;this.dragControl.handlers.drag.started=true;this.dragControl.handlers.drag.start=a;this.dragControl.handlers.drag.last=a}}},dragVertex:function(b,a){this.modified=true;if(this.feature.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"){if(this.feature!=b){this.feature=b}this.layer.events.triggerEvent("vertexmodified",{vertex:b.geometry,feature:this.feature,pixel:a})}else{if(b._index){b.geometry.parent.addComponent(b.geometry,b._index);delete b._index;OpenLayers.Util.removeItem(this.virtualVertices,b);this.vertices.push(b)}else{if(b==this.dragHandle){this.layer.removeFeatures(this.vertices,{silent:true});this.vertices=[];if(this.radiusHandle){this.layer.destroyFeatures([this.radiusHandle],{silent:true});this.radiusHandle=null}}else{if(b!==this.radiusHandle){this.layer.events.triggerEvent("vertexmodified",{vertex:b.geometry,feature:this.feature,pixel:a})}}}if(this.virtualVertices.length>0){this.layer.destroyFeatures(this.virtualVertices,{silent:true});this.virtualVertices=[]}this.layer.drawFeature(this.feature,this.selectControl.renderIntent)}this.layer.drawFeature(b)},dragComplete:function(a){this.resetVertices();this.setFeatureState();this.onModification(this.feature);this.layer.events.triggerEvent("featuremodified",{feature:this.feature})},setFeatureState:function(){if(this.feature.state!=OpenLayers.State.INSERT&&this.feature.state!=OpenLayers.State.DELETE){this.feature.state=OpenLayers.State.UPDATE}},resetVertices:function(){if(this.dragControl.feature){this.dragControl.outFeature(this.dragControl.feature)}if(this.vertices.length>0){this.layer.removeFeatures(this.vertices,{silent:true});this.vertices=[]}if(this.virtualVertices.length>0){this.layer.removeFeatures(this.virtualVertices,{silent:true});this.virtualVertices=[]}if(this.dragHandle){this.layer.destroyFeatures([this.dragHandle],{silent:true});this.dragHandle=null}if(this.radiusHandle){this.layer.destroyFeatures([this.radiusHandle],{silent:true});this.radiusHandle=null}if(this.feature&&this.feature.geometry.CLASS_NAME!="OpenLayers.Geometry.Point"){if((this.mode&OpenLayers.Control.ModifyFeature.DRAG)){this.collectDragHandle()}if((this.mode&(OpenLayers.Control.ModifyFeature.ROTATE|OpenLayers.Control.ModifyFeature.RESIZE))){this.collectRadiusHandle()}if(this.mode&OpenLayers.Control.ModifyFeature.RESHAPE){if(!(this.mode&OpenLayers.Control.ModifyFeature.RESIZE)){this.collectVertices()}}}},handleKeypress:function(a){var b=a.keyCode;if(this.feature&&OpenLayers.Util.indexOf(this.deleteCodes,b)!=-1){var c=this.dragControl.feature;if(c&&OpenLayers.Util.indexOf(this.vertices,c)!=-1&&!this.dragControl.handlers.drag.dragging&&c.geometry.parent){c.geometry.parent.removeComponent(c.geometry);this.layer.drawFeature(this.feature,this.selectControl.renderIntent);this.resetVertices();this.setFeatureState();this.onModification(this.feature);this.layer.events.triggerEvent("featuremodified",{feature:this.feature})}}},collectVertices:function(){this.vertices=[];this.virtualVertices=[];var a=this;function b(j){var d,f,k,g;if(j.CLASS_NAME=="OpenLayers.Geometry.Point"){f=new OpenLayers.Feature.Vector(j);f._sketch=true;a.vertices.push(f)}else{var c=j.components.length;if(j.CLASS_NAME=="OpenLayers.Geometry.LinearRing"){c-=1}for(d=0;d<c;++d){k=j.components[d];if(k.CLASS_NAME=="OpenLayers.Geometry.Point"){f=new OpenLayers.Feature.Vector(k);f._sketch=true;a.vertices.push(f)}else{b(k)}}if(j.CLASS_NAME!="OpenLayers.Geometry.MultiPoint"){for(d=0,g=j.components.length;d<g-1;++d){var o=j.components[d];var q=j.components[d+1];if(o.CLASS_NAME=="OpenLayers.Geometry.Point"&&q.CLASS_NAME=="OpenLayers.Geometry.Point"){var l=(o.x+q.x)/2;var h=(o.y+q.y)/2;var m=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(l,h),null,a.virtualStyle);m.geometry.parent=j;m._index=d+1;m._sketch=true;a.virtualVertices.push(m)}}}}}b.call(this,this.feature.geometry);this.layer.addFeatures(this.virtualVertices,{silent:true});this.layer.addFeatures(this.vertices,{silent:true})},collectDragHandle:function(){var d=this.feature.geometry;var a=d.getBounds().getCenterLonLat();var c=new OpenLayers.Geometry.Point(a.lon,a.lat);var b=new OpenLayers.Feature.Vector(c);c.move=function(f,g){OpenLayers.Geometry.Point.prototype.move.call(this,f,g);d.move(f,g)};b._sketch=true;this.dragHandle=b;this.layer.addFeatures([this.dragHandle],{silent:true})},collectRadiusHandle:function(){var j=this.feature.geometry;var a=j.getBounds();var b=a.getCenterLonLat();var k=new OpenLayers.Geometry.Point(b.lon,b.lat);var h=new OpenLayers.Geometry.Point(a.right,a.bottom);var g=new OpenLayers.Feature.Vector(h);var c=(this.mode&OpenLayers.Control.ModifyFeature.RESIZE);var f=(this.mode&OpenLayers.Control.ModifyFeature.RESHAPE);var d=(this.mode&OpenLayers.Control.ModifyFeature.ROTATE);h.move=function(z,w){OpenLayers.Geometry.Point.prototype.move.call(this,z,w);var A=this.x-k.x;var t=this.y-k.y;var B=A-z;var u=t-w;if(d){var m=Math.atan2(u,B);var l=Math.atan2(t,A);var r=l-m;r*=180/Math.PI;j.rotate(r,k)}if(c){var q,v;if(f){q=t/u;v=(A/B)/q}else{var s=Math.sqrt((B*B)+(u*u));var o=Math.sqrt((A*A)+(t*t));q=o/s}j.resize(q,k,v)}};g._sketch=true;this.radiusHandle=g;this.layer.addFeatures([this.radiusHandle],{silent:true})},setMap:function(a){this.selectControl.setMap(a);this.dragControl.setMap(a);OpenLayers.Control.prototype.setMap.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.ModifyFeature"});OpenLayers.Control.ModifyFeature.RESHAPE=1;OpenLayers.Control.ModifyFeature.RESIZE=2;OpenLayers.Control.ModifyFeature.ROTATE=4;OpenLayers.Control.ModifyFeature.DRAG=8;OpenLayers.Geometry.LineString=OpenLayers.Class(OpenLayers.Geometry.Curve,{initialize:function(a){OpenLayers.Geometry.Curve.prototype.initialize.apply(this,arguments)},removeComponent:function(a){if(this.components&&(this.components.length>2)){OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,arguments)}},intersects:function(o){var c=false;var m=o.CLASS_NAME;if(m=="OpenLayers.Geometry.LineString"||m=="OpenLayers.Geometry.LinearRing"||m=="OpenLayers.Geometry.Point"){var s=this.getSortedSegments();var q;if(m=="OpenLayers.Geometry.Point"){q=[{x1:o.x,y1:o.y,x2:o.x,y2:o.y}]}else{q=o.getSortedSegments()}var v,h,f,a,u,t,d,b;outer:for(var k=0,l=s.length;k<l;++k){v=s[k];h=v.x1;f=v.x2;a=v.y1;u=v.y2;inner:for(var g=0,r=q.length;g<r;++g){t=q[g];if(t.x1>f){break}if(t.x2<h){continue}d=t.y1;b=t.y2;if(Math.min(d,b)>Math.max(a,u)){continue}if(Math.max(d,b)<Math.min(a,u)){continue}if(OpenLayers.Geometry.segmentsIntersect(v,t)){c=true;break outer}}}}else{c=o.intersects(this)}return c},getSortedSegments:function(){var a=this.components.length-1;var b=new Array(a);for(var c=0;c<a;++c){point1=this.components[c];point2=this.components[c+1];if(point1.x<point2.x){b[c]={x1:point1.x,y1:point1.y,x2:point2.x,y2:point2.y}}else{b[c]={x1:point2.x,y1:point2.y,x2:point1.x,y2:point1.y}}}function d(g,f){return g.x1-f.x1}return b.sort(d)},splitWithSegment:function(u,b){var c=!(b&&b.edge===false);var r=b&&b.tolerance;var a=[];var w=this.getVertices();var q=[];var A=[];var j=false;var f,d,m;var k,t,z;var g={point:true,tolerance:r};var h=null;for(var o=0,l=w.length-2;o<=l;++o){f=w[o];q.push(f.clone());d=w[o+1];z={x1:f.x,y1:f.y,x2:d.x,y2:d.y};m=OpenLayers.Geometry.segmentsIntersect(u,z,g);if(m instanceof OpenLayers.Geometry.Point){if((m.x===u.x1&&m.y===u.y1)||(m.x===u.x2&&m.y===u.y2)||m.equals(f)||m.equals(d)){t=true}else{t=false}if(t||c){if(!m.equals(A[A.length-1])){A.push(m.clone())}if(o===0){if(m.equals(f)){continue}}if(m.equals(d)){continue}j=true;if(!m.equals(f)){q.push(m)}a.push(new OpenLayers.Geometry.LineString(q));q=[m.clone()]}}}if(j){q.push(d.clone());a.push(new OpenLayers.Geometry.LineString(q))}if(A.length>0){var s=u.x1<u.x2?1:-1;var v=u.y1<u.y2?1:-1;h={lines:a,points:A.sort(function(C,B){return(s*C.x-s*B.x)||(v*C.y-v*B.y)})}}return h},split:function(C,b){var q=null;var d=b&&b.mutual;var m,f,o,c;if(C instanceof OpenLayers.Geometry.LineString){var B=this.getVertices();var h,g,A,l,a,s;var v=[];o=[];for(var w=0,r=B.length-2;w<=r;++w){h=B[w];g=B[w+1];A={x1:h.x,y1:h.y,x2:g.x,y2:g.y};c=c||[C];if(d){v.push(h.clone())}for(var u=0;u<c.length;++u){l=c[u].splitWithSegment(A,b);if(l){a=l.lines;if(a.length>0){a.unshift(u,1);Array.prototype.splice.apply(c,a);u+=a.length-2}if(d){for(var t=0,z=l.points.length;t<z;++t){s=l.points[t];if(!s.equals(h)){v.push(s);o.push(new OpenLayers.Geometry.LineString(v));if(s.equals(g)){v=[]}else{v=[s.clone()]}}}}}}}if(d&&o.length>0&&v.length>0){v.push(g.clone());o.push(new OpenLayers.Geometry.LineString(v))}}else{q=C.splitWith(this,b)}if(c&&c.length>1){f=true}else{c=[]}if(o&&o.length>1){m=true}else{o=[]}if(f||m){if(d){q=[o,c]}else{q=c}}return q},splitWith:function(b,a){return b.split(this,a)},getVertices:function(a){var b;if(a===true){b=[this.components[0],this.components[this.components.length-1]]}else{if(a===false){b=this.components.slice(1,this.components.length-1)}else{b=this.components.slice()}}return b},distanceTo:function(k,h){var l=!(h&&h.edge===false);var E=l&&h&&h.details;var t,f={};var w=Number.POSITIVE_INFINITY;if(k instanceof OpenLayers.Geometry.Point){var u=this.getSortedSegments();var s=k.x;var r=k.y;var C;for(var A=0,B=u.length;A<B;++A){C=u[A];t=OpenLayers.Geometry.distanceToSegment(k,C);if(t.distance<w){w=t.distance;f=t;if(w===0){break}}else{if(C.x2>s&&((r>C.y1&&r<C.y2)||(r<C.y1&&r>C.y2))){break}}}if(E){f={distance:f.distance,x0:f.x,y0:f.y,x1:s,y1:r}}else{f=f.distance}}else{if(k instanceof OpenLayers.Geometry.LineString){var d=this.getSortedSegments();var c=k.getSortedSegments();var b,a,q,D,g;var o=c.length;var m={point:true};outer:for(var A=0,B=d.length;A<B;++A){b=d[A];D=b.x1;g=b.y1;for(var z=0;z<o;++z){a=c[z];q=OpenLayers.Geometry.segmentsIntersect(b,a,m);if(q){w=0;f={distance:0,x0:q.x,y0:q.y,x1:q.x,y1:q.y};break outer}else{t=OpenLayers.Geometry.distanceToSegment({x:D,y:g},a);if(t.distance<w){w=t.distance;f={distance:w,x0:D,y0:g,x1:t.x,y1:t.y}}}}}if(!E){f=f.distance}if(w!==0){if(b){t=k.distanceTo(new OpenLayers.Geometry.Point(b.x2,b.y2),h);var v=E?t.distance:t;if(v<w){if(E){f={distance:w,x0:t.x1,y0:t.y1,x1:t.x0,y1:t.y0}}else{f=v}}}}}else{f=k.distanceTo(this,h);if(E){f={distance:f.distance,x0:f.x1,y0:f.y1,x1:f.x0,y1:f.y0}}}}return f},CLASS_NAME:"OpenLayers.Geometry.LineString"});OpenLayers.Format.GPX=OpenLayers.Class(OpenLayers.Format.XML,{extractWaypoints:true,extractTracks:true,extractRoutes:true,extractAttributes:true,initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},read:function(C){if(typeof C=="string"){C=OpenLayers.Format.XML.prototype.read.apply(this,[C])}var c=[];if(this.extractTracks){var w=C.getElementsByTagName("trk");for(var v=0,z=w.length;v<z;v++){var q={};if(this.extractAttributes){q=this.parseAttributes(w[v])}var m=this.getElementsByTagNameNS(w[v],w[v].namespaceURI,"trkseg");for(var u=0,h=m.length;u<h;u++){var o=this.extractSegment(m[u],"trkpt");c.push(new OpenLayers.Feature.Vector(o,q))}}}if(this.extractRoutes){var a=C.getElementsByTagName("rte");for(var t=0,s=a.length;t<s;t++){var q={};if(this.extractAttributes){q=this.parseAttributes(a[t])}var B=this.extractSegment(a[t],"rtept");c.push(new OpenLayers.Feature.Vector(B,q))}}if(this.extractWaypoints){var b=C.getElementsByTagName("wpt");for(var r=0,z=b.length;r<z;r++){var q={};if(this.extractAttributes){q=this.parseAttributes(b[r])}var f=new OpenLayers.Geometry.Point(b[r].getAttribute("lon"),b[r].getAttribute("lat"));c.push(new OpenLayers.Feature.Vector(f,q))}}if(this.internalProjection&&this.externalProjection){for(var A=0,d=c.length;A<d;A++){c[A].geometry.transform(this.externalProjection,this.internalProjection)}}return c},extractSegment:function(f,g){var d=this.getElementsByTagNameNS(f,f.namespaceURI,g);var b=[];for(var c=0,a=d.length;c<a;c++){b.push(new OpenLayers.Geometry.Point(d[c].getAttribute("lon"),d[c].getAttribute("lat")))}return new OpenLayers.Geometry.LineString(b)},parseAttributes:function(b){var a={};var d=b.firstChild;while(d){if(d.nodeType==1){var c=d.firstChild;if(c.nodeType==3||c.nodeType==4){name=(d.prefix)?d.nodeName.split(":")[1]:d.nodeName;if(name!="trkseg"&&name!="rtept"){a[name]=c.nodeValue}}}d=d.nextSibling}return a},CLASS_NAME:"OpenLayers.Format.GPX"});OpenLayers.Geometry.LinearRing=OpenLayers.Class(OpenLayers.Geometry.LineString,{componentTypes:["OpenLayers.Geometry.Point"],initialize:function(a){OpenLayers.Geometry.LineString.prototype.initialize.apply(this,arguments)},addComponent:function(a,b){var c=false;var d=this.components.pop();if(b!=null||!a.equals(d)){c=OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,arguments)}var f=this.components[0];OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,[f]);return c},removeComponent:function(a){if(this.components.length>4){this.components.pop();OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,arguments);var b=this.components[0];OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,[b])}},move:function(b,d){for(var c=0,a=this.components.length;c<a-1;c++){this.components[c].move(b,d)}},rotate:function(d,b){for(var c=0,a=this.components.length;c<a-1;++c){this.components[c].rotate(d,b)}},resize:function(f,b,d){for(var c=0,a=this.components.length;c<a-1;++c){this.components[c].resize(f,b,d)}return this},transform:function(f,c){if(f&&c){for(var d=0,a=this.components.length;d<a-1;d++){var b=this.components[d];b.transform(f,c)}this.bounds=null}return this},getCentroid:function(){if(this.components&&(this.components.length>2)){var j=0;var h=0;for(var f=0;f<this.components.length-1;f++){var d=this.components[f];var l=this.components[f+1];j+=(d.x+l.x)*(d.x*l.y-l.x*d.y);h+=(d.y+l.y)*(d.x*l.y-l.x*d.y)}var g=-1*this.getArea();var a=j/(6*g);var k=h/(6*g)}return new OpenLayers.Geometry.Point(a,k)},getArea:function(){var h=0;if(this.components&&(this.components.length>2)){var g=0;for(var f=0,d=this.components.length;f<d-1;f++){var a=this.components[f];var j=this.components[f+1];g+=(a.x+j.x)*(j.y-a.y)}h=-g/2}return h},getGeodesicArea:function(b){var d=this;if(b){var c=new OpenLayers.Projection("EPSG:4326");if(!c.equals(b)){d=this.clone().transform(b,c)}}var g=0;var a=d.components&&d.components.length;if(a>2){var j,h;for(var f=0;f<a-1;f++){j=d.components[f];h=d.components[f+1];g+=OpenLayers.Util.rad(h.x-j.x)*(2+Math.sin(OpenLayers.Util.rad(j.y))+Math.sin(OpenLayers.Util.rad(h.y)))}g=g*6378137*6378137/2}return g},containsPoint:function(o){var v=OpenLayers.Number.limitSigDigs;var m=14;var l=v(o.x,m);var k=v(o.y,m);function u(C,z,B,w,A){return(((z-w)*C)+((w*B)-(z*A)))/(B-A)}var a=this.components.length-1;var h,g,t,d,r,b,f,c;var j=0;for(var q=0;q<a;++q){h=this.components[q];t=v(h.x,m);d=v(h.y,m);g=this.components[q+1];r=v(g.x,m);b=v(g.y,m);if(d==b){if(k==d){if(t<=r&&(l>=t&&l<=r)||t>=r&&(l<=t&&l>=r)){j=-1;break}}continue}f=v(u(k,t,d,r,b),m);if(f==l){if(d<b&&(k>=d&&k<=b)||d>b&&(k<=d&&k>=b)){j=-1;break}}if(f<=l){continue}if(t!=r&&(f<Math.min(t,r)||f>Math.max(t,r))){continue}if(d<b&&(k>=d&&k<b)||d>b&&(k<d&&k>=b)){++j}}var s=(j==-1)?1:!!(j&1);return s},intersects:function(d){var b=false;if(d.CLASS_NAME=="OpenLayers.Geometry.Point"){b=this.containsPoint(d)}else{if(d.CLASS_NAME=="OpenLayers.Geometry.LineString"){b=d.intersects(this)}else{if(d.CLASS_NAME=="OpenLayers.Geometry.LinearRing"){b=OpenLayers.Geometry.LineString.prototype.intersects.apply(this,[d])}else{for(var c=0,a=d.components.length;c<a;++c){b=d.components[c].intersects(this);if(b){break}}}}}return b},getVertices:function(a){return(a===true)?[]:this.components.slice(0,this.components.length-1)},CLASS_NAME:"OpenLayers.Geometry.LinearRing"});OpenLayers.Geometry.MultiLineString=OpenLayers.Class(OpenLayers.Geometry.Collection,{componentTypes:["OpenLayers.Geometry.LineString"],initialize:function(a){OpenLayers.Geometry.Collection.prototype.initialize.apply(this,arguments)},split:function(q,v){var h=null;var u=v&&v.mutual;var r,a,t,o,b;var f=[];var s=[q];for(var g=0,l=this.components.length;g<l;++g){a=this.components[g];o=false;for(var d=0;d<s.length;++d){r=a.split(s[d],v);if(r){if(u){t=r[0];for(var c=0,m=t.length;c<m;++c){if(c===0&&f.length){f[f.length-1].addComponent(t[c])}else{f.push(new OpenLayers.Geometry.MultiLineString([t[c]]))}}o=true;r=r[1]}if(r.length){r.unshift(d,1);Array.prototype.splice.apply(s,r);break}}}if(!o){if(f.length){f[f.length-1].addComponent(a.clone())}else{f=[new OpenLayers.Geometry.MultiLineString(a.clone())]}}}if(f&&f.length>1){o=true}else{f=[]}if(s&&s.length>1){b=true}else{s=[]}if(o||b){if(u){h=[f,s]}else{h=s}}return h},splitWith:function(q,v){var h=null;var u=v&&v.mutual;var r,c,t,o,a,f,s;if(q instanceof OpenLayers.Geometry.LineString){s=[];f=[q];for(var g=0,l=this.components.length;g<l;++g){a=false;c=this.components[g];for(var d=0;d<f.length;++d){r=f[d].split(c,v);if(r){if(u){t=r[0];if(t.length){t.unshift(d,1);Array.prototype.splice.apply(f,t);d+=t.length-2}r=r[1];if(r.length===0){r=[c.clone()]}}for(var b=0,m=r.length;b<m;++b){if(b===0&&s.length){s[s.length-1].addComponent(r[b])}else{s.push(new OpenLayers.Geometry.MultiLineString([r[b]]))}}a=true}}if(!a){if(s.length){s[s.length-1].addComponent(c.clone())}else{s=[new OpenLayers.Geometry.MultiLineString([c.clone()])]}}}}else{h=q.split(this)}if(f&&f.length>1){o=true}else{f=[]}if(s&&s.length>1){a=true}else{s=[]}if(o||a){if(u){h=[f,s]}else{h=s}}return h},CLASS_NAME:"OpenLayers.Geometry.MultiLineString"});OpenLayers.Handler.Path=OpenLayers.Class(OpenLayers.Handler.Point,{line:null,freehand:false,freehandToggle:"shiftKey",initialize:function(c,b,a){OpenLayers.Handler.Point.prototype.initialize.apply(this,arguments)},createFeature:function(a){var b=this.control.map.getLonLatFromPixel(a);this.point=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(b.lon,b.lat));this.line=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([this.point.geometry]));this.callback("create",[this.point.geometry,this.getSketch()]);this.point.geometry.clearBounds();this.layer.addFeatures([this.line,this.point],{silent:true})},destroyFeature:function(){OpenLayers.Handler.Point.prototype.destroyFeature.apply(this);this.line=null},removePoint:function(){if(this.point){this.layer.removeFeatures([this.point])}},addPoint:function(a){this.layer.removeFeatures([this.point]);var b=this.control.map.getLonLatFromPixel(a);this.point=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(b.lon,b.lat));this.line.geometry.addComponent(this.point.geometry,this.line.geometry.components.length);this.callback("point",[this.point.geometry,this.getGeometry()]);this.callback("modify",[this.point.geometry,this.getSketch()]);this.drawFeature()},freehandMode:function(a){return(this.freehandToggle&&a[this.freehandToggle])?!this.freehand:this.freehand},modifyFeature:function(a){var b=this.control.map.getLonLatFromPixel(a);this.point.geometry.x=b.lon;this.point.geometry.y=b.lat;this.callback("modify",[this.point.geometry,this.getSketch()]);this.point.geometry.clearBounds();this.drawFeature()},drawFeature:function(){this.layer.drawFeature(this.line,this.style);this.layer.drawFeature(this.point,this.style)},getSketch:function(){return this.line},getGeometry:function(){var a=this.line&&this.line.geometry;if(a&&this.multi){a=new OpenLayers.Geometry.MultiLineString([a])}return a},mousedown:function(a){if(this.lastDown&&this.lastDown.equals(a.xy)){return false}if(this.lastDown==null){if(this.persist){this.destroyFeature()}this.createFeature(a.xy)}else{if((this.lastUp==null)||!this.lastUp.equals(a.xy)){this.addPoint(a.xy)}}this.mouseDown=true;this.lastDown=a.xy;this.drawing=true;return false},mousemove:function(a){if(this.drawing){if(this.mouseDown&&this.freehandMode(a)){this.addPoint(a.xy)}else{this.modifyFeature(a.xy)}}return true},mouseup:function(a){this.mouseDown=false;if(this.drawing){if(this.freehandMode(a)){this.removePoint();this.finalize()}else{if(this.lastUp==null){this.addPoint(a.xy)}this.lastUp=a.xy}return false}return true},dblclick:function(a){if(!this.freehandMode(a)){var b=this.line.geometry.components.length-1;this.line.geometry.removeComponent(this.line.geometry.components[b]);this.removePoint();this.finalize()}return false},CLASS_NAME:"OpenLayers.Handler.Path"});OpenLayers.Control.Split=OpenLayers.Class(OpenLayers.Control,{EVENT_TYPES:["beforesplit","split","aftersplit"],layer:null,source:null,sourceOptions:null,tolerance:null,edge:true,deferDelete:false,mutual:true,targetFilter:null,sourceFilter:null,handler:null,initialize:function(a){Array.prototype.push.apply(this.EVENT_TYPES,OpenLayers.Control.prototype.EVENT_TYPES);OpenLayers.Control.prototype.initialize.apply(this,[a]);this.options=a||{};if(this.options.source){this.setSource(this.options.source)}},setSource:function(a){if(this.active){this.deactivate();if(this.handler){this.handler.destroy();delete this.handler}this.source=a;this.activate()}else{this.source=a}},activate:function(){var a=OpenLayers.Control.prototype.activate.call(this);if(a){if(!this.source){if(!this.handler){this.handler=new OpenLayers.Handler.Path(this,{done:function(b){this.onSketchComplete({feature:new OpenLayers.Feature.Vector(b)})}},{layerOptions:this.sourceOptions})}this.handler.activate()}else{if(this.source.events){this.source.events.on({sketchcomplete:this.onSketchComplete,afterfeaturemodified:this.afterFeatureModified,scope:this})}}}return a},deactivate:function(){var a=OpenLayers.Control.prototype.deactivate.call(this);if(a){if(this.source&&this.source.events){this.layer.events.un({sketchcomplete:this.onSketchComplete,afterfeaturemodified:this.afterFeatureModified,scope:this})}}return a},onSketchComplete:function(a){this.feature=null;return !this.considerSplit(a.feature)},afterFeatureModified:function(b){if(b.modified){var a=b.feature;if(a.geometry instanceof OpenLayers.Geometry.LineString||a.geometry instanceof OpenLayers.Geometry.MultiLineString){this.feature=b.feature;this.considerSplit(b.feature)}}},removeByGeometry:function(c,d){for(var b=0,a=c.length;b<a;++b){if(c[b].geometry===d){c.splice(b,1);break}}},isEligible:function(a){return(a.state!==OpenLayers.State.DELETE)&&(a.geometry instanceof OpenLayers.Geometry.LineString||a.geometry instanceof OpenLayers.Geometry.MultiLineString)&&(this.feature!==a)&&(!this.targetFilter||this.targetFilter.evaluate(a.attributes))},considerSplit:function(c){sourceSplit=false;targetSplit=false;if(!this.sourceFilter||this.sourceFilter.evaluate(c.attributes)){var g=this.layer&&this.layer.features||[];var C,r,h,a;var m=[],B=[];var d=(this.layer===this.source)&&this.mutual;var b={edge:this.edge,tolerance:this.tolerance,mutual:d};var l=[c.geometry];var q,f;var t,s;for(var z=0,A=g.length;z<A;++z){q=g[z];if(this.isEligible(q)){f=[q.geometry];for(var w=0;w<l.length;++w){t=l[w];for(var u=0;u<f.length;++u){C=f[u];if(t.getBounds().intersectsBounds(C.getBounds())){r=t.split(C,b);if(r){a=this.events.triggerEvent("beforesplit",{source:c,target:q});if(a!==false){if(d){s=r[0];if(s.length>1){s.unshift(w,1);Array.prototype.splice.apply(l,s);w+=s.length-3}r=r[1]}if(r.length>1){r.unshift(u,1);Array.prototype.splice.apply(f,r);u+=r.length-3}}}}}}if(f&&f.length>1){this.geomsToFeatures(q,f);this.events.triggerEvent("split",{original:q,features:f});Array.prototype.push.apply(m,f);B.push(q);targetSplit=true}}}if(l&&l.length>1){this.geomsToFeatures(c,l);this.events.triggerEvent("split",{original:c,features:l});Array.prototype.push.apply(m,l);B.push(c);sourceSplit=true}if(sourceSplit||targetSplit){if(this.deferDelete){var o,v=[];for(var z=0,A=B.length;z<A;++z){o=B[z];if(o.state===OpenLayers.State.INSERT){v.push(o)}else{o.state=OpenLayers.State.DELETE;this.layer.drawFeature(o)}}this.layer.destroyFeatures(v,{silent:true});for(var z=0,A=m.length;z<A;++z){m[z].state=OpenLayers.State.INSERT}}else{this.layer.destroyFeatures(B,{silent:true})}this.layer.addFeatures(m,{silent:true});this.events.triggerEvent("aftersplit",{source:c,features:m})}}return sourceSplit},geomsToFeatures:function(c,d){var g=c.clone();delete g.geometry;var f;for(var b=0,a=d.length;b<a;++b){f=g.clone();f.geometry=d[b];f.state=OpenLayers.State.INSERT;d[b]=f}},destroy:function(){if(this.active){this.deactivate()}OpenLayers.Control.prototype.destroy.call(this)},CLASS_NAME:"OpenLayers.Control.Split"});OpenLayers.Geometry.Polygon=OpenLayers.Class(OpenLayers.Geometry.Collection,{componentTypes:["OpenLayers.Geometry.LinearRing"],initialize:function(a){OpenLayers.Geometry.Collection.prototype.initialize.apply(this,arguments)},getArea:function(){var c=0;if(this.components&&(this.components.length>0)){c+=Math.abs(this.components[0].getArea());for(var b=1,a=this.components.length;b<a;b++){c-=Math.abs(this.components[b].getArea())}}return c},getGeodesicArea:function(b){var d=0;if(this.components&&(this.components.length>0)){d+=Math.abs(this.components[0].getGeodesicArea(b));for(var c=1,a=this.components.length;c<a;c++){d-=Math.abs(this.components[c].getGeodesicArea(b))}}return d},containsPoint:function(a){var f=this.components.length;var c=false;if(f>0){c=this.components[0].containsPoint(a);if(c!==1){if(c&&f>1){var d;for(var b=1;b<f;++b){d=this.components[b].containsPoint(a);if(d){if(d===1){c=1}else{c=false}break}}}}}return c},intersects:function(f){var b=false;var d,a;if(f.CLASS_NAME=="OpenLayers.Geometry.Point"){b=this.containsPoint(f)}else{if(f.CLASS_NAME=="OpenLayers.Geometry.LineString"||f.CLASS_NAME=="OpenLayers.Geometry.LinearRing"){for(d=0,a=this.components.length;d<a;++d){b=f.intersects(this.components[d]);if(b){break}}if(!b){for(d=0,a=f.components.length;d<a;++d){b=this.containsPoint(f.components[d]);if(b){break}}}}else{for(d=0,a=f.components.length;d<a;++d){b=this.intersects(f.components[d]);if(b){break}}}}if(!b&&f.CLASS_NAME=="OpenLayers.Geometry.Polygon"){var c=this.components[0];for(d=0,a=c.components.length;d<a;++d){b=f.containsPoint(c.components[d]);if(b){break}}}return b},distanceTo:function(d,b){var c=!(b&&b.edge===false);var a;if(!c&&this.intersects(d)){a=0}else{a=OpenLayers.Geometry.Collection.prototype.distanceTo.apply(this,[d,b])}return a},CLASS_NAME:"OpenLayers.Geometry.Polygon"});OpenLayers.Geometry.Polygon.createRegularPolygon=function(k,g,b,m){var c=Math.PI*((1/b)-(1/2));if(m){c+=(m/180)*Math.PI}var a,j,h;var l=[];for(var f=0;f<b;++f){a=c+(f*2*Math.PI/b);j=k.x+(g*Math.cos(a));h=k.y+(g*Math.sin(a));l.push(new OpenLayers.Geometry.Point(j,h))}var d=new OpenLayers.Geometry.LinearRing(l);return new OpenLayers.Geometry.Polygon([d])};OpenLayers.Format.GeoRSS=OpenLayers.Class(OpenLayers.Format.XML,{rssns:"http://backend.userland.com/rss2",featureNS:"http://mapserver.gis.umn.edu/mapserver",georssns:"http://www.georss.org/georss",geons:"http://www.w3.org/2003/01/geo/wgs84_pos#",featureTitle:"Untitled",featureDescription:"No Description",gmlParser:null,xy:false,initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},createGeometryFromItem:function(q){var o=this.getElementsByTagNameNS(q,this.georssns,"point");var h=this.getElementsByTagNameNS(q,this.geons,"lat");var a=this.getElementsByTagNameNS(q,this.geons,"long");var s=this.getElementsByTagNameNS(q,this.georssns,"line");var l=this.getElementsByTagNameNS(q,this.georssns,"polygon");var c=this.getElementsByTagNameNS(q,this.georssns,"where");var d=this.getElementsByTagNameNS(q,this.georssns,"box");if(o.length>0||(h.length>0&&a.length>0)){var m;if(o.length>0){m=OpenLayers.String.trim(o[0].firstChild.nodeValue).split(/\s+/);if(m.length!=2){m=OpenLayers.String.trim(o[0].firstChild.nodeValue).split(/\s*,\s*/)}}else{m=[parseFloat(h[0].firstChild.nodeValue),parseFloat(a[0].firstChild.nodeValue)]}var j=new OpenLayers.Geometry.Point(parseFloat(m[1]),parseFloat(m[0]))}else{if(s.length>0){var k=OpenLayers.String.trim(this.concatChildValues(s[0])).split(/\s+/);var f=[];var o;for(var b=0,g=k.length;b<g;b+=2){o=new OpenLayers.Geometry.Point(parseFloat(k[b+1]),parseFloat(k[b]));f.push(o)}j=new OpenLayers.Geometry.LineString(f)}else{if(l.length>0){var k=OpenLayers.String.trim(this.concatChildValues(l[0])).split(/\s+/);var f=[];var o;for(var b=0,g=k.length;b<g;b+=2){o=new OpenLayers.Geometry.Point(parseFloat(k[b+1]),parseFloat(k[b]));f.push(o)}j=new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(f)])}else{if(c.length>0){if(!this.gmlParser){this.gmlParser=new OpenLayers.Format.GML({xy:this.xy})}var r=this.gmlParser.parseFeature(c[0]);j=r.geometry}else{if(d.length>0){var k=OpenLayers.String.trim(d[0].firstChild.nodeValue).split(/\s+/);var f=[];var o;if(k.length>3){o=new OpenLayers.Geometry.Point(parseFloat(k[1]),parseFloat(k[0]));f.push(o);o=new OpenLayers.Geometry.Point(parseFloat(k[1]),parseFloat(k[2]));f.push(o);o=new OpenLayers.Geometry.Point(parseFloat(k[3]),parseFloat(k[2]));f.push(o);o=new OpenLayers.Geometry.Point(parseFloat(k[3]),parseFloat(k[0]));f.push(o);o=new OpenLayers.Geometry.Point(parseFloat(k[1]),parseFloat(k[0]));f.push(o)}j=new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(f)])}}}}}if(j&&this.internalProjection&&this.externalProjection){j.transform(this.externalProjection,this.internalProjection)}return j},createFeatureFromItem:function(j){var d=this.createGeometryFromItem(j);var g=this.getChildValue(j,"*","title",this.featureTitle);var h=this.getChildValue(j,"*","description",this.getChildValue(j,"*","content",this.getChildValue(j,"*","summary",this.featureDescription)));var f=this.getChildValue(j,"*","link");if(!f){try{f=this.getElementsByTagNameNS(j,"*","link")[0].getAttribute("href")}catch(c){f=null}}var a=this.getChildValue(j,"*","id",null);var b={title:g,description:h,link:f};var k=new OpenLayers.Feature.Vector(d,b);k.fid=a;return k},getChildValue:function(d,b,c,g){var f;var a=this.getElementsByTagNameNS(d,b,c);if(a&&a[0]&&a[0].firstChild&&a[0].firstChild.nodeValue){f=a[0].firstChild.nodeValue}else{f=(g==undefined)?"":g}return f},read:function(f){if(typeof f=="string"){f=OpenLayers.Format.XML.prototype.read.apply(this,[f])}var a=null;a=this.getElementsByTagNameNS(f,"*","item");if(a.length==0){a=this.getElementsByTagNameNS(f,"*","entry")}var c=a.length;var d=new Array(c);for(var b=0;b<c;b++){d[b]=this.createFeatureFromItem(a[b])}return d},write:function(c){var d;if(c instanceof Array){d=this.createElementNS(this.rssns,"rss");for(var b=0,a=c.length;b<a;b++){d.appendChild(this.createFeatureXML(c[b]))}}else{d=this.createFeatureXML(c)}return OpenLayers.Format.XML.prototype.write.apply(this,[d])},createFeatureXML:function(l){var g=this.buildGeometryNode(l.geometry);var a=this.createElementNS(this.rssns,"item");var d=this.createElementNS(this.rssns,"title");d.appendChild(this.createTextNode(l.attributes.title?l.attributes.title:""));var b=this.createElementNS(this.rssns,"description");b.appendChild(this.createTextNode(l.attributes.description?l.attributes.description:""));a.appendChild(d);a.appendChild(b);if(l.attributes.link){var j=this.createElementNS(this.rssns,"link");j.appendChild(this.createTextNode(l.attributes.link));a.appendChild(j)}for(var k in l.attributes){if(k=="link"||k=="title"||k=="description"){continue}var h=this.createTextNode(l.attributes[k]);var f=k;if(k.search(":")!=-1){f=k.split(":")[1]}var c=this.createElementNS(this.featureNS,"feature:"+f);c.appendChild(h);a.appendChild(c)}a.appendChild(g);return a},buildGeometryNode:function(b){if(this.internalProjection&&this.externalProjection){b=b.clone();b.transform(this.internalProjection,this.externalProjection)}var a;if(b.CLASS_NAME=="OpenLayers.Geometry.Polygon"){a=this.createElementNS(this.georssns,"georss:polygon");a.appendChild(this.buildCoordinatesNode(b.components[0]))}else{if(b.CLASS_NAME=="OpenLayers.Geometry.LineString"){a=this.createElementNS(this.georssns,"georss:line");a.appendChild(this.buildCoordinatesNode(b))}else{if(b.CLASS_NAME=="OpenLayers.Geometry.Point"){a=this.createElementNS(this.georssns,"georss:point");a.appendChild(this.buildCoordinatesNode(b))}else{throw"Couldn't parse "+b.CLASS_NAME}}}return a},buildCoordinatesNode:function(g){var c=null;if(g.components){c=g.components}var f;if(c){var b=c.length;var d=new Array(b);for(var a=0;a<b;a++){d[a]=c[a].y+" "+c[a].x}f=d.join(" ")}else{f=g.y+" "+g.x}return this.createTextNode(f)},CLASS_NAME:"OpenLayers.Format.GeoRSS"});OpenLayers.Format.KML=OpenLayers.Class(OpenLayers.Format.XML,{kmlns:"http://earth.google.com/kml/2.0",placemarksDesc:"No description available",foldersName:"OpenLayers export",foldersDesc:"Exported on "+new Date(),extractAttributes:true,extractStyles:false,internalns:null,features:null,styles:null,styleBaseUrl:"",fetched:null,maxDepth:0,initialize:function(a){this.regExes={trimSpace:(/^\s*|\s*$/g),removeSpace:(/\s*/g),splitSpace:(/\s+/),trimComma:(/\s*,\s*/g),kmlColor:(/(\w{2})(\w{2})(\w{2})(\w{2})/),kmlIconPalette:(/root:\/\/icons\/palette-(\d+)(\.\w+)/),straightBracket:(/\$\[(.*?)\]/g)};OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},read:function(b){this.features=[];this.styles={};this.fetched={};var a={depth:0,styleBaseUrl:this.styleBaseUrl};return this.parseData(b,a)},parseData:function(h,c){if(typeof h=="string"){h=OpenLayers.Format.XML.prototype.read.apply(this,[h])}var f=["Link","NetworkLink","Style","StyleMap","Placemark"];for(var d=0,a=f.length;d<a;++d){var g=f[d];var b=this.getElementsByTagNameNS(h,"*",g);if(b.length==0){continue}switch(g.toLowerCase()){case"link":case"networklink":this.parseLinks(b,c);break;case"style":if(this.extractStyles){this.parseStyles(b,c)}break;case"stylemap":if(this.extractStyles){this.parseStyleMaps(b,c)}break;case"placemark":this.parseFeatures(b,c);break}}return this.features},parseLinks:function(c,d){if(d.depth>=this.maxDepth){return false}var h=OpenLayers.Util.extend({},d);h.depth++;for(var f=0,a=c.length;f<a;f++){var b=this.parseProperty(c[f],"*","href");if(b&&!this.fetched[b]){this.fetched[b]=true;var g=this.fetchLink(b);if(g){this.parseData(g,h)}}}},fetchLink:function(a){var b=OpenLayers.Request.GET({url:a,async:false});if(b){return b.responseText}},parseStyles:function(b,c){for(var d=0,a=b.length;d<a;d++){var f=this.parseStyle(b[d]);if(f){styleName=(c.styleBaseUrl||"")+"#"+f.id;this.styles[styleName]=f}}},parseStyle:function(B){var M={};var K=["LineStyle","PolyStyle","IconStyle","BalloonStyle"];var U,l,m,v;for(var P=0,q=K.length;P<q;++P){U=K[P];styleTypeNode=this.getElementsByTagNameNS(B,"*",U)[0];if(!styleTypeNode){continue}switch(U.toLowerCase()){case"linestyle":var u=this.parseProperty(styleTypeNode,"*","color");if(u){var c=(u.toString()).match(this.regExes.kmlColor);var N=c[1];M.strokeOpacity=parseInt(N,16)/255;var T=c[2];var R=c[3];var L=c[4];M.strokeColor="#"+L+R+T}var a=this.parseProperty(styleTypeNode,"*","width");if(a){M.strokeWidth=a}case"polystyle":var u=this.parseProperty(styleTypeNode,"*","color");if(u){var c=(u.toString()).match(this.regExes.kmlColor);var N=c[1];M.fillOpacity=parseInt(N,16)/255;var T=c[2];var R=c[3];var L=c[4];M.fillColor="#"+L+R+T}var o=this.parseProperty(styleTypeNode,"*","fill");if(o=="0"){M.fillColor="none"}break;case"iconstyle":var C=parseFloat(this.parseProperty(styleTypeNode,"*","scale")||1);var a=32*C;var d=32*C;var f=this.getElementsByTagNameNS(styleTypeNode,"*","Icon")[0];if(f){var t=this.parseProperty(f,"*","href");if(t){var J=this.parseProperty(f,"*","w");var Q=this.parseProperty(f,"*","h");var k="http://maps.google.com/mapfiles/kml";if(OpenLayers.String.startsWith(t,k)&&!J&&!Q){J=64;Q=64;C=C/2}J=J||Q;Q=Q||J;if(J){a=parseInt(J)*C}if(Q){d=parseInt(Q)*C}var c=t.match(this.regExes.kmlIconPalette);if(c){var O=c[1];var s=c[2];var I=this.parseProperty(f,"*","x");var H=this.parseProperty(f,"*","y");var E=I?I/32:0;var D=H?(7-H/32):7;var A=D*8+E;t="http://maps.google.com/mapfiles/kml/pal"+O+"/icon"+A+s}M.graphicOpacity=1;M.externalGraphic=t}}var G=this.getElementsByTagNameNS(styleTypeNode,"*","hotSpot")[0];if(G){var I=parseFloat(G.getAttribute("x"));var H=parseFloat(G.getAttribute("y"));var z=G.getAttribute("xunits");if(z=="pixels"){M.graphicXOffset=-I*C}else{if(z=="insetPixels"){M.graphicXOffset=-a+(I*C)}else{if(z=="fraction"){M.graphicXOffset=-a*I}}}var j=G.getAttribute("yunits");if(j=="pixels"){M.graphicYOffset=-d+(H*C)+1}else{if(j=="insetPixels"){M.graphicYOffset=-(H*C)+1}else{if(j=="fraction"){M.graphicYOffset=-d*(1-H)+1}}}}M.graphicWidth=a;M.graphicHeight=d;break;case"balloonstyle":var S=OpenLayers.Util.getXmlNodeValue(styleTypeNode);if(S){M.balloonStyle=S.replace(this.regExes.straightBracket,"${$1}")}break;default:}}if(!M.strokeColor&&M.fillColor){M.strokeColor=M.fillColor}var F=B.getAttribute("id");if(F&&M){M.id=F}return M},parseStyleMaps:function(a,q){for(var h=0,k=a.length;h<k;h++){var d=a[h];var c=this.getElementsByTagNameNS(d,"*","Pair");var b=d.getAttribute("id");for(var g=0,o=c.length;g<o;g++){var f=c[g];var m=this.parseProperty(f,"*","key");var l=this.parseProperty(f,"*","styleUrl");if(l&&m=="normal"){this.styles[(q.styleBaseUrl||"")+"#"+b]=this.styles[(q.styleBaseUrl||"")+l]}if(l&&m=="highlight"){}}}},parseFeatures:function(a,k){var d=new Array(a.length);for(var f=0,g=a.length;f<g;f++){var b=a[f];var j=this.parseFeature.apply(this,[b]);if(j){if(this.extractStyles&&j.attributes&&j.attributes.styleUrl){j.style=this.getStyle(j.attributes.styleUrl,k)}if(this.extractStyles){var h=this.getElementsByTagNameNS(b,"*","Style")[0];if(h){var c=this.parseStyle(h);if(c){j.style=OpenLayers.Util.extend(j.style,c)}}}d[f]=j}else{throw"Bad Placemark: "+f}}this.features=this.features.concat(d)},parseFeature:function(b){var c=["MultiGeometry","Polygon","LineString","Point"];var k,f,l,a;for(var h=0,j=c.length;h<j;++h){k=c[h];this.internalns=b.namespaceURI?b.namespaceURI:this.kmlns;f=this.getElementsByTagNameNS(b,this.internalns,k);if(f.length>0){var a=this.parseGeometry[k.toLowerCase()];if(a){l=a.apply(this,[f[0]]);if(this.internalProjection&&this.externalProjection){l.transform(this.externalProjection,this.internalProjection)}}else{OpenLayers.Console.error(OpenLayers.i18n("unsupportedGeometryType",{geomType:k}))}break}}var g;if(this.extractAttributes){g=this.parseAttributes(b)}var m=new OpenLayers.Feature.Vector(l,g);var d=b.getAttribute("id")||b.getAttribute("name");if(d!=null){m.fid=d}return m},getStyle:function(b,a){var c=OpenLayers.Util.removeTail(b);var g=OpenLayers.Util.extend({},a);g.depth++;g.styleBaseUrl=c;if(!this.styles[b]&&!OpenLayers.String.startsWith(b,"#")&&g.depth<=this.maxDepth&&!this.fetched[c]){var f=this.fetchLink(c);if(f){this.parseData(f,g)}}var d=OpenLayers.Util.extend({},this.styles[b]);return d},parseGeometry:{point:function(d){var c=this.getElementsByTagNameNS(d,this.internalns,"coordinates");var f=[];if(c.length>0){var b=c[0].firstChild.nodeValue;b=b.replace(this.regExes.removeSpace,"");f=b.split(",")}var a=null;if(f.length>1){if(f.length==2){f[2]=null}a=new OpenLayers.Geometry.Point(f[0],f[1],f[2])}else{throw"Bad coordinate string: "+b}return a},linestring:function(c,f){var d=this.getElementsByTagNameNS(c,this.internalns,"coordinates");var m=null;if(d.length>0){var b=this.getChildValue(d[0]);b=b.replace(this.regExes.trimSpace,"");b=b.replace(this.regExes.trimComma,",");var a=b.split(this.regExes.splitSpace);var j=a.length;var l=new Array(j);var k,h;for(var g=0;g<j;++g){k=a[g].split(",");h=k.length;if(h>1){if(k.length==2){k[2]=null}l[g]=new OpenLayers.Geometry.Point(k[0],k[1],k[2])}else{throw"Bad LineString point coordinates: "+a[g]}}if(j){if(f){m=new OpenLayers.Geometry.LinearRing(l)}else{m=new OpenLayers.Geometry.LineString(l)}}else{throw"Bad LineString coordinates: "+b}}return m},polygon:function(g){var c=this.getElementsByTagNameNS(g,this.internalns,"LinearRing");var h=c.length;var f=new Array(h);if(h>0){var b;for(var d=0,a=c.length;d<a;++d){b=this.parseGeometry.linestring.apply(this,[c[d],true]);if(b){f[d]=b}else{throw"Bad LinearRing geometry: "+d}}}return new OpenLayers.Geometry.Polygon(f)},multigeometry:function(f){var j,h;var g=[];var c=f.childNodes;for(var b=0,a=c.length;b<a;++b){j=c[b];if(j.nodeType==1){var d=(j.prefix)?j.nodeName.split(":")[1]:j.nodeName;var h=this.parseGeometry[d.toLowerCase()];if(h){g.push(h.apply(this,[j]))}}}return new OpenLayers.Geometry.Collection(g)}},parseAttributes:function(d){var f={};var g=d.getElementsByTagName("ExtendedData");if(g.length){f=this.parseExtendedData(g[0])}var b,m,l;var c=d.childNodes;for(var h=0,j=c.length;h<j;++h){b=c[h];if(b.nodeType==1){m=b.childNodes;if(m.length==1||m.length==3){var l;switch(m.length){case 1:l=m[0];break;case 3:default:l=m[1];break}if(l.nodeType==3||l.nodeType==4){var a=(b.prefix)?b.nodeName.split(":")[1]:b.nodeName;var k=OpenLayers.Util.getXmlNodeValue(l);if(k){k=k.replace(this.regExes.trimSpace,"");f[a]=k}}}}}return f},parseExtendedData:function(b){var d={};var c=b.getElementsByTagName("Data");for(var g=0,j=c.length;g<j;g++){var f=c[g];var k=f.getAttribute("name");var h={};var l=f.getElementsByTagName("value");if(l.length){h.value=this.getChildValue(l[0])}var a=f.getElementsByTagName("displayName");if(a.length){h.displayName=this.getChildValue(a[0])}d[k]=h}return d},parseProperty:function(c,d,b){var f;var a=this.getElementsByTagNameNS(c,d,b);try{f=OpenLayers.Util.getXmlNodeValue(a[0])}catch(g){f=null}return f},write:function(d){if(!(d instanceof Array)){d=[d]}var b=this.createElementNS(this.kmlns,"kml");var f=this.createFolderXML();for(var c=0,a=d.length;c<a;++c){f.appendChild(this.createPlacemarkXML(d[c]))}b.appendChild(f);return OpenLayers.Format.XML.prototype.write.apply(this,[b])},createFolderXML:function(){var f=this.createElementNS(this.kmlns,"name");var d=this.createTextNode(this.foldersName);f.appendChild(d);var a=this.createElementNS(this.kmlns,"description");var b=this.createTextNode(this.foldersDesc);a.appendChild(b);var c=this.createElementNS(this.kmlns,"Folder");c.appendChild(f);c.appendChild(a);return c},createPlacemarkXML:function(f){var h=this.createElementNS(this.kmlns,"name");var c=(f.attributes.name)?f.attributes.name:f.id;h.appendChild(this.createTextNode(c));var d=this.createElementNS(this.kmlns,"description");var g=(f.attributes.description)?f.attributes.description:this.placemarksDesc;d.appendChild(this.createTextNode(g));var b=this.createElementNS(this.kmlns,"Placemark");if(f.fid!=null){b.setAttribute("id",f.fid)}b.appendChild(h);b.appendChild(d);var a=this.buildGeometryNode(f.geometry);b.appendChild(a);return b},buildGeometryNode:function(f){if(this.internalProjection&&this.externalProjection){f=f.clone();f.transform(this.internalProjection,this.externalProjection)}var c=f.CLASS_NAME;var b=c.substring(c.lastIndexOf(".")+1);var a=this.buildGeometry[b.toLowerCase()];var d=null;if(a){d=a.apply(this,[f])}return d},buildGeometry:{point:function(b){var a=this.createElementNS(this.kmlns,"Point");a.appendChild(this.buildCoordinatesNode(b));return a},multipoint:function(a){return this.buildGeometry.collection.apply(this,[a])},linestring:function(b){var a=this.createElementNS(this.kmlns,"LineString");a.appendChild(this.buildCoordinatesNode(b));return a},multilinestring:function(a){return this.buildGeometry.collection.apply(this,[a])},linearring:function(b){var a=this.createElementNS(this.kmlns,"LinearRing");a.appendChild(this.buildCoordinatesNode(b));return a},polygon:function(j){var b=this.createElementNS(this.kmlns,"Polygon");var h=j.components;var f,g,d;for(var c=0,a=h.length;c<a;++c){d=(c==0)?"outerBoundaryIs":"innerBoundaryIs";f=this.createElementNS(this.kmlns,d);g=this.buildGeometry.linearring.apply(this,[h[c]]);f.appendChild(g);b.appendChild(f)}return b},multipolygon:function(a){return this.buildGeometry.collection.apply(this,[a])},collection:function(d){var b=this.createElementNS(this.kmlns,"MultiGeometry");var f;for(var c=0,a=d.components.length;c<a;++c){f=this.buildGeometryNode.apply(this,[d.components[c]]);if(f){b.appendChild(f)}}return b}},buildCoordinatesNode:function(f){var a=this.createElementNS(this.kmlns,"coordinates");var k;var j=f.components;if(j){var h;var g=j.length;var c=new Array(g);for(var d=0;d<g;++d){h=j[d];c[d]=h.x+","+h.y}k=c.join(" ")}else{k=f.x+","+f.y}var b=this.createTextNode(k);a.appendChild(b);return a},CLASS_NAME:"OpenLayers.Format.KML"});OpenLayers.Format.OSM=OpenLayers.Class(OpenLayers.Format.XML,{checkTags:false,interestingTagsExclude:null,areaTags:null,initialize:function(a){var d={interestingTagsExclude:["source","source_ref","source:ref","history","attribution","created_by"],areaTags:["area","building","leisure","tourism","ruins","historic","landuse","military","natural","sport"]};d=OpenLayers.Util.extend(d,a);var f={};for(var b=0;b<d.interestingTagsExclude.length;b++){f[d.interestingTagsExclude[b]]=true}d.interestingTagsExclude=f;var c={};for(var b=0;b<d.areaTags.length;b++){c[d.areaTags[b]]=true}d.areaTags=c;OpenLayers.Format.XML.prototype.initialize.apply(this,[d])},read:function(q){if(typeof q=="string"){q=OpenLayers.Format.XML.prototype.read.apply(this,[q])}var b=this.getNodes(q);var r=this.getWays(q);var h=new Array(r.length);for(var g=0;g<r.length;g++){var m=new Array(r[g].nodes.length);var a=this.isWayArea(r[g])?1:0;for(var f=0;f<r[g].nodes.length;f++){var c=b[r[g].nodes[f]];var o=new OpenLayers.Geometry.Point(c.lon,c.lat);o.osm_id=parseInt(r[g].nodes[f]);m[f]=o;c.used=true}var l=null;if(a){l=new OpenLayers.Geometry.Polygon(new OpenLayers.Geometry.LinearRing(m))}else{l=new OpenLayers.Geometry.LineString(m)}if(this.internalProjection&&this.externalProjection){l.transform(this.externalProjection,this.internalProjection)}var k=new OpenLayers.Feature.Vector(l,r[g].tags);k.osm_id=parseInt(r[g].id);k.fid="way."+k.osm_id;h[g]=k}for(var d in b){var c=b[d];if(!c.used||this.checkTags){var t=null;if(this.checkTags){var s=this.getTags(c.node,true);if(c.used&&!s[1]){continue}t=s[0]}else{t=this.getTags(c.node)}var k=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(c.lon,c.lat),t);if(this.internalProjection&&this.externalProjection){k.geometry.transform(this.externalProjection,this.internalProjection)}k.osm_id=parseInt(d);k.fid="node."+k.osm_id;h.push(k)}c.node=null}return h},getNodes:function(f){var d=f.getElementsByTagName("node");var a={};for(var b=0;b<d.length;b++){var c=d[b];var g=c.getAttribute("id");a[g]={lat:c.getAttribute("lat"),lon:c.getAttribute("lon"),node:c}}return a},getWays:function(h){var g=h.getElementsByTagName("way");var k=[];for(var d=0;d<g.length;d++){var b=g[d];var c={id:b.getAttribute("id")};c.tags=this.getTags(b);var f=b.getElementsByTagName("nd");c.nodes=new Array(f.length);for(var a=0;a<f.length;a++){c.nodes[a]=f[a].getAttribute("ref")}k.push(c)}return k},getTags:function(f,h){var a=f.getElementsByTagName("tag");var c={};var g=false;for(var b=0;b<a.length;b++){var d=a[b].getAttribute("k");c[d]=a[b].getAttribute("v");if(h){if(!this.interestingTagsExclude[d]){g=true}}}return h?[c,g]:c},isWayArea:function(b){var a=false;var d=false;if(b.nodes[0]==b.nodes[b.nodes.length-1]){a=true}if(this.checkTags){for(var c in b.tags){if(this.areaTags[c]){d=true;break}}}return a&&(this.checkTags?d:true)},write:function(d){if(!(d instanceof Array)){d=[d]}this.osm_id=1;this.created_nodes={};var f=this.createElementNS(null,"osm");f.setAttribute("version","0.5");f.setAttribute("generator","OpenLayers "+OpenLayers.VERSION_NUMBER);for(var c=d.length-1;c>=0;c--){var a=this.createFeatureNodes(d[c]);for(var b=0;b<a.length;b++){f.appendChild(a[b])}}return OpenLayers.Format.XML.prototype.write.apply(this,[f])},createFeatureNodes:function(c){var b=[];var f=c.geometry.CLASS_NAME;var d=f.substring(f.lastIndexOf(".")+1);d=d.toLowerCase();var a=this.createXML[d];if(a){b=a.apply(this,[c])}return b},createXML:{point:function(a){var f=null;var c=a.geometry?a.geometry:a;var d=false;if(a.osm_id){f=a.osm_id;if(this.created_nodes[f]){d=true}}else{f=-this.osm_id;this.osm_id++}if(d){b=this.created_nodes[f]}else{var b=this.createElementNS(null,"node")}this.created_nodes[f]=b;b.setAttribute("id",f);b.setAttribute("lon",c.x);b.setAttribute("lat",c.y);if(a.attributes){this.serializeTags(a,b)}this.setState(a,b);return d?[]:[b]},linestring:function(d){var a=[];var j=d.geometry;if(d.osm_id){id=d.osm_id}else{id=-this.osm_id;this.osm_id++}var b=this.createElementNS(null,"way");b.setAttribute("id",id);for(var c=0;c<j.components.length;c++){var g=this.createXML.point.apply(this,[j.components[c]]);if(g.length){g=g[0];var f=g.getAttribute("id");a.push(g)}else{f=j.components[c].osm_id;g=this.created_nodes[f]}this.setState(d,g);var h=this.createElementNS(null,"nd");h.setAttribute("ref",f);b.appendChild(h)}this.serializeTags(d,b);a.push(b);return a},polygon:function(b){var a=OpenLayers.Util.extend({area:"yes"},b.attributes);var c=new OpenLayers.Feature.Vector(b.geometry.components[0],a);c.osm_id=b.osm_id;return this.createXML.linestring.apply(this,[c])}},serializeTags:function(c,d){for(var b in c.attributes){var a=this.createElementNS(null,"tag");a.setAttribute("k",b);a.setAttribute("v",c.attributes[b]);d.appendChild(a)}},setState:function(a,b){if(a.state){var c=null;switch(a.state){case OpenLayers.State.UPDATE:c="modify";case OpenLayers.State.DELETE:c="delete"}if(c){b.setAttribute("action",c)}}},CLASS_NAME:"OpenLayers.Format.OSM"});OpenLayers.Geometry.MultiPolygon=OpenLayers.Class(OpenLayers.Geometry.Collection,{componentTypes:["OpenLayers.Geometry.Polygon"],initialize:function(a){OpenLayers.Geometry.Collection.prototype.initialize.apply(this,arguments)},CLASS_NAME:"OpenLayers.Geometry.MultiPolygon"});OpenLayers.Handler.Polygon=OpenLayers.Class(OpenLayers.Handler.Path,{polygon:null,initialize:function(c,b,a){OpenLayers.Handler.Path.prototype.initialize.apply(this,arguments)},createFeature:function(a){var b=this.control.map.getLonLatFromPixel(a);this.point=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(b.lon,b.lat));this.line=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LinearRing([this.point.geometry]));this.polygon=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([this.line.geometry]));this.callback("create",[this.point.geometry,this.getSketch()]);this.point.geometry.clearBounds();this.layer.addFeatures([this.polygon,this.point],{silent:true})},destroyFeature:function(){OpenLayers.Handler.Path.prototype.destroyFeature.apply(this);this.polygon=null},drawFeature:function(){this.layer.drawFeature(this.polygon,this.style);this.layer.drawFeature(this.point,this.style)},getSketch:function(){return this.polygon},getGeometry:function(){var a=this.polygon&&this.polygon.geometry;if(a&&this.multi){a=new OpenLayers.Geometry.MultiPolygon([a])}return a},dblclick:function(a){if(!this.freehandMode(a)){var b=this.line.geometry.components.length-2;this.line.geometry.removeComponent(this.line.geometry.components[b]);this.removePoint();this.finalize()}return false},CLASS_NAME:"OpenLayers.Handler.Polygon"});OpenLayers.Control.EditingToolbar=OpenLayers.Class(OpenLayers.Control.Panel,{initialize:function(c,b){OpenLayers.Control.Panel.prototype.initialize.apply(this,[b]);this.addControls([new OpenLayers.Control.Navigation()]);var a=[new OpenLayers.Control.DrawFeature(c,OpenLayers.Handler.Point,{displayClass:"olControlDrawFeaturePoint"}),new OpenLayers.Control.DrawFeature(c,OpenLayers.Handler.Path,{displayClass:"olControlDrawFeaturePath"}),new OpenLayers.Control.DrawFeature(c,OpenLayers.Handler.Polygon,{displayClass:"olControlDrawFeaturePolygon"})];this.addControls(a)},draw:function(){var a=OpenLayers.Control.Panel.prototype.draw.apply(this,arguments);this.activateControl(this.controls[0]);return a},CLASS_NAME:"OpenLayers.Control.EditingToolbar"});OpenLayers.Format.ArcXML=OpenLayers.Class(OpenLayers.Format.XML,{fontStyleKeys:["antialiasing","blockout","font","fontcolor","fontsize","fontstyle","glowing","interval","outline","printmode","shadow","transparency"],request:null,response:null,initialize:function(a){this.request=new OpenLayers.Format.ArcXML.Request();this.response=new OpenLayers.Format.ArcXML.Response();if(a){if(a.requesttype=="feature"){this.request.get_image=null;var c=this.request.get_feature.query;this.addCoordSys(c.featurecoordsys,a.featureCoordSys);this.addCoordSys(c.filtercoordsys,a.filterCoordSys);if(a.polygon){c.isspatial=true;c.spatialfilter.polygon=a.polygon}else{if(a.envelope){c.isspatial=true;c.spatialfilter.envelope={minx:0,miny:0,maxx:0,maxy:0};this.parseEnvelope(c.spatialfilter.envelope,a.envelope)}}}else{if(a.requesttype=="image"){this.request.get_feature=null;var b=this.request.get_image.properties;this.parseEnvelope(b.envelope,a.envelope);this.addLayers(b.layerlist,a.layers);this.addImageSize(b.imagesize,a.tileSize);this.addCoordSys(b.featurecoordsys,a.featureCoordSys);this.addCoordSys(b.filtercoordsys,a.filterCoordSys)}else{this.request=null}}}OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},parseEnvelope:function(b,a){if(a&&a.length==4){b.minx=a[0];b.miny=a[1];b.maxx=a[2];b.maxy=a[3]}},addLayers:function(d,c){for(var b=0,a=c.length;b<a;b++){d.push(c[b])}},addImageSize:function(b,a){if(a!==null){b.width=a.w;b.height=a.h;b.printwidth=a.w;b.printheight=a.h}},addCoordSys:function(a,b){if(typeof b=="string"){a.id=parseInt(b);a.string=b}else{if(typeof b=="object"&&b.proj!==null){a.id=b.proj.srsProjNumber;a.string=b.proj.srsCode}else{a=b}}},iserror:function(c){var a=null;if(!c){a=(this.response.error!=="")}else{c=OpenLayers.Format.XML.prototype.read.apply(this,[c]);var b=c.documentElement.getElementsByTagName("ERROR");a=(b!==null&&b.length>0)}return a},read:function(g){if(typeof g=="string"){g=OpenLayers.Format.XML.prototype.read.apply(this,[g])}var a=null;if(g&&g.documentElement){if(g.documentElement.nodeName=="ARCXML"){a=g.documentElement}else{a=g.documentElement.getElementsByTagName("ARCXML")[0]}}if(!a){var c,f;try{c=g.firstChild.nodeValue;f=g.firstChild.childNodes[1].firstChild.nodeValue}catch(d){}throw {message:"Error parsing the ArcXML request",error:c,source:f}}var b=this.parseResponse(a);return b},write:function(c){if(!c){c=this.request}var u=this.createElementNS("","ARCXML");u.setAttribute("version","1.1");var j=this.createElementNS("","REQUEST");if(c.get_image!=null){var m=this.createElementNS("","GET_IMAGE");j.appendChild(m);var l=this.createElementNS("","PROPERTIES");m.appendChild(l);var b=c.get_image.properties;if(b.featurecoordsys!=null){var s=this.createElementNS("","FEATURECOORDSYS");l.appendChild(s);if(b.featurecoordsys.id===0){s.setAttribute("string",b.featurecoordsys.string)}else{s.setAttribute("id",b.featurecoordsys.id)}}if(b.filtercoordsys!=null){var q=this.createElementNS("","FILTERCOORDSYS");l.appendChild(q);if(b.filtercoordsys.id===0){q.setAttribute("string",b.filtercoordsys.string)}else{q.setAttribute("id",b.filtercoordsys.id)}}if(b.envelope!=null){var A=this.createElementNS("","ENVELOPE");l.appendChild(A);A.setAttribute("minx",b.envelope.minx);A.setAttribute("miny",b.envelope.miny);A.setAttribute("maxx",b.envelope.maxx);A.setAttribute("maxy",b.envelope.maxy)}var w=this.createElementNS("","IMAGESIZE");l.appendChild(w);w.setAttribute("height",b.imagesize.height);w.setAttribute("width",b.imagesize.width);if(b.imagesize.height!=b.imagesize.printheight||b.imagesize.width!=b.imagesize.printwidth){w.setAttribute("printheight",b.imagesize.printheight);w.setArrtibute("printwidth",b.imagesize.printwidth)}if(b.background!=null){var a=this.createElementNS("","BACKGROUND");l.appendChild(a);a.setAttribute("color",b.background.color.r+","+b.background.color.g+","+b.background.color.b);if(b.background.transcolor!==null){a.setAttribute("transcolor",b.background.transcolor.r+","+b.background.transcolor.g+","+b.background.transcolor.b)}}if(b.layerlist!=null&&b.layerlist.length>0){var h=this.createElementNS("","LAYERLIST");l.appendChild(h);for(var t=0;t<b.layerlist.length;t++){var r=this.createElementNS("","LAYERDEF");h.appendChild(r);r.setAttribute("id",b.layerlist[t].id);r.setAttribute("visible",b.layerlist[t].visible);if(typeof b.layerlist[t].query=="object"){var g=b.layerlist[t].query;if(g.where.length<0){continue}var D=null;if(typeof g.spatialfilter=="boolean"&&g.spatialfilter){D=this.createElementNS("","SPATIALQUERY")}else{D=this.createElementNS("","QUERY")}D.setAttribute("where",g.where);if(typeof g.accuracy=="number"&&g.accuracy>0){D.setAttribute("accuracy",g.accuracy)}if(typeof g.featurelimit=="number"&&g.featurelimit<2000){D.setAttribute("featurelimit",g.featurelimit)}if(typeof g.subfields=="string"&&g.subfields!="#ALL#"){D.setAttribute("subfields",g.subfields)}if(typeof g.joinexpression=="string"&&g.joinexpression.length>0){D.setAttribute("joinexpression",g.joinexpression)}if(typeof g.jointables=="string"&&g.jointables.length>0){D.setAttribute("jointables",g.jointables)}r.appendChild(D)}if(typeof b.layerlist[t].renderer=="object"){this.addRenderer(r,b.layerlist[t].renderer)}}}}else{if(c.get_feature!=null){var m=this.createElementNS("","GET_FEATURES");m.setAttribute("outputmode","newxml");m.setAttribute("checkesc","true");if(c.get_feature.geometry){m.setAttribute("geometry",c.get_feature.geometry)}else{m.setAttribute("geometry","false")}if(c.get_feature.compact){m.setAttribute("compact",c.get_feature.compact)}if(c.get_feature.featurelimit=="number"){m.setAttribute("featurelimit",c.get_feature.featurelimit)}m.setAttribute("globalenvelope","true");j.appendChild(m);if(c.get_feature.layer!=null&&c.get_feature.layer.length>0){var B=this.createElementNS("","LAYER");B.setAttribute("id",c.get_feature.layer);m.appendChild(B)}var v=c.get_feature.query;if(v!=null){var z=null;if(v.isspatial){z=this.createElementNS("","SPATIALQUERY")}else{z=this.createElementNS("","QUERY")}m.appendChild(z);if(typeof v.accuracy=="number"){z.setAttribute("accuracy",v.accuracy)}if(v.featurecoordsys!=null){var f=this.createElementNS("","FEATURECOORDSYS");if(v.featurecoordsys.id==0){f.setAttribute("string",v.featurecoordsys.string)}else{f.setAttribute("id",v.featurecoordsys.id)}z.appendChild(f)}if(v.filtercoordsys!=null){var d=this.createElementNS("","FILTERCOORDSYS");if(v.filtercoordsys.id===0){d.setAttribute("string",v.filtercoordsys.string)}else{d.setAttribute("id",v.filtercoordsys.id)}z.appendChild(d)}if(v.buffer>0){var o=this.createElementNS("","BUFFER");o.setAttribute("distance",v.buffer);z.appendChild(o)}if(v.isspatial){var k=this.createElementNS("","SPATIALFILTER");k.setAttribute("relation",v.spatialfilter.relation);z.appendChild(k);if(v.spatialfilter.envelope){var C=this.createElementNS("","ENVELOPE");C.setAttribute("minx",v.spatialfilter.envelope.minx);C.setAttribute("miny",v.spatialfilter.envelope.miny);C.setAttribute("maxx",v.spatialfilter.envelope.maxx);C.setAttribute("maxy",v.spatialfilter.envelope.maxy);k.appendChild(C)}else{if(typeof v.spatialfilter.polygon=="object"){k.appendChild(this.writePolygonGeometry(v.spatialfilter.polygon))}}}if(v.where!=null&&v.where.length>0){z.setAttribute("where",v.where)}}}}u.appendChild(j);return OpenLayers.Format.XML.prototype.write.apply(this,[u])},addGroupRenderer:function(b,a){var f=this.createElementNS("","GROUPRENDERER");b.appendChild(f);for(var c=0;c<a.length;c++){var d=a[c];this.addRenderer(f,d)}},addRenderer:function(c,b){if(b instanceof Array){this.addGroupRenderer(c,b)}else{var a=this.createElementNS("",b.type.toUpperCase()+"RENDERER");c.appendChild(a);if(a.tagName=="VALUEMAPRENDERER"){this.addValueMapRenderer(a,b)}else{if(a.tagName=="VALUEMAPLABELRENDERER"){this.addValueMapLabelRenderer(a,b)}else{if(a.tagName=="SIMPLELABELRENDERER"){this.addSimpleLabelRenderer(a,b)}else{if(a.tagName=="SCALEDEPENDENTRENDERER"){this.addScaleDependentRenderer(a,b)}}}}}},addScaleDependentRenderer:function(a,b){if(typeof b.lower=="string"||typeof b.lower=="number"){a.setAttribute("lower",b.lower)}if(typeof b.upper=="string"||typeof b.upper=="number"){a.setAttribute("upper",b.upper)}this.addRenderer(a,b.renderer)},addValueMapLabelRenderer:function(j,h){j.setAttribute("lookupfield",h.lookupfield);j.setAttribute("labelfield",h.labelfield);if(typeof h.exacts=="object"){for(var a=0,l=h.exacts.length;a<l;a++){var f=h.exacts[a];var d=this.createElementNS("","EXACT");if(typeof f.value=="string"){d.setAttribute("value",f.value)}if(typeof f.label=="string"){d.setAttribute("label",f.label)}if(typeof f.method=="string"){d.setAttribute("method",f.method)}j.appendChild(d);if(typeof f.symbol=="object"){var b=null;if(f.symbol.type=="text"){b=this.createElementNS("","TEXTSYMBOL")}if(b!=null){var m=this.fontStyleKeys;for(var c=0,g=m.length;c<g;c++){var k=m[c];if(f.symbol[k]){b.setAttribute(k,f.symbol[k])}}d.appendChild(b)}}}}},addValueMapRenderer:function(l,k){l.setAttribute("lookupfield",k.lookupfield);if(typeof k.ranges=="object"){for(var a=0,b=k.ranges.length;a<b;a++){var h=k.ranges[a];var f=this.createElementNS("","RANGE");f.setAttribute("lower",h.lower);f.setAttribute("upper",h.upper);l.appendChild(f);if(typeof h.symbol=="object"){var d=null;if(h.symbol.type=="simplepolygon"){d=this.createElementNS("","SIMPLEPOLYGONSYMBOL")}if(d!=null){if(typeof h.symbol.boundarycolor=="string"){d.setAttribute("boundarycolor",h.symbol.boundarycolor)}if(typeof h.symbol.fillcolor=="string"){d.setAttribute("fillcolor",h.symbol.fillcolor)}if(typeof h.symbol.filltransparency=="number"){d.setAttribute("filltransparency",h.symbol.filltransparency)}f.appendChild(d)}}}}else{if(typeof k.exacts=="object"){for(var c=0,m=k.exacts.length;c<m;c++){var j=k.exacts[c];var g=this.createElementNS("","EXACT");if(typeof j.value=="string"){g.setAttribute("value",j.value)}if(typeof j.label=="string"){g.setAttribute("label",j.label)}if(typeof j.method=="string"){g.setAttribute("method",j.method)}l.appendChild(g);if(typeof j.symbol=="object"){var d=null;if(j.symbol.type=="simplemarker"){d=this.createElementNS("","SIMPLEMARKERSYMBOL")}if(d!=null){if(typeof j.symbol.antialiasing=="string"){d.setAttribute("antialiasing",j.symbol.antialiasing)}if(typeof j.symbol.color=="string"){d.setAttribute("color",j.symbol.color)}if(typeof j.symbol.outline=="string"){d.setAttribute("outline",j.symbol.outline)}if(typeof j.symbol.overlap=="string"){d.setAttribute("overlap",j.symbol.overlap)}if(typeof j.symbol.shadow=="string"){d.setAttribute("shadow",j.symbol.shadow)}if(typeof j.symbol.transparency=="number"){d.setAttribute("transparency",j.symbol.transparency)}if(typeof j.symbol.usecentroid=="string"){d.setAttribute("usecentroid",j.symbol.usecentroid)}if(typeof j.symbol.width=="number"){d.setAttribute("width",j.symbol.width)}g.appendChild(d)}}}}}},addSimpleLabelRenderer:function(g,j){g.setAttribute("field",j.field);var f=["featureweight","howmanylabels","labelbufferratio","labelpriorities","labelweight","linelabelposition","rotationalangles"];for(var d=0,a=f.length;d<a;d++){var c=f[d];if(j[c]){g.setAttribute(c,j[c])}}if(j.symbol.type=="text"){var h=j.symbol;var b=this.createElementNS("","TEXTSYMBOL");g.appendChild(b);var f=this.fontStyleKeys;for(var d=0,a=f.length;d<a;d++){var c=f[d];if(h[c]){b.setAttribute(c,j[c])}}}},writePolygonGeometry:function(h){if(!(h instanceof OpenLayers.Geometry.Polygon)){throw {message:"Cannot write polygon geometry to ArcXML with an "+h.CLASS_NAME+" object.",geometry:h}}var b=this.createElementNS("","POLYGON");for(var f=0,c=h.components.length;f<c;f++){var a=h.components[f];var k=this.createElementNS("","RING");for(var d=0,l=a.components.length;d<l;d++){var j=a.components[d];var g=this.createElementNS("","POINT");g.setAttribute("x",j.x);g.setAttribute("y",j.y);k.appendChild(g)}b.appendChild(k)}return b},parseResponse:function(F){if(typeof F=="string"){var r=new OpenLayers.Format.XML();F=r.read(F)}var a=new OpenLayers.Format.ArcXML.Response();var G=F.getElementsByTagName("ERROR");if(G!=null&&G.length>0){a.error=this.getChildValue(G,"Unknown error.")}else{var v=F.getElementsByTagName("RESPONSE");if(v==null||v.length==0){a.error="No RESPONSE tag found in ArcXML response.";return a}var u=v[0].firstChild.nodeName;if(u=="#text"){u=v[0].firstChild.nextSibling.nodeName}if(u=="IMAGE"){var c=F.getElementsByTagName("ENVELOPE");var C=F.getElementsByTagName("OUTPUT");if(c==null||c.length==0){a.error="No ENVELOPE tag found in ArcXML response."}else{if(C==null||C.length==0){a.error="No OUTPUT tag found in ArcXML response."}else{var A=this.parseAttributes(c[0]);var B=this.parseAttributes(C[0]);if(typeof B.type=="string"){a.image={envelope:A,output:{type:B.type,data:this.getChildValue(C[0])}}}else{a.image={envelope:A,output:B}}}}}else{if(u=="FEATURES"){var k=v[0].getElementsByTagName("FEATURES");var t=k[0].getElementsByTagName("FEATURECOUNT");a.features.featurecount=t[0].getAttribute("count");if(a.features.featurecount>0){var d=k[0].getElementsByTagName("ENVELOPE");a.features.envelope=this.parseAttributes(d[0],typeof(0));var D=k[0].getElementsByTagName("FEATURE");for(var q=0;q<D.length;q++){var j=new OpenLayers.Feature.Vector();var w=D[q].getElementsByTagName("FIELD");for(var g=0;g<w.length;g++){var h=w[g].getAttribute("name");var m=w[g].getAttribute("value");j.attributes[h]=m}var z=D[q].getElementsByTagName("POLYGON");if(z.length>0){var l=z[0].getElementsByTagName("RING");var f=[];for(var s=0;s<l.length;s++){var E=[];E.push(this.parsePointGeometry(l[s]));var o=l[s].getElementsByTagName("HOLE");for(var b=0;b<o.length;b++){E.push(this.parsePointGeometry(o[b]))}o=null;f.push(new OpenLayers.Geometry.Polygon(E));E=null}l=null;if(f.length==1){j.geometry=f[0]}else{j.geometry=new OpenLayers.Geometry.MultiPolygon(f)}}a.features.feature.push(j)}}}else{a.error="Unidentified response type."}}}return a},parseAttributes:function(d,c){var b={};for(var a=0;a<d.attributes.length;a++){if(c=="number"){b[d.attributes[a].nodeName]=parseFloat(d.attributes[a].nodeValue)}else{b[d.attributes[a].nodeName]=d.attributes[a].nodeValue}}return b},parsePointGeometry:function(d){var b=[];var f=d.getElementsByTagName("COORDS");if(f.length>0){var g=this.getChildValue(f[0]);g=g.split(/;/);for(var j=0;j<g.length;j++){var h=g[j].split(/ /);b.push(new OpenLayers.Geometry.Point(parseFloat(h[0]),parseFloat(h[1])))}f=null}else{var a=d.getElementsByTagName("POINT");if(a.length>0){for(var c=0;c<a.length;c++){b.push(new OpenLayers.Geometry.Point(parseFloat(a[c].getAttribute("x")),parseFloat(a[c].getAttribute("y"))))}}a=null}return new OpenLayers.Geometry.LinearRing(b)},CLASS_NAME:"OpenLayers.Format.ArcXML"});OpenLayers.Format.ArcXML.Request=OpenLayers.Class({initialize:function(b){var a={get_image:{properties:{background:null,draw:true,envelope:{minx:0,miny:0,maxx:0,maxy:0},featurecoordsys:{id:0,string:"",datumtransformid:0,datumtransformstring:""},filtercoordsys:{id:0,string:"",datumtransformid:0,datumtransformstring:""},imagesize:{height:0,width:0,dpi:96,printheight:0,printwidth:0,scalesymbols:false},layerlist:[],output:{baseurl:"",legendbaseurl:"",legendname:"",legendpath:"",legendurl:"",name:"",path:"",type:"jpg",url:""}}},get_feature:{layer:"",query:{isspatial:false,featurecoordsys:{id:0,string:"",datumtransformid:0,datumtransformstring:""},filtercoordsys:{id:0,string:"",datumtransformid:0,datumtransformstring:""},buffer:0,where:"",spatialfilter:{relation:"envelope_intersection",envelope:null}}},environment:{separators:{cs:" ",ts:";"}},layer:[],workspaces:[]};return OpenLayers.Util.extend(this,a)},CLASS_NAME:"OpenLayers.Format.ArcXML.Request"});OpenLayers.Format.ArcXML.Response=OpenLayers.Class({initialize:function(b){var a={image:{envelope:null,output:""},features:{featurecount:0,envelope:null,feature:[]},error:""};return OpenLayers.Util.extend(this,a)},CLASS_NAME:"OpenLayers.Format.ArcXML.Response"});OpenLayers.Format.GML=OpenLayers.Class(OpenLayers.Format.XML,{featureNS:"http://mapserver.gis.umn.edu/mapserver",featurePrefix:"feature",featureName:"featureMember",layerName:"features",geometryName:"geometry",collectionName:"FeatureCollection",gmlns:"http://www.opengis.net/gml",extractAttributes:true,xy:true,initialize:function(a){this.regExes={trimSpace:(/^\s*|\s*$/g),removeSpace:(/\s*/g),splitSpace:(/\s+/),trimComma:(/\s*,\s*/g)};OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},read:function(d){if(typeof d=="string"){d=OpenLayers.Format.XML.prototype.read.apply(this,[d])}var f=this.getElementsByTagNameNS(d.documentElement,this.gmlns,this.featureName);var c=[];for(var b=0;b<f.length;b++){var a=this.parseFeature(f[b]);if(a){c.push(a)}}return c},parseFeature:function(c){var d=["MultiPolygon","Polygon","MultiLineString","LineString","MultiPoint","Point","Envelope","Box"];var k,g,l,b;for(var j=0;j<d.length;++j){k=d[j];g=this.getElementsByTagNameNS(c,this.gmlns,k);if(g.length>0){var b=this.parseGeometry[k.toLowerCase()];if(b){l=b.apply(this,[g[0]]);if(this.internalProjection&&this.externalProjection){l.transform(this.externalProjection,this.internalProjection)}}else{OpenLayers.Console.error(OpenLayers.i18n("unsupportedGeometryType",{geomType:k}))}break}}var h;if(this.extractAttributes){h=this.parseAttributes(c)}var m=new OpenLayers.Feature.Vector(l,h);m.gml={featureType:c.firstChild.nodeName.split(":")[1],featureNS:c.firstChild.namespaceURI,featureNSPrefix:c.firstChild.prefix};var a=c.firstChild;var f;while(a){if(a.nodeType==1){f=a.getAttribute("fid")||a.getAttribute("id");if(f){break}}a=a.nextSibling}m.fid=f;return m},parseGeometry:{point:function(d){var b,a;var f=[];var b=this.getElementsByTagNameNS(d,this.gmlns,"pos");if(b.length>0){a=b[0].firstChild.nodeValue;a=a.replace(this.regExes.trimSpace,"");f=a.split(this.regExes.splitSpace)}if(f.length==0){b=this.getElementsByTagNameNS(d,this.gmlns,"coordinates");if(b.length>0){a=b[0].firstChild.nodeValue;a=a.replace(this.regExes.removeSpace,"");f=a.split(",")}}if(f.length==0){b=this.getElementsByTagNameNS(d,this.gmlns,"coord");if(b.length>0){var g=this.getElementsByTagNameNS(b[0],this.gmlns,"X");var c=this.getElementsByTagNameNS(b[0],this.gmlns,"Y");if(g.length>0&&c.length>0){f=[g[0].firstChild.nodeValue,c[0].firstChild.nodeValue]}}}if(f.length==2){f[2]=null}if(this.xy){return new OpenLayers.Geometry.Point(f[0],f[1],f[2])}else{return new OpenLayers.Geometry.Point(f[1],f[0],f[2])}},multipoint:function(f){var b=this.getElementsByTagNameNS(f,this.gmlns,"Point");var d=[];if(b.length>0){var a;for(var c=0;c<b.length;++c){a=this.parseGeometry.point.apply(this,[b[c]]);if(a){d.push(a)}}}return new OpenLayers.Geometry.MultiPoint(d)},linestring:function(c,f){var d,b;var q=[];var r=[];d=this.getElementsByTagNameNS(c,this.gmlns,"posList");if(d.length>0){b=this.getChildValue(d[0]);b=b.replace(this.regExes.trimSpace,"");q=b.split(this.regExes.splitSpace);var k=parseInt(d[0].getAttribute("dimension"));var g,o,m,l;for(var h=0;h<q.length/k;++h){g=h*k;o=q[g];m=q[g+1];l=(k==2)?null:q[g+2];if(this.xy){r.push(new OpenLayers.Geometry.Point(o,m,l))}else{r.push(new OpenLayers.Geometry.Point(m,o,l))}}}if(q.length==0){d=this.getElementsByTagNameNS(c,this.gmlns,"coordinates");if(d.length>0){b=this.getChildValue(d[0]);b=b.replace(this.regExes.trimSpace,"");b=b.replace(this.regExes.trimComma,",");var a=b.split(this.regExes.splitSpace);for(var h=0;h<a.length;++h){q=a[h].split(",");if(q.length==2){q[2]=null}if(this.xy){r.push(new OpenLayers.Geometry.Point(q[0],q[1],q[2]))}else{r.push(new OpenLayers.Geometry.Point(q[1],q[0],q[2]))}}}}var s=null;if(r.length!=0){if(f){s=new OpenLayers.Geometry.LinearRing(r)}else{s=new OpenLayers.Geometry.LineString(r)}}return s},multilinestring:function(f){var b=this.getElementsByTagNameNS(f,this.gmlns,"LineString");var d=[];if(b.length>0){var a;for(var c=0;c<b.length;++c){a=this.parseGeometry.linestring.apply(this,[b[c]]);if(a){d.push(a)}}}return new OpenLayers.Geometry.MultiLineString(d)},polygon:function(f){var b=this.getElementsByTagNameNS(f,this.gmlns,"LinearRing");var d=[];if(b.length>0){var a;for(var c=0;c<b.length;++c){a=this.parseGeometry.linestring.apply(this,[b[c],true]);if(a){d.push(a)}}}return new OpenLayers.Geometry.Polygon(d)},multipolygon:function(f){var a=this.getElementsByTagNameNS(f,this.gmlns,"Polygon");var d=[];if(a.length>0){var c;for(var b=0;b<a.length;++b){c=this.parseGeometry.polygon.apply(this,[a[b]]);if(c){d.push(c)}}}return new OpenLayers.Geometry.MultiPolygon(d)},envelope:function(b){var f=[];var a;var g;var l=this.getElementsByTagNameNS(b,this.gmlns,"lowerCorner");if(l.length>0){var j=[];if(l.length>0){a=l[0].firstChild.nodeValue;a=a.replace(this.regExes.trimSpace,"");j=a.split(this.regExes.splitSpace)}if(j.length==2){j[2]=null}if(this.xy){var d=new OpenLayers.Geometry.Point(j[0],j[1],j[2])}else{var d=new OpenLayers.Geometry.Point(j[1],j[0],j[2])}}var h=this.getElementsByTagNameNS(b,this.gmlns,"upperCorner");if(h.length>0){var j=[];if(h.length>0){a=h[0].firstChild.nodeValue;a=a.replace(this.regExes.trimSpace,"");j=a.split(this.regExes.splitSpace)}if(j.length==2){j[2]=null}if(this.xy){var k=new OpenLayers.Geometry.Point(j[0],j[1],j[2])}else{var k=new OpenLayers.Geometry.Point(j[1],j[0],j[2])}}if(d&&k){f.push(new OpenLayers.Geometry.Point(d.x,d.y));f.push(new OpenLayers.Geometry.Point(k.x,d.y));f.push(new OpenLayers.Geometry.Point(k.x,k.y));f.push(new OpenLayers.Geometry.Point(d.x,k.y));f.push(new OpenLayers.Geometry.Point(d.x,d.y));var c=new OpenLayers.Geometry.LinearRing(f);g=new OpenLayers.Geometry.Polygon([c])}return g}},parseAttributes:function(f){var g={};var a=f.firstChild;var d,h,c,l,k,b,j;while(a){if(a.nodeType==1){d=a.childNodes;for(h=0;h<d.length;++h){c=d[h];if(c.nodeType==1){l=c.childNodes;if(l.length==1){k=l[0];if(k.nodeType==3||k.nodeType==4){b=(c.prefix)?c.nodeName.split(":")[1]:c.nodeName;j=k.nodeValue.replace(this.regExes.trimSpace,"");g[b]=j}}else{g[c.nodeName.split(":").pop()]=null}}}break}a=a.nextSibling}return g},write:function(c){if(!(c instanceof Array)){c=[c]}var b=this.createElementNS("http://www.opengis.net/wfs","wfs:"+this.collectionName);for(var a=0;a<c.length;a++){b.appendChild(this.createFeatureXML(c[a]))}return OpenLayers.Format.XML.prototype.write.apply(this,[b])},createFeatureXML:function(l){var j=l.geometry;var f=this.buildGeometryNode(j);var k=this.createElementNS(this.featureNS,this.featurePrefix+":"+this.geometryName);k.appendChild(f);var a=this.createElementNS(this.gmlns,"gml:"+this.featureName);var m=this.createElementNS(this.featureNS,this.featurePrefix+":"+this.layerName);var c=l.fid||l.id;m.setAttribute("fid",c);m.appendChild(k);for(var h in l.attributes){var g=this.createTextNode(l.attributes[h]);var d=h.substring(h.lastIndexOf(":")+1);var b=this.createElementNS(this.featureNS,this.featurePrefix+":"+d);b.appendChild(g);m.appendChild(b)}a.appendChild(m);return a},buildGeometryNode:function(d){if(this.externalProjection&&this.internalProjection){d=d.clone();d.transform(this.internalProjection,this.externalProjection)}var c=d.CLASS_NAME;var b=c.substring(c.lastIndexOf(".")+1);var a=this.buildGeometry[b.toLowerCase()];return a.apply(this,[d])},buildGeometry:{point:function(b){var a=this.createElementNS(this.gmlns,"gml:Point");a.appendChild(this.buildCoordinatesNode(b));return a},multipoint:function(g){var d=this.createElementNS(this.gmlns,"gml:MultiPoint");var c=g.components;var b,f;for(var a=0;a<c.length;a++){b=this.createElementNS(this.gmlns,"gml:pointMember");f=this.buildGeometry.point.apply(this,[c[a]]);b.appendChild(f);d.appendChild(b)}return d},linestring:function(b){var a=this.createElementNS(this.gmlns,"gml:LineString");a.appendChild(this.buildCoordinatesNode(b));return a},multilinestring:function(g){var d=this.createElementNS(this.gmlns,"gml:MultiLineString");var a=g.components;var c,f;for(var b=0;b<a.length;++b){c=this.createElementNS(this.gmlns,"gml:lineStringMember");f=this.buildGeometry.linestring.apply(this,[a[b]]);c.appendChild(f);d.appendChild(c)}return d},linearring:function(b){var a=this.createElementNS(this.gmlns,"gml:LinearRing");a.appendChild(this.buildCoordinatesNode(b));return a},polygon:function(h){var d=this.createElementNS(this.gmlns,"gml:Polygon");var g=h.components;var c,f,b;for(var a=0;a<g.length;++a){b=(a==0)?"outerBoundaryIs":"innerBoundaryIs";c=this.createElementNS(this.gmlns,"gml:"+b);f=this.buildGeometry.linearring.apply(this,[g[a]]);c.appendChild(f);d.appendChild(c)}return d},multipolygon:function(g){var d=this.createElementNS(this.gmlns,"gml:MultiPolygon");var a=g.components;var f,b;for(var c=0;c<a.length;++c){f=this.createElementNS(this.gmlns,"gml:polygonMember");b=this.buildGeometry.polygon.apply(this,[a[c]]);f.appendChild(b);d.appendChild(f)}return d},bounds:function(b){var a=this.createElementNS(this.gmlns,"gml:Box");a.appendChild(this.buildCoordinatesNode(b));return a}},buildCoordinatesNode:function(g){var a=this.createElementNS(this.gmlns,"gml:coordinates");a.setAttribute("decimal",".");a.setAttribute("cs",",");a.setAttribute("ts"," ");var f=[];if(g instanceof OpenLayers.Bounds){f.push(g.left+","+g.bottom);f.push(g.right+","+g.top)}else{var c=(g.components)?g.components:[g];for(var b=0;b<c.length;b++){f.push(c[b].x+","+c[b].y)}}var d=this.createTextNode(f.join(" "));a.appendChild(d);return a},CLASS_NAME:"OpenLayers.Format.GML"});OpenLayers.Format.GeoJSON=OpenLayers.Class(OpenLayers.Format.JSON,{initialize:function(a){OpenLayers.Format.JSON.prototype.initialize.apply(this,[a])},read:function(k,h,a){h=(h)?h:"FeatureCollection";var d=null;var c=null;if(typeof k=="string"){c=OpenLayers.Format.JSON.prototype.read.apply(this,[k,a])}else{c=k}if(!c){OpenLayers.Console.error("Bad JSON: "+k)}else{if(typeof(c.type)!="string"){OpenLayers.Console.error("Bad GeoJSON - no type: "+k)}else{if(this.isValidType(c,h)){switch(h){case"Geometry":try{d=this.parseGeometry(c)}catch(b){OpenLayers.Console.error(b)}break;case"Feature":try{d=this.parseFeature(c);d.type="Feature"}catch(b){OpenLayers.Console.error(b)}break;case"FeatureCollection":d=[];switch(c.type){case"Feature":try{d.push(this.parseFeature(c))}catch(b){d=null;OpenLayers.Console.error(b)}break;case"FeatureCollection":for(var f=0,g=c.features.length;f<g;++f){try{d.push(this.parseFeature(c.features[f]))}catch(b){d=null;OpenLayers.Console.error(b)}}break;default:try{var j=this.parseGeometry(c);d.push(new OpenLayers.Feature.Vector(j))}catch(b){d=null;OpenLayers.Console.error(b)}}break}}}}return d},isValidType:function(c,a){var b=false;switch(a){case"Geometry":if(OpenLayers.Util.indexOf(["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon","Box","GeometryCollection"],c.type)==-1){OpenLayers.Console.error("Unsupported geometry type: "+c.type)}else{b=true}break;case"FeatureCollection":b=true;break;default:if(c.type==a){b=true}else{OpenLayers.Console.error("Cannot convert types from "+c.type+" to "+a)}}return b},parseFeature:function(d){var b,g,a,f;a=(d.properties)?d.properties:{};f=(d.geometry&&d.geometry.bbox)||d.bbox;try{g=this.parseGeometry(d.geometry)}catch(c){throw c}b=new OpenLayers.Feature.Vector(g,a);if(f){b.bounds=OpenLayers.Bounds.fromArray(f)}if(d.id){b.fid=d.id}return b},parseGeometry:function(f){if(f==null){return null}var h,g=false;if(f.type=="GeometryCollection"){if(!(f.geometries instanceof Array)){throw"GeometryCollection must have geometries array: "+f}var b=f.geometries.length;var d=new Array(b);for(var a=0;a<b;++a){d[a]=this.parseGeometry.apply(this,[f.geometries[a]])}h=new OpenLayers.Geometry.Collection(d);g=true}else{if(!(f.coordinates instanceof Array)){throw"Geometry must have coordinates array: "+f}if(!this.parseCoords[f.type.toLowerCase()]){throw"Unsupported geometry type: "+f.type}try{h=this.parseCoords[f.type.toLowerCase()].apply(this,[f.coordinates])}catch(c){throw c}}if(this.internalProjection&&this.externalProjection&&!g){h.transform(this.externalProjection,this.internalProjection)}return h},parseCoords:{point:function(a){if(a.length!=2){throw"Only 2D points are supported: "+a}return new OpenLayers.Geometry.Point(a[0],a[1])},multipoint:function(g){var c=[];var f=null;for(var b=0,a=g.length;b<a;++b){try{f=this.parseCoords.point.apply(this,[g[b]])}catch(d){throw d}c.push(f)}return new OpenLayers.Geometry.MultiPoint(c)},linestring:function(g){var c=[];var f=null;for(var b=0,a=g.length;b<a;++b){try{f=this.parseCoords.point.apply(this,[g[b]])}catch(d){throw d}c.push(f)}return new OpenLayers.Geometry.LineString(c)},multilinestring:function(g){var c=[];var b=null;for(var d=0,a=g.length;d<a;++d){try{b=this.parseCoords.linestring.apply(this,[g[d]])}catch(f){throw f}c.push(b)}return new OpenLayers.Geometry.MultiLineString(c)},polygon:function(h){var g=[];var f,b;for(var c=0,a=h.length;c<a;++c){try{b=this.parseCoords.linestring.apply(this,[h[c]])}catch(d){throw d}f=new OpenLayers.Geometry.LinearRing(b.components);g.push(f)}return new OpenLayers.Geometry.Polygon(g)},multipolygon:function(g){var b=[];var f=null;for(var c=0,a=g.length;c<a;++c){try{f=this.parseCoords.polygon.apply(this,[g[c]])}catch(d){throw d}b.push(f)}return new OpenLayers.Geometry.MultiPolygon(b)},box:function(a){if(a.length!=2){throw"GeoJSON box coordinates must have 2 elements"}return new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(a[0][0],a[0][1]),new OpenLayers.Geometry.Point(a[1][0],a[0][1]),new OpenLayers.Geometry.Point(a[1][0],a[1][1]),new OpenLayers.Geometry.Point(a[0][0],a[1][1]),new OpenLayers.Geometry.Point(a[0][0],a[0][1])])])}},write:function(f,d){var a={type:null};if(f instanceof Array){a.type="FeatureCollection";var h=f.length;a.features=new Array(h);for(var c=0;c<h;++c){var b=f[c];if(!b instanceof OpenLayers.Feature.Vector){var g="FeatureCollection only supports collections of features: "+b;throw g}a.features[c]=this.extract.feature.apply(this,[b])}}else{if(f.CLASS_NAME.indexOf("OpenLayers.Geometry")==0){a=this.extract.geometry.apply(this,[f])}else{if(f instanceof OpenLayers.Feature.Vector){a=this.extract.feature.apply(this,[f]);if(f.layer&&f.layer.projection){a.crs=this.createCRSObject(f)}}}}return OpenLayers.Format.JSON.prototype.write.apply(this,[a,d])},createCRSObject:function(b){var c=b.layer.projection.toString();var a={};if(c.match(/epsg:/i)){var d=parseInt(c.substring(c.indexOf(":")+1));if(d==4326){a={type:"OGC",properties:{urn:"urn:ogc:def:crs:OGC:1.3:CRS84"}}}else{a={type:"EPSG",properties:{code:d}}}}return a},extract:{feature:function(b){var a=this.extract.geometry.apply(this,[b.geometry]);return{type:"Feature",id:b.fid==null?b.id:b.fid,properties:b.attributes,geometry:a}},geometry:function(d){if(d==null){return null}if(this.internalProjection&&this.externalProjection){d=d.clone();d.transform(this.internalProjection,this.externalProjection)}var a=d.CLASS_NAME.split(".")[2];var c=this.extract[a.toLowerCase()].apply(this,[d]);var b;if(a=="Collection"){b={type:"GeometryCollection",geometries:c}}else{b={type:a,coordinates:c}}return b},point:function(a){return[a.x,a.y]},multipoint:function(c){var d=[];for(var b=0,a=c.components.length;b<a;++b){d.push(this.extract.point.apply(this,[c.components[b]]))}return d},linestring:function(b){var d=[];for(var c=0,a=b.components.length;c<a;++c){d.push(this.extract.point.apply(this,[b.components[c]]))}return d},multilinestring:function(c){var d=[];for(var b=0,a=c.components.length;b<a;++b){d.push(this.extract.linestring.apply(this,[c.components[b]]))}return d},polygon:function(c){var d=[];for(var b=0,a=c.components.length;b<a;++b){d.push(this.extract.linestring.apply(this,[c.components[b]]))}return d},multipolygon:function(d){var c=[];for(var b=0,a=d.components.length;b<a;++b){c.push(this.extract.polygon.apply(this,[d.components[b]]))}return c},collection:function(c){var a=c.components.length;var d=new Array(a);for(var b=0;b<a;++b){d[b]=this.extract.geometry.apply(this,[c.components[b]])}return d}},CLASS_NAME:"OpenLayers.Format.GeoJSON"});OpenLayers.Format.ArcXML.Features=OpenLayers.Class(OpenLayers.Format.XML,{initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a])},read:function(c){var b=new OpenLayers.Format.ArcXML();var a=b.read(c);return a.features.feature}});if(!OpenLayers.Format.GML){OpenLayers.Format.GML={}}OpenLayers.Format.GML.Base=OpenLayers.Class(OpenLayers.Format.XML,{namespaces:{gml:"http://www.opengis.net/gml",xlink:"http://www.w3.org/1999/xlink",xsi:"http://www.w3.org/2001/XMLSchema-instance",wfs:"http://www.opengis.net/wfs"},defaultPrefix:"gml",schemaLocation:null,featureType:null,featureNS:null,geometryName:"geometry",extractAttributes:true,srsName:null,xy:true,geometryTypes:null,singleFeatureType:null,regExes:{trimSpace:(/^\s*|\s*$/g),removeSpace:(/\s*/g),splitSpace:(/\s+/),trimComma:(/\s*,\s*/g)},initialize:function(a){OpenLayers.Format.XML.prototype.initialize.apply(this,[a]);this.setGeometryTypes();if(a&&a.featureNS){this.setNamespace("feature",a.featureNS)}this.singleFeatureType=!a||(typeof a.featureType==="string")},read:function(f){if(typeof f=="string"){f=OpenLayers.Format.XML.prototype.read.apply(this,[f])}if(f&&f.nodeType==9){f=f.documentElement}var c=[];this.readNode(f,{features:c});if(c.length==0){var d=this.getElementsByTagNameNS(f,this.namespaces.gml,"featureMember");if(d.length){for(var b=0,a=d.length;b<a;++b){this.readNode(d[b],{features:c})}}else{var d=this.getElementsByTagNameNS(f,this.namespaces.gml,"featureMembers");if(d.length){this.readNode(d[0],{features:c})}}}return c},readers:{gml:{featureMember:function(a,b){this.readChildNodes(a,b)},featureMembers:function(a,b){this.readChildNodes(a,b)},name:function(a,b){b.name=this.getChildValue(a)},boundedBy:function(b,c){var a={};this.readChildNodes(b,a);if(a.components&&a.components.length>0){c.bounds=a.components[0]}},Point:function(b,a){var c={points:[]};this.readChildNodes(b,c);if(!a.components){a.components=[]}a.components.push(c.points[0])},coordinates:function(f,h){var j=this.getChildValue(f).replace(this.regExes.trimSpace,"");j=j.replace(this.regExes.trimComma,",");var a=j.split(this.regExes.splitSpace);var g;var d=a.length;var c=new Array(d);for(var b=0;b<d;++b){g=a[b].split(",");if(this.xy){c[b]=new OpenLayers.Geometry.Point(g[0],g[1],g[2])}else{c[b]=new OpenLayers.Geometry.Point(g[1],g[0],g[2])}}h.points=c},coord:function(a,b){var c={};this.readChildNodes(a,c);if(!b.points){b.points=[]}b.points.push(new OpenLayers.Geometry.Point(c.x,c.y,c.z))},X:function(a,b){b.x=this.getChildValue(a)},Y:function(a,b){b.y=this.getChildValue(a)},Z:function(a,b){b.z=this.getChildValue(a)},MultiPoint:function(b,a){var c={components:[]};this.readChildNodes(b,c);a.components=[new OpenLayers.Geometry.MultiPoint(c.components)]},pointMember:function(a,b){this.readChildNodes(a,b)},LineString:function(b,a){var c={};this.readChildNodes(b,c);if(!a.components){a.components=[]}a.components.push(new OpenLayers.Geometry.LineString(c.points))},MultiLineString:function(b,a){var c={components:[]};this.readChildNodes(b,c);a.components=[new OpenLayers.Geometry.MultiLineString(c.components)]},lineStringMember:function(a,b){this.readChildNodes(a,b)},Polygon:function(b,a){var c={outer:null,inner:[]};this.readChildNodes(b,c);c.inner.unshift(c.outer);if(!a.components){a.components=[]}a.components.push(new OpenLayers.Geometry.Polygon(c.inner))},LinearRing:function(b,c){var a={};this.readChildNodes(b,a);c.components=[new OpenLayers.Geometry.LinearRing(a.points)]},MultiPolygon:function(b,a){var c={components:[]};this.readChildNodes(b,c);a.components=[new OpenLayers.Geometry.MultiPolygon(c.components)]},polygonMember:function(a,b){this.readChildNodes(a,b)},GeometryCollection:function(b,a){var c={components:[]};this.readChildNodes(b,c);a.components=[new OpenLayers.Geometry.Collection(c.components)]},geometryMember:function(a,b){this.readChildNodes(a,b)}},feature:{"*":function(c,d){var a;var b=c.localName||c.nodeName.split(":").pop();if(!this.singleFeatureType&&(OpenLayers.Util.indexOf(this.featureType,b)!=-1)){a="_typeName"}else{if(b==this.featureType){a="_typeName"}else{if(c.childNodes.length==0||(c.childNodes.length==1&&c.firstChild.nodeType==3)){if(this.extractAttributes){a="_attribute"}}else{a="_geometry"}}}if(a){this.readers.feature[a].apply(this,[c,d])}},_typeName:function(c,d){var a={components:[],attributes:{}};this.readChildNodes(c,a);if(a.name){a.attributes.name=a.name}var b=new OpenLayers.Feature.Vector(a.components[0],a.attributes);if(!this.singleFeatureType){b.type=c.nodeName.split(":").pop();b.namespace=c.namespaceURI}var f=c.getAttribute("fid")||this.getAttributeNS(c,this.namespaces.gml,"id");if(f){b.fid=f}if(this.internalProjection&&this.externalProjection&&b.geometry){b.geometry.transform(this.externalProjection,this.internalProjection)}if(a.bounds){b.geometry.bounds=a.bounds}d.features.push(b)},_geometry:function(a,b){this.readChildNodes(a,b)},_attribute:function(b,d){var a=b.localName||b.nodeName.split(":").pop();var c=this.getChildValue(b);d.attributes[a]=c}},wfs:{FeatureCollection:function(a,b){this.readChildNodes(a,b)}}},write:function(c){var b;if(c instanceof Array){b="featureMembers"}else{b="featureMember"}var a=this.writeNode("gml:"+b,c);this.setAttributeNS(a,this.namespaces.xsi,"xsi:schemaLocation",this.schemaLocation);return OpenLayers.Format.XML.prototype.write.apply(this,[a])},writers:{gml:{featureMember:function(a){var b=this.createElementNSPlus("gml:featureMember");this.writeNode("feature:_typeName",a,b);return b},MultiPoint:function(c){var b=this.createElementNSPlus("gml:MultiPoint");for(var a=0;a<c.components.length;++a){this.writeNode("pointMember",c.components[a],b)}return b},pointMember:function(b){var a=this.createElementNSPlus("gml:pointMember");this.writeNode("Point",b,a);return a},MultiLineString:function(c){var b=this.createElementNSPlus("gml:MultiLineString");for(var a=0;a<c.components.length;++a){this.writeNode("lineStringMember",c.components[a],b)}return b},lineStringMember:function(b){var a=this.createElementNSPlus("gml:lineStringMember");this.writeNode("LineString",b,a);return a},MultiPolygon:function(c){var b=this.createElementNSPlus("gml:MultiPolygon");for(var a=0;a<c.components.length;++a){this.writeNode("polygonMember",c.components[a],b)}return b},polygonMember:function(b){var a=this.createElementNSPlus("gml:polygonMember");this.writeNode("Polygon",b,a);return a},GeometryCollection:function(d){var c=this.createElementNSPlus("gml:GeometryCollection");for(var b=0,a=d.components.length;b<a;++b){this.writeNode("geometryMember",d.components[b],c)}return c},geometryMember:function(b){var a=this.createElementNSPlus("gml:geometryMember");var c=this.writeNode("feature:_geometry",b);a.appendChild(c.firstChild);return a}},feature:{_typeName:function(b){var c=this.createElementNSPlus("feature:"+this.featureType,{attributes:{fid:b.fid}});if(b.geometry){this.writeNode("feature:_geometry",b.geometry,c)}for(var a in b.attributes){var d=b.attributes[a];if(d!=null){this.writeNode("feature:_attribute",{name:a,value:d},c)}}return c},_geometry:function(c){if(this.externalProjection&&this.internalProjection){c=c.clone().transform(this.internalProjection,this.externalProjection)}var b=this.createElementNSPlus("feature:"+this.geometryName);var a=this.geometryTypes[c.CLASS_NAME];var d=this.writeNode("gml:"+a,c,b);if(this.srsName){d.setAttribute("srsName",this.srsName)}return b},_attribute:function(a){return this.createElementNSPlus("feature:"+a.name,{value:a.value})}},wfs:{FeatureCollection:function(c){var d=this.createElementNSPlus("wfs:FeatureCollection");for(var b=0,a=c.length;b<a;++b){this.writeNode("gml:featureMember",c[b],d)}return d}}},setGeometryTypes:function(){this.geometryTypes={"OpenLayers.Geometry.Point":"Point","OpenLayers.Geometry.MultiPoint":"MultiPoint","OpenLayers.Geometry.LineString":"LineString","OpenLayers.Geometry.MultiLineString":"MultiLineString","OpenLayers.Geometry.Polygon":"Polygon","OpenLayers.Geometry.MultiPolygon":"MultiPolygon","OpenLayers.Geometry.Collection":"GeometryCollection"}},CLASS_NAME:"OpenLayers.Format.GML.Base"});OpenLayers.Format.WFS=OpenLayers.Class(OpenLayers.Format.GML,{layer:null,wfsns:"http://www.opengis.net/wfs",ogcns:"http://www.opengis.net/ogc",initialize:function(a,b){OpenLayers.Format.GML.prototype.initialize.apply(this,[a]);this.layer=b;if(this.layer.featureNS){this.featureNS=this.layer.featureNS}if(this.layer.options.geometry_column){this.geometryName=this.layer.options.geometry_column}if(this.layer.options.typename){this.featureName=this.layer.options.typename}},write:function(b){var c=this.createElementNS(this.wfsns,"wfs:Transaction");c.setAttribute("version","1.0.0");c.setAttribute("service","WFS");for(var a=0;a<b.length;a++){switch(b[a].state){case OpenLayers.State.INSERT:c.appendChild(this.insert(b[a]));break;case OpenLayers.State.UPDATE:c.appendChild(this.update(b[a]));break;case OpenLayers.State.DELETE:c.appendChild(this.remove(b[a]));break}}return OpenLayers.Format.XML.prototype.write.apply(this,[c])},createFeatureXML:function(g){var c=this.buildGeometryNode(g.geometry);var h=this.createElementNS(this.featureNS,"feature:"+this.geometryName);h.appendChild(c);var b=this.createElementNS(this.featureNS,"feature:"+this.featureName);b.appendChild(h);for(var a in g.attributes){var j=this.createTextNode(g.attributes[a]);var d=a;if(a.search(":")!=-1){d=a.split(":")[1]}var f=this.createElementNS(this.featureNS,"feature:"+d);f.appendChild(j);b.appendChild(f)}return b},insert:function(b){var a=this.createElementNS(this.wfsns,"wfs:Insert");a.appendChild(this.createFeatureXML(b));return a},update:function(l){if(!l.fid){OpenLayers.Console.userError(OpenLayers.i18n("noFID"))}var g=this.createElementNS(this.wfsns,"wfs:Update");g.setAttribute("typeName",this.featurePrefix+":"+this.featureName);g.setAttribute("xmlns:"+this.featurePrefix,this.featureNS);var j=this.createElementNS(this.wfsns,"wfs:Property");var a=this.createElementNS(this.wfsns,"wfs:Name");var c=this.createTextNode(this.geometryName);a.appendChild(c);j.appendChild(a);var k=this.createElementNS(this.wfsns,"wfs:Value");var d=this.buildGeometryNode(l.geometry);if(l.layer){d.setAttribute("srsName",l.layer.projection.getCode())}k.appendChild(d);j.appendChild(k);g.appendChild(j);for(var f in l.attributes){j=this.createElementNS(this.wfsns,"wfs:Property");a=this.createElementNS(this.wfsns,"wfs:Name");a.appendChild(this.createTextNode(f));j.appendChild(a);k=this.createElementNS(this.wfsns,"wfs:Value");k.appendChild(this.createTextNode(l.attributes[f]));j.appendChild(k);g.appendChild(j)}var h=this.createElementNS(this.ogcns,"ogc:Filter");var b=this.createElementNS(this.ogcns,"ogc:FeatureId");b.setAttribute("fid",l.fid);h.appendChild(b);g.appendChild(h);return g},remove:function(b){if(!b.fid){OpenLayers.Console.userError(OpenLayers.i18n("noFID"));return false}var a=this.createElementNS(this.wfsns,"wfs:Delete");a.setAttribute("typeName",this.featurePrefix+":"+this.featureName);a.setAttribute("xmlns:"+this.featurePrefix,this.featureNS);var c=this.createElementNS(this.ogcns,"ogc:Filter");var d=this.createElementNS(this.ogcns,"ogc:FeatureId");d.setAttribute("fid",b.fid);c.appendChild(d);a.appendChild(c);return a},destroy:function(){this.layer=null},CLASS_NAME:"OpenLayers.Format.WFS"});OpenLayers.Layer.ArcIMS=OpenLayers.Class(OpenLayers.Layer.Grid,{DEFAULT_PARAMS:{ClientVersion:"9.2",ServiceName:""},tileSize:null,featureCoordSys:"4326",filterCoordSys:"4326",layers:null,async:true,name:"ArcIMS",isBaseLayer:true,DEFAULT_OPTIONS:{tileSize:new OpenLayers.Size(512,512),featureCoordSys:"4326",filterCoordSys:"4326",layers:null,isBaseLayer:true,async:true,name:"ArcIMS"},initialize:function(c,b,a){this.tileSize=new OpenLayers.Size(512,512);this.params=OpenLayers.Util.applyDefaults({ServiceName:a.serviceName},this.DEFAULT_PARAMS);this.options=OpenLayers.Util.applyDefaults(a,this.DEFAULT_OPTIONS);OpenLayers.Layer.Grid.prototype.initialize.apply(this,[c,b,this.params,a]);if(this.transparent){if(!this.isBaseLayer){this.isBaseLayer=false}if(this.format=="image/jpeg"){this.format=OpenLayers.Util.alphaHack()?"image/gif":"image/png"}}if(this.options.layers===null){this.options.layers=[]}},destroy:function(){OpenLayers.Layer.Grid.prototype.destroy.apply(this,arguments)},getURL:function(d){var a="";d=this.adjustBounds(d);var c=new OpenLayers.Format.ArcXML(OpenLayers.Util.extend(this.options,{requesttype:"image",envelope:d.toArray(),tileSize:this.tileSize}));var b=new OpenLayers.Request.POST({url:this.getFullRequestString(),data:c.write(),async:false});if(b!=null){var g=b.responseXML;if(!g||!g.documentElement){g=b.responseText}var f=new OpenLayers.Format.ArcXML();var h=f.read(g);a=this.getUrlOrImage(h.image.output)}return a},getURLasync:function(c,a,f,d){c=this.adjustBounds(c);var b=new OpenLayers.Format.ArcXML(OpenLayers.Util.extend(this.options,{requesttype:"image",envelope:c.toArray(),tileSize:this.tileSize}));OpenLayers.Request.POST({url:this.getFullRequestString(),async:true,data:b.write(),callback:function(g){var j=g.responseXML;if(!j||!j.documentElement){j=g.responseText}var h=new OpenLayers.Format.ArcXML();var k=h.read(j);a[f]=this.getUrlOrImage(k.image.output);d.apply(a)},scope:this})},getUrlOrImage:function(a){var b="";if(a.url){b=a.url}else{if(a.data){b="data:image/"+a.type+";base64,"+a.data}}return b},setLayerQuery:function(c,a){for(var b=0;b<this.options.layers.length;b++){if(c==this.options.layers[b].id){this.options.layers[b].query=a;return}}this.options.layers.push({id:c,visible:true,query:a})},getFeatureInfo:function(j,g,m){var b=m.buffer||1;var k=m.callback||function(){};var l=m.scope||window;var a={};OpenLayers.Util.extend(a,this.options);a.requesttype="feature";if(j instanceof OpenLayers.LonLat){a.polygon=null;a.envelope=[j.lon-b,j.lat-b,j.lon+b,j.lat+b]}else{if(j instanceof OpenLayers.Geometry.Polygon){a.envelope=null;a.polygon=j}}var f=new OpenLayers.Format.ArcXML(a);OpenLayers.Util.extend(f.request.get_feature,m);f.request.get_feature.layer=g.id;if(typeof g.query.accuracy=="number"){f.request.get_feature.query.accuracy=g.query.accuracy}else{var h=this.map.getCenter();var d=this.map.getViewPortPxFromLonLat(h);d.x++;var c=this.map.getLonLatFromPixel(d);f.request.get_feature.query.accuracy=c.lon-h.lon}f.request.get_feature.query.where=g.query.where;f.request.get_feature.query.spatialfilter.relation="area_intersection";OpenLayers.Request.POST({url:this.getFullRequestString({CustomService:"Query"}),data:f.write(),callback:function(q){var o=f.parseResponse(q.responseText);if(!f.iserror()){k.call(l,o.features)}else{k.call(l,null)}}})},addTile:function(b,a){return new OpenLayers.Tile.Image(this,a,b,null,this.tileSize)},CLASS_NAME:"OpenLayers.Layer.ArcIMS"});OpenLayers.Format.GML.v2=OpenLayers.Class(OpenLayers.Format.GML.Base,{schemaLocation:"http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd",initialize:function(a){OpenLayers.Format.GML.Base.prototype.initialize.apply(this,[a])},readers:{gml:OpenLayers.Util.applyDefaults({outerBoundaryIs:function(b,a){var c={};this.readChildNodes(b,c);a.outer=c.components[0]},innerBoundaryIs:function(b,a){var c={};this.readChildNodes(b,c);a.inner.push(c.components[0])},Box:function(d,b){var f={};this.readChildNodes(d,f);if(!b.components){b.components=[]}var c=f.points[0];var a=f.points[1];b.components.push(new OpenLayers.Bounds(c.x,c.y,a.x,a.y))}},OpenLayers.Format.GML.Base.prototype.readers.gml),feature:OpenLayers.Format.GML.Base.prototype.readers.feature,wfs:OpenLayers.Format.GML.Base.prototype.readers.wfs},write:function(c){var b;if(c instanceof Array){b="wfs:FeatureCollection"}else{b="gml:featureMember"}var a=this.writeNode(b,c);this.setAttributeNS(a,this.namespaces.xsi,"xsi:schemaLocation",this.schemaLocation);return OpenLayers.Format.XML.prototype.write.apply(this,[a])},writers:{gml:OpenLayers.Util.applyDefaults({Point:function(b){var a=this.createElementNSPlus("gml:Point");this.writeNode("coordinates",[b],a);return a},coordinates:function(d){var c=d.length;var f=new Array(c);var a;for(var b=0;b<c;++b){a=d[b];if(this.xy){f[b]=a.x+","+a.y}else{f[b]=a.y+","+a.x}if(a.z!=undefined){f[b]+=","+a.z}}return this.createElementNSPlus("gml:coordinates",{attributes:{decimal:".",cs:",",ts:" "},value:(c==1)?f[0]:f.join(" ")})},LineString:function(b){var a=this.createElementNSPlus("gml:LineString");this.writeNode("coordinates",b.components,a);return a},Polygon:function(c){var b=this.createElementNSPlus("gml:Polygon");this.writeNode("outerBoundaryIs",c.components[0],b);for(var a=1;a<c.components.length;++a){this.writeNode("innerBoundaryIs",c.components[a],b)}return b},outerBoundaryIs:function(a){var b=this.createElementNSPlus("gml:outerBoundaryIs");this.writeNode("LinearRing",a,b);return b},innerBoundaryIs:function(a){var b=this.createElementNSPlus("gml:innerBoundaryIs");this.writeNode("LinearRing",a,b);return b},LinearRing:function(a){var b=this.createElementNSPlus("gml:LinearRing");this.writeNode("coordinates",a.components,b);return b},Box:function(b){var a=this.createElementNSPlus("gml:Box");this.writeNode("coordinates",[{x:b.left,y:b.bottom},{x:b.right,y:b.top}],a);if(this.srsName){a.setAttribute("srsName",this.srsName)}return a}},OpenLayers.Format.GML.Base.prototype.writers.gml),feature:OpenLayers.Format.GML.Base.prototype.writers.feature,wfs:OpenLayers.Format.GML.Base.prototype.writers.wfs},CLASS_NAME:"OpenLayers.Format.GML.v2"});OpenLayers.Format.GML.v3=OpenLayers.Class(OpenLayers.Format.GML.Base,{schemaLocation:"http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd",curve:false,multiCurve:true,surface:false,multiSurface:true,initialize:function(a){OpenLayers.Format.GML.Base.prototype.initialize.apply(this,[a])},readers:{gml:OpenLayers.Util.applyDefaults({featureMembers:function(a,b){this.readChildNodes(a,b)},Curve:function(b,a){var c={points:[]};this.readChildNodes(b,c);if(!a.components){a.components=[]}a.components.push(new OpenLayers.Geometry.LineString(c.points))},segments:function(a,b){this.readChildNodes(a,b)},LineStringSegment:function(b,a){var c={};this.readChildNodes(b,c);if(c.points){Array.prototype.push.apply(a.points,c.points)}},pos:function(b,d){var f=this.getChildValue(b).replace(this.regExes.trimSpace,"");var c=f.split(this.regExes.splitSpace);var a;if(this.xy){a=new OpenLayers.Geometry.Point(c[0],c[1],c[2])}else{a=new OpenLayers.Geometry.Point(c[1],c[0],c[2])}d.points=[a]},posList:function(a,d){var k=this.getChildValue(a).replace(this.regExes.trimSpace,"");var o=k.split(this.regExes.splitSpace);var f=parseInt(a.getAttribute("dimension"))||2;var b,q,m,h;var l=o.length/f;var r=new Array(l);for(var c=0,g=o.length;c<g;c+=f){q=o[c];m=o[c+1];h=(f==2)?undefined:o[c+2];if(this.xy){r[c/f]=new OpenLayers.Geometry.Point(q,m,h)}else{r[c/f]=new OpenLayers.Geometry.Point(m,q,h)}}d.points=r},Surface:function(a,b){this.readChildNodes(a,b)},patches:function(a,b){this.readChildNodes(a,b)},PolygonPatch:function(a,b){this.readers.gml.Polygon.apply(this,[a,b])},exterior:function(b,a){var c={};this.readChildNodes(b,c);a.outer=c.components[0]},interior:function(b,a){var c={};this.readChildNodes(b,c);a.inner.push(c.components[0])},MultiCurve:function(b,a){var c={components:[]};this.readChildNodes(b,c);if(c.components.length>0){a.components=[new OpenLayers.Geometry.MultiLineString(c.components)]}},curveMember:function(a,b){this.readChildNodes(a,b)},MultiSurface:function(b,a){var c={components:[]};this.readChildNodes(b,c);if(c.components.length>0){a.components=[new OpenLayers.Geometry.MultiPolygon(c.components)]}},surfaceMember:function(a,b){this.readChildNodes(a,b)},surfaceMembers:function(a,b){this.readChildNodes(a,b)},pointMembers:function(a,b){this.readChildNodes(a,b)},lineStringMembers:function(a,b){this.readChildNodes(a,b)},polygonMembers:function(a,b){this.readChildNodes(a,b)},geometryMembers:function(a,b){this.readChildNodes(a,b)},Envelope:function(d,b){var f={points:new Array(2)};this.readChildNodes(d,f);if(!b.components){b.components=[]}var c=f.points[0];var a=f.points[1];b.components.push(new OpenLayers.Bounds(c.x,c.y,a.x,a.y))},lowerCorner:function(b,a){var c={};this.readers.gml.pos.apply(this,[b,c]);a.points[0]=c.points[0]},upperCorner:function(b,a){var c={};this.readers.gml.pos.apply(this,[b,c]);a.points[1]=c.points[0]}},OpenLayers.Format.GML.Base.prototype.readers.gml),feature:OpenLayers.Format.GML.Base.prototype.readers.feature,wfs:OpenLayers.Format.GML.Base.prototype.readers.wfs},write:function(c){var b;if(c instanceof Array){b="featureMembers"}else{b="featureMember"}var a=this.writeNode("gml:"+b,c);this.setAttributeNS(a,this.namespaces.xsi,"xsi:schemaLocation",this.schemaLocation);return OpenLayers.Format.XML.prototype.write.apply(this,[a])},writers:{gml:OpenLayers.Util.applyDefaults({featureMembers:function(c){var d=this.createElementNSPlus("gml:featureMembers");for(var b=0,a=c.length;b<a;++b){this.writeNode("feature:_typeName",c[b],d)}return d},Point:function(b){var a=this.createElementNSPlus("gml:Point");this.writeNode("pos",b,a);return a},pos:function(a){var b=(this.xy)?(a.x+" "+a.y):(a.y+" "+a.x);return this.createElementNSPlus("gml:pos",{value:b})},LineString:function(b){var a=this.createElementNSPlus("gml:LineString");this.writeNode("posList",b.components,a);return a},Curve:function(b){var a=this.createElementNSPlus("gml:Curve");this.writeNode("segments",b,a);return a},segments:function(b){var a=this.createElementNSPlus("gml:segments");this.writeNode("LineStringSegment",b,a);return a},LineStringSegment:function(b){var a=this.createElementNSPlus("gml:LineStringSegment");this.writeNode("posList",b.components,a);return a},posList:function(d){var b=d.length;var f=new Array(b);var a;for(var c=0;c<b;++c){a=d[c];if(this.xy){f[c]=a.x+" "+a.y}else{f[c]=a.y+" "+a.x}}return this.createElementNSPlus("gml:posList",{value:f.join(" ")})},Surface:function(b){var a=this.createElementNSPlus("gml:Surface");this.writeNode("patches",b,a);return a},patches:function(b){var a=this.createElementNSPlus("gml:patches");this.writeNode("PolygonPatch",b,a);return a},PolygonPatch:function(d){var c=this.createElementNSPlus("gml:PolygonPatch",{attributes:{interpolation:"planar"}});this.writeNode("exterior",d.components[0],c);for(var b=1,a=d.components.length;b<a;++b){this.writeNode("interior",d.components[b],c)}return c},Polygon:function(d){var c=this.createElementNSPlus("gml:Polygon");this.writeNode("exterior",d.components[0],c);for(var b=1,a=d.components.length;b<a;++b){this.writeNode("interior",d.components[b],c)}return c},exterior:function(a){var b=this.createElementNSPlus("gml:exterior");this.writeNode("LinearRing",a,b);return b},interior:function(a){var b=this.createElementNSPlus("gml:interior");this.writeNode("LinearRing",a,b);return b},LinearRing:function(a){var b=this.createElementNSPlus("gml:LinearRing");this.writeNode("posList",a.components,b);return b},MultiCurve:function(d){var c=this.createElementNSPlus("gml:MultiCurve");for(var b=0,a=d.components.length;b<a;++b){this.writeNode("curveMember",d.components[b],c)}return c},curveMember:function(b){var a=this.createElementNSPlus("gml:curveMember");if(this.curve){this.writeNode("Curve",b,a)}else{this.writeNode("LineString",b,a)}return a},MultiSurface:function(d){var c=this.createElementNSPlus("gml:MultiSurface");for(var b=0,a=d.components.length;b<a;++b){this.writeNode("surfaceMember",d.components[b],c)}return c},surfaceMember:function(a){var b=this.createElementNSPlus("gml:surfaceMember");if(this.surface){this.writeNode("Surface",a,b)}else{this.writeNode("Polygon",a,b)}return b},Envelope:function(b){var a=this.createElementNSPlus("gml:Envelope");this.writeNode("lowerCorner",b,a);this.writeNode("upperCorner",b,a);if(this.srsName){a.setAttribute("srsName",this.srsName)}return a},lowerCorner:function(a){var b=(this.xy)?(a.left+" "+a.bottom):(a.bottom+" "+a.left);return this.createElementNSPlus("gml:lowerCorner",{value:b})},upperCorner:function(a){var b=(this.xy)?(a.right+" "+a.top):(a.top+" "+a.right);return this.createElementNSPlus("gml:upperCorner",{value:b})}},OpenLayers.Format.GML.Base.prototype.writers.gml),feature:OpenLayers.Format.GML.Base.prototype.writers.feature,wfs:OpenLayers.Format.GML.Base.prototype.writers.wfs},setGeometryTypes:function(){this.geometryTypes={"OpenLayers.Geometry.Point":"Point","OpenLayers.Geometry.MultiPoint":"MultiPoint","OpenLayers.Geometry.LineString":(this.curve===true)?"Curve":"LineString","OpenLayers.Geometry.MultiLineString":(this.multiCurve===false)?"MultiLineString":"MultiCurve","OpenLayers.Geometry.Polygon":(this.surface===true)?"Surface":"Polygon","OpenLayers.Geometry.MultiPolygon":(this.multiSurface===false)?"MultiPolygon":"MultiSurface","OpenLayers.Geometry.Collection":"GeometryCollection"}},CLASS_NAME:"OpenLayers.Format.GML.v3"});OpenLayers.Format.Filter.v1_0_0=OpenLayers.Class(OpenLayers.Format.GML.v2,OpenLayers.Format.Filter.v1,{VERSION:"1.0.0",schemaLocation:"http://www.opengis.net/ogc/filter/1.0.0/filter.xsd",initialize:function(a){OpenLayers.Format.GML.v2.prototype.initialize.apply(this,[a])},readers:{ogc:OpenLayers.Util.applyDefaults({PropertyIsEqualTo:function(b,c){var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO});this.readChildNodes(b,a);c.filters.push(a)},PropertyIsNotEqualTo:function(b,c){var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.NOT_EQUAL_TO});this.readChildNodes(b,a);c.filters.push(a)}},OpenLayers.Format.Filter.v1.prototype.readers.ogc),gml:OpenLayers.Format.GML.v2.prototype.readers.gml,feature:OpenLayers.Format.GML.v2.prototype.readers.feature},writers:{ogc:OpenLayers.Util.applyDefaults({PropertyIsEqualTo:function(a){var b=this.createElementNSPlus("ogc:PropertyIsEqualTo");this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.value,b);return b},PropertyIsNotEqualTo:function(a){var b=this.createElementNSPlus("ogc:PropertyIsNotEqualTo");this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.value,b);return b},BBOX:function(a){var c=this.createElementNSPlus("ogc:BBOX");this.writeNode("PropertyName",a,c);var b=this.writeNode("gml:Box",a.value,c);if(a.projection){b.setAttribute("srsName",a.projection)}return c}},OpenLayers.Format.Filter.v1.prototype.writers.ogc),gml:OpenLayers.Format.GML.v2.prototype.writers.gml,feature:OpenLayers.Format.GML.v2.prototype.writers.feature},writeSpatial:function(b,a){var c=this.createElementNSPlus("ogc:"+a);this.writeNode("PropertyName",b,c);var d;if(b.value instanceof OpenLayers.Geometry){d=this.writeNode("feature:_geometry",b.value).firstChild}else{d=this.writeNode("gml:Box",b.value)}if(b.projection){d.setAttribute("srsName",b.projection)}c.appendChild(d);return c},CLASS_NAME:"OpenLayers.Format.Filter.v1_0_0"});OpenLayers.Format.Filter.v1_1_0=OpenLayers.Class(OpenLayers.Format.GML.v3,OpenLayers.Format.Filter.v1,{VERSION:"1.1.0",schemaLocation:"http://www.opengis.net/ogc/filter/1.1.0/filter.xsd",initialize:function(a){OpenLayers.Format.GML.v3.prototype.initialize.apply(this,[a])},readers:{ogc:OpenLayers.Util.applyDefaults({PropertyIsEqualTo:function(b,d){var c=b.getAttribute("matchCase");var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,matchCase:!(c==="false"||c==="0")});this.readChildNodes(b,a);d.filters.push(a)},PropertyIsNotEqualTo:function(b,d){var c=b.getAttribute("matchCase");var a=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.NOT_EQUAL_TO,matchCase:!(c==="false"||c==="0")});this.readChildNodes(b,a);d.filters.push(a)}},OpenLayers.Format.Filter.v1.prototype.readers.ogc),gml:OpenLayers.Format.GML.v3.prototype.readers.gml,feature:OpenLayers.Format.GML.v3.prototype.readers.feature},writers:{ogc:OpenLayers.Util.applyDefaults({PropertyIsEqualTo:function(a){var b=this.createElementNSPlus("ogc:PropertyIsEqualTo",{attributes:{matchCase:a.matchCase}});this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.value,b);return b},PropertyIsNotEqualTo:function(a){var b=this.createElementNSPlus("ogc:PropertyIsNotEqualTo",{attributes:{matchCase:a.matchCase}});this.writeNode("PropertyName",a,b);this.writeNode("Literal",a.value,b);return b},BBOX:function(a){var c=this.createElementNSPlus("ogc:BBOX");this.writeNode("PropertyName",a,c);var b=this.writeNode("gml:Envelope",a.value);if(a.projection){b.setAttribute("srsName",a.projection)}c.appendChild(b);return c}},OpenLayers.Format.Filter.v1.prototype.writers.ogc),gml:OpenLayers.Format.GML.v3.prototype.writers.gml,feature:OpenLayers.Format.GML.v3.prototype.writers.feature},writeSpatial:function(b,a){var c=this.createElementNSPlus("ogc:"+a);this.writeNode("PropertyName",b,c);var d;if(b.value instanceof OpenLayers.Geometry){d=this.writeNode("feature:_geometry",b.value).firstChild}else{d=this.writeNode("gml:Envelope",b.value)}if(b.projection){d.setAttribute("srsName",b.projection)}c.appendChild(d);return c},CLASS_NAME:"OpenLayers.Format.Filter.v1_1_0"});OpenLayers.Format.SLD.v1=OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0,{namespaces:{sld:"http://www.opengis.net/sld",ogc:"http://www.opengis.net/ogc",gml:"http://www.opengis.net/gml",xlink:"http://www.w3.org/1999/xlink",xsi:"http://www.w3.org/2001/XMLSchema-instance"},defaultPrefix:"sld",schemaLocation:null,defaultSymbolizer:{fillColor:"#808080",fillOpacity:1,strokeColor:"#000000",strokeOpacity:1,strokeWidth:1,strokeDashstyle:"solid",pointRadius:3,graphicName:"square"},initialize:function(a){OpenLayers.Format.Filter.v1_0_0.prototype.initialize.apply(this,[a])},read:function(c,a){a=OpenLayers.Util.applyDefaults(a,this.options);var b={namedLayers:a.namedLayersAsArray===true?[]:{}};this.readChildNodes(c,b);return b},readers:OpenLayers.Util.applyDefaults({sld:{StyledLayerDescriptor:function(a,b){b.version=a.getAttribute("version");this.readChildNodes(a,b)},Name:function(a,b){b.name=this.getChildValue(a)},Title:function(a,b){b.title=this.getChildValue(a)},Abstract:function(a,b){b.description=this.getChildValue(a)},NamedLayer:function(d,f){var c={userStyles:[],namedStyles:[]};this.readChildNodes(d,c);for(var b=0,a=c.userStyles.length;b<a;++b){c.userStyles[b].layerName=c.name}if(f.namedLayers instanceof Array){f.namedLayers.push(c)}else{f.namedLayers[c.name]=c}},NamedStyle:function(b,a){a.namedStyles.push(this.getChildName(b.firstChild))},UserStyle:function(c,a){var d={defaultsPerSymbolizer:true,rules:[]};this.readChildNodes(c,d);var b=new OpenLayers.Style(this.defaultSymbolizer,d);a.userStyles.push(b)},IsDefault:function(b,a){if(this.getChildValue(b)=="1"){a.isDefault=true}},FeatureTypeStyle:function(b,a){var c={rules:[]};this.readChildNodes(b,c);a.rules=c.rules},Rule:function(a,c){var b=new OpenLayers.Rule();this.readChildNodes(a,b);c.rules.push(b)},ElseFilter:function(a,b){b.elseFilter=true},MinScaleDenominator:function(a,b){b.minScaleDenominator=parseFloat(this.getChildValue(a))},MaxScaleDenominator:function(a,b){b.maxScaleDenominator=parseFloat(this.getChildValue(a))},TextSymbolizer:function(b,c){var a=c.symbolizer.Text||{};this.readChildNodes(b,a);c.symbolizer.Text=a},Label:function(b,a){var d={};this.readChildNodes(b,d);if(d.property){a.label="${"+d.property+"}"}else{var c=this.readOgcExpression(b);if(c){a.label=c}}},Font:function(b,a){this.readChildNodes(b,a)},Halo:function(b,a){var c={};this.readChildNodes(b,c);a.haloRadius=c.haloRadius;a.haloColor=c.fillColor;a.haloOpacity=c.fillOpacity},Radius:function(c,b){var a=this.readOgcExpression(c);if(a!=null){b.haloRadius=a}},LineSymbolizer:function(b,c){var a=c.symbolizer.Line||{};this.readChildNodes(b,a);c.symbolizer.Line=a},PolygonSymbolizer:function(b,c){var a=c.symbolizer.Polygon||{};this.readChildNodes(b,a);c.symbolizer.Polygon=a},PointSymbolizer:function(b,c){var a=c.symbolizer.Point||{};this.readChildNodes(b,a);c.symbolizer.Point=a},Stroke:function(b,a){a.stroke=true;this.readChildNodes(b,a)},Fill:function(b,a){a.fill=true;this.readChildNodes(b,a)},CssParameter:function(c,b){var a=c.getAttribute("name");var f=this.cssMap[a];if(f){var d=this.readOgcExpression(c);if(d){b[f]=d}}},Graphic:function(f,d){d.graphic=true;var j={};this.readChildNodes(f,j);var c=["strokeColor","strokeWidth","strokeOpacity","strokeLinecap","fillColor","fillOpacity","graphicName","rotation","graphicFormat"];var h,g;for(var b=0,a=c.length;b<a;++b){h=c[b];g=j[h];if(g!=undefined){d[h]=g}}if(j.opacity!=undefined){d.graphicOpacity=j.opacity}if(j.size!=undefined){d.pointRadius=j.size/2}if(j.href!=undefined){d.externalGraphic=j.href}if(j.rotation!=undefined){d.rotation=j.rotation}},ExternalGraphic:function(a,b){this.readChildNodes(a,b)},Mark:function(a,b){this.readChildNodes(a,b)},WellKnownName:function(a,b){b.graphicName=this.getChildValue(a)},Opacity:function(b,c){var a=this.readOgcExpression(b);if(a){c.opacity=a}},Size:function(b,c){var a=this.readOgcExpression(b);if(a){c.size=a}},Rotation:function(b,c){var a=this.readOgcExpression(b);if(a){c.rotation=a}},OnlineResource:function(a,b){b.href=this.getAttributeNS(a,this.namespaces.xlink,"href")},Format:function(a,b){b.graphicFormat=this.getChildValue(a)}}},OpenLayers.Format.Filter.v1_0_0.prototype.readers),cssMap:{stroke:"strokeColor","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-dasharray":"strokeDashstyle",fill:"fillColor","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","font-weight":"fontWeight","font-style":"fontStyle"},getCssProperty:function(a){var b=null;for(var c in this.cssMap){if(this.cssMap[c]==a){b=c;break}}return b},getGraphicFormat:function(a){var d,c;for(var b in this.graphicFormats){if(this.graphicFormats[b].test(a)){d=b;break}}return d||this.defautlGraphicFormat},defaultGraphicFormat:"image/png",graphicFormats:{"image/jpeg":/\.jpe?g$/i,"image/gif":/\.gif$/i,"image/png":/\.png$/i},write:function(a){return this.writers.sld.StyledLayerDescriptor.apply(this,[a])},writers:OpenLayers.Util.applyDefaults({sld:{StyledLayerDescriptor:function(f){var b=this.createElementNSPlus("StyledLayerDescriptor",{attributes:{version:this.VERSION,"xsi:schemaLocation":this.schemaLocation}});if(f.name){this.writeNode("Name",f.name,b)}if(f.title){this.writeNode("Title",f.title,b)}if(f.description){this.writeNode("Abstract",f.description,b)}if(f.namedLayers instanceof Array){for(var d=0,a=f.namedLayers.length;d<a;++d){this.writeNode("NamedLayer",f.namedLayers[d],b)}}else{for(var c in f.namedLayers){this.writeNode("NamedLayer",f.namedLayers[c],b)}}return b},Name:function(a){return this.createElementNSPlus("Name",{value:a})},Title:function(a){return this.createElementNSPlus("Title",{value:a})},Abstract:function(a){return this.createElementNSPlus("Abstract",{value:a})},NamedLayer:function(c){var d=this.createElementNSPlus("NamedLayer");this.writeNode("Name",c.name,d);if(c.namedStyles){for(var b=0,a=c.namedStyles.length;b<a;++b){this.writeNode("NamedStyle",c.namedStyles[b],d)}}if(c.userStyles){for(var b=0,a=c.userStyles.length;b<a;++b){this.writeNode("UserStyle",c.userStyles[b],d)}}return d},NamedStyle:function(a){var b=this.createElementNSPlus("NamedStyle");this.writeNode("Name",a,b);return b},UserStyle:function(a){var b=this.createElementNSPlus("UserStyle");if(a.name){this.writeNode("Name",a.name,b)}if(a.title){this.writeNode("Title",a.title,b)}if(a.description){this.writeNode("Abstract",a.description,b)}if(a.isDefault){this.writeNode("IsDefault",a.isDefault,b)}this.writeNode("FeatureTypeStyle",a,b);return b},IsDefault:function(a){return this.createElementNSPlus("IsDefault",{value:(a)?"1":"0"})},FeatureTypeStyle:function(c){var d=this.createElementNSPlus("FeatureTypeStyle");for(var b=0,a=c.rules.length;b<a;++b){this.writeNode("Rule",c.rules[b],d)}return d},Rule:function(h){var g=this.createElementNSPlus("Rule");if(h.name){this.writeNode("Name",h.name,g)}if(h.title){this.writeNode("Title",h.title,g)}if(h.description){this.writeNode("Abstract",h.description,g)}if(h.elseFilter){this.writeNode("ElseFilter",null,g)}else{if(h.filter){this.writeNode("ogc:Filter",h.filter,g)}}if(h.minScaleDenominator!=undefined){this.writeNode("MinScaleDenominator",h.minScaleDenominator,g)}if(h.maxScaleDenominator!=undefined){this.writeNode("MaxScaleDenominator",h.maxScaleDenominator,g)}var c=OpenLayers.Style.SYMBOLIZER_PREFIXES;var f,d;for(var b=0,a=c.length;b<a;++b){f=c[b];d=h.symbolizer[f];if(d){this.writeNode(f+"Symbolizer",d,g)}}return g},ElseFilter:function(){return this.createElementNSPlus("ElseFilter")},MinScaleDenominator:function(a){return this.createElementNSPlus("MinScaleDenominator",{value:a})},MaxScaleDenominator:function(a){return this.createElementNSPlus("MaxScaleDenominator",{value:a})},LineSymbolizer:function(a){var b=this.createElementNSPlus("LineSymbolizer");this.writeNode("Stroke",a,b);return b},Stroke:function(a){var b=this.createElementNSPlus("Stroke");if(a.strokeColor!=undefined){this.writeNode("CssParameter",{symbolizer:a,key:"strokeColor"},b)}if(a.strokeOpacity!=undefined){this.writeNode("CssParameter",{symbolizer:a,key:"strokeOpacity"},b)}if(a.strokeWidth!=undefined){this.writeNode("CssParameter",{symbolizer:a,key:"strokeWidth"},b)}return b},CssParameter:function(a){return this.createElementNSPlus("CssParameter",{attributes:{name:this.getCssProperty(a.key)},value:a.symbolizer[a.key]})},TextSymbolizer:function(a){var b=this.createElementNSPlus("TextSymbolizer");if(a.label!=null){this.writeNode("Label",a.label,b)}if(a.fontFamily!=null||a.fontSize!=null||a.fontWeight!=null||a.fontStyle!=null){this.writeNode("Font",a,b)}if(a.haloRadius!=null||a.haloColor!=null||a.haloOpacity!=null){this.writeNode("Halo",a,b)}if(a.fillColor!=null||a.fillOpacity!=null){this.writeNode("Fill",a,b)}return b},Font:function(a){var b=this.createElementNSPlus("Font");if(a.fontFamily){this.writeNode("CssParameter",{symbolizer:a,key:"fontFamily"},b)}if(a.fontSize){this.writeNode("CssParameter",{symbolizer:a,key:"fontSize"},b)}if(a.fontWeight){this.writeNode("CssParameter",{symbolizer:a,key:"fontWeight"},b)}if(a.fontStyle){this.writeNode("CssParameter",{symbolizer:a,key:"fontStyle"},b)}return b},Label:function(b){var g=this.createElementNSPlus("Label");var h=b.split("${");g.appendChild(this.createTextNode(h[0]));var f,d;for(var c=1,a=h.length;c<a;c++){f=h[c];d=f.indexOf("}");if(d>0){this.writeNode("ogc:PropertyName",{property:f.substring(0,d)},g);g.appendChild(this.createTextNode(f.substring(++d)))}else{g.appendChild(this.createTextNode("${"+f))}}return g},Halo:function(a){var b=this.createElementNSPlus("Halo");if(a.haloRadius){this.writeNode("Radius",a.haloRadius,b)}if(a.haloColor||a.haloOpacity){this.writeNode("Fill",{fillColor:a.haloColor,fillOpacity:a.haloOpacity},b)}return b},Radius:function(a){return node=this.createElementNSPlus("Radius",{value:a})},PolygonSymbolizer:function(a){var b=this.createElementNSPlus("PolygonSymbolizer");if(a.fillColor!=undefined||a.fillOpacity!=undefined){this.writeNode("Fill",a,b)}if(a.strokeWidth!=undefined||a.strokeColor!=undefined||a.strokeOpacity!=undefined||a.strokeDashstyle!=undefined){this.writeNode("Stroke",a,b)}return b},Fill:function(a){var b=this.createElementNSPlus("Fill");if(a.fillColor){this.writeNode("CssParameter",{symbolizer:a,key:"fillColor"},b)}if(a.fillOpacity!=null){this.writeNode("CssParameter",{symbolizer:a,key:"fillOpacity"},b)}return b},PointSymbolizer:function(a){var b=this.createElementNSPlus("PointSymbolizer");this.writeNode("Graphic",a,b);return b},Graphic:function(a){var b=this.createElementNSPlus("Graphic");if(a.externalGraphic!=undefined){this.writeNode("ExternalGraphic",a,b)}else{this.writeNode("Mark",a,b)}if(a.graphicOpacity!=undefined){this.writeNode("Opacity",a.graphicOpacity,b)}if(a.pointRadius!=undefined){this.writeNode("Size",a.pointRadius*2,b)}if(a.rotation!=undefined){this.writeNode("Rotation",a.rotation,b)}return b},ExternalGraphic:function(a){var b=this.createElementNSPlus("ExternalGraphic");this.writeNode("OnlineResource",a.externalGraphic,b);var c=a.graphicFormat||this.getGraphicFormat(a.externalGraphic);this.writeNode("Format",c,b);return b},Mark:function(a){var b=this.createElementNSPlus("Mark");if(a.graphicName){this.writeNode("WellKnownName",a.graphicName,b)}this.writeNode("Fill",a,b);this.writeNode("Stroke",a,b);return b},WellKnownName:function(a){return this.createElementNSPlus("WellKnownName",{value:a})},Opacity:function(a){return this.createElementNSPlus("Opacity",{value:a})},Size:function(a){return this.createElementNSPlus("Size",{value:a})},Rotation:function(a){return this.createElementNSPlus("Rotation",{value:a})},OnlineResource:function(a){return this.createElementNSPlus("OnlineResource",{attributes:{"xlink:type":"simple","xlink:href":a}})},Format:function(a){return this.createElementNSPlus("Format",{value:a})}}},OpenLayers.Format.Filter.v1_0_0.prototype.writers),CLASS_NAME:"OpenLayers.Format.SLD.v1"});OpenLayers.Format.WFST.v1_0_0=OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0,OpenLayers.Format.WFST.v1,{version:"1.0.0",schemaLocations:{wfs:"http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"},initialize:function(a){OpenLayers.Format.Filter.v1_0_0.prototype.initialize.apply(this,[a]);OpenLayers.Format.WFST.v1.prototype.initialize.apply(this,[a])},readers:{wfs:OpenLayers.Util.applyDefaults({WFS_TransactionResponse:function(a,b){b.insertIds=[];b.success=false;this.readChildNodes(a,b)},InsertResult:function(b,a){var c={fids:[]};this.readChildNodes(b,c);a.insertIds.push(c.fids[0])},TransactionResult:function(a,b){this.readChildNodes(a,b)},Status:function(a,b){this.readChildNodes(a,b)},SUCCESS:function(a,b){b.success=true}},OpenLayers.Format.WFST.v1.prototype.readers.wfs),gml:OpenLayers.Format.GML.v2.prototype.readers.gml,feature:OpenLayers.Format.GML.v2.prototype.readers.feature,ogc:OpenLayers.Format.Filter.v1_0_0.prototype.readers.ogc},writers:{wfs:OpenLayers.Util.applyDefaults({Query:function(b){b=OpenLayers.Util.extend({featureNS:this.featureNS,featurePrefix:this.featurePrefix,featureType:this.featureType,srsName:this.srsName},b);var d=this.createElementNSPlus("wfs:Query",{attributes:{typeName:(b.featureNS?b.featurePrefix+":":"")+b.featureType}});if(b.featureNS){d.setAttribute("xmlns:"+b.featurePrefix,b.featureNS)}if(b.propertyNames){for(var c=0,a=b.propertyNames.length;c<a;c++){this.writeNode("ogc:PropertyName",{property:b.propertyNames[c]},d)}}if(b.filter){this.setFilterProperty(b.filter);this.writeNode("ogc:Filter",b.filter,d)}return d}},OpenLayers.Format.WFST.v1.prototype.writers.wfs),gml:OpenLayers.Format.GML.v2.prototype.writers.gml,feature:OpenLayers.Format.GML.v2.prototype.writers.feature,ogc:OpenLayers.Format.Filter.v1_0_0.prototype.writers.ogc},CLASS_NAME:"OpenLayers.Format.WFST.v1_0_0"});OpenLayers.Format.WFST.v1_1_0=OpenLayers.Class(OpenLayers.Format.Filter.v1_1_0,OpenLayers.Format.WFST.v1,{version:"1.1.0",schemaLocations:{wfs:"http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"},initialize:function(a){OpenLayers.Format.Filter.v1_1_0.prototype.initialize.apply(this,[a]);OpenLayers.Format.WFST.v1.prototype.initialize.apply(this,[a])},readers:{wfs:OpenLayers.Util.applyDefaults({TransactionResponse:function(a,b){b.insertIds=[];b.success=false;this.readChildNodes(a,b)},TransactionSummary:function(a,b){b.success=true},InsertResults:function(a,b){this.readChildNodes(a,b)},Feature:function(b,a){var c={fids:[]};this.readChildNodes(b,c);a.insertIds.push(c.fids[0])}},OpenLayers.Format.WFST.v1.prototype.readers.wfs),gml:OpenLayers.Format.GML.v3.prototype.readers.gml,feature:OpenLayers.Format.GML.v3.prototype.readers.feature,ogc:OpenLayers.Format.Filter.v1_1_0.prototype.readers.ogc},writers:{wfs:OpenLayers.Util.applyDefaults({Query:function(b){b=OpenLayers.Util.extend({featureNS:this.featureNS,featurePrefix:this.featurePrefix,featureType:this.featureType,srsName:this.srsName},b);var d=this.createElementNSPlus("wfs:Query",{attributes:{typeName:(b.featureNS?b.featurePrefix+":":"")+b.featureType,srsName:b.srsName}});if(b.featureNS){d.setAttribute("xmlns:"+b.featurePrefix,b.featureNS)}if(b.propertyNames){for(var c=0,a=b.propertyNames.length;c<a;c++){this.writeNode("wfs:PropertyName",{property:b.propertyNames[c]},d)}}if(b.filter){this.setFilterProperty(b.filter);this.writeNode("ogc:Filter",b.filter,d)}return d},PropertyName:function(a){return this.createElementNSPlus("wfs:PropertyName",{value:a.property})}},OpenLayers.Format.WFST.v1.prototype.writers.wfs),gml:OpenLayers.Format.GML.v3.prototype.writers.gml,feature:OpenLayers.Format.GML.v3.prototype.writers.feature,ogc:OpenLayers.Format.Filter.v1_1_0.prototype.writers.ogc},CLASS_NAME:"OpenLayers.Format.WFST.v1_1_0"});OpenLayers.Format.SLD.v1_0_0=OpenLayers.Class(OpenLayers.Format.SLD.v1,{VERSION:"1.0.0",schemaLocation:"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd",initialize:function(a){OpenLayers.Format.SLD.v1.prototype.initialize.apply(this,[a])},CLASS_NAME:"OpenLayers.Format.SLD.v1_0_0"});OpenLayers.Protocol.WFS.v1_0_0=OpenLayers.Class(OpenLayers.Protocol.WFS.v1,{version:"1.0.0",CLASS_NAME:"OpenLayers.Protocol.WFS.v1_0_0"});OpenLayers.Protocol.WFS.v1_1_0=OpenLayers.Class(OpenLayers.Protocol.WFS.v1,{version:"1.1.0",CLASS_NAME:"OpenLayers.Protocol.WFS.v1_1_0"});var CryptoJS=CryptoJS||(function(f,h){var a={};var b=a.lib={};var l=b.Base=(function(){function r(){}return{extend:function(t){r.prototype=this;var s=new r();if(t){s.mixIn(t)}s.$super=this;return s},create:function(){var s=this.extend();s.init.apply(s,arguments);return s},init:function(){},mixIn:function(t){for(var s in t){if(t.hasOwnProperty(s)){this[s]=t[s]}}if(t.hasOwnProperty("toString")){this.toString=t.toString}},clone:function(){return this.$super.extend(this)}}}());var o=b.WordArray=l.extend({init:function(s,r){s=this.words=s||[];if(r!=h){this.sigBytes=r}else{this.sigBytes=s.length*4}},toString:function(r){return(r||j).stringify(this)},concat:function(z){var u=this.words;var t=z.words;var r=this.sigBytes;var w=z.sigBytes;this.clamp();if(r%4){for(var v=0;v<w;v++){var s=(t[v>>>2]>>>(24-(v%4)*8))&255;u[(r+v)>>>2]|=s<<(24-((r+v)%4)*8)}}else{if(t.length>65535){for(var v=0;v<w;v+=4){u[(r+v)>>>2]=t[v>>>2]}}else{u.push.apply(u,t)}}this.sigBytes+=w;return this},clamp:function(){var s=this.words;var r=this.sigBytes;s[r>>>2]&=4294967295<<(32-(r%4)*8);s.length=f.ceil(r/4)},clone:function(){var r=l.clone.call(this);r.words=this.words.slice(0);return r},random:function(t){var s=[];for(var r=0;r<t;r+=4){s.push((f.random()*4294967296)|0)}return o.create(s,t)}});var q=a.enc={};var j=q.Hex={stringify:function(t){var v=t.words;var s=t.sigBytes;var u=[];for(var r=0;r<s;r++){var w=(v[r>>>2]>>>(24-(r%4)*8))&255;u.push((w>>>4).toString(16));u.push((w&15).toString(16))}return u.join("")},parse:function(t){var r=t.length;var u=[];for(var s=0;s<r;s+=2){u[s>>>3]|=parseInt(t.substr(s,2),16)<<(24-(s%8)*4)}return o.create(u,r/2)}};var d=q.Latin1={stringify:function(u){var v=u.words;var t=u.sigBytes;var r=[];for(var s=0;s<t;s++){var w=(v[s>>>2]>>>(24-(s%4)*8))&255;r.push(String.fromCharCode(w))}return r.join("")},parse:function(t){var r=t.length;var u=[];for(var s=0;s<r;s++){u[s>>>2]|=(t.charCodeAt(s)&255)<<(24-(s%4)*8)}return o.create(u,r)}};var c=q.Utf8={stringify:function(r){try{return decodeURIComponent(escape(d.stringify(r)))}catch(s){throw new Error("Malformed UTF-8 data")}},parse:function(r){return d.parse(unescape(encodeURIComponent(r)))}};var k=b.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=o.create();this._nDataBytes=0},_append:function(r){if(typeof r=="string"){r=c.parse(r)}this._data.concat(r);this._nDataBytes+=r.sigBytes},_process:function(C){var u=this._data;var D=u.words;var r=u.sigBytes;var z=this.blockSize;var B=z*4;var A=r/B;if(C){A=f.ceil(A)}else{A=f.max((A|0)-this._minBufferSize,0)}var w=A*z;var v=f.min(w*4,r);if(w){for(var t=0;t<w;t+=z){this._doProcessBlock(D,t)}var s=D.splice(0,w);u.sigBytes-=v}return o.create(s,v)},clone:function(){var r=l.clone.call(this);r._data=this._data.clone();return r},_minBufferSize:0});var g=b.Hasher=k.extend({init:function(r){this.reset()},reset:function(){k.reset.call(this);this._doReset()},update:function(r){this._append(r);this._process();return this},finalize:function(r){if(r){this._append(r)}this._doFinalize();return this._hash},clone:function(){var r=k.clone.call(this);r._hash=this._hash.clone();return r},blockSize:512/32,_createHelper:function(r){return function(t,s){return r.create(s).finalize(t)}},_createHmacHelper:function(r){return function(t,s){return m.HMAC.create(r,s).finalize(t)}}});var m=a.algo={};return a}(Math));(function(){var h=CryptoJS;var d=h.lib;var g=d.WordArray;var b=d.Hasher;var f=h.algo;var a=[];var c=f.SHA1=b.extend({_doReset:function(){this._hash=g.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(o,k){var v=this._hash.words;var u=v[0];var s=v[1];var r=v[2];var q=v[3];var m=v[4];for(var l=0;l<80;l++){if(l<16){a[l]=o[k+l]|0}else{var j=a[l-3]^a[l-8]^a[l-14]^a[l-16];a[l]=(j<<1)|(j>>>31)}var w=((u<<5)|(u>>>27))+m+a[l];if(l<20){w+=((s&r)|(~s&q))+1518500249}else{if(l<40){w+=(s^r^q)+1859775393}else{if(l<60){w+=((s&r)|(s&q)|(r&q))-1894007588}else{w+=(s^r^q)-899497514}}}m=q;q=r;r=(s<<30)|(s>>>2);s=u;u=w}v[0]=(v[0]+u)|0;v[1]=(v[1]+s)|0;v[2]=(v[2]+r)|0;v[3]=(v[3]+q)|0;v[4]=(v[4]+m)|0},_doFinalize:function(){var l=this._data;var m=l.words;var j=this._nDataBytes*8;var k=l.sigBytes*8;m[k>>>5]|=128<<(24-k%32);m[(((k+64)>>>9)<<4)+15]=j;l.sigBytes=m.length*4;this._process()}});h.SHA1=b._createHelper(c);h.HmacSHA1=b._createHmacHelper(c)}());Ext.namespace("GeoExt.tree");GeoExt.tree.LayerContainer=Ext.extend(Ext.tree.AsyncTreeNode,{constructor:function(a){a=Ext.applyIf(a||{},{text:"Layers"});this.loader=a.loader instanceof GeoExt.tree.LayerLoader?a.loader:new GeoExt.tree.LayerLoader(Ext.applyIf(a.loader||{},{store:a.layerStore}));GeoExt.tree.LayerContainer.superclass.constructor.call(this,a)},recordIndexToNodeIndex:function(c){var b=this.loader.store;var f=b.getCount();var a=this.childNodes.length;var g=-1;for(var d=f-1;d>=0;--d){if(this.loader.filter(b.getAt(d))===true){++g;if(c===d||g>a-1){break}}}return g},destroy:function(){delete this.layerStore;GeoExt.tree.LayerContainer.superclass.destroy.apply(this,arguments)}});Ext.tree.TreePanel.nodeTypes.gx_layercontainer=GeoExt.tree.LayerContainer;Ext.namespace("GeoExt.tree");GeoExt.tree.BaseLayerContainer=Ext.extend(GeoExt.tree.LayerContainer,{constructor:function(a){a=Ext.applyIf(a||{},{text:"Base Layer",loader:{}});a.loader=Ext.applyIf(a.loader,{baseAttrs:Ext.applyIf(a.loader.baseAttrs||{},{iconCls:"gx-tree-baselayer-icon",checkedGroup:"baselayer"}),filter:function(b){var c=b.get("layer");return c.displayInLayerSwitcher===true&&c.isBaseLayer===true}});GeoExt.tree.BaseLayerContainer.superclass.constructor.call(this,a)}});Ext.tree.TreePanel.nodeTypes.gx_baselayercontainer=GeoExt.tree.BaseLayerContainer;Ext.namespace("GeoExt.tree");GeoExt.tree.LayerParamLoader=function(a){Ext.apply(this,a);this.addEvents("beforeload","load");GeoExt.tree.LayerLoader.superclass.constructor.call(this)};Ext.extend(GeoExt.tree.LayerParamLoader,Ext.util.Observable,{param:null,delimiter:",",load:function(b,d){if(this.fireEvent("beforeload",this,b)){while(b.firstChild){b.removeChild(b.firstChild)}var c=(b.layer instanceof OpenLayers.Layer.HTTPRequest)&&b.layer.params[this.param];if(c){var a=(c instanceof Array)?c:c.split(this.delimiter);Ext.each(a,function(f){this.addParamNode(f,b)},this)}if(typeof d=="function"){d()}this.fireEvent("load",this,b)}},addParamNode:function(a,c){var d=this.createNode({layer:c.layer,param:this.param,item:a,delimiter:this.delimiter});var b=c.item(0);if(b){c.insertBefore(d,b)}else{c.appendChild(d)}},createNode:function(attr){if(this.baseAttrs){Ext.apply(attr,this.baseAttrs)}if(typeof attr.uiProvider=="string"){attr.uiProvider=this.uiProviders[attr.uiProvider]||eval(attr.uiProvider)}attr.nodeType=attr.nodeType||"gx_layerparam";return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr)}});Ext.namespace("GeoExt");GeoExt.SliderTip=Ext.extend(Ext.Tip,{hover:true,minWidth:10,minWidth:10,offsets:[0,-10],dragging:false,init:function(a){a.on({dragstart:this.onSlide,drag:this.onSlide,dragend:this.hide,destroy:this.destroy,scope:this});if(this.hover){a.on("render",this.registerThumbListeners,this)}this.slider=a},registerThumbListeners:function(){this.slider.thumb.on({mouseover:function(){this.onSlide(this.slider);this.dragging=false},mouseout:function(){if(!this.dragging){this.hide.apply(this,arguments)}},scope:this})},onSlide:function(a){this.dragging=true;this.show();this.body.update(this.getText(a));this.doAutoWidth();this.el.alignTo(a.thumb,"b-t?",this.offsets)},getText:function(a){return a.getValue()}});Ext.namespace("GeoExt");GeoExt.ZoomSlider=Ext.extend(Ext.Slider,{map:null,baseCls:"gx-zoomslider",aggressive:false,updating:false,initComponent:function(){GeoExt.ZoomSlider.superclass.initComponent.call(this);if(this.map){if(this.map instanceof GeoExt.MapPanel){this.map=this.map.map}this.bind(this.map)}if(this.aggressive===true){this.on("change",this.changeHandler,this)}else{this.on("changecomplete",this.changeHandler,this)}this.on("beforedestroy",this.unbind,this)},onRender:function(){GeoExt.ZoomSlider.superclass.onRender.apply(this,arguments);this.el.addClass(this.baseCls)},afterRender:function(){Ext.Slider.superclass.afterRender.apply(this,arguments);this.update()},addToMapPanel:function(a){if(!this.events.afterrender){this.on({render:function(){window.setTimeout(this.bind.createDelegate(this,[a.map]),0)},scope:this})}this.on({render:function(){var b=this.getEl();b.setStyle({position:"absolute",zIndex:a.map.Z_INDEX_BASE.Control});b.on({mousedown:this.stopMouseEvents,click:this.stopMouseEvents})},afterrender:function(){this.bind(a.map)},scope:this})},stopMouseEvents:function(a){a.stopEvent()},removeFromMapPanel:function(a){var b=this.getEl();b.un("mousedown",this.stopMouseEvents,this);b.un("click",this.stopMouseEvents,this);this.unbind()},bind:function(a){this.map=a;this.map.events.on({zoomend:this.update,changebaselayer:this.initZoomValues,scope:this});if(this.map.baseLayer){this.initZoomValues();this.update()}},unbind:function(){if(this.map){this.map.events.un({zoomend:this.update,changebaselayer:this.initZoomValues,scope:this})}},initZoomValues:function(){var a=this.map.baseLayer;if(this.initialConfig.minValue===undefined){this.minValue=a.minZoomLevel||0}if(this.initialConfig.maxValue===undefined){this.maxValue=a.maxZoomLevel||a.numZoomLevels-1}},getZoom:function(){return this.getValue()},getScale:function(){return OpenLayers.Util.getScaleFromResolution(this.map.getResolutionForZoom(this.getValue()),this.map.getUnits())},getResolution:function(){return this.map.getResolutionForZoom(this.getValue())},changeHandler:function(){if(this.map&&!this.updating){this.map.zoomTo(this.getValue())}},update:function(){if(this.rendered&&this.map){this.updating=true;this.setValue(this.map.getZoom());this.updating=false}}});Ext.reg("gx_zoomslider",GeoExt.ZoomSlider);Ext.namespace("GeoExt.data");GeoExt.data.WMSCapabilitiesReader=function(a,b){a=a||{};if(!a.format){a.format=new OpenLayers.Format.WMSCapabilities()}if(typeof b!=="function"){b=GeoExt.data.LayerRecord.create(b||a.fields||[{name:"name",type:"string"},{name:"title",type:"string"},{name:"abstract",type:"string"},{name:"queryable",type:"boolean"},{name:"opaque",type:"boolean"},{name:"noSubsets",type:"boolean"},{name:"cascaded",type:"int"},{name:"fixedWidth",type:"int"},{name:"fixedHeight",type:"int"},{name:"minScale",type:"float"},{name:"maxScale",type:"float"},{name:"prefix",type:"string"},{name:"formats"},{name:"styles"},{name:"srs"},{name:"dimensions"},{name:"bbox"},{name:"llbbox"},{name:"attribution"},{name:"keywords"},{name:"identifiers"},{name:"authorityURLs"},{name:"metadataURLs"}])}GeoExt.data.WMSCapabilitiesReader.superclass.constructor.call(this,a,b)};Ext.extend(GeoExt.data.WMSCapabilitiesReader,Ext.data.DataReader,{attributionCls:"gx-attribution",read:function(a){var b=a.responseXML;if(!b||!b.documentElement){b=a.responseText}return this.readRecords(b)},serviceExceptionFormat:function(a){if(OpenLayers.Util.indexOf(a,"application/vnd.ogc.se_inimage")>-1){return"application/vnd.ogc.se_inimage"}if(OpenLayers.Util.indexOf(a,"application/vnd.ogc.se_xml")>-1){return"application/vnd.ogc.se_xml"}return a[0]},imageFormat:function(b){var a=b.formats;if(b.opaque&&OpenLayers.Util.indexOf(a,"image/jpeg")>-1){return"image/jpeg"}if(OpenLayers.Util.indexOf(a,"image/png")>-1){return"image/png"}if(OpenLayers.Util.indexOf(a,"image/png; mode=24bit")>-1){return"image/png; mode=24bit"}if(OpenLayers.Util.indexOf(a,"image/gif")>-1){return"image/gif"}return a[0]},imageTransparent:function(a){return a.opaque==undefined||!a.opaque},readRecords:function(z){if(typeof z==="string"||z.nodeType){z=this.meta.format.read(z)}var f=z.version;var c=z.capability||{};var g=c.request&&c.request.getmap&&c.request.getmap.href;var k=c.layers;var h=c.exception?c.exception.formats:[];var s=this.serviceExceptionFormat(h);var r=[];if(g&&k){var m=this.recordType.prototype.fields;var w,b,d,a,l;for(var q=0,u=k.length;q<u;q++){w=k[q];if(w.name){b={};for(var o=0,t=m.length;o<t;o++){a=m.items[o];l=w[a.mapping||a.name]||a.defaultValue;l=a.convert(l);b[a.name]=l}d={attribution:w.attribution?this.attributionMarkup(w.attribution):undefined,minScale:w.minScale,maxScale:w.maxScale};if(this.meta.layerOptions){Ext.apply(d,this.meta.layerOptions)}b.layer=new OpenLayers.Layer.WMS(w.title||w.name,g,{layers:w.name,exceptions:s,format:this.imageFormat(w),transparent:this.imageTransparent(w),version:f},d);r.push(new this.recordType(b,b.layer.id))}}}return{totalRecords:r.length,success:true,records:r}},attributionMarkup:function(a){var b=[];if(a.logo){b.push("<img class='"+this.attributionCls+"-image' src='"+a.logo.href+"' />")}if(a.title){b.push("<span class='"+this.attributionCls+"-title'>"+a.title+"</span>")}if(a.href){for(var c=0;c<b.length;c++){b[c]="<a class='"+this.attributionCls+"-link' href="+a.href+">"+b[c]+"</a>"}}return b.join(" ")}});Ext.namespace("GeoExt.data");GeoExt.data.LayerStoreMixin=function(){return{map:null,reader:null,constructor:function(b){b=b||{};b.reader=b.reader||new GeoExt.data.LayerReader({},b.fields);delete b.fields;var c=b.map instanceof GeoExt.MapPanel?b.map.map:b.map;delete b.map;if(b.layers){b.data=b.layers}delete b.layers;var a={initDir:b.initDir};delete b.initDir;arguments.callee.superclass.constructor.call(this,b);if(c){this.bind(c,a)}},bind:function(d,a){if(this.map){return}this.map=d;a=a||{};var b=a.initDir;if(a.initDir==undefined){b=GeoExt.data.LayerStore.MAP_TO_STORE|GeoExt.data.LayerStore.STORE_TO_MAP}var c=d.layers.slice(0);if(b&GeoExt.data.LayerStore.STORE_TO_MAP){this.each(function(f){this.map.addLayer(f.get("layer"))},this)}if(b&GeoExt.data.LayerStore.MAP_TO_STORE){this.loadData(c,true)}d.events.on({changelayer:this.onChangeLayer,addlayer:this.onAddLayer,removelayer:this.onRemoveLayer,scope:this});this.on({load:this.onLoad,clear:this.onClear,add:this.onAdd,remove:this.onRemove,update:this.onUpdate,scope:this});this.data.on({replace:this.onReplace,scope:this})},unbind:function(){if(this.map){this.map.events.un({changelayer:this.onChangeLayer,addlayer:this.onAddLayer,removelayer:this.onRemoveLayer,scope:this});this.un("load",this.onLoad,this);this.un("clear",this.onClear,this);this.un("add",this.onAdd,this);this.un("remove",this.onRemove,this);this.data.un("replace",this.onReplace,this);this.map=null}},onChangeLayer:function(b){var f=b.layer;var c=this.findBy(function(g,h){return g.get("layer")===f});if(c>-1){var a=this.getAt(c);if(b.property==="order"){if(!this._adding&&!this._removing){var d=this.map.getLayerIndex(f);if(d!==c){this._removing=true;this.remove(a);delete this._removing;this._adding=true;this.insert(d,[a]);delete this._adding}}}else{if(b.property==="name"){a.set("title",f.name)}else{this.fireEvent("update",this,a,Ext.data.Record.EDIT)}}}},onAddLayer:function(a){if(!this._adding){var b=a.layer;this._adding=true;this.loadData([b],true);delete this._adding}},onRemoveLayer:function(a){if(this.map.unloadDestroy){if(!this._removing){var b=a.layer;this._removing=true;this.remove(this.getById(b.id));delete this._removing}}else{this.unbind()}},onLoad:function(c,b,f){if(!Ext.isArray(b)){b=[b]}if(f&&!f.add){this._removing=true;for(var g=this.map.layers.length-1;g>=0;g--){this.map.removeLayer(this.map.layers[g])}delete this._removing;var a=b.length;if(a>0){var h=new Array(a);for(var d=0;d<a;d++){h[d]=b[d].get("layer")}this._adding=true;this.map.addLayers(h);delete this._adding}}},onClear:function(a){this._removing=true;for(var b=this.map.layers.length-1;b>=0;b--){this.map.removeLayer(this.map.layers[b])}delete this._removing},onAdd:function(b,a,c){if(!this._adding){this._adding=true;var f;for(var d=a.length-1;d>=0;--d){f=a[d].get("layer");this.map.addLayer(f);if(c!==this.map.layers.length-1){this.map.setLayerIndex(f,c)}}delete this._adding}},onRemove:function(b,a,c){if(!this._removing){var d=a.get("layer");if(this.map.getLayer(d.id)!=null){this._removing=true;this.removeMapLayer(a);delete this._removing}}},onUpdate:function(c,a,b){if(b===Ext.data.Record.EDIT){var d=a.get("layer");var f=a.get("title");if(f!==d.name){d.setName(f)}}},removeMapLayer:function(a){this.map.removeLayer(a.get("layer"))},onReplace:function(c,a,b){this.removeMapLayer(a)},destroy:function(){this.unbind();GeoExt.data.LayerStore.superclass.destroy.call(this)}}};GeoExt.data.LayerStore=Ext.extend(Ext.data.Store,new GeoExt.data.LayerStoreMixin);GeoExt.data.LayerStore.MAP_TO_STORE=1;GeoExt.data.LayerStore.STORE_TO_MAP=2;Ext.namespace("GeoExt.tree");GeoExt.tree.LayerLoader=function(a){Ext.apply(this,a);this.addEvents("beforeload","load");GeoExt.tree.LayerLoader.superclass.constructor.call(this)};Ext.extend(GeoExt.tree.LayerLoader,Ext.util.Observable,{store:null,filter:function(a){return a.get("layer").displayInLayerSwitcher==true},uiProviders:null,load:function(a,b){if(this.fireEvent("beforeload",this,a)){this.removeStoreHandlers();while(a.firstChild){a.removeChild(a.firstChild)}if(!this.uiProviders){this.uiProviders=a.getOwnerTree().getLoader().uiProviders}if(!this.store){this.store=GeoExt.MapPanel.guess().layers}this.store.each(function(c){this.addLayerNode(a,c)},this);this.addStoreHandlers(a);if(typeof b=="function"){b()}this.fireEvent("load",this,a)}},onStoreAdd:function(b,a,c,f){if(!this._reordering){var g=f.recordIndexToNodeIndex(c+a.length-1);for(var d=0;d<a.length;++d){this.addLayerNode(f,a[d],g)}}},onStoreRemove:function(b,a,c,d){if(!this._reordering){this.removeLayerNode(d,a)}},addLayerNode:function(d,a,b){b=b||0;if(this.filter(a)===true){var f=this.createNode({nodeType:"gx_layer",layer:a.get("layer"),layerStore:this.store});var c=d.item(b);if(c){d.insertBefore(f,c)}else{d.appendChild(f)}f.on("move",this.onChildMove,this)}},removeLayerNode:function(b,a){if(this.filter(a)===true){var c=b.findChildBy(function(d){return d.layer==a.get("layer")});if(c){c.un("move",this.onChildMove,this);c.remove();b.reload()}}},onChildMove:function(m,c,k,l,h){this._reordering=true;var b=this.store.findBy(function(o){return o.get("layer")===c.layer});var g=this.store.getAt(b);if(l instanceof GeoExt.tree.LayerContainer&&this.store===l.loader.store){l.loader._reordering=true;this.store.remove(g);var a;if(l.childNodes.length>1){var j=(h===0)?h+1:h-1;a=this.store.findBy(function(o){return l.childNodes[j].layer===o.get("layer")});h===0&&a++}else{if(k.parentNode===l.parentNode){var d=l;do{d=d.previousSibling}while(d&&!(d instanceof GeoExt.tree.LayerContainer&&d.lastChild));if(d){a=this.store.findBy(function(o){return d.lastChild.layer===o.get("layer")})}else{var f=l;do{f=f.nextSibling}while(f&&!(f instanceof GeoExt.tree.LayerContainer&&f.firstChild));if(f){a=this.store.findBy(function(o){return f.firstChild.layer===o.get("layer")})}a++}}}if(a!==undefined){this.store.insert(a,[g]);window.setTimeout(function(){l.reload();k.reload()})}else{this.store.insert(b,[g])}delete l.loader._reordering}delete this._reordering},addStoreHandlers:function(b){if(!this._storeHandlers){this._storeHandlers={add:this.onStoreAdd.createDelegate(this,[b],true),remove:this.onStoreRemove.createDelegate(this,[b],true)};for(var a in this._storeHandlers){this.store.on(a,this._storeHandlers[a],this)}}},removeStoreHandlers:function(){if(this._storeHandlers){for(var a in this._storeHandlers){this.store.un(a,this._storeHandlers[a],this)}delete this._storeHandlers}},createNode:function(attr){if(this.baseAttrs){Ext.apply(attr,this.baseAttrs)}if(typeof attr.uiProvider=="string"){attr.uiProvider=this.uiProviders[attr.uiProvider]||eval(attr.uiProvider)}attr.nodeType=attr.nodeType||"gx_layer";return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr)},destroy:function(){this.removeStoreHandlers()}});Ext.namespace("GeoExt.grid");GeoExt.grid.FeatureSelectionModelMixin=function(){return{autoActivateControl:true,layerFromStore:true,selectControl:null,bound:false,superclass:null,constructor:function(a){a=a||{};if(a.selectControl instanceof OpenLayers.Control.SelectFeature){if(!a.singleSelect){var b=a.selectControl;a.singleSelect=!(b.multiple||!!b.multipleKey)}}else{if(a.layer instanceof OpenLayers.Layer.Vector){this.selectControl=this.createSelectControl(a.layer,a.selectControl);delete a.layer;delete a.selectControl}}this.superclass=arguments.callee.superclass;this.superclass.constructor.call(this,a)},initEvents:function(){this.superclass.initEvents.call(this);if(this.layerFromStore){var a=this.grid.getStore()&&this.grid.getStore().layer;if(a&&!(this.selectControl instanceof OpenLayers.Control.SelectFeature)){this.selectControl=this.createSelectControl(a,this.selectControl)}}if(this.selectControl){this.bind(this.selectControl)}},createSelectControl:function(b,a){a=a||{};var d=a.singleSelect!==undefined?a.singleSelect:this.singleSelect;a=OpenLayers.Util.extend({toggle:true,multipleKey:d?null:(Ext.isMac?"metaKey":"ctrlKey")},a);var c=new OpenLayers.Control.SelectFeature(b,a);b.map.addControl(c);return c},bind:function(f,b){if(!this.bound){b=b||{};this.selectControl=f;if(f instanceof OpenLayers.Layer.Vector){this.selectControl=this.createSelectControl(f,b.controlConfig)}if(this.autoActivateControl){this.selectControl.activate()}var d=this.getLayers();for(var c=0,a=d.length;c<a;c++){d[c].events.on({featureselected:this.featureSelected,featureunselected:this.featureUnselected,scope:this})}this.on("rowselect",this.rowSelected,this);this.on("rowdeselect",this.rowDeselected,this);this.bound=true}return this.selectControl},unbind:function(){var c=this.selectControl;if(this.bound){var d=this.getLayers();for(var b=0,a=d.length;b<a;b++){d[b].events.un({featureselected:this.featureSelected,featureunselected:this.featureUnselected,scope:this})}this.un("rowselect",this.rowSelected,this);this.un("rowdeselect",this.rowDeselected,this);if(this.autoActivateControl){c.deactivate()}this.selectControl=null;this.bound=false}return c},featureSelected:function(a){if(!this._selecting){var b=this.grid.store;var c=b.findBy(function(d,f){return d.data.feature==a.feature});if(c!=-1&&!this.isSelected(c)){this._selecting=true;this.selectRow(c,!this.singleSelect);this._selecting=false;this.grid.getView().focusRow(c)}}},featureUnselected:function(a){if(!this._selecting){var b=this.grid.store;var c=b.findBy(function(d,f){return d.data.feature==a.feature});if(c!=-1&&this.isSelected(c)){this._selecting=true;this.deselectRow(c);this._selecting=false;this.grid.getView().focusRow(c)}}},rowSelected:function(c,h,b){var f=b.data.feature;if(!this._selecting&&f){var g=this.getLayers();for(var d=0,a=g.length;d<a;d++){if(g[d].selectedFeatures.indexOf(f)==-1){this._selecting=true;this.selectControl.select(f);this._selecting=false;break}}}},rowDeselected:function(c,h,b){var f=b.data.feature;if(!this._selecting&&f){var g=this.getLayers();for(var d=0,a=g.length;d<a;d++){if(g[d].selectedFeatures.indexOf(f)!=-1){this._selecting=true;this.selectControl.unselect(f);this._selecting=false;break}}}},getLayers:function(){return this.selectControl.layers||[this.selectControl.layer]}}};GeoExt.grid.FeatureSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,new GeoExt.grid.FeatureSelectionModelMixin);Ext.namespace("GeoExt","GeoExt.data");GeoExt.data.LayerReader=function(a,b){a=a||{};if(!(b instanceof Function)){b=GeoExt.data.LayerRecord.create(b||a.fields||{})}GeoExt.data.LayerReader.superclass.constructor.call(this,a,b)};Ext.extend(GeoExt.data.LayerReader,Ext.data.DataReader,{totalRecords:null,readRecords:function(g){var a=[];if(g){var c=this.recordType,l=c.prototype.fields;var h,d,f,b,k,q,m,o;for(h=0,d=g.length;h<d;h++){k=g[h];q={};for(f=0,b=l.length;f<b;f++){m=l.items[f];o=k[m.mapping||m.name]||m.defaultValue;o=m.convert(o);q[m.name]=o}q.layer=k;a[a.length]=new c(q,k.id)}}return{records:a,totalRecords:this.totalRecords!=null?this.totalRecords:a.length}}});Ext.namespace("GeoExt.data");GeoExt.data.LayerRecord=Ext.data.Record.create([{name:"layer"},{name:"title",type:"string",mapping:"name"}]);GeoExt.data.LayerRecord.prototype.clone=function(b){var a=this.get("layer")&&this.get("layer").clone();return new this.constructor(Ext.applyIf({layer:a},this.data),b||a.id)};GeoExt.data.LayerRecord.create=function(g){var c=Ext.extend(GeoExt.data.LayerRecord,{});var d=c.prototype;d.fields=new Ext.util.MixedCollection(false,function(f){return f.name});GeoExt.data.LayerRecord.prototype.fields.each(function(h){d.fields.add(h)});if(g){for(var b=0,a=g.length;b<a;b++){d.fields.add(new Ext.data.Field(g[b]))}}c.getField=function(f){return d.fields.get(f)};return c};Ext.namespace("GeoExt.form");GeoExt.form.BasicForm=Ext.extend(Ext.form.BasicForm,{protocol:null,prevResponse:null,autoAbort:true,doAction:function(b,a){if(b=="search"){a=Ext.applyIf(a||{},{protocol:this.protocol,abortPrevious:this.autoAbort});b=new GeoExt.form.SearchAction(this,a)}return GeoExt.form.BasicForm.superclass.doAction.call(this,b,a)},search:function(a){return this.doAction("search",a)}});Ext.namespace("GeoExt","GeoExt.data");GeoExt.data.FeatureReader=function(a,b){a=a||{};if(!(b instanceof Function)){b=GeoExt.data.FeatureRecord.create(b||a.fields||{})}GeoExt.data.FeatureReader.superclass.constructor.call(this,a,b)};Ext.extend(GeoExt.data.FeatureReader,Ext.data.DataReader,{totalRecords:null,read:function(a){return this.readRecords(a.features)},readRecords:function(b){var c=[];if(b){var f=this.recordType,l=f.prototype.fields;var k,g,h,d,s,r,o,q;for(k=0,g=b.length;k<g;k++){s=b[k];r={};if(s.attributes){for(h=0,d=l.length;h<d;h++){o=l.items[h];if(/[\[\.]/.test(o.mapping)){try{q=new Function("obj","return obj."+o.mapping)(s.attributes)}catch(m){q=o.defaultValue}}else{q=s.attributes[o.mapping||o.name]||o.defaultValue}if(o.convert){q=o.convert(q)}r[o.name]=q}}r.feature=s;r.state=s.state;r.fid=s.fid;var a=(s.state===OpenLayers.State.INSERT)?undefined:s.id;c[c.length]=new f(r,a)}}return{records:c,totalRecords:this.totalRecords!=null?this.totalRecords:c.length}}});Ext.namespace("GeoExt.data");GeoExt.data.WMSDescribeLayerReader=function(a,b){a=a||{};if(!a.format){a.format=new OpenLayers.Format.WMSDescribeLayer()}if(!(typeof b==="function")){b=Ext.data.Record.create(b||a.fields||[{name:"owsType",type:"string"},{name:"owsURL",type:"string"},{name:"typeName",type:"string"}])}GeoExt.data.WMSDescribeLayerReader.superclass.constructor.call(this,a,b)};Ext.extend(GeoExt.data.WMSDescribeLayerReader,Ext.data.DataReader,{read:function(a){var b=a.responseXML;if(!b||!b.documentElement){b=a.responseText}return this.readRecords(b)},readRecords:function(f){if(typeof f==="string"||f.nodeType){f=this.meta.format.read(f)}var b=[],d;for(var c=0,a=f.length;c<a;c++){d=f[c];if(d){b.push(new this.recordType(d))}}return{totalRecords:b.length,success:true,records:b}}});Ext.namespace("GeoExt.form");GeoExt.form.SearchAction=Ext.extend(Ext.form.Action,{type:"search",response:null,constructor:function(b,a){GeoExt.form.SearchAction.superclass.constructor.call(this,b,a)},run:function(){var b=this.options;var a=GeoExt.form.toFilter(this.form);if(b.clientValidation===false||this.form.isValid()){if(b.abortPrevious&&this.form.prevResponse){b.protocol.abort(this.form.prevResponse)}this.form.prevResponse=b.protocol.read(Ext.applyIf({filter:a,callback:this.handleResponse,scope:this},b))}else{if(b.clientValidation!==false){this.failureType=Ext.form.Action.CLIENT_INVALID;this.form.afterAction(this,false)}}},handleResponse:function(a){this.form.prevResponse=null;this.response=a;if(a.success()){this.form.afterAction(this,true)}else{this.form.afterAction(this,false)}var b=this.options;if(b.callback){b.callback.call(b.scope,a)}}});Ext.namespace("GeoExt.data");GeoExt.data.FeatureRecord=Ext.data.Record.create([{name:"feature"},{name:"state"},{name:"fid"}]);GeoExt.data.FeatureRecord.create=function(g){var c=Ext.extend(GeoExt.data.FeatureRecord,{});var d=c.prototype;d.fields=new Ext.util.MixedCollection(false,function(f){return f.name});GeoExt.data.FeatureRecord.prototype.fields.each(function(h){d.fields.add(h)});if(g){for(var b=0,a=g.length;b<a;b++){d.fields.add(new Ext.data.Field(g[b]))}}c.getField=function(f){return d.fields.get(f)};return c};Ext.namespace("GeoExt");GeoExt.LegendWMS=Ext.extend(Ext.Panel,{imageFormat:"image/gif",defaultStyleIsFirst:true,layer:null,record:null,bodyBorder:false,initComponent:function(){GeoExt.LegendWMS.superclass.initComponent.call(this);if(!this.layer){this.layer=this.record.get("layer")}this.updateLegend()},getLegendUrl:function(d,h){var c;var g=this.record&&this.record.get("styles");h=h||(this.layer.params.LAYERS instanceof Array)?this.layer.params.LAYERS:this.layer.params.LAYERS.split(",");var b=this.layer.params.STYLES&&this.layer.params.STYLES.split(",");var a=h.indexOf(d);var f=b&&b[a];if(g&&g.length>0){if(f){Ext.each(g,function(j){c=(j.name==f&&j.legend)&&j.legend.href;return !c})}else{if(this.defaultStyleIsFirst===true&&!b&&!this.layer.params.SLD&&!this.layer.params.SLD_BODY){c=g[0].legend&&g[0].legend.href}}}return c||this.layer.getFullRequestString({REQUEST:"GetLegendGraphic",WIDTH:null,HEIGHT:null,EXCEPTIONS:"application/vnd.ogc.se_xml",LAYER:d,LAYERS:null,STYLE:(f!=="")?f:null,STYLES:null,SRS:null,FORMAT:this.imageFormat})},updateLegend:function(c){var j,b,d,a;j=(this.layer.params.LAYERS instanceof Array)?this.layer.params.LAYERS:this.layer.params.LAYERS.split(",");if(this.items){var f=[];this.items.each(function(k){d=j.indexOf(k.itemId);if(d<0){f.push(k)}else{b=j[d];var l=c||this.getLegendUrl(b,j);if(!OpenLayers.Util.isEquivalentUrl(l,k.url)){k.updateLegend(l)}}},this);for(d=0,a=f.length;d<a;d++){var h=f[d];this.remove(h);h.destroy()}}var g=false;for(d=0,a=j.length;d<a;d++){b=j[d];if(!this.items||!this.getComponent(b)){this.add({xtype:"gx_legendimage",url:c||this.getLegendUrl(b,j),itemId:b});g=true}}if(g){this.doLayout()}}});Ext.namespace("GeoExt.data");GeoExt.data.WMSDescribeLayerStore=function(a){a=a||{};GeoExt.data.WMSDescribeLayerStore.superclass.constructor.call(this,Ext.apply(a,{proxy:a.proxy||(!a.data?new Ext.data.HttpProxy({url:a.url,disableCaching:false,method:"GET"}):undefined),reader:new GeoExt.data.WMSDescribeLayerReader(a,a.fields)}))};Ext.extend(GeoExt.data.WMSDescribeLayerStore,Ext.data.Store);Ext.namespace("GeoExt");GeoExt.FeatureRenderer=Ext.extend(Ext.BoxComponent,{feature:undefined,symbolizers:[OpenLayers.Feature.Vector.style["default"]],symbolType:"Point",resolution:1,minWidth:20,minHeight:20,renderers:["SVG","VML","Canvas"],rendererOptions:null,pointFeature:undefined,lineFeature:undefined,polygonFeature:undefined,renderer:null,initComponent:function(){GeoExt.FeatureRenderer.superclass.initComponent.apply(this,arguments);Ext.applyIf(this,{pointFeature:new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0,0)),lineFeature:new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([new OpenLayers.Geometry.Point(-8,-3),new OpenLayers.Geometry.Point(-3,3),new OpenLayers.Geometry.Point(3,-3),new OpenLayers.Geometry.Point(8,3)])),polygonFeature:new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(-8,-4),new OpenLayers.Geometry.Point(-6,-6),new OpenLayers.Geometry.Point(6,-6),new OpenLayers.Geometry.Point(8,-4),new OpenLayers.Geometry.Point(8,4),new OpenLayers.Geometry.Point(6,6),new OpenLayers.Geometry.Point(-6,6),new OpenLayers.Geometry.Point(-8,4)])]))});if(!this.feature){this.setFeature(null,{draw:false})}this.addEvents("click")},initCustomEvents:function(){this.clearCustomEvents();this.el.on("click",this.onClick,this)},clearCustomEvents:function(){if(this.el&&this.el.removeAllListeners){this.el.removeAllListeners()}},onClick:function(){this.fireEvent("click",this)},onRender:function(b,a){if(!this.el){this.el=document.createElement("div");this.el.id=this.getId()}if(!this.renderer||!this.renderer.supported()){this.assignRenderer()}this.renderer.map={getResolution:(function(){return this.resolution}).createDelegate(this)};this.drawFeature();GeoExt.FeatureRenderer.superclass.onRender.apply(this,arguments)},afterRender:function(){GeoExt.FeatureRenderer.superclass.afterRender.apply(this,arguments);this.initCustomEvents()},onResize:function(a,b){this.setRendererDimensions();GeoExt.FeatureRenderer.superclass.onResize.apply(this,arguments)},setRendererDimensions:function(){var j=this.feature.geometry.getBounds();var l=j.getWidth();var h=j.getHeight();var f=this.initialConfig.resolution;if(!f){f=Math.max(l/this.width||0,h/this.height||0)||1}this.resolution=f;var c=Math.max(this.width||this.minWidth,l/f);var k=Math.max(this.height||this.minHeight,h/f);var b=j.getCenterPixel();var g=c*f/2;var d=k*f/2;var a=new OpenLayers.Bounds(b.x-g,b.y-d,b.x+g,b.y+d);this.renderer.setSize(new OpenLayers.Size(Math.round(c),Math.round(k)));this.renderer.setExtent(a,true)},assignRenderer:function(){for(var b=0,a=this.renderers.length;b<a;++b){var c=OpenLayers.Renderer[this.renderers[b]];if(c&&c.prototype.supported()){this.renderer=new c(this.el,this.rendererOptions);break}}},setSymbolizers:function(b,a){this.symbolizers=b;if(!a||a.draw){this.drawFeature()}},setSymbolType:function(b,a){this.symbolType=b;this.setFeature(null,a)},setFeature:function(b,a){this.feature=b||this[this.symbolType.toLowerCase()+"Feature"];if(!a||a.draw){this.drawFeature()}},drawFeature:function(){this.renderer.clear();this.setRendererDimensions();for(var b=0,a=this.symbolizers.length;b<a;++b){this.renderer.drawFeature(this.feature.clone(),Ext.apply({},this.symbolizers[b]))}},update:function(a){a=a||{};if(a.feature){this.setFeature(a.feature,{draw:false})}else{if(a.symbolType){this.setSymbolType(a.symbolType,{draw:false})}}if(a.symbolizers){this.setSymbolizers(a.symbolizers,{draw:false})}this.drawFeature()},beforeDestroy:function(){this.clearCustomEvents();if(this.renderer){this.renderer.destroy()}}});Ext.reg("gx_renderer",GeoExt.FeatureRenderer);Ext.namespace("GeoExt");GeoExt.Popup=Ext.extend(Ext.Window,{anchored:true,map:null,panIn:true,unpinnable:true,feature:null,lonlat:null,animCollapse:false,draggable:false,shadow:false,popupCls:"gx-popup",ancCls:null,initComponent:function(){if(this.map instanceof GeoExt.MapPanel){this.map=this.map.map}if(!this.map&&this.feature&&this.feature.layer){this.map=this.feature.layer.map}if(!this.feature&&this.lonlat){this.feature=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(this.lonlat.lon,this.lonlat.lat))}if(this.anchored){this.addAnchorEvents()}this.baseCls=this.popupCls+" "+this.baseCls;this.elements+=",anc";GeoExt.Popup.superclass.initComponent.call(this)},onRender:function(b,a){GeoExt.Popup.superclass.onRender.call(this,b,a);this.ancCls=this.popupCls+"-anc";this.createElement("anc",this.el.dom)},initTools:function(){if(this.unpinnable){this.addTool({id:"unpin",handler:this.unanchorPopup.createDelegate(this,[])})}GeoExt.Popup.superclass.initTools.call(this)},show:function(){GeoExt.Popup.superclass.show.apply(this,arguments);if(this.anchored){this.position();if(this.panIn&&!this._mapMove){this.panIntoView()}}},setSize:function(a,c){if(this.anc){var b=this.anc.getSize();if(typeof a=="object"){c=a.height-b.height;a=a.width}else{if(!isNaN(c)){c=c-b.height}}}GeoExt.Popup.superclass.setSize.call(this,a,c)},position:function(){var c=this.feature.geometry.getBounds().getCenterLonLat();if(this._mapMove===true){var h=this.map.getExtent().containsLonLat(c);if(h!==this.isVisible()){this.setVisible(h)}}if(this.isVisible()){var d=this.map.getViewPortPxFromLonLat(c);var g=Ext.fly(this.map.div).getBox();var f=this.anc;var b=f.getLeft(true)+f.getWidth()/2;var a=this.el.getHeight();this.setPosition(d.x+g.x-b,d.y+g.y-a)}},unanchorPopup:function(){this.removeAnchorEvents();this.draggable=true;this.header.addClass("x-window-draggable");this.dd=new Ext.Window.DD(this);this.anc.remove();this.anc=null;this.tools.unpin.hide()},panIntoView:function(){var h=this.feature.geometry.getBounds().getCenterLonLat();var a=this.map.getViewPortPxFromLonLat(h);var b=Ext.fly(this.map.div).getBox();var j=this.getPosition(true);j[0]-=b.x;j[1]-=b.y;var d=[b.width,b.height];var f=this.getSize();var c=[j[0],j[1]];var g=this.map.paddingForPopups;if(j[0]<g.left){c[0]=g.left}else{if(j[0]+f.width>d[0]-g.right){c[0]=d[0]-g.right-f.width}}if(j[1]<g.top){c[1]=g.top}else{if(j[1]+f.height>d[1]-g.bottom){c[1]=d[1]-g.bottom-f.height}}var l=j[0]-c[0];var k=j[1]-c[1];this.map.pan(l,k)},onMapMove:function(){this._mapMove=true;this.position();delete this._mapMove},addAnchorEvents:function(){this.map.events.on({move:this.onMapMove,scope:this});this.on({resize:this.position,collapse:this.position,expand:this.position,scope:this})},removeAnchorEvents:function(){this.map.events.un({move:this.onMapMove,scope:this});this.un("resize",this.position,this);this.un("collapse",this.position,this);this.un("expand",this.position,this)},beforeDestroy:function(){if(this.anchored){this.removeAnchorEvents()}GeoExt.Popup.superclass.beforeDestroy.call(this)}});Ext.reg("gx_popup",GeoExt.Popup);Ext.namespace("GeoExt.data");GeoExt.data.AttributeStore=function(a){a=a||{};GeoExt.data.AttributeStore.superclass.constructor.call(this,Ext.apply(a,{proxy:a.proxy||(!a.data?new Ext.data.HttpProxy({url:a.url,disableCaching:false,method:"GET"}):undefined),reader:new GeoExt.data.AttributeReader(a,a.fields||["name","type"])}))};Ext.extend(GeoExt.data.AttributeStore,Ext.data.Store);Ext.namespace("GeoExt.form");GeoExt.form.FormPanel=Ext.extend(Ext.form.FormPanel,{protocol:null,createForm:function(){delete this.initialConfig.listeners;return new GeoExt.form.BasicForm(null,this.initialConfig)},search:function(a){this.getForm().search(a)}});Ext.reg("gx_formpanel",GeoExt.form.FormPanel);Ext.namespace("GeoExt.data");GeoExt.data.WMCReader=function(a,b){a=a||{};if(!a.format){a.format=new OpenLayers.Format.WMC()}if(!(typeof b==="function")){b=GeoExt.data.LayerRecord.create(b||a.fields||[{name:"abstract",type:"string"},{name:"metadataURL",type:"string"},{name:"queryable",type:"boolean"},{name:"formats"},{name:"styles"}])}GeoExt.data.WMCReader.superclass.constructor.call(this,a,b)};Ext.extend(GeoExt.data.WMCReader,Ext.data.DataReader,{read:function(a){var b=a.responseXML;if(!b||!b.documentElement){b=a.responseText}return this.readRecords(b)},readRecords:function(g){var o=this.meta.format;if(typeof g==="string"||g.nodeType){g=o.read(g)}var s=g?g.layersContext:undefined;var a=[];if(s){var c=this.recordType,k=c.prototype.fields;var h,d,f,b,m,r,l,q;for(h=0,d=s.length;h<d;h++){m=s[h];r={};for(f=0,b=k.length;f<b;f++){l=k.items[f];q=m[l.mapping||l.name]||l.defaultValue;q=l.convert(q);r[l.name]=q}r.layer=o.getLayerFromContext(m);a.push(new this.recordType(r,r.layer.id))}}return{totalRecords:a.length,success:true,records:a}}});Ext.namespace("GeoExt.tree");GeoExt.tree.OverlayLayerContainer=Ext.extend(GeoExt.tree.LayerContainer,{constructor:function(a){a=Ext.applyIf(a||{},{text:"Overlays"});a.loader=Ext.applyIf(a.loader||{},{filter:function(b){var c=b.get("layer");return c.displayInLayerSwitcher===true&&c.isBaseLayer===false}});GeoExt.tree.OverlayLayerContainer.superclass.constructor.call(this,a)}});Ext.tree.TreePanel.nodeTypes.gx_overlaylayercontainer=GeoExt.tree.OverlayLayerContainer;Ext.namespace("GeoExt.data");GeoExt.data.WFSCapabilitiesReader=function(a,b){a=a||{};if(!a.format){a.format=new OpenLayers.Format.WFSCapabilities()}if(!(typeof b==="function")){b=GeoExt.data.LayerRecord.create(b||a.fields||[{name:"name",type:"string"},{name:"abstract",type:"string"}])}GeoExt.data.WFSCapabilitiesReader.superclass.constructor.call(this,a,b)};Ext.extend(GeoExt.data.WFSCapabilitiesReader,Ext.data.DataReader,{read:function(a){var b=a.responseXML;if(!b||!b.documentElement){b=a.responseText}return this.readRecords(b)},readRecords:function(g){if(typeof g==="string"||g.nodeType){g=this.meta.format.read(g)}var b=[],j,c,d,m,o;var a=g.featureTypeList.featureTypes;var h={url:g.capability.request.getfeature.href.post};for(var f=0,k=a.length;f<k;f++){j=a[f];if(j.name){d=j.name.split(":");if(d.length>1){o={featureType:d[1],featurePrefix:d[0]}}else{o={featureType:d[0],featurePrefix:null}}if(this.meta.protocolOptions){Ext.apply(o,this.meta.protocolOptions,h)}else{Ext.apply(o,{},h)}m={protocol:new OpenLayers.Protocol.WFS(o),strategies:[new OpenLayers.Strategy.Fixed()]};if(this.meta.layerOptions){Ext.apply(m,this.meta.layerOptions)}c=new OpenLayers.Layer.Vector(j.title||j.name,m);b.push(new this.recordType(Ext.apply(j,{layer:c}),c.id))}}return{totalRecords:b.length,success:true,records:b}}});Ext.namespace("GeoExt");GeoExt.LegendPanel=Ext.extend(Ext.Panel,{dynamic:true,showTitle:true,labelCls:null,bodyStyle:"",layerStore:null,filter:function(a){return true},initComponent:function(){GeoExt.LegendPanel.superclass.initComponent.call(this)},onRender:function(){GeoExt.LegendPanel.superclass.onRender.apply(this,arguments);if(!this.layerStore){this.layerStore=GeoExt.MapPanel.guess().layers}this.layerStore.each(function(a){this.addLegend(a)},this);if(this.dynamic){this.layerStore.on({add:this.onStoreAdd,remove:this.onStoreRemove,clear:this.onStoreClear,update:this.onStoreUpdate,scope:this})}this.doLayout()},recordIndexToPanelIndex:function(b){var a=this.layerStore;var g=a.getCount();var h=-1;var j=this.items?this.items.length:0;for(var d=g-1;d>=0;--d){var c=a.getAt(d).get("layer");var f=GeoExt["Legend"+c.CLASS_NAME.split(".").pop()];if(c.displayInLayerSwitcher&&f&&(a.getAt(d).get("hideInLegend")!==true)){++h;if(b===d||h>j-1){break}}}return h},onStoreUpdate:function(c,a,b){var f=a.get("layer");var g=this.items?this.getComponent(f.id):null;if((this.showTitle&&!a.get("hideTitle"))&&(g&&g.items.get(0).text!==a.get("title"))){g.items.get(0).setText(a.get("title"))}if(g){g.setVisible(f.getVisibility()&&f.inRange&&f.displayInLayerSwitcher&&!a.get("hideInLegend"));var d=a.get("legendURL")!=null?a.get("legendURL"):undefined;g.items.get(1).updateLegend(d)}},onStoreAdd:function(c,b,d){var g=this.recordIndexToPanelIndex(d+b.length-1);for(var f=0,a=b.length;f<a;f++){this.addLegend(b[f],g)}this.doLayout()},onStoreRemove:function(b,a,c){this.removeLegend(a)},removeLegend:function(a){var b=this.getComponent(a.get("layer").id);if(b){this.remove(b,true);this.doLayout()}},onStoreClear:function(a){this.removeAllLegends()},removeAllLegends:function(){this.removeAll(true);this.doLayout()},createLegendSubpanel:function(a){var b=a.get("layer");var f=this.createMainPanel(a);if(f!==null){var d;if(a.get("legendURL")){d=new GeoExt.LegendImage({url:a.get("legendURL")});f.add(d)}else{var c=GeoExt["Legend"+b.CLASS_NAME.split(".").pop()];if(c){d=new c(Ext.applyIf({layer:b,record:a},this.legendOptions));f.add(d)}}}return f},addLegend:function(a,b){if(this.filter(a)===true){b=b||0;var c=a.get("layer");var d=this.createLegendSubpanel(a);if(d!==null){d.setVisible(c.getVisibility()&&c.inRange);this.insert(b,d)}}},createMainPanel:function(b){var c=b.get("layer");var a=null;var d=GeoExt["Legend"+c.CLASS_NAME.split(".").pop()];if(c.displayInLayerSwitcher&&!b.get("hideInLegend")&&d){var f={id:c.id,border:false,bodyBorder:false,hideMode:"offsets",bodyStyle:this.bodyStyle,items:[new Ext.form.Label({text:(this.showTitle&&!b.get("hideTitle"))?c.name:"",cls:"x-form-item x-form-item-label"+(this.labelCls?" "+this.labelCls:"")})]};a=new Ext.Panel(f)}return a},onDestroy:function(){if(this.layerStore){this.layerStore.un("add",this.onStoreAdd,this);this.layerStore.un("remove",this.onStoreRemove,this);this.layerStore.un("clear",this.onStoreClear,this);this.layerStore.un("update",this.onStoreUpdate,this)}GeoExt.LegendPanel.superclass.onDestroy.apply(this,arguments)}});Ext.reg("gx_legendpanel",GeoExt.LegendPanel);Ext.namespace("GeoExt.form");GeoExt.form.toFilter=function(g,a){if(g instanceof Ext.form.FormPanel){g=g.getForm()}var f=[],b=g.getValues(false);for(var j in b){var d=j.split("__");var h=b[j],c;if(d.length>1&&(c=GeoExt.form.toFilter.FILTER_MAP[d[1]])!==undefined){j=d[0]}else{c=OpenLayers.Filter.Comparison.EQUAL_TO}f.push(new OpenLayers.Filter.Comparison({type:c,value:h,property:j}))}return new OpenLayers.Filter.Logical({type:a||OpenLayers.Filter.Logical.AND,filters:f})};GeoExt.form.toFilter.FILTER_MAP={eq:OpenLayers.Filter.Comparison.EQUAL_TO,ne:OpenLayers.Filter.Comparison.NOT_EQUAL_TO,lt:OpenLayers.Filter.Comparison.LESS_THAN,le:OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO,gt:OpenLayers.Filter.Comparison.GREATER_THAN,ge:OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,like:OpenLayers.Filter.Comparison.LIKE};Ext.namespace("GeoExt.tree");GeoExt.tree.LayerNodeUI=Ext.extend(Ext.tree.TreeNodeUI,{constructor:function(a){GeoExt.tree.LayerNodeUI.superclass.constructor.apply(this,arguments)},render:function(d){var c=this.node.attributes;if(c.checked===undefined){c.checked=this.node.layer.getVisibility()}GeoExt.tree.LayerNodeUI.superclass.render.apply(this,arguments);var b=this.checkbox;if(c.checkedGroup){var f=Ext.DomHelper.insertAfter(b,['<input type="radio" name="',c.checkedGroup,'_checkbox" class="',b.className,b.checked?'" checked="checked"':"",'"></input>'].join(""));f.defaultChecked=b.defaultChecked;Ext.get(b).remove();this.checkbox=f}this.enforceOneVisible()},onClick:function(a){if(a.getTarget(".x-tree-node-cb",1)){this.toggleCheck(this.isChecked())}else{GeoExt.tree.LayerNodeUI.superclass.onClick.apply(this,arguments)}},toggleCheck:function(a){a=(a===undefined?!this.isChecked():a);GeoExt.tree.LayerNodeUI.superclass.toggleCheck.call(this,a);this.enforceOneVisible()},enforceOneVisible:function(){var b=this.node.attributes;var g=b.checkedGroup;if(g){var d=this.node.layer;var a=this.node.getOwnerTree().getChecked();var c=0;Ext.each(a,function(k){var j=k.getUI();var h=k.layer;if(!k.hidden&&k.attributes.checkedGroup===g){c++;if(h!=d&&b.checked){h.setVisibility(false)}}});if(c===0&&b.checked==false){var f=this.node.getUI();d.setVisibility(true)}}},appendDDGhost:function(c){var b=this.elNode.cloneNode(true);var a=Ext.DomQuery.select("input[type='radio']",b);Ext.each(a,function(d){d.name=d.name+"_clone"});c.appendChild(b)}});GeoExt.tree.LayerNode=Ext.extend(Ext.tree.AsyncTreeNode,{layer:null,layerStore:null,constructor:function(a){a.leaf=a.leaf||!(a.children||a.loader);if(!a.iconCls&&!a.children){a.iconCls="gx-tree-layer-icon"}if(a.loader&&!(a.loader instanceof Ext.tree.TreeLoader)){a.loader=new GeoExt.tree.LayerParamLoader(a.loader)}this.defaultUI=this.defaultUI||GeoExt.tree.LayerNodeUI;Ext.apply(this,{layer:a.layer,layerStore:a.layerStore});if(a.text){this.fixedText=true}GeoExt.tree.LayerNode.superclass.constructor.apply(this,arguments)},render:function(a){var c=this.layer instanceof OpenLayers.Layer&&this.layer;if(!c){if(!this.layerStore||this.layerStore=="auto"){this.layerStore=GeoExt.MapPanel.guess().layers}var b=this.layerStore.findBy(function(f){return f.get("title")==this.layer},this);if(b!=-1){c=this.layerStore.getAt(b).get("layer")}}if(!this.rendered||!c){var d=this.getUI();if(c){this.layer=c;if(c.isBaseLayer){this.draggable=false;Ext.applyIf(this.attributes,{checkedGroup:"gx_baselayer"})}if(!this.text){this.text=c.name}d.show();this.addVisibilityEventHandlers()}else{d.hide()}if(this.layerStore instanceof GeoExt.data.LayerStore){this.addStoreEventHandlers(c)}}GeoExt.tree.LayerNode.superclass.render.apply(this,arguments)},addVisibilityEventHandlers:function(){this.layer.events.on({visibilitychanged:this.onLayerVisibilityChanged,scope:this});this.on({checkchange:this.onCheckChange,scope:this})},onLayerVisibilityChanged:function(){if(!this._visibilityChanging){this.getUI().toggleCheck(this.layer.getVisibility())}},onCheckChange:function(c,b){if(b!=this.layer.getVisibility()){this._visibilityChanging=true;var a=this.layer;if(b&&a.isBaseLayer&&a.map){a.map.setBaseLayer(a)}else{a.setVisibility(b)}delete this._visibilityChanging}},addStoreEventHandlers:function(){this.layerStore.on({add:this.onStoreAdd,remove:this.onStoreRemove,update:this.onStoreUpdate,scope:this})},onStoreAdd:function(c,b,d){var a;for(var f=0;f<b.length;++f){a=b[f].get("layer");if(this.layer==a){this.getUI().show();break}else{if(this.layer==a.name){this.render();break}}}},onStoreRemove:function(b,a,c){if(this.layer==a.get("layer")){this.getUI().hide()}},onStoreUpdate:function(c,a,b){var d=a.get("layer");if(!this.fixedText&&(this.layer==d&&this.text!==d.name)){this.setText(d.name)}},destroy:function(){var b=this.layer;if(b instanceof OpenLayers.Layer){b.events.un({visibilitychanged:this.onLayerVisibilityChanged,scope:this})}delete this.layer;var a=this.layerStore;if(a){a.un("add",this.onStoreAdd,this);a.un("remove",this.onStoreRemove,this);a.un("update",this.onStoreUpdate,this)}delete this.layerStore;this.un("checkchange",this.onCheckChange,this);GeoExt.tree.LayerNode.superclass.destroy.apply(this,arguments)}});Ext.tree.TreePanel.nodeTypes.gx_layer=GeoExt.tree.LayerNode;Ext.namespace("GeoExt.tree");GeoExt.tree.LayerParamNode=Ext.extend(Ext.tree.TreeNode,{layer:null,param:null,item:null,delimiter:null,allItems:null,constructor:function(a){var b=a||{};b.iconCls=b.iconCls||"gx-tree-layerparam-icon";b.text=b.text||b.item;typeof b.layer=="string"?false:b.layer.getVisibility();this.param=b.param;this.item=b.item;this.delimiter=b.delimiter||",";GeoExt.tree.LayerParamNode.superclass.constructor.apply(this,arguments)},render:function(b){var f=this.attributes.layer;if(typeof f=="string"){var c=this.attributes.layerStore||GeoExt.MapPanel.guess().layers;var d=c.findBy(function(g){return g.get("title")==f});f=c.getAt(d).get("layer")}this.layer=f;this.allItems=this.getItems();var a=f.getVisibility();this.attributes.checked=this.attributes.checked==null?a:this.attributes.checked;if(this.attributes.checked!==a){this.onCheckChange(this,!a)}this.addVisibilityEventHandlers();GeoExt.tree.LayerParamNode.superclass.render.apply(this,arguments)},getItems:function(){var a=this.layer.params[this.param];return a instanceof Array?a:(a?a.split(this.delimiter):[])},createParams:function(a){var b={};b[this.param]=this.layer.params[this.param] instanceof Array?a:a.join(this.delimiter);return b},addVisibilityEventHandlers:function(){this.layer.events.on({visibilitychanged:this.onLayerVisibilityChanged,scope:this});this.on({checkchange:this.onCheckChange,scope:this})},onLayerVisibilityChanged:function(){if(this.getItems().length===0){this.layer.mergeNewParams(this.createParams(this.allItems))}var a=this.layer.getVisibility();if(a&&this.getItems().indexOf(this.item)!==-1){this.getUI().toggleCheck(true)}if(!a){this.layer.mergeNewParams(this.createParams([]));this.getUI().toggleCheck(false)}},onCheckChange:function(f,d){var c=this.layer;var b=[];var a=this.getItems();if(d===true&&c.getVisibility()===false&&a.length===this.allItems.length){a=[]}Ext.each(this.allItems,function(h){if((h!==this.item&&a.indexOf(h)!==-1)||(d===true&&h===this.item)){b.push(h)}},this);var g=(b.length>0);g&&c.mergeNewParams(this.createParams(b));if(g!==c.getVisibility()){c.setVisibility(g)}(!g)&&c.mergeNewParams(this.createParams([]))},destroy:function(){var a=this.layer;if(a instanceof OpenLayers.Layer){a.events.un({visibilitychanged:this.onLayerVisibilityChanged,scope:this})}delete this.layer;this.un("checkchange",this.onCheckChange,this);GeoExt.tree.LayerNode.superclass.destroy.apply(this,arguments)}});Ext.tree.TreePanel.nodeTypes.gx_layerparam=GeoExt.tree.LayerParamNode;Ext.namespace("GeoExt.tree");GeoExt.tree.RadioButtonMixin=function(){return(function(){var a;return{constructor:function(b){b.addEvents("radiochange");a=arguments.callee.superclass;a.constructor.apply(this,arguments)},render:function(c){if(!this.rendered){a.render.apply(this,arguments);var b=this.node.attributes;if(b.radioGroup){Ext.DomHelper.insertBefore(this.anchor,['<input type="radio" class="gx-tree-radio" name="',b.radioGroup,'_radio"></input>'].join(""))}}},onClick:function(c){var b=c.getTarget(".gx-tree-radio",1);if(b){b.defaultChecked=b.checked;this.fireEvent("radiochange",this.node)}else{a.onClick.apply(this,arguments)}}}})()};Ext.namespace("GeoExt");GeoExt.LegendImage=Ext.extend(Ext.BoxComponent,{url:null,defaultImgSrc:null,imgCls:null,initComponent:function(){GeoExt.LegendImage.superclass.initComponent.call(this);if(this.defaultImgSrc===null){this.defaultImgSrc=Ext.BLANK_IMAGE_URL}this.autoEl={tag:"img","class":(this.imgCls?this.imgCls:""),src:this.defaultImgSrc}},updateLegend:function(a){this.url=a;var b=this.getEl();if(b){b.un("error",this.onImageLoadError,this);b.on("error",this.onImageLoadError,this,{single:true});b.dom.src=a}},onRender:function(b,a){GeoExt.LegendImage.superclass.onRender.call(this,b,a);if(this.url){this.updateLegend(this.url)}},onDestroy:function(){var a=this.getEl();if(a){a.un("error",this.onImageLoadError,this)}GeoExt.LegendImage.superclass.onDestroy.apply(this,arguments)},onImageLoadError:function(){this.getEl().dom.src=this.defaultImgSrc}});Ext.reg("gx_legendimage",GeoExt.LegendImage);Ext.namespace("GeoExt");GeoExt.LayerOpacitySlider=Ext.extend(Ext.Slider,{layer:null,complementaryLayer:null,delay:5,changeVisibilityDelay:5,aggressive:false,changeVisibility:false,value:null,constructor:function(a){if(a.layer){if(a.layer instanceof OpenLayers.Layer){this.layer=a.layer}else{if(a.layer instanceof GeoExt.data.LayerRecord){this.layer=a.layer.get("layer")}}if(a.complementaryLayer instanceof OpenLayers.Layer){this.complementaryLayer=a.complementaryLayer}else{if(a.complementaryLayer instanceof GeoExt.data.LayerRecord){this.complementaryLayer=a.complementaryLayer.get("layer")}}delete a.layer;delete a.complementaryLayer}GeoExt.LayerOpacitySlider.superclass.constructor.call(this,a)},initComponent:function(){if(this.layer&&this.layer.opacity!==null){this.value=parseInt(this.layer.opacity*(this.maxValue-this.minValue))}else{if(this.value==null){this.value=this.maxValue}}GeoExt.LayerOpacitySlider.superclass.initComponent.call(this);if(this.changeVisibility&&this.layer&&(this.layer.opacity==0||this.value==this.minValue)){this.layer.setVisibility(false)}if(this.complementaryLayer&&((this.layer&&this.layer.opacity==1)||(this.value==this.maxValue))){this.complementaryLayer.setVisibility(false)}if(this.aggressive===true){this.on("change",this.changeLayerOpacity,this,{buffer:this.delay})}else{this.on("changecomplete",this.changeLayerOpacity,this)}if(this.changeVisibility===true){this.on("change",this.changeLayerVisibility,this,{buffer:this.changeVisibilityDelay})}if(this.complementaryLayer){this.on("change",this.changeComplementaryLayerVisibility,this,{buffer:this.changeVisibilityDelay})}},changeLayerOpacity:function(a,b){if(this.layer){this.layer.setOpacity(b/100)}},changeLayerVisibility:function(b,c){var a=this.layer.getVisibility();if(c==this.minValue&&a===true){this.layer.setVisibility(false)}else{if(c>this.minValue&&a==false){this.layer.setVisibility(true)}}},changeComplementaryLayerVisibility:function(b,c){var a=this.complementaryLayer.getVisibility();if(c==this.maxValue&&a===true){this.complementaryLayer.setVisibility(false)}else{if(c<this.maxValue&&a==false){this.complementaryLayer.setVisibility(true)}}},addToMapPanel:function(a){this.on({render:function(){var b=this.getEl();b.setStyle({position:"absolute",zIndex:a.map.Z_INDEX_BASE.Control});b.on({mousedown:this.stopMouseEvents,click:this.stopMouseEvents})},scope:this})},removeFromMapPanel:function(a){var b=this.getEl();b.un({mousedown:this.stopMouseEvents,click:this.stopMouseEvents,scope:this})},stopMouseEvents:function(a){a.stopEvent()}});Ext.reg("gx_opacityslider",GeoExt.LayerOpacitySlider);Ext.namespace("GeoExt.data");GeoExt.data.AttributeReader=function(a,b){a=a||{};if(!a.format){a.format=new OpenLayers.Format.WFSDescribeFeatureType()}GeoExt.data.AttributeReader.superclass.constructor.call(this,a,b||a.fields)};Ext.extend(GeoExt.data.AttributeReader,Ext.data.DataReader,{read:function(a){var b=a.responseXML;if(!b||!b.documentElement){b=a.responseText}return this.readRecords(b)},readRecords:function(k){var f;if(k instanceof Array){f=k}else{f=this.meta.format.read(k).featureTypes[0].properties}var c=this.recordType;var o=c.prototype.fields;var g=o.length;var r,u,a,m,s,l,t,b=[];for(var h=0,q=f.length;h<q;++h){s=false;r=f[h];u={};for(var d=0;d<g;++d){a=o.items[d].name;t=r[a];if(this.meta.ignore&&this.meta.ignore[a]){l=this.meta.ignore[a];if(typeof l=="string"){s=(l===t)}else{if(l instanceof Array){s=(l.indexOf(t)>-1)}else{if(l instanceof RegExp){s=(l.test(t))}}}if(s){break}}u[a]=r[a]}if(!s){b[b.length]=new c(u)}}return{success:true,records:b,totalRecords:b.length}}});Ext.namespace("GeoExt");GeoExt.ZoomSliderTip=Ext.extend(GeoExt.SliderTip,{template:"<div>Zoom Level: {zoom}</div><div>Resolution: {resolution}</div><div>Scale: 1 : {scale}</div>",compiledTemplate:null,init:function(a){this.compiledTemplate=new Ext.Template(this.template);GeoExt.ZoomSliderTip.superclass.init.call(this,a)},getText:function(a){var b={zoom:a.getZoom(),resolution:a.getResolution(),scale:Math.round(a.getScale())};return this.compiledTemplate.apply(b)}});Ext.namespace("GeoExt.data");GeoExt.data.ScaleStore=Ext.extend(Ext.data.Store,{map:null,constructor:function(a){var b=(a.map instanceof GeoExt.MapPanel?a.map.map:a.map);delete a.map;a=Ext.applyIf(a,{reader:new Ext.data.JsonReader({},["level","resolution","scale"])});GeoExt.data.ScaleStore.superclass.constructor.call(this,a);if(b){this.bind(b)}},bind:function(b,a){this.map=(b instanceof GeoExt.MapPanel?b.map:b);this.map.events.register("changebaselayer",this,this.populateFromMap);if(this.map.baseLayer){this.populateFromMap()}else{this.map.events.register("addlayer",this,this.populateOnAdd)}},unbind:function(){if(this.map){this.map.events.unregister("addlayer",this,this.populateOnAdd);this.map.events.unregister("changebaselayer",this,this.populateFromMap);delete this.map}},populateOnAdd:function(a){if(a.layer.isBaseLayer){this.populateFromMap();this.map.events.unregister("addlayer",this,this.populateOnAdd)}},populateFromMap:function(){var c=[];var a=this.map.baseLayer.resolutions;var b=this.map.baseLayer.units;for(var f=a.length-1;f>=0;f--){var d=a[f];c.push({level:f,resolution:d,scale:OpenLayers.Util.getScaleFromResolution(d,b)})}this.loadData(c)}});Ext.namespace("GeoExt.data");GeoExt.data.FeatureStoreMixin=function(){return{layer:null,reader:null,addFeatureFilter:null,addRecordFilter:null,constructor:function(b){b=b||{};b.reader=b.reader||new GeoExt.data.FeatureReader({},b.fields);var c=b.layer;delete b.layer;if(b.features){b.data=b.features}delete b.features;var a={initDir:b.initDir};delete b.initDir;arguments.callee.superclass.constructor.call(this,b);if(c){this.bind(c,a)}},bind:function(d,b){if(this.layer){return}this.layer=d;b=b||{};var g=b.initDir;if(b.initDir==undefined){g=GeoExt.data.FeatureStore.LAYER_TO_STORE|GeoExt.data.FeatureStore.STORE_TO_LAYER}var f=d.features.slice(0);if(g&GeoExt.data.FeatureStore.STORE_TO_LAYER){var a=this.getRange();for(var c=a.length-1;c>=0;c--){this.layer.addFeatures([a[c].get("feature")])}}if(g&GeoExt.data.FeatureStore.LAYER_TO_STORE){this.loadData(f,true)}d.events.on({featuresadded:this.onFeaturesAdded,featuresremoved:this.onFeaturesRemoved,featuremodified:this.onFeatureModified,scope:this});this.on({load:this.onLoad,clear:this.onClear,add:this.onAdd,remove:this.onRemove,update:this.onUpdate,scope:this})},unbind:function(){if(this.layer){this.layer.events.un({featuresadded:this.onFeaturesAdded,featuresremoved:this.onFeaturesRemoved,featuremodified:this.onFeatureModified,scope:this});this.un("load",this.onLoad,this);this.un("clear",this.onClear,this);this.un("add",this.onAdd,this);this.un("remove",this.onRemove,this);this.un("update",this.onUpdate,this);this.layer=null}},getRecordFromFeature:function(c){var a=null;if(c.state!==OpenLayers.State.INSERT){a=this.getById(c.id)}else{var b=this.findBy(function(d){return d.get("feature")===c});if(b>-1){a=this.getAt(b)}}return a},onFeaturesAdded:function(b){if(!this._adding){var g=b.features,f=g;if(typeof this.addFeatureFilter=="function"){f=[];var d,a,c;for(var d=0,a=g.length;d<a;d++){c=g[d];if(this.addFeatureFilter(c)!==false){f.push(c)}}}this._adding=true;this.loadData(f,true);delete this._adding}},onFeaturesRemoved:function(b){if(!this._removing){var f=b.features,d,a,c;for(c=f.length-1;c>=0;c--){d=f[c];a=this.getRecordFromFeature(d);if(a!==undefined){this._removing=true;this.remove(a);delete this._removing}}}},onFeatureModified:function(d){if(!this._updating){var h=d.feature;var c=this.getRecordFromFeature(h);if(c!==undefined){c.beginEdit();attributes=h.attributes;if(attributes){var b=this.recordType.prototype.fields;for(var g=0,a=b.length;g<a;g++){var j=b.items[g];var f=j.mapping||j.name;if(f in attributes){c.set(j.name,j.convert(attributes[f]))}}}c.set("state",h.state);c.set("fid",h.fid);c.data.feature=h;this._updating=true;c.endEdit();delete this._updating}}},addFeaturesToLayer:function(c){var d,a,f,b;if(typeof this.addRecordFilter=="function"){f=[];for(d=0,a=c.length;d<a;d++){b=c[d];if(this.addRecordFilter(b)!==false){f.push(b.get("feature"))}}}else{f=new Array((a=c.length));for(d=0;d<a;d++){f[d]=c[d].get("feature")}}if(f.length>0){this._adding=true;this.layer.addFeatures(f);delete this._adding}},onLoad:function(b,a,c){if(!c||c.add!==true){this._removing=true;this.layer.removeFeatures(this.layer.features);delete this._removing;this.addFeaturesToLayer(a)}},onClear:function(a){this._removing=true;this.layer.removeFeatures(this.layer.features);delete this._removing},onAdd:function(b,a,c){if(!this._adding){this.addFeaturesToLayer(a)}},onRemove:function(b,a,c){if(!this._removing){var d=a.get("feature");if(this.layer.getFeatureById(d.id)!=null){this._removing=true;this.layer.removeFeatures([a.get("feature")]);delete this._removing}}},onUpdate:function(f,b,d){if(!this._updating){var h=new GeoExt.data.FeatureRecord().fields;var g=b.get("feature");if(b.fields){var a=this.layer.events.triggerEvent("beforefeaturemodified",{feature:g});if(a!==false){var c=g.attributes;b.fields.each(function(k){var j=k.mapping||k.name;if(!h.containsKey(j)){c[j]=b.get(k.name)}});this._updating=true;this.layer.events.triggerEvent("featuremodified",{feature:g});delete this._updating;if(this.layer.getFeatureById(g.id)!=null){this.layer.drawFeature(g)}}}}}}};GeoExt.data.FeatureStore=Ext.extend(Ext.data.Store,new GeoExt.data.FeatureStoreMixin);GeoExt.data.FeatureStore.LAYER_TO_STORE=1;GeoExt.data.FeatureStore.STORE_TO_LAYER=2;Ext.namespace("GeoExt.data");GeoExt.data.WFSCapabilitiesStore=function(a){a=a||{};GeoExt.data.WFSCapabilitiesStore.superclass.constructor.call(this,Ext.apply(a,{proxy:a.proxy||(!a.data?new Ext.data.HttpProxy({url:a.url,disableCaching:false,method:"GET"}):undefined),reader:new GeoExt.data.WFSCapabilitiesReader(a,a.fields)}))};Ext.extend(GeoExt.data.WFSCapabilitiesStore,Ext.data.Store);Ext.namespace("GeoExt");GeoExt.MapPanel=Ext.extend(Ext.Panel,{map:null,layers:null,center:null,zoom:null,extent:null,initComponent:function(){if(!(this.map instanceof OpenLayers.Map)){this.map=new OpenLayers.Map(Ext.applyIf(this.map||{},{allOverlays:true}))}var a=this.layers;if(!a||a instanceof Array){this.layers=new GeoExt.data.LayerStore({layers:a,map:this.map})}if(typeof this.center=="string"){this.center=OpenLayers.LonLat.fromString(this.center)}else{if(this.center instanceof Array){this.center=new OpenLayers.LonLat(this.center[0],this.center[1])}}if(typeof this.extent=="string"){this.extent=OpenLayers.Bounds.fromString(this.extent)}else{if(this.extent instanceof Array){this.extent=OpenLayers.Bounds.fromArray(this.extent)}}GeoExt.MapPanel.superclass.initComponent.call(this)},updateMapSize:function(){if(this.map){this.map.updateSize()}},renderMap:function(){var a=this.map;a.render(this.body.dom);if(a.layers.length>0){if(this.center||this.zoom!=null){a.setCenter(this.center,this.zoom)}else{if(this.extent){a.zoomToExtent(this.extent)}else{a.zoomToMaxExtent()}}}},afterRender:function(){GeoExt.MapPanel.superclass.afterRender.apply(this,arguments);if(!this.ownerCt){this.renderMap()}else{this.ownerCt.on("move",this.updateMapSize,this);this.ownerCt.on({afterlayout:{fn:this.renderMap,scope:this,single:true}})}},onResize:function(){GeoExt.MapPanel.superclass.onResize.apply(this,arguments);this.updateMapSize()},onBeforeAdd:function(a){if(typeof a.addToMapPanel==="function"){a.addToMapPanel(this)}GeoExt.MapPanel.superclass.onBeforeAdd.apply(this,arguments)},remove:function(b,a){if(typeof b.removeFromMapPanel==="function"){b.removeFromMapPanel(this)}GeoExt.MapPanel.superclass.remove.apply(this,arguments)},beforeDestroy:function(){if(this.ownerCt){this.ownerCt.un("move",this.updateMapSize,this)}if(!this.initialConfig.map||!(this.initialConfig.map instanceof OpenLayers.Map)){if(this.map&&this.map.destroy){this.map.destroy()}}delete this.map;GeoExt.MapPanel.superclass.beforeDestroy.apply(this,arguments)}});GeoExt.MapPanel.guess=function(){return Ext.ComponentMgr.all.find(function(a){return a instanceof GeoExt.MapPanel})};Ext.reg("gx_mappanel",GeoExt.MapPanel);Ext.namespace("GeoExt","GeoExt.data");GeoExt.data.ProtocolProxy=function(a){Ext.apply(this,a);GeoExt.data.ProtocolProxy.superclass.constructor.apply(this,arguments)};Ext.extend(GeoExt.data.ProtocolProxy,Ext.data.DataProxy,{protocol:null,abortPrevious:true,response:null,load:function(h,c,j,f,b){if(this.fireEvent("beforeload",this,h)!==false){var g={params:h||{},request:{callback:j,scope:f,arg:b},reader:c};var a=OpenLayers.Function.bind(this.loadResponse,this,g);if(this.abortPrevious){this.abortRequest()}var d={params:h,callback:a,scope:this};Ext.applyIf(d,b);this.response=this.protocol.read(d)}else{j.call(f||this,null,b,false)}},abortRequest:function(){if(this.response){this.protocol.abort(this.response);this.response=null}},loadResponse:function(c,b){if(b.success()){var a=c.reader.read(b);this.fireEvent("load",this,c,c.request.arg);c.request.callback.call(c.request.scope,a,c.request.arg,true)}else{this.fireEvent("loadexception",this,c,b);c.request.callback.call(c.request.scope,null,c.request.arg,false)}}});Ext.namespace("GeoExt");GeoExt.Action=Ext.extend(Ext.Action,{control:null,map:null,uScope:null,uHandler:null,uToggleHandler:null,uCheckHandler:null,constructor:function(a){this.uScope=a.scope;this.uHandler=a.handler;this.uToggleHandler=a.toggleHandler;this.uCheckHandler=a.checkHandler;a.scope=this;a.handler=this.pHandler;a.toggleHandler=this.pToggleHandler;a.checkHandler=this.pCheckHandler;var b=this.control=a.control;delete a.control;if(b){if(a.map){a.map.addControl(b);delete a.map}if((a.pressed||a.checked)&&b.map){b.activate()}b.events.on({activate:this.onCtrlActivate,deactivate:this.onCtrlDeactivate,scope:this})}arguments.callee.superclass.constructor.call(this,a)},pHandler:function(a){var b=this.control;if(b&&b.type==OpenLayers.Control.TYPE_BUTTON){b.trigger()}if(this.uHandler){this.uHandler.apply(this.uScope,arguments)}},pToggleHandler:function(a,b){this.changeControlState(b);if(this.uToggleHandler){this.uToggleHandler.apply(this.uScope,arguments)}},pCheckHandler:function(a,b){this.changeControlState(b);if(this.uCheckHandler){this.uCheckHandler.apply(this.uScope,arguments)}},changeControlState:function(a){if(a){if(!this._activating){this._activating=true;this.control.activate();this._activating=false}}else{if(!this._deactivating){this._deactivating=true;this.control.deactivate();this._deactivating=false}}},onCtrlActivate:function(){var a=this.control;if(a.type==OpenLayers.Control.TYPE_BUTTON){this.enable()}else{this.safeCallEach("toggle",[true]);this.safeCallEach("setChecked",[true])}},onCtrlDeactivate:function(){var a=this.control;if(a.type==OpenLayers.Control.TYPE_BUTTON){this.disable()}else{this.safeCallEach("toggle",[false]);this.safeCallEach("setChecked",[false])}},safeCallEach:function(f,b){var d=this.items;for(var c=0,a=d.length;c<a;c++){if(d[c][f]){d[c][f].apply(d[c],b)}}}});Ext.namespace("GeoExt.data");GeoExt.data.WMSCapabilitiesStore=function(a){a=a||{};GeoExt.data.WMSCapabilitiesStore.superclass.constructor.call(this,Ext.apply(a,{proxy:a.proxy||(!a.data?new Ext.data.HttpProxy({url:a.url,disableCaching:false,method:"GET"}):undefined),reader:new GeoExt.data.WMSCapabilitiesReader(a,a.fields)}))};Ext.extend(GeoExt.data.WMSCapabilitiesStore,Ext.data.Store);Ext.namespace("GeoExt");GeoExt.LayerOpacitySliderTip=Ext.extend(GeoExt.SliderTip,{template:"<div>{opacity}%</div>",compiledTemplate:null,init:function(a){this.compiledTemplate=new Ext.Template(this.template);GeoExt.LayerOpacitySliderTip.superclass.init.call(this,a)},getText:function(a){var b={opacity:a.getValue()};return this.compiledTemplate.apply(b)}});Ext.ns("Tine.widgets");Tine.widgets.MapPanel=Ext.extend(GeoExt.MapPanel,{zoom:4,map:null,layers:null,initComponent:function(){this.map=new OpenLayers.Map();this.layers=[new OpenLayers.Layer.OSM()];if(this.center instanceof Array){this.center=new OpenLayers.LonLat(this.center[0],this.center[1]).transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"))}Tine.widgets.MapPanel.superclass.initComponent.call(this)},setCenter:function(g,c){this.center=new OpenLayers.LonLat(g,c).transform(new OpenLayers.Projection("EPSG:4326"),this.map.getProjectionObject());this.map.setCenter(this.center);var a=new OpenLayers.Size(32,32);var f=new OpenLayers.Pixel(0,-a.h);var b=new OpenLayers.Icon("images/oxygen/32x32/actions/flag-red.png",a,f);var d=new OpenLayers.Layer.Markers("Markers");d.addMarker(new OpenLayers.Marker(this.center,b));this.map.addLayer(d)},beforeDestroy:function(){delete this.map;this.supr().beforeDestroy.apply(this,arguments)}});Ext.reg("widget-mappanel",Tine.widgets.MapPanel);Ext.ns("Tine.widgets");Tine.widgets.ContentTypeTreePanel=function(a){Ext.apply(this,a);Tine.widgets.ContentTypeTreePanel.superclass.constructor.call(this)};Ext.extend(Tine.widgets.ContentTypeTreePanel,Ext.tree.TreePanel,{rootVisible:false,border:false,collapsible:true,root:null,titleCollapse:true,title:"",baseCls:"ux-arrowcollapse",recordClass:null,app:null,contentTypes:null,contentType:null,initComponent:function(){Tine.widgets.ContentTypeTreePanel.superclass.initComponent.call(this);var a=new Ext.tree.TreeNode({expanded:true,text:"",allowDrag:false,allowDrop:false,icon:false});this.setRootNode(a);var a=this.getRootNode();this.recordClass=Tine[this.app.appName].Model[this.contentType];Ext.each(this.contentTypes,function(c){var b=c.meta?c.meta.modelName:c.model;var d=Tine[this.app.appName].Model[b];if(c.requiredRight&&(!Tine.Tinebase.common.hasRight(c.requiredRight,this.app.appName,d.getMeta("recordsName").toLowerCase()))){return true}var f=new Ext.tree.TreeNode({id:"treenode-"+d.getMeta("modelName"),iconCls:this.app.appName+b,text:d.getRecordsName(),leaf:true,containerType:Tine.Tinebase.container.TYPE_SHARED,container:Ext.apply(Tine[this.app.name].registry.get("defaultContainer"),{name:this.app.i18n._hidden(d.getMeta("containerName"))})});f.on("click",function(){this.app.getMainScreen().activeContentType=b;this.app.getMainScreen().show()},this);if(c.genericCtxActions){this["contextMenu"+b]=Tine.widgets.tree.ContextMenu.getMenu({nodeName:this.app.i18n._hidden(d.getMeta("recordsName")),actions:c.genericCtxActions,scope:this,backend:"Tinebase_Container",backendModel:"Container"});f.on("contextmenu",function(h,g){if(h.leaf){this.ctxNode=h;this["contextMenu"+b].showAt(g.getXY())}},this)}a.appendChild(f)},this)},afterRender:function(){Tine.widgets.ContentTypeTreePanel.superclass.afterRender.call(this);var a=this.root.findChildBy(function(b){if(b.id=="treenode-"+this.contentType){return true}return false},this);if(a){a.select()}this.on("click",function(b){if(a){a.select()}},this)}});Ext.ns("Tine.widgets.form");Tine.widgets.form.RecordPickerManager=function(){var a={};return{get:function(b,d,f){f=f||{};var b=Ext.isString(b)?b:b.appName,d=Ext.isFunction(d)?d.getMeta("modelName"):d,g=b+d;if(a[g]){if(Ext.isString(a[g])){return Ext.ComponentMgr.create(f,a[g])}else{return new a[g](f)}}else{var c={recordClass:Tine.Tinebase.data.RecordMgr.get(b,d),recordProxy:Tine[b][d.toLowerCase()+"Backend"],loadingText:_("Searching...")};Ext.apply(c,f);return new Tine.Tinebase.widgets.form.RecordPickerComboBox(c)}},register:function(b,c,d){if(!Tine.hasOwnProperty("log")){this.register.defer(100,this,[b,c,d]);return false}var b=Ext.isString(b)?b:b.appName,c=Ext.isFunction(c)?c.getMeta("modelName"):c,f=b+c;if(!a[f]){Tine.log.debug("RecordPickerManager::registerItem: "+b+c);a[f]=d}}}}();Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.AddToRecordPanel=Ext.extend(Ext.FormPanel,{appName:null,recordClass:null,selectionFilter:null,count:null,callingApp:null,callingModel:null,addRelations:null,app:null,layout:"fit",border:false,cls:"tw-editdialog",labelAlign:"top",anchor:"100% 100%",deferredRender:false,buttonAlign:null,bufferResize:500,initComponent:function(){if(!this.app){this.app=Tine.Tinebase.appMgr.get(this.appName)}Tine.log.debug("initComponent: appName: ",this.appName);Tine.log.debug("initComponent: app: ",this.app);this.initActions();this.initButtons();this.items=this.getFormItems();Tine.widgets.dialog.AddToRecordPanel.superclass.initComponent.call(this)},initActions:function(){this.action_cancel=new Ext.Action({text:_("Cancel"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_cancel"});this.action_update=new Ext.Action({text:_("Ok"),minWidth:70,scope:this,handler:this.onUpdate,iconCls:"action_saveAndClose"})},initButtons:function(){this.fbar=["->",this.action_cancel,this.action_update]},onRender:function(b,a){Tine.widgets.dialog.AddToRecordPanel.superclass.onRender.call(this,b,a);new Ext.KeyMap(this.el,[{key:[10,13],ctrl:true,fn:this.onUpdate,scope:this}])},onCancel:function(){this.fireEvent("cancel");this.purgeListeners();this.window.close()},isValid:Ext.emptyFn,getFormItems:Ext.emptyFn,getRelationConfig:function(){return{}},getRecord:function(){var b=this.searchBox.getValue(),a=this.searchBox.store.getById(b);return a},onUpdate:function(){if(this.isValid()){if(this.app){var a=this.app.getMainScreen();if(a){var b=a.getCenterPanel()}}b.onEditInNewWindow({actionType:"edit"},this.getRecord()?this.getRecord():this.searchBox.selectedRecord,[{ptype:"addrelations_edit_dialog",selectionFilter:this.selectionFilter,addRelations:this.addRelations,relationConfig:this.getRelationConfig(),callingApp:this.callingApp,callingModel:this.callingModel}]);this.onCancel()}}});
/*
 * Ext JS Library 3.3.0
 * Copyright(c) 2006-2010 Ext JS, Inc.
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.ns("Ext.ux");Ext.ux.FieldLabeler=(function(){function a(b){for(var c=this.ownerCt;c;c=c.ownerCt){if(c[b]){return c[b]}}}return{init:function(b){b.onRender=b.onRender.createSequence(this.onRender);b.onResize=this.onResize;b.onDestroy=b.onDestroy.createSequence(this.onDestroy)},onRender:function(){if(this.ownerCt){if(this.ownerCt.layout instanceof Ext.layout.FormLayout){return}}this.resizeEl=(this.wrap||this.el).wrap({cls:"x-form-element",style:(Ext.isIE||Ext.isOpera)?"position:absolute;top:0;left:0;overflow:visible":""});this.positionEl=this.itemCt=this.resizeEl.wrap({cls:"x-form-item "});if(this.nextSibling()){this.margins={top:0,right:0,bottom:this.positionEl.getMargins("b"),left:0}}this.actionMode="itemCt";if(!Ext.isDefined(this.hideLabels)){this.hideLabels=a.call(this,"hideLabels")}if(this.hideLabels){this.resizeEl.setStyle("padding-left","0px");return}if(!Ext.isDefined(this.labelSeparator)){this.labelSeparator=a.call(this,"labelSeparator")}if(!Ext.isDefined(this.labelPad)){this.labelPad=a.call(this,"labelPad")}if(!Ext.isDefined(this.labelAlign)){this.labelAlign=a.call(this,"labelAlign")||"left"}this.itemCt.addClass("x-form-label-"+this.labelAlign);if(this.labelAlign=="top"){if(!this.labelWidth){this.labelWidth="auto"}this.resizeEl.setStyle("padding-left","0px")}else{if(!Ext.isDefined(this.labelWidth)){this.labelWidth=a.call(this,"labelWidth")||100}this.resizeEl.setStyle("padding-left",(this.labelWidth+(this.labelPad||5))+"px");this.labelWidth+="px"}this.label=this.itemCt.insertFirst({tag:"label",cls:"x-form-item-label",style:{width:this.labelWidth},html:this.fieldLabel+(this.labelSeparator||":")})},onResize:function(b,c){Ext.form.Field.prototype.onResize.apply(this,arguments);b-=this.resizeEl.getPadding("l");if(this.getTriggerWidth){this.wrap.setWidth(b);this.el.setWidth(b-this.getTriggerWidth())}else{this.el.setWidth(b)}if(this.el.dom.tagName.toLowerCase()=="textarea"){var c=this.resizeEl.getHeight(true);if(!this.hideLabels&&(this.labelAlign=="top")){c-=this.label.getHeight()}this.el.setHeight(c)}},onDestroy:function(){this.itemCt.remove()}}})();Ext.applyIf(Array.prototype,{getMigration:function(a){return{toDelete:this.diff(a),toCreate:a.diff(this),toUpdate:this.intersect(a)}},diff:function(){var b=[],c=[];for(var a=0;a<arguments.length;a++){b=b.concat(arguments[a])}Ext.each(this,function(d){if(b.indexOf(d)<0){c.push(d)}},this);return c},map:function(a){var b=[];Ext.each(this,function(c,d){b.push(a.call(this,c,d))},this);return b},intersect:function(){var c=[],a=[];for(var b=0;b<arguments.length;b++){c=c.concat(arguments[b])}Ext.each(this,function(d){if(c.indexOf(d)>=0){a.push(d)}},this);return a},unique:function(){return Ext.unique(this)}});Ext.ns("Ext.ux");Ext.ux.log=window.console||{};Ext.apply(Ext.ux.log,{PRIO:7,priorities:{EMERG:0,ALERT:1,CRIT:2,ERR:3,ERROR:3,WARN:4,NOTICE:5,INFO:6,DEBUG:7,TRACE:8},prioLogFnMap:{EMERG:console.error,ALERT:console.error,CRIT:console.error,ERR:console.error,ERROR:console.error,WARN:console.warn,NOTICE:console.info,INFO:console.info,DEBUG:console.log,TRACE:console.log},getPrio:function(){return this.PRIO},setPrio:function(b){this.PRIO=b;for(var a in this.priorities){this[a]=this[a.toLowerCase()]=b>=this.priorities[a]?this.prioLogFnMap[a]:Ext.emptyFn}}});Ext.onReady(function(){Ext.ux.log.setPrio(Ext.LOGLEVEL);Ext.ux.log.debug("logger initialized")});Ext.ns("Ext.ux");Ext.ux.ConnectionStatus=function(a){Ext.apply(this,a);Ext.ux.ConnectionStatus.superclass.constructor.call(this)};Ext.extend(Ext.ux.ConnectionStatus,Ext.Button,{showIcon:true,status:"unknown",iconCls:"x-ux-connectionstatus-unknown",isSuppoeted:null,handler:function(){if(this.isSuppoeted){this.toggleStatus()}},initComponent:function(){Ext.ux.ConnectionStatus.superclass.initComponent.call(this);this.onlineText="("+_("online")+")";this.offlineText="("+_("offline")+")";this.unknownText="("+_("unknown")+")";if(Ext.isIE6||Ext.isIE7||!window.navigator||window.navigator.onLine===undefined){this.setStatus("unknown");this.isSupported=false}else{this.setStatus(window.navigator.onLine?"online":"offline");this.isSupported=true}Ext.getBody().on("offline",function(){this.setStatus("offline",true)},this);Ext.getBody().on("online",function(){this.setStatus("online",true)},this)},toggleStatus:function(){this.setStatus(this.status=="online"?"offline":"online")},setIconClass:function(a){this.supr().setIconClass.call(this,this.showIcon?a:"")},setStatus:function(a){switch(a){case"online":this.status=a;this.setText(this.onlineText);this.setIconClass("x-ux-connectionstatus-online");break;case"offline":this.status=a;this.setText(this.offlineText);this.setIconClass("x-ux-connectionstatus-offline");break;case"unknown":this.status=a;this.setText(this.unknownText);this.setIconClass("x-ux-connectionstatus-unknown");this.hide();break;default:console.error('no such status:"'+a+'"');break}}});Ext.ns("Ext.ux.direct");Ext.ux.direct.JsonRpcProvider=Ext.extend(Ext.direct.RemotingProvider,{useNamedParams:false,initAPI:function(){for(var c in this.services){var a=c.split(".");var b=this.namespace[a[0]]||(this.namespace[a[0]]={});b[a[1]]=this.createMethod(a[0],Ext.apply(this.services[c],{name:a[1],len:this.services[c].parameters.length}))}},doCall:function(g,a,b){if(b[b.length-1].paramsAsHash){var f=b.shift();for(var d=0;d<a.parameters.length;d++){b.splice(d,0,f[a.parameters[d].name])}}return Ext.ux.direct.JsonRpcProvider.superclass.doCall.call(this,g,a,b)},getCallData:function(b){var d=b.action+"."+b.method,a=b.provider.services[d],c=b.data||[];if(this.useNamedParams){var c={};Ext.each(a.parameters,function(g,f){c[g.name]=b.data[f]},this)}return{jsonrpc:"2.0",method:d,params:c,id:b.tid}},onData:function(b,d,c){var a=[].concat(Ext.decode(c.responseText));c.responseText=[];Ext.each(a,function(g,f){c.responseText[f]={type:g.result?"rpc":"exception",result:g.result,tid:g.id,error:g.error};if(c.responseText[f].type==="rpc"){delete c.responseText.error}});return Ext.ux.direct.JsonRpcProvider.superclass.onData.apply(this,arguments)}});Ext.Direct.PROVIDERS.jsonrpcprovider=Ext.ux.direct.JsonRpcProvider;Ext.ns("Ext.ux");Ext.ux.DatePickerWeekPlugin=function(a){Ext.apply(this,a||{})};Ext.ux.DatePickerWeekPlugin.prototype={weekHeaderString:"WK",init:function(a){a.onRender=a.onRender.createSequence(this.onRender,a);a.update=a.update.createSequence(this.update,a);a.handleDateClick=a.handleDateClick.createSequence(this.handleDateClick,a);a.showMonthPicker=a.showMonthPicker.createInterceptor(this.inspectMonthPickerClick,a);a.weekHeaderString=this.weekHeaderString;a.getRowEl=this.getRowEl.createDelegate(a);a.selectWeek=this.selectWeek.createDelegate(a);a.clearSelection=this.clearSelection.createDelegate(a);a.onWkCellOver=this.onWkCellOver.createDelegate(a);a.onWkCellOut=this.onWkCellOut.createDelegate(a)},onRender:function(){var b=Ext.DomQuery.selectNode("table[class=x-date-inner]",this.getEl().dom);var a=Ext.DomQuery.select("tr",b);for(var d,c=0;c<a.length;c++){d=Ext.DomHelper.insertFirst(a[c],c==0?'<th class="x-date-picker-wk-hd">'+this.weekHeaderString+"</th>":'<td class="x-date-picker-wk"><a class="x-date-date" tabindex="1" hidefocus="on" href="#"><em><span>'+c+"</span></em></td>");Ext.get(d).addListener({scope:this,mouseover:this.onWkCellOver,mouseout:this.onWkCellOut})}this.update(this.value)},onWkCellOver:function(c,a){var b=c.getTarget("tr",10,true);b.addClass("x-date-picker-wk-wkrowover")},onWkCellOut:function(c,a){var b=c.getTarget("tr",10,true);b.removeClass("x-date-picker-wk-wkrowover")},update:function(g,l,a){var d=g.getFirstDateOfMonth(),j=d.getDay()-this.startDay;if(j<0){j+=7}var f=d.add(Date.DAY,-1*j+1);var b=Ext.DomQuery.select("td[class=x-date-picker-wk]",this.getEl().dom);for(var h=0,c;h<b.length;h++){c=Ext.id()+":"+f.add(Date.DAY,h*7).format("Y-m-d");b[h].firstChild.firstChild.innerHTML='<span id="'+c+'">'+f.add(Date.DAY,h*7).getWeekOfYear()+"</span>"}if(a){this.clearSelection();if(!Ext.isArray(a)){a=[a]}for(var h=0,k;h<a.length;h++){k=this.getRowEl(a[h]);this.selectWeek(k)}}},handleDateClick:function(c){target=c.getTarget("td[class=x-date-picker-wk]");if(target){var d=target.parentNode;var a=target.firstChild.firstChild.firstChild.innerHTML;if(Ext.DomQuery.select("td[class=x-date-prevday]",d).length>3){this.showPrevMonth()}else{if(Ext.DomQuery.select("td[class=x-date-nextday]",d).length>4){this.showNextMonth()}}d=this.getRowEl(a);var b=Date.parseDate(d.firstChild.firstChild.firstChild.firstChild.id.split(":")[1],"Y-m-d");this.setValue(b);this.clearSelection();this.selectWeek(d);this.fireEvent("select",this,this.value,a)}},getRowEl:function(a){var b=Ext.DomQuery.select("td[class=x-date-picker-wk]",this.getEl().dom);for(var d=0;d<b.length;d++){if(b[d].firstChild.firstChild.firstChild.innerHTML==a){var c=b[d].parentNode;break}}return c},clearSelection:function(){var a=Ext.DomQuery.selectNode("table[class=x-date-inner]",this.getEl().dom);var c=Ext.DomQuery.select("td",a);for(var b=0;b<c.length;b++){Ext.fly(c[b]).removeClass("x-date-selected")}},inspectMonthPickerClick:Ext.emptyFn,selectWeek:function(b){if(b){for(var a=1;a<b.childNodes.length;a++){Ext.fly(b.childNodes[a]).addClass("x-date-selected")}}}};Ext.ns("Ext.ux");Ext.ux.ButtonLockedToggle=Ext.extend(Ext.Button,{enableToggle:true,toggle:function(a){if(a===undefined&&this.pressed){return}a=a===undefined?!this.pressed:a;if(a!=this.pressed){if(a){if(this.el){this.el.addClass("x-btn-pressed")}this.pressed=true;this.fireEvent("toggle",this,true)}else{if(this.el){this.el.removeClass("x-btn-pressed")}this.pressed=false;this.fireEvent("toggle",this,false)}if(this.toggleHandler){this.toggleHandler.call(this.scope||this,this,a)}}}});Ext.reg("btnlockedtoggle",Ext.ux.ButtonLockedToggle);Ext.reg("tbbtnlockedtoggle",Ext.ux.ButtonLockedToggle);if(Ext.grid.GridView.prototype.cellSelectorDepth<6){Ext.grid.GridView.prototype.cellSelectorDepth=6}Ext.ns("Ext.ux");Ext.ux.PercentCombo=Ext.extend(Ext.form.ComboBox,{autoExpand:false,blurOnSelect:false,displayField:"value",valueField:"key",mode:"local",triggerAction:"all",emptyText:"percent ...",lazyInit:false,forceSelection:true,initComponent:function(){Ext.ux.PercentCombo.superclass.initComponent.call(this);if(!this.value){this.value=0}this.store=new Ext.data.SimpleStore({fields:["key","value"],data:[["0","0%"],["10","10%"],["20","20%"],["30","30%"],["40","40%"],["50","50%"],["60","60%"],["70","70%"],["80","80%"],["90","90%"],["100","100%"]]});if(this.autoExpand){this.lazyInit=false;this.on("focus",function(){this.selectByValue(this.getValue());this.onTriggerClick()})}if(this.blurOnSelect){this.on("select",function(){this.fireEvent("blur",this)},this)}},setValue:function(a){a=a?a:0;Ext.ux.PercentCombo.superclass.setValue.call(this,a)}});Ext.reg("extuxpercentcombo",Ext.ux.PercentCombo);Ext.ux.PercentRenderer=function(a){if(!Ext.ux.PercentRenderer.template){Ext.ux.PercentRenderer.template=new Ext.XTemplate('<div class="x-progress-wrap PercentRenderer">','<div class="x-progress-inner PercentRenderer">','<div class="x-progress-bar PercentRenderer" style="width:{percent}%">','<div class="PercentRendererText PercentRenderer">',"<div>{percent}%</div>","</div>","</div>",'<div class="x-progress-text x-progress-text-back PercentRenderer">',"<div>&#160;</div>","</div>","</div>","</div>").compile()}return Ext.ux.PercentRenderer.template.apply({percent:a})};Ext.ux.PercentRendererWithName=function(m,k,c){var g="";if(c.fileRecord){c=c.fileRecord}if(c.get("type")=="folder"){k.css="x-tinebase-typefolder"}else{var f=c.get("contenttype");if(f){var l=f.replace("/","-");k.css=l+"_16x16 "}k.css+="standardFileClass_16x16"}if(!Tine.Tinebase.uploadManager.isHtml5ChunkedUpload()){var b=m;if(typeof m=="object"){b=m.name}if(c.get("status")=="uploading"){k.css="x-tinebase-uploadrow"}return b}if(!Ext.ux.PercentRendererWithName.template){Ext.ux.PercentRendererWithName.template=new Ext.XTemplate('<div class="x-progress-wrap PercentRenderer" style="{display}">','<div class="x-progress-inner PercentRenderer">','<div class="x-progress-bar PercentRenderer" style="width:{percent}%;{additionalStyle}">','<div class="PercentRendererText PercentRenderer">',"{fileName}","</div>","</div>",'<div class="x-progress-text x-progress-text-back PercentRenderer">',"<div>&#160;</div>","</div>","</div>","</div>").compile()}if(m==undefined){return""}var b=m;if(typeof m=="object"){b=m.name}var h=c.get("progress");var d="";if(c.get("status")=="paused"&&h<100){b=_("(paused)")+"&#160;&#160;"+b;d="background-image: url('styles/images/tine20/progress/progress-bg-y.gif') !important;"}var j="width:0px";if(h>-1&&h<100){j="";var a=Ext.ux.PercentRendererWithName.template.apply({percent:h,display:j,fileName:b,additionalStyle:d});return a}else{return b}};Ext.namespace("Tine.Tinebase");Tine.Tinebase.ApplicationStarter={userApplications:null,types:{date:"date",datetime:"date",time:"date",string:"string","boolean":"bool",integer:"int","float":"float"},filters:{Tinebase_Model_Filter_Id:null,Tinebase_Model_Filter_Text:"string",Tinebase_Model_Filter_Date:"date",Tinebase_Model_Filter_DateTime:"date",Tinebase_Model_Filter_Bool:"bool",Tinebase_Model_Filter_ForeignId:"foreign",Tinebase_Model_Filter_Int:"number",Tinebase_Model_Filter_User:"user"},init:function(){if(!Tine.Tinebase.hasOwnProperty("appMgr")){this.init.defer(100,this);return}if(!this.userApplications){this.userApplications=Tine.Tinebase.registry.get("userApplications");this.createStructure(true)}},getField:function(b,a){var c={name:a};if(b.type){c.type=this.types[b.type];switch(b.type){case"datetime":c.dateFormat=Date.patterns.ISO8601Long;break;case"date":c.dateFormat=Date.patterns.ISO8601Long;break;case"time":c.dateFormat=Date.patterns.ISO8601Time;case"foreign":c.type=b.options.app+"."+b.options.model;break}if(b.hasOwnProperty("dateFormat")){c.dateFormat=b.dateFormat}}return c},getGridRenderer:function(c,f,a,b){var d=null;if(c&&f){switch(c.type){case"foreign":d=function(k,l,h){var j=Tine[c.options.app].Model[c.options.model];var m=j.getMeta("titleProperty");return h.get(f)?Ext.util.Format.htmlEncode(h.get(f)[m]):""};break;case"integer":if(c.hasOwnProperty("specialType")){var g=(c.specialType=="bytes1000");d=function(j,h,k){return Tine.Tinebase.common.byteRenderer(j,h,k,2,g)}}break;case"user":d=Tine.Tinebase.common.usernameRenderer;break;case"keyfield":d=Tine.Tinebase.widgets.keyfield.Renderer.get(a,c.name);break;case"date":d=Tine.Tinebase.common.dateRenderer;break;case"datetime":d=Tine.Tinebase.common.dateTimeRenderer;break;case"time":d=Tine.Tinebase.common.timeRenderer;break;case"tag":d=Tine.Tinebase.common.tagsRenderer;break;case"container":d=Tine.Tinebase.common.containerRenderer;break;case"boolean":d=Tine.Tinebase.common.booleanRenderer;break;default:d=function(h){return Ext.util.Format.htmlEncode(h)}}}return d},getFilter:function(s,h,f,l,k){var r=(h&&h.label)?h.label:(f&&f.label)?f.label:null;var g=Tine.Tinebase.appMgr.get(l);if(!r&&(s!="query")){return null}var c={label:g.i18n._(r),field:s};if(h){if(h.hasOwnProperty("options")&&(h.options.hasOwnProperty("jsFilterType")||h.options.hasOwnProperty("jsFilterValueType"))){if(h.options.jsFilterType){c.filtertype=h.options.jsFilterType}if(h.options.jsFilterValueType){c.valueType=h.options.jsFilterValueType}return c}switch(h.filter){case"Tinebase_Model_Filter_Bool":c.valueType=this.filters[h.filter];c.defaultValue=false;break;case"Tinebase_Model_Filter_ForeignId":var j=Ext.extend(Tine.widgets.grid.ForeignRecordFilter,{foreignRecordClass:f.options.app+"."+f.options.model,linkType:"foreignId",ownField:s});var q=l.toLowerCase();var m=f.options.model.toLowerCase();var d=q+"."+m;Tine.widgets.grid.FilterToolbar.FILTERS[d]=j;c={filtertype:d};break;case"Tinebase_Model_Filter_Tag":c={filtertype:"tinebase.tag",app:l};break;case"Tinebase_Model_Filter_Container":c={filtertype:"tine.widget.container.filtermodel",app:l,recordClass:l+"."+k};break;case"Tinebase_Model_Filter_Query":c=Ext.apply(c,{label:_("Quick search"),operators:["contains"]});break;default:if(this.filters[h.filter]){c.valueType=this.filters[h.filter]}else{var t=h.filter.split("_"),o=t[0].toLowerCase()+"."+t[2].toLowerCase();o=o.replace(/filter/g,"");if(Tine.widgets.grid.FilterToolbar.FILTERS[o]){c={filtertype:o}}else{c=null}}}}return c},createStructure:function(a){var c=new Date();Ext.each(this.userApplications,function(g){var f=g.name;Ext.namespace("Tine."+f);if(Tine[f].registry&&Tine[f].registry.get("models")){Tine[f].isAuto=true;var h=Tine[f].registry.get("models");var d=[];Tine[f].i18n=new Locale.Gettext();Tine[f].i18n.textdomain(f);Ext.iterate(h,function(o,k){Ext.namespace("Tine."+f,"Tine."+f+".Model");var r=o+"Array";var s=[];d.push(k);var l={},m=[];Ext.each(k.keys,function(z){s.push(this.getField(k.fields[z],z));l[z]=k.fields[z].standard?k.fields[z].standard:null;if(k.fields[z].label){if(a){var A=this.getGridRenderer(k.fields[z],z,f,o);if(A){Tine.widgets.grid.RendererManager.register(f,o,z,A)}}}},this);if(k.hasOwnProperty("meta")){if(k.meta.hasRelations){s.push("relations")}if(k.meta.hasTags){s.push("tags")}if(k.meta.hasCustomFields||k.meta.hasCustomfields){s.push("customfields")}if(k.meta.hasNotes){s.push("notes")}Ext.iterate(k.filter,function(z,A){var B=this.getFilter(z,A,k.fields[z],f,o);if(B){m.push(B)}},this)}Tine[f].Model[r]=(k.meta&&k.meta.useModlog)?Tine.Tinebase.Model.genericFields.concat(s):s;if(!Tine[f].Model.hasOwnProperty(o)){Tine[f].Model[o]=Tine.Tinebase.data.Record.create(Tine[f].Model[r],Ext.apply(k.meta?k.meta:{},{appName:f,modelName:o}))}Ext.namespace("Tine."+f);var w=o.toLowerCase()+"Backend";if(!Tine[f].hasOwnProperty(w)){Tine[f][w]=new Tine.Tinebase.data.RecordProxy({appName:f,modelName:o,recordClass:Tine[f].Model[o]})}var q=o+"TreePanel";if(!Tine[f].hasOwnProperty(q)){Tine[f][q]=Ext.extend(Tine.widgets.container.TreePanel,{filterMode:"filterToolbar",recordClass:Tine[f].Model[o]})}if(k.meta){if(k.meta.containerProperty){var t=Tine[f].registry.get("default"+o+"Container");if(t){l[k.meta.containerProperty]=t}}if(k.meta.hasNotes){l.notes=[]}if(k.meta.hasTags){l.tags=[]}if(k.meta.hasCustomFields){l.customfields={}}Tine[f].Model[o].getDefaultData=function(){if(!z){var z=Ext.decode(Ext.encode(l))}return z};Tine[f].Model[o].getDefaultData()}if(!Ext.isFunction(Tine[f].Model[o].getFilterModel)){Tine[f].Model[o].getFilterModel=function(){if(!z){var z=Ext.decode(Ext.encode(m))}return z};Tine[f].Model[o].getFilterModel()}var v=o+"FilterPanel";if(!Tine[f].hasOwnProperty(v)){Tine[f][v]=function(z){Ext.apply(this,z);Tine[f][v].superclass.constructor.call(this)};Ext.extend(Tine[f][v],Tine.widgets.persistentfilter.PickerPanel)}if(!Tine[f].hasOwnProperty("MainScreen")){Tine[f].MainScreen=Ext.extend(Tine.widgets.MainScreen,{app:f,contentTypes:d,activeContentType:o})}var u=o+"EditDialog";if(Tine[f].hasOwnProperty(u)){if(k.meta.containerProperty){Tine[f][u].prototype.showContainerSelector=true}if(!Ext.isFunction(Tine[f][u].openWindow)){Tine[f][u].openWindow=function(z){var B=(z.record&&z.record.id)?z.record.id:0;var A=Tine.WindowFactory.getWindow({width:Tine[f][u].prototype.windowWidth?Tine[f][u].prototype.windowWidth:600,height:Tine[f][u].prototype.windowHeight?Tine[f][u].prototype.windowHeight:230,name:Tine[f][u].prototype.windowNamePrefix+B,contentPanelConstructor:"Tine."+f+"."+u,contentPanelConstructorConfig:z});return A}}}var j=o+"GridPanel";if(!Tine[f].hasOwnProperty(j)){Tine[f][j]=Ext.extend(Tine.widgets.grid.GridPanel,{modelConfig:k,app:Tine[f],recordProxy:Tine[f][w],recordClass:Tine[f].Model[o]})}else{Ext.apply(Tine[f][j].prototype,{modelConfig:k,app:Tine[f],recordProxy:Tine[f][w],recordClass:Tine[f].Model[o]})}},this)}},this);var b=new Date()}};Ext.ns("Ext.ux");Ext.ux.PopupWindow=function(a){Ext.apply(this,a);Ext.ux.PopupWindow.superclass.constructor.call(this)};Ext.extend(Ext.ux.PopupWindow,Ext.Component,{url:null,name:"new window",width:500,height:500,modal:false,layout:"fit",title:null,contentPanelConstructor:null,contentPanelConstructorConfig:{},popup:null,windowManager:null,initComponent:function(){if(!this.title){this.title=Tine.title}this.windowManager=Ext.ux.PopupWindowMgr;Ext.ux.PopupWindow.superclass.initComponent.call(this);this.width=Math.min(screen.availWidth,this.width);this.height=Math.min(screen.availHeight,this.height);this.popup=Tine.Tinebase.common.openWindow(this.name,this.url,this.width,this.height);this.windowManager.register(this);this.addEvents({beforeclose:true,render:true,close:true})},rename:function(a){this.windowManager.unregister(this);this.name=this.popup.name=a;this.windowManager.register(this)},setTitle:function(b,a){if(this.popup&&this.popup.document){this.popup.document.title=b}},close:function(){if(this.fireEvent("beforeclose",this)!==false){this.fireEvent("close",this);this.purgeListeners();this.windowManager.unregister(this);this.popup.close()}},onLoad:function(){this.Ext.onReady(function(){},this)},onClose:function(){}});Ext.ux.PopupWindowGroup=function(b){b=b||{};var a=b.mainWindow||window;a.isMainWindow=true;var f={};var c=[];var d=null;var g=function(){var k;for(var l in f){try{var h=new Date().getTime();if(f[l].registerTime&&(f[l].registerTime/1+2000>h/1)){continue}k=f[l].popup.document;if(!Ext.isIE&&!k.defaultView){k=false}}catch(j){k=false}if(!k){c.remove(f[l]);delete f[l]}}};return{register:function(h){h.registerTime=new Date().getTime();g();if(!h.popup){console.error("pure window instead of Ext.ux.PopupWindow got registered")}f[h.name]=h;c.push(h)},unregister:function(h){delete f[h.name];c.remove(h)},get:function(h){g();h=typeof h=="object"?h.name:h;return f[h]},getMainWindow:function(){return a},bringToFront:function(h){h=this.get(h);if(h!=d){h._lastAccess=new Date().getTime();if(h.popup.focus){h.popup.focus()}return true}return false},getBy:function(k,j){g();var l=[];for(var h=c.length-1;h>=0;--h){var m=c[h];if(k.call(j||m,m)!==false){l.push(m)}}return l},each:function(j,h){g();for(var k in f){if(f[k]&&typeof f[k]!="function"){if(j.call(h||f[k],f[k])===false){return}}}}}};try{Ext.ux.PopupWindowMgr=window.opener.Ext.ux.PopupWindowMgr?window.opener.Ext.ux.PopupWindowMgr:new Ext.ux.PopupWindowGroup()}catch(e){Ext.ux.PopupWindowMgr=new Ext.ux.PopupWindowGroup()}Ext.ns("Ext.ux.Notification");Ext.ux.Notification=function(){return{show:function(d,c){var a=window.location.href.replace(/#+.*/,"")+"/images/tine_logo.png";if(window.jetpack!==undefined){jetpack.notifications.show({title:d,body:c,icon:a})}else{if(window.callout!==undefined){callout.notify(d,c,{icon:a,href:document.location.href})}else{if(window.webkitNotifications!==undefined&&window.webkitNotifications.checkPermission()==0){var b=window.webkitNotifications.createNotification(a,d,c);b.show();setTimeout(function(){b.cancel()},15000)}else{Ext.ux.MessageBox.msg(d,c)}}}}}}();Ext.ns("Ext.ux");Ext.ux.WindowFactory=function(a){Ext.apply(this,a);switch(this.windowType){case"Browser":this.windowClass=Ext.ux.PopupWindow;this.windowManager=Ext.ux.PopupWindowMgr;break;case"Ext":this.windowClass=Ext.Window;this.windowManager=Ext.WindowMgr;break;case"Air":this.windowClass=Ext.air.NativeWindow;this.windowManager=Ext.air.NativeWindowManager;break;default:console.error("No such windowType: "+this.windowType);break}};Ext.ux.WindowFactory.prototype={windowClass:null,windowManager:null,getBrowserWindow:function(a){var b=Ext.ux.PopupWindowMgr.get(a.name);if(!b){b=new this.windowClass(a)}Ext.ux.PopupWindowMgr.bringToFront(b);return b},getExtWindow:function(b){b.height=b.height+20;b.width=b.width+16;b.height=Math.min(Ext.getBody().getBox().height,b.height);b.width=Math.min(Ext.getBody().getBox().width,b.width);b.layout=b.layout||"fit";b.items={layout:"card",border:false,activeItem:0,isWindowMainCardPanel:true,items:[this.getCenterPanel(b)]};b.modal=true;var a=new Ext.Window(b);b.items.items[0].window=a;if(b.hasOwnProperty("initShow")&&b.initShow===false){return a}a.show();return a},getCenterPanel:function(c){var b;if(c.contentPanelConstructor){c.contentPanelConstructorConfig=c.contentPanelConstructorConfig||{};var a=c.contentPanelConstructorConfig.listeners;if(a){var f={};for(var j in a){if(a.hasOwnProperty(j)&&j!=="scope"){if(a[j].fn){f[j]=function(){a[j].fn.call(a[j].scope,arguments[0],arguments[1],arguments[2],arguments[3],arguments[4])}}else{f[j]=function(){a[j].call(a.scope,arguments[0],arguments[1],arguments[2],arguments[3],arguments[4])}}}}c.contentPanelConstructorConfig.listeners=f}c.contentPanelConstructorConfig.window=c;if(this.windowType=="Browser"){Tine.Tinebase.ApplicationStarter.init()}var h=c.contentPanelConstructor.split("."),g=window;for(var d=0;d<h.length;d+=1){g=g[h[d]]}b=new g(c.contentPanelConstructorConfig)}else{b=c.items?c.items:{}}return b},getWindow:function(a){var b=(a.modal)?"Ext":this.windowType;a.name=Ext.isString(a.name)?a.name.replace(/[^a-zA-Z0-9_]/g,""):a.name;if(!a.title&&a.contentPanelConstructorConfig&&a.contentPanelConstructorConfig.title){a.title=a.contentPanelConstructorConfig.title;delete a.contentPanelConstructorConfig.title}switch(b){case"Browser":return this.getBrowserWindow(a);case"Ext":return this.getExtWindow(a);case"Air":return this.getAirWindow(a);default:console.error("No such windowType: "+this.windowType);break}}};Ext.ux.SliderTip=Ext.extend(Ext.Tip,{minWidth:10,offsets:[0,-10],init:function(a){a.on("dragstart",this.onSlide,this);a.on("drag",this.onSlide,this);a.on("dragend",this.hide,this);a.on("destroy",this.destroy,this)},onSlide:function(a){this.show();this.body.update(this.getText(a));this.doAutoWidth();this.el.alignTo(a.thumb,"b-t?",this.offsets)},getText:function(a){return a.getValue()}});Ext.ns("Ext.ux");Ext.ux.Wizard=function(a){var b=Ext.apply({layout:"card",activeItem:0,bodyStyle:"paddingTop:15px",defaults:{border:false},buttons:[{text:"Previous",handler:this.movePrevious,scope:this,disabled:true},{text:"Next",handler:this.moveNext,scope:this},{text:"Finish",handler:this.finishHanlder,scope:this,disabled:true},{text:"Cancel",handler:this.hideHanlder,scope:this}]},a||{});this.currentItem=0;this.template=new Ext.Template("Step {current} of {count}");this.mandatorySteps=b.mandatorySteps;Ext.ux.Wizard.superclass.constructor.call(this,b);this.addEvents("leave","activate","finish","cancel");this.on("render",function(){this.footer.addClass("x-panel-footer-wizard");this.footer.insertFirst({html:'<div class="x-panel-footer-wizard-status">&nbsp;</div>'});this.setStatus();return true})};Ext.extend(Ext.ux.Wizard,Ext.Panel,{getCurrentStep:function(){return this.currentItem+1},getStepCount:function(){return this.items.items.length},setCurrentStep:function(a){this.move(a-1)},beforeMove:function(c,a,b){return this.fireEvent("leave",c,a,b)},setStatus:function(){var f=0;var c=1;var h=2;var a=3;var g=(this.getCurrentStep()==1);var b=(this.getCurrentStep()==this.getStepCount());var d=isNaN(parseInt(this.mandatorySteps))?this.getStepCount():Math.min(Math.max(parseInt(this.mandatorySteps),1),this.getStepCount());this.buttons[f].setDisabled(g);this.buttons[c].setDisabled(b);this.buttons[h].setDisabled(!(b||(d<this.getCurrentStep())));this.footer.first("div div",true).firstChild.innerHTML=this.template.applyTemplate({current:this.getCurrentStep(),count:this.getStepCount()})},move:function(a){if(a>=0&&a<this.items.items.length){if(this.beforeMove(this.layout.activeItem,this.items.items[a],a>this.currentItem)){this.layout.setActiveItem(a);this.currentItem=a;this.setStatus();this.fireEvent("activate",this.layout.activeItem)}}},moveNext:function(a,b){this.move(this.currentItem+1)},movePrevious:function(a,b){this.move(this.currentItem-1)},hideHanlder:function(){if(this.fireEvent("cancel")){this.hide()}},finishHanlder:function(){if(this.fireEvent("finish")){this.hide()}}});Ext.ns("Ext.ux");Ext.ux.SearchField=Ext.extend(Ext.form.TwinTriggerField,{paramName:"query",selectOnFocus:true,emptyText:"",validationEvent:false,validateOnBlur:false,trigger1Class:"x-form-clear-trigger",trigger2Class:"x-form-search-trigger",hideTrigger1:true,width:180,hasSearch:false,initComponent:function(){this.emptyText=_("enter searchfilter");Ext.ux.SearchField.superclass.initComponent.call(this);this.on("specialkey",function(a,b){if(b.getKey()==b.ENTER){this.onTrigger2Click()}},this)},onTrigger1Click:function(){if(this.hasSearch){this.el.dom.value="";this.fireEvent("change",this,this.getRawValue(),this.startValue);this.startValue=this.getRawValue();this.triggers[0].hide();this.hasSearch=false}},onTrigger2Click:function(){var a=this.getRawValue();this.fireEvent("change",this,this.getRawValue(),this.startValue);this.startValue=this.getRawValue();this.hasSearch=true;this.triggers[0][a.length<1?"hide":"show"]()}});Ext.ns("Ext.ux.form");Ext.ux.BrowseButton=Ext.extend(Ext.Button,{initComponent:function(){this.plugins=this.plugins||[];this.plugins.push(new Ext.ux.file.BrowsePlugin({}));Ext.ux.BrowseButton.superclass.initComponent.call(this)}});Ext.reg("browsebutton",Ext.ux.BrowseButton);
/*
 * Ext JS Library 3.1.1
 * Copyright(c) 2006-2010 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.ns("Ext.ux.grid");Ext.ux.grid.CheckColumn=function(a){Ext.apply(this,a);if(!this.id){this.id=Ext.id()}this.renderer=this.renderer.createDelegate(this)};Ext.ux.grid.CheckColumn.prototype={init:function(a){this.grid=a;this.grid.on("render",function(){var b=this.grid.getView();b.mainBody.on("mousedown",this.onMouseDown,this)},this)},onMouseDown:function(d,c){if(Ext.fly(c).hasClass(this.createId())){d.stopEvent();var b=this.grid.getView().findRowIndex(c);var a=this.grid.store.getAt(b);a.set(this.dataIndex,!a.data[this.dataIndex])}},renderer:function(b,c,a){c.css+=" x-grid3-check-col-td";return String.format('<div class="x-grid3-check-col{0} {1}">&#160;</div>',b?"-on":"",this.createId())},createId:function(){return"x-grid3-cc-"+this.id}};Ext.preg("checkcolumn",Ext.ux.grid.CheckColumn);Ext.grid.CheckColumn=Ext.ux.grid.CheckColumn;Ext.ns("Ext.ux","Ext.ux.grid");Ext.ux.grid.QuickaddGridPanel=Ext.extend(Ext.grid.EditorGridPanel,{quickaddMandatory:false,validate:false,resetAllOnNew:false,adding:false,initComponent:function(){this.idPrefix=Ext.id();Ext.ux.grid.QuickaddGridPanel.superclass.initComponent.call(this);this.addEvents("newentry");this.cls="x-grid3-quickadd";this.initTemplates();this.getView().afterRender=this.getView().afterRender.createSequence(this.renderQuickAddFields,this);this.quickaddHandlers={scope:this,blur:function(a){this.doBlur.defer(250,this)},specialkey:function(b,c){var a=c.getKey();switch(a){case c.ENTER:c.stopEvent();b.el.blur();if(b.triggerBlur){b.triggerBlur()}break;case c.ESC:c.stopEvent();b.setValue("");b.el.blur();break}}}},renderQuickAddFields:function(){Ext.each(this.getCols(),function(a){if(a.quickaddField){a.quickaddField.render(this.getQuickAddWrap(a));a.quickaddField.setDisabled(a.id!=this.quickaddMandatory);a.quickaddField.on(this.quickaddHandlers)}},this);this.colModel.on("configchange",this.syncFields,this);this.colModel.on("hiddenchange",this.syncFields,this);this.on("resize",this.syncFields);this.on("columnresize",this.syncFields);this.syncFields();this.colModel.getColumnById(this.quickaddMandatory).quickaddField.on("focus",this.onMandatoryFocus,this)},doBlur:function(){var b;Ext.each(this.getCols(true),function(g){if(g.quickaddField&&(g.quickaddField.hasFocus||g.quickaddField.hasFocusedSubPanels||(this.validate&&!g.quickaddField.isValid()))){b=true}},this);if(!b){var f={};Ext.each(this.getCols(true),function(g){if(g.quickaddField){f[g.id]=g.quickaddField.getValue();g.quickaddField.setDisabled(g.id!=this.quickaddMandatory)}},this);if(this.colModel.getColumnById(this.quickaddMandatory).quickaddField.getValue()!=""){if(this.fireEvent("newentry",f)){this.colModel.getColumnById(this.quickaddMandatory).quickaddField.setValue("");if(this.validate){this.colModel.getColumnById(this.quickaddMandatory).quickaddField.clearInvalid()}if(this.resetAllOnNew){var d=this.colModel.config;for(var c=0,a=d.length;c<a;c++){if(d[c].quickaddField!=undefined){d[c].quickaddField.setValue("")}}}}}this.adding=false}},getCols:function(a){if(a===true){var b=[];Ext.each(this.colModel.config,function(c){if(!c.hidden){b.push(c)}},this);return b}return this.colModel.config},getQuickAddWrap:function(a){return Ext.get(this.idPrefix+a.id)},initTemplates:function(){this.getView().templates=this.getView().templates?this.getView().templates:{};var f=this.getView().templates;var c="";var a=this.colModel;var g=a.getColumnCount();for(var b=0;b<g;b++){var d=a.getColumnId(b);c+='<td><div class="x-small-editor" id="'+this.idPrefix+d+'"></div></td>'}f.header=new Ext.Template('<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}">','<thead><tr class="x-grid3-hd-row">{cells}</tr></thead>','<tbody><tr class="new-row">',c,"</tr></tbody>","</table>")},syncFields:function(){var c=Ext.get(Ext.DomQuery.selectNode("tr[class=new-row]",this.getView().mainHd.dom));var b=this.getCols();for(var d,f,a=b.length-1;a>=0;a--){d=b[a];var f=this.getQuickAddWrap(d).parent();c.insertFirst(f);f.dom.style.display=d.hidden?"none":"";if(d.quickaddField){d.quickaddField.setSize(d.width-1)}}},onMandatoryFocus:function(){this.adding=true;Ext.each(this.getCols(true),function(a){if(a.quickaddField){a.quickaddField.setDisabled(false)}},this)}});Ext.ux.grid.RowExpander=function(a){Ext.apply(this,a);this.addEvents({beforeexpand:true,expand:true,beforecollapse:true,collapse:true});Ext.ux.grid.RowExpander.superclass.constructor.call(this);if(this.tpl){if(typeof this.tpl=="string"){this.tpl=new Ext.Template(this.tpl)}this.tpl.compile()}this.state={};this.bodyContent={}};Ext.extend(Ext.ux.grid.RowExpander,Ext.util.Observable,{header:"",width:20,sortable:false,fixed:true,dataIndex:"",id:"expander",lazyRender:true,enableCaching:false,getRowClass:function(a,f,d,c){d.cols=d.cols-1;var b=this.bodyContent[a.id];if(!b&&!this.lazyRender){b=this.getBodyContent(a,f)}if(b){d.body=b}return this.state[a.id]?"x-grid3-row-expanded":"x-grid3-row-collapsed"},init:function(b){this.grid=b;var a=b.getView();a.getRowClass=this.getRowClass.createDelegate(this);a.enableRowBody=true;b.on("render",function(){a.mainBody.on("mousedown",this.onMouseDown,this)},this)},getBodyContent:function(a,b){if(!this.enableCaching){return this.tpl.apply(a.data)}var c=this.bodyContent[a.id];if(!c){c=this.tpl.apply(a.data);this.bodyContent[a.id]=c}return c},onMouseDown:function(b,a){if(a.className=="x-grid3-row-expander"){b.stopEvent();var c=b.getTarget(".x-grid3-row");this.toggleRow(c)}},renderer:function(b,c,a){c.cellAttr='rowspan="2"';return'<div class="x-grid3-row-expander">&#160;</div>'},beforeExpand:function(b,a,c){if(this.fireEvent("beforexpand",this,b,a,c)!==false){if(this.tpl&&this.lazyRender){a.innerHTML=this.getBodyContent(b,c)}return true}else{return false}},toggleRow:function(a){if(typeof a=="number"){a=this.grid.view.getRow(a)}this[Ext.fly(a).hasClass("x-grid3-row-collapsed")?"expandRow":"collapseRow"](a)},expandRow:function(c){if(typeof c=="number"){c=this.grid.view.getRow(c)}var b=this.grid.store.getAt(c.rowIndex);var a=Ext.DomQuery.selectNode("tr:nth(2) div.x-grid3-row-body",c);if(this.beforeExpand(b,a,c.rowIndex)){this.state[b.id]=true;Ext.fly(c).replaceClass("x-grid3-row-collapsed","x-grid3-row-expanded");this.fireEvent("expand",this,b,a,c.rowIndex)}},collapseRow:function(c){if(typeof c=="number"){c=this.grid.view.getRow(c)}var b=this.grid.store.getAt(c.rowIndex);var a=Ext.fly(c).child("tr:nth(1) div.x-grid3-row-body",true);if(this.fireEvent("beforcollapse",this,b,a,c.rowIndex)!==false){this.state[b.id]=false;Ext.fly(c).replaceClass("x-grid3-row-expanded","x-grid3-row-collapsed");this.fireEvent("collapse",this,b,a,c.rowIndex)}}});Ext.ns("Ext.ux.grid");Ext.ux.grid.PagingToolbar=Ext.extend(Ext.PagingToolbar,{displayPageInfo:false,displaySelectionHelper:false,sm:null,disableSelectAllPages:false,initComponent:function(){this.selHelperText={main:_("{0} selected"),deselect:_("Unselect all"),selectall:_("Select all pages ({0} records)"),toggle:_("Toggle selection")};Ext.ux.grid.PagingToolbar.superclass.initComponent.call(this)},onRender:function(b,a){Ext.ux.grid.PagingToolbar.superclass.onRender.call(this,b,a);if(this.displaySelectionHelper){this.renderSelHelper()}},renderSelHelper:function(){this.deselectBtn=new Ext.Action({iconCls:"x-ux-pagingtb-deselect",text:this.getSelHelperText("deselect"),scope:this,handler:function(){this.sm.clearSelections()}});this.selectAllPages=new Ext.Action({iconCls:"x-ux-pagingtb-selectall",text:this.getSelHelperText("selectall"),scope:this,disabled:this.disableSelectAllPages,handler:function(){this.sm.selectAll()}});this.toggleSelectionBtn=new Ext.Action({iconCls:"x-ux-pagingtb-toggle",text:this.getSelHelperText("toggle"),scope:this,handler:function(){this.sm.toggleSelection()}});this.addSeparator();this.selHelperBtn=new Ext.Action({xtype:"tbsplit",text:this.getSelHelperText("main"),iconCls:"x-ux-pagingtb-main",menu:new Ext.menu.Menu({items:[this.deselectBtn,this.selectAllPages,this.toggleSelectionBtn]})});this.add(this.selHelperBtn);this.sm.on("selectionchange",this.updateSelHelper,this);this.store.on("load",this.updateSelHelper,this)},updateSelHelper:function(){this.selHelperBtn.setText(this.getSelHelperText("main"));this.selectAllPages.setText(this.getSelHelperText("selectall"))},getSelHelperText:function(b){var a;switch(b){case"main":a=this.sm.getCount();break;case"selectall":a=this.store.getTotalCount();break;default:return this.selHelperText[b];break}return String.format(this.selHelperText[b],a)}});Ext.ns("Ext.ux.grid");Ext.ux.grid.GridViewMenuPlugin=Ext.extend(Object,{_view:null,_menuBtn:null,colMenu:null,cm:null,init:function(b){if(b.enableHdMenu===true){throw ('Ext.ux.grid.GridViewMenuPlugin - grid\'s "enableHdMenu" property has to be set to "false"')}var a=this._view=b.getView();a.afterMethod("initElements",this.initElements,this);a.afterMethod("initData",this.initData,this);a.afterMethod("onLayout",this._onLayout,this);a.beforeMethod("destroy",this._destroy,this);this.colMenu=new Ext.menu.Menu({listeners:{scope:this,beforeshow:this._beforeColMenuShow,itemclick:this._handleHdMenuClick}});this.colMenu.override({show:function(d,f,c){this.parentMenu=c;if(!this.el){this.render()}this.fireEvent("beforeshow",this);this.showAt(this.el.getAlignToXY(d,f||this.defaultAlign,[Ext.isWebKit?2:1,0]),c,true)}})},_handleHdMenuClick:function(a,b){if(this.colMenu.items.indexOf(a)>1){return this._view.handleHdMenuClick(a,b)}},_beforeColMenuShow:function(a){this._view.beforeColMenuShow.call(this,a);this.colMenu.insert(0,new Ext.menu.Separator());this.colMenu.insert(0,new Ext.menu.TextItem({text:String.format('<img src="{0}" class="x-menu-item-icon x-cols-icon" />{1}',Ext.BLANK_IMAGE_URL,this._view.columnsText),style:"line-height:16px;padding:3px 21px 3px 27px;"}))},_handleHdDown:function(b,a){if(Ext.fly(a).hasClass("x-grid3-hd-btn")){b.stopEvent();this.colMenu.show(a,"tr-br?")}},_getMenuButton:function(){var b=document.createElement("a");b.className="ext-ux-grid-gridviewmenuplugin-menuBtn x-grid3-hd-btn";b.href="#";return new Ext.Element(b)},initData:function(){this.cm=this._view.cm},initElements:function(){this.menuBtn=this._getMenuButton();this._view.mainHd.dom.appendChild(this.menuBtn.dom);this.menuBtn.on("click",this._handleHdDown,this)},_onLayout:function(){if(this._view.mainHd.dom.offsetHeight>1){this.menuBtn.dom.style.height=(this._view.mainHd.dom.offsetHeight-1)+"px"}},_destroy:function(){if(this.colMenu){this.colMenu.removeAll();Ext.menu.MenuMgr.unregister(this.colMenu);if(this.colMenu.getEl()){this.colMenu.getEl().remove()}delete this.colMenu}if(this._menuBtn){this._menuBtn.remove();delete this._menuBtn}}});Ext.ns("Ext.ux.file");Ext.ux.file.UploadManager=function(a){Ext.apply(this,a);Ext.ux.file.UploadManager.superclass.constructor.apply(this,arguments);this.uploads={};this.addEvents("uploadcomplete","uploadfailure","uploadprogress","uploadstart","update")};Ext.extend(Ext.ux.file.UploadManager,Ext.util.Observable,{maxConcurrentUploads:3,runningUploads:0,uploadIdPrefix:"tine-upload-",uploads:null,uploadCount:0,queueUpload:function(a){var b=this.uploadIdPrefix+(1000+this.uploadCount++).toString();if(a.id&&a.id!==-1){b=a.id}a.id=b;this.uploads[b]=a;this.relayEvents(a,["update"]);a.on("uploadcomplete",this.onUploadComplete,this);return b},upload:function(a){return this.uploads[a].upload()},getUpload:function(a){return this.uploads[a]},unregisterUpload:function(a){delete this.uploads[a]},isHtml5ChunkedUpload:function(){if(window.File==undefined){return false}if(this.isHostMethod(File.prototype,"slice")||this.isHostMethod(File.prototype,"mozSlice")||this.isHostMethod(File.prototype,"webkitSlice")){return true}else{return false}},isHostMethod:function(a,c){var b=typeof a[c];return b=="function"||(!!(b=="object"&&a[c]))||b=="unknown"},isBusy:function(){return(this.maxConcurrentUploads==this.runningUploads)},isUploadsPending:function(){return(this.uploads.length>0)},onUploadComplete:function(){Tine.Tinebase.uploadManager.runningUploads=Math.max(0,Tine.Tinebase.uploadManager.runningUploads-1);for(var b in Tine.Tinebase.uploadManager.uploads){var a=Tine.Tinebase.uploadManager.uploads[b];if(a.isQueued()&&!a.isPaused()&&!Tine.Tinebase.uploadManager.isBusy()){a.setQueued(false);a.resumeUpload();break}}},onUploadStart:function(){Tine.Tinebase.uploadManager.runningUploads=Math.min(Tine.Tinebase.uploadManager.maxConcurrentUploads,Tine.Tinebase.uploadManager.runningUploads+1)}});Ext.ns("Ext.ux.file");Ext.ux.file.Upload=function(a){Ext.apply(this,a);Ext.ux.file.Upload.superclass.constructor.apply(this,arguments);this.addEvents("uploadcomplete","uploadfailure","uploadprogress","uploadstart","update");if(!this.file&&this.fileSelector){this.file=this.fileSelector.getFileList()[0]}this.fileSize=(this.file.size?this.file.size:this.file.fileSize);this.maxChunkSize=this.maxPostSize-16384;this.currentChunkSize=this.maxChunkSize;this.tempFiles=[]};Ext.extend(Ext.ux.file.Upload,Ext.util.Observable,{id:-1,maxFileUploadSize:20971520,maxPostSize:20971520,maxChunkSize:20955136,minChunkSize:102400,MAX_RETRY_COUNT:10,RETRY_TIMEOUT_MILLIS:3000,CHUNK_TIMEOUT_MILLIS:100,url:"index.php",fileSelector:null,fileRecord:null,currentChunk:null,uploadPath:"/",file:null,paused:false,queued:false,tempFiles:new Array(),lastChunkUploadFailed:false,currentChunk:null,retryCount:0,currentChunkSize:0,currentChunkPosition:0,fileSize:0,createForm:function(){var a=Ext.getBody().createChild({tag:"form",action:this.url,method:"post",cls:"x-hidden",id:Ext.id(),cn:[{tag:"input",type:"hidden",name:"MAX_FILE_SIZE",value:this.maxFileUploadSize}]});return a},upload:function(){if(((!Ext.isGecko&&window.XMLHttpRequest&&window.File&&window.FileList)||(Ext.isGecko&&window.FileReader))&&this.file){this.getInput();if(this.isHtml5ChunkedUpload()){var b=this.maxChunkSize;var c=this.minChunkSize;var a=this.maxChunkSize;if(this.fileSize>5*b){a=b}else{a=Math.max(c,this.fileSize/5)}this.maxChunkSize=a;if(Tine.Tinebase.uploadManager&&Tine.Tinebase.uploadManager.isBusy()){this.createFileRecord(true);this.setQueued(true)}else{this.createFileRecord(false);this.fireEvent("uploadstart",this);this.fireEvent("update","uploadstart",this,this.fileRecord);this.html5ChunkedUpload()}return this.fileRecord}else{this.createFileRecord(false);this.fireEvent("uploadstart",this);this.fireEvent("update","uploadstart",this,this.fileRecord);this.html5upload();return this.fileRecord}}else{return this.html4upload()}},html5upload:function(){if(this.maxPostSize/1<this.file.size/1&&!this.isHtml5ChunkedUpload()){this.fileRecord.html5upload=true;this.onUploadFail(null,null,this.fileRecord);return this.fileRecord}var c={"Content-Type":"application/x-www-form-urlencoded","X-Tine20-Request-Type":"HTTP","X-Requested-With":"XMLHttpRequest"};var a=this.file;if(this.isHtml5ChunkedUpload()){a=this.currentChunk}var b=new Ext.data.Connection({disableCaching:true,method:"POST",url:this.url+"?method=Tinebase.uploadTempFile",timeout:300000,defaultHeaders:c});var d=b.request({headers:{"X-File-Name":this.fileRecord.get("name"),"X-File-Type":this.fileRecord.get("type"),"X-File-Size":this.fileRecord.get("size")},xmlData:a,success:this.onUploadSuccess.createDelegate(this,null,true),failure:this.onUploadFail.createDelegate(this,null,true)});return this.fileRecord},html5ChunkedUpload:function(){this.prepareChunk();this.html5upload()},resumeUpload:function(){this.setPaused(false);this.html5ChunkedUpload()},prepareChunk:function(){if(this.lastChunkUploadFailed){this.currentChunkPosition=Math.max(0,this.currentChunkPosition-this.currentChunkSize);this.currentChunkSize=Math.max(this.minChunkSize,this.currentChunkSize/2)}else{this.currentChunkSize=Math.min(this.maxChunkSize,this.currentChunkSize*2)}this.lastChunkUploadFailed=false;var b=Math.min(this.fileSize,this.currentChunkPosition+this.currentChunkSize);var a=this.sliceFile(this.file,this.currentChunkPosition,b);if(b/1==this.fileSize/1){this.lastChunk=true}this.currentChunkPosition=b;this.currentChunk=a},finishUploadRecord:function(a){a=Ext.util.JSON.decode(a.responseText);if(a.tempFile){a=a.tempFile}if(a.error==0){this.fileRecord.beginEdit();this.fileRecord.set("size",a.size);this.fileRecord.set("id",a.id);this.fileRecord.set("progress",99);this.fileRecord.set("tempFile","");this.fileRecord.set("tempFile",a);this.fileRecord.commit(false);this.fireEvent("uploadcomplete",this,this.fileRecord);this.fireEvent("update","uploadcomplete",this,this.fileRecord)}else{this.fileRecord.beginEdit();this.fileRecord.set("status","failure");this.fileRecord.set("progress",-1);this.fileRecord.set("tempFile","");this.fileRecord.set("tempFile",a);this.fileRecord.commit(false);this.fireEvent("update","uploadfailure",this,this.fileRecord)}},onUploadSuccess:function(c,d,b){var a=Ext.util.JSON.decode(c.responseText);this.retryCount=0;if(a.status&&a.status!=="success"){this.onUploadFail(a,d,b)}this.fileRecord.beginEdit();this.fileRecord.set("tempFile",a.tempFile);this.fileRecord.set("size",0);this.fileRecord.commit(false);this.fireEvent("update","uploadprogress",this,this.fileRecord);if(!this.isHtml5ChunkedUpload()){this.finishUploadRecord(c)}else{this.addTempfile(this.fileRecord.get("tempFile"));var f=parseInt(this.currentChunkPosition*100/this.fileSize/1);if(this.lastChunk){f=98}this.fileRecord.beginEdit();this.fileRecord.set("progress",f);this.fileRecord.commit(false);if(this.lastChunk){window.setTimeout((function(){Ext.Ajax.request({timeout:10*60*1000,params:{method:"Tinebase.joinTempFiles",tempFilesData:this.tempFiles},success:this.finishUploadRecord.createDelegate(this),failure:this.finishUploadRecord.createDelegate(this)})}).createDelegate(this),this.CHUNK_TIMEOUT_MILLIS)}else{window.setTimeout((function(){if(!this.isPaused()){this.prepareChunk();this.html5upload()}}).createDelegate(this),this.CHUNK_TIMEOUT_MILLIS)}}},onUploadFail:function(b,c,a){if(this.isHtml5ChunkedUpload()){this.lastChunkUploadFailed=true;this.retryCount++;if(this.retryCount>this.MAX_RETRY_COUNT){this.fileRecord.beginEdit();this.fileRecord.set("status","failure");this.fileRecord.endEdit();this.fireEvent("update","uploadfailure",this,this.fileRecord)}else{window.setTimeout((function(){this.prepareChunk();this.html5upload()}).createDelegate(this),this.RETRY_TIMEOUT_MILLIS)}}else{this.fileRecord.beginEdit();this.fileRecord.set("status","failure");this.fileRecord.endEdit();this.fireEvent("update","uploadfailure",this,this.fileRecord)}},html4upload:function(){var b=this.createForm();var a=this.getInput();b.appendChild(a);this.fileRecord=new Ext.ux.file.Upload.file({name:this.fileSelector.getFileName(),size:0,type:this.fileSelector.getFileCls(),input:a,form:b,status:"uploading",progress:0});this.fireEvent("update","uploadprogress",this,this.fileRecord);if(this.maxFileUploadSize/1<this.file.size/1){this.fileRecord.html4upload=true;this.onUploadFail(null,null,this.fileRecord);return this.fileRecord}Ext.Ajax.request({fileRecord:this.fileRecord,isUpload:true,method:"post",form:b,success:this.onUploadSuccess.createDelegate(this,[this.fileRecord],true),failure:this.onUploadFail.createDelegate(this,[this.fileRecord],true),params:{method:"Tinebase.uploadTempFile",requestType:"HTTP"}});return this.fileRecord},createFileRecord:function(b){var a="uploading";if(b){a="pending"}this.fileRecord=new Ext.ux.file.Upload.file({name:this.file.name?this.file.name:this.file.fileName,type:(this.file.type?this.file.type:this.file.fileType),size:0,status:a,progress:0,input:this.file,uploadKey:this.id});this.fireEvent("update","uploadprogress",this,this.fileRecord)},addTempfile:function(a){this.tempFiles.push(a);return true},getTempfiles:function(){return this.tempFiles},setPaused:function(b){this.paused=b;var a="paused";if(!this.paused){a="uploading"}this.fileRecord.beginEdit();this.fileRecord.set("status",a);this.fileRecord.endEdit();this.fireEvent("update","uploadpaused",this,this.fileRecord)},isPaused:function(){return this.paused},isHostMethod:function(a,c){var b=typeof a[c];return b=="function"||(!!(b=="object"&&a[c]))||b=="unknown"},isHtml5ChunkedUpload:function(){if(window.File==undefined){return false}if(this.isHostMethod(File.prototype,"slice")||this.isHostMethod(File.prototype,"mozSlice")||this.isHostMethod(File.prototype,"webkitSlice")){return this.fileSize>this.minChunkSize}else{return false}},getInput:function(){if(!this.input){this.input=this.fileSelector.detachInputFile()}return this.input},sliceFile:function(b,d,a,c){if(b.slice){return b.slice(d,a)}else{if(b.mozSlice){return b.mozSlice(d,a,c)}else{if(b.webkitSlice){return b.webkitSlice(d,a)}else{return false}}}},setQueued:function(b){this.queued=b;var a="queued";if(!this.queued){a="uploading"}this.fileRecord.beginEdit();this.fileRecord.set("status",a);this.fileRecord.endEdit();this.fireEvent("update","uploadqueued",this,this.fileRecord)},isQueued:function(){return this.queued}});Ext.ux.file.Upload.file=Ext.data.Record.create([{name:"id",type:"text",system:true},{name:"uploadKey",type:"text",system:true},{name:"name",type:"text",system:true},{name:"size",type:"number",system:true},{name:"type",type:"text",system:true},{name:"status",type:"text",system:true},{name:"progress",type:"number",system:true},{name:"form",system:true},{name:"input",system:true},{name:"request",system:true},{name:"path",system:true},{name:"tempFile",system:true}]);Ext.ux.file.Upload.file.getFileData=function(a){return Ext.copyTo({},a.data,["tempFile","name","path","size","type"])};Ext.ns("Ext.ux.file");Ext.ux.file.BrowsePlugin=function(a){Ext.apply(this,a)};Ext.ux.file.BrowsePlugin.prototype={multiple:false,dropEl:null,enableFileDrop:true,enableFileDialog:true,inputFileName:"file",onBrowseButtonClick:Ext.emptyFn,input_file:null,handler:null,scope:null,currentTreeNodeUI:null,init:function(a){if(a.handler){this.handler=a.handler}this.scope=a.scope||window;a.handler=null;a.scope=null;this.component=a;a.on("afterrender",this.onRender,this);a.on("show",this.syncWrap,this);a.on("resize",this.syncWrap,this);a.on("afterlayout",this.syncWrap,this);if(typeof a.setDisabled=="function"){a.setDisabled=a.setDisabled.createSequence(function(b){if(this.input_file){this.input_file.dom.disabled=b}},this)}if(typeof a.enable=="function"){a.enable=a.enable.createSequence(function(){if(this.input_file){this.input_file.dom.disabled=false}},this)}if(typeof a.disable=="function"){a.disable=a.disable.createSequence(function(){if(this.input_file){this.input_file.dom.disabled=true}},this)}if(typeof a.destroy=="function"){a.destroy=a.destroy.createSequence(function(){var b=this.detachInputFile(true);if(b){b.remove()}b=null},this)}},onRender:function(){this.button_container=this.buttonCt||this.component.el.child("tbody")||this.component.el;this.button_container.position("relative");this.wrap=this.component.el.wrap({cls:"tbody"});if(this.component.ownerCt&&this.component.btnEl){this.component.ownerCt.on("afterlayout",function(){if(this.wrap.first()!==this.component.el){this.wrap.insertBefore(this.component.el);this.wrap.insertFirst(this.component.el)}this.syncWrap()},this);this.component.ownerCt.on("show",this.syncWrap,this);this.component.ownerCt.on("resize",this.syncWrap,this)}if(this.enableFileDialog){this.createInputFile()}if(this.enableFileDrop&&!Ext.isIE){if(!this.dropEl){if(this.dropElSelector){this.dropEl=this.wrap.up(this.dropElSelector)}else{this.dropEl=this.button_container}}this.dropEl.on("dragleave",function(a){a.stopPropagation();a.preventDefault();this.createMouseEvent(a,"mouseout")},this);this.dropEl.on("dragover",function(a){a.stopPropagation();a.preventDefault();this.createMouseEvent(a,"mouseover")},this);this.dropEl.on("drop",function(d,c){d.stopPropagation();d.preventDefault();this.onBrowseButtonClick();var b=d.browserEvent.dataTransfer;var a=b.files;this.onInputFileChange(d,null,null,a)},this)}},syncWrap:function(){if(this.button_container){var a=this.button_container.getSize();this.wrap.setSize(a)}},createInputFile:function(){this.input_file=this.wrap.createChild(Ext.apply({tag:"input",type:"file",size:1,name:this.inputFileName||Ext.id(this.component.el),style:"position: absolute; display: block; border: none; cursor: pointer;"},this.multiple?{multiple:true}:{}));this.input_file.dom.disabled=this.component.disabled;var a=this.button_container.getBox();this.wrap.setBox(a);this.wrap.applyStyles("overflow: hidden; position: relative;");this.wrap.on("mousemove",function(g){var f=g.getXY();this.input_file.setXY([f[0]-this.input_file.getWidth()/2,f[1]-5]);if(this.component.btnEl){var c=Ext.get(this.wrap.dom);var b=c.getX(),h=c.getWidth(),d=f[0];if(d-b>this.component.btnEl.dom.clientWidth){this.input_file.dom.style.zIndex=-1}else{this.input_file.dom.style.zIndex=""}}},this,{buffer:20});this.button_container.on("mousemove",function(g){var f=g.getXY();this.input_file.setXY([f[0]-this.input_file.getWidth()/2,f[1]-5]);if(this.component.btnEl){var c=Ext.get(this.button_container.dom);var b=c.getX(),h=c.getWidth(),d=f[0];if(d-b>this.component.btnEl.dom.clientWidth){this.input_file.dom.style.zIndex=-1}else{this.input_file.dom.style.zIndex=""}}},this,{buffer:30});this.input_file.setOpacity(0);Ext.fly(this.input_file).on("click",function(b){this.onBrowseButtonClick()},this);if(!this.supressOverFix&&Ext.isFunction(this.component.onMouseOut)){this.component.onMouseOut=this.component.onMouseOut.createInterceptor(function(b){if(this.isMouseOver){return false}this.isMouseOver=false},this);this.wrap.on("mouseover",function(b){this.isMouseOver=true;if(this.component.el.hasClass("x-btn")&&!this.component.disabled){this.component.el.addClass("x-btn-over")}},this);this.wrap.on("mouseout",function(b){this.isMouseOver=false;if(this.component.el.hasClass("x-btn")&&!this.component.disabled){this.component.el.removeClass("x-btn-over")}},this)}if(this.component.handleMouseEvents){this.wrap.on("mouseover",this.component.onMouseOver||Ext.emptyFn,this.component);this.wrap.on("mousedown",this.component.onMouseDown||Ext.emptyFn,this.component);this.wrap.on("contextmenu",this.component.onContextMenu||Ext.emptyFn,this.component)}if(this.component.tooltip){if(typeof this.component.tooltip=="object"){Ext.QuickTips.register(Ext.apply({target:this.input_file},this.component.tooltip))}else{this.input_file.dom[this.component.tooltipType]=this.component.tooltip}}this.input_file.on("change",this.onInputFileChange,this);this.input_file.on("click",function(b){b.stopPropagation()})},onInputFileChange:function(d,c,a,b){if(window.FileList){this.files=b?b:this.input_file.dom.files}else{this.files=[{name:this.input_file.getValue().split(/[\/\\]/).pop()}];this.files[0].type=this.getFileCls()}if(this.handler){this.handler.call(this.scope,this,d)}},detachInputFile:function(b){var a=this.input_file;b=b||false;if(this.input_file){if(typeof this.component.tooltip=="object"){Ext.QuickTips.unregister(this.input_file)}else{this.input_file.dom[this.component.tooltipType]=null}this.input_file.removeAllListeners()}this.input_file=null;if(this.enableFileDialog&&!b){this.createInputFile()}return a},getFileList:function(){return this.files},getInputFile:function(){return this.input_file},getFileName:function(){var a=this.getFileList()[0];return a.name?a.name:a.fileName},getFileCls:function(){var a=this.getFileName().split(".");if(a.length===1){return""}else{return a.pop().toLowerCase()}},isImage:function(){var a=this.getFileCls();return(a=="jpg"||a=="gif"||a=="png"||a=="jpeg")},createMouseEvent:function(c,b){if(document.createEvent){var a=document.createEvent("MouseEvents");a.initMouseEvent(b,true,true,window,c.browserEvent.detail,c.browserEvent.screenX,c.browserEvent.screenY,c.browserEvent.clientX,c.browserEvent.clientY,c.browserEvent.ctrlKey,c.browserEvent.altKey,c.browserEvent.shiftKey,c.browserEvent.metaKey,c.browserEvent.button,c.browserEvent.relatedTarget);c.target.dispatchEvent(a)}else{if(document.createEventObject){var a=document.createEventObject();a.detail=c.browserEvent.detail;a.screenX=c.browserEvent.screenX;a.screenY=c.browserEvent.screenY;a.clientX=c.browserEvent.clientX;a.clientY=c.browserEvent.clientY;a.ctrlKey=c.browserEvent.ctrlKey;a.altKey=c.browserEvent.altKey;a.shiftKey=c.browserEvent.shiftKey;a.metaKey=c.browserEvent.metaKey;a.button=c.browserEvent.button;a.relatedTarget=c.browserEvent.relatedTarget;c.getTarget("div").fireEvent("on"+b,a)}}}};Ext.preg("ux.browseplugin",Ext.ux.file.BrowsePlugin);Ext.ns("Ext.ux.file");Ext.ux.file.Download=function(a){a=a||{};Ext.apply(this,a);Ext.ux.file.Download.superclass.constructor.call(this);this.addEvents({success:true,fail:true,abort:true})};Ext.extend(Ext.ux.file.Download,Ext.util.Observable,{url:"index.php",method:"POST",params:null,timeout:1800000,form:null,transactionId:null,start:function(){this.form=Ext.getBody().createChild({tag:"form",method:this.method,cls:"x-hidden"});var a=new Ext.data.Connection({debugUploads:Ext.isGecko});this.transactionId=a.request({isUpload:true,form:this.form,params:this.params,scope:this,success:this.onSuccess,failure:this.onFailure,url:this.url,timeout:this.timeout})},abort:function(){Ext.Ajax.abort(this.transactionId);this.form.remove();this.fireEvent("abort",this)},onSuccess:function(){this.form.remove();this.fireEvent("success",this)},onFailure:function(){this.form.remove();this.fireEvent("fail",this)}});Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.ColorField=Ext.extend(Ext.form.TriggerField,{listWidth:150,editable:false,initComponent:function(){Ext.ux.form.ColorField.superclass.initComponent.call(this);this.store=new Ext.data.Store({});this.addEvents("select")},onDestroy:function(){Ext.destroy(this.menu);Ext.ux.form.ColorField.superclass.onDestroy.call(this)},onTriggerClick:function(){if(this.disabled){return}if(this.menu==null){this.menu=new Ext.menu.ColorMenu({hideOnClick:false})}this.onFocus();this.menu.show(this.el,"tl-bl?");this.menuEvents("on")},setValue:function(a){a=a||"#FFFFFF";Ext.ux.form.ColorField.superclass.setValue.call(this,a);this.el.setStyle("background",a);this.el.setStyle("color",a)},menuEvents:function(a){this.menu[a]("select",this.onSelect,this);this.menu[a]("hide",this.onMenuHide,this);this.menu[a]("show",this.onFocus,this)},onSelect:function(a,b){this.setValue("#"+b);this.fireEvent("select",this,"#"+b);this.menu.hide()},onMenuHide:function(){this.focus(false,60);this.menuEvents("un")}});Ext.reg("colorfield",Ext.ux.form.ColorField);Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.IconTextField=Ext.extend(Ext.form.TextField,{labelIcon:"",initComponent:function(){Ext.ux.form.IconTextField.superclass.initComponent.call(this);if(this.labelIcon.length>0){this.fieldLabel='<img src="'+this.labelIcon+'" class="x-ux-form-icontextfield-labelicon">'+this.fieldLabel}}});Ext.reg("icontextfield",Ext.ux.form.IconTextField);Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.MirrorTextField=Ext.extend(Ext.ux.form.IconTextField,{initComponent:function(){Ext.ux.form.MirrorTextField.superclass.initComponent.call(this);Ext.ux.form.MirrorTextFieldManager.register(this)},setValue:function(a){Ext.ux.form.MirrorTextFieldManager.setAll(this,a)},onDestroy:function(){if(this.rendered){Ext.ux.form.MirrorTextFieldManager.unregister(this)}}});Ext.reg("mirrortextfield",Ext.ux.form.MirrorTextField);Ext.ux.form.MirrorTextFieldManager=function(){var b={};function a(j,h,f){var c=b[j.name];for(var g=0,d=c.length;g<d;g++){c[g].setRawValue(h)}return true}return{register:function(d){var c=b[d.name];if(!c){c=b[d.name]=[]}c.push(d);d.on("change",a)},unregister:function(d){var c=b[d.name];if(c){c.remove(d);d.un("change",a)}},setAll:function(f,d){var c=b[f.name];if(c){a(f,d)}}}}();Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.ColumnFormPanel=Ext.extend(Ext.Panel,{formDefaults:{xtype:"icontextfield",anchor:"100%",labelSeparator:"",columnWidth:0.333},layout:"hfit",labelAlign:"top",initComponent:function(){var h=[];for(var g=0,f=this.items.length;g<f;g++){var l=this.items[g];var d={border:false,layout:"column",items:[]};for(var a=0,b=l.length;a<b;a++){var c=l[a];var k=d.items.push({columnWidth:c.columnWidth?c.columnWidth:this.formDefaults.columnWidth,layout:"form",labelAlign:this.labelAlign,defaults:this.formDefaults,bodyStyle:"padding-right: 5px;",border:false,items:c});if(c.width){d.items[k-1].width=c.width;delete d.items[k-1].columnWidth}}h.push(d)}this.items=h;Ext.ux.form.ColumnFormPanel.superclass.initComponent.call(this)}});Ext.reg("columnform",Ext.ux.form.ColumnFormPanel);Ext.ns("Ext.ux.form.");Ext.ux.form.LayerCombo=function(a){Ext.ux.form.LayerCombo.superclass.constructor.call(this,a);this.addEvents("beforecollapse")};Ext.extend(Ext.ux.form.LayerCombo,Ext.form.TriggerField,{hideButtons:false,formConfig:null,lazyInit:true,triggerClass:"x-form-arrow-trigger",shadow:"sides",layerAlign:"tl-bl?",layerClass:"",minLayerWidth:70,minLayerHeight:70,currentValue:null,editable:false,collapse:function(){if(!this.isExpanded()){return}if(this.fireEvent("beforecollapse",this)!==false){this.layer.hide();Ext.getDoc().un("mousewheel",this.collapseIf,this);Ext.getDoc().un("mousedown",this.collapseIf,this);this.fireEvent("collapse",this)}},collapseIf:function(a){if(!a.within(this.wrap)&&!a.within(this.layer)){this.collapse()}},doQuery:Ext.emptyFn,expand:function(){if(this.isExpanded()||!this.hasFocus){return}this.setFormValue(this.currentValue);this.layer.alignTo.apply(this.layer,[this.el].concat(this.layerAlign));this.layer.show();if(Ext.isGecko2){this.innerLayer.setOverflow("auto")}this.mon(Ext.getDoc(),{scope:this,mousewheel:this.collapseIf,mousedown:this.collapseIf});this.fireEvent("expand",this)},getFormValue:function(){var a=this.getInnerForm().getForm().getValues();return a},getItems:function(){return[]},getLayerParent:function(){return document.body},getButtons:function(){if(!this.hideButtons){this.action_ok=new Ext.Action({text:_("Ok"),scope:this,handler:this.onOk,iconCls:"action_saveAndClose"});this.action_cancel=new Ext.Action({text:_("Cancel"),scope:this,handler:this.onCancel,iconCls:"action_cancel"});return[this.action_cancel,this.action_ok]}return false},getInnerForm:function(){if(!this.innerForm){this.innerForm=new Ext.form.FormPanel(Ext.apply({height:this.layerHeight||"auto",border:false,cls:"tw-editdialog",items:this.getItems(),buttonAlign:"right",buttons:this.getButtons()},this.formConfig))}return this.innerForm},getValue:function(){return this.currentValue},initComponent:function(){Ext.ux.form.LayerCombo.superclass.initComponent.apply(this,arguments)},initLayer:function(){if(!this.layer){var a="ux-layercombo-layer",d=Ext.getDom(this.getLayerParent()||Ext.getBody()),c=parseInt(Ext.fly(d).getStyle("z-index"),10);if(this.ownerCt&&!c){this.findParentBy(function(g){c=parseInt(g.getPositionEl().getStyle("z-index"),10);return !!c})}this.layer=new Ext.Layer({parentEl:d,shadow:this.shadow,cls:[a,this.layerClass].join(" "),constrain:false,zindex:(c||8000)+5});var f=this.layerWidth||Math.max(this.wrap.getWidth(),this.minLayerWidth);this.layer.setSize(f,0);this.assetHeight=0;if(this.syncFont!==false){this.layer.setStyle("font-size",this.el.getStyle("font-size"))}if(this.title){this.header=this.layer.createChild({cls:a+"-hd",html:this.title});this.assetHeight+=this.header.getHeight()}this.innerLayer=this.layer.createChild({cls:a+"-inner"});this.innerLayer.setWidth(f-this.layer.getFrameWidth("lr"));var b=this.getInnerForm();b.render(this.innerLayer);this.setLayerHeight(this.layerHeight?this.layerHeight:"auto")}},isExpanded:function(){return this.layer&&this.layer.isVisible()},onCancel:function(){this.setValue(this.currentValue);this.collapse()},onDestroy:function(){if(this.dqTask){this.dqTask.cancel();this.dqTask=null}Ext.destroy(this.resizer,this.layer);Ext.destroyMembers(this,"hiddenField");Ext.form.ComboBox.superclass.onDestroy.call(this)},onOk:function(){this.collapse();var a=this.getFormValue();this.setValue(a);this.fireEvent("select",this,a);this.startValue=a},onRender:function(b,a){if(this.hiddenName&&!Ext.isDefined(this.submitValue)){this.submitValue=false}Ext.ux.form.LayerCombo.superclass.onRender.apply(this,arguments);if(this.hiddenName){this.hiddenField=this.el.insertSibling({tag:"input",type:"hidden",name:this.hiddenName,id:(this.hiddenId||this.hiddenName)},"before",true)}if(Ext.isGecko){this.el.dom.setAttribute("autocomplete","off")}if(!this.lazyInit){this.initLayer()}else{this.on("focus",this.initLayer,this,{single:true})}},onTriggerClick:function(){if(this.readOnly||this.disabled){return}if(this.isExpanded()){this.collapse();this.el.focus()}else{this.onFocus({});this.expand()}},setLayerHeight:function(a){if(!Ext.isNumber(a)){a=this.innerForm.getHeight()}this.innerLayer.dom.style.height="";var b=this.layer.getFrameWidth("tb")+(this.resizable?this.handleHeight:0)+this.assetHeight;this.innerLayer.setHeight(a);this.layer.beginUpdate();this.layer.setHeight(a+b);this.layer.alignTo.apply(this.layer,[this.el].concat(this.layerAlign));this.layer.endUpdate()},setValue:function(a){this.currentValue=a;return this},setFormValue:function(a){this.getInnerForm().getForm().setValues(a)}});Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.ClearableComboBox=Ext.extend(Ext.form.ComboBox,{disableClearer:null,initComponent:function(){Ext.ux.form.ClearableComboBox.superclass.initComponent.call(this);this.triggerConfig={tag:"span",cls:"x-form-twin-triggers",style:"padding-right:2px",cn:[{tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger x-form-clear-trigger"},{tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger"}]}},getTrigger:function(a){return this.triggers[a]},initTrigger:function(){var a=this.trigger.select(".x-form-trigger",true);this.wrap.setStyle("overflow","hidden");var b=this;a.each(function(d,g,c){d.hide=function(){this.dom.style.display="none";b.el.setWidth(b.wrap.getWidth()-21)};d.show=function(){this.dom.style.display="";b.el.setWidth(b.wrap.getWidth()-38)};var f="Trigger"+(c+1);if(this["hide"+f]){d.dom.style.display="none"}d.on("click",this["on"+f+"Click"],this,{preventDefault:true});d.addClassOnOver("x-form-trigger-over");d.addClassOnClick("x-form-trigger-click")},this);this.triggers=a.elements;this.triggers[0].hide()},onTrigger1Click:function(){if(this.disabled){return}this.clearValue()},onTrigger2Click:function(){this.onTriggerClick()},clearValue:function(){Ext.ux.form.ClearableComboBox.superclass.clearValue.apply(this,arguments);this.fireEvent("select",this,this.getRawValue(),this.startValue);this.startValue=this.getRawValue();if(this.triggers&&this.disableClearer!==true){this.triggers[0].hide()}},onSelect:function(c,a,b){if(this.triggers&&this.disableClearer!==true){this.triggers[0].show()}Ext.ux.form.ClearableComboBox.superclass.onSelect.call(this,c,a,b);this.startValue=this.getValue()},setValue:function(a){Ext.ux.form.ClearableComboBox.superclass.setValue.call(this,a);if(a&&(this.triggers&&this.disableClearer!==true)){this.triggers[0].show()}},assertValue:function(){var b=this.getRawValue(),a;if(this.valueField&&Ext.isDefined(this.value)){a=this.findRecord(this.valueField,this.value)}if(!a||a.get(this.displayField)!=b){a=this.findRecord(this.displayField,b)}if(!a&&this.forceSelection){if(b.length>0&&b!=this.emptyText){this.el.dom.value=Ext.value(this.lastSelectionText,"");this.applyEmptyText()}else{this.clearValue()}}else{if(a&&this.valueField){if(this.value==b){return}b=a.get(this.valueField||this.displayField)}this.selectedRecord=a;this.setRawValue(a?a.get(this.displayField):b)}}});Ext.reg("extuxclearablecombofield",Ext.ux.form.ClearableComboBox);Ext.ns("Ext.ux.form");Ext.ux.form.ClearableTextField=Ext.extend(Ext.form.TriggerField,{enableKeyEvents:true,triggerClass:"x-form-clear-trigger",checkTrigger:function(){if(this.getValue()){this.el.setWidth(this.wrap.getWidth()-this.trigger.getWidth());this.trigger.show()}else{this.trigger.hide();this.el.setWidth(this.wrap.getWidth())}},initComponent:function(){this.supr().initComponent.call(this);this.on("keyup",this.checkTrigger,this)},afterRender:function(){this.supr().afterRender.call(this);this.checkTrigger()},onTriggerClick:function(){var a=this.getValue();this.setValue("");if(a){this.fireEvent("change",this,"",a)}this.checkTrigger();this.el.focus()},onDestroy:function(){this.un("keyup",this.checkTrigger)},setValue:function(b){var a=this.supr().setValue.call(this,b);this.checkTrigger();return a}});Ext.reg("extuxclearabletextfield",Ext.ux.form.ClearableTextField);Ext.ns("Ext.ux.form");Ext.ux.form.RecordsComboBox=Ext.extend(Ext.form.ComboBox,{triggerAction:"all",editable:false,forceSelection:true,valueField:"id",setValue:function(a){var b=a;if(typeof a==="object"&&Object.prototype.toString.call(a)==="[object Object]"){if(a.records!==undefined){this.mode="local";this.store.loadData(a.records)}b=a.value}Ext.ux.form.RecordsComboBox.superclass.setValue.call(this,b)}});Ext.reg("reccombo",Ext.ux.form.RecordsComboBox);Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.DateTimeField=Ext.extend(Ext.form.Field,{autoEl:"div",value:"",increment:15,timeEditable:true,markedInvalid:false,dateConf:null,timeConf:null,defaultTime:null,initComponent:function(){Ext.ux.form.DateTimeField.superclass.initComponent.call(this);this.lastValues=[];this.on("change",this.onChange,this)},onChange:function(d,g,c){if(c==""&&g){var a=g.clone(),b=new Date(),h=(this.defaultTime)?this.defaultTime.split(":"):[b.getHours(),b.getMinutes()];a.setHours(parseInt(h[0]));a.setMinutes(parseInt(h[1]));d.setValue(a)}},clearInvalid:function(){this.markedInvalid=false;if(this.dateField){this.dateField.clearInvalid()}if(this.timeField){this.timeField.clearInvalid()}},clearTime:function(){var a=this.getValue();if(Ext.isDate(a)){this.setValue(this.getValue().clearTime(true))}else{this.timeField.setValue(new Date().clearTime())}},combineDateTime:function(a,b){a=Ext.isDate(a)?a:new Date.clearTime();if(Ext.isDate(b)){a=a.clone();a.clearTime();a=a.add(Date.HOUR,b.getHours());a=a.add(Date.MINUTE,b.getMinutes())}return a},getName:function(){return this.name},getValue:function(){if(!this.dateField){return this.value}var a=this.dateField.getValue();var b=this.timeField.getValue();if(!Ext.isDate(b)){b=Date.parseDate(b,"H:i")}if(Ext.isDate(a)){a=this.combineDateTime(a,b)}return a},markInvalid:function(a){this.markedInvalid=true;this.dateField.markInvalid(a);this.timeField.markInvalid(a)},onRender:function(b,a){this.el=document.createElement(this.autoEl);this.el.id=this.getId();this.el=Ext.get(this.el);b.dom.insertBefore(this.el.dom,a);this.el.applyStyles("overflow:visible;");var c=(this.allowBlank)?Ext.ux.form.ClearableDateField:Ext.form.DateField;this.dateField=new c(Ext.apply({lazyRender:false,renderTo:this.el,readOnly:this.readOnly,hideTrigger:this.hideTrigger,disabled:this.disabled,tabIndex:this.tabIndex===-1?this.tabIndex:false,allowBlank:this.allowBlank,value:this.value,listeners:{scope:this,change:this.onDateChange,select:this.onDateChange,focus:this.onDateFocus,blur:this.onDateBlur}},this.dateConf||{}));this.timeField=new Ext.form.TimeField(Ext.apply({lazyRender:false,increment:this.increment,renderTo:this.el,readOnly:this.readOnly,hideTrigger:this.hideTrigger,disabled:this.disabled,editable:this.timeEditable,tabIndex:this.tabIndex===-1?this.tabIndex:false,allowBlank:this.allowBlank,value:this.value,listeners:{scope:this,change:this.onTimeChange,select:this.onTimeChange,focus:this.onDateFocus,blur:this.onDateBlur}},this.timeConf||{}))},onDateFocus:function(){this.hasFocus=true;this.fireEvent("focus",this)},onDateBlur:function(){this.hasFocus=false;this.fireEvent("blur",this)},onDateChange:function(){var a=this.getValue();this.setValue(a);this.fireEvent("change",this,a,this.lastValues.length>1?this.lastValues[this.lastValues.length-2]:"")},onResize:function(b,c){Ext.ux.form.DateTimeField.superclass.onResize.apply(this,arguments);if(this.allowBlank){var f=[0.65,0.35]}else{var f=[0.55,0.45]}this.el.setHeight(20);this.el.setStyle({position:"relative"});this.dateField.wrap.setStyle({position:"absolute"});var a=Math.abs(b*f[0]-5);this.dateField.setWidth(a);this.dateField.wrap.setWidth(a);this.timeField.wrap.setStyle({position:"absolute"});var d=Math.abs(b*f[1]);this.timeField.setWidth(d);this.timeField.wrap.setWidth(d);this.timeField.wrap.setLeft(a+5)},onTimeChange:function(){var a=this.getValue();this.setValue(a);this.fireEvent("change",this,a,this.lastValues.length>1?this.lastValues[this.lastValues.length-2]:"")},setDisabled:function(a,b){if(b!=="time"&&this.dateField){this.dateField.setDisabled(a)}if(b!=="date"&&this.timeField){this.timeField.setDisabled(a)}Ext.ux.form.DateTimeField.superclass.setDisabled.call(this,a)},setReadOnly:function(a,b){if(b!=="time"&&this.dateField){this.dateField.setReadOnly(a)}if(b!=="date"&&this.timeField){this.timeField.setReadOnly(a)}Ext.ux.form.DateTimeField.superclass.setReadOnly.call(this,a)},setRawValue:Ext.EmptyFn,setValue:function(a,b){if(!b){this.lastValues.push(a)}if(this.dateField&&this.timeField){this.dateField.setValue(a);this.timeField.setValue(a)}this.value=a},undo:function(){if(this.lastValues.length>1){this.lastValues.pop();this.setValue(this.lastValues[this.lastValues.length-1],true)}else{this.reset()}},isValid:function(a){return this.dateField.isValid(a)&&this.timeField.isValid(a)&&!this.markedInvalid}});Ext.reg("datetimefield",Ext.ux.form.DateTimeField);Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.ClearableDateField=Ext.extend(Ext.form.DateField,{initComponent:function(){Ext.ux.form.ClearableDateField.superclass.initComponent.call(this);this.triggerConfig={tag:"span",cls:"x-form-twin-triggers",cn:[{tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger x-form-clear-trigger"},{tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger x-form-date-trigger"}]}},getTrigger:function(a){return this.triggers[a]},initTrigger:function(){var a=this.trigger.select(".x-form-trigger",true);this.wrap.setStyle("overflow","hidden");var b=this;a.each(function(d,g,c){d.hide=function(){var h=b.wrap.getWidth();this.dom.style.display="none";b.el.setWidth(h-b.trigger.getWidth())};d.show=function(){var h=b.wrap.getWidth();this.dom.style.display="";b.el.setWidth(h-b.trigger.getWidth())};var f="Trigger"+(c+1);if(this["hide"+f]){d.dom.style.display="none"}d.on("click",this["on"+f+"Click"],this,{preventDefault:true});d.addClassOnOver("x-form-trigger-over");d.addClassOnClick("x-form-trigger-click")},this);this.triggers=a.elements;this.triggers[0].hide()},validateValue:function(a){if(a!==this.emptyText&&a!==undefined&&a.length>"1"){if(Ext.isArray(this.triggers)&&this.triggers[0]&&typeof this.triggers[0].show=="function"){this.triggers[0].show()}}return true},onTrigger1Click:function(){this.setValue("");this.fireEvent("select",this,"","");this.triggers[0].hide()},onTrigger2Click:function(){this.onTriggerClick()},setValue:function(a){if(Ext.isArray(this.triggers)&&this.triggers[0]&&typeof this.triggers[0].show=="function"){this.triggers[0][a?"show":"hide"]()}return Ext.ux.form.ClearableDateField.superclass.setValue.apply(this,arguments)}});Ext.reg("extuxclearabledatefield",Ext.ux.form.ClearableDateField);Ext.ns("Ext.ux.form");Ext.ux.form.ImageField=Ext.extend(Ext.form.Field,{border:true,defaultImage:"images/empty_photo_blank.png",defaultAutoCreate:{tag:"input",type:"hidden"},handleMouseEvents:true,initComponent:function(){this.plugins=this.plugins||[];this.scope=this;this.handler=this.onFileSelect;this.browsePlugin=new Ext.ux.file.BrowsePlugin({dropElSelector:"div[class^=x-panel-body]"});this.plugins.push(this.browsePlugin);Tine.widgets.dialog.MultipleEditDialogPlugin.prototype.registerSkipItem(this);Ext.ux.form.ImageField.superclass.initComponent.call(this);this.imageSrc=this.defaultImage;if(this.border===true){this.width=this.width;this.height=this.height}},onRender:function(c,a){Ext.ux.form.ImageField.superclass.onRender.call(this,c,a);this.buttonCt=Ext.DomHelper.insertFirst(c,"<div>&#160;</div>",true);this.buttonCt.applyStyles({border:this.border===true?"1px solid #B5B8C8":"0"});this.buttonCt.setSize(this.width,this.height);this.loadMask=new Ext.LoadMask(this.buttonCt,{msg:_("Loading"),msgCls:"x-mask-loading"});var d=_("Click to edit");this.textCt=Ext.DomHelper.insertFirst(this.buttonCt,'<div class="x-ux-from-imagefield-text">'+d+"</div>",true);this.textCt.setSize(this.width,this.height);var b=Ext.util.TextMetrics.createInstance(this.textCt);b.setFixedWidth(this.width);this.textCt.setStyle({top:((this.height-b.getHeight(d))/2)+"px"});this.imageCt=Ext.DomHelper.insertFirst(this.buttonCt,'<img src="'+this.imageSrc+'"/>',true);this.imageCt.setOpacity(0.2);this.imageCt.setStyle({position:"absolute",top:"18px"});Ext.apply(this.browsePlugin,{buttonCt:this.buttonCt,renderTo:this.buttonCt})},getValue:function(){return Ext.ux.form.ImageField.superclass.getValue.call(this)},setValue:function(a){Ext.ux.form.ImageField.superclass.setValue.call(this,a);if(!a||a===this.defaultImage){this.setDefaultImage(this.defaultImage)}else{if(a instanceof Ext.ux.util.ImageURL||(Ext.isString(a)&&a.match(/&/))){this.imageSrc=Ext.ux.util.ImageURL.prototype.parseURL(a);this.imageSrc.width=this.width;this.imageSrc.height=this.height;this.imageSrc.ratiomode=0}else{this.setDefaultImage(!Ext.isEmpty(a)?a:this.defaultImage)}}this.updateImage()},onFileSelect:function(f){if(!f.isImage()){Ext.MessageBox.alert(_("Not An Image"),_("Please select an image file (gif/png/jpeg)")).setIcon(Ext.MessageBox.ERROR);return}var c=f.getFileList();var d=new Ext.ux.file.Upload({file:c[0],fileSelector:f});d.on("uploadcomplete",function(h,g){console.log(arguments);this.imageSrc=new Ext.ux.util.ImageURL({id:g.get("tempFile").id,width:this.width,height:this.height,ratiomode:0});this.setValue(this.imageSrc);this.updateImage()},this);d.on("uploadfailure",this.onUploadFail,this);this.loadMask.show();var b=Tine.Tinebase.uploadManager.queueUpload(d);var a=Tine.Tinebase.uploadManager.upload(b);if(this.ctxMenu){this.ctxMenu.hide()}},onUploadFail:function(){Ext.MessageBox.alert(_("Upload Failed"),_("Could not upload image. Please notify your Administrator")).setIcon(Ext.MessageBox.ERROR)},onContextMenu:function(d,a){d.preventDefault();var c=Ext.DomHelper.append(this.buttonCt,"<div>&#160;</div>",true);var b=new Ext.menu.Item({text:_("Change Image"),iconCls:"action_uploadImage",handler:this.onFileSelect,scope:this,plugins:[new Ext.ux.file.BrowsePlugin({})]});this.ctxMenu=new Ext.menu.Menu({items:[b,{text:_("Crop Image"),iconCls:"action_cropImage",scope:this,disabled:true,handler:function(){var f=new Ext.ux.form.ImageCropper({imageURL:this.imageSrc});var h=new Tine.widgets.dialog.EditRecord({handlerScope:this,handlerCancle:this.close,items:f});var g=Tine.WindowFactory.getWindow({width:320,height:320,title:_("Crop Image"),layout:"fit",items:h})}},{text:_("Delete Image"),iconCls:"action_delete",disabled:this.imageSrc===this.defaultImage,scope:this,handler:function(){this.setValue("")}},{text:_("Show Original Image"),iconCls:"action_originalImage",disabled:this.imageSrc===this.defaultImage,scope:this,handler:this.downloadImage}]});this.ctxMenu.showAt(d.getXY())},downloadImage:function(){var a=Ext.apply(this.imageSrc,{height:-1,width:-1}).toString();var b=Tine.WindowFactory.getWindow({url:a,name:"showImage",width:800,height:600})},setDefaultImage:function(b){this.defaultImage=b;this.imageSrc=this.defaultImage;var a=Ext.DomHelper.insertAfter(this.imageCt,'<img src="'+this.defaultImage+'"/>',true);this.imageCt.remove();this.imageCt=a;this.imageCt.setOpacity(0.2);this.imageCt.setStyle({position:"absolute",top:"18px"});this.textCt.setVisible(true);Ext.ux.form.ImageField.superclass.setValue.call(this,"")},updateImage:function(){if(this.imageCt.dom.src.substr(-1*this.imageSrc.length)!==this.imageSrc){var b=this.imageCt.up("div");var a=Ext.DomHelper.insertAfter(this.imageCt,'<img src="'+this.imageSrc+'"/>',true);a.on("load",function(){this.imageCt.remove();this.imageCt=a;this.textCt.setVisible(this.imageSrc===this.defaultImage);this.imageCt.setOpacity(this.imageSrc===this.defaultImage?0.2:1);this.loadMask.hide()},this);a.on("error",function(){Ext.MessageBox.alert(_("Image Failed"),_("Could not load image. Please notify your Administrator")).setIcon(Ext.MessageBox.ERROR);this.loadMask.hide()},this)}}});Ext.ns("Ext.ux.util");Ext.ux.util.ImageURL=function(a){Ext.apply(this,a,{url:"index.php",method:"Tinebase.getImage",application:"Tinebase",location:"tempFile",width:90,height:120,ratiomode:0,mtime:new Date().getTime()})};Ext.ux.util.ImageURL.prototype.toString=function(){return this.url+"?method="+this.method+"&application="+this.application+"&location="+this.location+"&id="+this.id+"&width="+this.width+"&height="+this.height+"&ratiomode="+this.ratiomode+"&mtime="+this.mtime};Ext.ux.util.ImageURL.prototype.parseURL=function(b){var f=b.toString(),h={},d=f.substr(f.indexOf("?")+1).split("&");for(var c=0,a=d.length;c<a;c+=1){var g=d[c].split("=");h[g[0]]=Ext.util.Format.htmlEncode(g[1])}return new Ext.ux.util.ImageURL(h)};Ext.ns("Ext.ux.form");Ext.ux.form.ImageCropper=function(a){Ext.apply(this,a);Ext.ux.form.ImageCropper.superclass.constructor.apply(this,arguments);this.addEvents("imagecropped")};Ext.extend(Ext.ux.form.ImageCropper,Ext.Component,{imageSize:false,width:320,height:320,initComponent:function(){this.imageURL.width=290;this.imageURL.height=240;this.imageURL.ratiomode=1;Ext.ux.form.ImageCropper.superclass.initComponent.call(this)},onRender:function(d,a){Ext.ux.form.ImageCropper.superclass.onRender.call(this,d,a);this.wrapEl=Ext.DomHelper.insertFirst(d,{tag:"div"},true);this.bgImageEl=Ext.DomHelper.insertFirst(this.wrapEl,{tag:"img",id:"yui_img",src:this.imageURL},true);this.bgImageEl.setOpacity(0.5);this.fgImageEl=Ext.DomHelper.insertFirst(this.wrapEl,{tag:"div",style:{width:"100px",height:"100px",position:"absolute",top:"30px",left:"30px","background-image":"url("+this.imageURL+")","background-repeat":"no-repeat"}},true);this.resizeable=new Ext.Resizable(this.fgImageEl,{wrap:true,pinned:true,handles:"s e se",draggable:true,dynamic:true});this.resizeable.dd.fgImageEl=this.fgImageEl;this.resizeable.dd.bgImageEl=this.bgImageEl;this.resizeable.dd.onDrag=this.syncImageEls;var f=this.resizeable.getEl().query("div.x-resizable-handle");for(var c=0,b=f.length;c<b;c++){Ext.get(f[c]).setOpacity(1)}this.syncImageEls()},syncImageEls:function(){var b=this.bgImageEl.getX()-this.fgImageEl.getX();var a=this.bgImageEl.getY()-this.fgImageEl.getY();this.fgImageEl.setStyle("background-position",b+"px "+a+"px")}});Ext.ns("Ext.ux.form");Ext.ux.form.Spinner=function(a){Ext.ux.form.Spinner.superclass.constructor.call(this,a);this.addEvents({spin:true,spinup:true,spindown:true})};Ext.extend(Ext.ux.form.Spinner,Ext.form.TriggerField,{triggerClass:"x-form-spinner-trigger",splitterClass:"x-form-spinner-splitter",alternateKey:Ext.EventObject.shiftKey,strategy:undefined,onRender:function(b,a){Ext.ux.form.Spinner.superclass.onRender.call(this,b,a);this.splitter=this.wrap.createChild({tag:"div",cls:this.splitterClass,style:"width:13px; height:2px;"});this.splitter.show().setRight((Ext.isIE)?1:2);this.splitter.show().setTop(8);this.proxy=this.trigger.createProxy("",this.splitter,true);this.proxy.addClass("x-form-spinner-proxy");this.proxy.setStyle("left","0px");this.proxy.setSize(14,1);this.proxy.hide();this.dd=new Ext.dd.DDProxy(this.splitter.dom.id,"SpinnerDrag",{dragElId:this.proxy.id});this.initSpinner()},initTrigger:function(){this.trigger.addClassOnOver("x-form-trigger-over");this.trigger.addClassOnClick("x-form-trigger-click")},initSpinner:function(){this.keyNav=new Ext.KeyNav(this.el,{up:function(a){a.preventDefault();this.onSpinUp()},down:function(a){a.preventDefault();this.onSpinDown()},pageUp:function(a){a.preventDefault();this.onSpinUpAlternate()},pageDown:function(a){a.preventDefault();this.onSpinDownAlternate()},scope:this});this.repeater=new Ext.util.ClickRepeater(this.trigger);this.repeater.on("click",this.onTriggerClick,this,{preventDefault:true});this.trigger.on("mouseover",this.onMouseOver,this,{preventDefault:true});this.trigger.on("mouseout",this.onMouseOut,this,{preventDefault:true});this.trigger.on("mousemove",this.onMouseMove,this,{preventDefault:true});this.trigger.on("mousedown",this.onMouseDown,this,{preventDefault:true});this.trigger.on("mouseup",this.onMouseUp,this,{preventDefault:true});this.wrap.on("mousewheel",this.handleMouseWheel,this);this.dd.setXConstraint(0,0,10);this.dd.setYConstraint(1500,1500,10);this.dd.endDrag=this.endDrag.createDelegate(this);this.dd.startDrag=this.startDrag.createDelegate(this);this.dd.onDrag=this.onDrag.createDelegate(this);if("object"==typeof this.strategy&&this.strategy.xtype){switch(this.strategy.xtype){case"number":this.strategy=new Ext.ux.form.Spinner.NumberStrategy(this.strategy);break;case"date":this.strategy=new Ext.ux.form.Spinner.DateStrategy(this.strategy);break;case"time":this.strategy=new Ext.ux.form.Spinner.TimeStrategy(this.strategy);break;default:delete (this.strategy);break}delete (this.strategy.xtype)}if(this.strategy==undefined){this.strategy=new Ext.ux.form.Spinner.NumberStrategy()}},onMouseOver:function(){if(this.disabled){return}var a=this.getMiddle();this.__tmphcls=(Ext.EventObject.getPageY()<a)?"x-form-spinner-overup":"x-form-spinner-overdown";this.trigger.addClass(this.__tmphcls)},onMouseOut:function(){this.trigger.removeClass(this.__tmphcls)},onMouseMove:function(){if(this.disabled){return}var a=this.getMiddle();if(((Ext.EventObject.getPageY()>a)&&this.__tmphcls=="x-form-spinner-overup")||((Ext.EventObject.getPageY()<a)&&this.__tmphcls=="x-form-spinner-overdown")){}},onMouseDown:function(){if(this.disabled){return}var a=this.getMiddle();this.__tmpccls=(Ext.EventObject.getPageY()<a)?"x-form-spinner-clickup":"x-form-spinner-clickdown";this.trigger.addClass(this.__tmpccls)},onMouseUp:function(){this.trigger.removeClass(this.__tmpccls)},onTriggerClick:function(){if(this.disabled||this.getEl().dom.readOnly){return}var b=this.getMiddle();var a=(Ext.EventObject.getPageY()<b)?"Up":"Down";this["onSpin"+a]()},getMiddle:function(){var b=this.trigger.getTop();var c=this.trigger.getHeight();var a=b+(c/2);return a},isSpinnable:function(){if(this.disabled||this.getEl().dom.readOnly){Ext.EventObject.preventDefault();return false}return true},handleMouseWheel:function(a){if(this.wrap.hasClass("x-trigger-wrap-focus")==false){return}var b=a.getWheelDelta();if(b>0){this.onSpinUp();a.stopEvent()}else{if(b<0){this.onSpinDown();a.stopEvent()}}},startDrag:function(){this.proxy.show();this._previousY=Ext.fly(this.dd.getDragEl()).getTop()},endDrag:function(){this.proxy.hide()},onDrag:function(){if(this.disabled){return}var b=Ext.fly(this.dd.getDragEl()).getTop();var a="";if(this._previousY>b){a="Up"}if(this._previousY<b){a="Down"}if(a!=""){this["onSpin"+a]()}this._previousY=b},onSpinUp:function(){if(this.isSpinnable()==false){return}if(Ext.EventObject.shiftKey==true){this.onSpinUpAlternate();return}else{this.strategy.onSpinUp(this)}this.fireEvent("spin",this);this.fireEvent("spinup",this)},onSpinDown:function(){if(this.isSpinnable()==false){return}if(Ext.EventObject.shiftKey==true){this.onSpinDownAlternate();return}else{this.strategy.onSpinDown(this)}this.fireEvent("spin",this);this.fireEvent("spindown",this)},onSpinUpAlternate:function(){if(this.isSpinnable()==false){return}this.strategy.onSpinUpAlternate(this);this.fireEvent("spin",this);this.fireEvent("spinup",this)},onSpinDownAlternate:function(){if(this.isSpinnable()==false){return}this.strategy.onSpinDownAlternate(this);this.fireEvent("spin",this);this.fireEvent("spindown",this)}});Ext.reg("uxspinner",Ext.ux.form.Spinner);Ext.ux.form.Spinner.Strategy=function(a){Ext.apply(this,a)};Ext.extend(Ext.ux.form.Spinner.Strategy,Ext.util.Observable,{defaultValue:0,minValue:undefined,maxValue:undefined,incrementValue:1,alternateIncrementValue:5,validationTask:new Ext.util.DelayedTask(),onSpinUp:function(a){this.spin(a,false,false)},onSpinDown:function(a){this.spin(a,true,false)},onSpinUpAlternate:function(a){this.spin(a,false,true)},onSpinDownAlternate:function(a){this.spin(a,true,true)},spin:function(a,c,b){this.validationTask.delay(500,function(){a.validate()})},fixBoundries:function(a){return a}});Ext.ux.form.Spinner.NumberStrategy=function(a){Ext.ux.form.Spinner.NumberStrategy.superclass.constructor.call(this,a)};Ext.extend(Ext.ux.form.Spinner.NumberStrategy,Ext.ux.form.Spinner.Strategy,{allowDecimals:true,decimalPrecision:2,spin:function(b,f,c){Ext.ux.form.Spinner.NumberStrategy.superclass.spin.call(this,b,f,c);var a=parseFloat(b.getValue());var d=(c==true)?this.alternateIncrementValue:this.incrementValue;(f==true)?a-=d:a+=d;a=(isNaN(a))?this.defaultValue:a;a=this.fixBoundries(a);b.setRawValue(a)},fixBoundries:function(b){var a=b;if(this.minValue!=undefined&&a<this.minValue){a=this.minValue}if(this.maxValue!=undefined&&a>this.maxValue){a=this.maxValue}return this.fixPrecision(a)},fixPrecision:function(b){var a=isNaN(b);if(!this.allowDecimals||this.decimalPrecision==-1||a||!b){return a?"":b}return parseFloat(parseFloat(b).toFixed(this.decimalPrecision))}});Ext.ux.form.Spinner.DateStrategy=function(a){Ext.ux.form.Spinner.DateStrategy.superclass.constructor.call(this,a)};Ext.extend(Ext.ux.form.Spinner.DateStrategy,Ext.ux.form.Spinner.Strategy,{defaultValue:new Date(),format:"Y-m-d",incrementValue:1,incrementConstant:Date.DAY,alternateIncrementValue:1,alternateIncrementConstant:Date.MONTH,spin:function(d,h,f){Ext.ux.form.Spinner.DateStrategy.superclass.spin.call(this,d,h,f);var a=d.getRawValue();a=Date.parseDate(a,this.format);var c=(h==true)?-1:1;var g=(f==true)?this.alternateIncrementValue:this.incrementValue;var b=(f==true)?this.alternateIncrementConstant:this.incrementConstant;if(typeof this.defaultValue=="string"){this.defaultValue=Date.parseDate(this.defaultValue,this.format)}a=(a)?a.add(b,c*g):this.defaultValue;a=this.fixBoundries(a);d.setRawValue(Ext.util.Format.date(a,this.format))},fixBoundries:function(b){var d=b;var c=(typeof this.minValue=="string")?Date.parseDate(this.minValue,this.format):this.minValue;var a=(typeof this.maxValue=="string")?Date.parseDate(this.maxValue,this.format):this.maxValue;if(this.minValue!=undefined&&d<c){d=c}if(this.maxValue!=undefined&&d>a){d=a}return d}});Ext.ux.form.Spinner.TimeStrategy=function(a){Ext.ux.form.Spinner.TimeStrategy.superclass.constructor.call(this,a)};Ext.extend(Ext.ux.form.Spinner.TimeStrategy,Ext.ux.form.Spinner.DateStrategy,{format:"H:i",incrementValue:1,incrementConstant:Date.MINUTE,alternateIncrementValue:1,alternateIncrementConstant:Date.HOUR});Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.LockCombo=Ext.extend(Ext.form.ComboBox,{paramName:"query",selectOnFocus:true,emptyText:"select entry...",hiddenFieldId:"",hiddenFieldData:"",validationEvent:false,validateOnBlur:false,trigger1Class:"x-form-trigger",trigger2ClassLocked:"x-form-locked-trigger",trigger2ClassUnlocked:"x-form-unlocked-trigger",hideTrigger1:false,width:180,hasSearch:false,initComponent:function(){Ext.ux.form.LockCombo.superclass.initComponent.call(this);if(!this.hiddenFieldData){this.hiddenFieldData="1"}this.triggerConfig={tag:"span",cls:"x-form-twin-triggers",cn:[{tag:"img",id:"trigger1",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger "+this.trigger1Class},{tag:"img",id:"trigger2",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger "}]}},getTrigger:function(a){return this.triggers[a]},initTrigger:function(){var a=this.trigger.select(".x-form-trigger",true);this.wrap.setStyle("overflow","hidden");var b=this;a.each(function(f,h,d){f.hide=function(){var j=b.wrap.getWidth();this.dom.style.display="none";b.el.setWidth(j-b.trigger.getWidth())};f.show=function(){var j=b.wrap.getWidth();this.dom.style.display="";b.el.setWidth(j-b.trigger.getWidth())};var g="Trigger"+(d+1);if(this["hide"+g]){f.dom.style.display="none"}f.on("click",this["on"+g+"Click"],this,{preventDefault:true});if(f.id=="trigger2"){if(this.hiddenFieldData=="0"){var c=this.trigger2ClassLocked.toString();f.addClass(c)}if(this.hiddenFieldData=="1"||!this.hiddenFieldData){var c=this.trigger2ClassUnlocked.toString();f.addClass(c)}}f.addClassOnOver("x-form-trigger-over");f.addClassOnClick("x-form-trigger-click")},this);this.triggers=a.elements},onRender:function(b,a){Ext.ux.form.LockCombo.superclass.onRender.call(this,b,a);this.hiddenBox=b.parent().createChild({tag:"input",type:"hidden",name:this.hiddenFieldId,id:this.hiddenFieldId,value:this.hiddenFieldData});Ext.ComponentMgr.register(this.hiddenBox)},onTrigger1Click:function(){if(this.disabled){return}if(this.isExpanded()){this.collapse();this.el.focus()}else{this.onFocus({});if(this.triggerAction=="all"){this.doQuery(this.allQuery,true)}else{this.doQuery(this.getRawValue())}this.el.focus()}},onTrigger2Click:function(){var c=Ext.getCmp(this.hiddenFieldId).getValue();var b=this.trigger.select(".x-form-trigger",true);if(c=="0"){Ext.getCmp(this.hiddenFieldId).dom.value="1";var a=this.trigger2ClassUnlocked.toString();b.each(function(f,g,d){if(f.id=="trigger2"){f.dom.className="x-form-trigger "+a}})}else{Ext.getCmp(this.hiddenFieldId).dom.value="0";var a=this.trigger2ClassLocked.toString();b.each(function(f,g,d){if(f.id=="trigger2"){f.dom.className="x-form-trigger "+a}})}}});Ext.reg("lockCombo",Ext.ux.form.LockCombo);Ext.ns("Ext.ux","Ext.ux.form");Ext.ux.form.LockTextfield=Ext.extend(Ext.form.TriggerField,{hiddenFieldId:"",hiddenFieldData:"",triggerClassLocked:"x-form-locked-trigger",triggerClassUnlocked:"x-form-unlocked-trigger",initComponent:function(){this.triggerClass=(this.hiddenFieldData=="1")?this.triggerClassUnlocked:this.triggerClassLocked;Ext.ux.form.LockTextfield.superclass.initComponent.call(this)},onRender:function(b,a){Ext.ux.form.LockTextfield.superclass.onRender.call(this,b,a);this.hiddenBox=b.parent().createChild({tag:"input",type:"hidden",name:this.hiddenFieldId,id:this.hiddenFieldId,value:this.hiddenFieldData});Ext.ComponentMgr.register(this.hiddenBox)},onTriggerClick:function(){var a=Ext.getCmp(this.hiddenFieldId).getValue();if(a=="0"){Ext.getCmp(this.hiddenFieldId).dom.value="1";this.trigger.removeClass(this.triggerClassLocked);this.trigger.addClass(this.triggerClassUnlocked)}else{Ext.getCmp(this.hiddenFieldId).dom.value="0";this.trigger.removeClass(this.triggerClassUnlocked);this.trigger.addClass(this.triggerClassLocked)}}});Ext.reg("lockTextfield",Ext.ux.form.LockTextfield);
/*
 * MIT license
 */
Ext.ns("Ext.ux.form.HtmlEditor");Ext.ux.form.HtmlEditor.MidasCommand=Ext.extend(Ext.util.Observable,{init:function(a){this.cmp=a;this.btns=[];this.cmp.on("render",this.onRender,this);this.cmp.on("initialize",this.onInit,this,{delay:100,single:true})},onInit:function(){Ext.EventManager.on(this.cmp.getDoc(),{mousedown:this.onEditorEvent,dblclick:this.onEditorEvent,click:this.onEditorEvent,keyup:this.onEditorEvent,buffer:100,scope:this})},onRender:function(){var c,a=this.cmp.getToolbar(),b;Ext.each(this.midasBtns,function(d){if(Ext.isObject(d)){c={iconCls:"x-edit-"+d.cmd,handler:function(){this.cmp.relayCmd(d.cmd)},scope:this,tooltip:d.tooltip||{title:d.title},overflowText:d.overflowText||d.title}}else{c=new Ext.Toolbar.Separator()}b=a.addButton(c);if(d.enableOnSelection){b.disable()}this.btns.push(b)},this)},onEditorEvent:function(){var a=this.cmp.getDoc();Ext.each(this.btns,function(c,d){if(this.midasBtns[d].enableOnSelection||this.midasBtns[d].disableOnSelection){if(a.getSelection){if((this.midasBtns[d].enableOnSelection&&a.getSelection()!=="")||(this.midasBtns[d].disableOnSelection&&a.getSelection()==="")){c.enable()}else{c.disable()}}else{if(a.selection){if((this.midasBtns[d].enableOnSelection&&a.selection.createRange().text!=="")||(this.midasBtns[d].disableOnSelection&&a.selection.createRange().text==="")){c.enable()}else{c.disable()}}}}if(this.midasBtns[d].monitorCmdState){c.toggle(a.queryCommandState(this.midasBtns[d].cmd))}},this)}});Ext.ux.form.HtmlEditor.Divider=Ext.extend(Ext.util.Observable,{init:function(a){this.cmp=a;this.cmp.on("render",this.onRender,this)},onRender:function(){this.cmp.getToolbar().addButton([new Ext.Toolbar.Separator()])}});Ext.ux.form.HtmlEditor.IndentOutdent=Ext.extend(Ext.ux.form.HtmlEditor.MidasCommand,{midasBtns:["|",{cmd:"outdent",tooltip:{title:"Outdent Text"},overflowText:"Outdent Text"},{cmd:"indent",tooltip:{title:"Indent Text"},overflowText:"Indent Text"}]});Ext.ux.form.HtmlEditor.RemoveFormat=Ext.extend(Ext.ux.form.HtmlEditor.MidasCommand,{midasBtns:["|",{enableOnSelection:true,cmd:"removeFormat",tooltip:{title:"Remove Formatting"},overflowText:"Remove Formatting"}]});Ext.ux.form.HtmlEditor.SubSuperScript=Ext.extend(Ext.ux.form.HtmlEditor.MidasCommand,{midasBtns:["|",{enableOnSelection:true,cmd:"subscript",tooltip:{title:"Subscript"},overflowText:"Subscript"},{enableOnSelection:true,cmd:"superscript",tooltip:{title:"Superscript"},overflowText:"Superscript"}]});Ext.ux.form.HtmlEditor.SpecialCharacters=Ext.extend(Ext.util.Observable,{specialChars:[],charRange:[160,256],init:function(a){this.cmp=a;this.cmp.on("render",this.onRender,this)},onRender:function(){var b=this.cmp;var a=this.cmp.getToolbar().addButton({iconCls:"x-edit-char",handler:function(){if(this.specialChars.length){Ext.each(this.specialChars,function(f,d){this.specialChars[d]=["&#"+f+";"]},this)}for(i=this.charRange[0];i<this.charRange[1];i++){this.specialChars.push(["&#"+i+";"])}var c=new Ext.data.ArrayStore({fields:["char"],data:this.specialChars});this.charWindow=new Ext.Window({title:"Insert Special Character",width:436,autoHeight:true,layout:"fit",items:[{xtype:"dataview",store:c,ref:"../charView",autoHeight:true,multiSelect:true,tpl:new Ext.XTemplate('<tpl for="."><div class="char-item">{char}</div></tpl><div class="x-clear"></div>'),overClass:"char-over",itemSelector:"div.char-item",listeners:{dblclick:function(f,d,h,g){this.insertChar(f.getStore().getAt(d).get("char"));this.charWindow.close()},scope:this}}],buttons:[{text:"Insert",handler:function(){Ext.each(this.charWindow.charView.getSelectedRecords(),function(d){var f=d.get("char");this.insertChar(f)},this);this.charWindow.close()},scope:this},{text:"Cancel",handler:function(){this.charWindow.close()},scope:this}]});this.charWindow.show()},scope:this,tooltip:{title:"Insert Special Character"},overflowText:"Special Characters"})},insertChar:function(a){if(a){this.cmp.insertAtCursor(a)}}});Ext.ux.form.HtmlEditor.Table=Ext.extend(Ext.util.Observable,{cmd:"table",tableBorderOptions:[["none","None"],["1px solid #000","Sold Thin"],["2px solid #000","Solid Thick"],["1px dashed #000","Dashed"],["1px dotted #000","Dotted"]],init:function(a){this.cmp=a;this.cmp.on("render",this.onRender,this)},onRender:function(){var b=this.cmp;var a=this.cmp.getToolbar().addButton({iconCls:"x-edit-table",handler:function(){if(!this.tableWindow){this.tableWindow=new Ext.Window({title:"Insert Table",closeAction:"hide",items:[{itemId:"insert-table",xtype:"form",border:false,plain:true,bodyStyle:"padding: 10px;",labelWidth:60,labelAlign:"right",items:[{xtype:"numberfield",allowBlank:false,allowDecimals:false,fieldLabel:"Rows",name:"row",width:60},{xtype:"numberfield",allowBlank:false,allowDecimals:false,fieldLabel:"Columns",name:"col",width:60},{xtype:"combo",fieldLabel:"Border",name:"border",forceSelection:true,mode:"local",store:new Ext.data.ArrayStore({autoDestroy:true,fields:["spec","val"],data:this.tableBorderOptions}),triggerAction:"all",value:"none",displayField:"val",valueField:"spec",width:90}]}],buttons:[{text:"Insert",handler:function(){var h=this.tableWindow.getComponent("insert-table").getForm();if(h.isValid()){var f=h.findField("border").getValue();var c=[h.findField("row").getValue(),h.findField("col").getValue()];if(c.length==2&&c[0]>0&&c[0]<10&&c[1]>0&&c[1]<10){var g="<table>";for(var j=0;j<c[0];j++){g+="<tr>";for(var d=0;d<c[1];d++){g+="<td width='20%' style='border: "+f+";'>"+j+"-"+d+"</td>"}g+="</tr>"}g+="</table>";this.cmp.insertAtCursor(g)}this.tableWindow.hide()}else{if(!h.findField("row").isValid()){h.findField("row").getEl().frame()}else{if(!h.findField("col").isValid()){h.findField("col").getEl().frame()}}}},scope:this},{text:"Cancel",handler:function(){this.tableWindow.hide()},scope:this}]})}else{this.tableWindow.getEl().frame()}this.tableWindow.show()},scope:this,tooltip:{title:"Insert Table"},overflowText:"Table"})}});Ext.ux.form.HtmlEditor.Word=Ext.extend(Ext.util.Observable,{curLength:0,lastLength:0,lastValue:"",wordPasteEnabled:true,init:function(a){this.cmp=a;this.cmp.on("render",this.onRender,this);this.cmp.on("initialize",this.onInit,this,{delay:100,single:true})},onInit:function(){Ext.EventManager.on(this.cmp.getDoc(),{keyup:this.checkIfPaste,scope:this});this.lastValue=this.cmp.getValue();this.curLength=this.lastValue.length;this.lastLength=this.lastValue.length},checkIfPaste:function(c){var a=0;this.curLength=this.cmp.getValue().length;if(c.V==c.getKey()&&c.ctrlKey&&this.wordPasteEnabled){this.cmp.suspendEvents();a=this.findValueDiffAt(this.cmp.getValue());var b=[this.cmp.getValue().substr(0,a),this.fixWordPaste(this.cmp.getValue().substr(a,(this.curLength-this.lastLength))),this.cmp.getValue().substr((this.curLength-this.lastLength)+a,this.curLength)];this.cmp.setValue(b.join(""));this.cmp.resumeEvents()}this.lastLength=this.cmp.getValue().length;this.lastValue=this.cmp.getValue()},findValueDiffAt:function(a){for(i=0;i<this.curLength;i++){if(this.lastValue[i]!=a[i]){return i}}},fixWordPaste:function(a){var b=[/&nbsp;/ig,/[\r\n]/g,/<(xml|style)[^>]*>.*?<\/\1>/ig,/<\/?(meta|object|span)[^>]*>/ig,/<\/?[A-Z0-9]*:[A-Z]*[^>]*>/ig,/(lang|class|type|href|name|title|id|clear)=\"[^\"]*\"/ig,/style=(\'\'|\"\")/ig,/<![\[-].*?-*>/g,/MsoNormal/g,/<\\?\?xml[^>]*>/g,/<\/?o:p[^>]*>/g,/<\/?v:[^>]*>/g,/<\/?o:[^>]*>/g,/<\/?st1:[^>]*>/g,/&nbsp;/g,/<\/?SPAN[^>]*>/g,/<\/?FONT[^>]*>/g,/<\/?STRONG[^>]*>/g,/<\/?H1[^>]*>/g,/<\/?H2[^>]*>/g,/<\/?H3[^>]*>/g,/<\/?H4[^>]*>/g,/<\/?H5[^>]*>/g,/<\/?H6[^>]*>/g,/<\/?P[^>]*><\/P>/g,/<!--(.*)-->/g,/<!--(.*)>/g,/<!(.*)-->/g,/<\\?\?xml[^>]*>/g,/<\/?o:p[^>]*>/g,/<\/?v:[^>]*>/g,/<\/?o:[^>]*>/g,/<\/?st1:[^>]*>/g,/style=\"[^\"]*\"/g,/style=\'[^\"]*\'/g,/lang=\"[^\"]*\"/g,/lang=\'[^\"]*\'/g,/class=\"[^\"]*\"/g,/class=\'[^\"]*\'/g,/type=\"[^\"]*\"/g,/type=\'[^\"]*\'/g,/href=\'#[^\"]*\'/g,/href=\"#[^\"]*\"/g,/name=\"[^\"]*\"/g,/name=\'[^\"]*\'/g,/ clear=\"all\"/g,/id=\"[^\"]*\"/g,/title=\"[^\"]*\"/g,/<span[^>]*>/g,/<\/?span[^>]*>/g,/class=/g];Ext.each(b,function(c){a=a.replace(c,"")});a=a.replace(/<div[^>]*>/g,"<p>");a=a.replace(/<\/?div[^>]*>/g,"</p>");return a},onRender:function(){this.cmp.getToolbar().add({iconCls:"x-edit-wordpaste",pressed:true,handler:function(a){a.toggle(!a.pressed);this.wordPasteEnabled=!this.wordPasteEnabled},scope:this,tooltip:{text:"Cleanse text pasted from Word or other Rich Text applications"}})}});Ext.ux.form.HtmlEditor.HR=Ext.extend(Ext.util.Observable,{cmd:"hr",init:function(a){this.cmp=a;this.cmp.on("render",this.onRender,this)},onRender:function(){var b=this.cmp;var a=this.cmp.getToolbar().addButton({iconCls:"x-edit-hr",handler:function(){if(!this.hrWindow){this.hrWindow=new Ext.Window({title:"Insert Rule",closeAction:"hide",items:[{itemId:"insert-hr",xtype:"form",border:false,plain:true,bodyStyle:"padding: 10px;",labelWidth:60,labelAlign:"right",items:[{xtype:"label",html:"Enter the width of the Rule in percentage<br/> followed by the % sign at the end, or to<br/> set a fixed width omit the % symbol.<br/>&nbsp;"},{xtype:"textfield",maskRe:/[0-9]|%/,regex:/^[1-9][0-9%]{1,3}/,fieldLabel:"Width",name:"hrwidth",width:60,listeners:{specialkey:function(c,d){if((d.getKey()==d.ENTER||d.getKey()==d.RETURN)&&c.isValid()){this.doInsertHR()}else{c.getEl().frame()}},scope:this}}]}],buttons:[{text:"Insert",handler:function(){var c=this.hrWindow.getComponent("insert-hr").getForm();if(c.isValid()){this.doInsertHR()}else{c.findField("hrwidth").getEl().frame()}},scope:this},{text:"Cancel",handler:function(){this.hrWindow.hide()},scope:this}]})}else{this.hrWindow.getEl().frame()}this.hrWindow.show()},scope:this,tooltip:{title:"Insert Horizontal Rule"},overflowText:"Horizontal Rule"})},doInsertHR:function(){var b=this.hrWindow.getComponent("insert-hr").getForm();if(b.isValid()){var a=b.findField("hrwidth").getValue();if(a){this.insertHR(a)}else{this.insertHR("100%")}b.reset();this.hrWindow.hide()}},insertHR:function(a){this.cmp.insertAtCursor('<hr width="'+a+'">')}});Ext.ns("Ext.ux","Ext.ux.layout");Ext.ux.layout.HorizontalFitLayout=Ext.extend(Ext.layout.ContainerLayout,{containsScrollbar:false,monitorResize:true,onLayout:function(b,c){Ext.layout.FitLayout.superclass.onLayout.call(this,b,c);if(!this.container.collapsed){var a=c.getStyleSize();a.width=b.containsScrollbar?a.width-16:a.width;b.items.each(function(d){this.setItemSize(d,a)},this)}},setItemSize:function(b,a){if(b&&a.height>0){b.setWidth(a.width)}}});Ext.Container.LAYOUTS.hfit=Ext.ux.layout.HorizontalFitLayout;Ext.ns("Ext.ux.layout");Ext.ux.layout.CenterLayout=Ext.extend(Ext.layout.FitLayout,{setItemSize:function(b,a){this.container.addClass("ux-layout-center");b.addClass("ux-layout-center-item");if(b&&a.height>0){if(b.width){a.width=b.width}b.setSize(a)}}});Ext.Container.LAYOUTS["ux.center"]=Ext.ux.layout.CenterLayout;Ext.ns("Ext.ux.layout");Ext.ux.layout.RowLayout=Ext.extend(Ext.layout.ContainerLayout,{monitorResize:true,isValidParent:function(b,a){return b.getEl().dom.parentNode==this.innerCt.dom},onLayout:function(g,k){var b=g.items.items,j=b.length,a,c;if(!this.innerCt){k.addClass("ux-row-layout-ct");this.innerCt=k.createChild({cls:"x-row-inner"})}this.renderAll(g,this.innerCt);var l=k.getViewSize();if(l.width<1&&l.height<1){return}var d=l.height-k.getPadding("tb"),f=d;this.innerCt.setSize({height:d});for(c=0;c<j;c++){a=b[c];if(!a.rowHeight){f-=(a.getSize().height+a.getEl().getMargins("tb"))}}f=f<0?0:f;for(c=0;c<j;c++){a=b[c];if(a.rowHeight){a.setSize({height:Math.floor(a.rowHeight*f)-a.getEl().getMargins("tb")})}}}});Ext.Container.LAYOUTS["ux.row"]=Ext.ux.layout.RowLayout;Ext.ns("Ext.ux");Ext.ux.GMapPanel=Ext.extend(Ext.Panel,{initComponent:function(){var a={plain:true,zoomLevel:3,yaw:180,pitch:0,zoom:0,gmapType:"map",border:false};Ext.applyIf(this,a);Ext.ux.GMapPanel.superclass.initComponent.call(this)},afterRender:function(){var b=this.ownerCt.getSize();Ext.applyIf(this,b);Ext.ux.GMapPanel.superclass.afterRender.call(this);if(this.gmapType==="map"){this.gmap=new GMap2(this.body.dom)}if(this.gmapType==="panorama"){this.gmap=new GStreetviewPanorama(this.body.dom)}if(typeof this.addControl==="object"&&this.gmapType==="map"){this.gmap.addControl(this.addControl)}if(typeof this.setCenter==="object"){if(typeof this.setCenter.geoCodeAddr==="string"){this.geoCodeLookup(this.setCenter.geoCodeAddr)}else{if(this.gmapType==="map"){var a=new GLatLng(this.setCenter.lat,this.setCenter["long"]);this.gmap.setCenter(a,this.zoomLevel)}if(typeof this.setCenter.marker==="object"&&typeof a==="object"){this.addMarker(a,this.setCenter.marker,this.setCenter.marker.clear)}}if(this.gmapType==="panorama"){this.gmap.setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter["long"]),{yaw:this.yaw,pitch:this.pitch,zoom:this.zoom})}}var c=new Ext.util.DelayedTask();c.delay(300,function(){this.addMarkers(this.markers)},this)},onResize:function(a,b){if(typeof this.gmap=="object"){this.gmap.checkResize()}Ext.ux.GMapPanel.superclass.onResize.call(this,a,b)},setSize:function(c,a,b){if(typeof this.gmap=="object"){this.gmap.checkResize()}Ext.ux.GMapPanel.superclass.setSize.call(this,c,a,b)},getMap:function(){return this.gmap},addMarkers:function(c){if(Ext.isArray(c)){for(var b=0;b<c.length;b++){var a=new GLatLng(c[b].lat,c[b]["long"]);this.addMarker(a,c[b].marker,false,c[b].setCenter)}}},addMarker:function(c,d,b,a){Ext.applyIf(d,G_DEFAULT_ICON);if(b===true){this.gmap.clearOverlays()}if(a===true){this.gmap.setCenter(c,this.zoomLevel)}var f=new GMarker(c,d);this.gmap.addOverlay(f)},geoCodeLookup:function(a){this.geocoder=new GClientGeocoder();this.geocoder.getLocations(a,this.addAddressToMap.createDelegate(this))},addAddressToMap:function(a){if(!a||a.Status.code!=200){Ext.MessageBox.alert("Error","Code "+a.Status.code+" Error Returned")}else{place=a.Placemark[0];addressinfo=place.AddressDetails;accuracy=addressinfo.Accuracy;if(accuracy===0){Ext.MessageBox.alert("Unable to Locate Address","Unable to Locate the Address you provided")}else{if(accuracy<7){Ext.MessageBox.alert("Address Accuracy","The address provided has a low accuracy.<br><br>Level "+accuracy+" Accuracy (8 = Exact Match, 1 = Vague Match)")}else{point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);if(typeof this.setCenter.marker==="object"&&typeof point==="object"){this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true)}}}}}});Ext.reg("gmappanel",Ext.ux.GMapPanel);Ext.ns("Ext.ux");Date.prototype.getFirstDateOfWeek=function(){var a=this.clearTime();var b=this.getWeekOfYear();while(b==a.getWeekOfYear()){a=a.add(Date.DAY,-1)}a=a.add(Date.DAY,1);return a};Ext.ux.DatePickerRange=Ext.extend(Ext.DatePicker,{selectionMode:"month",setSelectionMode:function(a){this.selectionMode=a;this.setValue(this.value)},getSelectionMode:function(){return this.selectionMode()},update:function(F){var a=this.activeDate;this.activeDate=F;if(a&&this.el){var l=F.getTime();if(a.getMonth()==F.getMonth()&&a.getFullYear()==F.getFullYear()){this.cells.removeClass("x-date-selected");this.cells.each(function(d){if(this.isSelected(d.dom.firstChild.dateValue)){d.addClass("x-date-selected")}},this);return}}var h=F.getDaysInMonth();var m=F.getFirstDateOfMonth();var c=m.getDay()-this.startDay;if(c<=this.startDay){c+=7}var B=F.add("mo",-1);var f=B.getDaysInMonth()-c;var b=this.cells.elements;var o=this.textNodes;h+=c;var v=86400000;var D=(new Date(B.getFullYear(),B.getMonth(),f)).clearTime();var C=new Date().clearTime().getTime();var s=F.clearTime().getTime();var r=this.minDate?this.minDate.clearTime():Number.NEGATIVE_INFINITY;var z=this.maxDate?this.maxDate.clearTime():Number.POSITIVE_INFINITY;var G=this.disabledDatesRE;var q=this.disabledDatesText;var I=this.disabledDays?this.disabledDays.join(""):false;var E=this.disabledDaysText;var A=this.format;var j=function(K,d){d.title="";var w=D.getTime();d.firstChild.dateValue=w;if(w==C){d.className+=" x-date-today";d.title=K.todayText}if(K.isSelected(d.firstChild.dateValue)){d.className+=" x-date-selected"}if(w<r){d.className=" x-date-disabled";d.title=K.minText;return}if(w>z){d.className=" x-date-disabled";d.title=K.maxText;return}if(I){if(I.indexOf(D.getDay())!=-1){d.title=E;d.className=" x-date-disabled"}}if(G&&A){var J=D.dateFormat(A);if(G.test(J)){d.title=q.replace("%0",J);d.className=" x-date-disabled"}}};var u=0;for(;u<c;u++){o[u].innerHTML=(++f);D.setDate(D.getDate()+1);b[u].className="x-date-prevday";j(this,b[u])}for(;u<h;u++){intDay=u-c+1;o[u].innerHTML=(intDay);D.setDate(D.getDate()+1);b[u].className="x-date-active";j(this,b[u])}var H=0;for(;u<42;u++){o[u].innerHTML=(++H);D.setDate(D.getDate()+1);b[u].className="x-date-nextday";j(this,b[u])}this.mbtn.setText(this.monthNames[F.getMonth()]+" "+F.getFullYear());if(!this.internalRender){var g=this.el.dom.firstChild;var k=g.offsetWidth;this.el.setWidth(k+this.el.getBorderWidth("lr"));Ext.fly(g).setWidth(k);this.internalRender=true;if(Ext.isOpera&&!this.secondPass){g.rows[0].cells[1].style.width=(k-(g.rows[0].cells[0].offsetWidth+g.rows[0].cells[2].offsetWidth))+"px";this.secondPass=true;this.update.defer(10,this,[F])}}},isSelected:function(a){a=new Date(a);switch(this.selectionMode){case"day":return a.clearTime().getTime()==this.value.clearTime().getTime();break;case"month":return a.getFirstDateOfMonth().clearTime().getTime()==this.value.getFirstDateOfMonth().clearTime().getTime();break;case"week":return a.getFirstDateOfWeek().clearTime().getTime()==this.value.getFirstDateOfWeek().clearTime().getTime();break;default:throw"Illegal selection mode";break}}});Ext.reg("datepickerrange",Ext.ux.DatePickerRange);Ext.ns("Ext.ux","Ext.ux.tree");Ext.ux.tree.CheckboxSelectionModel=function(a){this.addEvents("beforeselect","selectionchange");Ext.apply(this,a);Ext.ux.tree.CheckboxSelectionModel.superclass.constructor.call(this)};Ext.extend(Ext.ux.tree.CheckboxSelectionModel,Ext.util.Observable,{activateLeafNodesOnly:false,optimizeSelection:false,activeNode:null,defaultValue:false,activate:function(a){if(!a){return}if(this.activateLeafNodesOnly&&!a.isLeaf()){return false}if(this.activeNode){this.activeNode.ui.onSelectedChange(false)}this.activeNode=a;a.ui.onSelectedChange(true)},clearSelections:function(b){this.suspendEvents(false);var d=this.tree.getChecked();if(d.length>0){for(var c=0,a=d.length;c<a;c++){d[c].ui.toggleCheck(false)}}this.resumeEvents()},getActiveNode:function(){return this.activeNode},getSelectedNodes:function(){return this.tree.getChecked()},init:function(a){this.tree=a;a.getTreeEl().on("keydown",this.onKeyDown,this);a.on("click",this.onNodeClick,this);a.on("beforeappend",this.onBeforeAppend,this);a.on("checkchange",this.onCheckChange,this)},isSelected:function(a){if(a&&a.ui){return a.ui.isChecked()}},onBeforeAppend:function(a,b,c){c.attributes.checked=this.defaultValue},onCheckChange:function(b,a){if(a){this.activate(b);if(this.optimizeSelection){this.optimize(b)}}else{}this.fireEvent("selectionchange",this,this.tree.getChecked())},onNodeClick:function(a){this.select(a);this.activate(a)},select:function(a,c,b){if(!a.ui.isChecked()&&this.fireEvent("beforeselect",this,a)!==false){a.ui.toggleCheck(true)}return a},unselect:function(a){a.ui.toggleCheck(false)},optimize:function(a){this.suspendEvents();this.unselectChildNodes(a);while(a=a.parentNode){if(this.isSelected(a)){a.unselect()}}this.resumeEvents()},unselectChildNodes:function(b){if(b.isExpandable()&&b.isExpanded()){for(var a=0;a<b.childNodes.length;a++){if(b.childNodes[a].isExpandable()){this.unselectChildNodes(b.childNodes[a])}b.childNodes[a].unselect()}}},onKeyDown:Ext.tree.DefaultSelectionModel.prototype.onKeyDown,selectNext:Ext.tree.DefaultSelectionModel.prototype.selectNext,selectPrevious:Ext.tree.DefaultSelectionModel.prototype.selectPrevious});Ext.ns("Ext.ux.display");Ext.ux.display.DisplayPanel=Ext.extend(Ext.form.FormPanel,{cls:"x-ux-display",layout:"ux.display",loadRecord:function(a){return this.getForm().loadRecord(a)},onRender:function(){this.supr().onRender.apply(this,arguments)}});Ext.reg("ux.displaypanel",Ext.ux.display.DisplayPanel);Ext.ns("Ext.ux.display");Ext.ux.display.DisplayField=Ext.extend(Ext.form.DisplayField,{htmlEncode:true,nl2br:false,renderer:function(a){return a},setRawValue:function(b){var a=this.renderer(b);if(this.htmlEncode){a=Ext.util.Format.htmlEncode(a)}if(this.nl2br){a=Ext.util.Format.nl2br(a)}return this.rendered?(this.el.dom.innerHTML=(Ext.isEmpty(a)?"":a)):(this.value=a)}});Ext.reg("ux.displayfield",Ext.ux.display.DisplayField);Ext.ux.display.DisplayTextArea=Ext.extend(Ext.form.TextArea,{readOnly:true,cls:"x-ux-display-textarea"});Ext.reg("ux.displaytextarea",Ext.ux.display.DisplayTextArea);Ext.ns("Ext.ux.layout");Ext.ux.layout.DisplayLayout=Ext.extend(Ext.layout.FormLayout,{background:"none",onLayout:function(a,b){Ext.ux.layout.DisplayLayout.superclass.onLayout.apply(this,arguments);b.addClass("x-ux-display-background-"+this.background);if(this.declaration&&!this.declEl){this.declEl=b.createChild({dom:"div",html:this.declaration,"class":"x-ux-display-declaration x-ux-display-background-declaration"})}},destroy:function(){if(this.declEl){this.declEl.remove()}Ext.ux.layout.DisplayLayout.superclass.destroy.call(this)}});Ext.Container.LAYOUTS["ux.display"]=Ext.ux.layout.DisplayLayout;Ext.ns("Ext.ux");Ext.ux.MessageBox=function(){var b;function a(c,d){return['<div class="x-ux-messagebox-msg">','<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>','<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>',c,"</h3>",d,"</div></div></div>",'<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',"</div>"].join("")}return{msg:function(g,f){if(!b){b=Ext.DomHelper.insertFirst(document.body,{id:"x-ux-messagebox-msg-div"},true)}b.alignTo(document,"t-t");var d=String.format.apply(String,Array.prototype.slice.call(arguments,1));var c=Ext.DomHelper.append(b,{html:a(g,d)},true);c.slideIn("t").pause(2).ghost("t",{remove:true})}}}();Ext.ns("Ext.ux");Ext.ux.TabPanelSortPlugin=function(a){Ext.apply(this,a)};Ext.ux.TabPanelSortPlugin.prototype={dragZoneConfig:null,dropZoneConfig:null,tabpanel:null,pos:null,init:function(a){this.tabpanel=a;this.tabpanel.addEvents("tabsort");this.tabpanel.on("render",this.onRender,this)},onRender:function(a){this.dragZone=new Ext.dd.DragZone(a.header,Ext.apply({getDragData:this.getDragData.createDelegate(this),getRepairXY:this.getRepairXY.createDelegate(this)},this.dragZoneConfig||{}));this.dropZone=new Ext.dd.DropZone(a.header,Ext.apply({onNodeOver:this.onNodeOver.createDelegate(this),onNodeDrop:this.onNodeDrop.createDelegate(this),getTargetFromEvent:this.getTargetFromEvent.createDelegate(this)},this.dropZoneConfig||{}))},getDDEl:function(){if(!this.ddel){this.ddel=Ext.get(document.createElement("div"))}return this.ddel},getDragData:function(b){var a=this.tabpanel.findTargets(b);if(a.el){this.pos=this.tabpanel.items.indexOf(a.item);var c=this.getDDEl();c.update(Ext.DomQuery.selectNode("span[class^=x-tab-strip-text]",a.el).innerHTML);return Ext.apply(a,{pos:this.pos,ddel:c.dom,repairXY:Ext.fly(a.el).getXY()})}},onNodeOver:function(g,a,f,d){var g=this.tabpanel.findTargets(f);if(g.el){this.pos=this.tabpanel.items.indexOf(g.item);var c=Ext.fly(g.el).getBox(),b=(f.getXY()[0]>c.x+c.width/2)?"r":"l";if(this.pos>d.pos&&b==="l"){this.pos=--this.pos}else{if(this.pos<d.pos&&b==="r"){this.pos=++this.pos}}}return Ext.dd.DropZone.prototype.dropAllowed},onNodeDrop:function(d,a,c,b){if(this.pos==(this.tabpanel.items.length)-1){Ext.fly(b.el).insertAfter(this.tabpanel.items.itemAt(this.pos).tabEl)}else{if(this.tabpanel.items.indexOf(b.item)<this.pos){Ext.fly(b.el).insertBefore(this.tabpanel.items.itemAt(this.pos+1).tabEl)}else{Ext.fly(b.el).insertBefore(this.tabpanel.items.itemAt(this.pos).tabEl)}}this.tabpanel.items.remove(b.item);this.tabpanel.items.insert(this.pos,b.item);this.tabpanel.fireEvent("tabsort",this.tabpanel);return true},getRepairXY:function(a){return this.dragZone.dragData.repairXY},getTargetFromEvent:function(a){return a.getTarget("ul[class^=x-tab]",10)}};Ext.ns("Ext.ux");Ext.ux.ItemRegistry=function(a){Ext.apply(this,a)};Ext.ux.ItemRegistry.itemMap={};Ext.ux.ItemRegistry.registerItem=function(a,b,c){if(!Ext.ux.ItemRegistry.itemMap.hasOwnProperty(a)){Ext.ux.ItemRegistry.itemMap[a]=[]}Ext.ux.ItemRegistry.itemMap[a].push({item:b,pos:c})};Ext.ux.ItemRegistry.prototype={key:null,init:function(b){this.cmp=b;if(!this.key){this.key=b.getItemId()}this.cmp.items.each(function(d,c){if(!d.hasOwnProperty("registerdItemPos")){d.registerdItemPos=c*10}},this);var a=Ext.ux.ItemRegistry.itemMap[this.key]||[];Ext.each(a,function(d){var f=this.getItem(d),c=null;this.cmp.items.each(function(h,g){if(f.registerdItemPos<h.registerdItemPos){this.cmp.insert(g,f);c=g;return false}return true},this);if(!Ext.isNumber(c)){this.cmp.add(f)}},this)},getItem:function(a){var c=a.item,b;if(typeof c==="function"){b=new c(this.config)}else{if(Ext.isString(c)){c={xtype:c}}b=this.cmp.lookupComponent(c)}b.registerdItemPos=a.pos?a.pos:this.cmp.items.length*10;return b}};Ext.ComponentMgr.registerPlugin("ux.itemregistry",Ext.ux.ItemRegistry);Ext.applyIf(Function.prototype,{deferByTickets:function(g,b,a){var c=this.createDelegate(g,b,a),d=[];var f=function(){if(Ext.isEmpty(d)){c()}};return function(){var h=Ext.id();d.push(h);return function(){d.remove(h);f()}}}});Ext.ux.Printer=function(){return{renderers:{},registerRenderer:function(b,a){this.renderers[b]=new (a)()},getRenderer:function(a){return this.renderers[a]},print:function(a){var d=a.getXTypes().split("/");for(var b=d.length-1;b>=0;b--){var f=d[b],c=this.getRenderer(f);if(c!=undefined){c.print(a);break}}}}}();Ext.override(Ext.Component,{getXTypes:function(){var a=this.constructor;if(!a.xtypes){var f=[],b=this;while(b){var d=b.constructor.xtype;if(d!=undefined){f.unshift(d)}b=b.constructor.superclass}a.xtypeChain=f;a.xtypes=f.join("/")}return a.xtypes}});Ext.ux.Printer.BaseRenderer=Ext.extend(Object,{printStrategy:"iframe",print:function(a){return this[this.printStrategy+"Print"](a)},windowPrint:function(b){var a=b&&b.getXType?String.format("print_{0}_{1}",b.getXType(),b.id.replace(/-/g,"_")):"print";var c=window.open("",a);c.document.write(this.generateHTML(b));c.document.close();if(Ext.isGecko){c.print();c.close();return}this.doPrintOnStylesheetLoad.defer(10,this,[c])},iframePrint:function(a){var d=Ext.id(),b=document,c=b.createElement("iframe");Ext.fly(c).set({id:d,name:d,style:{position:"absolute",width:"210mm",height:"297mm",top:"-10000px",left:"-10000px"}});b.body.appendChild(c);Ext.fly(c).set({src:Ext.SSL_SECURE_URL});var b=c.contentWindow.document||c.contentDocument||WINDOW.frames[d].document;b.open();b.write(this.generateHTML(a));b.close();this.doPrintOnStylesheetLoad.defer(10,this,[c.contentWindow])},doPrintOnStylesheetLoad:function(c){var b=c.document.getElementById("csscheck"),a=b.currentStyle||getComputedStyle(b,null);if(a.display!=="none"){this.doPrintOnStylesheetLoad.defer(10,this,[c]);return}c.print();c.close()},generateHTML:function(a){return new Ext.XTemplate('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',"<html>","<head>",'<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />','<link href="'+this.stylesheetPath+"?"+new Date().getTime()+'" rel="stylesheet" type="text/css" media="screen,print" />',"<title>"+this.getTitle(a)+"</title>","</head>","<body>",'<div id="csscheck"></div>',this.generateBody(a),"</body>","</html>").apply(this.prepareData(a))},generateBody:Ext.emptyFn,prepareData:function(a){return a},getTitle:function(a){return typeof a.getTitle=="function"?a.getTitle():(a.title||"Printing")},stylesheetPath:"stylesheets/print.css"});Ext.ux.Printer.GridPanelRenderer=Ext.extend(Ext.ux.Printer.BaseRenderer,{generateBody:function(c){var b=this.getColumns(c);var d=this.headerTpl.apply(b);var a=this.bodyTpl.apply(b);return String.format('<table>{0}<tpl for=".">{1}</tpl></table>',d,a)},prepareData:function(b){var a=this.getColumns(b);var c=[];b.store.data.each(function(d){var f={};Ext.iterate(d.data,function(g,h){Ext.each(a,function(j){if(j.dataIndex==g){f[g]=j.renderer?j.renderer(h,null,d):h;f[g]=f[g]||"";return false}},this)});c.push(f)});return c},getColumns:function(b){var a=[];Ext.each(b.getColumnModel().config,function(c){if(c.hidden!=true){a.push(c)}},this);return a},headerTpl:new Ext.XTemplate("<tr><thead>",'<tpl for=".">',"<th>{header}</th>","</tpl>","</thead></tr>"),bodyTpl:new Ext.XTemplate("<tr>",'<tpl for=".">',"<td>{{dataIndex}}</td>","</tpl>","</tr>")});Ext.ux.Printer.registerRenderer("grid",Ext.ux.Printer.GridPanelRenderer);Ext.ux.Printer.ColumnTreeRenderer=Ext.extend(Ext.ux.Printer.BaseRenderer,{generateBody:function(b){var c=this.getColumns(b);var d=this.headerTpl.apply(c);var a=this.bodyTpl.apply(c);return String.format('<table>{0}<tpl for=".">{1}</tpl></table>',d,a)},getColumns:function(a){return a.columns},prepareData:function(a){var b=a.root,d=[],h=this.getColumns(a),g=this.indentPadding;var c=function(f){if(f.hidden===true||f.isHiddenRoot()===true){return}var j=Ext.apply({depth:f.getDepth()*g},f.attributes);Ext.iterate(j,function(k,l){Ext.each(h,function(m){if(m.dataIndex==k){j[k]=m.renderer?m.renderer(l):l}},this)});j[this.getColumns(a)[0].dataIndex]=f.attributes.text;d.push(j)};b.cascade(c,this);return d},indentPadding:15,headerTpl:new Ext.XTemplate("<tr>",'<tpl for=".">','<th width="{width}">{header}</th>',"</tpl>","</tr>"),bodyTpl:new Ext.XTemplate("<tr>",'<tpl for=".">','<td style="padding-left: {[xindex == 1 ? "\\{depth\\}" : "0"]}px">{{dataIndex}}</td>',"</tpl>","</tr>")});Ext.ux.Printer.registerRenderer("columntree",Ext.ux.Printer.ColumnTreeRenderer);Ext.ns("Tine.Tinebase","Tine.Tinebase.data");Tine.Tinebase.data.Record=function(a,b){if(b||b===0){this.id=b}else{if(a[this.idProperty]){this.id=a[this.idProperty]}else{this.id=++Ext.data.Record.AUTO_ID}}this.data=a};Ext.extend(Tine.Tinebase.data.Record,Ext.data.Record,{appName:null,modelName:null,idProperty:"id",titleProperty:null,recordName:"record",recordsName:"records",containerProperty:"container_id",containerName:"container",containersName:"containers",defaultFilter:null,cfExp:/^#(.+)/,get:function(a){if(cfName=String(a).match(this.cfExp)){return this.data.customfields?this.data.customfields[cfName[1]]:null}return this.data[a]},set:function(a,c){var b=Ext.isPrimitive(c)?String:Ext.encode,d=this.get(a);if(b(d)==b(c)){return}this.dirty=true;if(!this.modified){this.modified={}}if(this.modified[a]===undefined){this.modified[a]=d}if(cfName=String(a).match(this.cfExp)){this.data.customfields=this.data.customfields||{};this.data.customfields[cfName[1]]=c}else{this.data[a]=c}if(!this.editing){this.afterEdit()}},getTitle:function(){var a=this.titleProperty?this.titleProperty.split("."):[null];return(a.length>0&&this.get(a[0])&&this.get(a[0])[a[1]])?this.get(a[0])[a[1]]:a[0]?this.get(this.titleProperty):""},getId:function(){return this.get(this.idProperty?this.idProperty:"id")},toString:function(){return Ext.encode(this.data)}});Tine.Tinebase.data.Record.create=function(k,j){var d=Ext.extend(Tine.Tinebase.data.Record,{});var h=d.prototype;Ext.apply(h,j);h.fields=new Ext.util.MixedCollection(false,function(f){return f.name});for(var b=0,a=k.length;b<a;b++){h.fields.add(new Ext.data.Field(k[b]))}d.getField=function(f){return h.fields.get(f)};d.getMeta=function(f){var l=null;switch(f){case ("phpClassName"):l=h.appName+"_Model_"+h.modelName;break;default:l=h[f]}return l};d.getDefaultData=function(){return{}};d.getFieldDefinitions=function(){return h.fields.items};d.getFieldNames=function(){if(!h.fieldsarray){var f=h.fieldsarray=[];Ext.each(h.fields.items,function(l){f.push(l.name)})}return h.fieldsarray};d.hasField=function(f){return h.fields.indexOfKey(f)>=0};d.getRecordName=function(){var l=f=Tine.Tinebase.appMgr.get(h.appName),f=l&&l.i18n?l.i18n:Tine.Tinebase.translation;return f.n_(h.recordName,h.recordsName,1)};d.getRecordsName=function(){var l=f=Tine.Tinebase.appMgr.get(h.appName),f=l&&l.i18n?l.i18n:Tine.Tinebase.translation;return f.n_(h.recordName,h.recordsName,50)};d.getContainerName=function(){var l=f=Tine.Tinebase.appMgr.get(h.appName),f=l&&l.i18n?l.i18n:Tine.Tinebase.translation;return f.n_(h.containerName,h.containersName,1)};d.getContainersName=function(){var l=f=Tine.Tinebase.appMgr.get(h.appName),f=l&&l.i18n?l.i18n:Tine.Tinebase.translation;return f.n_(h.containerName,h.containersName,50)};d.getAppName=function(){return Tine.Tinebase.appMgr.get(h.appName).i18n._(h.appName)};d.getPhpClassName=function(m,l){if(!m&&!l){return d.getMeta("phpClassName")}if(Ext.isFunction(m.getMeta)){return m.getMeta("phpClassName")}var f=(Ext.isObject(m)&&m.hasOwnProperty("name"))?m.name:m;return f+"_Model_"+l};var c=d.getMeta("containerProperty");if(c){var g=h.fields.get(c);if(g){g.label=h.containerName}}Tine.Tinebase.data.RecordMgr.add(d);return d};Tine.Tinebase.data.Record.generateUID=function(b){var a=String(CryptoJS.SHA1(String(Math.floor(Math.random()*Math.pow(10,16)))+String(new Date().getMilliseconds())));if(b){a=a.substring(0,b)}return a};Tine.Tinebase.data.RecordManager=Ext.extend(Ext.util.MixedCollection,{add:function(c){if(!Ext.isFunction(c.getMeta)){throw new Ext.Error("only records of type Tinebase.data.Record could be added")}var a=c.getMeta("appName"),b=c.getMeta("modelName");if(!a&&b){throw new Ext.Error("appName and modelName must be in the metadatas")}Tine.Tinebase.data.RecordManager.superclass.add.call(this,a+"."+b,c)},get:function(a,b){if(Ext.isFunction(a.getMeta)){return a}if(!b&&a.modelName){b=a.modelName}if(a.appName){a=a.appName}if(!Ext.isString(a)){throw new Ext.Error("appName must be a string")}Ext.each([a,b],function(d){if(!Ext.isString(d)){return}var c=d.split(/(?:_Model_)|(?:\.)/);if(c.length>1){a=c[0];b=c[1]}});return Tine.Tinebase.data.RecordManager.superclass.get.call(this,a+"."+b)}});Tine.Tinebase.data.RecordMgr=new Tine.Tinebase.data.RecordManager(true);Tine.Tinebase.data.RecordStore=function(a){a.batchTransactions=false;a.appName=a.recordClass.getMeta("appName");a.modelName=a.recordClass.getMeta("modelName");if(typeof(a.reader)=="undefined"){a.reader=new Ext.data.JsonReader({root:a.root||"results",totalProperty:a.totalProperty||"totalcount",id:a.recordClass.getMeta("idProperty")},a.recordClass)}if(typeof(a.writer)=="undefined"&&!a.readOnly){a.writer=new Ext.data.JsonWriter({})}if(typeof(a.proxy)=="undefined"){a.proxy=new Tine.Tinebase.data.RecordProxy({recordClass:a.recordClass})}Tine.Tinebase.data.RecordStore.superclass.constructor.call(this,a)};Ext.extend(Tine.Tinebase.data.RecordStore,Ext.data.Store,{});Ext.reg("tinerecordstore",Tine.Tinebase.data.RecordStore);Ext.ns("Tine.Tinebase.data");Tine.Tinebase.data.RecordProxy=function(a){a.api={read:true,create:true,update:true,destroy:true};Tine.Tinebase.data.RecordProxy.superclass.constructor.call(this,a);Ext.apply(this,a);this.appName=this.appName?this.appName:a.recordClass.getMeta("appName");this.modelName=this.modelName?this.modelName:a.recordClass.getMeta("modelName");this.idProperty=this.idProperty?this.idProperty:a.recordClass.getMeta("idProperty");this.jsonReader=new Ext.data.JsonReader({id:this.idProperty,root:"results",totalProperty:"totalcount"},this.recordClass)};Ext.extend(Tine.Tinebase.data.RecordProxy,Ext.data.DataProxy,{recordClass:null,appName:null,idProperty:null,modelName:null,transId:null,abort:function(a){return Ext.Ajax.abort(a)},isLoading:function(a){return Ext.Ajax.isLoading(a)},loadRecord:function(a,b){b=b||{};b.params=b.params||{};b.beforeSuccess=function(d){return[this.recordReader(d)]};var c=b.params;c.method=this.appName+".get"+this.modelName;c.id=a.get(this.idProperty);return this.doXHTTPRequest(b)},searchRecords:function(c,a,b){b=b||{};b.params=b.params||{};var d=b.params;d.method=this.appName+".search"+this.modelName+"s";d.filter=(c)?c:[];d.paging=a;b.beforeSuccess=function(f){return[this.jsonReader.read(f)]};b.timeout=60000;return this.doXHTTPRequest(b)},saveRecord:function(a,c,b){c=c||{};c.params=c.params||{};c.beforeSuccess=function(f){return[this.recordReader(f)]};var d=c.params;d.method=this.appName+".save"+this.modelName;d.recordData=a.data;if(b){Ext.apply(d,b)}c.timeout=300000;return this.doXHTTPRequest(c)},deleteRecords:function(a,b){b=b||{};b.params=b.params||{};b.params.method=this.appName+".delete"+this.modelName+"s";b.params.ids=this.getRecordIds(a);b.timeout=120000;return this.doXHTTPRequest(b)},deleteRecordsByFilter:function(b,a){a=a||{};a.params=a.params||{};a.params.method=this.appName+".delete"+this.modelName+"sByFilter";a.params.filter=b;a.timeout=300000;return this.doXHTTPRequest(a)},updateRecords:function(b,c,a){a=a||{};a.params=a.params||{};a.params.method=this.appName+".updateMultiple"+this.modelName+"s";a.params.filter=b;a.params.values=c;a.beforeSuccess=function(d){return[Ext.util.JSON.decode(d.responseText)]};return this.doXHTTPRequest(a)},getRecordIds:function(a){var c=[];if(!Ext.isArray(a)){a=[a]}for(var b=0;b<a.length;b++){c.push(a[b].id?a[b].id:a.id)}return c},load:function(f,b,g,d,a){if(this.fireEvent("beforeload",this,f)!==false){var c={sort:f.sort,dir:f.dir,start:f.start,limit:f.limit};this.searchRecords(f.filter,c,{scope:this,success:function(h){g.call(d||this,h,a,true)},failure:function(h){this.fireEvent("loadexception",this,"remote",h,a)}})}else{g.call(d||this,null,a,false)}},doRequest:function(g,b,h,a,j,d,c){var f={params:h,callback:j,scope:d};switch(g){case Ext.data.Api.actions.create:this.saveRecord(b,f);break;case Ext.data.Api.actions.read:this.load(h,a,j,d,c);break;case Ext.data.Api.actions.update:this.saveRecord(b,f);break;case Ext.data.Api.actions.destroy:this.deleteRecords(b,f);break}},getReader:function(){return this.jsonReader},recordReader:function(c){var b=Ext.util.JSON.decode('{"results": ['+c.responseText+"]}");var f=this.jsonReader.readRecords(b);var a=f.records[0];var d=a.get(a.idProperty);a.id=d?d:0;return a},isLoading:function(a){return Ext.Ajax.isLoading(a)},doXHTTPRequest:function(b){var a={scope:this,params:b.params,callback:b.callback,success:function(c){if(typeof b.success=="function"){var d=[];if(typeof b.beforeSuccess=="function"){d=b.beforeSuccess.call(this,c)}b.success.apply(b.scope,d)}},failure:function(d,c){var h=Ext.decode(d.responseText),g=h.data?h.data:h;g.request=c.jsonData;g.response=d.responseText;if(typeof b.failure=="function"){var f=[];if(typeof b.beforeFailure=="function"){f=b.beforeFailure.call(this,d)}else{f=[g]}Tine.log.debug("Tine.Tinebase.data.RecordProxy::doXHTTPRequest -> call failure fn");b.failure.apply(b.scope,f)}else{if(!b.callback){Tine.log.debug("Tine.Tinebase.data.RecordProxy::doXHTTPRequest -> handle exception");this.handleRequestException(g)}else{Tine.log.debug("Tine.Tinebase.data.RecordProxy::doXHTTPRequest -> call callback fn")}}}};if(b.timeout){a.timeout=b.timeout}this.transId=Ext.Ajax.request(a);return this.transId},handleRequestException:function(a){Tine.Tinebase.ExceptionHandler.handleRequestException(a)}});Ext.ns("Tine.Tinebase.data");Tine.Tinebase.data.AbstractBackend=function(a){Tine.Tinebase.data.AbstractBackend.superclass.constructor.call(this);Ext.apply(this,a)};Ext.extend(Tine.Tinebase.data.AbstractBackend,Ext.data.DataProxy,{appName:null,modelName:null,recordClass:null,idProperty:"id",loadRecord:function(a,b){b.success.defer(1000,b.scope,a)},searchRecords:function(c,a,b){b.success.defer(1000,b.scope,[{records:[],success:1,totalRecords:0}])},saveRecord:function(a,b){a.commit(true);b.success.defer(1000,b.scope,[a])},deleteRecords:function(a,b){b.success.defer(1000,b.scope)},updateRecords:function(b,c,a){a.success.defer(1000,a.scope,[])},getRecordIds:function(a){var c=[];if(!Ext.isArray(a)){a=[a]}for(var b=0;b<a.length;b++){c.push(a[b].id?a[b].id:a.id)}return c},load:function(f,b,g,d,a){if(this.fireEvent("beforeload",this,f)!==false){var c={sort:f.sort,dir:f.dir,start:f.start,limit:f.limit};this.searchRecords(f.filter,c,{scope:this,success:function(h){g.call(d||this,h,a,true)}})}else{g.call(d||this,null,a,false)}},getReader:function(){},isLoading:function(a){}});Ext.ns("Tine.Tinebase");Tine.Tinebase.StateProvider=function(a){Tine.Tinebase.StateProvider.superclass.constructor.call(this);Ext.apply(this,a);this.state=this.readRegistry()};Ext.extend(Tine.Tinebase.StateProvider,Ext.state.Provider,{clear:function(b){Tine.Tinebase.clearState(b);var a=Tine.Tinebase.registry.get("stateInfo");delete a[b];Tine.Tinebase.StateProvider.superclass.clear.call(this,b)},readRegistry:function(){var b={};var a=Tine.Tinebase.registry.get("stateInfo");for(var c in a){b[c]=this.decodeValue(a[c])}return b},set:function(c,d){if(typeof d=="undefined"||d===null){this.clear(c);return}var b=this.encodeValue(d);Tine.Tinebase.setState(c,b);var a=Tine.Tinebase.registry.get("stateInfo");a[c]=b;Tine.Tinebase.StateProvider.superclass.set.call(this,c,d)}});Ext.ns("Tine","Tine.Tinebase");Tine.Tinebase.ExceptionHandler=function(){var c=function(){var f=a.apply(this,arguments);var d="<table>";for(p in f){if(f.hasOwnProperty(p)){d+="<tr><td><b>"+p+"</b></td><td>"+f[p]+"</td></tr>"}}d+="</table>";if(d.match(/versioncheck/)){return true}if(d.match(/chrome/)){return true}if(d.match(/OpenLayers\.js/)&&d.match(/element is null/)){return true}if(d.match(/swf\.setDataProvider/)){return true}return false};var a=function(){var g={name:"unknown error",message:"unknown",code:"unknown",description:"unknown",url:"unknown",line:"unknown"};var f=[];for(var h=0;h<arguments.length;h++){f[h]=arguments[h]}if(f[0] instanceof Error){g.name=f[0].name;g.message=f[0].message;g.code=f[0].number&65535;g.description=f[0].description}else{if((f.length==3)&&(typeof(f[2])=="number")){g.name="catchable exception";g.message=f[0];g.url=f[1];g.line=f[2]}else{g.message="An unknown JS error has occured.";g.description="The following information may be useful:\n";for(var d=0;d<f.length;d++){try{g.description+=(Ext.encode(f[d])+"\n")}catch(j){g.description+="Could not encode error args: "+j+"\n"}}}}return g};var b=function(g,l,d){if(!g.code&&g.responseText){var f=Ext.util.JSON.decode(g.responseText);g=f.data}var j={buttons:Ext.Msg.OK,icon:Ext.MessageBox.WARNING,fn:l,scope:d};Tine.log.debug("Tine.Tinebase.ExceptionHandler::handleRequestException -> Exception:");Tine.log.debug(g);if(!l){l=Ext.emptyFn}if(!d){d=this}switch(g.code){case 401:Ext.MessageBox.show(Ext.apply(j,{title:_("Authorisation Required"),msg:_("Your session timed out. You need to login again."),fn:function(){var m=(Tine.Tinebase.registry.get("redirectUrl"));if(m&&m!=""){window.location=Tine.Tinebase.registry.get("redirectUrl")}else{window.location.reload()}}}));break;case 403:Ext.MessageBox.show(Ext.apply(j,{title:_("Insufficient Rights"),msg:_("Sorry, you are not permitted to perform this action"),icon:Ext.MessageBox.ERROR}));break;case 404:Ext.MessageBox.show(Ext.apply(j,{title:_("Not Found"),msg:_("Sorry, your request could not be completed because the required data could not be found. In most cases this means that someone already deleted the data. Please refresh your current view."),icon:Ext.MessageBox.ERROR}));break;case 409:Ext.MessageBox.show(Ext.apply(j,{title:_("Concurrent Updates"),msg:_("Someone else saved this record while you where editing the data. You need to reload and make your changes again.")}));break;case 503:Ext.MessageBox.show(Ext.apply(j,{title:_("Service Unavailable"),msg:_("The server is currently unable to handle the request due to a temporary overloading, maintenance or misconfiguration of the server. Please try again or contact your administrator.")}));break;case 505:var h=g.message?"<br /><b>"+_("Server Message:")+"</b><br />"+g.message:"";Ext.MessageBox.show(Ext.apply(j,{title:_("Invalid Data"),msg:_("Your input data is not valid. Please provide valid data.")+h}));break;case 510:(function(){alert(_("Connection lost, please check your network!"))}).defer(1000);break;case 520:Ext.MessageBox.show(Ext.apply(j,{title:_("Timeout"),msg:_("Sorry, some timeout occured while processing your request. Please reload your browser, try again or contact your administrator.")}));break;case 540:Ext.MessageBox.show(Ext.apply(j,{title:_("No Response"),msg:_("Sorry, the Server did not respond any data. Please reload your browser, try again or contact your administrator.")}));break;case 550:Ext.MessageBox.show(Ext.apply(j,{title:_("Out of Resources"),msg:_('Sorry, the Server stated a "memory exhausted" condition. Please contact your administrator.')}));break;case 600:Ext.MessageBox.show(Ext.apply(j,{title:_(g.title),msg:_(g.message)}));break;case 610:Ext.MessageBox.show(Ext.apply(j,{title:_("No Role Memberships"),msg:_("Your user account has no role memberships. Please contact your administrator.")}));break;default:var k=400;if(Ext.getBody().getHeight(true)*0.7<k){k=Ext.getBody().getHeight(true)*0.7}if(!Tine.Tinebase.exceptionDlg){Tine.Tinebase.exceptionDlg=new Tine.Tinebase.ExceptionDialog({height:k,exception:g,listeners:{close:function(){Tine.Tinebase.exceptionDlg=null}}});Tine.Tinebase.exceptionDlg.show()}break}if(Tine.Tinebase.registry&&Tine.Tinebase.registry.get("config")&&Tine.Tinebase.registry.get("config").automaticBugreports&&Tine.Tinebase.registry.get("config").automaticBugreports.value&&!Tine.Tinebase.exceptionDlg){Tine.log.debug("Tine.Tinebase.ExceptionHandler::handleRequestException -> Activate non-interacive exception dialog.");Tine.Tinebase.exceptionDlg=new Tine.Tinebase.ExceptionDialog({exception:g,nonInteractive:true,listeners:{close:function(){Tine.Tinebase.exceptionDlg=null}}});Tine.Tinebase.exceptionDlg.show()}};window.onerror=!window.onerror?c:window.onerror.createSequence(c);return{handleRequestException:b}}();Ext.ns("Tine","Tine.Tinebase");Tine.Tinebase.ExceptionDialog=Ext.extend(Ext.Window,{width:400,height:600,xtype:"panel",layout:"fit",plain:true,closeAction:"close",autoScroll:true,releaseMode:true,nonInteractive:false,initComponent:function(){this.currentAccount=Tine.Tinebase.registry.get("currentAccount");if(!Tine.Tinebase.registry.get("version")||Tine.Tinebase.registry.get("version").buildType!="RELEASE"){this.releaseMode=false;this.width=800}var c="";if(Ext.isArray(this.exception.trace)){for(var b=0,a=this.exception.trace.length;b<a;b++){c+=(this.exception.trace[b].file?this.exception.trace[b].file:"[internal function]")+(this.exception.trace[b].line?"("+this.exception.trace[b].line+")":"")+": "+(this.exception.trace[b]["class"]?"<b>"+this.exception.trace[b]["class"]+this.exception.trace[b].type+"</b>":"")+"<b>"+this.exception.trace[b]["function"]+"</b>("+((this.exception.trace[b].args&&this.exception.trace[b].args[0])?this.exception.trace[b].args[0]:"")+")<br/>"}this.exception.traceHTML=c}this.title=_("Abnormal End");this.items=this.getReportForm();Tine.Tinebase.ExceptionDialog.superclass.initComponent.call(this);this.on("show",function(){if(this.nonInteractive){Tine.log.debug("Tine.Tinebase.ExceptionDialog::onShow -> Sending bugreport non-interactive ...");this.onSendReport()}else{this.setHeight(this.getHeight()+10)}},this);this.on("close",function(){if(Tine.Tinebase.registry&&Tine.Tinebase.registry.get("config")&&Tine.Tinebase.registry.get("config").automaticBugreports&&Tine.Tinebase.registry.get("config").automaticBugreports.value&&!this.nonInteractive){Tine.log.debug("Tine.Tinebase.ExceptionDialog::onCancel -> Activate non-interacive exception dialog.");Tine.Tinebase.exceptionDlg=new Tine.Tinebase.ExceptionDialog({exception:this.exception,nonInteractive:true,listeners:{close:function(){Tine.Tinebase.exceptionDlg=null}}});Tine.Tinebase.exceptionDlg.show()}},this)},initButtons:function(){this.reportButtons=[{text:_("Cancel"),iconCls:"action_cancel",scope:this,handler:function(){this.close()}},{text:_("Send Report"),iconCls:"action_saveAndClose",scope:this,enabled:Tine.Tinebase.common.hasRight("report_bugs","Tinebase"),handler:this.onSendReport}];return this.reportButtons},getReportForm:function(){this.initButtons();this.reportForm=new Ext.FormPanel({id:"tb-exceptiondialog-frompanel",bodyStyle:"padding:5px;",buttonAlign:"right",labelAlign:"top",autoScroll:true,buttons:this.reportButtons,items:[{xtype:"panel",border:false,html:'<div class="tb-exceptiondialog-text"><p>'+_("An error occurred, the program ended abnormal.")+"</p><p>"+_("The last action you made was potentially not performed correctly.")+"</p><p>"+_("Please help improving this software and notify the vendor. Include a brief description of what you where doing when the error occurred.")+"</p></div>"},{id:"tb-exceptiondialog-description",height:60,xtype:"textarea",fieldLabel:_("Description"),name:"description",anchor:"95%",readOnly:false},{xtype:"fieldset",id:"tb-exceptiondialog-send-contact",anchor:"95%",title:_("Send Contact Information"),autoHeight:true,checkboxToggle:true,items:[{id:"tb-exceptiondialog-contact",xtype:"textfield",hideLabel:true,anchor:"100%",name:"contact",value:this.currentAccount.accountFullName+" "+this.currentAccount.accountEmailAddress}]},{xtype:"panel",width:"95%",layout:"form",collapsible:true,collapsed:this.releaseMode,title:_("Details:"),defaults:{xtype:"textfield",readOnly:true,anchor:"95%"},html:'<div class="tb-exceptiondialog-details"><p class="tb-exceptiondialog-msg">'+this.exception.message+'</p><p class="tb-exceptiondialog-trace">'+this.exception.traceHTML+"</p></div>"}]});return this.reportForm},onSendReport:function(){if(!this.nonInteractive){Ext.MessageBox.wait(_("Sending report..."),_("Please wait a moment"))}var f="http://www.tine20.org/bugreport.php";var h=this.generateHash();this.exception.msg=this.exception.message;this.exception.description=Ext.getCmp("tb-exceptiondialog-description").getValue();this.exception.clientVersion=Tine.clientVersion;this.exception.serverVersion=(Tine.Tinebase.registry.get("version"))?Tine.Tinebase.registry.get("version"):{};Ext.each(Tine.Tinebase.registry.get("userApplications"),function(k){if(k.name=="Tinebase"){this.exception.tinebaseVersion=k;return false}},this);if(!Ext.getCmp("tb-exceptiondialog-send-contact").collapsed){this.exception.contact=Ext.getCmp("tb-exceptiondialog-contact").getValue()}var j=this.strChunk(Ext.util.JSON.encode(this.exception),600);var a=[];for(var d=0;d<j.length;d++){var c=d+1+"/"+j.length;var g={data:this.base64encode("hash="+h+"&part="+c+"&data="+j[d])};var b=f+"?"+Ext.urlEncode(g);a.push(Ext.DomHelper.insertFirst(this.el,{tag:"img",src:b,hidden:true},true))}if(!this.nonInteractive){window.setTimeout(this.showTransmissionCompleted,4000)}this.close()},showTransmissionCompleted:function(){Ext.MessageBox.show({title:_("Transmission Completed"),msg:_("Your report has been sent. Thanks for your contribution")+"<br /><b>"+_("Please restart your browser now!")+"</b>",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})},strChunk:function(c,b){var f=[];var d=Math.ceil(c.length/b);for(var a=0;a<c.length;a+=b){f.push(c.substr(a,b))}return f},generateHash:function(){var b=String(new Date().getTime()).substr(4);var c="ABCDEFGHIJKLMNOPQRSTUVWXYZ";for(var a=0;a<4;a++){b+=c.charAt(Math.floor(Math.random()*26))}return b},base64encode:function(d){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var a="";var m,k,h,l,j,g,f;var c=0;while(c<d.length){m=d.charCodeAt(c++);k=d.charCodeAt(c++);h=d.charCodeAt(c++);l=m>>2;j=((m&3)<<4)|(k>>4);g=((k&15)<<2)|(h>>6);f=h&63;if(isNaN(k)){g=f=64}else{if(isNaN(h)){f=64}}a=a+b.charAt(l)+b.charAt(j)+b.charAt(g)+b.charAt(f)}return a}});Ext.ns("Tine.Tinebase.container");Tine.Tinebase.container={TYPE_PERSONAL:"personal",TYPE_SHARED:"shared",isLeafRegExp:/^\/personal\/[0-9a-z_\-]+\/|^\/shared\/[a-f0-9]+/i,isPersonalNodeRegExp:/^\/personal\/([0-9a-z_\-]+)$/i,getMyNodePath:function(){return"/personal/"+Tine.Tinebase.registry.get("currentAccount").accountId},getMyFileNodePath:function(){return"/personal/"+Tine.Tinebase.registry.get("currentAccount").accountLoginName},pathIsContainer:function(a){return !Ext.isString(a)||!!a.match(Tine.Tinebase.container.isLeafRegExp)},pathIsMyPersonalContainer:function(c){var a=new RegExp("^"+Tine.Tinebase.container.getMyNodePath()+"/([0-9a-z_-]+)$");var b=String(c).match(a);return !!b},pathIsPersonalNode:function(b){if(!Ext.isString(b)){return false}var a=b.match(Tine.Tinebase.container.isPersonalNodeRegExp);return a?a[1]:false},path2name:function(c,b,a){switch(c){case"/":return String.format(_("All {0}"),a);case"/shared":return String.format(_("Shared {0}"),a);case"/personal":return String.format(_("Other Users {0}"),a)}if(c===Tine.Tinebase.container.getMyNodePath()||c===Tine.Tinebase.container.getMyFileNodePath()){return String.format(_("My {0}"),a)}return c},path2type:function(b){var a=Ext.isArray(b)?b:String(b).split("/");return a[1]}};Ext.ns("Tine","Tine.Tinebase");Tine.Tinebase.common={openWindow:function(r,b,c,s){if(Ext.isIE){s=s+20}if(Ext.isChrome){s+=40}r=Ext.isString(r)?r.replace(/[^a-zA-Z0-9_]/g,""):r;var q,j,o,m,f,g,a;if(document.all){q=document.body.clientWidth;j=document.body.clientHeight;o=window.screenTop;m=window.screenLeft}else{if(window.innerWidth){q=window.innerWidth;j=window.innerHeight;o=window.screenX;m=window.screenY}}f=((q-c)/2)+m;g=((j-s)/2)+o;try{a=window.open(b,r,"width="+c+",height="+s+",top="+g+",left="+f+",directories=no,toolbar=no,location=no,menubar=no,scrollbars=no,status=no,resizable=yes,dependent=no");return a}catch(k){Tine.log.info("window.open Exception: ");Tine.log.info(k);a=false}if(!a){var l="window.open('http://127.0.0.1/tine20/tine20/"+b+"','"+r+"','width="+c+",height="+s+",top="+g+",left="+f+",directories=no,toolbar=no,location=no,menubar=no,scrollbars=no,status=no,resizable=yes,dependent=no')";var d={openCode:l,popup:null};Tine.log.debug("openCode: "+l);a=l}return a},showDebugConsole:function(){if(!Ext.debug){var a=document.getElementsByTagName("head")[0],c=document.createElement("script");c.setAttribute("src","library/ExtJS/src/debug.js");c.setAttribute("type","text/javascript");a.appendChild(c);var b=Ext.get(c);b.on("load",function(){Ext.log("debug console initialised")});b.on("fail",function(){Ext.msg.alert("could not activate debug console")})}else{Ext.log("debug console reactivated")}},dateTimeRenderer:function(a){var b=a instanceof Date?a:Date.parseDate(a,Date.patterns.ISO8601Long);return Ext.util.Format.date(b,Locale.getTranslationData("Date","medium")+" "+Locale.getTranslationData("Time","medium"))},dateRenderer:function(b){var a=b instanceof Date?b:Date.parseDate(b,Date.patterns.ISO8601Long);return Ext.util.Format.date(a,Locale.getTranslationData("Date","medium"))},timeRenderer:function(b){var a=b instanceof Date?b:Date.parseDate(b,Date.patterns.ISO8601Long);return Ext.util.Format.date(a,Locale.getTranslationData("Time","medium"))},byteRenderer:function(f,d,b,a,c){if(b&&b.get("type")=="folder"){return""}return Tine.Tinebase.common.byteFormatter(f,null,a,c)},byteFormatter:function(g,f,a,c){g=parseInt(g,10);a=Ext.isNumber(a)?a:2;var h=["Bytes","Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],k=c?1000:1024;if(f){var d=h.indexOf(f);d=(d==-1)?0:d}else{for(var d=0,b;d<h.length;d++){if(g<Math.pow(k,d)){break}}}return((d<=1)?g:Ext.util.Format.round(g/(Math.pow(k,Math.max(1,d-1))),a))+" "+h[d]},tagsRenderer:function(c){var a="";if(c){for(var d=0;d<c.length;d+=1){var b=Tine.Tinebase.common.doubleEncode(c[d].name);if(c[d].description){b+=" | "+Tine.Tinebase.common.doubleEncode(c[d].description)}if(c[d].occurrence){b+=" ("+_("Usage:&#160;")+c[d].occurrence+")"}a+='<div ext:qtip="'+b+'" class="tb-grid-tags" style="background-color:'+(c[d].color?c[d].color:"#fff")+';">&#160;</div>'}}return a},tagRenderer:function(b){if(!Tine.Tinebase.common.tagRenderer.tpl){Tine.Tinebase.common.tagRenderer.tpl=new Ext.XTemplate('<div class="tb-grid-tags" style="background-color:{values.color};">&#160;</div>','<div class="x-widget-tag-tagitem-text" ext:qtip="',"{[this.encode(values.name)]}","<tpl if=\"type == 'personal' \">&nbsp;<i>("+_("personal")+")</i></tpl>","</i>&nbsp;[{occurrence}]",'<tpl if="description != null && description.length &gt; 1"><hr>{[this.encode(values.description)]}</tpl>" >',"&nbsp;{[this.encode(values.name)]}","<tpl if=\"type == 'personal' \">&nbsp;<i>("+_("personal")+")</i></tpl>","</div>",{encode:function(c){if(c){return Tine.Tinebase.common.doubleEncode(c)}else{return""}}}).compile()}var a=_("No Information");if(b&&Ext.isFunction(b.beginEdit)){b=b.data}else{if(arguments[2]&&Ext.isFunction(arguments[2].beginEdit)){b=arguments[2].data}}if(Ext.isObject(b)){a=Tine.Tinebase.common.tagRenderer.tpl.apply(b)}return a},containerRenderer:function(c,b){if(!Tine.Tinebase.common.containerRenderer.tpl){Tine.Tinebase.common.containerRenderer.tpl=new Ext.XTemplate('<div class="x-tree-node-leaf x-unselectable file">','<img class="x-tree-node-icon" unselectable="on" src="',Ext.BLANK_IMAGE_URL,'">','<span style="color: {color};">&nbsp;&#9673;&nbsp</span>',"<span> ","{name}","</span>","</div>").compile()}var a=_("No Information");if(c&&Ext.isFunction(c.beginEdit)){c=c.data}if(Ext.isObject(c)){var f=Ext.isFunction(c.beginEdit)?c.get("name"):c.name,d=Ext.isFunction(c.beginEdit)?c.get("color"):c.color;if(f){a=Tine.Tinebase.common.containerRenderer.tpl.apply({name:Ext.util.Format.htmlEncode(f).replace(/ /g,"&nbsp;"),color:d?d:"#808080"})}else{if(Ext.isObject(b)){b.css="x-form-empty-field"}}}return a},minutesRenderer:function(d,h,a){var f,c=d%60,b=Math.floor(d/60),g;if(a&&(Ext.isString(a)||a===true)){if(a===true||(a.match(/i/)&&String(c).length===1)){c="0"+String(c)}if(a===true||(a.match(/H/)&&String(b).length===1)){b="0"+String(b)}}if(!h||!Ext.isString(h)){f=String.format(Tine.Tinebase.translation.ngettext("{0} minute","{0} minutes",c),c);g=String.format(Tine.Tinebase.translation.ngettext("{0} hour","{0} hours",b),b);if(c===0){f=g}else{f=b?g+", "+f:f}return f}return String.format(h,b,c)},secondsRenderer:function(f){var c=f%60,b=Math.floor(f/60),a="";var d=String.format(Tine.Tinebase.translation.ngettext("{0} second","{0} seconds",c),c);if(b){a=Tine.Tinebase.common.minutesRenderer(b)}if(c){if(a!==""){a+=", "}a+=d}return a},usernameRenderer:function(b){var a=(b)?b.accountDisplayName:"";return Ext.util.Format.htmlEncode(a)},accountRenderer:function(b,f,a,d,j,h){if(!b){return""}var c,k,g;if(b.accountDisplayName){c="user";g=b.accountDisplayName}else{if(b.name){c="group";g=b.name}else{if(a.data.name){c=a.data.type;g=a.data.name}else{if(a.data.account_name){c=a.data.account_type;g=a.data.account_name}}}}k=c==="user"?"renderer renderer_accountUserIcon":"renderer renderer_accountGroupIcon";return'<div class="'+k+'">&#160;</div>'+Ext.util.Format.htmlEncode(g)},accountTypeRenderer:function(b){var a=(b)==="user"?"renderer_accountUserIcon":"renderer_accountGroupIcon";return'<div style="background-position: 0px" class="'+a+'">&#160;</div>'},cellEditorHintRenderer:function(a){return'<div style="position:relative">'+a+'<div class="tine-grid-cell-hint">&#160;</div></div>'},booleanRenderer:function(a){var b=String.format("{0}",(a==1)?Locale.getTranslationData("Question","yes"):Locale.getTranslationData("Question","no"));return b.substr(0,b.indexOf(":"))},accountSortType:function(a){if(a&&a.accountDisplayName){return a.accountDisplayName}else{if(a&&a.n_fileas){return a.n_fileas}else{if(a&&a.name){return a.name}else{return a}}}},recordSortType:function(a){if(a&&Ext.isFunction(a.getTitle)){return a.getTitle()}else{if(a&&a.id){return a.id}else{return a}}},isTrue:function(a){return a===1||a==="1"||a===true||a==="true"},isEmptyObject:function(b){for(var a in b){if(b.hasOwnProperty(a)){return false}}return true},clone:function(d){if(!d||"object"!==typeof d){return d}if("function"===typeof d.clone){return d.clone()}var f="[object Array]"===Object.prototype.toString.call(d)?[]:{},b,a;for(b in d){if(d.hasOwnProperty(b)){a=d[b];if(a&&"object"===typeof a){f[b]=Tine.Tinebase.common.clone(a)}else{f[b]=a}}}return f},assertComparable:function(a){if(Ext.isObject(a)||Ext.isArray(a)){Tine.Tinebase.common.applyComparableToString(a)}return a},applyComparableToString:function(a){a.toString=function(){return Ext.encode(a)}},hasRight:function(d,b,f){var g=[];if(!(Tine&&Tine[b]&&Tine[b].registry&&Tine[b].registry.get("rights"))){if(!Tine.Tinebase.appMgr){console.error("Tine.Tinebase.appMgr not yet available")}else{if(Tine.Tinebase.appMgr.get(b)){console.error("Tine."+b+".rights is not available, initialisation Error!")}}return false}g=Tine[b].registry.get("rights");var a=false;for(var c=0;c<g.length;c+=1){if(g[c]==="admin"){a=true;break}if(d==="view"&&(g[c]==="view_"+f||g[c]==="manage_"+f)){a=true;break}if(d==="manage"&&g[c]==="manage_"+f){a=true;break}if(d===g[c]){a=true;break}}return a},getRandomNumber:function(b,a){if(b>a){return -1}if(b===a){return b}return b+parseInt(Math.random()*(a-b+1),10)},doubleEncode:function(a){return Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(a))},resolveApp:function(b,a){if(a){return Ext.isObject(b)?b:Tinebase.appMgr.get(b)}return Ext.isObject(b)?b.name:b},resolveModel:function(c,d){var b=Ext.isObject(c)?c.getMeta("modelName"):c;if(d){var a=this.resolveApp(d);return Tine[a].Model[b]}return b}};Ext.ns("Tine.Tinebase.Model");Tine.Tinebase.Model.modlogFields=[{name:"creation_time",type:"date",dateFormat:Date.patterns.ISO8601Long,isMetaField:true},{name:"created_by",isMetaField:true},{name:"last_modified_time",type:"date",dateFormat:Date.patterns.ISO8601Long,isMetaField:true},{name:"last_modified_by",isMetaField:true},{name:"is_deleted",type:"boolean",isMetaField:true},{name:"deleted_time",type:"date",dateFormat:Date.patterns.ISO8601Long,isMetaField:true},{name:"deleted_by",isMetaField:true}];Tine.Tinebase.Model.genericFields=Tine.Tinebase.Model.modlogFields.concat([{name:"container_id",header:"Container",isMetaField:false}]);Tine.Tinebase.Model.Language=Ext.data.Record.create([{name:"locale"},{name:"language"},{name:"region"}]);Tine.Tinebase.Model.Timezone=Ext.data.Record.create([{name:"timezone"},{name:"timezoneTranslation"}]);Tine.Tinebase.Model.Role=Tine.Tinebase.data.Record.create([{name:"id"},{name:"name"},{name:"description"}],{appName:"Tinebase",modelName:"Role",idProperty:"id",titleProperty:"name",recordName:"Role",recordsName:"Roles",containerProperty:null});Tine.Tinebase.Model.Account=Ext.data.Record.create([{name:"id"},{name:"type"},{name:"name"},{name:"data"}]);Tine.Tinebase.Model.Container=Tine.Tinebase.data.Record.create(Tine.Tinebase.Model.genericFields.concat([{name:"id"},{name:"name"},{name:"type"},{name:"color"},{name:"path"},{name:"is_container_node",type:"boolean"},{name:"dtselect",type:"number"},{name:"backend"},{name:"application_id"},{name:"account_grants"},{name:"model"}]),{appName:"Tinebase",modelName:"Container",idProperty:"id",titleProperty:"name"});Tine.Tinebase.Model.Grant=Ext.data.Record.create([{name:"id"},{name:"account_id"},{name:"account_type"},{name:"account_name",sortType:Tine.Tinebase.common.accountSortType},{name:"freebusyGrant",type:"boolean"},{name:"readGrant",type:"boolean"},{name:"addGrant",type:"boolean"},{name:"editGrant",type:"boolean"},{name:"deleteGrant",type:"boolean"},{name:"privateGrant",type:"boolean"},{name:"exportGrant",type:"boolean"},{name:"syncGrant",type:"boolean"},{name:"adminGrant",type:"boolean"}]);Tine.Tinebase.Model.Tag=Tine.Tinebase.data.Record.create(Tine.Tinebase.Model.genericFields.concat([{name:"id"},{name:"app"},{name:"owner"},{name:"name"},{name:"type"},{name:"description"},{name:"color"},{name:"occurrence"},{name:"rights"},{name:"contexts"},{name:"selection_occurrence",type:"number"}]),{appName:"Tinebase",modelName:"Tag",idProperty:"id",titleProperty:"name",recordName:"Tag",recordsName:"Tags"});Tine.Tinebase.Model.Tag.replaceTemplateField=function(b){if(Ext.isArray(b)){return Ext.each(b,Tine.Tinebase.Model.Tag.replaceTemplateField)}if(Ext.isFunction(b.beginEdit)){b=b.data}var a={CURRENTDATE:Tine.Tinebase.common.dateRenderer(new Date()),CURRENTTIME:Tine.Tinebase.common.timeRenderer(new Date()),USERFULLNAME:Tine.Tinebase.registry.get("currentAccount").accountDisplayName};Ext.each(["name","description"],function(d){for(var c in a){if(a.hasOwnProperty(c)&&Ext.isString(b[d])){b[d]=b[d].replace(new RegExp("###"+c+"###","g"),a[c])}}},this)};Tine.Tinebase.PickerRecord=Ext.data.Record.create([{name:"id"},{name:"name"},{name:"data"}]);Tine.Tinebase.Model.Note=Ext.data.Record.create([{name:"id"},{name:"note_type_id"},{name:"note"},{name:"creation_time",type:"date",dateFormat:Date.patterns.ISO8601Long},{name:"created_by"}]);Tine.Tinebase.Model.NoteType=Ext.data.Record.create([{name:"id"},{name:"name"},{name:"icon"},{name:"icon_class"},{name:"description"},{name:"is_user_type"}]);Tine.Tinebase.Model.Customfield=Ext.data.Record.create([{name:"id"},{name:"application_id"},{name:"model"},{name:"name"},{name:"definition"},{name:"account_grants"}]);Tine.Tinebase.Model.CustomfieldValue=Ext.data.Record.create([{name:"record_id"},{name:"customfield_id"},{name:"value"}]);Tine.Tinebase.Model.Preference=Ext.data.Record.create([{name:"id"},{name:"name"},{name:"value"},{name:"type"},{name:"label"},{name:"description"},{name:"personal_only",type:"boolean"},{name:"options"}]);Tine.Tinebase.Model.Alarm=Tine.Tinebase.data.Record.create([{name:"id"},{name:"record_id"},{name:"model"},{name:"alarm_time",type:"date",dateFormat:Date.patterns.ISO8601Long},{name:"minutes_before",sortType:Ext.data.SortTypes.asInt},{name:"sent_time",type:"date",dateFormat:Date.patterns.ISO8601Long},{name:"sent_status"},{name:"sent_message"},{name:"options"}],{appName:"Tinebase",modelName:"Alarm",idProperty:"id",titleProperty:"minutes_before",recordName:"Alarm",recordsName:"Alarms",containerProperty:null,getOption:function(b){var c=this.get("options"),a=c?Ext.decode(c):{};return a[b]},setOption:function(b,d){var c=this.get("options"),a=c?Ext.decode(c):{};a[b]=d;this.set("options",Ext.encode(a))}});Tine.Tinebase.Model.ImportJob=Tine.Tinebase.data.Record.create([{name:"files"},{name:"import_definition_id"},{name:"model"},{name:"import_function"},{name:"container_id"},{name:"dry_run"},{name:"options"}],{appName:"Tinebase",modelName:"Import",idProperty:"id",titleProperty:"model",recordName:"Import",recordsName:"Imports",containerProperty:null});Tine.Tinebase.Model.ExportJob=Tine.Tinebase.data.Record.create([{name:"filter"},{name:"export_definition_id"},{name:"format"},{name:"exportFunction"},{name:"recordsName"},{name:"model"},{name:"count",type:"int"},{name:"options"}],{appName:"Tinebase",modelName:"Export",idProperty:"id",titleProperty:"model",recordName:"Export",recordsName:"Exports",containerProperty:null});Tine.Tinebase.Model.ImportExportDefinition=Ext.data.Record.create(Tine.Tinebase.Model.genericFields.concat([{name:"id"},{name:"name"},{name:"label",sortType:Ext.data.SortTypes.asUCText},{name:"filename"},{name:"plugin"},{name:"description"},{name:"model"},{name:"plugin_options"}]));Tine.Tinebase.Model.Credentials=Tine.Tinebase.data.Record.create([{name:"id"},{name:"username"},{name:"password"}],{appName:"Tinebase",modelName:"Credentials",idProperty:"id",titleProperty:"username",recordName:"Credentials",recordsName:"Credentials",containerProperty:null});Tine.Tinebase.Model.Relation=Tine.Tinebase.data.Record.create([{name:"id"},{name:"own_model"},{name:"own_id"},{name:"related_model"},{name:"related_id"},{name:"type"},{name:"remark"},{name:"related_record",sortType:Tine.Tinebase.common.recordSortType},{name:"creation_time"}],{appName:"Tinebase",modelName:"Relation",idProperty:"id",titleProperty:"related_model",recordName:"Relation",recordsName:"Relations",containerProperty:null});Tine.Tinebase.Model.Department=Tine.Tinebase.data.Record.create([{name:"id"},{name:"name"},{name:"description"}],{appName:"Tinebase",modelName:"Department",idProperty:"id",titleProperty:"name",recordName:"Department",recordsName:"Departments",containerProperty:null});Tine.Tinebase.Model.Department.getFilterModel=function(){return[{label:_("Name"),field:"name",operators:["contains"]}]};Tine.Tinebase.Model.Config=Tine.Tinebase.data.Record.create([{name:"id"},{name:"settings"}],{appName:"Tinebase",modelName:"Config",idProperty:"id",titleProperty:"id",recordName:"Config",recordsName:"Configs",containerProperty:null});Ext.ns("Tine.Tinebase");Tine.Tinebase.Application=function(a){a=a||{};Ext.apply(this,a);Tine.Tinebase.Application.superclass.constructor.call(this);this.i18n=new Locale.Gettext();this.i18n.textdomain(this.appName);this.init();this.initAutoHooks()};Ext.extend(Tine.Tinebase.Application,Ext.util.Observable,{appName:null,hasMainScreen:true,i18n:null,getTitle:function(){return this.i18n._(this.appName)},getIconCls:function(a){return this.appName+"IconCls"},getMainScreen:function(){if(!this.mainScreen&&typeof Tine[this.appName].MainScreen==="function"){this.mainScreen=new Tine[this.appName].MainScreen({app:this})}return this.mainScreen},getRegistry:function(){return Tine[this.appName].registry},init:Ext.emptyFn,initAutoHooks:function(){if(this.addButtonText){Ext.ux.ItemRegistry.registerItem("Tine.widgets.grid.GridPanel.addButton",{text:this.i18n._hidden(this.addButtonText),iconCls:this.getIconCls(),scope:this,handler:function(){var a=this.getMainScreen(),b=a.getCenterPanel();b.onEditInNewWindow.call(b,{})}})}},onBeforeActivate:Ext.emptyFn,onActivate:Ext.emptyFn,onBeforeDeActivate:Ext.emptyFn,onDeActivate:Ext.emptyFn});Ext.ns("Tine.Tinebase.widgets.keyfield");Tine.Tinebase.widgets.keyfield.Store=function(c){c.app=Ext.isString(c.app)?Tine.Tinebase.appMgr.get(c.app):c.app;c.keyFieldConfig=c.app.getRegistry().get("config")[c.keyFieldName];var f=c.keyFieldConfig&&c.keyFieldConfig.value&&c.keyFieldConfig.value.records.length?c.keyFieldConfig.value.records:[];Ext.each(f,function(g){g.i18nValue=g.value?c.app.i18n._hidden(g.value):""});c.data=f;if(!c.keyFieldConfig){throw ("No keyfield config found for "+c.keyFieldName+" in "+c.app.appName+" registry.")}var a=c.keyFieldConfig.definition&&c.keyFieldConfig.definition.options?c.keyFieldConfig.definition.options.recordModel:"Tinebase_Config_KeyFieldRecord",b=a.split("_"),d=Tine[b[0]]&&Tine[b[0]]["Model"]&&Tine[b[0]]["Model"][b[2]]?Tine[b[0]]["Model"][b[2]]:null;c.fields=d?d:["id","value","icon","system","i18nValue"];Tine.Tinebase.widgets.keyfield.Store.superclass.constructor.call(this,c)};Ext.extend(Tine.Tinebase.widgets.keyfield.Store,Ext.data.JsonStore,{app:null,keyFieldName:null,keyFieldConfig:null});Tine.Tinebase.widgets.keyfield.StoreMgr=function(){var a={};return{get:function(f,d){var b=Ext.isString(f)?f:f.appName,c=b+"_"+d;if(!a[c]){a[c]=new Tine.Tinebase.widgets.keyfield.Store({app:f,keyFieldName:d})}return a[c]}}}();Ext.ns("Tine.Tinebase.widgets.keyfield");Tine.Tinebase.widgets.keyfield.ComboBox=Ext.extend(Ext.form.ComboBox,{app:null,keyFieldName:null,showIcon:true,sortBy:null,blurOnSelect:true,expandOnFocus:true,mode:"local",displayField:"i18nValue",valueField:"id",initComponent:function(){this.app=Ext.isString(this.app)?Tine.Tinebase.appMgr.get(this.app):this.app;this.keyFieldConfig=this.app.getRegistry().get("config")[this.keyFieldName];if(!this.value&&(this.keyFieldConfig&&Ext.isObject(this.keyFieldConfig.value)&&this.keyFieldConfig.value.hasOwnProperty("default"))){this.value=this.keyFieldConfig.value["default"]}this.store=Tine.Tinebase.widgets.keyfield.StoreMgr.get(this.app,this.keyFieldName);if(this.sortBy){this.store.sort(this.sortBy)}this.showIcon=this.showIcon&&this.store.find("icon",/^.+$/)>-1;this.initTpl();Tine.Tinebase.widgets.keyfield.ComboBox.superclass.initComponent.call(this)},initTpl:function(){if(this.showIcon){this.tpl='<tpl for="."><div class="x-combo-list-item"><img src="{icon}" class="tine-keyfield-icon"/>{'+this.displayField+"}</div></tpl>"}}});Ext.reg("widget-keyfieldcombo",Tine.Tinebase.widgets.keyfield.ComboBox);Ext.ns("Tine.Tinebase.widgets.keyfield");Tine.Tinebase.widgets.keyfield.Renderer=function(){var a={};return{get:function(j,f,g){var b=Ext.isString(j)?j:j.appName,j=Tine.Tinebase.appMgr.get(b),c=Tine.Tinebase.widgets.keyfield.StoreMgr.get(j,f),g=g?g:"text|icon",h=g.split("|"),d=b+f+g;if(!a[d]){a[d]=function(q){if(!q){return""}var k=c.getById(q),o=k?k.get("i18nValue"):j.i18n._hidden(q),m=k?k.get("icon"):null,l="";if(h.indexOf("icon")>-1&&m){l=l+'<img src="'+m+'" class="tine-keyfield-icon" ext:qtip="'+Ext.util.Format.htmlEncode(o)+'" />'}if(h.indexOf("text")>-1&&o){l=l+Ext.util.Format.htmlEncode(o)}return l}}return a[d]},render:function(d,b,f){var c=this.get(d,b);return c(f)},register:function(g,d,f){var b=Ext.isString(g)?g:g.appName,c=b+"_"+d;a[c]=f}}}();Ext.ns("Tine.widgets");Tine.widgets.LangChooser=Ext.extend(Ext.form.ComboBox,{fieldLabel:null,displayField:"language",valueField:"locale",triggerAction:"all",editable:false,width:100,listWidth:200,initComponent:function(){this.value=Tine.Tinebase.registry.get("locale").language;this.fieldLabel=this.fieldLabel?this.fieldLabel:_("Language");this.tpl=new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{language} <tpl if="region.length &gt; 1">{region}</tpl> [{locale}]</div></tpl>',{encode:function(a){return Ext.util.Format.htmlEncode(a)}});this.store=new Ext.data.JsonStore({id:"locale",root:"results",totalProperty:"totalcount",fields:Tine.Tinebase.Model.Language,baseParams:{method:"Tinebase.getAvailableTranslations"}});Tine.widgets.LangChooser.superclass.initComponent.call(this);this.on("select",this.onLangSelect,this)},onLangSelect:function(d,c,a){var f=Tine.Tinebase.registry.get("locale").locale;var b=c.get("locale");if(b!==f){Ext.MessageBox.wait(_("setting new language..."),_("Please Wait"));Ext.Ajax.request({scope:this,params:{method:"Tinebase.setLocale",localeString:b,saveaspreference:true,setcookie:true},success:function(g,j){if(window.google&&google.gears&&google.gears.localServer){var h=google.gears.localServer.openStore("tine20-package-store");if(h){google.gears.localServer.removeStore("tine20-package-store")}}window.location.reload(true)}})}}});Ext.reg("tinelangchooser",Tine.widgets.LangChooser);Ext.ns("Tine","Tine.widgets");Tine.widgets.ActionUpdater=function(a){a=a||{};var b=a.actions||[];a.actions=[];Ext.apply(this,a);this.addActions(b)};Tine.widgets.ActionUpdater.prototype={actions:null,evalGrants:true,grantsProperty:"account_grants",containerProperty:"container_id",addActions:function(c){switch(typeof(c)){case"object":if(typeof(c.each)=="function"){c.each(this.addAction,this)}else{for(var b in c){this.addAction(c[b])}}break;case"array":for(var a=0;a<c.length;a++){this.addAction(c[a])}break}},addAction:function(a){if(a&&a.initialConfig){if(a.requiredGrant){Ext.applyIf(a.initialConfig,{requiredGrant:a.requiredGrant,actionUpdater:a.actionUpdater,allowMultiple:a.allowMultiple,singularText:a.singularText,pluralText:a.pluralText,translationObject:a.translationObject})}this.actions.push(a)}},updateActions:function(b){var c=false;if(typeof(b.getSelections)=="function"){c=b.isFilterSelect;b=b.getSelections()}else{if(typeof(b.beginEdit)=="function"){b=[b]}}var a=this.getGrantsSum(b);this.each(function(g){var d=g.actionUpdater||g.initialConfig.actionUpdater;if(typeof(d)=="function"){var f=g.scope||g.initialConfig.scope||window;d.call(f,g,a,b)}else{this.defaultUpdater(g,a,b,c)}},this)},defaultUpdater:function(d,k,b,c){var f=b.length!=0&&(b.length>1?d.initialConfig.allowMultiple:true),a=b&&b.length>1,g=(!this.evalGrants)||k[d.initialConfig.requiredGrant];if(d.initialConfig.requiredGrant&&d.initialConfig.requiredGrant!="addGrant"){d.setDisabled(!(g&&f))}if(d.disableOnFilterSelection&&c){d.setDisabled(true);return}if(f){if(a){if(d.initialConfig.requiredMultipleRight){var h=d.initialConfig.requiredMultipleRight.split("_");if(h.length==2){d.setDisabled(!Tine.Tinebase.common.hasRight(h[0],d.initialConfig.scope.app.name,h[1]))}else{Tine.log.debug("multiple edit right was not properly applied")}}if(d.initialConfig.requiredMultipleGrant){var l=true;if(Ext.isArray(b)){Ext.each(b,function(m){if(m.get("container_id")&&m.get("container_id").account_grants){l=(l&&(m.get("container_id").account_grants[d.initialConfig.requiredMultipleGrant]))}else{return false}},this);d.setDisabled(!l)}}}if(d.initialConfig.singularText&&d.initialConfig.pluralText&&d.initialConfig.translationObject){var j=d.initialConfig.translationObject.n_(d.initialConfig.singularText,d.initialConfig.pluralText,b.length);d.setText(j)}}},each:function(c,b){for(var a=0;a<this.actions.length;a++){if(c.call(b||this.actions[a],this.actions[a])===false){break}}},getGrantsSum:function(c){var g=c.length==0?false:true;var a={addGrant:g,adminGrant:g,deleteGrant:g,editGrant:g,readGrant:g,exportGrant:g,syncGrant:g};if(!this.evalGrants){return a}var f;for(var d=0;d<c.length;d++){f=this.containerProperty?c[d].get(this.containerProperty)[this.grantsProperty]:this.grantsProperty?c[d].get(this.grantsProperty):c[d].data;for(var b in a){if(a.hasOwnProperty(b)&&f&&f.hasOwnProperty(b)){a[b]=a[b]&f[b]}}}if(a.adminGrant){for(var b in a){a[b]=true}}return a}};Tine.widgets.actionUpdater=function(b,f,g,h){if(!g){g="container_id"}if(typeof(b.getSelections)=="function"){b=b.getSelections()}else{if(typeof(b.beginEdit)=="function"){b=[b]}}var k=b.length==0?false:true;var l={addGrant:k,adminGrant:k,deleteGrant:k,editGrant:k,exportGrant:k,readGrant:k,syncGrant:k};for(var j=0;j<b.length;j++){var m=b[j].get(g)?b[j].get(g).account_grants:{};for(var a in l){l[a]=l[a]&m[a]}}var d=function(q){var s=q.initialConfig;if(s){if(q.requiredGrant){s={requiredGrant:q.requiredGrant,allowMultiple:q.allowMultiple,singularText:q.singularText,pluralText:q.pluralText,translationObject:q.translationObject}}var r=s.requiredGrant;if(r&&r!="addGrant"){var o=h||l[r];if(b.length>1&&!s.allowMultiple){o=false}if(b.length==0){o=false}q.setDisabled(!o);if(s.singularText&&s.pluralText&&s.translationObject){var t=s.translationObject.n_(s.singularText,s.pluralText,b.length);q.setText(t)}}}};switch(typeof(f)){case"object":if(typeof(f.each)=="function"){f.each(d,this)}else{for(var c in f){d(f[c])}}break;case"array":for(var j=0;j<f.length;j++){d(f[j])}break}};Ext.ns("Tine.widgets","Tine.widgets.dialog");Tine.widgets.dialog.EditRecord=Ext.extend(Ext.FormPanel,{tbarItems:false,appName:null,containerName:"container",containersName:"containers",containerProperty:"container_id",showContainerSelector:false,handlerScope:null,handlerSaveAndClose:null,handlerApplyChanges:null,handlerCancel:null,windowLayout:"border",window:null,bodyStyle:"padding:5px",anchor:"100% 100%",region:"center",deferredRender:false,buttonAlign:"right",cls:"tw-editdialog",initComponent:function(){this.addEvents("cancel","saveAndClose","update","apply");this.initHandlers();this.initActions();this.initButtons();Tine.widgets.dialog.EditRecord.superclass.initComponent.call(this)},onRender:function(b,a){Tine.widgets.dialog.EditRecord.superclass.onRender.call(this,b,a);if(this.showContainerSelector){this.recordContainerEl=this.footer.first().insertFirst({tag:"div",style:{position:"relative",top:"4px","float":"left"}});var c=new Tine.widgets.container.selectionComboBox({id:this.appName+"EditRecordContainerSelector",fieldLabel:_("Saved in"),width:300,name:this.containerProperty,containerName:this.containerName,containersName:this.containersName,appName:this.appName});this.getForm().add(c);var d=new Ext.Panel({layout:"form",border:false,renderTo:this.recordContainerEl,bodyStyle:{"background-color":"#F0F0F0"},items:c})}},initActions:function(){this.action_saveAndClose=new Ext.Action({requiredGrant:"editGrant",text:_("Ok"),minWidth:70,handler:this.handlerSaveAndClose,iconCls:"action_saveAndClose",scope:this.handlerScope});this.action_applyChanges=new Ext.Action({requiredGrant:"editGrant",text:_("Apply"),minWidth:70,handler:this.handlerApplyChanges,iconCls:"action_applyChanges",scope:this.handlerScope});this.action_cancel=new Ext.Action({text:_("Cancel"),minWidth:70,handler:this.handlerCancel,iconCls:"action_cancel",scope:this.handlerScope});this.action_delete=new Ext.Action({requiredGrant:"deleteGrant",text:_("delete"),minWidth:70,handler:this.handlerDelete,iconCls:"action_delete",scope:this.handlerScope,disabled:true})},initButtons:function(){var a=[this.action_delete];this.buttons=[this.action_cancel,this.action_saveAndClose];if(this.tbarItems){this.tbar=new Ext.Toolbar({items:this.tbarItems})}},initHandlers:function(){this.handlerScope=this.handlerScope?this.handlerScope:this;this.handlerSaveAndClose=this.handlerSaveAndClose?this.handlerSaveAndClose:function(b,a){this.handlerApplyChanges(b,a,true)};this.handlerCancel=this.handlerCancel?this.handlerCancel:this.closeWindow},updateToolbars:function(a,c){var b=[this.action_saveAndClose,this.action_applyChanges,this.action_delete,this.action_cancel];Tine.widgets.actionUpdater(a,b,c);Tine.widgets.actionUpdater(a,this.tbarItems,c)},getToolbar:function(){return this.getTopToolbar()},onCancel:function(){this.fireEvent("cancel");this.purgeListeners()},onSaveAndClose:function(){this.fireEvent("saveAndClose")},onApply:function(){this.fireEvent("apply")},closeWindow:function(){this.window.close()}});Ext.reg("tineeditrecord",Tine.widgets.dialog.EditRecord);Ext.ns("Tine.widgets");Tine.widgets.VersionCheck=function(){var a=new Ext.data.Store({proxy:new Ext.data.ScriptTagProxy({url:"https://versioncheck.officespot20.com/versionCheck/versionCheck.php"}),reader:new Ext.data.JsonReader({root:"version"},["codeName","packageString","releaseTime","critical","build"])});a.on("load",function(f,d){if(!Tine.Tinebase.registry.get("version")){return false}var b=d[0];var g=Date.parseDate(Tine.Tinebase.registry.get("version").releasetime,Date.patterns.ISO8601Long);var c=Date.parseDate(b.get("releasetime"),Date.patterns.ISO8601Long);if(c>g&&Tine.Tinebase.common.hasRight("run","Tinebase")){if(b.get("critical")==true){Ext.MessageBox.show({title:_("New version of Tine 2.0 available"),msg:String.format(_('Version "{0}" of Tine 2.0 is available.'),b.get("codeName"))+"\n"+_("It's a critical update and must be installed as soon as possible!"),width:500,buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR})}else{Ext.MessageBox.show({title:_("New version of Tine 2.0 available"),msg:String.format(_('Version "{0}" of Tine 2.0 is available.'),b.get("codeName"))+"\n"+_("Please consider updating!"),width:400,buttons:Ext.Msg.OK,icon:Ext.MessageBox.INFO})}}},this);a.load({params:{version:Ext.util.JSON.encode(Tine.Tinebase.registry.get("version"))}})};Ext.ns("Tine.widgets","Tine.widgets.dialog");Tine.widgets.dialog.AlarmPanel=Ext.extend(Ext.Panel,{recordAlarmField:"dtstart",layout:"fit",border:true,frame:true,initComponent:function(){this.title=_("Alarms");this.alarmOptions=[["0",_("0 minutes before")],["5",_("5 minutes before")],["15",_("15 minutes before")],["30",_("30 minutes before")],["60",_("1 hour before")],["120",_("2 hours before")],["720",_("12 hours before")],["1440",_("1 day before")],["2880",_("2 days before")],["custom",_("Custom Datetime")]];this.items=this.alarmGrid=new Tine.widgets.grid.QuickaddGridPanel({layout:"fit",autoExpandColumn:"alarm_time",quickaddMandatory:"minutes_before",frame:false,recordClass:Tine.Tinebase.Model.Alarm,onNewentry:this.onNewentry.createDelegate(this),cm:new Ext.grid.ColumnModel([{id:"minutes_before",header:_("Alarm Time"),dataIndex:"minutes_before",width:200,hideable:false,sortable:true,quickaddField:new Ext.form.ComboBox({triggerAction:"all",lazyRender:false,editable:false,mode:"local",forceSelection:true,store:this.alarmOptions,listeners:{scope:this,beforeselect:function(d,a,b){var c=this.record?this.record.get(this.recordAlarmField):null;this.alarmTimeQuickAdd.setDisabled(a.data.field1!="custom");if(Ext.isDate(c)&&a.data.field1=="custom"){this.alarmTimeQuickAdd.setValue(c.add(Date.MINUTE,-1*Ext.isNumber(d.getValue())?d.getValue():0))}if(a.data.field1!="custom"){this.alarmTimeQuickAdd.setValue()}}}}),editor:new Ext.form.ComboBox({triggerAction:"all",lazyRender:false,editable:false,mode:"local",forceSelection:true,allowBlank:false,expandOnFocus:true,blurOnSelect:true,store:this.alarmOptions}),renderer:this.minutesBeforeRenderer.createDelegate(this)},{id:"alarm_time",dataIndex:"alarm_time",hideable:false,sortable:false,renderer:this.alarmTimeRenderer.createDelegate(this),quickaddField:this.alarmTimeQuickAdd=new Ext.ux.form.DateTimeField({allowBlank:true}),editor:new Ext.ux.form.DateTimeField({allowBlank:false})}])});this.alarmGrid.on("beforeedit",this.onBeforeEdit,this);this.alarmGrid.on("afteredit",this.onAfterEdit,this);Tine.widgets.dialog.AlarmPanel.superclass.initComponent.call(this)},onNewentry:function(a){if(a.minutes_before=="custom"&&!Ext.isDate(a.alarm_time)){return false}Tine.widgets.grid.QuickaddGridPanel.prototype.onNewentry.apply(this.alarmGrid,arguments);this.alarmGrid.store.sort("minutes_before","ASC")},onBeforeEdit:function(c){if(c.field=="alarm_time"){var a=c.record.get("minutes_before"),d=c.record.get("alarm_time");if(a!="custom"){c.cancel=true}else{if(d&&!Ext.isDate(d)){var b=Date.parseDate(d,Date.patterns.ISO8601Long);c.record.set("alarm_time","");c.record.set("alarm_time",b)}}}},onAfterEdit:function(b){if(b.record.get("minutes_before")=="custom"&&!Ext.isDate(b.record.get("alarm_time"))){var a=this.record?this.record.get(this.recordAlarmField):null;b.record.set("alarm_time",Ext.isDate(a)?a.clone():new Date())}if(b.record.get("minutes_before")!="custom"){b.record.set("alarm_time","")}this.alarmGrid.store.sort("minutes_before","ASC")},minutesBeforeRenderer:function(b){var a=null;Ext.each(this.alarmOptions,function(c){if(c[0]==b){a=c[1];return false}});if(!a){a=String.format(_("{0} minutes before"),b)}return a},alarmTimeRenderer:function(c,b,a){return a.get("minutes_before")=="custom"?Tine.Tinebase.common.dateTimeRenderer.apply(this,arguments):""},onRecordLoad:function(a){this.record=a;this.alarmGrid.store.removeAll();this.alarmGrid.setStoreFromArray(a.get("alarms")||[]);this.alarmGrid.store.sort("minutes_before","ASC")},onRecordUpdate:function(a){a.set("alarms","");a.set("alarms",this.alarmGrid.getFromStoreAsArray())},setDisabled:function(a){this.el[a?"mask":"unmask"]()}});Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.EditDialog=Ext.extend(Ext.FormPanel,{app:null,mode:"remote",tbarItems:false,appName:null,modelName:null,recordClass:null,recordProxy:null,showContainerSelector:null,evalGrants:true,record:null,saveAndCloseButtonText:"",cancelButtonText:"",copyRecord:false,doDuplicateCheck:true,editGrant:"editGrant",hideRelationsPanel:false,ignoreRelatedModels:null,saving:false,containerSelectCombo:null,fixedFields:null,bodyStyle:"padding:5px",layout:"fit",border:false,cls:"tw-editdialog",anchor:"100% 100%",deferredRender:false,buttonAlign:null,bufferResize:500,relationsPanel:null,relationPickers:null,initComponent:function(){this.addEvents("cancel","saveAndClose","update","apply","load","save");if(!this.recordClass&&this.modelName){this.recordClass=Tine[this.appName].Model[this.modelName]}if(this.recordClass){this.appName=this.appName?this.appName:this.recordClass.getMeta("appName");this.modelName=this.modelName?this.modelName:this.recordClass.getMeta("modelName")}if(!this.app){this.app=Tine.Tinebase.appMgr.get(this.appName)}if(!this.windowNamePrefix){this.windowNamePrefix=this.modelName+"EditWindow_"}Tine.log.debug("initComponent: appName: ",this.appName);Tine.log.debug("initComponent: modelName: ",this.modelName);Tine.log.debug("initComponent: app: ",this.app);if(this.app.i18n&&this.recordClass!==null){this.i18nRecordName=this.app.i18n.n_hidden(this.recordClass.getMeta("recordName"),this.recordClass.getMeta("recordsName"),1);this.i18nRecordsName=this.app.i18n._hidden(this.recordClass.getMeta("recordsName"))}if(!this.recordProxy&&this.recordClass){Tine.log.debug("no record proxy given, creating a new one...");this.recordProxy=new Tine.Tinebase.data.RecordProxy({recordClass:this.recordClass})}this.plugins=Ext.isString(this.plugins)?Ext.decode(this.plugins):Ext.isArray(this.plugins)?this.plugins.concat(Ext.decode(this.initialConfig.plugins)):[];this.plugins.push(new Tine.widgets.customfields.EditDialogPlugin({}));this.plugins.push(this.tokenModePlugin=new Tine.widgets.dialog.TokenModeEditDialogPlugin({}));this.initActions();this.initButtons();this.initContainerSelector();this.initRecord();this.items=this.getFormItems();this.initRelationsPanel();Tine.widgets.dialog.EditDialog.superclass.initComponent.call(this);this.fixFields()},fixFields:function(){if(this.fixedFields){if(!this.rendered){this.fixFields.defer(100,this);return false}Ext.each(Ext.decode(this.fixedFields),function(b){var d=this.getForm().findField(b.key);if(Ext.isFunction(this.recordClass.getField(b.key).type)){var c=this.recordClass.getField(b.key).type;var a=new c(b.value);d.selectedRecord=a;d.setValue(b.value);d.fireEvent("select")}else{d.setValue(b.value)}d.disable()},this)}},initActions:function(){this.action_saveAndClose=new Ext.Action({requiredGrant:this.editGrant,text:(this.saveAndCloseButtonText!="")?this.app.i18n._(this.saveAndCloseButtonText):_("Ok"),minWidth:70,ref:"../btnSaveAndClose",scope:this,handler:function(){this.onSaveAndClose.defer(500,this)},iconCls:"action_saveAndClose"});this.action_applyChanges=new Ext.Action({requiredGrant:this.editGrant,text:_("Apply"),minWidth:70,ref:"../btnApplyChanges",scope:this,handler:this.onApplyChanges,iconCls:"action_applyChanges"});this.action_cancel=new Ext.Action({text:(this.cancelButtonText!="")?this.app.i18n._(this.cancelButtonText):_("Cancel"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_cancel"});this.action_delete=new Ext.Action({requiredGrant:"deleteGrant",text:_("delete"),minWidth:70,scope:this,handler:this.onDelete,iconCls:"action_delete",disabled:true})},initButtons:function(){this.fbar=["->",this.action_cancel,this.action_saveAndClose];if(this.tbarItems){this.tbar=new Ext.Toolbar({items:this.tbarItems})}},initContainerSelector:function(){if(this.showContainerSelector){this.containerSelectCombo=new Tine.widgets.container.selectionComboBox({id:this.app.appName+"EditDialogContainerSelector-"+Ext.id(),fieldLabel:_("Saved in"),width:300,listWidth:300,name:this.recordClass.getMeta("containerProperty"),recordClass:this.recordClass,containerName:this.app.i18n.n_hidden(this.recordClass.getMeta("containerName"),this.recordClass.getMeta("containersName"),1),containersName:this.app.i18n._hidden(this.recordClass.getMeta("containersName")),appName:this.app.appName,requiredGrant:this.evalGrants?"addGrant":false,disabled:this.isContainerSelectorDisabled(),listeners:{scope:this,select:function(){var a=this.containerSelectCombo.selectedContainer?this.containerSelectCombo.selectedContainer.account_grants:{};if(this.record.data.id){var b=a.hasOwnProperty("editGrant")?!a.editGrant:false}else{var b=a.hasOwnProperty("addGrant")?!a.addGrant:false}this.action_saveAndClose.setDisabled(b)}}});this.on("render",function(){this.getForm().add(this.containerSelectCombo)},this);this.fbar=[_("Saved in"),this.containerSelectCombo].concat(this.fbar)}},isContainerSelectorDisabled:function(){if(this.record){var d=this.recordClass.getMeta("containerProperty"),b=this.record.data[d],a=(b&&b.hasOwnProperty("account_grants"))?b.account_grants:null,c=false;if(this.evalGrants&&this.record.data.id&&a){c=!(a.hasOwnProperty("editGrant")&&a.editGrant)}return c}else{return false}},initRecord:function(){Tine.log.debug("init record with mode: "+this.mode);if(!this.record){Tine.log.debug("creating new default data record");this.record=new this.recordClass(this.recordClass.getDefaultData(),0)}if(this.mode!=="local"){if(this.record&&this.record.id){this.loadRemoteRecord()}else{this.onRecordLoad()}}else{if(!Ext.isFunction(this.record.beginEdit)){this.record=this.recordProxy.recordReader({responseText:this.record})}this.onRecordLoad()}},loadRemoteRecord:function(){Tine.log.info("initiating record load via proxy");this.loadRequest=this.recordProxy.loadRecord(this.record,{scope:this,success:function(a){this.record=a;this.onRecordLoad()}})},doCopyRecord:function(){var c=this.recordClass.getMeta("copyOmitFields")||[];c=c.concat(["id","notes"]);var b=this.recordClass.getFieldNames().diff(c),a=Ext.copyTo({},this.record.data,b);this.record=new this.recordClass(a,0)},onRecordLoad:function(){if(!this.rendered){this.onRecordLoad.defer(250,this);return}Tine.log.debug("Tine.widgets.dialog.EditDialog::onRecordLoad() - Loading of the following record completed:");Tine.log.debug(this.record);if(this.copyRecord){this.doCopyRecord();this.window.setTitle(String.format(_("Copy {0}"),this.i18nRecordName))}else{if(!this.record.id){this.window.setTitle(String.format(_("Add New {0}"),this.i18nRecordName))}else{this.window.setTitle(String.format(_('Edit {0} "{1}"'),this.i18nRecordName,this.record.getTitle()))}}var a=this.onAfterRecordLoad.deferByTickets(this),b=a();this.fireEvent("load",this,this.record,a);b()},onAfterRecordLoad:function(){var a=this.getForm();if(a){a.loadRecord(this.record);a.clearInvalid()}if(this.record&&this.record.hasOwnProperty("data")&&Ext.isObject(this.record.data[this.recordClass.getMeta("containerProperty")])){this.updateToolbars(this.record,this.recordClass.getMeta("containerProperty"))}if(this.loadMask){this.loadMask.hide()}},onRecordUpdate:function(){var a=this.getForm();a.updateRecord(this.record)},onRender:function(b,a){Tine.widgets.dialog.EditDialog.superclass.onRender.call(this,b,a);new Ext.KeyMap(this.el,[{key:[10,13],ctrl:true,scope:this,fn:function(){if(this.getForm().hasOwnProperty("items")){this.getForm().items.each(function(c){if(c.hasFocus){c.setValue(c.getRawValue())}},this)}this.action_saveAndClose.execute()}}]);this.loadMask=new Ext.LoadMask(b,{msg:String.format(_("Transferring {0}..."),this.i18nRecordName)});if(this.loadRecord!==false){this.loadMask.show()}},updateToolbars:function(a,c){if(!this.evalGrants){return}var b=[this.action_saveAndClose,this.action_applyChanges,this.action_delete,this.action_cancel];Tine.widgets.actionUpdater(a,b,c);Tine.widgets.actionUpdater(a,this.tbarItems,c)},getToolbar:function(){return this.getTopToolbar()},isValid:function(){return this.getForm().isValid()},onCancel:function(){this.fireEvent("cancel");this.purgeListeners();this.window.close()},onSaveAndClose:function(){this.fireEvent("saveAndClose");this.onApplyChanges(true)},onApplyChanges:function(b){this.loadMask.show();var a=this.doApplyChanges.deferByTickets(this,[b]),c=a();this.fireEvent("save",this,this.record,a);c()},doApplyChanges:function(b){this.onRecordUpdate();if(this.isValid()){if(this.mode!=="local"){this.recordProxy.saveRecord(this.record,{scope:this,success:function(d){this.record=d;if(!Ext.isFunction(this.window.cascade)){this.onRecordLoad()}var f=this.onAfterApplyChanges.deferByTickets(this,[b]),g=f();this.fireEvent("update",Ext.util.JSON.encode(this.record.data),this.mode,this,f);g()},failure:this.onRequestFailed,timeout:300000},{duplicateCheck:this.doDuplicateCheck})}else{this.onRecordLoad();var a=this.onAfterApplyChanges.deferByTickets(this,[b]),c=a();this.fireEvent("update",Ext.util.JSON.encode(this.record.data),this.mode,this,a);c()}}else{this.loadMask.hide();Ext.MessageBox.alert(_("Errors"),this.getValidationErrorMessage())}},onAfterApplyChanges:function(a){this.window.rename(this.windowNamePrefix+this.record.id);this.loadMask.hide();if(a){this.window.fireEvent("saveAndClose");this.purgeListeners();this.window.close()}},getValidationErrorMessage:function(){return _("Please fix the errors noted.")},onDelete:function(a,b){Ext.MessageBox.confirm(_("Confirm"),String.format(_("Do you really want to delete this {0}?"),this.i18nRecordName),function(c){if(a=="yes"){var d=new Ext.LoadMask(this.getEl(),{msg:String.format(_("Deleting {0}"),this.i18nRecordName)});d.show();this.recordProxy.deleteRecords(this.record,{scope:this,success:function(){this.purgeListeners();this.window.close()},failure:function(){Ext.MessageBox.alert(_("Failed"),String.format(_("Could not delete {0}."),this.i18nRecordName));Ext.MessageBox.hide()}})}})},onDuplicateException:function(b){var c=new Tine.widgets.dialog.DuplicateResolveGridPanel({app:this.app,store:new Tine.widgets.dialog.DuplicateResolveStore({app:this.app,recordClass:this.recordClass,recordProxy:this.recordProxy,data:{clientRecord:b.clientRecord,duplicates:b.duplicates}}),fbar:["->",this.action_cancel,this.action_saveAndClose]});c.btnSaveAndClose.setHandler(function(f,g){var d=c.store.resolveStrategy;if(d=="discard"){return this.onCancel()}this.record=c.store.getResolvedRecord();this.onRecordLoad();a.layout.setActiveItem(this.id);c.doLayout();this.doDuplicateCheck=false;this.onSaveAndClose()},this);this.window.setTitle(String.format(_("Resolve Duplicate {0} Suspicion"),this.i18nRecordName));var a=this.findParentBy(function(d){return d.isWindowMainCardPanel});a.add(c);a.layout.setActiveItem(c.id);c.doLayout()},onRequestFailed:function(a){this.saving=false;if(a.code==629){this.onDuplicateException.apply(this,arguments)}else{Tine.Tinebase.ExceptionHandler.handleRequestException(a)}this.loadMask.hide()},initRelationsPanel:function(){if(!this.relationsPanel&&!this.hideRelationsPanel&&this.recordClass&&this.recordClass.hasField("relations")){this.relationsPanel=new Tine.widgets.relation.GenericPickerGridPanel({anchor:"100% 100%",editDialog:this});this.items.items.push(this.relationsPanel)}}});Ext.ns("Tine.widgets.editDialog");Tine.widgets.dialog.MultipleEditDialogPlugin=function(a){Ext.apply(this,a)};Tine.widgets.dialog.MultipleEditDialogPlugin.prototype={app:null,editDialog:null,selectedRecords:null,selectionFilter:null,interRecord:null,form:null,handleFields:null,isFilterSelect:null,totalRecordCount:null,skipItems:[],init:function(a){a.mode="local";a.evalGrants=false;a.onRecordLoad=a.onRecordLoad.createSequence(this.onAfterRender,this);a.onApplyChanges=a.onApplyChanges.createInterceptor(this.onRecordUpdate,this);a.onRecordUpdate=Ext.emptyFn;a.initRecord=Ext.emptyFn;a.useMultiple=true;a.interRecord=new a.recordClass({});a.loadRecord=true;a.on("load",function(d,b,c){this.loadInterceptor=c()},this);this.app=Tine.Tinebase.appMgr.get(a.app);this.form=a.getForm();this.handleFields=[];this.interRecord=a.interRecord;if(a.hasOwnProperty("isMultipleValid")&&Ext.isFunction(a.isMultipleValid)){a.isValid=a.isMultipleValid}else{a.isValid=function(){return true}}this.editDialog=a},registerSkipItem:function(a){this.skipItems.push(a)},onAfterRender:function(){Ext.each(this.skipItems,function(d){d.setDisabled(true)},this);var a=[];var b=this.form.findField("container_id");if(b){b.disable()}Ext.each(this.editDialog.recordClass.getFieldNames(),function(d){var f=this.form.findField(d);if(!f){Tine.log.info('No field found for property "'+d+'". Ignoring...');return true}Tine.log.info('Field found for property "'+d+'".');a.push({key:d,type:"default",formField:f,recordKey:d})},this);var c=Tine.widgets.customfields.ConfigManager.getConfigs(this.app,this.editDialog.recordClass);if(c){Ext.each(c,function(d){var f=this.form.findField("customfield_"+d.data.name);if(!f){Tine.log.info('No customfield found for property "'+d.data.name+'". Ignoring...');return true}Tine.log.info('Customfield found for property "'+d.data.name+'".');a.push({key:d.data.name,type:"custom",formField:f,recordKey:"#"+d.data.name})},this)}if(this.editDialog.relationPickers){Ext.each(this.editDialog.relationPickers,function(d){Tine.log.info('RelationPicker found. Using "%'+d.relationType+"-"+d.fullModelName+'" as key.');a.push({key:d.relationType+"-"+d.fullModelName,type:"relation",formField:d.combo,recordKey:"%"+d.relationType+"-"+d.fullModelName})})}Ext.each(a,function(f){var d=f.formField;if((!(d.isXType("textfield")))&&(!(d.isXType("checkbox")))&&(!(d.isXType("datetimefield")))||d.multiEditable===false){Tine.log.debug('Disabling field for key "'+f.recordKey+'". Cannot be handled atm.');d.setDisabled(true);this.interRecord.set(f.recordKey,"");return true}if(d.hasOwnProperty("emptyText")){d.emptyText=""}d.startEvents=["focus"];d.triggerEvents=["blur"];if(d.isXType("tinedurationspinner")){d.emptyOnZero=true;d.startEvents=["focus","spin"];d.triggerEvents=["spin","blur"]}else{if(d.isXType("tinerecordpickercombobox")){d.startEvents=["focus","expand"];d.triggerEvents=["select","blur"]}}this.handleFields.push(f);Ext.each(d.startEvents,function(g){d.on(g,this.onInitField,this,[d])},this)},this);this.editDialog.record=this.interRecord;this.onRecordLoad()},onInitField:function(b){Tine.log.info('Init handler called for field "'+b.name+'".');if(!b.multipleInitialized){if(!b.isXType("checkbox")){this.createMultiButton(b)}var a=this.interRecord.get(b.name);if(b.isXType("addressbookcontactpicker")&&b.useAccountRecord){b.startRecord=a?a:null;a=a.accountId?a.accountId:null}else{if(b.isXType("timefield")){if(a.length){a=a.replace(/\d{4}-\d{2}-\d{2}\s/,"").replace(/:\d{2}$/,"")}}else{if(b.isXType("trigger")&&b.triggers){b.on("blur",this.hideTriggerClearer);b.on("focus",this.hideTriggerClearer);b.on("select",this.hideTriggerClearer)}else{if(Ext.isObject(a)){a=a[b.recordClass.getMeta("idProperty")];b.startRecord=new b.recordClass(a)}}}}b.startingValue=(a==undefined||a==null)?"":a;Tine.log.info('Setting start value to "'+a+'".');Ext.each(b.triggerEvents,function(c){b.on(c,this.onTriggerField,b)},this);b.multipleInitialized=true;if(b.isXType("tinedurationspinner")){b.fireEvent(b.triggerEvents[1])}}else{if(b.multiButton){b.multiButton.removeClass("hidden")}}},hideTriggerClearer:function(){this.triggers[0].hide()},createMultiButton:function(d){var a=18;if(d.isXType("tinerecordpickercombobox")){d.disableClearer=true;a+=19}else{if(d.isXType("extuxclearabledatefield")){d.disableClearer=true;if(!d.multi){a+=17}}else{if(d.isXType("tine.widget.field.AutoCompleteField")){}else{if(d.isXType("trigger")){if(!d.hideTrigger){a+=17}}else{if(d.isXType("datetimefield")){a+=17}}}}}var c=d.el.parent().select(".tinebase-editmultipledialog-clearer"),b=d.getWidth(),f=(b-a)+"px";d.startLeft=(b-a);if(c.elements.length>0){c.setStyle({left:f});c.removeClass("hidden");return}d.multiButton=new Ext.Element(document.createElement("img"));d.multiButton.set({src:Ext.BLANK_IMAGE_URL,"ext:qtip":Ext.util.Format.htmlEncode(_("Delete value from all selected records")),"class":"tinebase-editmultipledialog-clearer",style:"left:"+f});d.multiButton.addClassOnOver("over");d.multiButton.addClassOnClick("click");d.multiButton.on("click",this.onMultiButton,d);d.el.insertSibling(d.multiButton)},onMultiButton:function(){Tine.log.debug("Multibutton called.");if(this.multiButton.hasClass("undo")){Tine.log.debug('Resetting value to "'+this.startingValue+'".');if(this.startRecord){this.store.removeAll();this.setValue(this.startRecord);this.value=this.startingValue}else{this.setValue(this.startingValue)}this.clearInvalid();if(this.isXType("extuxclearabledatefield")&&this.multi){var b=this.startLeft?this.startLeft:0;var a=this.el.parent().select(".tinebase-editmultipledialog-clearer");a.setStyle("left",b+"px")}if(this.multi){this.cleared=false}}else{Tine.log.debug("Clearing value.");if(this.isXType("extuxclearabledatefield")&&this.multi){var b=this.startLeft?this.startLeft:0;b-=17;var a=this.el.parent().select(".tinebase-editmultipledialog-clearer");a.setStyle("left",b+"px")}this.setValue("");if(this.multi){this.cleared=true;this.allowBlank=this.origAllowBlank}}this.fireEvent(this.triggerEvents[0],this)},onTriggerField:function(){Tine.log.info('Trigger handler called for field "'+this.name+'".');var b=this.el.parent().select(".tinebase-editmultipledialog-dirty");var a=this.hasOwnProperty("startingValue")?String(this.startingValue):String(this.originalValue),c;if(this.isXType("datefield")){c=this.fullDateTime?this.fullDateTime.format("Y-m-d H:i:s"):""}else{if(this.isXType("timefield")){c=this.fullDateTime}else{c=String(this.getValue())}}Tine.log.info('Start value: "'+a+'", current: "'+c+'"');if((Ext.encode(a)!=Ext.encode(c))||(this.cleared===true)){if(b.elements.length>0){b.setStyle("display","block")}else{var d=new Ext.Element(document.createElement("img"));d.set({src:Ext.BLANK_IMAGE_URL,"class":"tinebase-editmultipledialog-dirty",height:5,width:5});this.el.insertSibling(d)}this.edited=true;this.setReadOnly(false);this.removeClass("tinebase-editmultipledialog-noneedit");this.multiButton.addClass("undo");this.multiButton.removeClass("hidden");this.multiButton.set({"ext:qtip":Ext.util.Format.htmlEncode(_("Undo change for all selected records"))})}else{if(b.elements.length>0){b.setStyle("display","none")}this.edited=false;if(this.multi){this.setReadOnly(true);this.addClass("tinebase-editmultipledialog-noneedit")}this.multiButton.removeClass("undo");this.multiButton.addClass("hidden");this.multiButton.set({"ext:qtip":Ext.util.Format.htmlEncode(_("Delete value from all selected records"))})}},onRecordLoad:function(){if(this.isFilterSelect&&this.selectionFilter){this.fetchRecordsOnLoad()}else{var a=[];Ext.each(this.selectedRecords,function(b,c){a.push(new this.editDialog.recordClass(b))},this);this.onRecordPrepare(a)}},onRecordPrepare:function(a){Ext.each(this.handleFields,function(c){var b=false;Ext.each(a,function(d,f){if(c.type=="relation"){this.setFieldValue(c,false)}else{if(f===0){b=d.get(c.recordKey)}if((Ext.encode(d.get(c.recordKey))!=Ext.encode(b))){this.interRecord.set(c.recordKey,"");this.setFieldValue(c,false);return false}else{if(f==a.length-1){this.interRecord.set(c.recordKey,b);this.setFieldValue(c,true);return true}}}},this)},this);this.interRecord.dirty=false;this.interRecord.modified={};this.editDialog.window.setTitle(String.format(_("Edit {0} {1}"),this.totalRecordCount,this.editDialog.i18nRecordsName));Tine.log.debug("loading of the following intermediate record completed:");Tine.log.debug(this.interRecord);this.editDialog.updateToolbars(this.interRecord,this.editDialog.recordClass.getMeta("containerProperty"));if(this.editDialog.tbarItems){Ext.each(this.editDialog.tbarItems,function(b){if(Ext.isFunction(b.setDisabled)){b.setDisabled(true)}b.multiEditable=false})}this.loadInterceptor();Ext.each(this.handleFields,function(c){if(c.formField.isXType("timefield")){var b=this.interRecord.get(c.key);if(b){c.formField.setValue(new Date(b))}}},this);return false},setFieldValue:function(c,b){var a=c.formField;a.removeClass("x-form-empty-field");if(!b){a.setReadOnly(true);a.addClass("tinebase-editmultipledialog-noneedit");a.origAllowBlank=a.allowBlank;a.allowBlank=true;a.multi=true;a.setValue("");a.originalValue="";a.clearInvalid();Ext.QuickTips.register({target:a,dismissDelay:30000,title:_("Different Values"),text:_("This field has different values. Editing this field will overwrite the old values."),width:200});if(a.isXType("checkbox")){this.wrapCheckbox(a)}}else{if(a.isXType("checkbox")){a.originalValue=this.interRecord.get(a.name);a.setValue(this.interRecord.get(a.name))}else{if(a.isXType("tinerecordpickercombobox")){var d=this.interRecord.get(c.recordKey);if(d){if(!a.isXType("addressbookcontactpicker")){a.startRecord=new a.recordClass(d)}else{a.startRecord=d}}}else{a.setValue(this.interRecord.get(c.recordKey))}}}a.edited=false;if(a.isXType("checkbox")){a.on("check",function(){this.edited=(this.originalValue!==this.getValue())})}},wrapCheckbox:function(a){if(a.rendered!==true){this.wrapCheckbox.defer(100,this,[a]);return}a.getEl().wrap({tag:"span","class":"tinebase-editmultipledialog-dirtycheck"});a.originalValue=null;a.setValue(false)},onRecordUpdate:function(){this.changedHuman="<br /><br /><ul>";var b=[];Ext.each(this.handleFields,function(g){var c=g.formField,f=Ext.util.Format.htmlEncode;if(c.edited===true){var d=c.fieldLabel?c.fieldLabel:c.boxLabel?c.boxLabel:c.ownerCt.fieldLabel;d=d?d:c.ownerCt.title;b.push({name:(g.type=="relation")?g.recordKey:c.getName(),value:c.getValue()});this.changedHuman+='<li><span style="font-weight:bold">'+d+":</span> ";if(c.isXType("checkbox")){f=Tine.Tinebase.common.booleanRenderer}else{if(c.isXType("tinedurationspinner")){f=Tine.Tinebase.common.minutesRenderer}}this.changedHuman+=c.lastSelectionText?f(c.lastSelectionText):f(c.getValue());this.changedHuman+="</li>"}},this);this.changedHuman+="</ul>";if(b.length==0){this.editDialog.onCancel();return false}if(!this.editDialog.isMultipleValid()){Ext.MessageBox.alert(_("Errors"),_("Please fix the errors noted."));Ext.each(this.handleFields,function(c){if(c.activeError){if(!c.edited){c.activeError=null}}});return false}else{var a=this.selectionFilter;Ext.MessageBox.confirm(_("Confirm"),String.format(_("Do you really want to change these {0} records?")+this.changedHuman,this.totalRecordCount),function(c){if(c=="yes"){Ext.MessageBox.wait(_("Please wait"),_("Applying changes"));Ext.Ajax.request({url:"index.php",timeout:3600000,params:{method:"Tinebase.updateMultipleRecords",appName:this.editDialog.recordClass.getMeta("appName"),modelName:this.editDialog.recordClass.getMeta("modelName"),changes:b,filter:a},success:function(f,d){Ext.MessageBox.hide();var h=Ext.decode(f.responseText);if(h.failcount>0){var g=Tine.widgets.dialog.MultipleEditResultSummary.openWindow({response:f.responseText,appName:this.app.appName,recordClass:this.editDialog.recordClass});g.on("close",function(){this.editDialog.fireEvent("update");this.editDialog.onCancel()},this)}else{this.editDialog.fireEvent("update");this.editDialog.onCancel()}},scope:this})}},this)}return false},fetchRecordsOnLoad:function(){Tine.log.debug("Fetching additional records...");this.editDialog.recordProxy.searchRecords(this.selectionFilter,null,{scope:this,success:function(a){this.onRecordPrepare.call(this,a.records)}})}};Ext.ComponentMgr.registerPlugin("multiple_edit_dialog",Tine.widgets.dialog.MultipleEditDialogPlugin);Ext.ns("Tine.widgets.editDialog");Tine.widgets.dialog.AddRelationsEditDialogPlugin=function(a){Ext.apply(this,a)};Tine.widgets.dialog.AddRelationsEditDialogPlugin.prototype={recordClass:null,editDialog:null,addRelations:null,selectionFilter:null,callingApp:null,callingModel:null,relationConfig:null,recordProxy:null,init:function(a){a.on("load",function(d,b,c){this.interceptor=c();this.fetchRecords()},this);Tine.log.info('Init plugin "Tine.widgets.dialog.AddRelationsDialogPlugin"...');this.relationConfig=this.relationConfig?this.relationConfig:{};Ext.each(a.app.getRegistry().get("relatableModels"),function(b){if(b.relatedApp==this.callingApp&&b.relatedModel==this.callingModel){Ext.applyIf(this.relationConfig,b["default"]);return false}},this);this.editDialog=a;this.recordClass=Tine[this.callingApp].Model[this.callingModel];this.recordProxy=new Tine.Tinebase.data.RecordProxy({recordClass:this.recordClass})},fetchRecords:function(){if(Ext.isBoolean(this.addRelations)){Tine.log.debug("Fetching additional records...");this.recordProxy.searchRecords(this.selectionFilter,null,{scope:this,success:function(b){this.addRelationsOnLoad(b.records)}})}else{var a=[];Ext.each(this.addRelations,function(b){a.push(this.recordProxy.recordReader({responseText:Ext.encode(b)}))},this);this.addRelationsOnLoad(a)}},addRelationsOnLoad:function(b){var f=this.editDialog.recordClass.getMeta("idProperty"),c=this.recordClass.getMeta("idProperty");var a=[];Ext.each(b,function(g){var j=true;Ext.each(this.editDialog.record.get("relations"),function(k){if((g.get(c)==k.related_record[c])){j=false;return}},this);if(j){if(g.data.hasOwnProperty("relations")){delete g.data.relations}var h={own_backend:"Sql",own_degree:"sibling",own_id:this.editDialog.record.get(f),own_model:this.editDialog.app.name+"_Model_"+this.editDialog.recordClass.getMeta("modelName"),related_backend:"sql",related_id:g.get(c),related_model:this.callingApp+"_Model_"+this.callingModel,related_record:g.data,remark:"",type:""};Ext.apply(h,this.relationConfig);a.push(h)}},this);var d=this.editDialog.record.data.hasOwnProperty("relations")?this.editDialog.record.data.relations:[];Ext.each(d,function(g){if(g.related_record.hasOwnProperty("relation")){delete g.related_record.relation}},this);this.editDialog.record.set("relations",d.concat(a));this.interceptor()}};Ext.ComponentMgr.registerPlugin("addrelations_edit_dialog",Tine.widgets.dialog.AddRelationsEditDialogPlugin);Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.MultipleEditResultSummary=function(a){Tine.widgets.dialog.MultiOptionsDialog.superclass.constructor.call(this,a);this.options=a.options||{};this.scope=a.scope||window};Ext.extend(Tine.widgets.dialog.MultipleEditResultSummary,Ext.FormPanel,{layout:"fit",border:false,labelAlign:"top",items:null,anchor:"100% 100%",store:null,response:null,appName:null,app:null,recordClass:null,initComponent:function(){this.response=Ext.decode(this.response);if(!this.app){this.app=Tine.Tinebase.appMgr.get(this.appName)}if(this.app.i18n&&this.recordClass!==null){this.i18nRecordName=this.app.i18n.n_hidden(this.recordClass.getMeta("recordName"),this.recordClass.getMeta("recordsName"),1);this.i18nRecordsName=this.app.i18n._hidden(this.recordClass.getMeta("recordsName"))}this.initActions();this.initButtons();this.initStore();this.items=this.getFormItems();Tine.widgets.dialog.MultipleEditResultSummary.superclass.initComponent.call(this)},initActions:function(){this.action_update=new Ext.Action({text:_("OK"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_saveAndClose"})},initStore:function(){this.store=new Ext.data.JsonStore({mode:"local",idProperty:"id",fields:["id","record","message"],sortInfo:{field:"record",direction:"ASC"}});this.store.loadData(this.response.exceptions)},initButtons:function(){this.fbar=["->",this.action_update]},onRender:function(b,a){Tine.widgets.dialog.MultipleEditResultSummary.superclass.onRender.call(this,b,a);var c=new Ext.KeyMap(this.el,[{key:[10,13],ctrl:true,fn:this.onCancel,scope:this}])},onCancel:function(){this.fireEvent("cancel");this.purgeListeners();this.window.close()},getFormItems:function(){if(this.items){return this.items}var c=this.response.totalcount+this.response.failcount;var b=(c>1)?this.i18nRecordsName:this.i18nRecordName;var a=String.format((c>1)?_("You edited {0} {1}."):_("You edited {0} {1}."),c,b);a+="<br />";b=(this.response.totalcount>1)?this.i18nRecordsName:this.i18nRecordName;a+=String.format((this.response.totalcount>1)?_("{0} {1} have been updated properly."):_("{0} {1} has been updated properly."),this.response.totalcount,b);a+="<br />";b=(this.response.failcount>1)?this.i18nRecordsName:this.i18nRecordName;a+=String.format((this.response.failcount>1)?_("{0} {1} have invalid data after updating. These {1} have not been changed."):_("{0} {1} has invalid data after updating. This {1} has not been changed."),this.response.failcount,b);return{border:false,cls:"x-ux-display",layout:"ux.display",frame:true,autoScroll:true,items:[{height:100,border:false,items:[{hideLabel:true,xtype:"ux.displayfield",value:a,htmlEncode:false,style:"padding: 0 5px; color: black",cls:"x-panel-mc"}],hideLabel:true,ref:"../../summaryPanelInfo",layout:"ux.display",layoutConfig:{background:"border"}},{baseCls:"ux-arrowcollapse",cls:"ux-arrowcollapse-plain",collapsible:true,hidden:false,flex:1,title:"",ref:"../../summaryPanelFailures",items:[{xtype:"grid",store:this.store,autoHeight:true,columns:[{id:"id",header:_("Index"),width:60,sortable:false,dataIndex:"id",hidden:true},{id:"record",header:this.i18nRecordName,width:160,sortable:true,dataIndex:"record",renderer:function(d){return d.n_fn}},{id:"failure",header:_("Failure"),width:60,sortable:true,dataIndex:"message"}],autoExpandColumn:"failure"}]}]}}});Tine.widgets.dialog.MultipleEditResultSummary.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:600,height:450,modal:true,title:_("Summary"),contentPanelConstructor:"Tine.widgets.dialog.MultipleEditResultSummary",contentPanelConstructorConfig:a});return b};Ext.ns("Ext.ux");Ext.ux.TabPanelKeyPlugin=function(a){Ext.apply(this,a)};Ext.ux.TabPanelKeyPlugin.prototype={panel:null,init:function(a){this.panel=a;this.panel.onRender=this.panel.onRender.createSequence(this.onRender,this)},onRender:function(){if(!this.panel.rendered){this.onRender.defer(250,this);return}var b=this.panel.items.length;for(var a=0;a<b;a++){var c=this.panel.items.items[a];if(c.disabled!==true){new Ext.KeyMap(this.panel.el,[{key:a+49,ctrl:true,scope:this,fn:this.switchTab}])}}},switchTab:function(b){var a=parseInt(b)-49;if(this.panel){this.panel.setActiveTab(a)}}};Ext.preg("ux.tabpanelkeyplugin",Ext.ux.TabPanelKeyPlugin);Ext.ns("Tine.widgets.editDialog");Tine.widgets.dialog.TokenModeEditDialogPlugin=function(a){Ext.apply(this,a)};Tine.widgets.dialog.TokenModeEditDialogPlugin.prototype={app:null,editDialog:null,form:null,inTokenMode:false,selection:null,init:function(a){this.editDialog=a;this.app=Tine.Tinebase.appMgr.get(this.editDialog.app);this.form=this.editDialog.getForm();if(this.editDialog.rendered){this.onAfterRender()}else{this.editDialog.on("afterrender",this.onAfterRender,this)}this.editDialog.onRecordLoad=this.editDialog.onRecordLoad.createSequence(this.onRecordLoad,this)},onAfterRender:function(){this.editDialog.getEl().on("keydown",function(a){if(a.ctrlKey&&a.getKey()===a.T){if(this.inTokenMode){this.endTokenMode()}else{this.startTokenMode()}}},this)},onRecordLoad:function(){if(this.inTokenMode){this.startTokenMode.defer(100,this)}},startTokenMode:function(){this.initialize();if(this.inTokenMode){this.endTokenMode()}this.inTokenMode=true;this.selection=[];this.form.items.each(function(a){if(a instanceof Ext.form.TextField&&!a.disabled&&!a.forceSelection){if(a.rendered){this.tokenizeField(a)}else{a.on("render",this.tokenizeField,this)}}},this)},endTokenMode:function(){if(this.inTokenMode){this.inTokenMode=false;Ext.select("div[class^=tinebase-tokenedit-tokenbox]",this.editDialog.getEl()).remove();this.form.items.each(function(a){a.un("render",this.tokenizeField,this);a.un("resize",this.syncFieldSize,this)},this)}},initialize:function(){if(!this.isInitialized){this.isInitialized=true;this.dragZone=new Ext.dd.DragZone(this.editDialog.getEl(),{getDragData:this.getDragData.createDelegate(this),getRepairXY:Ext.emptyFn});this.dropZone=new Ext.dd.DropZone(this.editDialog.getEl(),{onNodeOver:this.onNodeOver.createDelegate(this),onNodeDrop:this.onNodeDrop.createDelegate(this),getTargetFromEvent:this.getTargetFromEvent.createDelegate(this)});this.editDialog.getEl().on("mousedown",this.onClick,this)}},tokenizeField:function(d){if(!this.inTokenMode){return}var a=d.itemCt.insertFirst({tag:"div","class":"tinebase-tokenedit-tokenbox x-form-text"+(d instanceof Ext.form.TextArea?" tinebase-tokenedit-tokenbox-area":"")});this.syncFieldSize(d);d.on("resize",this.syncFieldSize,this);var b=Ext.util.Format.htmlEncode(d.getValue());if(b){b=b.replace(/\n/g," &#x21A9; ");var c=String(b).split(/\s+/);this.getTokenTpl().overwrite(a,c)}},syncFieldSize:function(b){var a=b.itemCt.down("div[class^=tinebase-tokenedit-tokenbox]");a.setBox(b.el.getBox())},getTokenTpl:function(){if(!this.tokenTpl){this.tokenTpl=new Ext.XTemplate('<tpl for=".">','<span class="tinebase-tokenedit-token">{.}</span>',"</tpl>").compile()}return this.tokenTpl},onClick:function(b){if(this.processedEvent==b.browserEvent){return}this.processedEvent=b.browserEvent;var a=b.getTarget(".tinebase-tokenedit-token",10,true);if(a){if(b.ctrlKey){if(this.selection.indexOf(a)<0){this.selection.push(a);a.addClass("tinebase-tokenedit-token-selected")}else{this.selection.remove(a);a.removeClass("tinebase-tokenedit-token-selected")}}else{Ext.each(this.selection,function(c){c.removeClass("tinebase-tokenedit-token-selected")},this);this.selection=[a];a.addClass("tinebase-tokenedit-token-selected")}}},getDragData:function(c){var b=c.getTarget(".tinebase-tokenedit-token",10,true);if(b){if(this.selection.indexOf(b)<0){this.onClick(c)}this.processedEvent=c.browserEvent;var d=new Ext.Element(document.createElement("div"));d.id=Ext.id();var a=[];Ext.each(this.selection,function(f){a.push(Ext.getCmp(f.parent("div[class^=tinebase-tokenedit-tokenbox]").parent("div").child("*[id^=ext-comp]").id));var g=f.dom.cloneNode(true);g.id=Ext.id();d.appendChild(g)},this);return{ddel:d.dom,sourceFields:a}}},getTargetFromEvent:function(b){var a=b.getTarget(".tinebase-tokenedit-tokenbox",10,true);this.getPositionEl().setStyle("display",a?"inline-block":"none");return a},onNodeOver:function(h,a,g,d){var f=h.query(".tinebase-tokenedit-token"),b=null,j=null,c=g.getXY();Ext.each(f,function(o){var m=Ext.get(o),q=m.getBox();var l=c[0]>q[0]?Math.max(0,Math.min(c[0]-q[0],c[0]-q.right)):Math.max(0,Math.min(q[0]-c[0],q.right-c[0]));var k=c[1]>q[1]?Math.max(0,Math.min(c[1]-q[1],c[1]-q.bottom)):Math.max(0,Math.min(q[1]-c[1],q.bottom-c[1]));m.distance=l+k;if(!b||m.distance<b.distance){b=m;j=q}},this);if(b){d.insertPosition=c[0]>(j.x+j.width/2)?"insertAfter":"insertBefore";this.getPositionEl()[d.insertPosition](b)}else{h.insertFirst(this.getPositionEl())}d.nextToken=b;return Ext.dd.DropZone.prototype.dropAllowed},onNodeDrop:function(g,a,f,b){var d=Ext.getCmp(g.up("div").child("*[id^=ext-comp]").id),c=this.getPositionEl();c.setStyle("display","none");Ext.each(this.selection,function(h){h.insertBefore(c)},this);Ext.each([d].concat(b.sourceFields),function(j){var h=[];Ext.each(j.itemCt.query(".tinebase-tokenedit-token"),function(k){h.push(k.innerHTML)},this);h=h.join(" ");h=Ext.util.Format.htmlDecode(h.replace(/\s*\u21A9\s*/g,"\n"));j.setValue(h)},this)},getPositionEl:function(){if(!this.positionEl){this.positionEl=this.editDialog.getEl().createChild({tag:"span","class":"tinebase-tokenedit-position",html:"&nbsp;"})}return this.positionEl}};Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.WizardPanel=Ext.extend(Ext.Panel,{cls:"tw-editdialog",border:false,layout:"card",activeItem:0,initComponent:function(){this.addEvents("cancel","finish");this.initFooterBar();this.on("afterrender",this.onAfterRender,this);Tine.widgets.dialog.WizardPanel.superclass.initComponent.call(this)},onBackButton:function(){return Ext.isFunction(this.layout.activeItem.onBackButton)?this.layout.activeItem.onBackButton():this.navigate(-1)},onNextButton:function(){return Ext.isFunction(this.layout.activeItem.onNextButton)?this.layout.activeItem.onNextButton():this.navigate(+1)},onCancelButton:function(){if(Ext.isFunction(this.layout.activeItem.onCancelButton)){return this.layout.activeItem.onCancelButton()}else{this.fireEvent("cancel",this,this.layout.activeItem)}},onFinishButton:function(){if(Ext.isFunction(this.layout.activeItem.onFinishButton)){return this.layout.activeItem.onFinishButton()}else{this.fireEvent("finish",this,this.layout.activeItem)}},navigate:function(b){var a=this.items.indexOf(this.layout.activeItem),c=Ext.isNumber(b)?this.items.get(a+b):this.items.get(b);if(c){this.layout.setActiveItem(c);c.doLayout()}this.manageButtons()},manageButtons:function(){Ext.each(["back","next","cancel","finish"],function(a){this[a+"Button"].setDisabled(!this[a+"IsAllowed"]())},this)},backIsAllowed:function(){var a=Ext.isFunction(this.layout.activeItem.backIsAllowed)?this.layout.activeItem.backIsAllowed():true;return a&&this.items.indexOf(this.layout.activeItem)>0},nextIsAllowed:function(){var a=Ext.isFunction(this.layout.activeItem.nextIsAllowed)?this.layout.activeItem.nextIsAllowed():true;return a&&this.items.indexOf(this.layout.activeItem)<this.items.getCount()-1},cancelIsAllowed:function(){var a=Ext.isFunction(this.layout.activeItem.cancelIsAllowed)?this.layout.activeItem.cancelIsAllowed():true;return a&&true},finishIsAllowed:function(){var a=Ext.isFunction(this.layout.activeItem.finishIsAllowed)?this.layout.activeItem.finishIsAllowed():true;return a&&this.items.indexOf(this.layout.activeItem)==this.items.getCount()-1},initFooterBar:function(){this.fbar=["->",{text:_("Back"),minWidth:70,ref:"../backButton",iconCls:"action_previous",scope:this,handler:this.onBackButton},{text:_("Next"),minWidth:70,ref:"../nextButton",iconCls:"action_next",scope:this,handler:this.onNextButton},{text:_("Cancel"),minWidth:70,ref:"../cancelButton",iconCls:"action_cancel",scope:this,handler:this.onCancelButton},{text:_("Finish"),minWidth:70,ref:"../finishButton",iconCls:"action_saveAndClose",scope:this,handler:this.onFinishButton}]},onAfterRender:function(){this.manageButtons()}});Ext.reg("tw-wizardpanel",Tine.widgets.dialog.WizardPanel);Ext.ns("Tine.widgets","Tine.widgets.dialog");Tine.widgets.dialog.AdminPanel=Ext.extend(Tine.widgets.dialog.EditDialog,{appName:"Admin",recordClass:Tine.Tinebase.Model.Config,evalGrants:false,initComponent:function(){this.record=new this.recordClass({id:this.appName});Tine.widgets.dialog.AdminPanel.superclass.initComponent.call(this)},onRecordLoad:function(){if(!this.rendered){this.onRecordLoad.defer(250,this);return}this.window.setTitle(String.format(_("Change settings for application {0}"),this.appName));if(this.fireEvent("load",this)!==false){var b=this.record.get("settings"),c=this.getForm();for(var a in b){c.findField(a).setValue(b[a])}c.clearInvalid();this.loadMask.hide()}},onRecordUpdate:function(){var c=this.record.get("settings"),d=this.getForm(),a={};for(var b in c){a[b]=d.findField(b).getValue()}this.record.set("settings",a)},getFormItems:function(){return{xtype:"tabpanel",activeTab:0,border:false,items:[{title:this.app.i18n._("Defaults"),autoScroll:true,border:false,frame:true,xtype:"columnform",formDefaults:{anchor:"90%",labelSeparator:"",columnWidth:1},items:this.getConfigItems()}]}},getConfigItems:function(){return[]}});Ext.ns("Tine.widgets","Tine.widgets.dialog");Tine.widgets.dialog.CredentialsDialog=Ext.extend(Tine.widgets.dialog.EditDialog,{credentialsId:null,windowNamePrefix:"CredentialsWindow_",loadRecord:false,tbarItems:[],evalGrants:false,sendRequest:true,mode:"local",getFormItems:function(){return{bodyStyle:"padding:5px;",buttonAlign:"right",labelAlign:"top",border:false,layout:"form",defaults:{xtype:"textfield",anchor:"90%",listeners:{scope:this,specialkey:function(b,a){if(a.getKey()==a.ENTER){this.onApplyChanges()}}}},items:[{fieldLabel:_("Username"),name:"username",allowBlank:false},{fieldLabel:_("Password"),name:"password",inputType:"password"}]}},onRecordLoad:function(){if(!this.rendered){this.onRecordLoad.defer(250,this);return}var a=this.windowTitle||this.app.i18n._("Please enter your credentials");this.window.setTitle(a);this.getForm().loadRecord(this.record);this.loadMask.hide()},onApplyChanges:function(){var b=this.getForm();if(b.isValid()){var a=b.getValues();if(this.sendRequest){this.loadMask.show();var c={method:this.appName+".changeCredentials",password:a.password,username:a.username,id:this.credentialsId};Ext.Ajax.request({params:c,scope:this,success:function(f,d){this.loadMask.hide();this.fireEvent("update",f);this.purgeListeners();this.window.close()}})}else{this.fireEvent("update",a);this.window.close()}}else{Ext.MessageBox.alert(_("Errors"),_("Please fix the errors noted."))}}});Tine.widgets.dialog.CredentialsDialog.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:240,height:180,name:Tine.widgets.dialog.CredentialsDialog.windowNamePrefix+Ext.id(),contentPanelConstructor:"Tine.widgets.dialog.CredentialsDialog",contentPanelConstructorConfig:a,modal:true});return b};Ext.ns("Tine.widgets","Tine.widgets.dialog");Tine.widgets.dialog.Preferences=Ext.extend(Ext.FormPanel,{i18n:null,prefsCardPanel:null,treePanel:null,prefPanels:{},adminMode:false,adminPrefPanels:{},initialCardName:null,layout:"fit",cls:"tw-editdialog",anchor:"100% 100%",buttonAlign:"right",border:false,initComponent:function(){this.addEvents("cancel","saveAndClose","update");this.i18n=new Locale.Gettext();this.i18n.textdomain("Tinebase");this.initActions();this.initButtons();this.items=this.getItems();Tine.widgets.dialog.Preferences.superclass.initComponent.call(this)},initActions:function(){this.action_saveAndClose=new Ext.Action({text:_("Ok"),minWidth:70,scope:this,handler:this.onSaveAndClose,iconCls:"action_saveAndClose"});this.action_cancel=new Ext.Action({text:_("Cancel"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_cancel"});this.action_switchAdminMode=new Ext.Action({text:_("Admin Mode"),minWidth:70,scope:this,handler:this.onSwitchAdminMode,iconCls:"action_adminMode",enableToggle:true})},initButtons:function(){this.buttons=[this.action_cancel,this.action_saveAndClose];this.tbar=new Ext.Toolbar({items:[this.action_switchAdminMode]})},getItems:function(){this.prefsCardPanel=new Tine.widgets.dialog.PreferencesCardPanel({region:"center"});this.treePanel=new Tine.widgets.dialog.PreferencesTreePanel({title:_("Applications"),region:"west",width:200,border:false,frame:false,initialNodeId:this.initialCardName});return[{xtype:"panel",autoScroll:true,border:false,frame:false,layout:"border",items:[this.treePanel,this.prefsCardPanel]}]},onRender:function(b,a){Tine.widgets.dialog.Preferences.superclass.onRender.call(this,b,a);this.setHeight(Ext.fly(this.el.dom.parentNode).getHeight());this.window.setTitle(this.i18n._("Edit Preferences"));this.loadMask=new Ext.LoadMask(b,{msg:_("Loading ...")})},onCancel:function(){this.fireEvent("cancel");this.purgeListeners();this.window.close()},onDestroy:function(){for(var a in this.adminPrefPanels){if(this.adminPrefPanels.hasOwnProperty(a)){if(this.adminPrefPanels[a]!==null){this.adminPrefPanels[a].destroy();this.adminPrefPanels[a]=null}}}for(a in this.prefPanels){if(this.prefPanels.hasOwnProperty(a)){if(this.prefPanels[a]!==null){this.prefPanels[a].destroy();this.prefPanels[a]=null}}}this.prefsCardPanel.destroy();this.prefsCardPanel=null;Tine.widgets.dialog.Preferences.superclass.onDestroy.apply(this,arguments)},onSaveAndClose:function(){this.onApplyChanges(true);this.fireEvent("saveAndClose")},onApplyChanges:function(a){if(!this.isValid()){Ext.MessageBox.alert(_("Errors"),_("You need to correct the red marked fields before config could be saved"));return}this.loadMask.show();var b=this.getValuesFromPanels();Ext.Ajax.request({scope:this,params:{method:"Tinebase.savePreferences",data:b,adminMode:(this.adminMode)?1:0},success:function(c){this.loadMask.hide();this.updateRegistry(Ext.util.JSON.decode(c.responseText).results);if(a){this.purgeListeners();this.window.close()}},failure:function(c){Ext.MessageBox.alert(_("Errors"),_("Saving of preferences failed."))}})},isValid:function(){var a={};var b=(this.adminMode)?this.adminPrefPanels:this.prefPanels;for(panelName in b){a=b[panelName];if(a&&typeof a.isValid==="function"&&!a.isValid()){return false}}return true},getValuesFromPanels:function(){var a,f={};var c=(this.adminMode)?this.adminPrefPanels:this.prefPanels;for(panelName in c){if(c.hasOwnProperty(panelName)){a=c[panelName];if(a!==null){f[a.appName]={};for(var b=0;b<a.items.length;b++){var d=a.items.items[b];if(d&&d.name){if(this.adminMode){if(!d.disabled){f[a.appName][d.prefId]={value:d.getValue(),name:d.name};f[a.appName][d.prefId].type=(Ext.getCmp(d.name+"_writable").getValue()==1)?"default":"forced"}}else{f[a.appName][d.name]={value:d.getValue()}}}}}}}return f},updateRegistry:function(b){for(application in b){if(b.hasOwnProperty(application)){appPrefs=b[application];var d=Tine[application].registry.get("preferences");var c=false;for(var a=0;a<appPrefs.length;a++){if(d.get(appPrefs[a].name)!=appPrefs[a].value){d.replace(appPrefs[a].name,appPrefs[a].value);c=true}}if(c){Tine[application].registry.replace("preferences",d)}}}},onSwitchAdminMode:function(a,b){this.adminMode=(!this.adminMode);if(this.adminMode){this.prefsCardPanel.addClass("prefpanel_adminMode")}else{this.prefsCardPanel.removeClass("prefpanel_adminMode")}var c=this.treePanel.getSelectionModel().getSelectedNode();if(c){this.showPrefsForApp(this.treePanel.getSelectionModel().getSelectedNode().id)}this.treePanel.checkGrants(this.adminMode)},initPrefStore:function(a){this.loadMask.show();var c=(this.adminMode)?[{field:"account",operator:"equals",value:{accountId:0,accountType:"anyone"}}]:"";var b=new Ext.data.JsonStore({fields:Tine.Tinebase.Model.Preference,baseParams:{method:"Tinebase.searchPreferencesForApplication",applicationName:a,filter:c},listeners:{load:this.onStoreLoad,scope:this},root:"results",totalProperty:"totalcount",id:"id",remoteSort:false});b.load()},onStoreLoad:function(c,b,f){var a=c.baseParams.applicationName;var d=new Tine.widgets.dialog.PreferencesPanel({prefStore:c,appName:a,adminMode:this.adminMode});d.on("change",function(g){var h=this.treePanel.getNodeById(g);h.setText(h.text+"*")},this);if(this.adminMode){this.adminPrefPanels[a]=d}else{this.prefPanels[a]=d}this.activateCard(d,false);this.loadMask.hide()},activateCard:function(a,b){if(!b){this.prefsCardPanel.add(a);this.prefsCardPanel.layout.container.add(a)}this.prefsCardPanel.layout.setActiveItem(a.id);a.doLayout()},showPrefsForApp:function(a){if(a==="Tinebase.UserProfile"){if(!this.prefPanels[a]){this.prefPanels[a]=new Tine.Tinebase.UserProfilePanel({appName:a});this.activateCard(this.prefPanels[a],false)}}var b=(this.adminMode)?this.adminPrefPanels[a]:this.prefPanels[a];if(!this.adminMode){this.action_switchAdminMode.setDisabled(!Tine.Tinebase.common.hasRight("admin",a))}if(!b){this.initPrefStore(a)}else{this.activateCard(b,true)}}});Tine.widgets.dialog.Preferences.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:800,height:470,name:"Preferences",contentPanelConstructor:"Tine.widgets.dialog.Preferences",contentPanelConstructorConfig:a});return b};Ext.ns("Tine.widgets","Tine.widgets.dialog");Tine.widgets.dialog.PreferencesTreePanel=Ext.extend(Ext.tree.TreePanel,{initialNodeId:null,iconCls:"x-new-application",rootVisible:true,border:false,autoScroll:true,bodyStyle:"background-color:white",initComponent:function(){Tine.widgets.dialog.PreferencesTreePanel.superclass.initComponent.call(this);this.initTreeNodes();this.initHandlers();this.selectInitialNode.defer(200,this)},selectInitialNode:function(){var a=(this.initialNodeId!==null)?this.getNodeById(this.initialNodeId):this.getRootNode();this.fireEvent("click",a)},initTreeNodes:function(){var a=new Ext.tree.TreeNode({text:_("General Preferences"),id:"Tinebase",draggable:false,allowDrop:false,expanded:true});this.setRootNode(a);var b=Tine.Tinebase.appMgr.getAll();if(Tine.Tinebase.common.hasRight("manage_own_profile","Tinebase")){var c=new Ext.tree.TreeNode({text:_("My Profile"),cls:"file",iconCls:"tinebase-accounttype-user",id:"Tinebase.UserProfile",leaf:null});a.appendChild(c)}b.each(function(f){if(f&&Ext.isFunction(f.getTitle)){var d=new Ext.tree.TreeNode({text:f.getTitle(),cls:"file",id:f.appName,iconCls:f.getIconCls("PreferencesTreePanel"),leaf:null});a.appendChild(d)}},this)},initHandlers:function(){this.on("click",function(b){b.getOwnerTree().selectPath(b.getPath());b.expand();var a=this.findParentByType(Tine.widgets.dialog.Preferences);a.showPrefsForApp(b.id)},this);this.on("beforeexpand",function(a){if(a.getSelectionModel().getSelectedNode()===null){a.expandPath("/Tinebase");a.selectPath("/Tinebase")}a.fireEvent("click",a.getSelectionModel().getSelectedNode())},this)},checkGrants:function(b){var a=this.getRootNode();a.eachChild(function(c){if(!Tine.Tinebase.common.hasRight("admin",c.id)&&b){c.disable()}else{c.enable()}})}});Ext.ns("Tine.widgets","Tine.widgets.dialog");Tine.widgets.dialog.PreferencesCardPanel=Ext.extend(Ext.Panel,{layout:"card",border:false,frame:true,labelAlign:"top",autoScroll:true,defaults:{anchor:"100%"},initComponent:function(){this.title=_("Preferences");Tine.widgets.dialog.PreferencesCardPanel.superclass.initComponent.call(this)}});Tine.widgets.dialog.PreferencesPanel=Ext.extend(Ext.Panel,{prefStore:null,appName:"Tinebase",adminMode:false,layout:"form",border:true,labelAlign:"top",autoScroll:true,defaults:{anchor:"95%",labelSeparator:""},bodyStyle:"padding:5px",initComponent:function(){this.addEvents("change");if(this.prefStore&&this.prefStore.getCount()>0){Tine.log.debug("Tine.widgets.dialog.PreferencesPanel::initComponent() -> Adding pref items from store:");Tine.log.debug(this.prefStore);this.items=[];this.prefStore.each(function(a){var c={fieldLabel:a.get("label"),name:a.get("name"),value:a.get("value"),listeners:{scope:this,change:function(j,h,g){this.fireEvent("change",this.appName)}},prefId:a.id,description:a.get("description")};var b=a.get("options");if(b.length>1||(b.length==1&&b[0][0]!=="_default_")){Ext.apply(c,{xtype:(this.adminMode?"lockCombo":"combo"),store:a.get("options"),mode:"local",forceSelection:true,allowBlank:false,triggerAction:"all"})}else{Ext.apply(c,{xtype:(this.adminMode?"lockTextfield":"textfield"),defaultValue:(b[0]&&b[0][1])?b[0][1]:"",isValid:function(){var g=this.defaultValue.match(/\(([0-9]*)\)$/)?"int":"string",h=this.getValue();if(h=="_default_"){return true}if(g=="int"){return !!String(h).match(/\d+/)}return true},setValue:function(g){g=g=="_default_"?this.defaultValue:g;Ext.form.TextField.prototype.setValue.call(this,g)},getValue:function(){var g=Ext.form.TextField.prototype.getValue.call(this);return g==this.defaultValue?"_default_":g},postBlur:function(){var g=this.getValue();if(g===""){this.setValue("_default_")}}})}if(this.adminMode){c.hiddenFieldData=(a.get("type")=="forced")?"0":"1";c.hiddenFieldId=a.get("name")+"_writable";c.disabled=(a.get("personal_only")==="1"||a.get("personal_only")===true)}else{c.disabled=(a.get("type")=="forced")}try{var d=Ext.ComponentMgr.create(c);this.items.push(d);a.fieldObj=d}catch(f){Tine.log.debug(f);Tine.log.err('Unable to create preference field "'+a.get("name")+'". Check definition!');this.prefStore.remove(a)}},this)}else{this.html='<div class="x-grid-empty">'+_("There are no preferences for this application.")+"</div>"}Ext.QuickTips.init();Tine.widgets.dialog.PreferencesPanel.superclass.initComponent.call(this)},afterRender:function(){Tine.widgets.dialog.PreferencesPanel.superclass.afterRender.call(this);var d=Tine.Tinebase.appMgr.get(this.appName),a=d?d.i18n._.createDelegate(d.i18n):_;if(this.items&&this.items.items){for(var b=0;b<this.items.items.length;b++){var c=this.items.items[b];Ext.QuickTips.register({target:c,dismissDelay:30000,title:Ext.util.Format.htmlEncode(a(c.fieldLabel)),text:Ext.util.Format.htmlEncode(a(c.description)),width:200})}}},isValid:function(){var c=true;if(this.items&&this.items.items){var b;for(var a=0;a<this.items.items.length;a++){b=this.items.items[a];if(!b.isValid()){b.markInvalid();c=false}}}return c}});Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.ImportDialog=Ext.extend(Tine.widgets.dialog.WizardPanel,{appName:null,modelName:null,defaultImportContainer:null,allowedFileExtensions:null,recordClass:null,definitionsStore:null,selectedDefinition:null,exceptionStore:null,lastImportResponse:null,windowNamePrefix:"ImportWindow_",initComponent:function(){Tine.log.debug("Tine.widgets.dialog.ImportDialog::initComponent this");Tine.log.debug(this);this.app=Tine.Tinebase.appMgr.get(this.appName);this.recordClass=Tine.Tinebase.data.RecordMgr.get(this.appName,this.modelName);this.allowedFileExtensions=[];this.definitionsStore=new Ext.data.JsonStore({fields:Tine.Tinebase.Model.ImportExportDefinition,root:"results",totalProperty:"totalcount",remoteSort:false});if(Tine[this.appName].registry.get("importDefinitions")){Ext.each(Tine[this.appName].registry.get("importDefinitions").results,function(b){var a=b.plugin_options,c=a?a.extension:null;b.label=this.app.i18n._hidden(a&&a.label?a.label:b.name);if(this.allowedFileExtensions.indexOf(c)==-1){this.allowedFileExtensions=this.allowedFileExtensions.concat(c)}this.definitionsStore.addSorted(new Tine.Tinebase.Model.ImportExportDefinition(b,b.id))},this);this.definitionsStore.sort("label")}if(!this.selectedDefinition&&Tine[this.appName].registry.get("defaultImportDefinition")){this.selectedDefinition=this.definitionsStore.getById(Tine[this.appName].registry.get("defaultImportDefinition").id)}this.exceptionStore=new Ext.data.JsonStore({mode:"local",idProperty:"index",fields:["index","code","message","exception","resolveStrategy","resolvedRecord","isResolved"]});this.items=[this.getFilePanel(),this.getOptionsPanel(),this.getConflictsPanel(),this.getSummaryPanel()];Tine.widgets.dialog.ImportDialog.superclass.initComponent.call(this)},onCancelButton:function(){this.fireEvent("cancel",this,this.layout.activeItem);this.window.close()},doImport:function(c,a,b){Ext.Ajax.request({scope:this,timeout:1800000,callback:this.onImportResponse.createDelegate(this,[c],true),params:{method:this.appName+".import"+this.recordClass.getMeta("recordsName"),tempFileId:this.uploadButton.getTempFileId(),definitionId:this.definitionCombo.getValue(),importOptions:Ext.apply({container_id:this.containerCombo.getValue(),autotags:this.tagsPanel.getFormField().getValue()},a||{}),clientRecordData:b}})},onImportResponse:function(b,c,a,d){a=Ext.util.JSON.decode(a.responseText);Tine.log.debug("Tine.widgets.dialog.ImportDialog::onImportResponse server response");Tine.log.debug(a);this.lastImportResponse=a;this.exceptionStore.loadData(a.exceptions);this.exceptionStore.filterBy(this.exceptionStoreFilter,this);if(this.exceptionStore.getCount()){this.loadConflict(0)}if(Ext.isFunction(d)){d.call(this,b,c,a)}},exceptionStoreFilter:function(a,b){return a.get("code")==629&&!a.get("isResolved")},getFilePanel:function(){if(this.filePanel){return this.filePanel}var d=this.selectedDefinition,c=d?d.get("description"):"",b=d?d.get("plugin_options"):null,a=b&&b.example?b.example:"";return{title:_("Choose File and Format"),layout:"vbox",border:false,xtype:"ux.displaypanel",frame:true,ref:"../filePanel",items:[{xtype:"panel",baseCls:"ux-subformpanel",title:_("Choose Import File"),height:100,items:[{xtype:"label",html:"<p>"+_("Please choose the file that contains the records you want to add to Tine 2.0").replace(/Tine 2\.0/g,Tine.title)+"</p><br />"},{xtype:"tw.uploadbutton",ref:"../../uploadButton",text:String.format(_("Select file containing your {0}"),this.recordClass.getRecordsName()),handler:this.onFileReady,allowedTypes:this.allowedFileExtensions,scope:this}]},{xtype:"panel",baseCls:"ux-subformpanel",title:_("What should the file you upload look like?"),flex:1,items:[{xtype:"label",html:"<p>"+_("Tine 2.0 does not understand all kind of files you might want to upload. You will have to manually adjust your file so Tine 2.0 can handle it.").replace(/Tine 2\.0/g,Tine.title)+"</p><br />"},{xtype:"label",html:"<p>"+_("Following you find a list of all supported import formats and a sample file, how Tine 2.0 expects your file to look like.").replace(/Tine 2\.0/g,Tine.title)+"</p><br />"},{xtype:"label",html:"<p>"+_("Please select the import format of the file you want to upload").replace(/Tine 2\.0/g,Tine.title)+"</p>"},{xtype:"combo",ref:"../../definitionCombo",store:this.definitionsStore,displayField:"label",valueField:"id",mode:"local",triggerAction:"all",editable:false,allowBlank:false,forceSelection:true,width:400,value:this.selectedDefinition?this.selectedDefinition.id:null,listeners:{scope:this,select:this.onDefinitionSelect}},{xtype:"label",ref:"../../exampleLink",html:a?('<p><a href="'+a+'">'+_("Download example file")+"</a></p>"):"<p>&nbsp;</p>"},{xtype:"displayfield",ref:"../../definitionDescription",height:70,value:c,cls:"x-ux-display-background-border",style:"padding-left: 5px;"}]}],nextIsAllowed:(function(){return this.definitionCombo&&this.definitionCombo.getValue()&&this.uploadButton&&this.uploadButton.fileRecord}).createDelegate(this)}},onFileReady:function(){this.manageButtons()},onDefinitionSelect:function(g,b,d){var f=b.get("description"),c=b.get("plugin_options"),a=c&&c.example?c.example:"";this.selectedDefinition=b;this.definitionDescription.setValue(f);this.exampleLink.setText(a?('<p><a href="'+a+'">'+_("Download example file")+"</a></p>"):"<p>&nbsp;</p>",false);this.manageButtons()},getImportPluginOptions:function(){var a=this.selectedDefinition?this.selectedDefinition.get("plugin_options"):null;return a||{}},getOptionsPanel:function(){if(this.optionsPanel){return this.optionsPanel}return{title:_("Set Import Options"),layout:"fit",border:false,xtype:"form",frame:true,ref:"../optionsPanel",items:[{xtype:"label",html:"<p>"+String.format(_("Select {0} to add you {1} to:"),this.recordClass.getContainerName(),this.recordClass.getRecordsName())+"</p>"},new Tine.widgets.container.selectionComboBox({id:this.app.appName+"EditDialogContainerSelector",width:300,ref:"../containerCombo",stateful:false,containerName:this.recordClass.getContainerName(),containersName:this.recordClass.getContainersName(),appName:this.appName,value:this.defaultImportContainer,requiredGrant:false}),new Tine.widgets.tags.TagPanel({app:this.appName,ref:"../tagsPanel",style:"margin-top: 15px; border: 1px solid silver; border-top: none;",border:true,collapsible:false,height:200})],listeners:{scope:this,show:function(){var b=this.getImportPluginOptions();if(b.autotags){var a=b.autotags;Ext.each([].concat(a),function(c){c.name=this.app.i18n._hidden(c.name);c.description=this.app.i18n._hidden(c.description)},this);this.tagsPanel.getFormField().setValue(a)}this.containerCombo.setValue(b.container_id?b.container_id:this.defaultImportContainer)}},nextIsAllowed:(function(){return this.containerCombo&&this.containerCombo.getValue()}).createDelegate(this),onNextButton:(function(){if(!this.checkMask){this.checkMask=new Ext.LoadMask(this.getEl(),{msg:_("Checking Import")})}this.checkMask.show();this.doImport(function(b,c,a){this.checkMask.hide();if(!a.duplicatecount){this.navigate(+2)}else{this.navigate(+1)}},{dryrun:true})}).createDelegate(this)}},getConflictsPanel:function(){if(this.conflictsPanel){return this.conflictsPanel}return{title:_("Resolve Conflicts"),layout:"vbox",border:false,xtype:"form",frame:true,ref:"../conflictsPanel",items:[{xtype:"paging",ref:"../conflictPagingToolbar",pageSize:1,beforePageText:_("Conflict"),firstText:_("First Conflict"),prevText:_("Previous Conflict"),nextText:_("Next Conflict"),lastText:_("Last Conflict"),store:this.exceptionStore,doLoad:this.loadConflict.createDelegate(this),onLoad:Ext.emptyFn,listeners:{afterrender:function(a){a.refresh.hide()}},items:[this.conflictIndexText=new Ext.Toolbar.TextItem({}),"->",{text:_("Conflict is resolved"),xtype:"splitbutton",scope:this,handler:this.onResolveConflict,menu:[{text:_("Resolve all conflicts"),scope:this,handler:this.onResolveAllConflict}]}]},new Tine.widgets.dialog.DuplicateResolveGridPanel({flex:1,ref:"../duplicateResolveGridPanel",header:false,app:this.app,store:new Tine.widgets.dialog.DuplicateResolveStore({app:this.app,recordClass:this.recordClass})})],listeners:{scope:this,show:function(){if(!this.exceptionStore.isFiltered()){this.exceptionStore.filterBy(this.exceptionStoreFilter,this);this.manageButtons()}}},nextIsAllowed:(function(){var a=true;this.exceptionStore.each(function(b){if(!b.get("isResolved")){a=false;return false}},this);return a}).createDelegate(this)}},onResolveConflict:function(){var c=this.conflictPagingToolbar.cursor,a=this.exceptionStore.getAt(c),b=this.duplicateResolveGridPanel.getStore(),d=b.resolveStrategy,f=b.getResolvedRecord();a.set("resolveStrategy",d);a.set("resolvedRecord",f);a.set("isResolved",true);this.exceptionStore.filterBy(this.exceptionStoreFilter,this);this.manageButtons();this.loadConflict(this.exceptionStore.getCount()>c?c:c-1);if(Ext.isFunction(arguments[0])){return arguments[0].call(this)}},onResolveAllConflict:function(){if(this.exceptionStore.getCount()>0){this.conflictMask.show();this.conflictMask.hidden=false;return this.onResolveConflict.defer(20,this,[this.onResolveAllConflict])}else{this.conflictMask.hide();this.conflictMask.hidden=true}},loadConflict:function(c){if(!this.conflictMask){this.conflictMask=new Ext.LoadMask(this.getEl(),{msg:_("Processing Conflict Data"),hidden:true})}if(this.conflictMask.hidden){this.conflictMask.show();this.conflictMask.hidden=false;return this.loadConflict.defer(200,this,arguments)}var a=this.exceptionStore.getAt(this.conflictPagingToolbar.cursor),f=this.exceptionStore.getAt(c),b=this.duplicateResolveGridPanel.getStore();if(this.conflictPagingToolbar.cursor!=c&&a&&b.getCount()){a.set("resolvedRecord",b.getResolvedRecord());a.set("resolveStrategy",b.resolveStrategy)}if(f){b.loadData(f.get("exception"),f.get("resolveStrategy")||b.resolveStrategy,f.get("resolvedRecord"))}else{b.removeAll();this.duplicateResolveGridPanel.getView().mainBody.update("<br />  "+_("No conflict to resolve"));this.navigate.defer(200,this,[+1])}var g=this.conflictPagingToolbar,d=c+1,h=this.exceptionStore.getCount();g.cursor=c;g.afterTextItem.setText(String.format(g.afterPageText,h));g.inputItem.setValue(d);g.first.setDisabled(d==1);g.prev.setDisabled(d==1);g.next.setDisabled(d==h);g.last.setDisabled(d==h);this.conflictIndexText.setText(f?String.format(_("(This is record {0} in your import file)"),f.get("index")+1):_("No conflict to resolve"));this.conflictMask.hide();this.conflictMask.hidden=true},getSummaryPanel:function(){if(this.summaryPanel){return this.summaryPanel}var a=new Ext.ux.grid.RowExpander({tpl:new Ext.XTemplate("{[this.showClientRecord(values)]}",{showClientRecord:function(b){if(b&&b.exception&&b.exception.clientRecord){return Ext.util.Format.htmlEncode(Ext.encode(b.exception.clientRecord))}else{return _("No Detail Informations")}}})});return{title:_("Summary"),border:false,xtype:"ux.displaypanel",frame:true,ref:"../summaryPanel",autoScroll:true,items:[{height:100,ref:"../summaryPanelInfo",border:false,layout:"ux.display",layoutConfig:{background:"border"}},{ref:"../summaryPanelFailures",baseCls:"ux-arrowcollapse",cls:"ux-arrowcollapse-plain",collapsible:true,hidden:true,flex:1,title:"",items:[{xtype:"grid",store:this.exceptionStore,autoHeight:true,plugins:a,columns:[a,{id:"index",header:_("Index"),width:60,sortable:false,dataIndex:"index"},{id:"failure",header:_("Failure"),width:60,sortable:false,dataIndex:"message"}],autoExpandColumn:"failure"}]}],listeners:{scope:this,show:this.onSummaryPanelShow},onFinishButton:(function(){if(!this.importMask){this.importMask=new Ext.LoadMask(this.getEl(),{msg:String.format(_("Importing {0}"),this.recordClass.getRecordsName())})}this.importMask.show();var c=[];var b={};this.exceptionStore.clearFilter(true);this.exceptionStore.each(function(d){c.push({recordData:d.get("resolvedRecord").data,resolveStrategy:d.get("resolveStrategy")||"discard",index:d.get("index")})});this.doImport(function(f,g,d){this.importMask.hide();this.fireEvent("finish",this,this.layout.activeItem);if(Ext.isArray(d.exceptions)&&d.exceptions.length>0){this.backButton.setDisabled(true);this.finishButton.setHandler(function(){this.window.close()},this);this.summaryPanelInfo.hide();this.exceptionStore.clearFilter(true);this.summaryPanelFailures.show();this.summaryPanelFailures.setTitle(String.format(_("{0} records had failures and where discarded."),d.exceptions.length))}else{this.window.close()}},b,c)}).createDelegate(this)}},onSummaryPanelShow:function(){if(!this.summaryPanelInfo.rendered){return this.onSummaryPanelShow.defer(100,this)}var k=this.lastImportResponse,b=k.totalcount,f=0,g=0,h=0;this.exceptionStore.clearFilter();this.exceptionStore.each(function(m){var o=m.get("resolveStrategy");if(!o||!Ext.isString(o)){f++}else{if(o=="keep"){b++}else{if(o.match(/^merge.*/)){g++}else{if(o=="discard"){h++}}}}},this);var l=this.tagsPanel.getFormField().getValue(),a=this.containerCombo.selectedContainer,d=[String.format(_("In total we found {0} records in your import file."),k.totalcount+k.duplicatecount+k.failcount)];if(b){d.push(String.format(_('{0} of them will be added as new records into: "{1}".'),b,Tine.Tinebase.common.containerRenderer(a).replace("<div","<span").replace("</div>","</span>")))}if(g+h){d.push(String.format(_("{0} of them where identified as duplicates."),g+h));if(g){d.push(String.format(_("From the identified duplicates {0} will be merged into the existing records."),g))}if(h){d.push(String.format(_("From the identified duplicates {0} will be discarded."),h))}}if(Ext.isArray(l)&&l.length){var j=[],c=null;Ext.each(l,function(m){if(Ext.isString(m)){c=this.tagsPanel.recordTagsStore.getById(m);m=(c)?c.data:null}if(m){j.push(m.name)}},this);d.push(String.format(_('All records will be tagged with: "{0}" so you can find them easily.'),j.join(", ")))}this.summaryPanelInfo.update('<div style="padding: 5px;">'+d.join("<br />")+"</div>");if(f){this.exceptionStore.filterBy(function(m,o){return !(m.get("code")==629&&!m.get("isResolved"))});this.summaryPanelFailures.show();this.summaryPanelFailures.setTitle(String.format(_("{0} records have failures and will be discarded."),f))}}});Tine.widgets.dialog.ImportDialog.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:800,height:600,name:Tine.widgets.dialog.ImportDialog.windowNamePrefix+Ext.id(),contentPanelConstructor:"Tine.widgets.dialog.ImportDialog",contentPanelConstructorConfig:a});return b};Ext.ns("Tine.widgets","Tine.widgets.dialog");Tine.widgets.dialog.ExportDialog=Ext.extend(Tine.widgets.dialog.EditDialog,{appName:null,windowNamePrefix:"ExportWindow_",loadRecord:false,tbarItems:[],evalGrants:false,sendRequest:true,mode:"local",initComponent:function(){this.app=Tine.Tinebase.appMgr.get(this.appName);this.recordClass=Tine.Tinebase.Model.ExportJob;this.saveAndCloseButtonText=_("Export");this.definitionsStore=new Ext.data.JsonStore({fields:Tine.Tinebase.Model.ImportExportDefinition,root:"results",totalProperty:"totalcount",idProperty:"id",remoteSort:false});if(Tine[this.appName].registry.get("exportDefinitions")){Ext.each(Tine[this.appName].registry.get("exportDefinitions").results,function(b){var a=b.plugin_options,c=a?a.extension:null;b.label=this.app.i18n._hidden(a&&a.label?a.label:b.name);this.definitionsStore.addSorted(new Tine.Tinebase.Model.ImportExportDefinition(b,b.id))},this);this.definitionsStore.sort("label")}Tine.widgets.dialog.ExportDialog.superclass.initComponent.call(this)},onRecordLoad:function(){if(!this.rendered){this.onRecordLoad.defer(250,this);return}this.window.setTitle(String.format(_("Export {0} {1}"),this.record.get("count"),this.record.get("recordsName")))},getFormItems:function(){if(this.record){this.definitionsStore.each(function(a){if(a.get("model")!==this.record.get("model")){this.definitionsStore.remove(a)}},this)}return{bodyStyle:"padding:5px;",buttonAlign:"right",labelAlign:"top",border:false,layout:"form",defaults:{anchor:"100%"},items:[{xtype:"combo",fieldLabel:_("Export definition"),name:"export_definition_id",store:this.definitionsStore,displayField:"label",mode:"local",triggerAction:"all",editable:false,allowBlank:false,forceSelection:true,emptyText:_("Select Export Definition ..."),valueField:"id",value:(this.definitionsStore.getCount()>0)?this.definitionsStore.getAt(0).id:null}]}},onApplyChanges:function(b){var a=this.getForm();if(a.isValid()){this.onRecordUpdate();var c=new Ext.ux.file.Download({params:{method:this.record.get("exportFunction"),requestType:"HTTP",filter:Ext.util.JSON.encode(this.record.get("filter")),options:Ext.util.JSON.encode({definitionId:this.record.get("export_definition_id")})}}).start();this.window.close()}else{Ext.MessageBox.alert(_("Errors"),_("Please fix the errors noted."))}}});Tine.widgets.dialog.ExportDialog.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:400,height:150,name:Tine.widgets.dialog.ExportDialog.windowNamePrefix+Ext.id(),contentPanelConstructor:"Tine.widgets.dialog.ExportDialog",contentPanelConstructorConfig:a,modal:true});return b};Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.MultiOptionsDialog=function(a){Tine.widgets.dialog.MultiOptionsDialog.superclass.constructor.call(this,a);this.options=a.options||{};this.scope=a.scope||window};Ext.extend(Tine.widgets.dialog.MultiOptionsDialog,Ext.FormPanel,{options:null,scope:null,questionText:null,invalidText:null,handler:Ext.emptyFn,allowCancel:false,windowNamePrefix:"MultiOptionsDialog",bodyStyle:"padding:5px",layout:"fit",border:false,cls:"tw-editdialog",anchor:"100% 100%",deferredRender:false,buttonAlign:null,bufferResize:500,initComponent:function(){this.initButtons();this.itemsName=this.id+"-radioItems";this.items=[{layout:"hbox",border:false,layoutConfig:{align:"stretch"},items:[{border:false,html:'<div class="x-window-dlg"><div class="ext-mb-icon ext-mb-question"></div></div>',flex:0,width:45},{border:false,layout:"fit",flex:1,autoScroll:true,items:[{xtype:"label",border:false,cls:"ext-mb-text",html:this.questionText||_("What would you like to do?")},{xtype:"radiogroup",hideLabel:true,itemCls:"x-check-group-alt",columns:1,name:"optionGroup",items:this.getItems()}]}]}];this.supr().initComponent.call(this)},initButtons:function(){this.fbar=["->",{xtype:"button",text:_("Ok"),minWidth:70,scope:this,handler:this.onOk,iconCls:"action_saveAndClose"},{xtype:"button",text:_("Cancel"),minWidth:70,scope:this,hidden:!this.allowCancel,handler:this.onCancel,iconCls:"action_cancel"}]},getItems:function(){var a=[];Ext.each(this.options,function(b){a.push({checked:!!b.checked,fieldLabel:"",labelSeparator:"",boxLabel:b.text,name:this.itemsName,inputValue:b.name})},this);return a},onOk:function(){var c=this.getForm().findField("optionGroup");var b=c.getValue();var a=b?b.getGroupValue():null;if(!a){c.markInvalid(this.invalidText||_("You need to select an option!"));return}this.handler.call(this.scope,a);this.window.close()},onCancel:function(){this.handler.call(this.scope,"cancel");this.window.close()}});Tine.widgets.dialog.MultiOptionsDialog.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:a.width||400,height:a.height||150,closable:false,name:Tine.widgets.dialog.MultiOptionsDialog.windowNamePrefix+Ext.id(),contentPanelConstructor:"Tine.widgets.dialog.MultiOptionsDialog",contentPanelConstructorConfig:a,modal:true});return b};Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.FileListDialog=function(a){Tine.widgets.dialog.FileListDialog.superclass.constructor.call(this,a);this.options=a.options||{};this.scope=a.scope||window};Ext.extend(Tine.widgets.dialog.FileListDialog,Ext.FormPanel,{options:null,scope:null,questionText:null,invalidText:null,handler:Ext.emptyFn,allowCancel:false,windowNamePrefix:"FileListDialog",bodyStyle:"padding:5px",layout:"fit",border:false,cls:"tw-editdialog",anchor:"100% 100%",deferredRender:false,buttonAlign:null,bufferResize:500,initComponent:function(){this.initButtons();this.itemsName=this.id+"-fileList";this.items=[{layout:"hbox",border:false,layoutConfig:{align:"stretch"},items:[{border:false,layout:"fit",flex:1,autoScroll:true,items:[{xtype:"label",border:false,cls:"ext-mb-text",html:this.text}]}]}];this.supr().initComponent.call(this)},initButtons:function(){this.fbar=["->",{xtype:"button",text:_("No"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_cancel"},{xtype:"button",text:_("Yes"),minWidth:70,scope:this,handler:this.onOk,iconCls:"action_applyChanges"}]},onOk:function(){this.handler.call(this.scope,"yes");this.window.close()},onCancel:function(){this.handler.call(this.scope,"no");this.window.close()}});Tine.widgets.dialog.FileListDialog.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:a.width||400,height:a.height||150,closable:false,name:Tine.widgets.dialog.FileListDialog.windowNamePrefix+Ext.id(),contentPanelConstructor:"Tine.widgets.dialog.FileListDialog",contentPanelConstructorConfig:a,modal:true});return b};Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.DuplicateMergeDialog=Ext.extend(Ext.FormPanel,{appName:null,app:null,modelName:null,recordClass:null,recordProxy:null,loadMask:null,layout:"fit",border:false,cls:"tw-editdialog",labelAlign:"top",anchor:"100% 100%",deferredRender:false,buttonAlign:null,bufferResize:500,initComponent:function(){if(!this.app){this.app=Tine.Tinebase.appMgr.get(this.appName)}this.recordClass=Tine.Tinebase.data.RecordMgr.get(this.appName,this.modelName);this.selections=Ext.decode(this.selections);this.records=[];this.recordProxy=Tine[this.appName][this.recordClass.getMeta("recordName").toLowerCase()+"Backend"];if(!this.recordProxy){return}Ext.each(this.selections,function(a){this.records.push(this.recordProxy.recordReader({responseText:Ext.encode(a)}))},this);Tine.log.debug("initComponent: appName: ",this.appName);Tine.log.debug("initComponent: app: ",this.app);this.initActions();this.items=this.getFormItems();Tine.widgets.dialog.DuplicateMergeDialog.superclass.initComponent.call(this)},initActions:function(){this.action_cancel=new Ext.Action({text:_("Cancel"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_cancel"});this.action_update=new Ext.Action({text:_("OK"),minWidth:70,scope:this,handler:this.onUpdate,iconCls:"action_saveAndClose"});this.fbar=["->",this.action_cancel,this.action_update]},onUpdate:function(){var c=this.gridPanel.getStore(),b=c.getResolvedRecord(),a=[],f=c.duplicates.concat([c.clientRecord]),d=this.gridPanel.actionCombo.getValue();Tine.log.debug("Tine.widgets.dialog.DuplicateMergeDialog::onUpdate() - strategy:");Tine.log.debug(this.gridPanel.actionCombo.getValue());Tine.log.debug("Tine.widgets.dialog.DuplicateMergeDialog::onUpdate() - allRecords:");Tine.log.debug(f);if(d==="mergeTheirs"){b.id=f[0].id}else{b.id=f[1].id}b.data.id=b.id;Tine.log.debug("Tine.widgets.dialog.DuplicateMergeDialog::onUpdate() - updateRecord:");Tine.log.debug(b);Ext.each(f,function(g){if(g.id!=b.id){a.push(g)}});Tine.log.debug("Tine.widgets.dialog.DuplicateMergeDialog::onUpdate() - removeRecords:");Tine.log.debug(a);this.loadMask=new Ext.LoadMask(this.getEl(),{msg:_("Merging Records...")});this.loadMask.show();this.recordProxy.saveRecord(b,{scope:this,success:function(g){this.removeDuplicates(a)},failure:function(g){this.onFailure("update",g)}})},removeDuplicates:function(a){this.recordProxy.deleteRecords(a,{scope:this,success:function(){this.onSuccess()},failure:function(b){this.onFailure("remove",b)}})},onFailure:function(b,a){if(b=="update"){Tine.Tinebase.ExceptionHandler.handleRequestException(a,function(){if(this.loadMask){this.loadMask.hide()}},this)}else{Ext.MessageBox.alert(_("Merge Failed"),String.format(_("The merge succeeded, but the duplicate {0} could not be deleted."),this.recordClass.getRecordName()),function(){Tine.Tinebase.ExceptionHandler.handleRequestException(a);if(this.loadMask){this.loadMask.hide()}},this)}},getFormItems:function(){return{layout:"border",items:[{region:"center",layout:"fit",items:[new Tine.widgets.dialog.DuplicateResolveGridPanel({ref:"../../gridPanel",app:this.app,recordClass:this.recordClass,store:new Tine.widgets.dialog.DuplicateResolveStore({recordClass:this.recordClass,defaultResolveStrategy:"mergeMine",app:this.app,data:{clientRecord:this.records.shift(),duplicates:this.records},checkEditGrant:Ext.emptyFn}),listeners:{afterrender:function(){var a=this.recordClass.getRecordsName(),b=this.recordClass.getRecordName();this.actionCombo.store=new Ext.data.ArrayStore({id:0,fields:["value","text"],data:[["mergeMine",String.format(_("Merge {0}, prefer First"),a)],["mergeTheirs",String.format(_("Merge {0}, prefer Second"),a)]]});this.actionCombo.setWidth(400);this.onStoreLoad();this.setTitle(String.format(_("Merge {0}"),a));this.getColumnModel().setColumnHeader(this.getColumnModel().getIndexById("clientValue"),String.format(_("First {0}"),b));this.getColumnModel().setColumnHeader(this.getColumnModel().getIndexById("value0"),String.format(_("Second {0}"),b));this.getColumnModel().setColumnHeader(this.getColumnModel().getIndexById("finalValue"),String.format(_("Final {0}"),b))}}})]}]}},onSuccess:function(){this.window.fireEvent("contentschange");this.onCancel()},onCancel:function(){this.window.purgeListeners();this.window.close()}});Tine.widgets.dialog.DuplicateMergeDialog.getWindow=function(a){return Tine.WindowFactory.getWindow({width:800,height:600,name:Tine.widgets.dialog.ImportDialog.windowNamePrefix+Ext.id(),contentPanelConstructor:"Tine.widgets.dialog.DuplicateMergeDialog",contentPanelConstructorConfig:a})};Ext.ns("Tine.widgets.dialog");Tine.widgets.dialog.DuplicateResolveGridPanel=Ext.extend(Ext.grid.EditorGridPanel,{app:null,cls:"tw-editdialog",border:false,layout:"fit",enableColumnMove:false,stripeRows:true,trackMouseOver:false,clicksToEdit:1,enableHdMenu:false,viewConfig:{forceFit:true},initComponent:function(){this.title=_("The record you try to add might already exist.");this.view=new Ext.grid.GroupingView({forceFit:true,hideGroupedColumn:true,groupTextTpl:"{group}"});this.initColumnModel();this.initToolbar();this.store.on("load",this.onStoreLoad,this);this.store.on("strategychange",this.onStoreLoad,this);this.on("cellclick",this.onCellClick,this);this.on("afterrender",this.onAfterRender,this);Tine.widgets.dialog.DuplicateResolveGridPanel.superclass.initComponent.call(this)},onAfterRender:function(){this.onStoreLoad()},onCellClick:function(c,h,a,f){var b=this.getColumnModel().getDataIndex(a),d=this.store.getAt(h);if(d&&b&&b.match(/clientValue|value\d+/)){d.set("finalValue",d.get(b));var g=this.getView().getCell(h,this.getColumnModel().getIndexById("finalValue"));if(g){Ext.fly(g).highlight()}}},onStoreLoad:function(){var a=this.store.resolveStrategy;this.actionCombo.setValue(a);this.applyStrategy(a)},onActionSelect:function(c,b,a){var d=b.get("value");this.applyStrategy(d);this.store.applyStrategy(d)},applyStrategy:function(c){var a=this.getColumnModel(),b=this.getView();if(a){a.setHidden(a.getIndexById("clientValue"),c=="discard");a.setHidden(a.getIndexById("finalValue"),c=="keep");if(b&&b.grid){this.getView().refresh()}}},initColumnModel:function(){var a=this.valueRenderer.createDelegate(this);this.cm=new Ext.grid.ColumnModel([{header:_("Field Group"),width:50,sortable:true,dataIndex:"group",id:"group",menuDisabled:true},{header:_("Field Name"),width:50,sortable:true,dataIndex:"i18nFieldName",id:"i18nFieldName",menuDisabled:true},{header:_("My Value"),width:50,resizable:false,dataIndex:"clientValue",id:"clientValue",menuDisabled:true,renderer:a},{header:_("Existing Value"),width:50,resizable:false,dataIndex:"value"+this.store.duplicateIdx,id:"value"+this.store.duplicateIdx,menuDisabled:true,renderer:a},{header:_("Final Value"),width:50,resizable:false,dataIndex:"finalValue",id:"finalValue",menuDisabled:true,renderer:a}])},initToolbar:function(){this.tbar=[{xtype:"label",text:_("Action:")+" "},{xtype:"combo",ref:"../actionCombo",typeAhead:true,width:250,triggerAction:"all",lazyRender:true,mode:"local",valueField:"value",displayField:"text",value:this.store.resolveStrategy,store:new Ext.data.ArrayStore({id:0,fields:["value","text"],data:[["mergeTheirs",_("Merge, keeping existing details")],["mergeMine",_("Merge, keeping my details")],["discard",_("Keep existing record and discard mine")],["keep",_("Keep both records")]]}),listeners:{scope:this,select:this.onActionSelect}}]},valueRenderer:function(h,a,c,f,k,j){var l=c.get("fieldName"),g=this.getColumnModel().getDataIndex(k),d=Tine.widgets.grid.RendererManager.get(this.app,this.store.recordClass,l,Tine.widgets.grid.RendererManager.CATEGORY_GRIDPANEL);if(g&&g.match(/clientValue|value\d+/)&&!this.store.resolveStrategy.match(/(keep|discard)/)){var b=c.get("finalValue")==h?"keep":"discard";a.css="tine-duplicateresolve-"+b+"value"}return d.apply(this,arguments)}});Tine.widgets.dialog.DuplicateResolveModel=Ext.data.Record.create([{name:"fieldName",type:"string"},{name:"fieldDef",type:"fieldDef"},{name:"group",type:"string"},{name:"i18nFieldName",type:"string"},"clientValue","value0","value1","value2","value3","value4","finalValue"]);Tine.widgets.dialog.DuplicateResolveStore=Ext.extend(Ext.data.GroupingStore,{app:null,recordClass:null,recordProxy:null,clientRecord:null,duplicates:null,resolveStrategy:null,defaultResolveStrategy:"mergeTheirs",idProperty:"fieldName",fields:Tine.widgets.dialog.DuplicateResolveModel,groupField:"group",sortInfo:{field:"group",oder:"ASC"},constructor:function(b){var a=b.data;delete b.data;this.reader=new Ext.data.JsonReader({idProperty:this.idProperty,fields:this.fields});Tine.widgets.dialog.DuplicateResolveStore.superclass.constructor.apply(this,arguments);if(!this.recordProxy&&this.recordClass){this.recordProxy=new Tine.Tinebase.data.RecordProxy({recordClass:this.recordClass})}this.duplicateIdx=0;if(a){this.loadData(a)}},loadData:function(g,d,b){this.clientRecord=this.createRecord(g.clientRecord);this.duplicates=g.duplicates;Ext.each([].concat(this.duplicates),function(j,h){this.duplicates[h]=this.createRecord(this.duplicates[h])},this);this.resolveStrategy=d||this.defaultResolveStrategy;if(b){b=this.createRecord(b)}var a=this.recordClass.getFieldDefinitions(),f=Tine.widgets.customfields.ConfigManager.getConfigs(this.app,this.recordClass,true);var c=[];Ext.each(a.concat(f),function(l){if(l.isMetaField||l.omitDuplicateResolving){return}var m=l.name,k=l.uiconfig?l.uiconfig.group:l.group,j={fieldName:m,fieldDef:l,i18nFieldName:l.label?this.app.i18n._hidden(l.label):this.app.i18n._hidden(m),clientValue:Tine.Tinebase.common.assertComparable(this.clientRecord.get(m))};j.group=k?this.app.i18n._hidden(k):j.i18nFieldName;Ext.each([].concat(this.duplicates),function(q,o){j["value"+o]=Tine.Tinebase.common.assertComparable(this.duplicates[o].get(m))},this);var h=new Tine.widgets.dialog.DuplicateResolveModel(j,m);if(b){if(b.modified&&b.modified.hasOwnProperty(m)){h.set("finalValue",b.modified[m])}h.set("finalValue",b.get(m))}c.push(h)},this);this.insert(0,c);if(!b){this.applyStrategy(this.resolveStrategy)}this.sortData();this.fireEvent("load",this)},sortData:function(b,c){c=c||"ASC";var a={};this.each(function(f){var h=f.get("group"),d=String(f.get("clientValue")).replace(/^undefined$|^null$|^\[\]$/,""),g=String(f.get("value"+this.duplicateIdx)).replace(/^undefined$|^null$|^\[\]$/,"");if(!a.hasOwnProperty(h)){a[h]=990}if(d||g){a[h]-=1}if(d!=g){a[h]-=10}},this);this.data.sort("ASC",function(h,f){var g=h.get("group"),k=String(a[g])+g,d=f.get("group"),j=String(a[d])+d;return k>j?1:(k<j?-1:0)})},applyStrategy:function(a){Tine.log.debug("Tine.widgets.dialog.DuplicateResolveStore::applyStrategy() - action: "+a);this.resolveStrategy=a;this.checkEditGrant();this.each(function(c){var f=c.get("value"+this.duplicateIdx),d=c.get("clientValue"),b=this.resolveStrategy==="keep"?"mine":"theirs";if(this.resolveStrategy=="mergeTheirs"&&["","null","undefined","[]"].indexOf(String(f))>-1){b="mine"}if(this.resolveStrategy=="mergeMine"&&["","null","undefined","[]"].indexOf(String(d))<0){b="mine"}if(c.get("fieldName")=="tags"){c.set("finalValue",Tine.Tinebase.common.assertComparable([].concat(this.resolveStrategy!="discard"?d:[]).concat(this.resolveStrategy!="keep"?f:[])))}else{c.set("finalValue",b==="mine"?d:f)}Tine.log.debug("Tine.widgets.dialog.DuplicateResolveStore::applyStrategy() - resolved record field: "+c.get("fieldName"));Tine.log.debug(c)},this);this.commitChanges()},checkEditGrant:function(){var a=!this.recordClass.getMeta("containerProperty")?true:this.duplicates[this.duplicateIdx].get("container_id")?this.duplicates[this.duplicateIdx].get(this.recordClass.getMeta("containerProperty")).account_grants.editGrant:false;if(this.resolveStrategy.match(/^merge/)&&!a){Tine.log.info("Tine.widgets.dialog.DuplicateResolveStore::checkEditGrant() - user has no editGrant, changing strategy to keep");this.resolveStrategy="keep";this.fireEvent("strategychange",this,this.resolveStrategy)}},getResolvedRecord:function(){var a=(this.resolveStrategy=="keep"?this.clientRecord:this.duplicates[this.duplicateIdx]).copy();this.each(function(c){var f=c.get("fieldName"),d=c.get("finalValue"),b=c.modified||{};if(b.hasOwnProperty("finalValue")){Tine.log.debug("Tine.widgets.dialog.DuplicateResolveStore::getResolvedRecord "+f+" changed from "+b.finalValue+" to "+d);a.set(f,Tine.Tinebase.common.assertComparable(b.finalValue))}a.set(f,Tine.Tinebase.common.assertComparable(d))},this);Tine.log.debug("Tine.widgets.dialog.DuplicateResolveStore::getResolvedRecord() resolved record:");Tine.log.debug(a);return a},createRecord:function(a){return Ext.isFunction(a.beginEdit)?a:this.recordProxy.recordReader({responseText:Ext.encode(a)})}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.RendererManager=function(){var a={};return{CATEGORY_GRIDPANEL:"gridPanel",CATEGORY_DISPLAYPANEL:"displayPanel",defaultRenderer:function(b){return b?Ext.util.Format.htmlEncode(b):""},getByFieldname:function(c){var b=null;if(c=="tags"){b=Tine.Tinebase.common.tagsRenderer}else{if(c=="notes"){b=function(d){return d?_("has notes"):""}}else{if(c=="relations"){b=function(d){return d?_("has relations"):""}}else{if(c=="customfields"){}else{if(c=="container_id"){b=Tine.Tinebase.common.containerRenderer}}}}}return b},getByDataType:function(b,d,k){var j=null,g=Tine.Tinebase.data.RecordMgr.get(b,d),h=g?g.getField(k):null,c=h?h.type:"auto";switch(c){case"date":j=Tine.Tinebase.common.dateRenderer;break;case"boolean":j=Tine.Tinebase.common.booleanRenderer;break;case"keyField":var f=h.keyFieldConfigName;j=Tine.Tinebase.widgets.keyfield.Renderer.get(b,f);break;default:j=this.defaultRenderer;break}return j},get:function(b,c,j,f){var b=Ext.isString(b)?b:b.appName,c=Ext.isFunction(c)?c.getMeta("modelName"):c,d=[b,c,j,f].join("_"),h=[b,c,j].join("_");var g=a[d]?a[d]:a[h];if(!g){g=this.getByFieldname(j)}if(!g){g=this.getByDataType(b,c,j)}return g?g:this.defaultRenderer},register:function(b,c,j,g,f){var b=Ext.isString(b)?b:b.appName,c=Ext.isFunction(c)?c.getMeta("modelName"):c,d=[b,c,j,f].join("_"),h=[b,c,j].join("_");a[f?d:h]=g}}}();Ext.ns("Tine.Tinebase.widgets","Tine.widgets.grid");Tine.widgets.grid.DetailsPanel=Ext.extend(Ext.Panel,{defaultHeight:125,grid:null,record:null,defaultInfosPanel:null,singleRecordPanel:null,multiRecordsPanel:null,border:false,autoScroll:true,layout:"card",activeItem:0,getDefaultInfosPanel:function(){if(!this.defaultInfosPanel){this.defaultInfosPanel=new Ext.Panel(this.defaults)}return this.defaultInfosPanel},getSingleRecordPanel:function(){if(!this.singleRecordPanel){this.singleRecordPanel=new Ext.Panel(this.defaults)}return this.singleRecordPanel},getMultiRecordsPanel:function(){if(!this.multiRecordsPanel){this.multiRecordsPanel=new Ext.Panel(this.defaults)}return this.multiRecordsPanel},initComponent:function(){this.items=[this.getDefaultInfosPanel(),this.getSingleRecordPanel(),this.getMultiRecordsPanel()];Ext.each(this.items,function(a){Ext.applyIf(a,{border:false,autoScroll:true,layout:"fit"})},this);Tine.widgets.grid.DetailsPanel.superclass.initComponent.apply(this,arguments)},updateDetails:function(b,a){this.tpl.overwrite(a,b.data)},showDefault:function(a){if(this.defaultTpl){this.defaultTpl.overwrite(a)}},showMulti:function(b,a){if(this.multiTpl){this.multiTpl.overwrite(a)}},doBind:function(a){this.grid=a;a.store.on("load",function(b){this.onDetailsUpdate(a.getSelectionModel())},this)},onDetailsUpdate:function(b){var a=b.getCount();if(a===0||b.isFilterSelect){if(this.layout&&Ext.isFunction(this.layout.setActiveItem)){this.layout.setActiveItem(this.getDefaultInfosPanel())}this.showDefault(this.getDefaultInfosPanel().body);this.record=null}else{if(a===1){this.layout.setActiveItem(this.getSingleRecordPanel());this.record=b.getSelected();this.updateDetails(this.record,this.getSingleRecordPanel().body)}else{if(a>1){this.layout.setActiveItem(this.getMultiRecordsPanel());this.record=b.getSelected();this.showMulti(b,this.getMultiRecordsPanel().body)}}}},getLoadMask:function(){if(!this.loadMask){this.loadMask=new Ext.LoadMask(this.el)}return this.loadMask},wrapPanel:function(b,a){return{layout:"fit",border:false,items:[{layout:"vbox",border:false,layoutConfig:{align:"stretch"},items:[{layout:"hbox",flex:1,border:false,layoutConfig:{padding:"5",align:"stretch"},defaults:{margins:"0 5 0 0"},items:[{flex:2,layout:"ux.display",labelWidth:a,padding:10,layoutConfig:{background:"solid",margins:"0 5 0 0"},items:b}]}]}]}}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterModel=function(a){Ext.apply(this,a);Tine.widgets.grid.FilterModel.superclass.constructor.call(this);this.addEvents("filtertrigger");this.initComponent()};Ext.extend(Tine.widgets.grid.FilterModel,Ext.util.Observable,{label:"",field:"",valueType:"string",defaultValue:null,operators:null,defaultOperator:null,customOperators:null,store:null,displayField:null,valueField:null,filterValueWidth:200,initComponent:function(){this.isFilterModel=true;if(!this.operators){this.operators=[]}if(this.defaultOperator===null){switch(this.valueType){case"date":this.defaultOperator="within";break;case"account":case"group":case"user":case"bool":case"number":case"percentage":case"combo":case"country":this.defaultOperator="equals";break;case"string":default:this.defaultOperator="contains";break}}if(this.defaultValue===null){switch(this.valueType){case"customfield":case"string":this.defaultValue="";break;case"bool":this.defaultValue="1";break;case"percentage":this.defaultValue="0";break;case"date":case"account":case"group":case"user":case"number":case"country":default:break}}},onDestroy:Ext.emptyFn,operatorRenderer:function(c,b){var d=new Ext.data.JsonStore({fields:["operator","label"],data:[{operator:"contains",label:_("contains")},{operator:"regex",label:_("reg. exp.")},{operator:"equals",label:_("is equal to")},{operator:"greater",label:_("is greater than")},{operator:"less",label:_("is less than")},{operator:"not",label:_("is not")},{operator:"in",label:_("one of")},{operator:"notin",label:_("none of")},{operator:"before",label:_("is before")},{operator:"after",label:_("is after")},{operator:"within",label:_("is within")},{operator:"inweek",label:_("is in week no.")},{operator:"startswith",label:_("starts with")},{operator:"endswith",label:_("ends with")},{operator:"definedBy",label:_("defined by")}].concat(this.getCustomOperators()||[]),remoteSort:false,sortInfo:{field:"label",direction:"ASC"}});if(this.operators.length==0){switch(this.valueType){case"string":this.operators.push("contains","equals","startswith","endswith","not","in");break;case"customfield":this.operators.push("contains","equals","startswith","endswith","not");break;case"date":this.operators.push("equals","before","after","within","inweek");break;case"number":case"percentage":this.operators.push("equals","greater","less");break;default:this.operators.push(this.defaultOperator);break}}if(this.operators.length>0){d.each(function(f){if(this.operators.indexOf(f.get("operator"))<0){d.remove(f)}},this)}if(d.getCount()>1){var a=new Ext.form.ComboBox({filter:c,width:80,id:"tw-ftb-frow-operatorcombo-"+c.id,mode:"local",lazyInit:false,emptyText:_("select a operator"),forceSelection:true,typeAhead:true,triggerAction:"all",store:d,displayField:"label",valueField:"operator",value:c.get("operator")?c.get("operator"):this.defaultOperator,tpl:'<tpl for="."><div class="x-combo-list-item tw-ftb-operator-{operator}">{label}</div></tpl>',renderTo:b});a.on("select",function(g,f,h){if(g.value!=g.filter.get("operator")){this.onOperatorChange(g.filter,g.value)}},this);a.on("blur",function(f){if(f.value!=f.filter.get("operator")){this.onOperatorChange(f.filter,f.value)}},this)}else{if(this.operators[0]=="freeform"){var a=new Ext.form.TextField({filter:c,width:100,emptyText:this.emptyTextOperator||"",value:c.get("operator")?c.get("operator"):"",renderTo:b})}else{var a=new Ext.form.Label({filter:c,width:100,style:{margin:"0px 10px"},getValue:function(){return d.getAt(0).get("operator")},text:d.getAt(0).get("label"),renderTo:b,setValue:Ext.emptyFn})}}return a},getCustomOperators:function(){return this.customOperators||[]},onOperatorChange:function(a,b){a.set("operator",b);a.set("value","");if(this.valueType=="date"){switch(b){case"within":a.numberfield.hide();a.datePicker.hide();a.withinCombo.show();a.formFields.value=a.withinCombo;break;case"inweek":a.withinCombo.hide();a.datePicker.hide();a.numberfield.show();a.formFields.value=a.numberfield;break;default:a.withinCombo.hide();a.numberfield.hide();a.datePicker.show();a.formFields.value=a.datePicker}}},valueRenderer:function(c,b){var g,a=this.filterValueWidth,f={filter:c,width:a,id:"tw-ftb-frow-valuefield-"+c.id,renderTo:b,value:c.data.value?c.data.value:this.defaultValue};switch(this.valueType){case"date":g=this.dateValueRenderer(c,b);break;case"percentage":g=new Ext.ux.PercentCombo(Ext.apply(f,{listeners:{specialkey:function(j,h){if(h.getKey()==h.ENTER){this.onFiltertrigger()}},select:this.onFiltertrigger,scope:this}}));break;case"user":g=new Tine.Addressbook.SearchCombo(Ext.apply(f,{listWidth:350,emptyText:_("Search Account ..."),userOnly:true,name:"organizer",nameField:"n_fileas",useAccountRecord:true,listeners:{specialkey:function(j,h){if(h.getKey()==h.ENTER){this.onFiltertrigger()}},select:this.onFiltertrigger,scope:this}}));break;case"bool":g=new Ext.form.ComboBox(Ext.apply(f,{mode:"local",forceSelection:true,triggerAction:"all",store:[[0,Locale.getTranslationData("Question","no").replace(/:.*/,"")],[1,Locale.getTranslationData("Question","yes").replace(/:.*/,"")]],listeners:{specialkey:function(j,h){if(h.getKey()==h.ENTER){this.onFiltertrigger()}},select:this.onFiltertrigger,scope:this}}));break;case"combo":var d=Ext.apply(f,{mode:"local",forceSelection:true,triggerAction:"all",store:this.store,listeners:{specialkey:function(j,h){if(h.getKey()==h.ENTER){this.onFiltertrigger()}},select:this.onFiltertrigger,scope:this}});if(this.displayField!==null&&this.valueField!==null){d.displayField=this.displayField;d.valueField=this.valueField}g=new Ext.form.ComboBox(d);break;case"country":g=new Tine.widgets.CountryCombo(Ext.apply(f,{}));break;case"customfield":case"string":case"number":default:g=new Ext.ux.form.ClearableTextField(Ext.apply(f,{emptyText:this.emptyText,listeners:{scope:this,specialkey:function(j,h){if(h.getKey()==h.ENTER){this.onFiltertrigger()}}}}));break}return g},onValueChange:function(a,b){a.set("value",b)},dateValueRenderer:function(a,b){var c=a.get("operator")?a.get("operator"):this.defaultOperator;var d="datePicker";switch(c){case"within":d="withinCombo";break;case"inweek":d="numberfield";break}var f=[["dayThis",_("today")],["dayLast",_("yesterday")],["weekThis",_("this week")],["weekLast",_("last week")],["weekBeforeLast",_("the week before last")],["monthThis",_("this month")],["monthLast",_("last month")],["quarterThis",_("this quarter")],["quarterLast",_("last quarter")],["yearThis",_("this year")],["yearLast",_("last year")]];var k=[["dayNext",_("tomorrow")],["weekNext",_("next week")],["monthNext",_("next month")],["quarterNext",_("next quarter")],["yearNext",_("next year")]];var g=this.pastOnly?f:k.concat(f);var j="weekThis";if(a.data.value&&a.data.value.toString().match(/^[a-zA-Z]+$/)){j=a.data.value.toString()}else{if(this.defaultValue&&this.defaultValue.toString().match(/^[a-zA-Z]+$/)){j=this.defaultValue.toString()}}a.withinCombo=new Ext.form.ComboBox({hidden:d!="withinCombo",filter:a,width:this.filterValueWidth,value:j,renderTo:b,mode:"local",lazyInit:false,forceSelection:true,typeAhead:true,triggerAction:"all",store:g,listeners:{specialkey:function(m,l){if(l.getKey()==l.ENTER){this.onFiltertrigger()}},select:this.onFiltertrigger,scope:this}});var h="";if(Ext.isDate(a.data.value)){h=a.data.value}else{if(Ext.isDate(Date.parseDate(a.data.value,Date.patterns.ISO8601Long))){h=Date.parseDate(a.data.value,Date.patterns.ISO8601Long)}else{if(Ext.isDate(this.defaultValue)){h=this.defaultValue}}}a.datePicker=new Ext.form.DateField({hidden:d!="datePicker",filter:a,width:this.filterValueWidth,value:h,renderTo:b,listeners:{specialkey:function(m,l){if(l.getKey()==l.ENTER){this.onFiltertrigger()}},select:this.onFiltertrigger,scope:this}});a.numberfield=new Ext.form.NumberField({hidden:d!="numberfield",filter:a,width:this.filterValueWidth,value:h,renderTo:b,minValue:1,maxValue:52,maxLength:2,allowDecimals:false,allowNegative:false,listeners:{scope:this,specialkey:function(m,l){if(l.getKey()==l.ENTER){this.onFiltertrigger()}}}});return a[d]},onFiltertrigger:function(){this.fireEvent("filtertrigger",this)}});Tine.widgets.grid.FilterRegistry=function(){var a={};return{register:function(b,c,f){var d=b+"."+c;if(!a[d]){a[d]=[]}a[d].push(f)},get:function(b,c){if(Ext.isFunction(b.getMeta)){c=b.getMeta("modelName");b=b.getMeta("appName")}var d=b+"."+c;return a[d]||[]}}}();Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterPlugin=function(a){a=a||{};Ext.apply(this,a);this.addEvents("change");Tine.widgets.grid.FilterPlugin.superclass.constructor.call(this)};Ext.extend(Tine.widgets.grid.FilterPlugin,Ext.util.Observable,{grid:null,store:null,xtype:"filterplugin",getValue:Ext.emptyFn,getGridPanel:function(){return this.grid},setValue:Ext.emptyFn,init:function(a){this.grid=a;this.store=a.store;this.doBind()},doBind:function(){this.store.on("beforeload",this.onBeforeLoad,this);this.store.on("load",this.onLoad,this)},onFilterChange:function(){if(this.getGridPanel()&&typeof this.getGridPanel().getView==="function"){this.getGridPanel().getView().isPagingRefresh=true}if(this.store){this.store.load({})}this.fireEvent("change",this)},onBeforeLoad:function(a,b){b=b||{};b.params=b.params||{};b.params.filter=b.params.filter?b.params.filter:[];var d=this.getValue();if(d&&Ext.isArray(b.params.filter)){d=Ext.isArray(d)?d:[d];for(var c=0;c<d.length;c++){b.params.filter.push(d[c])}}},onLoad:function(a,b){if(Ext.isArray(a.proxy.jsonReader.jsonData.filter)){this.setValue(a.proxy.jsonReader.jsonData.filter)}}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterButton=function(a){a=a||{};Ext.apply(this,a);Tine.widgets.grid.FilterButton.superclass.constructor.call(this);Ext.applyIf(this,new Tine.widgets.grid.FilterPlugin())};Ext.extend(Tine.widgets.grid.FilterButton,Ext.Button,{field:null,operator:"equals",invert:false,enableToggle:true,getValue:function(){return{field:this.field,operator:this.operator,value:this.invert?!this.pressed:this.pressed}},setValue:function(b){for(var a=0;a<b.length;a++){if(b[a].field==this.field){this.toggle(this.invert?!b[a].value:!!b[a].value);break}}},handler:function(){this.onFilterChange()}});Ext.reg("wdgt.filterbutton",Tine.widgets.grid.FilterButton);Ext.ns("Tine.widgets.grid");Tine.widgets.grid.ExportButton=function(a){a=a||{};Ext.apply(this,a);a.handler=this.doExport.createDelegate(this);Tine.widgets.grid.ExportButton.superclass.constructor.call(this,a)};Ext.extend(Tine.widgets.grid.ExportButton,Ext.Action,{iconCls:"action_export",format:"csv",exportFunction:null,sm:null,gridPanel:null,showExportDialog:false,doExport:function(){if(!this.sm){this.sm=this.gridPanel.grid.getSelectionModel()}if(this.sm.getCount()===0){return false}var c=this.sm.getSelectionFilter();if(this.showExportDialog){var a=this.gridPanel.recordClass,b=a.getMeta("appName")+"_Model_"+a.getMeta("modelName");Tine.widgets.dialog.ExportDialog.openWindow({appName:this.gridPanel.app.appName,record:new Tine.Tinebase.Model.ExportJob({filter:c,format:this.format,exportFunction:this.exportFunction,count:this.sm.getCount(),recordsName:this.gridPanel.i18nRecordsName,model:b})})}else{this.startDownload(c)}},startDownload:function(a){var b=new Ext.ux.file.Download({params:{method:this.exportFunction,requestType:"HTTP",filter:Ext.util.JSON.encode(a),options:Ext.util.JSON.encode({format:this.format})}}).start()}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterToolbar=function(a){Ext.apply(this,a);Tine.widgets.grid.FilterToolbar.superclass.constructor.call(this);Ext.applyIf(this,new Tine.widgets.grid.FilterPlugin());this.childSheets={}};Tine.widgets.grid.FilterToolbar.FILTERS={};Ext.extend(Tine.widgets.grid.FilterToolbar,Ext.Panel,{filterModels:null,defaultFilter:null,recordClass:null,allowSaving:false,neverAllowSaving:false,showSearchButton:true,filterFieldWidth:240,filterValueWidth:200,rowPrefix:null,childSheets:null,isActive:true,header:false,border:false,monitorResize:true,region:"north",layout:"fit",record:Ext.data.Record.create([{name:"field"},{name:"operator"},{name:"value"}]),frowIdPrefix:"tw-ftb-frowid-",initTemplates:function(){var c=this.templates||{};if(!c.master){c.master=new Ext.Template('<div class="tw-filtertoolbar x-toolbar x-small-editor" hidefocus="true">','<table style="width: auto;" border="0" cellpadding="0" cellspacing="0">',"{tbody}","</table>","</div>")}if(!c.filterrow){c.filterrow=new Ext.Template('<tr id="{id}" class="fw-ftb-frow">','<td class="tw-ftb-frow-pbutton"></td>','<td class="tw-ftb-frow-mbutton"></td>','<td class="tw-ftb-frow-prefix">{prefix}</td>','<td class="tw-ftb-frow-field" width="'+this.filterFieldWidth+'px">{field}</td>','<td class="tw-ftb-frow-operator" width="90px" >{operator}</td>','<td class="tw-ftb-frow-value" width="'+this.filterValueWidth+'px">{value}</td>','<td class="tw-ftb-frow-searchbutton"></td>',"</tr>")}for(var a in c){var b=c[a];if(b&&typeof b.compile=="function"&&!b.compiled){b.disableFormats=true;b.compile()}}this.templates=c},initActions:function(){this.actions={addFilterRow:new Ext.Button({tooltip:_("add new filter"),iconCls:"action_addFilter",scope:this,handler:this.addFilter}),removeAllFilters:new Ext.Button({tooltip:_("reset all filters"),iconCls:"action_delAllFilter",scope:this,handler:this.deleteAllFilters}),startSearch:new Ext.Button({text:_("start search"),iconCls:"action_startFilter",scope:this,handler:function(){this.onFiltertrigger()}}),saveFilter:new Ext.Button({tooltip:_("save as favorite"),iconCls:"action_saveFilter",handler:this.onSaveFilter.createDelegate(this)})};this.action_loadFilter=new Ext.Action({text:_("Load a favorite"),hidden:true,iconCls:"action-tinebase-favorite",scope:this,handler:this.onLoadFilter})},onRender:function(b,a){Tine.widgets.grid.FilterToolbar.superclass.onRender.call(this,b,a);if(!this.app&&this.store){this.app=Tine.Tinebase.appMgr.get(this.store.proxy.recordClass.getMeta("appName"))}if(!this.neverAllowSaving&&this.app&&this.app.getMainScreen()&&typeof this.app.getMainScreen().getWestPanel=="function"&&this.app.getMainScreen().getWestPanel().hasFavoritesPanel){this.allowSaving=true}this.renderTable();this.filterStore.each(function(c){this.renderFilterRow(c)},this);for(action in this.actions){this.actions[action].hidden=true;this.actions[action].render(this.bwrap)}this.searchButtonWrap=this.actions.startSearch.getEl().wrap();this.searchButtonWrap.addClass("x-btn-over");this.onFilterRowsChange();if(!this.parentSheet){this.tbar=new Ext.Toolbar({items:[],hidden:true});this.tbar.render(this.el,0)}this.breadCrumb=new Ext.Action({text:(this.parentSheet?"&gt;&nbsp;&nbsp;&nbsp;":"")+this.title,scope:this,handler:function(){this.setActiveSheet(this)}})},generateTitle:function(){var d=this.id;if(this.recordClass){var c=Tine.Tinebase.appMgr.get(this.recordClass.getMeta("appName")),b=this.recordClass.getMeta("recordName"),a=this.recordClass.getMeta("recordsName");d=c.i18n.n_hidden(b,a,50)}return d},isSaveAllowed:function(){return this.allowSaving},onTitleChange:function(a,b){if(this.breadCrumb){this.breadCrumb.setText((this.parentSheet?"&gt;&nbsp;&nbsp;&nbsp;":"")+b)}},onSaveFilter:function(){this.app.getMainScreen().getWestPanel().getFavoritesPanel().saveFilter()},onLoadFilter:function(){Ext.Msg.alert("sorry","not yet implemented")},renderTable:function(){var b=this.templates;var a="";this.filterStore.each(function(c){a+=b.filterrow.apply({id:this.frowIdPrefix+c.id})},this);this.tableEl=b.master.overwrite(this.bwrap,{tbody:a},true)},renderFilterRow:function(a){a.formFields={};var b=this.getFilterModel(a);if(!b){Tine.log.warn("Tine.widgets.grid.FilterToolbar::renderFilterRow no filterModel found");Tine.log.warn(a);this.filterStore.remove(a);return}var c=this.bwrap.child("tr[id="+this.frowIdPrefix+a.id+"]");a.formFields.field=new Ext.form.ComboBox({filter:a,width:this.filterFieldWidth,minListWidth:240,resizable:true,id:"tw-ftb-frow-fieldcombo-"+a.id,mode:"local",lazyInit:false,emptyText:_("select a field"),forceSelection:true,typeAhead:true,triggerAction:"all",store:this.fieldStore,displayField:"label",valueField:"field",value:b.field,renderTo:c.child("td[class=tw-ftb-frow-field]"),validator:this.validateFilter.createDelegate(this),tpl:'<tpl for="."><div class="x-combo-list-item tw-ftb-field-{field}">{label}</div></tpl>'});a.formFields.field.setValue=a.formFields.field.setValue.createInterceptor(function(){this.fieldStore.clearFilter()},this);a.formFields.field.on("select",function(f,d,g){if(f.value!=f.filter.get("field")){this.onFieldChange(f.filter,f.value)}},this);a.formFields.field.on("blur",function(d){if(d.value!=d.filter.get("field")){this.onFieldChange(d.filter,d.value)}},this);a.formFields.operator=b.operatorRenderer(a,c.child("td[class^=tw-ftb-frow-operator]"));a.formFields.value=b.valueRenderer(a,c.child("td[class^=tw-ftb-frow-value]"));a.deleteRowButton=new Ext.Button({id:"tw-ftb-frow-deletebutton-"+a.id,tooltip:_("Delete this filter"),filter:a,iconCls:"action_delThisFilter",renderTo:c.child("td[class=tw-ftb-frow-mbutton]"),scope:this,handler:function(d){this.deleteFilter(d.filter)}})},validateFilter:function(a){return this.fieldStore.query("label",a).getCount()!=0},arrangeButtons:function(){var b=this.filterStore.getCount();var a=this.filterStore.getAt(0).id;var c=this.filterStore.getAt(b-1).id;this.filterStore.each(function(d){var f=this.bwrap.child("tr[id="+this.frowIdPrefix+d.id+"]");f.child("td[class=tw-ftb-frow-prefix]").dom.innerHTML=_("and");if(d.id==c){f.child("td[class=tw-ftb-frow-pbutton]").insertFirst(this.actions.addFilterRow.getEl());this.actions.addFilterRow.show();f.child("td[class=tw-ftb-frow-searchbutton]").insertFirst(this.searchButtonWrap);if(this.showSearchButton){this.actions.startSearch.show()}this.actions.removeAllFilters.setVisible(b>1);this.actions.saveFilter.setVisible(this.allowSaving&&b>1)}if(d.id==a){f.child("td[class=tw-ftb-frow-prefix]").dom.innerHTML=this.rowPrefix;this.actions.removeAllFilters.getEl().applyStyles("float: left");f.child("td[class=tw-ftb-frow-searchbutton]").insertFirst(this.actions.saveFilter.getEl());f.child("td[class=tw-ftb-frow-searchbutton]").insertFirst(this.actions.removeAllFilters.getEl())}},this)},doLayout:function(){if(typeof this.layout.layout=="function"){Tine.widgets.grid.FilterToolbar.superclass.doLayout.apply(this,arguments)}if(this.rendered){this.arrangeButtons();this.filterStore.each(function(b){for(var a in b.formFields){if(b.formFields[a]&&typeof b.formFields[a].syncSize=="function"){b.formFields[a].setWidth(b.formFields[a].width);if(b.formFields[a].wrap){b.formFields[a].wrap.setWidth(b.formFields[a].width)}b.formFields[a].syncSize()}}},this)}},onFiltertrigger:function(){if(!this.supressEvents){this.onFilterChange()}},onFieldChange:function(d,b){var c=this.getFilterModel(d),l=d.formFields.operator.getValue(),a=d.formFields.value.getValue();var m=d.formFields.value;if(typeof m.selectText!="function"||typeof m.doQuery=="function"){a=""}if(c&&Ext.isFunction(c.onDestroy)){c.onDestroy(d)}d.formFields.operator.removeMode="childsonly";d.formFields.value.removeMode="childsonly";d.formFields.operator.destroy();delete d.formFields.operator;d.formFields.value.destroy();delete d.formFields.value;var j=this.getFilterModel(b);var k=this.bwrap.child("tr[id="+this.frowIdPrefix+d.id+"]");var q=k.child("td[class^=tw-ftb-frow-operator]");var h=k.child("td[class^=tw-ftb-frow-value]");d.set("field",b);d.set("operator","");d.set("value","");d.formFields.operator=j.operatorRenderer(d,q);d.formFields.value=j.valueRenderer(d,h);var m=d.formFields.value;if(a&&typeof m.selectText=="function"&&typeof m.doQuery!="function"){var g=d.formFields.operator;if(typeof g.findRecord=="function"){if(typeof g.setValue=="function"&&g.findRecord(g.valueField,l)){g.setValue(l)}d.formFields.value.setValue(a);d.formFields.value.selectText.defer(50,d.formFields.value)}}},initComponent:function(){this.title=this.generateTitle();this.on("titlechange",this.onTitleChange,this);Tine.widgets.grid.FilterToolbar.superclass.initComponent.call(this);this.on("show",function(){this.doLayout()},this);if(this.rowPrefix===null){this.rowPrefix=_("Show")}this.initTemplates();this.initActions();this.filters=Ext.isArray(this.filters)?this.filters:[];if(this.filters.length<1){this.filters=[{field:this.defaultFilter}]}this.filterStore=new Ext.data.JsonStore({fields:this.record,data:this.filters});this.filterModelMap={};var a=[];if(this.recordClass&&!this.filterModels){this.filterModels=this.recordClass.getFilterModel()}if(this.recordClass){this.filterModels=this.filterModels.concat(Tine.widgets.grid.FilterRegistry.get(this.recordClass));var f=this.createFilterModel({filtertype:"foreignrecord",ownRecordClass:this.recordClass,isGeneric:true});if(f.operatorStore.getCount()>0){this.filterModels.push(f)}this.ownRecordFilterModel=this.createFilterModel({filtertype:"ownrecord",ownRecordClass:this.recordClass});this.filterModels.push(this.ownRecordFilterModel)}for(var c=0;c<this.filterModels.length;c++){var b=this.filterModels[c],d=this.createFilterModel(b);this.filterModelMap[d.field]=d;a.push(d);d.on("filtertrigger",this.onFiltertrigger,this);if(Ext.isFunction(d.getSubFilters)){Ext.each(d.getSubFilters(),function(g){g.superFilter=d;g.field=":"+g.field;this.filterModelMap[g.field]=g;a.push(g);g.on("filtertrigger",this.onFiltertrigger,this)},this)}}this.fieldStore=new Ext.data.JsonStore({fields:["field","label"],data:a,remoteSort:false,sortInfo:{field:"label",direction:"ASC"}})},onFilterRowsChange:function(){if(!this.supressEvents){this.ownerCt.layout.layout()}this.doLayout()},createFilterModel:function(a){if(a&&a.isFilterModel){return a}a.ftb=this;if(a.filtertype){return new Tine.widgets.grid.FilterToolbar.FILTERS[a.filtertype](a)}else{return new Tine.widgets.grid.FilterModel(a)}},getFilterModel:function(a){var b=Ext.isFunction(a.get)?a.get("field"):a;if(!b&&a.data&&a.data.condition){return this.ownRecordFilterModel}return this.filterModelMap[b]},addFilter:function(a){if(!a||arguments[1]){a=new this.record({field:this.defaultFilter})}this.filterStore.add(a);var b=this.templates.filterrow.insertAfter(this.bwrap.child("tr[class=fw-ftb-frow]:last"),{id:"tw-ftb-frowid-"+a.id},true);this.renderFilterRow(a);this.onFilterRowsChange();return a},resetFilter:function(a){},deleteFilter:function(a){var d=this.bwrap.child("tr[id=tw-ftb-frowid-"+a.id+"]");var c=this.filterStore.getCount()==1,b=this.getFilterModel(a);this.filterStore.remove(this.filterStore.getById(a.id));a.formFields.field.destroy();a.formFields.operator.destroy();a.formFields.value.destroy();if(b&&Ext.isFunction(b.onDestroy)){b.onDestroy(a)}if(c){var f=this.addFilter();for(action in this.actions){this.actions[action].hide();this.bwrap.insertFirst(action=="startSearch"?this.searchButtonWrap:this.actions[action].getEl())}}d.remove();this.onFilterRowsChange();if(!this.supressEvents){this.onFiltertrigger()}},deleteAllFilters:function(){this.supressEvents=true;this.filterStore.each(function(a){this.deleteFilter(a)},this);this.supressEvents=false;this.onFiltertrigger();this.onFilterRowsChange()},getValue:function(){var a=[];this.filterStore.each(function(c){var f=this.getFilterModel(c),b=Ext.isFunction(f.getFilterData)?f.getFilterData(c):this.getFilterData(c);if(b.field&&Ext.isString(b.field)&&b.field.match(/:/)){var g=b.field.split(":");if(g[0]=="customfield"){a.push({field:"customfield",operator:b.operator,value:{cfId:g[1],value:b.value}})}else{if(f&&f.superFilter){if(this.parentSheet&&this.parentSheet.recordClass==f.superFilter.foreignRecordClass){a.push(b);return}if(this.filterStore.find("field",f.superFilter.field)<0){var d=this.addFilter(new this.record({field:f.superFilter.field,operator:"definedBy"}));b=this.getFilterData(d);a.push(b)}}}}else{a.push(b)}},this);return a},getFilterData:function(c){var b={};for(var a in c.formFields){b[a]=c.formFields[a].getValue()}c.fields.each(function(f){var d=f.name;if(!b.hasOwnProperty(d)){b[d]=c.get(d)}},this);b.id=c.id;return b},setFilterData:function(a,b){a.beginEdit();Ext.each(["field","operator","value"],function(c){a.set(c,b[c]);if(Ext.isFunction(a.formFields[c].setValue)){a.formFields[c].setValue(b[c])}},this);a.endEdit();return a},setValue:function(f){this.supressEvents=true;var c=[];this.filterStore.each(function(h){c.push(h)},this);var d,g,b;for(var a=0;a<f.length;a++){g=f[a];if(g.value&&g.value.cfId){f[a].field=g.field+":"+g.value.cfId;f[a].value=g.value.value}}for(var a=0;a<f.length;a++){b=null;g=f[a];d=g.condition?this.ownRecordFilterModel:this.filterModelMap[g.field];if(d){if(g.id){b=this.filterStore.getById(g.id)}if(b){Ext.isFunction(d.setFilterData)?d.setFilterData(b,g):this.setFilterData(b,g);c.remove(b)}else{if(!g.implicit){b=new this.record(g,g.id);this.addFilter(b)}}}}Ext.each(c,function(h){this.deleteFilter(h)},this);this.supressEvents=false;this.onFilterRowsChange()},getAllFilterData:function(){this.store.on("beforeload",this.storeOnBeforeload,this);this.store.load();this.store.un("beforeload",this.storeOnBeforeload,this);return this.allFilterData},storeOnBeforeload:function(a,b){this.allFilterData=b.params.filter;this.store.fireEvent("exception");return false},onDestroy:function(){if(this.parentSheet){this.parentSheet.removeFilterSheet(this)}},addFilterSheet:function(a){a.ownerCt=this.ownerCt;a.parentSheet=this;this.childSheets[a.id]=a;a.onFilterChange=this.onFilterChange.createDelegate(this)},removeFilterSheet:function(a){if(!this.childSheets[a.id].destroying){this.childSheets[a.id].destroy()}delete this.childSheets[a.id];if(a==this.activeSheet){this.setActiveSheet.defer(100,this,[this])}},setActiveSheet:function(d){var a=Ext.isString(d)?(d=this.id?this:this.childSheets[d]):d,c=this.getRootSheet(),b=d.getParentSheets();if(!a.rendered){a.render(this.el)}this.bwrap[a==this?"show":"hide"]();for(var f in this.childSheets){if(this.childSheets.hasOwnProperty(f)){if(a==this.childSheets[f]){this.childSheets[f].show();this.childSheets[f].setActiveSheet(d)}else{this.childSheets[f].hide()}}}if(a!=c){c.tbar.removeAll();Ext.each(b,function(g){g.breadCrumb.enable();c.tbar.add(g.breadCrumb)},this);a.breadCrumb.disable();c.tbar.add(a.breadCrumb,"->",a.action_loadFilter);c.tbar.show();c.tbar.doLayout()}else{c.tbar.hide()}this.activeSheet=a;this.onFilterRowsChange()},getParentSheets:function(a){a=a||[];if(this.parentSheet){a.unshift(this.parentSheet);return this.parentSheet.getParentSheets(a)}return a},getRootSheet:function(){return this.parentSheet?this.parentSheet.getRootSheet():this}});Ext.reg("tinewidgetsfiltertoolbar",Tine.widgets.grid.FilterToolbar);Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterStructureTreePanel=Ext.extend(Ext.tree.TreePanel,{filterPanel:null,cls:"tw-ftb-filterstructure-treepanel",autoScroll:true,border:false,useArrows:true,collapsible:true,collapsed:true,baseCls:"ux-arrowcollapse",animCollapse:true,titleCollapse:true,rootVisible:false,initComponent:function(){this.title=['<span ext:qtip="',Ext.util.Format.htmlEncode(_("Show records that match to one of the following filters")),'">',Ext.util.Format.htmlEncode(_("or alternatively")),"</span>"].join("");this.root={path:"/",expanded:true,children:[this.createNode(this.filterPanel.activeFilterPanel),{id:"addFilterPanel",text:_("Add alternative filter"),iconCls:"action_add",leaf:true}]};this.contextMenu=new Ext.menu.Menu({items:[{text:_("Remove Filter"),iconCls:"action_remove",scope:this,handler:this.onCtxRemove}]});this.on("click",this.onClick,this);this.on("beforeclick",this.onBeforeClick,this);this.on("contextmenu",this.onContextMenu,this);this.on("checkchange",this.onCheckChange,this);this.on("afterrender",this.onAfterRender,this);this.on("insert",this.onNodeInsert,this);this.on("textchange",this.onNodeTextChange,this);this.on("expandnode",this.filterPanel.manageHeight,this.filterPanel);this.on("collapsenode",this.filterPanel.manageHeight,this.filterPanel);this.on("collapse",this.filterPanel.manageHeight,this.filterPanel);this.on("expand",this.filterPanel.manageHeight,this.filterPanel);this.filterPanel.on("filterpaneladded",this.onFilterPanelAdded,this);this.filterPanel.on("filterpanelremoved",this.onFilterPanelRemoved,this);this.filterPanel.on("filterpanelactivate",this.onFilterPanelActivate,this);this.filterPanel.activeFilterPanel.on("titlechange",this.onFilterPanelTitleChange,this);this.editor=new Ext.tree.TreeEditor(this);Tine.widgets.grid.FilterStructureTreePanel.superclass.initComponent.call(this)},onContextMenu:function(a,b){if(this.getRootNode().childNodes.length>2&&a.id!="addFilterPanel"){this.contextMenu.contextNode=a;this.contextMenu.showAt(b.getXY())}},onCtxRemove:function(){if(this.contextMenu.contextNode){this.filterPanel.removeFilterPanel(this.contextMenu.contextNode.id)}},onAfterRender:function(){this.onFilterPanelActivate(this.filterPanel,this.filterPanel.activeFilterPanel)},onNodeTextChange:function(b,c,a){if(b.attributes&&b.attributes.filterPanel){b.attributes.filterPanel.setTitle(c)}},onNodeInsert:function(a,c,d){var g=Ext.EventObject.getTarget(".x-tree-node-el",10),f=g&&Ext.fly(g,"_treeEvents").getAttribute("tree-node-id","ext")=="addFilterPanel"?true:false,b=this.getRootNode().childNodes.length;if(b>2&&this.collapsed){this.expand()}if(f){this.editor.triggerEdit.defer(100,this.editor,[d])}},onFilterPanelAdded:function(a,b){this.getRootNode().insertBefore(this.createNode(b),this.getNodeById("addFilterPanel"));b.on("titlechange",this.onFilterPanelTitleChange,this)},onFilterPanelRemoved:function(a,b){var c=this.getNodeById(b.id);delete c.filterPanel;if(c){c.remove()}},onFilterPanelActivate:function(a,b){var c=this.getNodeById(b.id);if(c){this.suspendEvents();c.select();this.resumeEvents()}},onFilterPanelTitleChange:function(a,c){var b=this.getNodeById(a.id);if(b){this.suspendEvents();b.setText(c);this.resumeEvents()}},onBeforeClick:function(a){if(a.id=="addFilterPanel"){this.onAddFilterPanel();return false}},onAddFilterPanel:function(){var a=this.filterPanel.addFilterPanel();this.filterPanel.setActiveFilterPanel(a)},onCheckChange:function(b,a){b.attributes.filterPanel.isActive=a},onClick:function(a){if(a.attributes&&a.attributes.filterPanel){this.filterPanel.setActiveFilterPanel(a.attributes.filterPanel)}},createNode:function(a){a.isActive=true;return{checked:true,editable:true,id:a.id,filterPanel:a,leaf:true,text:a.title?a.title:a.id,iconCls:a.app?a.app.getIconCls():"leaf"}}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterPanel=function(a){this.filterToolbarConfig=a;this.criteriaIgnores=a.criteriaIgnores||[{field:"container_id",operator:"equals",value:{path:"/"}},{field:"query",operator:"contains",value:""}];delete this.filterToolbarConfig.plugins;Ext.each(["onFilterChange","getAllFilterData"],function(b){if(a.hasOwnProperty(b)){this[b]=a[b]}},this);Ext.applyIf(this,new Tine.widgets.grid.FilterPlugin());this.filterPanels=[];this.addEvents("filterpaneladded","filterpanelremoved","filterpanelactivate");Tine.widgets.grid.FilterPanel.superclass.constructor.call(this,{})};Ext.extend(Tine.widgets.grid.FilterPanel,Ext.Panel,{quickFilterField:"query",criteriaIgnores:null,moreFiltersActiveText:"Attention: There are more filters active!",activeFilterPanel:null,filterPanels:null,criteriaCount:0,cls:"tw-ftb-filterpanel",layout:"border",border:false,initComponent:function(){var a=this.addFilterPanel();this.activeFilterPanel=a;this.initQuickFilterField();this.items=[{region:"east",width:200,border:false,layout:"fit",split:true,items:[new Tine.widgets.grid.FilterStructureTreePanel({filterPanel:this})]},{region:"center",border:false,layout:"card",activeItem:0,items:[a],autoScroll:false,listeners:{scope:this,afterlayout:this.manageHeight}}];Tine.widgets.grid.FilterPanel.superclass.initComponent.call(this)},isSaveAllowed:function(){return this.activeFilterPanel.allowSaving},getAllFilterData:Tine.widgets.grid.FilterToolbar.prototype.getAllFilterData,storeOnBeforeload:Tine.widgets.grid.FilterToolbar.prototype.storeOnBeforeload,manageHeight:function(){if(this.rendered){var b=this.activeFilterPanel.getHeight(),d=this.layout.north?this.layout.north.panel.getHeight():0,c=this.layout.east&&this.layout.east.panel.getEl().child("ul")?(this.layout.east.panel.getEl().child("ul").getHeight()+28):0,a=Math.min(Math.max(c,b+d),120);this.setHeight(a);if(this.layout.center&&b>120){this.layout.center.panel.el.child('div[class^="x-panel-body"]',true).scrollTop=1000000;this.layout.center.panel.el.child('div[class^="x-panel-body"]',false).applyStyles("overflow-y: auto")}if(this.layout.east&&c>120){this.layout.east.panel.el.child('div[class^="x-panel-body"]',true).scrollTop=1000000}this.ownerCt.layout.layout()}},onAddFilterPanel:function(){var a=this.addFilterPanel();this.setActiveFilterPanel(a)},addFilterPanel:function(a){a=a||{};var b=new Tine.widgets.grid.FilterToolbar(Ext.apply({},this.filterToolbarConfig,a));b.onFilterChange=this.onFilterChange.createDelegate(this);this.filterPanels[b.id]=b;this.criteriaCount++;if(this.criteriaCount>1&&b.title==b.generateTitle()){b.setTitle(b.title+" "+this.criteriaCount)}this.fireEvent("filterpaneladded",this,b);return b},removeFilterPanel:function(a){a=Ext.isString(a)?this.filterPanels[a]:a;if(!this.filterPanels[a.id].destroying){this.filterPanels[a.id].destroy()}delete this.filterPanels[a.id];this.criteriaCount--;this.fireEvent("filterpanelremoved",this,a)},setActiveFilterPanel:function(a){a=Ext.isString(a)?this.filterPanels[a]:a;this.activeFilterPanel=a;this.layout.center.panel.add(a);this.layout.center.panel.layout.setActiveItem(a.id);a.doLayout();if(a.activeSheet){a.setActiveSheet(a.activeSheet)}this.manageHeight.defer(100,this);this.fireEvent("filterpanelactivate",this,a)},initQuickFilterField:function(){var a=!!this.filterToolbarConfig.recordClass;if(a){var b=this.filterToolbarConfig.recordClass.getMeta("appName")+"-"+this.filterToolbarConfig.recordClass.getMeta("recordName")+"-FilterToolbar-QuickfilterPlugin"}this.quickFilter=new Ext.ux.SearchField({width:300,enableKeyEvents:true});this.quickFilter.onTrigger1Click=this.quickFilter.onTrigger1Click.createSequence(this.onQuickFilterClear,this);this.quickFilter.onTrigger2Click=this.quickFilter.onTrigger2Click.createSequence(this.onQuickFilterTrigger,this);this.criteriaText=new Ext.Panel({border:0,html:"",bodyStyle:{border:0,background:"none","text-align":"left","line-height":"11px"}});this.detailsToggleBtn=new Ext.Button({style:{"margin-top":"2px"},enableToggle:true,text:_("show details"),tooltip:_("Always show advanced filters"),scope:this,handler:this.onDetailsToggle,stateful:a,stateId:a?b:null,getState:function(){return{detailsButtonPressed:this.pressed}},applyState:function(c){if(c.detailsButtonPressed){this.toggle(c.detailsButtonPressed)}},stateEvents:["toggle"],listeners:{scope:this,render:function(){this.criteriaText.setWidth(this.quickFilterGroup.getWidth()-this.detailsToggleBtn.getWidth());this.onDetailsToggle(this.detailsToggleBtn)}}})},onQuickFilterClear:function(){this.quickFilter.reset();this.activeFilterPanel.onFiltertrigger.call(this.activeFilterPanel)},onQuickFilterTrigger:function(){this.activeFilterPanel.onFiltertrigger.call(this.activeFilterPanel)},onDetailsToggle:function(a){this[a.pressed?"show":"hide"]();this.quickFilter.setDisabled(a.pressed);this.manageCriteriaText();if(a.pressed){var c=this.quickFilter.getValue(),b;this.quickFilter.setValue("");if(c){this.activeFilterPanel.filterStore.each(function(d){if(d.get("field")==this.quickFilterField&&!d.get("value")){b=d;b.set("value",c);b.formFields.value.setValue(c);return false}},this);if(!b){b=this.activeFilterPanel.addFilter(new this.activeFilterPanel.record({field:this.quickFilterField,value:c}))}}}this.activeFilterPanel.doLayout();this.manageHeight()},manageCriteriaText:function(){var c=false,a=0,b=[];for(var d in this.filterPanels){if(this.filterPanels.hasOwnProperty(d)){a++}}if(!a>1){c=true}else{this.activeFilterPanel.filterStore.each(function(j){var k=this.activeFilterPanel.getFilterData(j);for(var h=0,o,m;h<this.criteriaIgnores.length;h++){o=this.criteriaIgnores[h];m=true;for(var l in o){if(o.hasOwnProperty(l)){if(Ext.isString(o[l])||Ext.isEmpty(k[l])){m&=k.hasOwnProperty(l)&&k[l]===o[l]}else{for(var g in o[l]){if(o[l].hasOwnProperty(g)){m&=k.hasOwnProperty(l)&&typeof k[l].hasOwnProperty=="function"&&k[l].hasOwnProperty(g)&&k[l][g]===o[l][g]}}}}}if(m){return}}if(this.activeFilterPanel.filterModelMap[k.field]){b.push(this.activeFilterPanel.filterModelMap[k.field].label)}else{b.push(k.field)}},this);c=b.length>0}c=this.hidden?c:false;if(this.criteriaText&&this.criteriaText.rendered){this.criteriaText.update(c?_(this.moreFiltersActiveText):"")}},getQuickFilterField:function(){if(!this.quickFilterGroup){this.quickFilterGroup=new Ext.ButtonGroup({columns:1,items:[this.quickFilter,{xtype:"toolbar",style:{border:0,background:"none"},items:[this.criteriaText,"->",this.detailsToggleBtn]}]})}return this.quickFilterGroup},getQuickFilterPlugin:function(){return this},getValue:function(){var c=this.quickFilter.getValue(),a=[];if(c){a.push({field:this.quickFilterField,operator:"contains",value:c,id:"quickFilter"});Ext.each(this.criteriaIgnores,function(h){if(h.field!=this.quickFilterField){var d=this.activeFilterPanel.filterStore.find("field",h.field),f=d>=0?this.activeFilterPanel.filterStore.getAt(d):null,g=f?this.activeFilterPanel.getFilterModel(f):null;if(f){a.push(Ext.isFunction(g.getFilterData)?g.getFilterData(f):this.activeFilterPanel.getFilterData(f))}}},this);return a}for(var b in this.filterPanels){if(this.filterPanels.hasOwnProperty(b)&&this.filterPanels[b].isActive){a.push({condition:"AND",filters:this.filterPanels[b].getValue(),id:b,label:this.filterPanels[b].title})}}return[{condition:"OR",filters:a}]},setValue:function(d){var c=false;Ext.each(d,function(h){if(h.condition&&h.condition=="OR"){d=h.filters;c=true;return false}},this);if(!c){this.activeFilterPanel.setTitle(this.activeFilterPanel.generateTitle());for(var g in this.filterPanels){if(this.filterPanels.hasOwnProperty(g)){if(this.filterPanels[g]!=this.activeFilterPanel){this.removeFilterPanel(this.filterPanels[g])}}}this.activeFilterPanel.setValue(d);var f=this.activeFilterPanel.filterStore.getById("quickFilter");if(f){this.quickFilter.setValue(f.get("value"));this.activeFilterPanel.supressEvents=true;this.activeFilterPanel.deleteFilter(f);this.activeFilterPanel.supressEvents=false}}else{var a=[],b=this.activeFilterPanel;Ext.each(d,function(j){var h;if(j.id&&this.filterPanels.hasOwnProperty(j.id)){h=this.filterPanels[j.id]}else{h=this.addFilterPanel({id:j.id});this.setActiveFilterPanel(h)}h.setValue(j.filters);a.push(h.id);if(j.label){h.setTitle(Ext.util.Format.htmlEncode(j.label))}},this);this.setActiveFilterPanel(a.indexOf(b.id)>0?b:a[0]);for(var g in this.filterPanels){if(this.filterPanels.hasOwnProperty(g)&&a.indexOf(g)<0&&this.filterPanels[g].isActive==true){this.removeFilterPanel(g)}}}this.manageCriteriaText()}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.PickerFilter=Ext.extend(Tine.widgets.grid.FilterModel,{app:null,field:"",defaultOperator:"in",defaultValue:"",label:"",filterValueWidth:200,multiselectFieldConfig:null,picker:null,recordClass:null,initComponent:function(){this.operators=this.operators||["equals","not","in","notin"];if(this.picker===null){this.picker=(this.recordClass==Tine.Addressbook.Model.Contact)?Tine.Addressbook.SearchCombo:Tine.Tinebase.widgets.form.RecordPickerComboBox}this.multiselectFieldConfig=this.multiselectFieldConfig||{selectionWidget:new this.picker({app:this.app,recordClass:this.recordClass,blurOnSelect:true}),recordClass:this.recordClass,isSelectionVisible:function(){return this.selectionWidget.isExpanded()}};Tine.widgets.grid.PickerFilter.superclass.initComponent.call(this)},onOperatorChange:function(d,h,b){var g=d.formFields.operator.getValue(),a=[].concat(d.formFields.value.getValue()),f=d.formFields.value.store,c=Ext.select("tr[id="+this.ftb.frowIdPrefix+d.id+"] td[class^=tw-ftb-frow-value]",this.ftb.el).first();Ext.each(a,function(k,j){try{if(Ext.isPrimitive(k)){a[j]=f.getById(k).data}}catch(l){Tine.log.warn("Tine.widgets.grid.PickerFilter::onOperatorChange could not get record data")}},this);Tine.widgets.grid.PickerFilter.superclass.onOperatorChange.apply(this,arguments);if(d.formFields.value&&Ext.isFunction(d.formFields.value.destroy)){d.formFields.value.removeMode="childsonly";d.formFields.value.destroy();delete d.formFields.value}d.formFields.value=this.valueRenderer(d,c);if(["in","notin"].indexOf(h)>-1){d.formFields.value.setValue(a)}},valueRenderer:function(c,b){if(c.formFields.value){return c.formFields.value}var a=c.get("operator")?c.get("operator"):this.defaultOperator,d;Tine.log.debug("Tine.widgets.grid.PickerFilter::valueRenderer() - Creating new value field for "+a+" operator.");switch(a){case"equals":case"not":d=this.getPicker(c,b);break;default:d=this.getPickerGridLayerCombo(c,b)}d.on("specialkey",function(g,f){if(f.getKey()==f.ENTER){this.onFiltertrigger()}},this);d.on("select",this.onFiltertrigger,this);return d},getPicker:function(c,b){Tine.log.debug("Tine.widgets.grid.PickerFilter::getPicker()");var a=new this.picker({app:this.app,recordClass:this.recordClass,filter:c,blurOnSelect:true,width:this.filterValueWidth,id:"tw-ftb-frow-valuefield-"+c.id,value:c.data.value?c.data.value:this.defaultValue,renderTo:b});return a},getPickerGridLayerCombo:function(b,a){return new Tine.widgets.grid.PickerFilterValueField(Ext.apply({app:this.app,filter:b,width:this.filterValueWidth,id:"tw-ftb-frow-valuefield-"+b.id,value:b.data.value?b.data.value:this.defaultValue,renderTo:a},this.multiselectFieldConfig))}});Tine.widgets.grid.FilterToolbar.FILTERS["tinebase.pickerfilter"]=Tine.widgets.grid.PickerFilter;Tine.widgets.grid.PickerFilterValueField=Ext.extend(Ext.ux.form.LayerCombo,{layerHeight:200,hideButtons:false,formConfig:{labelAlign:"left",labelWidth:30},labelField:"name",recordClass:null,valueStore:null,selectionWidget:null,labelRenderer:Ext.emptyFn,initComponent:function(){this.on("beforecollapse",this.onBeforeCollapse,this);if(!this.store){this.store=new Ext.data.SimpleStore({fields:this.recordClass})}Tine.widgets.grid.PickerFilterValueField.superclass.initComponent.call(this)},getFormValue:function(){var a=[];this.store.each(function(b){a.push(b.data)},this);return a},getItems:function(){var b=this,a=[];this.initSelectionWidget();this.pickerGridPanel=new Tine.widgets.grid.PickerGridPanel({height:this.layerHeight||"auto",recordClass:this.recordClass,store:this.store,autoExpandColumn:this.labelField,getColumnModel:this.getColumnModel.createDelegate(this),initActionsAndToolbars:function(){Tine.widgets.grid.PickerGridPanel.prototype.initActionsAndToolbars.call(this);this.tbar=new Ext.Toolbar({layout:"fit",items:[b.selectionWidget]})}});a.push(this.pickerGridPanel);return a},initSelectionWidget:function(){this.selectionWidget.on("select",this.onRecordSelect,this)},getColumnModel:function(){var a={id:this.labelField,header:String.format(_("Selected  {0}"),this.recordClass.getMeta("recordsName")),dataIndex:this.labelField};if(this.labelRenderer!=Ext.emptyFn){a.renderer=this.labelRenderer}return new Ext.grid.ColumnModel({defaults:{sortable:false},columns:[a]})},onRecordSelect:function(b,a){this.addRecord(a);this.selectionWidget.suspendEvents();this.selectionWidget.clearValue();this.selectionWidget.resumeEvents()},addRecord:function(b){Tine.log.debug("Tine.widgets.grid.PickerFilterValueField::addRecord()");Tine.log.debug(b);var c=(b.data)?b.data:b.attributes?b.attributes:b;var f=this.store.getById(b.id);if(!f){this.store.add(new this.recordClass(c))}else{var a=this.store.indexOf(f);var d=this.pickerGridPanel.getView().getRow(a);Ext.fly(d).highlight()}if(this.selectionWidget.selectPanel){this.selectionWidget.selectPanel.close()}},setValue:function(d){d=Ext.isArray(d)?d:[d];Tine.log.debug("Tine.widgets.grid.PickerFilterValueField::setValue()");Tine.log.debug(d);var b=[];this.currentValue=[];this.store.removeAll();var a,g,f;for(var c=0;c<d.length;c++){f=this.getRecordText(d[c]);if(f&&f!==""){b.push(f)}}this.setRawValue(b.join(", "));return this},getRecordText:function(b){var d=(Ext.isString(b))?b:b.id,a=(this.valueStore)?this.valueStore.getById(d):((!Ext.isString(b))?new this.recordClass(b,d):null);Tine.log.debug("Tine.widgets.grid.PickerFilterValueField::getRecordText()");Tine.log.debug(a);if(!a){return""}this.store.add(a.copy());this.currentValue.push(a.id);var c=a.get(this.labelField);c=(this.labelRenderer!=Ext.emptyFn)?this.labelRenderer(c):c;return c},onBeforeCollapse:function(){var a=true;if(this.pickerGridPanel){var b=this.pickerGridPanel.contextMenu&&!this.pickerGridPanel.contextMenu.hidden,c=this.isSelectionVisible();a=!(b||c)}Tine.log.debug("Tine.widgets.grid.PickerFilterValueField::onBeforeCollapse() - collapse: "+a);return a},isSelectionVisible:function(){return false}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterToolbarQuickFilterPlugin=function(a){a=a||{};this.criteriaIgnores=a.criteriaIgnores||[{field:"container_id",operator:"equals",value:{path:"/"}},{field:"query",operator:"contains",value:""}];Ext.apply(this,a)};Tine.widgets.grid.FilterToolbarQuickFilterPlugin.prototype={quickFilterField:"query",ftb:null,quickFilter:null,quickFilterRow:null,criteriaIgnores:null,bind:function(){this.quickFilterRow.formFields.value.on("keyup",this.syncField,this);this.quickFilterRow.formFields.value.on("change",this.syncField,this)},getQuickFilterField:function(){if(!this.quickFilterGroup){this.quickFilterGroup=new Ext.ButtonGroup({columns:1,items:[this.quickFilter,{xtype:"toolbar",style:{border:0,background:"none"},items:[this.criteriaText,"->",this.detailsToggleBtn]}]})}return this.quickFilterGroup},getQuickFilterPlugin:function(){return this},getQuickFilterRowField:function(){if(!this.quickFilterRow){var a=new this.ftb.record({field:this.quickFilterField,value:this.quickFilter.getValue()});this.ftb.addFilter(a)}return this.quickFilterRow},init:function(a){this.ftb=a;this.ftb.renderFilterRow=this.ftb.renderFilterRow.createSequence(this.onAddFilter,this);this.ftb.onFieldChange=this.ftb.onFieldChange.createSequence(this.onFieldChange,this);this.ftb.deleteFilter=this.ftb.deleteFilter.createInterceptor(this.onBeforeDeleteFilter,this);this.ftb.setValue=this.ftb.setValue.createSequence(this.onSetValue,this);this.ftb.onRender=this.ftb.onRender.createSequence(this.onRender,this);this.ftb.getQuickFilterField=this.getQuickFilterField.createDelegate(this);this.ftb.getQuickFilterPlugin=this.getQuickFilterPlugin.createDelegate(this);this.quickFilter=new Ext.ux.SearchField({width:300,enableKeyEvents:true});this.quickFilter.onTrigger1Click=this.quickFilter.onTrigger1Click.createSequence(this.onQuickFilterClear,this);this.quickFilter.onTrigger2Click=this.quickFilter.onTrigger2Click.createSequence(this.onQuickFilterTrigger,this);this.quickFilter.on("keyup",this.syncField,this);this.quickFilter.on("change",this.syncField,this);this.criteriaText=new Ext.Panel({border:0,html:"",bodyStyle:{border:0,background:"none","text-align":"left","line-height":"11px"}});var b=!!this.ftb.recordClass;if(b){var c=this.ftb.recordClass.getMeta("appName")+"-"+this.ftb.recordClass.getMeta("recordName")+"-FilterToolbar-QuickfilterPlugin"}this.detailsToggleBtn=new Ext.Button({style:{"margin-top":"2px"},enableToggle:true,text:_("show details"),tooltip:_("Always show advanced filters"),scope:this,handler:this.onDetailsToggle,stateful:b,stateId:b?c:null,getState:function(){return{detailsButtonPressed:this.pressed}},applyState:function(d){if(d.detailsButtonPressed){this.toggle(d.detailsButtonPressed)}},stateEvents:["toggle"],listeners:{scope:this,render:function(){this.criteriaText.setWidth(this.quickFilterGroup.getWidth()-this.detailsToggleBtn.getWidth())}}});this.ftb.hide()},onAddFilter:function(a){if(a.get("field")==this.quickFilterField&&!this.quickFilterRow){this.quickFilterRow=a;this.bind();this.syncField(a.formFields.value)}},onDetailsToggle:function(a){this.ftb[a.pressed?"show":"hide"]();this.ftb.onFilterRowsChange()},onFieldChange:function(a,b){if(a==this.quickFilterRow){this.onBeforeDeleteFilter(a)}if(b==this.quickFilterField){this.onAddFilter(a)}},onBeforeDeleteFilter:function(a){if(a==this.quickFilterRow){this.quickFilter.setValue("");this.unbind();delete this.quickFilterRow;this.ftb.filterStore.each(function(b){if(b!=a&&b.get("field")==this.quickFilterField){this.onAddFilter(b);return false}},this)}},onQuickFilterClear:function(){this.ftb.deleteFilter(this.quickFilterRow);this.quickFilter.reset()},onQuickFilterTrigger:function(){this.ftb.onFiltertrigger.call(this.ftb);this.ftb.onFilterRowsChange.call(this.ftb)},onRender:function(){this.onDetailsToggle(this.detailsToggleBtn)},onSetValue:function(a){this.setCriteriaText(a)},setCriteriaText:function(b){var c="",a=[];Ext.each(b,function(h){for(var g=0,l,k;g<this.criteriaIgnores.length;g++){l=this.criteriaIgnores[g];k=true;for(var j in l){if(l.hasOwnProperty(j)){if(Ext.isString(l[j])||Ext.isEmpty(h[j])){k&=h.hasOwnProperty(j)&&h[j]===l[j]}else{for(var d in l[j]){if(l[j].hasOwnProperty(d)){k&=h.hasOwnProperty(j)&&typeof h[j].hasOwnProperty=="function"&&h[j].hasOwnProperty(d)&&h[j][d]===l[j][d]}}}}}if(k){return}}if(this.ftb.filterModelMap[h.field]){a.push(this.ftb.filterModelMap[h.field].label)}else{a.push(h.field)}},this);if(!Ext.isEmpty(a)){c=String.format(Tine.Tinebase.translation.ngettext("Your view is limited by {0} criteria:","Your view is limited by {0} criterias:",a.length),a.length)+"<br />&nbsp;"+a.join(", ")}this.criteriaText.update(c)},syncField:function(a){if(a==this.quickFilter){this.getQuickFilterRowField().formFields.value.setValue(this.quickFilter.getValue())}else{this.quickFilter.setValue(this.quickFilterRow.formFields.value.getValue())}},unbind:function(){this.quickFilterRow.formFields.value.un("keyup",this.syncField,this);this.quickFilterRow.formFields.value.un("change",this.syncField,this)}};Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,{store:null,gridPanel:null,isFilterSelect:false,getSelectionFilter:function(){if(!this.isFilterSelect){var a=this.getFilterOfRowSelection()}else{var a=this.getAllFilterData()}return a},getSelectionsCollection:function(){return this.selections},getCurrentPageIds:function(){var a=[];this.store.each(function(b){a.push(b.id)},this);return a},getAllFilterData:function(){this.store.on("beforeload",this.storeOnBeforeload,this);this.store.load();this.store.un("beforeload",this.storeOnBeforeload,this);return this.allFilterData},storeOnBeforeload:function(a,b){this.allFilterData=b.params.filter;this.store.fireEvent("exception");return false},selectAll:function(a){this.isFilterSelect=!a;Tine.widgets.grid.FilterSelectionModel.superclass.selectAll.call(this)},onRefresh:function(){this.clearSelections(true);Tine.widgets.grid.FilterSelectionModel.superclass.onRefresh.call(this)},onRemove:function(a,b,c){this.clearSelections(true);Tine.widgets.grid.FilterSelectionModel.superclass.onRemove.call(this,a,b,c)},deselectRow:function(b,a){this.isFilterSelect=false;Tine.widgets.grid.FilterSelectionModel.superclass.deselectRow.call(this,b,a)},clearSelections:function(a){this.suspendEvents();this.isFilterSelect=false;Tine.widgets.grid.FilterSelectionModel.superclass.clearSelections.call(this);this.resumeEvents();if(!a){this.fireEvent("selectionchange",this)}},toggleSelection:function(){if(this.isFilterSelect){this.clearSelections()}else{this.suspendEvents();var a;this.store.each(function(b){a=this.store.indexOf(b);if(this.isSelected(a)){this.deselectRow(a)}else{this.selectRow(a,true)}},this);this.resumeEvents();this.fireEvent("selectionchange",this)}},getCount:function(){if(!this.isFilterSelect){return Tine.widgets.grid.FilterSelectionModel.superclass.getCount.call(this)}else{return this.store.getTotalCount()}},getFilterOfRowSelection:function(){var a=this.store.reader.meta.id;var b=[];this.each(function(c){b.push(c.id)});return[{field:a,operator:"in",value:b}]}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.ForeignRecordFilter=Ext.extend(Tine.widgets.grid.FilterModel,{app:null,ownRecordClass:null,foreignRecordClass:null,linkType:"relation",filterName:null,ownField:null,editDefinitionText:"Edit definition",pickerConfig:null,startDefinitionText:"Start definition",isGeneric:false,field:"foreignRecord",ignoreRelatedModels:null,initComponent:function(){if(this.foreignRecordClass){this.foreignRecordClass=Tine.Tinebase.data.RecordMgr.get(this.foreignRecordClass)}this.ignoreRelatedModels=this.ignoreRelatedModels?this.ignoreRelatedModels.push("Filemanager_Model_Node"):["Filemanager_Model_Node"];if(this.ownField){this.field=this.ownField}this["init"+(this.isGeneric?"Generic":"Explicit")]();Tine.widgets.grid.ForeignRecordFilter.superclass.initComponent.call(this)},initGeneric:function(){this.label=_("Related to");var a=[];if(this.ownRecordClass.hasField("relations")){var a=[];Ext.each(Tine.widgets.relation.Manager.get(this.app,this.ownRecordClass,this.ignoreRelatedModels),function(c){if(Tine.Tinebase.common.hasRight("run",c.relatedApp)){var b=c.text.replace(/ \(.+\)/,"");a.push({operator:{linkType:"relation",foreignRecordClass:Tine.Tinebase.common.resolveModel(c.relatedModel,c.relatedApp)},label:b})}},this)}Ext.each(Tine.widgets.grid.ForeignRecordFilter.OperatorRegistry.get(this.ownRecordClass),function(f){var d=Tine.Tinebase.data.RecordMgr.get(f.foreignRecordClass),b=d.getMeta("appName"),g=Tine.Tinebase.appMgr.get(b),c=g?g.i18n._hidden(f.label):f.label;a.push({operator:{linkType:f.linkType,foreignRecordClass:d,filterName:f.filterName},label:c})},this);Ext.each(a,function(b){b.toString=this.objectToString},this);this.operatorStore=new Ext.data.JsonStore({fields:["operator","label"],data:a});if(this.operatorStore.getCount()>0){this.defaultOperator=this.operatorStore.getAt(0).get("operator")}},initExplicit:function(){this.foreignField=this.foreignRecordClass.getMeta("idProperty");var b=Tine.Tinebase.appMgr.get(this.foreignRecordClass.getMeta("appName")),a;if(b){a=b.i18n}else{a=new Locale.Gettext();a.textdomain("Tinebase")}if(!this.label){this.label=a.n_(this.foreignRecordClass.getMeta("recordName"),this.foreignRecordClass.getMeta("recordsName"),1)}else{this.label=a._(this.label)}if(!this.operators){this.operators=["equals","definedBy"]}if(!this.defaultOperator){this.defaultOperator="equals"}},onDefineRelatedRecord:function(a){if(!a.toolbar){this.createRelatedRecordToolbar(a)}this.ftb.setActiveSheet(a.toolbar);a.formFields.value.setText((this.editDefinitionText))},getRelatedRecordValue:function(a){var b=a.toolbar?a.toolbar.getValue():[],d=a.foreignRecordDefinition.foreignRecordClass,c;if(this.isGeneric){c={appName:d.getMeta("appName"),modelName:d.getMeta("modelName"),linkType:a.foreignRecordDefinition.linkType,filterName:a.foreignRecordDefinition.filterName,filters:b}}else{c=b;if(a.get("operator")!="definedBy"){c.push({field:":"+d.getMeta("idProperty"),operator:a.get("operator"),value:a.formFields.value.value})}this.ftb.filterStore.each(function(f){var g=this.ftb.getFilterModel(f);if(g.superFilter&&g.superFilter==this){var h=this.ftb.getFilterData(f);c.push(h)}},this)}return c},setRelatedRecordValue:function(c){var g=c.get("value");if(["equals","oneOf"].indexOf(c.get("operator")?c.get("operator"):c.formFields.operator.origGetValue())>=0){return c.formFields.value.origSetValue(arguments[1]?arguments[1]:g)}if(this.isGeneric){this.operatorStore.each(function(j){var h=j.get("operator"),k=h.foreignRecordClass;if(k.getMeta("appName")==g.appName&&k.getMeta("modelName")==g.modelName){c.formFields.operator.setValue(h);c.foreignRecordDefinition=h;return false}},this);if(Ext.isObject(c.foreignRecordDefinition)&&g&&Ext.isArray(g.filters)&&g.filters.length){if(!c.toolbar){this.createRelatedRecordToolbar(c)}c.toolbar.setValue(g.filters);if(c.formFields.value&&Ext.isFunction(c.formFields.value.setText)){c.formFields.value.setText(_(this.editDefinitionText))}}}else{if(!Ext.isArray(g)){return}var d=c.foreignRecordDefinition,f=d.foreignRecordClass,b=f.getMeta("idProperty"),a=[];Ext.each(g,function(m,j){if(!Ext.isString(m.field)){return}if(m.implicit){a.push(m)}var l=m.field.match(/^(:)?(.*)/),h=!!l[1],k=l[2];if(h){if(k==b){return}if(this.ftb.getFilterModel(m.field)){delete m.id;this.ftb.addFilter(new this.ftb.record(m))}a.push(m)}},this);Ext.each(a,function(h){g.remove(h)},this);if(!g.length){c.set("value","###NOT SET###");c.set("value","");c.formFields.operator.setValue(this.defaultOperator);this.onOperatorChange(c,this.defaultOperator,false);Tine.log.info("hide row -> not yet implemented")}else{if(g.length==1&&[b,":"+b].indexOf(g[0].field)>-1){c.set("value",g[0].value);c.formFields.operator.setValue(g[0].operator);this.onOperatorChange(c,g[0].operator,true)}else{if(!c.toolbar){this.createRelatedRecordToolbar(c)}c.toolbar.setValue(g);c.formFields.operator.setValue("definedBy")}}}},createRelatedRecordToolbar:function(c){var d=c.foreignRecordDefinition,f=d.foreignRecordClass,b=f.getFilterModel(),a=this.ftb;if(!c.toolbar){if(Ext.isFunction(this.getSubFilters)){b=b.concat(this.getSubFilters())}c.toolbar=new Tine.widgets.grid.FilterToolbar({recordClass:f,filterModels:b,defaultFilter:f.getMeta("defaultFilter")?f.getMeta("defaultFilter"):"query"});a.addFilterSheet(c.toolbar);this.ftb.setActiveSheet(c.toolbar);this.ftb.setActiveSheet(this.ftb)}},operatorRenderer:function(c,b){var a;c.set("operator",c.get("operator")?c.get("operator"):this.defaultOperator);if(!this.isGeneric){a=Tine.widgets.grid.ForeignRecordFilter.superclass.operatorRenderer.apply(this,arguments);c.foreignRecordDefinition={linkType:this.linkType,foreignRecordClass:this.foreignRecordClass,filterName:this.filterName}}else{a=new Ext.form.ComboBox({filter:c,width:80,id:"tw-ftb-frow-operatorcombo-"+c.id,mode:"local",lazyInit:false,emptyText:_("select a operator"),forceSelection:true,typeAhead:true,triggerAction:"all",store:this.operatorStore,displayField:"label",valueField:"operator",value:c.get("operator"),renderTo:b});a.on("select",function(f,d,g){if(f.value!=f.filter.get("operator")){this.onOperatorChange(f.filter,f.value)}},this);c.foreignRecordDefinition=c.get("operator")}a.origGetValue=a.getValue.createDelegate(a);a.getValue=function(){return"AND"};return a},onOperatorChange:function(c,d,a){if(this.isGeneric){c.foreignRecordDefinition=d}if(c.get("operator")!=d){if(c.toolbar){c.toolbar.destroy();delete c.toolbar}}c.set("operator",d);if(!a){c.set("value","")}var b=Ext.select("tr[id="+this.ftb.frowIdPrefix+c.id+"] td[class^=tw-ftb-frow-value]",this.ftb.el).first();if(c.formFields.value&&Ext.isFunction(c.formFields.value.destroy)){c.formFields.value.removeMode="childsonly";c.formFields.value.destroy();delete c.formFields.value}c.formFields.value=this.valueRenderer(c,b)},valueRenderer:function(c,b){var a=c.get("operator")?c.get("operator"):this.defaultOperator,d;switch(a){case"equals":d=Tine.widgets.form.RecordPickerManager.get(this.foreignRecordClass.getMeta("appName"),this.foreignRecordClass,Ext.apply({filter:c,blurOnSelect:true,width:this.filterValueWidth,listWidth:500,listAlign:"tr-br",id:"tw-ftb-frow-valuefield-"+c.id,value:c.data.value?c.data.value:this.defaultValue,renderTo:b},this.pickerConfig));d.on("specialkey",function(g,f){if(f.getKey()==f.ENTER){this.onFiltertrigger()}},this);d.origSetValue=d.setValue.createDelegate(d);break;default:this.setRelatedRecordValue(c);if(!c.formFields.value){d=new Ext.Button({text:_(this.startDefinitionText),filter:c,width:this.filterValueWidth,id:"tw-ftb-frow-valuefield-"+c.id,renderTo:b,handler:this.onDefineRelatedRecord.createDelegate(this,[c]),scope:this});b.addClass("x-btn-over");if(c.toolbar){d.setText((this.editDefinitionText))}}else{d=c.formFields.value}break}d.setValue=this.setRelatedRecordValue.createDelegate(this,[c],0);d.getValue=this.getRelatedRecordValue.createDelegate(this,[c]);return d},objectToString:function(){return Ext.encode(this)},onDestroy:function(a){if(a.toolbar){this.ftb.removeFilterSheet(a.toolbar);delete a.toolbar}}});Tine.widgets.grid.ForeignRecordFilter.OperatorRegistry=function(){var a={};return{register:function(b,c,d){var f=b+"."+c;if(!a[f]){a[f]=[]}a[f].push(d)},get:function(b,c){if(Ext.isFunction(b.getMeta)){c=b.getMeta("modelName");b=b.getMeta("appName")}var d=b+"."+c;return a[d]||[]}}}();Tine.widgets.grid.FilterToolbar.FILTERS.foreignrecord=Tine.widgets.grid.ForeignRecordFilter;Tine.widgets.grid.OwnRecordFilter=Ext.extend(Tine.widgets.grid.ForeignRecordFilter,{isGeneric:false,initComponent:function(){this.label=this.ftb.generateTitle();this.field=this.ownRecordClass.getMeta("idProperty");this.defaultOperator="definedBy";this.foreignRecordClass=this.ownRecordClass;Tine.widgets.grid.OwnRecordFilter.superclass.initComponent.call(this)},getFilterData:function(a){var b={field:this.field,id:a.id,label:a.toolbar?a.toolbar.title:null};if(a.get("operator")=="equals"){Ext.apply(b,{operator:"equals",value:a.formFields.value.getValue()[0].value})}else{Ext.apply(b,{condition:a.condition||"AND",filters:this.getRelatedRecordValue(a)})}return b},setFilterData:function(a,b){if(Ext.isObject(b.filters)){b.filters.toString=this.objectToString}if(b.operator=="equals"){b.operator="AND";b.value=[{field:":"+this.field,operator:"equals",value:b.value}];b.value.toString=this.objectToString;a.set("operator","AND");a.set("value",b.value)}else{a.condition=b.condition||"AND"}this.setRelatedRecordValue(a)},setRelatedRecordValue:function(a){if(a.data.filters){a.set("value",a.data.filters);delete a.data.filters}Tine.widgets.grid.OwnRecordFilter.superclass.setRelatedRecordValue.apply(this,arguments)}});Tine.widgets.grid.FilterToolbar.FILTERS.ownrecord=Tine.widgets.grid.OwnRecordFilter;Ext.ns("Tine.widgets.grid");Tine.widgets.grid.QuickaddGridPanel=Ext.extend(Ext.ux.grid.QuickaddGridPanel,{recordClass:null,dataField:null,useBBar:false,clicksToEdit:"auto",frame:true,initComponent:function(){this.initGrid();this.initActions();this.on("rowcontextmenu",this.onRowContextMenu,this);if(!this.store){this.store=new Ext.data.Store({reader:new Ext.data.ArrayReader({idIndex:0},this.recordClass)})}Tine.widgets.grid.QuickaddGridPanel.superclass.initComponent.call(this);this.on("newentry",this.onNewentry,this)},initGrid:function(){this.enableHdMenu=false;this.plugins=this.plugins||[];this.plugins.push(new Ext.ux.grid.GridViewMenuPlugin({}));this.sm=new Ext.grid.RowSelectionModel();this.sm.on("selectionchange",function(b){var a=b.getCount();this.deleteAction.setDisabled(a==0)},this);this.cm=(!this.cm)?this.getColumnModel():this.cm},initActions:function(){this.deleteAction=new Ext.Action({text:_("Remove"),iconCls:"actionDelete",handler:this.onDelete,scope:this,disabled:true});if(this.useBBar){this.bbar=[this.deleteAction]}},getColumnModel:function(){return new Ext.grid.ColumnModel([])},onNewentry:function(b){var a=null;if(Ext.isFunction(this.recordClass.getDefaultData)){a=Ext.apply(this.recordClass.getDefaultData(),b)}else{a=b}var c=new this.recordClass(a,Ext.id());this.store.insert(0,[c]);return true},onDelete:function(){var b=this.getSelectionModel().getSelections();for(var a=0;a<b.length;++a){this.store.remove(b[a])}},onRowContextMenu:function(b,d,c){c.stopEvent();var a=b.getSelectionModel();if(!a.isSelected(d)){this.updateOnSelectionChange=this.updateDetailsPanelOnCtxMenu;a.selectRow(d)}this.getContextMenu().showAt(c.getXY());this.updateOnSelectionChange=true},getContextMenu:function(){if(!this.contextMenu){var a=[this.deleteAction];this.contextMenu=new Ext.menu.Menu({items:a})}return this.contextMenu},getNextId:function(){var a=this.store.getCount()+1;while(this.store.getById(a)){a++}return a},setStoreFromArray:function(c){for(var b=0;b<c.length;++b){if(this.dataField===null){var a=c[b]}else{var a={};a[this.dataField]=c[b]}this.store.insert(0,new this.recordClass(a))}},getFromStoreAsArray:function(){var a=[];this.store.each(function(b){a.push((this.dataField===null)?b.data:b.get(this.dataField))},this);return a}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FileUploadGrid=Ext.extend(Ext.grid.GridPanel,{id:"tinebase-file-grid",filesProperty:"files",header:false,border:false,deferredRender:false,autoExpandColumn:"name",showProgress:true,initComponent:function(){this.record=this.record||null;this.id=this.id+Ext.id();this.actionUpdater=new Tine.widgets.ActionUpdater({containerProperty:"container_id",evalGrants:false});this.initToolbarAndContextMenu();this.initStore();this.initColumnModel();this.initSelectionModel();this.plugins=[new Ext.ux.grid.GridViewMenuPlugin({})];this.enableHdMenu=false;Tine.widgets.grid.FileUploadGrid.superclass.initComponent.call(this);this.on("rowcontextmenu",function(b,d,c){c.stopEvent();var a=b.getSelectionModel();if(!a.isSelected(d)){a.selectRow(d)}this.contextMenu.showAt(c.getXY())},this)},onUploadFail:function(c,b){var a;if(b.html5upload){a=a=Tine.Tinebase.registry.get("maxPostSize")}else{a=Tine.Tinebase.registry.get("maxFileUploadSize")}Ext.MessageBox.alert(_("Upload Failed"),_("Could not upload file. Filesize could be too big. Please notify your Administrator. Max upload size: ")+parseInt(a,10)/1048576+" MB").setIcon(Ext.MessageBox.ERROR);this.getStore().remove(b);if(this.loadMask){this.loadMask.hide()}},onRemove:function(c,d){var f=this.getSelectionModel().getSelections();for(var b=0;b<f.length;b+=1){this.store.remove(f[b]);var a=Tine.Tinebase.uploadManager.getUpload(f[b].get("uploadKey"));a.setPaused(true)}},onPause:function(c,d){var f=this.getSelectionModel().getSelections();for(var b=0;b<f.length;b++){var a=Tine.Tinebase.uploadManager.getUpload(f[b].get("uploadKey"));a.setPaused(true)}this.getSelectionModel().deselectRange(0,this.getSelectionModel().getCount())},onResume:function(c,d){var f=this.getSelectionModel().getSelections();for(var b=0;b<f.length;b++){var a=Tine.Tinebase.uploadManager.getUpload(f[b].get("uploadKey"));a.resumeUpload()}this.getSelectionModel().deselectRange(0,this.getSelectionModel().getCount())},initToolbarAndContextMenu:function(){this.action_add=new Ext.Action(this.getAddAction());this.action_remove=new Ext.Action({text:_("Remove file"),iconCls:"action_remove",scope:this,disabled:true,handler:this.onRemove});this.action_pause=new Ext.Action({text:_("Pause upload"),iconCls:"action_pause",scope:this,handler:this.onPause,actionUpdater:this.isPauseEnabled});this.action_resume=new Ext.Action({text:_("Resume upload"),iconCls:"action_resume",scope:this,handler:this.onResume,actionUpdater:this.isResumeEnabled});this.tbar=[this.action_add,this.action_remove];this.contextMenu=new Ext.menu.Menu({items:[this.action_remove,this.action_pause,this.action_resume]});this.actionUpdater.addActions([this.action_pause,this.action_resume])},initStore:function(){this.store=new Ext.data.SimpleStore({fields:Ext.ux.file.Upload.file});this.loadRecord(this.record)},getAddAction:function(){return{text:_("Add file"),iconCls:"action_add",scope:this,plugins:[{ptype:"ux.browseplugin",multiple:true,dropElSelector:"div[id="+this.id+"]"}],handler:this.onFilesSelect}},loadRecord:function(a){if(a&&a.get(this.filesProperty)){var d=a.get(this.filesProperty);for(var c=0;c<d.length;c+=1){var b=new Ext.ux.file.Upload.file(d[c]);b.data.status="complete";this.store.add(b)}}},initColumnModel:function(){this.cm=new Ext.grid.ColumnModel(this.getColumns())},getColumns:function(){var a=[{resizable:true,id:"name",dataIndex:"name",width:300,header:_("name"),renderer:Ext.ux.PercentRendererWithName},{resizable:true,id:"size",dataIndex:"size",width:70,header:_("size"),renderer:Ext.util.Format.fileSize},{resizable:true,id:"type",dataIndex:"type",width:70,header:_("type")}];return a},initSelectionModel:function(){this.selModel=new Ext.grid.RowSelectionModel({multiSelect:true});this.selModel.on("selectionchange",function(b){var a=b.getCount();this.action_remove.setDisabled(a===0);this.actionUpdater.updateActions(b)},this)},onFilesSelect:function(c,b){var a=c.getFileList();Ext.each(a,function(h){var f=new Ext.ux.file.Upload({file:h,fileSelector:c});var g=Tine.Tinebase.uploadManager.queueUpload(f);var d=Tine.Tinebase.uploadManager.upload(g);f.on("uploadfailure",this.onUploadFail,this);f.on("uploadcomplete",this.onUploadComplete,d);f.on("uploadstart",Tine.Tinebase.uploadManager.onUploadStart,this);if(d.get("status")!=="failure"){this.store.add(d)}},this)},onUploadComplete:function(b,a){a.beginEdit();a.set("status","complete");a.set("progress",100);a.commit(false);Tine.Tinebase.uploadManager.onUploadComplete()},isUploading:function(){var a=this.store.query("status","uploading");return(a.getCount()>0)},isPauseEnabled:function(d,a,b){for(var c=0;c<b.length;c++){if(b[c].get("type")==="folder"){d.hide();return}}for(var c=0;c<b.length;c++){if(!b[c].get("status")||(b[c].get("type ")!=="folder"&&b[c].get("status")!=="paused"&&b[c].get("status")!=="uploading"&&b[c].get("status")!=="pending")){d.hide();return}}d.show();for(var c=0;c<b.length;c++){if(b[c].get("status")){d.setDisabled(false)}else{d.setDisabled(true)}if(b[c].get("status")&&b[c].get("status")!=="uploading"){d.setDisabled(true)}}},isResumeEnabled:function(d,a,b){for(var c=0;c<b.length;c++){if(b[c].get("type")==="folder"){d.hide();return}}for(var c=0;c<b.length;c++){if(!b[c].get("status")||(b[c].get("type ")!=="folder"&&b[c].get("status")!=="uploading"&&b[c].get("status")!=="paused"&&b[c].get("status")!=="pending")){d.hide();return}}d.show();for(var c=0;c<b.length;c++){if(b[c].get("status")){d.setDisabled(false)}else{d.setDisabled(true)}if(b[c].get("status")&&b[c].get("status")!=="paused"){d.setDisabled(true)}}}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.PickerGridPanel=Ext.extend(Ext.grid.EditorGridPanel,{enableBbar:true,enableTbar:true,store:null,recordClass:null,recordDefaults:null,searchRecordClass:null,searchComboClass:null,searchComboConfig:null,selectRowAfterAdd:true,highlightRowAfterAdd:false,contextMenu:null,contextMenuItems:null,configColumns:null,initComponent:function(){this.contextMenuItems=(this.contextMenuItems!==null)?this.contextMenuItems:[];this.configColumns=(this.configColumns!==null)?this.configColumns:[];this.searchComboConfig=this.searchComboConfig||{};this.initStore();this.initActionsAndToolbars();this.initGrid();Tine.widgets.grid.PickerGridPanel.superclass.initComponent.call(this)},initStore:function(){if(this.store===null){this.store=new Ext.data.SimpleStore({fields:this.recordClass})}this.store.on("add",function(b,a,c){(function(){if(this.rendered){if(this.selectRowAfterAdd){this.getView().focusRow(c);this.getSelectionModel().selectRow(c)}else{if(this.highlightRowAfterAdd&&a.length===1){var d=this.getView().getRow(c);Ext.fly(d).highlight()}}}}).defer(300,this)},this)},initActionsAndToolbars:function(){this.actionRemove=new Ext.Action({text:_("Remove record"),disabled:true,scope:this,handler:this.onRemove,iconCls:"action_deleteContact"});var a=[this.actionRemove];this.contextMenu=new Ext.menu.Menu({items:a.concat(this.contextMenuItems)});this.contextMenu.on("hide",function(){if(this.contextMenu.hasOwnProperty("tempItems")&&this.contextMenu.tempItems.length){Ext.each(this.contextMenu.tempItems,function(b){this.contextMenu.remove(b.itemId)},this)}this.contextMenu.tempItems=[]},this);if(this.enableBbar){this.bbar=new Ext.Toolbar({items:[this.actionRemove].concat(this.contextMenuItems)})}if(this.enableTbar){this.initTbar()}},initTbar:function(){this.tbar=new Ext.Toolbar({items:[this.getSearchCombo()],listeners:{scope:this,resize:this.onTbarResize}})},onTbarResize:function(d){if(d.items.getCount()==1){var c=d.items.get(0),b=this.getGridEl().getWidth(),a=c.getEl().getLeft()-this.getGridEl().getLeft();if(d.items.getCount()==1){d.items.get(0).setWidth(b-a)}}},initGrid:function(){this.cm=this.getColumnModel();this.selModel=new Ext.grid.RowSelectionModel({multiSelect:true});var b=[];for(var a=0;a<this.configColumns.length;a++){if(!this.configColumns[a].init||typeof(this.configColumns[a].init)!="function"){b.push(this.configColumns[a])}}for(var a=0;a<b.length;a++){this.configColumns.remove(b[a])}this.plugins=this.configColumns;this.selModel.on("selectionchange",function(d){var c=d.getCount();this.actionRemove.setDisabled(c==0)},this);this.on("rowcontextmenu",this.onRowContextMenu.createDelegate(this),this)},onRowContextMenu:function(b,d,c){c.stopEvent();this.fireEvent("beforecontextmenu",b,d,c);var a=b.getSelectionModel();if(!a.isSelected(d)){a.selectRow(d)}this.contextMenu.showAt(c.getXY())},getSearchCombo:function(){var a=(this.searchComboClass!==null)?this.searchComboClass:Tine.Tinebase.widgets.form.RecordPickerComboBox;return new a(Ext.apply({recordStore:this.store,blurOnSelect:true,recordClass:(this.searchRecordClass!==null)?this.searchRecordClass:this.recordClass,newRecordClass:this.recordClass,newRecordDefaults:this.recordDefaults,emptyText:_("Search for records ..."),onSelect:this.onAddRecordFromCombo},this.searchComboConfig))},onAddRecordFromCombo:function(b){var a=new this.newRecordClass(Ext.applyIf(b.data,this.newRecordDefaults||{}),b.id);if(!this.recordStore.getById(a.id)){this.recordStore.add([a])}this.collapse();this.clearValue();this.reset()},onRemove:function(b,c){var d=this.getSelectionModel().getSelections();for(var a=0;a<d.length;++a){this.store.remove(d[a])}},onKeyDown:function(a){if(a.ctrlKey){switch(a.getKey()){case a.A:this.getSelectionModel().selectAll(true);a.preventDefault();break}}else{switch(a.getKey()){case a.DELETE:this.onRemove();break}}}});Ext.reg("wdgt.pickergrid",Tine.widgets.grid.PickerGridPanel);Ext.ns("Tine.widgets.grid");Tine.widgets.grid.LinkGridPanel=Ext.extend(Tine.widgets.grid.PickerGridPanel,{recordClass:Tine.Tinebase.Model.Relation,autoExpandColumn:"name",enableTbar:true,clicksToEdit:1,selectRowAfterAdd:false,record:null,relationTypesKeyfieldName:null,relationTypes:null,defaultType:"",app:null,typeColumnHeader:null,getColumnModel:function(){this.typeEditor=(this.relationTypesKeyfieldName)?new Tine.Tinebase.widgets.keyfield.ComboBox({app:this.app.appName,keyFieldName:this.relationTypesKeyfieldName}):(this.relationTypes)?new Ext.form.ComboBox({displayField:"label",valueField:"relation_type",mode:"local",triggerAction:"all",lazyInit:false,autoExpand:true,blurOnSelect:true,listClass:"x-combo-list-small",store:new Ext.data.SimpleStore({fields:["label","relation_type"],data:this.relationTypes})}):null;return new Ext.grid.ColumnModel({defaults:{sortable:true},columns:[{id:"name",header:_("Name"),dataIndex:"related_record",renderer:this.relatedRecordRender,scope:this},{id:"type",header:(this.typeColumnHeader)?this.typeColumnHeader:_("Type"),dataIndex:"type",width:100,sortable:true,renderer:(this.relationTypesKeyfieldName)?Tine.Tinebase.widgets.keyfield.Renderer.get(this.app.appName,this.relationTypesKeyfieldName):this.relationTypeRenderer,scope:this,editor:this.typeEditor}].concat(this.configColumns)})},relatedRecordRender:function(b){var a="";if(b){a=Ext.util.Format.htmlEncode(b.get(this.searchRecordClass.getMeta("titleProperty")))}return a},relationTypeRenderer:function(b){var a="";if(b){a=this.app.i18n._(Ext.util.Format.capitalize(b))}return a},onAddRecordFromCombo:function(b){var a=new Tine.Tinebase.Model.Relation(Ext.apply({related_record:new this.newRecordClass(b.data,b.id),related_id:b.id,own_id:(this.record)?this.record.id:null},this.relationDefaults),b.id);Tine.log.debug("Adding new relation:");Tine.log.debug(a);if(this.recordStore.findExact("related_id",b.id)===-1){this.recordStore.add([a])}this.collapse();this.clearValue();this.reset()},onRecordLoad:function(a){if(this.record){return}this.record=a;Tine.log.debug("Loading relations into store...");if(a.get("relations")&&a.get("relations").length>0){var b=[];Ext.each(a.get("relations"),function(c){c.related_record=new this.searchRecordClass(c.related_record,c.related_id);b.push(new Tine.Tinebase.Model.Relation(c,c.id))},this);this.store.add(b)}(function(){this.highlightRowAfterAdd=true}).defer(400,this)},getData:function(){var a=[];this.store.each(function(b){b.data.related_record=b.data.related_record.data;a.push(b.data)},this);return a}});Ext.reg("wdgt.linkgrid",Tine.widgets.grid.LinkGridPanel);Ext.ns("Tine.widgets.grid");Tine.widgets.grid.FilterModelMultiSelect=Ext.extend(Tine.widgets.grid.FilterModel,{app:null,field:"",defaultOperator:"in",defaultValue:"",label:"",filterValueWidth:200,multiselectFieldConfig:null,initComponent:function(){this.operators=this.operators||["in","notin"];this.multiselectFieldConfig=this.multiselectFieldConfig||{};Tine.widgets.grid.FilterModelMultiSelect.superclass.initComponent.call(this)},valueRenderer:function(b,a){var c=new Tine.widgets.grid.FilterModelMultiSelectValueField(Ext.apply({app:this.app,filter:b,width:this.filterValueWidth,id:"tw-ftb-frow-valuefield-"+b.id,value:b.data.value?b.data.value:this.defaultValue,renderTo:a},this.multiselectFieldConfig));c.on("specialkey",function(f,d){if(d.getKey()==d.ENTER){this.onFiltertrigger()}},this);c.on("select",this.onFiltertrigger,this);return c}});Tine.widgets.grid.FilterToolbar.FILTERS["tinebase.multiselect"]=Tine.widgets.grid.FilterModelMultiSelect;Tine.widgets.grid.FilterModelMultiSelectValueField=Ext.extend(Ext.ux.form.LayerCombo,{hideButtons:false,formConfig:{labelAlign:"left",labelWidth:30},labelField:"name",xtype:"checkbox",recordClass:null,valueStore:null,selectionWidget:null,labelRenderer:Ext.emptyFn,initComponent:function(){this.on("beforecollapse",this.onBeforeCollapse,this);if(!this.store){this.store=new Ext.data.SimpleStore({fields:this.recordClass})}Tine.widgets.grid.FilterModelMultiSelectValueField.superclass.initComponent.call(this)},getFormValue:function(){var a=[];if(this.xtype=="checkbox"){var b=this.getInnerForm().getForm().getValues();for(var c in b){if(b[c]==="on"&&this.valueStore.getById(c)){a.push(c)}}}else{this.store.each(function(d){a.push(d.data)},this)}return a},getItems:function(){var a=[];if(this.xtype=="wdgt.pickergrid"){this.initSelectionWidget();selectionWidget=this.selectionWidget;this.pickerGridPanel=new Tine.widgets.grid.PickerGridPanel({height:this.layerHeight||"auto",recordClass:this.recordClass,store:this.store,autoExpandColumn:this.labelField,getColumnModel:this.getColumnModel.createDelegate(this),initActionsAndToolbars:function(){Tine.widgets.grid.PickerGridPanel.prototype.initActionsAndToolbars.call(this);this.tbar=new Ext.Toolbar({layout:"fit",items:[selectionWidget]})}});a.push(this.pickerGridPanel)}else{if(this.xtype=="checkbox"){this.valueStore.each(function(b){a.push({xtype:this.xtype,boxLabel:b.get(this.labelField),name:b.get("id")})},this)}}return a},initSelectionWidget:function(){this.selectionWidget.on("select",this.onRecordSelect,this)},getColumnModel:function(){var a={id:this.labelField,header:String.format(_("Selected  {0}"),this.recordClass.getMeta("recordsName")),dataIndex:this.labelField};if(this.labelRenderer!=Ext.emptyFn){a.renderer=this.labelRenderer}return new Ext.grid.ColumnModel({defaults:{sortable:false},columns:[a]})},onRecordSelect:function(b,a){this.addRecord(a);this.selectionWidget.clearValue()},addRecord:function(b){var c=(b.data)?b.data:b.attributes?b.attributes:b;var f=this.store.getById(b.id);if(!f){this.store.add(new Tine.Tinebase.Model.Container(c))}else{var a=this.store.indexOf(f);var d=this.pickerGridPanel.getView().getRow(a);Ext.fly(d).highlight()}this.selectionWidget.selectPanel.close()},setValue:function(d){d=Ext.isArray(d)?d:[d];var b=[];this.currentValue=[];if(this.xtype=="checkbox"){this.valueStore.each(function(h){var k=h.get("id");var j=h.get(this.labelField);Ext.each(d,function(l){if(l==k){b.push(j);this.currentValue.push(k)}},this)},this)}else{this.store.removeAll();var a,g,f;for(var c=0;c<d.length;c++){f=this.getRecordText(d[c]);if(f&&f!==""){b.push(f)}}}this.setRawValue(b.join(", "));return this},getRecordText:function(a){var b="";id=(Ext.isString(a))?a:a.id;record=this.valueStore.getById(id);if(record){this.currentValue.push(record.id);this.store.add(record.copy());b=record.get(this.labelField);b=(this.labelRenderer!=Ext.emptyFn)?this.labelRenderer(b):b}return b},onBeforeCollapse:function(){if(this.pickerGridPanel){var a=this.pickerGridPanel.contextMenu&&!this.pickerGridPanel.contextMenu.hidden,b=this.isSelectionVisible();return !(a||b)}else{return true}},isSelectionVisible:function(){return false},setFormValue:function(a){if(this.xtype=="checkbox"){this.getInnerForm().getForm().items.each(function(b){b.setValue(a.indexOf(b.name)>=0?"on":"off")},this)}}});Ext.ns("Tine.widgets.relation");Tine.widgets.relation.Manager=function(){var a={};var b=["Admin","Setup","Tinebase","ActiveSync"];return{get:function(h,g,f){var d=this.getKey(h,g);if(a[d]===undefined){this.create(g,d)}var c=a[d];var j=[];if(f){Ext.each(c,function(k){if(f.indexOf(k.relatedApp+"_Model_"+k.relatedModel)==-1){j.push(k)}},this)}else{return c}return j},has:function(f,d){var c=this.getKey(f,d);if(a[c]===undefined){this.create(d,c)}return a[c]?true:false},create:function(d,c){var f=[];if(!a[c]){a[c]=[]}Tine.Tinebase.data.RecordMgr.each(function(g){if(Tine.Tinebase.common.hasRight("run",g.getMeta("appName"))&&(b.indexOf(g.getMeta("appName"))==-1)&&(g.getFieldNames().indexOf("relations")>-1)){a[c].push({ownModel:d.getMeta("recordName"),relatedApp:g.getMeta("appName"),relatedModel:g.getMeta("modelName"),text:g.getRecordName()+" ("+g.getAppName()+")"})}});if(a[c].length==0){a[c]=false}},getKey:function(c,d){var c=Tine.Tinebase.common.resolveApp(c);var d=Tine.Tinebase.common.resolveModel(d);return c+d}}}();Ext.ns("Tine.widgets.relation");Tine.widgets.relation.MenuItemManager=function(){var a={};return{register:function(b,c,d){var f=b+c;if(!a[f]){a[f]=[]}a[f].push(d)},get:function(b,c,f){var g=b+c;var d=[];if(a[g]){Ext.each(a[g],function(h){d.push(new Ext.Action(Ext.apply({},h,f)))})}return d}}}();Ext.ns("Tine.widgets.relation");Tine.widgets.relation.GenericPickerGridPanel=Ext.extend(Tine.widgets.grid.PickerGridPanel,{recordClass:Tine.Tinebase.Model.Relation,clicksToEdit:1,selectRowAfterAdd:false,enableTbar:false,title:null,record:null,ownRecordClass:null,app:null,editDialog:null,possibleRelations:null,modelCombo:null,searchCombos:null,activeModel:null,degreeData:null,keyFieldConfigs:null,constrainsConfig:null,frame:true,border:true,autoScroll:true,layout:"fit",initComponent:function(){this.record=this.editDialog.record,this.app=this.editDialog.app;this.ownRecordClass=this.editDialog.recordClass,this.possibleRelations=Tine.widgets.relation.Manager.get(this.app,this.ownRecordClass,this.editDialog.ignoreRelatedModels);this.initTbar();this.viewConfig={getRowClass:this.getViewRowClass,enableRowBody:true};this.actionEditInNewWindow=new Ext.Action({text:_("Edit record"),disabled:true,scope:this,handler:this.onEditInNewWindow,iconCls:"action_edit"});this.title=this.i18nTitle=Tine.Tinebase.translation.ngettext("Relation","Relations",50);Tine.widgets.dialog.MultipleEditDialogPlugin.prototype.registerSkipItem(this);this.on("rowdblclick",this.onEditInNewWindow.createDelegate(this),this);this.on("beforecontextmenu",this.onBeforeContextMenu.createDelegate(this),this);this.contextMenuItems=[this.actionEditInNewWindow];this.keyFieldConfigs={};this.constrainsConfig={};Ext.each(this.app.getRegistry().get("relatableModels"),function(a){if(a.ownModel==this.ownRecordClass.getMeta("modelName")){if(a.keyfieldConfig){if(a.keyfieldConfig.from=="foreign"){this.keyFieldConfigs[a.relatedApp+a.relatedModel]={app:a.relatedApp,name:a.keyfieldConfig.name}}else{this.keyFieldConfigs[this.app.name+a.ownModel]={app:this.app.name,name:a.keyfieldConfig.name}}}if(a.config){this.constrainsConfig[a.relatedApp+a.relatedModel]=a.config}}},this);this.degreeData=[["sibling",_("Sibling")],["parent",_("Parent")],["child",_("Child")]];this.on("beforeedit",this.onBeforeRowEdit,this);this.on("validateedit",this.onValidateRowEdit,this);this.on("afteredit",this.onAfterRowEdit,this);this.editDialog.on("save",this.onSaveRecord,this);this.editDialog.on("load",this.loadRecord,this);Tine.widgets.relation.GenericPickerGridPanel.superclass.initComponent.call(this);this.selModel.on("selectionchange",function(a){this.actionEditInNewWindow.setDisabled(a.getCount()!=1)},this);this.store.on("add",this.onAdd,this)},onSaveRecord:function(b,a,d){var c=d();if(this.isValid()){if(a.data.hasOwnProperty("relations")){delete a.data.relations}a.set("relations",this.getData())}else{Ext.Msg.alert(_("Relations failure"),_("There are invalid relations. Please check before saving."));return false}c()},updateTitle:function(a){a=Ext.isNumber(a)?a:this.store.getCount();this.setTitle((a>0)?this.i18nTitle+" ("+a+")":this.i18nTitle)},initTbar:function(){var a=[this.getModelCombo()," "];a=a.concat(this.createSearchCombos());this.tbar=new Ext.Toolbar({items:a})},getViewRowClass:function(a,d,f,b){if(this.invalidRowRecords&&this.invalidRowRecords.indexOf(a.id)!==-1){var c=a.get("related_model").split("_Model_");c=Tine[c[0]].Model[c[1]];f.body='<div style="height: 19px; margin-top: -19px" ext:qtip="'+String.format(_("The maximum number of {0} with the type {1} is reached. Please change the type of this relation"),c.getRecordsName(),this.grid.typeRenderer(a.get("type"),null,a))+'"></div>';return"tine-editorgrid-row-invalid"}f.body="";return""},onEditInNewWindow:function(){var f=this.getSelectionModel().getSelected(),h=f.get("related_model").split("_")[0],d=f.get("related_model").split("_")[2],c=Tine.Tinebase.appMgr.get(h).getMainScreen(),b=f.get("related_record"),a=new Tine[h].Model[d](b);c.activeContentType=d;var g=c.getCenterPanel(d);g.onEditInNewWindow({actionType:"edit",mode:"remote"},a)},onBeforeContextMenu:function(d,c){var a=d.store.getAt(c),g=a.get("related_model");if(!g){return}var b=g.split("_Model_");var h=Tine.Tinebase.appMgr.get(b[0]);var f=Tine.widgets.relation.MenuItemManager.get(b[0],b[1],{scope:h,grid:d,gridIndex:c});Ext.each(f,function(j){j.setText(h.i18n._(j.getText()));this.contextMenu.add(j);if(!this.contextMenu.hasOwnProperty("tempItems")){this.contextMenu.tempItems=[]}this.contextMenu.tempItems.push(j)},this)},getModelCombo:function(){if(!this.modelCombo){var a=[];var b=0;Ext.each(this.possibleRelations,function(c){a.push([b,c.text,c.relatedApp,c.relatedModel]);b++},this);this.modelCombo=new Ext.form.ComboBox({store:new Ext.data.ArrayStore({fields:["id","text","appName","modelName"],data:a}),allowBlank:false,forceSelection:true,value:a.length>0?a[0][0]:null,displayField:"text",valueField:"id",idIndex:0,mode:"local",triggerAction:"all",selectOnFocus:true,getActiveData:function(){var c=this.getStore().getAt(this.getValue());if(c){return c.data}else{return null}},listeners:{scope:this,select:function(d){var c=d.getActiveData();if(c){this.showSearchCombo(c.appName,c.modelName)}}}})}return this.modelCombo},createSearchCombos:function(){var a=[];this.searchCombos={};Ext.each(this.possibleRelations,function(b){var c=b.relatedApp+b.relatedModel;this.searchCombos[c]=Tine.widgets.form.RecordPickerManager.get(b.relatedApp,b.relatedModel,{width:300,allowBlank:true,listeners:{scope:this,select:this.onAddRecordFromCombo}});a.push(this.searchCombos[c]);this.searchCombos[c].hide()},this);this.showSearchCombo(this.possibleRelations[0].relatedApp,this.possibleRelations[0].relatedModel);return a},showSearchCombo:function(a,b){var c=a+b;if(this.activeModel){this.searchCombos[this.activeModel].hide()}this.searchCombos[c].show();this.activeModel=a+b},getActiveSearchCombo:function(){return this.searchCombos[this.activeModel]},getColumnModel:function(){this.degreeEditor=new Ext.form.ComboBox({store:new Ext.data.ArrayStore({fields:["id","value"],data:this.degreeData}),allowBlank:false,displayField:"value",valueField:"id",mode:"local"});if(!this.colModel){this.colModel=new Ext.grid.ColumnModel({defaults:{sortable:true,width:180},columns:[{id:"related_model",dataIndex:"related_model",header:_("Record"),editor:false,renderer:this.relatedModelRenderer.createDelegate(this),scope:this},{id:"related_record",dataIndex:"related_record",header:_("Description"),renderer:this.relatedRecordRenderer.createDelegate(this),editor:false,scope:this},{id:"remark",dataIndex:"remark",header:_("Remark"),renderer:this.remarkRenderer.createDelegate(this),editor:Ext.form.Field,scope:this,width:120},{id:"own_degree",hidden:true,dataIndex:"own_degree",header:_("Dependency"),editor:this.degreeEditor,renderer:this.degreeRenderer.createDelegate(this),scope:this,width:100},{id:"type",dataIndex:"type",renderer:this.typeRenderer,header:_("Type"),scope:this,width:120,editor:true},{id:"creation_time",dataIndex:"creation_time",editor:false,renderer:Tine.Tinebase.common.dateTimeRenderer,header:_("Creation Time"),width:140}]})}return this.colModel},onBeforeRowEdit:function(f){var b=f.record.get("related_model").split("_");var d=b[0];b=b[2];var a=f.grid.getColumnModel();switch(f.field){case"type":var c=null;if(this.constrainsConfig[d+b]){c=this.getTypeEditor(this.constrainsConfig[d+b])}else{if(this.keyFieldConfigs[d+b]){c=new Tine.Tinebase.widgets.keyfield.ComboBox({app:d,keyFieldName:this.keyFieldConfigs[d+b].name})}}if(c){a.config[f.column].setEditor(c)}else{a.config[f.column].setEditor(null)}break;default:return}if(a.config[f.column].editor){a.config[f.column].editor.selectedRecord=null}},getTypeEditor:function(a){var b=[];Ext.each(a,function(d){b.push([d.type.toUpperCase(),d.text])});return new Ext.form.ComboBox({store:new Ext.data.ArrayStore({fields:["id","value"],data:b}),allowBlank:false,displayField:"value",valueField:"id",mode:"local"})},relatedRecordRenderer:function(f,g,j){var h=j.get("related_model");if(!h){return""}var c=h.split("_");var d=Tine[c[0]][c[1]][c[2]];var b=new d(f);var a="";if(f){a=Ext.util.Format.htmlEncode(b.getTitle())}return a},remarkRenderer:function(b,f,a){if(a&&a.get("related_model")){var d=Tine.Tinebase.appMgr.get(a.get("related_model").split("_Model_")[0])}if(!b){b=""}else{if(Ext.isObject(b)){var c="";Ext.iterate(b,function(g,h){c+=d.i18n._(Ext.util.Format.capitalize(g))+": "+(Ext.isNumber(h)?h:Ext.util.Format.capitalize(h))+", "},this);b=c.replace(/, $/,"")}else{if(Ext.isArray(b)){var c="";Ext.each(b,function(g){c+=(Ext.isNumber(g)?g:Ext.util.Format.capitalize(g))+", "},this);b=c.replace(/, $/,"")}else{if(b.match(/^\[.*\]$/)){b=Ext.decode(b);return this.remarkRenderer(b)}}}}return Ext.util.Format.htmlEncode(b)},degreeRenderer:function(a){if(!this.degreeDataObject){this.degreeDataObject={};Ext.each(this.degreeData,function(b){this.degreeDataObject[b[0]]=b[1]},this)}return this.degreeDataObject[a]?_(this.degreeDataObject[a]):""},relatedModelRenderer:function(c){if(!c){return""}var b=c.split("_");var a=Tine[b[0]][b[1]][b[2]];return'<span class="tine-recordclass-gridicon '+_(a.getMeta("appName"))+a.getMeta("modelName")+'">&nbsp;</span>'+a.getRecordName()+" ("+a.getAppName()+")"},typeRenderer:function(c,h,g){if(!g.get("own_model")||!g.get("related_model")){return""}var d=g.get("own_model").split("_Model_").join("");var b=g.get("related_model").split("_Model_").join("");var a=Ext.util.Format.htmlEncode;if(this.constrainsConfig[b]){Ext.each(this.constrainsConfig[b],function(f){if(f.type==c){c=f.text}})}else{if(this.keyFieldConfigs[d]){a=Tine.Tinebase.widgets.keyfield.Renderer.get(this.keyFieldConfigs[d].app,this.keyFieldConfigs[d].name)}else{if(this.keyFieldConfigs[b]){a=Tine.Tinebase.widgets.keyfield.Renderer.get(this.keyFieldConfigs[b].app,this.keyFieldConfigs[b].name)}}}return a(c)},getRelationDefaults:function(){return{own_backend:"Sql",related_backend:"Sql",own_id:(this.record)?this.record.id:null,own_model:this.ownRecordClass.getPhpClassName()}},onAddRecordFromCombo:function(){var a=this.getActiveSearchCombo().store.getById(this.getActiveSearchCombo().getValue());this.onAddRecord(a);this.getActiveSearchCombo().collapse();this.getActiveSearchCombo().reset()},onAddRecord:function(a,c){if(a){if(!c){c={}}if(a.data.hasOwnProperty("relations")){delete a.data.relations}var b=new Tine.Tinebase.Model.Relation(Ext.apply(this.getRelationDefaults(),Ext.apply({related_record:a.data,related_id:a.id,related_model:this.getActiveSearchCombo().recordClass.getMeta("appName")+"_Model_"+this.getActiveSearchCombo().recordClass.getMeta("modelName"),type:"",own_degree:"sibling"},c)),a.id);if(this.store.findExact("related_id",a.id)===-1){Tine.log.debug("Adding new relation:");Tine.log.debug(b);this.store.add([b])}}this.getActiveSearchCombo().collapse();this.getActiveSearchCombo().reset()},relationCheck:function(b,a){var c=true;this.store.each(function(d){if(d.get("related_model")==a&&d.get("related_id")==b.getId()){Ext.MessageBox.show({title:_("Failure"),msg:_("The record you tried to link is already linked. Please edit the existing link."),buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO});c=false;return false}},this);if((this.ownRecordClass.getMeta("phpClassName")==a)&&b.getId()==this.editDialog.record.getId()){Ext.MessageBox.show({title:_("Failure"),msg:_("You tried to link a record with itself. This is not allowed!"),buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR});c=false}return c},onAfterRowEdit:function(a){this.onUpdate(a.grid.store,a.record);this.view.refresh()},onValidateRowEdit:function(c){if(c.field==="type"){var a=c.record.get("related_model").split("_");var b=a[0];if(!this.view.invalidRowRecords){this.view.invalidRowRecords=[]}a=a[2];if(this.constrainsConfig[b+a]){this.view.invalidRowRecords.remove(c.record.get("id"));Ext.each(this.constrainsConfig[b+a],function(f){if(f.max&&f.max>0&&(f.type==c.value)){var g=this.store.queryBy(function(h,j){if((c.value==h.get("type"))&&(h.get("related_model")==(b+"_Model_"+a))){return true}else{return false}},this);if(g.getCount()>=f.max){g.each(function(h){if(this.view.invalidRowRecords.indexOf(h.id)===-1){this.view.invalidRowRecords.push(h.id)}},this);if(this.view.invalidRowRecords.indexOf(c.record.id)===-1){this.view.invalidRowRecords.push(c.record.id)}}}if(f.max&&f.max>0&&(f.type==c.originalValue)){var d=this.store.queryBy(function(h,j){if((c.originalValue==h.get("type"))&&(h.get("related_model")==(b+"_Model_"+a))){return true}else{return false}},this);if((d.getCount()-1)<=f.max){d.each(function(h){if(h.id!=c.record.get("id")){this.view.invalidRowRecords.remove(h.id)}},this)}}},this)}}return true},onAdd:function(b,a){Ext.each(a,function(c){Ext.each(this.editDialog.relationPickers,function(d){if(d.relationType==c.get("type")&&c.get("related_id")!=d.getValue()&&d.fullModelName==c.get("related_model")){var f=d.fullModelName.split("_Model_");d.combo.selectedRecord=new Tine[f[0]].Model[f[1]](c.get("related_record"));d.combo.startRecord=new Tine[f[0]].Model[f[1]](c.get("related_record"));d.combo.setValue(d.combo.selectedRecord);d.combo.startValue=d.combo.selectedRecord.get(this.recordClass.getMeta("idProperty"))}},this)},this)},onUpdate:function(b,a){b.each(function(c){Ext.each(this.editDialog.relationPickers,function(d){if(d.relationType==c.get("type")&&d.fullModelName==c.get("related_model")){d.setValue(c.get("related_record"))}},this)},this);this.updateTitle()},loadRecord:function(c,a,b){this.store.removeAll();var d=b();if(a.get("relations")&&a.get("relations").length>0){this.updateTitle(a.get("relations").length);var f=[];Ext.each(a.get("relations"),function(g){if(this.editDialog.ignoreRelatedModels){if(g.hasOwnProperty("related_model")&&this.editDialog.ignoreRelatedModels.indexOf(g.related_model)==-1){f.push(new Tine.Tinebase.Model.Relation(g,g.id))}}else{f.push(new Tine.Tinebase.Model.Relation(g,g.id))}},this);this.store.add(f);this.store.sort("creation_time","DESC");this.updateTitle()}if(this.store){this.store.on("update",this.onUpdate,this);this.store.on("add",this.updateTitle,this);this.store.on("remove",function(h,g,j){Ext.each(g,function(k){Ext.each(this.editDialog.relationPickers,function(l){if(l.relationType==k.get("type")&&k.get("related_id")==l.getValue()&&l.fullModelName==k.get("related_model")){l.clear()}},this)},this);this.updateTitle()},this)}d()},isValid:function(){if(this.view&&this.view.invalidRowRecords&&this.view.invalidRowRecords.length>0){return false}return true},getData:function(){var a=[];this.store.each(function(b){delete b.data.related_record.relations;delete b.data.related_record.relation;a.push(b.data)},this);return a}});Ext.ns("Tine.widgets.grid");Tine.widgets.grid.GridPanel=function(a){Ext.apply(this,a);this.gridConfig=this.gridConfig||{};this.defaultSortInfo=this.defaultSortInfo||{};this.defaultPaging=this.defaultPaging||{start:0,limit:50};if(this.stateful!==false&&!this.stateId){this.stateId=this.recordClass.getMeta("appName")+"-"+this.recordClass.getMeta("recordName")+"-GridPanel"}Tine.widgets.grid.GridPanel.superclass.constructor.call(this)};Ext.extend(Tine.widgets.grid.GridPanel,Ext.Panel,{app:null,gridConfig:null,recordClass:null,recordProxy:null,filterToolbar:null,evalGrants:true,filterSelectionDelete:false,defaultSortInfo:null,storeRemoteSort:true,usePagingToolbar:true,defaultPaging:null,pagingConfig:null,detailsPanel:null,i18nDeleteQuestion:null,i18nAddActionText:null,i18nEditActionText:null,i18nDeleteActionText:null,editDialogConfig:null,editDialogClass:null,i18nEmptyText:null,newRecordIcon:null,updateDetailsPanelOnCtxMenu:true,autoRefreshInterval:300,hasFavoritesPanel:true,hasQuickSearchFilterToolbarPlugin:true,disableSelectAllPages:false,multipleEdit:false,multipleEditRequiredRight:null,duplicateResolvable:false,autoRefreshTask:null,updateOnSelectionChange:true,copyEditAction:false,actionToolbar:null,pagingToolbar:null,contextMenu:null,lastStoreTransactionId:null,editBuffer:null,deleteQueue:null,modelConfig:null,selectionModel:null,splitAddButton:true,layout:"border",border:false,stateful:true,initComponent:function(){this.i18nRecordName=this.recordClass.getRecordName();this.i18nRecordsName=this.recordClass.getRecordsName();this.i18nContainerName=this.recordClass.getContainerName();this.i18nContainersName=this.recordClass.getContainersName();this.i18nEmptyText=this.i18nEmptyText||String.format(Tine.Tinebase.translation._("There could not be found any {0}. Please try to change your filter-criteria, view-options or the {1} you search in."),this.i18nRecordsName,this.i18nContainersName);this.i18nEditActionText=this.i18nEditActionText?this.i18nEditActionText:[String.format(Tine.Tinebase.translation.ngettext("Edit {0}","Edit {0}",1),this.i18nRecordName),String.format(Tine.Tinebase.translation.ngettext("Edit {0}","Edit {0}",2),this.i18nRecordsName)];this.editDialogConfig=this.editDialogConfig||{};this.editBuffer=[];this.deleteQueue=[];this.initGenericFilterToolbar();this.initGenericColumnModel();this.initStore();this.initGrid();this.actionUpdater=new Tine.widgets.ActionUpdater({containerProperty:this.recordClass.getMeta("containerProperty"),evalGrants:this.evalGrants});this.initActions();this.initLayout();if(Ext.isIE6||Ext.isIE7){this.on("show",function(){if(this.layout.rendered&&this.detailsPanel){var a=this.detailsPanel.getSize().height;this.layout.south.split.setCurrentSize(a)}},this)}Tine.widgets.grid.GridPanel.superclass.initComponent.call(this)},initGenericFilterToolbar:function(){if(this.modelConfig){var b=[];if(!Ext.isDefined(this.hasQuickSearchFilterToolbarPlugin)||this.hasQuickSearchFilterToolbarPlugin){this.quickSearchFilterToolbarPlugin=new Tine.widgets.grid.FilterToolbarQuickFilterPlugin();b.push(this.quickSearchFilterToolbarPlugin)}var a=this.recordClass.getMeta("modelName");this.filterToolbar=new Tine.widgets.grid.FilterPanel({app:this.app,recordClass:this.recordClass,allowSaving:true,filterModels:this.recordClass.getFilterModel(),defaultFilter:this.recordClass.getMeta("defaultFilter")?this.recordClass.getMeta("defaultFilter"):"query",plugins:b,filters:[]});this.plugins=this.plugins||[];this.plugins.push(this.filterToolbar)}},initGenericColumnModel:function(){if(this.modelConfig){var a=[];Ext.each(this.modelConfig.keys,function(c){if(this.modelConfig.fields[c].label){var b={id:c,dataIndex:c,header:this.app.i18n._(this.modelConfig.fields[c].label),hidden:this.modelConfig.fields[c].hidden};var d=Tine.widgets.grid.RendererManager.get(this.app.name,this.recordClass.getMeta("modelName"),c);if(d){b.renderer=d}a.push(b)}},this);this.gridConfig.cm=new Ext.grid.ColumnModel({defaults:{sortable:true,resizable:true},columns:a})}},initLayout:function(){this.items=[{region:"center",xtype:"panel",layout:"fit",border:false,tbar:this.pagingToolbar,items:this.grid}];if(this.detailsPanel){this.items.push({region:"south",border:false,collapsible:true,collapseMode:"mini",header:false,split:true,layout:"fit",height:this.detailsPanel.defaultHeight?this.detailsPanel.defaultHeight:125,items:this.detailsPanel});this.detailsPanel.doBind(this.grid)}if(this.filterToolbar){this.items.push({region:"north",border:false,autoScroll:true,items:this.filterToolbar,listeners:{scope:this,afterlayout:function(a){a.suspendEvents();a.setHeight(Math.min(120,this.filterToolbar.getHeight()));a.getEl().child('div[class^="x-panel-body"]',true).scrollTop=1000000;a.ownerCt.layout.layout();a.resumeEvents()}}})}},initActions:function(){this.action_editInNewWindow=new Ext.Action({requiredGrant:"readGrant",requiredMultipleGrant:"editGrant",requiredMultipleRight:this.multipleEditRequiredRight,text:this.i18nEditActionText?this.i18nEditActionText[0]:String.format(_("Edit {0}"),this.i18nRecordName),singularText:this.i18nEditActionText?this.i18nEditActionText[0]:String.format(_("Edit {0}"),this.i18nRecordName),pluralText:this.i18nEditActionText?this.i18nEditActionText[1]:String.format(Tine.Tinebase.translation.ngettext("Edit {0}","Edit {0}",1),this.i18nRecordsName),disabled:true,translationObject:this.i18nEditActionText?this.app.i18n:Tine.Tinebase.translation,actionType:"edit",handler:this.onEditInNewWindow.createDelegate(this,[{actionType:"edit"}]),iconCls:"action_edit",scope:this,allowMultiple:this.multipleEdit});this.action_editCopyInNewWindow=new Ext.Action({hidden:!this.copyEditAction,requiredGrant:"readGrant",text:String.format(_("Copy {0}"),this.i18nRecordName),disabled:true,actionType:"copy",handler:this.onEditInNewWindow.createDelegate(this,[{actionType:"copy"}]),iconCls:"action_editcopy",scope:this});this.action_addInNewWindow=new Ext.Action({requiredGrant:"addGrant",actionType:"add",text:this.i18nAddActionText?this.app.i18n._hidden(this.i18nAddActionText):String.format(_("Add {0}"),this.i18nRecordName),handler:this.onEditInNewWindow.createDelegate(this,[{actionType:"add"}]),iconCls:(this.newRecordIcon!==null)?this.newRecordIcon:this.app.appName+"IconCls",scope:this});this.actions_print=new Ext.Action({requiredGrant:"readGrant",text:_("Print Page"),disabled:false,handler:function(){Ext.ux.Printer.print(this.getGrid())},iconCls:"action_print",scope:this,allowMultiple:true});this.initDeleteAction();this.action_tagsMassAttach=new Tine.widgets.tags.TagsMassAttachAction({hidden:!this.recordClass.getField("tags"),selectionModel:this.grid.getSelectionModel(),recordClass:this.recordClass,updateHandler:this.loadGridData.createDelegate(this),app:this.app});this.action_tagsMassDetach=new Tine.widgets.tags.TagsMassDetachAction({hidden:!this.recordClass.getField("tags"),selectionModel:this.grid.getSelectionModel(),recordClass:this.recordClass,updateHandler:this.loadGridData.createDelegate(this),app:this.app});this.action_resolveDuplicates=new Ext.Action({requiredGrant:null,text:String.format(_("Merge {0}"),this.i18nRecordsName),iconCls:"action_resolveDuplicates",scope:this,handler:this.onResolveDuplicates,disabled:false,actionUpdater:function(c,a,b){if(b&&(b.length!=2)){c.setDisabled(true)}else{c.setDisabled(false)}}});this.actionUpdater.addActions([this.action_addInNewWindow,this.action_editInNewWindow,this.action_editCopyInNewWindow,this.action_deleteRecord,this.action_tagsMassAttach,this.action_tagsMassDetach,this.action_resolveDuplicates]);this.getActionToolbar()},initDeleteAction:function(){this.action_deleteRecord=new Ext.Action({requiredGrant:"deleteGrant",allowMultiple:true,singularText:this.i18nDeleteActionText?this.i18nDeleteActionText[0]:String.format(Tine.Tinebase.translation.ngettext("Delete {0}","Delete {0}",1),this.i18nRecordName),pluralText:this.i18nDeleteActionText?this.i18nDeleteActionText[1]:String.format(Tine.Tinebase.translation.ngettext("Delete {0}","Delete {0}",1),this.i18nRecordsName),translationObject:this.i18nDeleteActionText?this.app.i18n:Tine.Tinebase.translation,text:this.i18nDeleteActionText?this.i18nDeleteActionText[0]:String.format(Tine.Tinebase.translation.ngettext("Delete {0}","Delete {0}",1),this.i18nRecordName),handler:this.onDeleteRecords,disabled:true,iconCls:"action_delete",scope:this})},initStore:function(){if(this.recordProxy){this.store=new Ext.data.Store({fields:this.recordClass,proxy:this.recordProxy,reader:this.recordProxy.getReader(),remoteSort:this.storeRemoteSort,sortInfo:this.defaultSortInfo,listeners:{scope:this,add:this.onStoreAdd,remove:this.onStoreRemove,update:this.onStoreUpdate,beforeload:this.onStoreBeforeload,load:this.onStoreLoad,beforeloadrecords:this.onStoreBeforeLoadRecords,loadexception:this.onStoreLoadException}})}else{this.store=new Tine.Tinebase.data.RecordStore({recordClass:this.recordClass})}this.autoRefreshTask=new Ext.util.DelayedTask(this.loadGridData,this,[{removeStrategy:"keepBuffered",autoRefresh:true}])},getViewRowClass:function(a,c,f,b){var d=a.not_in_filter;var g="";if(d){g+="tine-grid-row-nolongerinfilter"}return g},onStoreNewEntry:function(c){var a=null;if(Ext.isFunction(this.recordClass.getDefaultData)){a=Ext.apply(this.recordClass.getDefaultData(),c)}else{a=c}var b=new this.recordClass(a);this.store.insert(0,[b]);if(this.usePagingToolbar){this.pagingToolbar.refresh.disable()}this.recordProxy.saveRecord(b,{scope:this,success:function(d){this.store.suspendEvents();this.store.remove(b);this.store.insert(0,[d]);this.store.resumeEvents();this.addToEditBuffer(d);this.loadGridData({removeStrategy:"keepBuffered"})}});return true},onHeaderClick:function(a,c,b){Ext.apply(this.store.lastOptions,{preserveCursor:true,preserveSelection:true,preserveScroller:true,removeStrategy:"default"})},onStoreAdd:function(b,a,c){this.store.totalLength+=a.length;if(this.pagingToolbar){this.pagingToolbar.updateInfo()}},onStoreRemove:function(b,a,c){this.store.totalLength--;if(this.pagingToolbar){this.pagingToolbar.updateInfo()}},onStoreUpdate:function(c,a,b){switch(b){case Ext.data.Record.EDIT:this.addToEditBuffer(a);if(this.usePagingToolbar){this.pagingToolbar.refresh.disable()}this.recordProxy.saveRecord(a,{scope:this,success:function(d){c.commitChanges();a.data=d.data;this.loadGridData({removeStrategy:"keepBuffered"})}});break;case Ext.data.Record.COMMIT:break}},onStoreBeforeload:function(a,b){this.lastStoreTransactionId=b.transactionId=Ext.id();b.params=b.params||{};b.params.filter=[];if(!b.removeStrategy||b.removeStrategy!=="keepBuffered"){this.editBuffer=[]}Ext.applyIf(b.params,this.defaultPaging)},onStoreLoad:function(b,a,c){if(Ext.isArray(c.preserveSelection)){Ext.each(c.preserveSelection,function(d){var f=this.store.indexOfId(d.id);if(f>=0){this.grid.getSelectionModel().selectRow(f,true)}},this)}if(Ext.isNumber(c.preserveScroller)){this.grid.getView().scroller.dom.scrollTop=c.preserveScroller}if(window.isMainWindow&&this.autoRefreshInterval){this.autoRefreshTask.delay(this.autoRefreshInterval*1000)}},onStoreLoadException:function(c,d,b,a){if(window.isMainWindow&&this.autoRefreshInterval){this.autoRefreshTask.delay(this.autoRefreshInterval*5000)}if(this.usePagingToolbar&&this.pagingToolbar.refresh){this.pagingToolbar.refresh.enable()}if(!a.autoRefresh){c.handleRequestException(b)}else{Tine.log.debug("Tine.widgets.grid.GridPanel::onStoreLoadException -> auto refresh failed.")}},onStoreBeforeLoadRecords:function(h,d,g,c){if(this.lastStoreTransactionId&&d.transactionId&&this.lastStoreTransactionId!==d.transactionId){Tine.log.debug("cancelling old transaction request.");return false}if(d.preserveSelection){d.preserveSelection=this.grid.getSelectionModel().getSelections()}if(d.preserveScroller&&this.grid.getView().scroller&&this.grid.getView().scroller.dom){d.preserveScroller=this.grid.getView().scroller.dom.scrollTop}if(!d.removeStrategy||d.removeStrategy==="default"){return true}var b=[],f=[],a=new Ext.util.MixedCollection();Ext.each(h.records,function(j){a.add(j.id,j)});this.store.each(function(j){var k=a.get(j.id);if(k){b.push(k);f.push(k.id)}else{if(d.removeStrategy==="keepAll"||(d.removeStrategy==="keepBuffered"&&this.editBuffer.indexOf(j.id)>=0)){var l=j.copy();l.not_in_filter=true;b.push(l);f.push(j.id)}}},this);a.each(function(k,j){if(f.indexOf(k.id)==-1&&this.deleteQueue.indexOf(k.id)==-1){var m=a.itemAt(j-1);var l=m?f.indexOf(m.id):-1;b.splice(l+1,0,k);f.splice(l+1,0,k.id)}},this);h.records=b},initialLoad:function(){var b=Tine.widgets.persistentfilter.model.PersistentFilter.getDefaultFavorite(this.app.appName);var a=this.app.getMainScreen()&&typeof this.app.getMainScreen().getWestPanel().getFavoritesPanel==="function"&&this.hasFavoritesPanel?this.app.getMainScreen().getWestPanel().getFavoritesPanel():null;if(b&&a){a.selectFilter(b)}else{this.store.load.defer(10,this.store,[typeof this.autoLoad=="object"?this.autoLoad:undefined])}if(this.usePagingToolbar&&this.recordProxy){this.pagingToolbar.refresh.disable.defer(10,this.pagingToolbar.refresh)}},initGrid:function(){this.selectionModel=new Tine.widgets.grid.FilterSelectionModel({store:this.store,gridPanel:this});this.selectionModel.on("selectionchange",function(c){this.actionUpdater.updateActions(c);this.ctxNode=this.selectionModel.getSelections();if(this.updateOnSelectionChange&&this.detailsPanel){this.detailsPanel.onDetailsUpdate(c)}},this);if(this.usePagingToolbar){this.pagingToolbar=new Ext.ux.grid.PagingToolbar(Ext.apply({pageSize:this.defaultPaging&&this.defaultPaging.limit?this.defaultPaging.limit:50,store:this.store,displayInfo:true,displayMsg:Tine.Tinebase.translation._("Displaying records {0} - {1} of {2}").replace(/records/,this.i18nRecordsName),emptyMsg:String.format(Tine.Tinebase.translation._("No {0} to display"),this.i18nRecordsName),displaySelectionHelper:true,sm:this.selectionModel,disableSelectAllPages:this.disableSelectAllPages},this.pagingConfig));this.pagingToolbar.on("beforechange",function(){this.grid.getView().isPagingRefresh=true},this)}var b=new Ext.grid.GridView({getRowClass:this.getViewRowClass,autoFill:true,forceFit:true,ignoreAdd:true,emptyText:this.i18nEmptyText,onLoad:Ext.grid.GridView.prototype.onLoad.createInterceptor(function(){if(this.grid.getView().isPagingRefresh){this.grid.getView().isPagingRefresh=false;return true}return false},this)});var a=this.gridConfig.quickaddMandatory?Ext.ux.grid.QuickaddGridPanel:(this.gridConfig.gridType||Ext.grid.GridPanel);this.gridConfig.store=this.store;this.gridConfig.plugins=this.gridConfig.plugins?this.gridConfig.plugins:[];this.gridConfig.plugins.push(new Ext.ux.grid.GridViewMenuPlugin({}));this.gridConfig.enableHdMenu=false;if(this.stateful){this.gridConfig.stateful=true;this.gridConfig.stateId=this.stateId+"-Grid"}this.grid=new a(Ext.applyIf(this.gridConfig,{border:false,store:this.store,sm:this.selectionModel,view:b}));this.grid.on("keydown",this.onKeyDown,this);this.grid.on("rowclick",this.onRowClick,this);this.grid.on("rowdblclick",this.onRowDblClick,this);this.grid.on("newentry",this.onStoreNewEntry,this);this.grid.on("headerclick",this.onHeaderClick,this);this.grid.on("rowcontextmenu",this.onRowContextMenu,this)},afterRender:function(){Tine.widgets.grid.GridPanel.superclass.afterRender.apply(this,arguments);this.initialLoad()},loadGridData:function(a){var a=a||{};Ext.applyIf(a,{callback:Ext.emptyFn,scope:this,params:{},preserveCursor:true,preserveSelection:true,preserveScroller:true,removeStrategy:"default"});if(a.preserveCursor&&this.usePagingToolbar){a.params.start=this.pagingToolbar.cursor}this.store.load(a)},getActionToolbar:function(){if(!this.actionToolbar){var b=this.getActionToolbarItems();var a=[];if(this.action_addInNewWindow){if(this.splitAddButton){a.push(Ext.apply(new Ext.SplitButton(this.action_addInNewWindow),{scale:"medium",rowspan:2,iconAlign:"top",arrowAlign:"right",menu:new Ext.menu.Menu({items:[],plugins:[{ptype:"ux.itemregistry",key:"Tine.widgets.grid.GridPanel.addButton"}]})}))}else{a.push(Ext.apply(new Ext.Button(this.action_addInNewWindow),{scale:"medium",rowspan:2,iconAlign:"top"}))}}if(this.action_editInNewWindow){a.push(Ext.apply(new Ext.Button(this.action_editInNewWindow),{scale:"medium",rowspan:2,iconAlign:"top"}))}if(this.action_deleteRecord){a.push(Ext.apply(new Ext.Button(this.action_deleteRecord),{scale:"medium",rowspan:2,iconAlign:"top"}))}if(this.actions_print){a.push(Ext.apply(new Ext.Button(this.actions_print),{scale:"medium",rowspan:2,iconAlign:"top"}))}this.actionToolbar=new Ext.Toolbar({items:[{xtype:"buttongroup",plugins:[{ptype:"ux.itemregistry",key:this.app.appName+"-GridPanel-ActionToolbar-leftbtngrp"}],items:a.concat(Ext.isArray(b)?b:[])}].concat(Ext.isArray(b)?[]:[b])});if(this.filterToolbar&&typeof this.filterToolbar.getQuickFilterField=="function"){this.actionToolbar.add("->",this.filterToolbar.getQuickFilterField())}}return this.actionToolbar},getActionToolbarItems:function(){var a=this.actionToolbarItems||[];if(!Ext.isEmpty(a)){this.actionUpdater.addActions(a)}return a},getContextMenu:function(){if(!this.contextMenu){var a=[];if(this.action_addInNewWindow){a.push(this.action_addInNewWindow)}if(this.action_editCopyInNewWindow){a.push(this.action_editCopyInNewWindow)}if(this.action_editInNewWindow){a.push(this.action_editInNewWindow)}if(this.action_deleteRecord){a.push(this.action_deleteRecord)}if(this.duplicateResolvable){a.push(this.action_resolveDuplicates)}if(this.action_tagsMassAttach&&!this.action_tagsMassAttach.hidden){a.push("-",this.action_tagsMassAttach,this.action_tagsMassDetach)}a=a.concat(this.getContextMenuItems());this.newRecordMenu=new Ext.menu.Menu({items:[],plugins:[{ptype:"ux.itemregistry",key:this.app.appName+"-GridPanel-ContextMenu-New"}]});this.newRecordAction=new Ext.Action({text:_("New..."),hidden:!this.newRecordMenu.items.length,iconCls:this.app.getIconCls(),scope:this,menu:this.newRecordMenu});a.push(this.newRecordAction);this.addToRecordMenu=new Ext.menu.Menu({items:[],plugins:[{ptype:"ux.itemregistry",key:this.app.appName+"-GridPanel-ContextMenu-Add"}]});this.addToRecordAction=new Ext.Action({text:_("Add to..."),hidden:!this.addToRecordMenu.items.length,iconCls:this.app.getIconCls(),scope:this,menu:this.addToRecordMenu});a.push(this.addToRecordAction);this.contextMenu=new Ext.menu.Menu({items:a,plugins:[{ptype:"ux.itemregistry",key:this.app.appName+"-GridPanel-ContextMenu"}]})}return this.contextMenu},getContextMenuItems:function(){var a=this.contextMenuItems||[];if(!Ext.isEmpty(a)){this.actionUpdater.addActions(a)}return a},getModlogColumns:function(){var a=[{id:"creation_time",header:_("Creation Time"),dataIndex:"creation_time",renderer:Tine.Tinebase.common.dateRenderer,hidden:true,sortable:true},{id:"created_by",header:_("Created By"),dataIndex:"created_by",renderer:Tine.Tinebase.common.usernameRenderer,hidden:true,sortable:true},{id:"last_modified_time",header:_("Last Modified Time"),dataIndex:"last_modified_time",renderer:Tine.Tinebase.common.dateRenderer,hidden:true,sortable:true},{id:"last_modified_by",header:_("Last Modified By"),dataIndex:"last_modified_by",renderer:Tine.Tinebase.common.usernameRenderer,hidden:true,sortable:true}];return a},getCustomfieldColumns:function(){var b=this.recordClass.getMeta("appName")+"_Model_"+this.recordClass.getMeta("modelName"),c=Tine.widgets.customfields.ConfigManager.getConfigs(this.app,b),a=[];Ext.each(c,function(d){a.push({id:d.id,header:d.get("definition").label,dataIndex:"customfields",renderer:Tine.widgets.customfields.Renderer.get(this.app,d),sortable:false,hidden:true})},this);return a},getCustomfieldFilters:function(){var b=this.recordClass.getMeta("appName")+"_Model_"+this.recordClass.getMeta("modelName"),c=Tine.widgets.customfields.ConfigManager.getConfigs(this.app,b),a=[];Ext.each(c,function(d){a.push({filtertype:"tinebase.customfield",app:this.app,cfConfig:d})},this);return a},getFilterToolbar:function(b){b=b||{};var a=[];if(!Ext.isDefined(this.hasQuickSearchFilterToolbarPlugin)||this.hasQuickSearchFilterToolbarPlugin){this.quickSearchFilterToolbarPlugin=new Tine.widgets.grid.FilterToolbarQuickFilterPlugin();a.push(this.quickSearchFilterToolbarPlugin)}return new Tine.widgets.grid.FilterPanel(Ext.apply(b,{app:this.app,recordClass:this.recordClass,filterModels:this.recordClass.getFilterModel().concat(this.getCustomfieldFilters()),defaultFilter:"query",filters:this.defaultFilters||[],plugins:a}))},getStore:function(){return this.grid.getStore()},getView:function(){return this.grid.getView()},getGrid:function(){return this.grid},onKeyDown:function(a){if(a.ctrlKey){switch(a.getKey()){case a.A:this.grid.getSelectionModel().selectAll(true);a.preventDefault();break;case a.E:if(this.action_editInNewWindow&&!this.action_editInNewWindow.isDisabled()){this.onEditInNewWindow.call(this,{actionType:"edit"});a.preventDefault()}break;case a.N:if(this.action_addInNewWindow&&!this.action_addInNewWindow.isDisabled()){this.onEditInNewWindow.call(this,{actionType:"add"});a.preventDefault()}break;case a.F:if(this.filterToolbar&&this.hasQuickSearchFilterToolbarPlugin){a.preventDefault();this.filterToolbar.getQuickFilterPlugin().quickFilter.focus()}break}}else{if([a.BACKSPACE,a.DELETE].indexOf(a.getKey())!==-1){if(!this.grid.editing&&!this.grid.adding&&!this.action_deleteRecord.isDisabled()){this.onDeleteRecords.call(this);a.preventDefault()}}}},onRowClick:function(a,c,b){if(b.button===0&&!b.shiftKey&&!b.ctrlKey){var d=a.getSelectionModel();if(d.getCount()==1&&d.isSelected(c)){return}d.clearSelections();d.selectRow(c,false);a.view.focusRow(c)}},onRowContextMenu:function(b,d,c){c.stopEvent();var a=b.getSelectionModel();if(!a.isSelected(d)){this.updateOnSelectionChange=this.updateDetailsPanelOnCtxMenu;a.selectRow(d)}this.getContextMenu().showAt(c.getXY());this.updateOnSelectionChange=true},onRowDblClick:function(a,c,b){this.onEditInNewWindow.call(this,{actionType:"edit"})},onRowContextMenu:function(b,d,c){c.stopEvent();var a=b.getSelectionModel();if(!a.isSelected(d)){this.updateOnSelectionChange=this.updateDetailsPanelOnCtxMenu;a.selectRow(d)}this.getContextMenu(b,d,c).showAt(c.getXY());this.updateOnSelectionChange=true},onEditInNewWindow:function(j,k,h){if(!k){if(j.actionType=="edit"||j.actionType=="copy"){if(!this.action_editInNewWindow||this.action_editInNewWindow.isDisabled()){return false}var f=this.grid.getSelectionModel().getSelections();k=f[0]}else{k=new this.recordClass(this.recordClass.getDefaultData(),0)}}var h=h?h:[];var b=this.selectionModel.getCount(),l=[],c=(j.hasOwnProperty("fixedFields")&&Ext.isArray(j.fixedFields))?Ext.encode(j.fixedFields):null,a=this.editDialogClass||Tine[this.app.appName][this.recordClass.getMeta("modelName")+"EditDialog"];if(((b>1)&&(this.multipleEdit)&&(j.actionType=="edit"))){Ext.each(this.selectionModel.getSelections(),function(m){l.push(m.data)},this);h.push({ptype:"multiple_edit_dialog",selectedRecords:l,selectionFilter:this.selectionModel.getSelectionFilter(),isFilterSelect:this.selectionModel.isFilterSelect,totalRecordCount:b})}var d=null,g=a.openWindow(Ext.copyTo(this.editDialogConfig||{},{plugins:h?Ext.encode(h):null,fixedFields:c,record:a.prototype.mode=="local"?Ext.encode(k.data):k,copyRecord:(j.actionType=="copy"),listeners:{scope:this,update:((this.selectionModel.getCount()>1)&&(this.multipleEdit))?this.onUpdateMultipleRecords:this.onUpdateRecord}},"record,listeners,fixedFields,copyRecord,plugins"));return true},onUpdateMultipleRecords:function(){this.store.reload()},onUpdateRecord:function(b,d){if(Ext.isString(b)&&this.recordProxy){b=this.recordProxy.recordReader({responseText:b})}else{if(b&&Ext.isFunction(b.copy)){b=b.copy()}}Tine.log.debug("Tine.widgets.grid.GridPanel::onUpdateRecord() -> record:");Tine.log.debug(b);if(b&&Ext.isFunction(b.copy)){var a=this.getStore().indexOfId(b.id);if(a>=0){var c=this.getGrid().getSelectionModel().isSelected(a);this.getStore().removeAt(a);this.getStore().insert(a,[b]);if(c){this.getGrid().getSelectionModel().selectRow(a,true)}}else{this.getStore().add([b])}this.addToEditBuffer(b)}if(d=="local"){this.onStoreUpdate(this.getStore(),b,Ext.data.Record.EDIT)}else{this.loadGridData({removeStrategy:"keepBuffered"})}},onResolveDuplicates:function(){if(this.grid.getSelectionModel().getSelections().length!=2){return}var a=[];Ext.each(this.grid.getSelectionModel().getSelections(),function(c){a.push(c.data)});var b=Tine.widgets.dialog.DuplicateMergeDialog.getWindow({selections:Ext.encode(a),appName:this.app.name,modelName:this.recordClass.getMeta("modelName")});b.on("contentschange",function(){this.store.reload()},this)},addToEditBuffer:function(b){var a=(Ext.isString(b))?Ext.decode(b):b.data,c=a[this.recordClass.getMeta("idProperty")];if(this.editBuffer.indexOf(c)===-1){this.editBuffer.push(c)}},onDeleteRecords:function(b,d){var g=this.grid.getSelectionModel();if(g.isFilterSelect&&!this.filterSelectionDelete){Ext.MessageBox.show({title:_("Not Allowed"),msg:_("You are not allowed to delete all pages at once"),buttons:Ext.Msg.OK,icon:Ext.MessageBox.INFO});return}var a=g.getSelections();if(Tine[this.app.appName].registry.containsKey("preferences")&&Tine[this.app.appName].registry.get("preferences").containsKey("confirmDelete")&&Tine[this.app.appName].registry.get("preferences").get("confirmDelete")==0){this.deleteRecords(g,a)}else{var c=a[0].get(this.recordClass.getMeta("titleProperty"));if(a.length>1){c+=", ..."}var f=this.i18nDeleteQuestion?this.app.i18n.n_hidden(this.i18nDeleteQuestion[0],this.i18nDeleteQuestion[1],a.length):String.format(Tine.Tinebase.translation.ngettext("Do you really want to delete the selected record ({0})?","Do you really want to delete the selected records ({0})?",a.length),c);Ext.MessageBox.confirm(_("Confirm"),f,function(h){if(h=="yes"){this.deleteRecords(g,a)}},this)}},deleteRecords:function(f,c){if(Ext.isArray(c)&&!(f.isFilterSelect&&this.filterSelectionDelete)){Ext.each(c,function(g){this.store.remove(g)})}if(this.recordProxy){if(this.usePagingToolbar){this.pagingToolbar.refresh.disable()}var b=this.app.i18n.n_hidden(this.recordClass.getMeta("recordName"),this.recordClass.getMeta("recordsName"),c.length),a=[].concat(c).map(function(g){return g.id});if(f.isFilterSelect&&this.filterSelectionDelete){if(!this.deleteMask){this.deleteMask=new Ext.LoadMask(this.grid.getEl(),{msg:String.format(_("Deleting {0}"),b)+_(" ... This may take a long time!")})}this.deleteMask.show()}this.deleteQueue=this.deleteQueue.concat(a);var d={scope:this,success:function(){this.refreshAfterDelete(a);this.onAfterDelete(a)},failure:function(g){this.refreshAfterDelete(a);this.loadGridData();Tine.Tinebase.ExceptionHandler.handleRequestException(g)}};if(f.isFilterSelect&&this.filterSelectionDelete){this.recordProxy.deleteRecordsByFilter(f.getSelectionFilter(),d)}else{this.recordProxy.deleteRecords(c,d)}}},refreshAfterDelete:function(a){this.deleteQueue=this.deleteQueue.diff(a);if(this.deleteMask){this.deleteMask.hide()}if(this.usePagingToolbar){this.pagingToolbar.refresh.show()}},onAfterDelete:function(a){this.editBuffer=this.editBuffer.diff(a);this.loadGridData({removeStrategy:"keepBuffered"})}});Ext.ns("Tine.Tinebase.widgets.keyfield");Tine.Tinebase.widgets.keyfield.Filter=Ext.extend(Tine.widgets.grid.FilterModel,{app:null,keyfieldName:null,defaultOperator:"in",initComponent:function(){this.operators=["in","notin"];Tine.Tinebase.widgets.keyfield.Filter.superclass.initComponent.call(this)},valueRenderer:function(b,a){var c=new Tine.Tinebase.widgets.keyfield.FilterValueField({app:this.app,filter:b,width:200,id:"tw-ftb-frow-valuefield-"+b.id,value:b.data.value?b.data.value:this.defaultValue,renderTo:a,keyfieldName:this.keyfieldName});c.on("specialkey",function(f,d){if(d.getKey()==d.ENTER){this.onFiltertrigger()}},this);c.on("select",this.onFiltertrigger,this);return c}});Tine.widgets.grid.FilterToolbar.FILTERS["tine.widget.keyfield.filter"]=Tine.Tinebase.widgets.keyfield.Filter;Tine.Tinebase.widgets.keyfield.FilterValueField=Ext.extend(Ext.ux.form.LayerCombo,{hideButtons:false,formConfig:{labelAlign:"left",labelWidth:30},app:null,keyfieldName:null,getFormValue:function(){var b=[];var a=Tine.Tinebase.widgets.keyfield.StoreMgr.get(this.app.appName,this.keyfieldName);var c=this.getInnerForm().getForm().getValues();for(var d in c){if(c[d]==="on"&&a.getById(d)){b.push(d)}}return b},getItems:function(){var a=[];Tine.Tinebase.widgets.keyfield.StoreMgr.get(this.app.appName,this.keyfieldName).each(function(c){var b={xtype:"checkbox",boxLabel:c.get("i18nValue"),icon:c.get("icon"),name:c.get("id")};if(b.icon){b.boxLabel='<img src="'+c.get("icon")+'" class="tine-keyfield-icon"/>'+b.boxLabel}a.push(b)},this);return a},setValue:function(a){a=Ext.isArray(a)?a:[a];var b=[];this.currentValue=[];Tine.Tinebase.widgets.keyfield.StoreMgr.get(this.app.appName,this.keyfieldName).each(function(d){var f=d.get("id");var c=d.get("i18nValue");if(a.indexOf(f)>=0){b.push(c);this.currentValue.push(f)}},this);this.setRawValue(b.join(", "));return this},setFormValue:function(a){this.getInnerForm().getForm().items.each(function(b){b.setValue(a.indexOf(b.name)>=0?"on":"off")},this)}});Ext.ns("Tine.widgets","Tine.widgets.tree");Tine.widgets.tree.Loader=Ext.extend(Ext.tree.TreeLoader,{displayLength:25,app:null,method:null,filter:null,url:"index.php",createNode:function(){this.inspectCreateNode.apply(this,arguments);return Tine.widgets.tree.Loader.superclass.createNode.apply(this,arguments)},getParams:function(a){return{method:this.method,filter:this.filter}},inspectCreateNode:Ext.EmptyFn,processResponse:function(a,c,f,b){var d=a.responseData||Ext.decode(a.responseText);if(d.totalcount){a.responseData=d.results}return Tine.widgets.tree.Loader.superclass.processResponse.apply(this,arguments)}});Ext.ns("Tine.widgets","Tine.widgets.tree");Tine.widgets.tree.ContextMenu={getMenu:function(b){this.config=b;this.action_add=new Ext.Action({text:String.format(_("Add {0}"),this.config.nodeName),iconCls:"action_add",handler:this.addNode,requiredGrant:"addGrant",scope:this.config});this.action_rename=new Ext.Action({text:String.format(_("Rename {0}"),this.config.nodeName),iconCls:"action_rename",handler:this.renameNode,scope:this.config,requiredGrant:"editGrant",allowMultiple:false});this.action_delete=new Ext.Action({text:String.format(Tine.Tinebase.translation.ngettext("Delete {0}","Delete {0}",1),this.config.nodeName),iconCls:"action_delete",handler:this.deleteNode,scope:this.config,requiredGrant:"deleteGrant",allowMultiple:true});this.action_grants=new Ext.Action({text:String.format(_("Manage {0} Permissions"),this.config.nodeName),iconCls:"action_managePermissions",handler:this.managePermissions,requiredGrant:"editGrant",scope:this.config});this.action_properties=new Ext.Action({text:String.format(_("{0} Properties"),this.config.nodeName),iconCls:"action_manageProperties",handler:this.manageProperties,requiredGrant:"readGrant",scope:this.config});this.action_changecolor=new Ext.Action({text:String.format(_("Set {0} color"),this.config.nodeName),iconCls:"action_changecolor",allowMultiple:true,menu:new Ext.menu.ColorMenu({scope:this,listeners:{select:this.changeNodeColor,scope:this.config}})});this.action_reload=new Ext.Action({text:String.format(_("Reload {0}"),this.config.nodeName),iconCls:"x-tbar-loading",handler:this.reloadNode,scope:this.config});this.action_resume=new Ext.Action({text:String.format(_("Resume upload"),b.nodeName),iconCls:"action_resume",handler:this.onResume,scope:this.config,actionUpdater:this.isResumeEnabled});this.action_editFile=new Ext.Action({requiredGrant:"editGrant",allowMultiple:false,text:_("Edit Properties"),handler:this.onEditFile,iconCls:"action_edit_file",actionType:"edit",scope:this});this.action_pause=new Ext.Action({text:String.format(_("Pause upload"),b.nodeName),iconCls:"action_pause",handler:this.onPause,actionUpdater:this.isPauseEnabled,scope:this.config});this.action_download=new Ext.Action({text:String.format(_("Download"),b.nodeName),iconCls:"action_filemanager_save_all",handler:this.downloadFile,actionUpdater:this.isDownloadEnabled,scope:this.config});var a=[];for(var c=0;c<b.actions.length;c++){switch(b.actions[c]){case"add":a.push(this.action_add);break;case"delete":a.push(this.action_delete);break;case"rename":a.push(this.action_rename);break;case"properties":a.push(this.action_properties);break;case"changecolor":a.push(this.action_changecolor);break;case"grants":a.push(this.action_grants);break;case"reload":a.push(this.action_reload);break;case"resume":a.push(this.action_resume);break;case"pause":a.push(this.action_pause);break;case"download":a.push(this.action_download);break;case"edit":a.push(this.action_editFile);break;default:a.push(new Ext.Action(b.actions[c]))}}return new Ext.menu.Menu({items:a})},addNode:function(){Ext.MessageBox.prompt(String.format(_("New {0}"),this.nodeName),String.format(_("Please enter the name of the new {0}:"),this.nodeName),function(c,d){if(this.scope.ctxNode&&c=="ok"){if(!d){Ext.Msg.alert(String.format(_("No {0} added"),this.nodeName),String.format(_("You have to supply a {0} name!"),this.nodeName));return}Ext.MessageBox.wait(_("Please wait"),String.format(_("Creating {0}..."),this.nodeName));var a=this.scope.ctxNode;var f={method:this.backend+".add"+this.backendModel,name:d};if(this.backendModel=="Node"){f.application=this.scope.app.appName||this.scope.appName;var b=a.attributes.nodeRecord.data.path+"/"+d;f.filename=b;f.type="folder";f.method=this.backend+".createNode"}else{if(this.backendModel=="Container"){f.application=this.scope.app.appName||this.scope.appName;f.containerType=Tine.Tinebase.container.path2type(a.attributes.path);f.modelName=this.scope.app.getMainScreen().getActiveContentType()}else{if(this.backendModel=="Folder"){var g=Tine.Tinebase.appMgr.get("Felamimail").getFolderStore().getById(a.attributes.folder_id);f.parent=g.get("globalname");f.accountId=g.get("account_id")}}}Ext.Ajax.request({params:f,scope:this,success:function(h,l){var j=Ext.util.JSON.decode(h.responseText);if(j.type=="folder"){var j=Ext.util.JSON.decode(h.responseText);var m=Tine.Tinebase.appMgr.get(this.scope.app.appName);var k=m.getMainScreen().getWestPanel().getContainerTreePanel().createTreeNode(j,a);a.appendChild(k)}else{var k=this.scope.loader.createNode(j);a.appendChild(k)}a.expand();this.scope.fireEvent("containeradd",j);Ext.MessageBox.hide()},failure:function(h,l){var j=Ext.util.JSON.decode(h.responseText);var k=Tine[this.scope.app.appName];if(k&&k.handleRequestException){k.handleRequestException(j.data)}}})}},this)},renameNode:function(){if(this.scope.ctxNode){var a=this.scope.ctxNode;Ext.MessageBox.show({title:String.format(_("Rename {0}"),this.nodeName),msg:String.format(_("Please enter the new name of the {0}:"),this.nodeName),buttons:Ext.MessageBox.OKCANCEL,value:a.text,fn:function(f,h){if(f=="ok"){if(!h){Ext.Msg.alert(String.format(_("Not renamed {0}"),this.nodeName),String.format(_("You have to supply a {0} name!"),this.nodeName));return}var k={method:this.backend+".rename"+this.backendModel,newName:h};k.application=this.scope.app.appName||this.scope.appName;if(this.backendModel=="Node"){var c=a.attributes.path;k.sourceFilenames=[c];var j="/";var b=c.split("/");for(var d=1;d<b.length-1;d++){j+=b[d]+"/"}k.destinationFilenames=[j+h];k.method=this.backend+".moveNodes"}if(this.backendModel=="Container"){k.containerId=a.attributes.container.id}else{if(this.backendModel=="Folder"){var g=Tine.Tinebase.appMgr.get("Felamimail").getFolderStore().getById(a.attributes.folder_id);k.oldGlobalName=g.get("globalname");k.accountId=g.get("account_id")}}Ext.Ajax.request({params:k,scope:this,success:function(o,m){var l=Ext.util.JSON.decode(o.responseText);a.setText(h);this.scope.fireEvent("containerrename",l,a,h)},failure:function(l,q){var m=Ext.util.JSON.decode(l.responseText);var o=Tine[this.scope.app.appName];if(o&&o.handleRequestException){o.handleRequestException(m.data)}}})}},scope:this,prompt:true,icon:Ext.MessageBox.QUESTION})}},deleteNode:function(){if(this.scope.ctxNode){var a=this.scope.ctxNode;Tine.log.debug("Tine.widgets.tree.ContextMenu::deleteNode()");Tine.log.debug(a);Ext.MessageBox.confirm(_("Confirm"),String.format(_('Do you really want to delete the {0} "{1}"?'),this.nodeName,a.text),function(b){if(b=="yes"){var f={method:this.backend+".delete"+this.backendModel};if(this.backendModel=="Node"){var d=[a.attributes.path];f.application=this.scope.app.appName||this.scope.appName;f.filenames=d;f.method=this.backend+".deleteNodes"}else{if(this.backendModel=="Container"){f.containerId=a.attributes.container.id}else{if(this.backendModel=="Folder"){var c=Tine.Tinebase.appMgr.get("Felamimail").getFolderStore().getById(a.attributes.folder_id);f.folder=c.get("globalname");f.accountId=c.get("account_id")}else{f.ids=[a.id];f.method=f.method+"s"}}}Ext.Ajax.request({params:f,scope:this,success:function(h,g){if(a){if(a.isSelected()){this.scope.getSelectionModel().select(a.parentNode);this.scope.fireEvent("click",a.parentNode,Ext.EventObject.setEvent())}a.remove();if(this.backendModel=="Container"){this.scope.fireEvent("containerdelete",a.attributes.container)}else{if(this.backendModel=="Node"){this.scope.fireEvent("containerdelete",a)}else{this.scope.fireEvent("containerdelete",a.attributes)}}}},failure:function(g,k){var h=Ext.util.JSON.decode(g.responseText);var j=Tine[this.scope.app.appName];if(j&&j.handleRequestException){j.handleRequestException(h.data)}}})}},this)}},changeNodeColor:function(c,a){if(this.scope.ctxNode){var b=this.scope.ctxNode;b.getUI().addClass("x-tree-node-loading");Ext.Ajax.request({params:{method:this.backend+".set"+this.backendModel+"Color",containerId:b.attributes.container.id,color:"#"+a},scope:this,success:function(g,f){var d=Ext.util.JSON.decode(g.responseText);b.getUI().colorNode.setStyle({color:d.color});b.attributes.color=d.color;this.scope.fireEvent("containercolorset",d);b.getUI().removeClass("x-tree-node-loading")},failure:function(d,h){var f=Ext.util.JSON.decode(d.responseText);var g=Tine[this.scope.app.appName];if(g&&g.handleRequestException){g.handleRequestException(f.data)}}})}},managePermissions:function(){if(this.scope.ctxNode){var b=this.scope.ctxNode,c;if(b.attributes.nodeRecord&&b.attributes.nodeRecord.data.name){c=b.attributes.nodeRecord.data.name}else{if(b.attributes.container){c=b.attributes.container}}var a=Tine.widgets.container.GrantsDialog.openWindow({title:String.format(_('Manage Permissions for {0} "{1}"'),this.nodeName,Ext.util.Format.htmlEncode(c.name)),containerName:this.nodeName,grantContainer:c,app:this.scope.app.appName})}},manageProperties:function(){if(this.scope.ctxNode){var b=this.scope.ctxNode,c;if(b.attributes.nodeRecord&&b.attributes.nodeRecord.data.name){c=b.attributes.nodeRecord.data.name}else{if(b.attributes.container){c=b.attributes.container}}var a=Tine.widgets.container.PropertiesDialog.openWindow({title:String.format(_('Properties for {0} "{1}"'),this.nodeName,Ext.util.Format.htmlEncode(c.name)),containerName:this.nodeName,grantContainer:c,app:this.scope.app.appName})}},reloadNode:function(){if(this.scope.ctxNode){var a=this.scope;this.scope.ctxNode.reload(function(b){b.expand();b.select();a.filterPlugin.onFilterChange()})}}};Ext.ns("Tine.widgets","Tine.widgets.tree");Tine.widgets.tree.FilterPlugin=Ext.extend(Tine.widgets.grid.FilterPlugin,{treePanel:null,field:"container_id",nodeAttributeField:"container",singleNodeOperator:"equals",selectNodes:true,getFilter:function(){var c={field:this.field},f=this.treePanel.getSelectionModel(),d=typeof f.getSelectedNodes=="function",b=d?f.getSelectedNodes():[f.getSelectedNode()];c.operator=d?"in":this.singleNodeOperator;var a=[];Ext.each(b,function(g){if(g){a.push(g.attributes[this.nodeAttributeField])}},this);c.value=Ext.isEmpty(a)?"":c.operator==="in"?a:a[0];return c},getValue:function(){if(this.treePanel.filterMode!=="gridFilter"){return null}return this.getFilter()},setValue:function(a){if(!this.selectNodes){return null}var b=this.treePanel.getSelectionModel();b.clearSelections(true);Ext.each(a,function(c){if(c.condition&&c.condition=="OR"){a=c.filters[0].filters;return false}},this);Ext.each(a,function(c){if(c.field!==this.field||Ext.isEmpty(c.value)){return}this.lastFocusEl=document.activeElement;if(this.treePanel.app.getMainScreen().getWestPanel().body){this.leftPanelScrollTop=this.treePanel.app.getMainScreen().getWestPanel().body.getScroll().top}this.treePanel.getSelectionModel().suspendEvents();this.selectValue(c.value)},this)},selectValue:function(b){var a=Ext.isArray(b)?b:[b];Ext.each(a,function(d,c){if(Ext.isString(d)&&!d.path){d=a[c]={path:d}}var f=this.treePanel.getTreePath(d.path);this.selectPath.call(this.treePanel,f,null,function(){d.isExpanded=true;var g=true;Ext.each(a,function(h){g&=h.isExpanded},this);if(g){this.treePanel.getSelectionModel().resumeEvents();(function(){try{if(this.lastFocusEl){var h=Ext.fly(this.lastFocusEl).up("div[class$=-scroller]"),k=h?h.dom.scrollTop:null;if(!Ext.isIE){Ext.fly(this.lastFocusEl).focus()}if(k){h.dom.scrollTop=k}}if(this.leftPanelScrollTop){this.treePanel.app.getMainScreen().getWestPanel().body.dom.scrollTop=this.leftPanelScrollTop}}catch(j){}}).defer(10,this)}}.createDelegate(this),true)},this)},selectPath:function(h,a,j,c){a=a||"id";var d=h.split(this.pathSeparator),b=d.pop();if(d.length>1){var g=function(k,f){if(k&&f){var l=f.findChild(a,b)||f.findChild("path",f.attributes.path+"/"+b);if(l){l.getOwnerTree().getSelectionModel().select(l,false,c);if(j){j(true,l)}}else{if(j){j(false,l)}}}else{if(j){j(false,l)}}};this.expandPath(d.join(this.pathSeparator),a,g)}else{this.root.select();if(j){j(true,this.root)}}}});Ext.ns("Tine.widgets","Tine.widgets.customfields");Tine.widgets.customfields.ConfigManager=function(){var b={};var c=function(f){f=Tine.Tinebase.appMgr.get(f);if(!b[f.appName]){var d=(Ext.isFunction(f.getRegistry))?f.getRegistry().get("customfields"):null;b[f.appName]=new Ext.data.JsonStore({fields:Tine.Tinebase.Model.Customfield,data:d?d:[]});b[f.appName].each(function(k){var j=k.get("definition"),g=j.options?j.options:{},h=j.keyFieldConfig?j.keyFieldConfig:null;if(h){f.getRegistry().get("config")[k.get("name")]=h}})}return b[f.appName]};var a=function(f){var d=f.get("definition");return new Ext.data.Field(Ext.apply({name:"#"+f.get("name")},d))};return{getConfig:function(h,g,f,k){var d=c(h),j=null;d.clearFilter(true);d.filter("model",g);j=d.findExact("name",f);j=j>-1?d.getAt(j):null;d.clearFilter(true);return k?a(j):j},getConfigs:function(j,g,f){if(Ext.isFunction(g.getMeta)){g=g.getMeta("appName")+"_Model_"+g.getMeta("modelName")}var d=c(j),h=[];d.clearFilter(true);d.filter("model",g);d.each(function(k){h.push(k)});d.clearFilter(true);if(f){Ext.each(h,function(l,k){h[k]=a(l)},this)}return h}}}();Ext.ns("Tine.widgets.customfields");Tine.widgets.customfields.Field={get:function(app,cfConfig,config,editDialog){Tine.log.debug(cfConfig);var def=cfConfig.get("definition"),uiConfig=def&&def.uiconfig?def.uiconfig:{},fieldDef={fieldLabel:def.label,name:"customfield_"+cfConfig.get("name"),xtype:(def.value_search==1)?"customfieldsearchcombo":uiConfig.xtype,customfieldId:cfConfig.id,readOnly:cfConfig.get("account_grants").indexOf("writeGrant")<0};if(!uiConfig.xtype&&def.type&&!def.value_search){switch(Ext.util.Format.lowercase(def.type)){case"keyfield":var options=def.options?def.options:{},keyFieldConfig=def.keyFieldConfig?def.keyFieldConfig:null;Ext.apply(fieldDef,{xtype:"widget-keyfieldcombo",app:options.app?options.app:app,keyFieldName:options.keyFieldName?options.keyFieldName:cfConfig.get("name"),sortBy:"id"});break;case"record":var options=def.options?def.options:{},recordConfig=def.recordConfig?def.recordConfig:null;Ext.apply(fieldDef,{xtype:"tinerecordpickercombobox",app:options.app?options.app:app,resizable:true,recordClass:eval(recordConfig.value.records),allowLinkingItself:false,editDialog:editDialog});break;case"integer":case"int":fieldDef.xtype="numberfield";break;case"date":fieldDef.xtype="datefield";fieldDef.listAlign="tr-br?";break;case"time":fieldDef.xtype="timefield";fieldDef.listAlign="tr-br?";break;case"datetime":fieldDef.xtype="datetimefield";fieldDef.listAlign="tr-br?";break;case"boolean":case"bool":fieldDef.xtype="checkbox";break;case"string":default:fieldDef.xtype="textfield";break}}if(def.length){fieldDef.maxLength=def.length}if(def.required){fieldDef.allowBlank=false}try{var fieldObj=Ext.ComponentMgr.create(Ext.apply(fieldDef,config));return fieldObj}catch(e){Tine.log.debug(e);Tine.log.err('Unable to create custom field "'+cfConfig.get("name")+'". Check definition!')}}};Ext.ns("Tine.widgets","Tine.widgets.customfields");Tine.widgets.customfields.FilterModel=Ext.extend(Tine.widgets.grid.FilterModel,{app:null,cfConfig:null,valueType:"customfield",initComponent:function(){this.field="customfield:"+this.cfConfig.id;this.cfDefinition=this.cfConfig.get("definition");this.label=this.cfDefinition.label;switch(this.cfDefinition.type){case"record":case"keyField":this.operators=["equals","not"];this.defaultOperator="equals";this.valueRenderer=this.cfValueRenderer;break;case"bool":case"boolean":this.valueType="bool";this.defaultOperator="equals";this.defaultValue="0";break;case"date":case"datetime":this.valueType="date";this.defaultOperator="within"}Tine.widgets.customfields.FilterModel.superclass.initComponent.call(this)},cfValueRenderer:function(b,a){var c=Tine.widgets.customfields.Field.get(this.app,this.cfConfig,{filter:b,width:200,id:"tw-ftb-frow-valuefield-"+b.id,value:b.data.value?b.data.value:this.defaultValue,renderTo:a});c.on("specialkey",function(f,d){if(d.getKey()==d.ENTER){this.onFiltertrigger()}},this);return c}});Tine.widgets.grid.FilterToolbar.FILTERS["tinebase.customfield"]=Tine.widgets.customfields.FilterModel;Ext.ns("Tine.widgets.customfields");Tine.widgets.customfields.Renderer=function(){var renderers={};return{get:function(app,cfConfig,what){var appName=Ext.isString(app)?app:app.appName,app=Tine.Tinebase.appMgr.get(appName),cfDefinition=cfConfig.get("definition"),cfName=cfConfig.get("name"),what=what?what:"text|icon",whatParts=what.split("|"),key=appName+cfConfig.id+what;if(!renderers[key]){if(["keyfield"].indexOf(Ext.util.Format.lowercase(cfDefinition.type))>-1){var app=cfDefinition.options&&Ext.isString(cfDefinition.options.app)?cfDefinition.options.app:app;var keyFieldName=cfDefinition.options&&Ext.isString(cfDefinition.options.keyFieldName)?cfDefinition.options.keyFieldName:cfName;renderers[key]=function(customfields){return Tine.Tinebase.widgets.keyfield.Renderer.render(app,keyFieldName,customfields[cfName])}}else{if(["record"].indexOf(Ext.util.Format.lowercase(cfDefinition.type))>-1){renderers[key]=function(customfields){var recordClass=eval(cfDefinition.recordConfig.value.records);return Ext.isObject(customfields[cfName])&&customfields[cfName].hasOwnProperty(recordClass.getMeta("titleProperty"))?customfields[cfName][recordClass.getMeta("titleProperty")]:customfields[cfName]}}else{renderers[key]=function(customfields){switch(cfDefinition.type){case"date":return Tine.Tinebase.common.dateRenderer(customfields[cfName]);case"datetime":return Tine.Tinebase.common.dateTimeRenderer(customfields[cfName]);case"time":return Tine.Tinebase.common.timeRenderer(customfields[cfName]);case"boolean":return Tine.Tinebase.common.booleanRenderer(customfields[cfName]);default:return Ext.util.Format.htmlEncode(customfields[cfName])}}}}}return renderers[key]},render:function(app,cfConfig,id){var renderer=this.get(app,cfConfig);return renderer(id)},register:function(app,cfConfig,renderer){var appName=Ext.isString(app)?app:app.appName,cfDefinition=cfConfig.get("definition"),cfName=cfConfig.get("name"),key=appName+cfConfig.id;renderers[key]=renderer}}}();Ext.ns("Tine.widgets","Tine.widgets.customfields");Tine.widgets.customfields.CustomfieldSearchCombo=Ext.extend(Ext.form.ComboBox,{customfieldId:null,forceSelection:false,triggerAction:"all",minChars:1,pageSize:10,displayField:"value",valueField:"value",enableKeyEvents:true,initComponent:function(){this.store=new Ext.data.JsonStore({fields:Tine.Tinebase.Model.CustomfieldValue,baseParams:{method:"Tinebase.searchCustomFieldValues",sort:"value",dir:"ASC"},root:"results",totalProperty:"totalcount"});this.on("beforequery",this.onBeforeQuery,this);this.on("keypress",this.syncValues,this,{buffer:500});Tine.widgets.customfields.CustomfieldSearchCombo.superclass.initComponent.call(this)},onBeforeLoad:function(a,b){b.params.paging={start:b.params.start,limit:b.params.limit}},syncValues:function(){var a=this.getRawValue();this.setValue(a)},onBeforeQuery:function(a){this.store.baseParams.filter=[{field:"customfield_id",operator:"equals",value:this.customfieldId},{field:"value",operator:"group",value:""},{field:"value",operator:"contains",value:a.query}]}});Ext.reg("customfieldsearchcombo",Tine.widgets.customfields.CustomfieldSearchCombo);Ext.ns("Tine.widgets.customfields");Tine.widgets.customfields.EditDialogPlugin=function(a){Ext.apply(this,a)};Tine.widgets.customfields.EditDialogPlugin.prototype={app:null,editDialog:null,init:function(a){this.editDialog=a;if(!this.editDialog.recordClass){return}this.app=Tine.Tinebase.appMgr.get(this.editDialog.app);this.customfieldsValue=[];this.editDialog.on("beforerender",this.onBeforeRender,this);this.editDialog.on("load",this.onRecordLoad,this);this.editDialog.onRecordUpdate=this.editDialog.onRecordUpdate.createSequence(this.onRecordUpdate,this)},onRecordLoad:function(){var g=this.editDialog.getForm(),b=this.editDialog.recordClass.getMeta("appName")+"_Model_"+this.editDialog.recordClass.getMeta("modelName"),d,h,j;this.customfieldsValue=this.editDialog.record.get("customfields")||{};for(d in this.customfieldsValue){h=g.findField("customfield_"+d);j=Tine.widgets.customfields.ConfigManager.getConfig(this.app,b,d);if(j){if(["date","datetime"].indexOf(Ext.util.Format.lowercase(j.get("definition").type))!=-1){this.customfieldsValue[d]=Date.parseDate(this.customfieldsValue[d],Date.patterns.ISO8601Long)}if(h){if(h.isXType("combo")&&Ext.isObject(this.customfieldsValue[d])){var c=j.get("model").split("_"),f=Tine[c[0]].Model[c[2]],a=new f(this.customfieldsValue[d]);h.setValue(a.getId());h.selectedRecord=a.data}else{h.setValue(this.customfieldsValue[d])}}}}},onRecordUpdate:function(){var a=this.editDialog.getForm();a.items.each(function(c){var b=c.getName();if(b.match(/^customfield_(.+)$/)){b=b.match(/^customfield_(.+)$/)[1];this.customfieldsValue[b]=c.getValue()}},this);this.customfieldsValue.toString=function(){return Ext.util.JSON.encode(this.customfieldsValue)};this.editDialog.record.set("customfields",this.customfieldsValue)},onBeforeRender:function(){var a=this.editDialog.recordClass.getMeta("appName")+"_Model_"+this.editDialog.recordClass.getMeta("modelName"),d=Tine.widgets.customfields.ConfigManager.getConfigs(this.app,a),b=this.editDialog.getForm(),c=new Ext.util.MixedCollection();Ext.each(d,function(f){if(!b.findField("customfield_"+f.get("name"))){c.add(f.id,f)}},this);if(c.getCount()){this.addCFTab(c)}},addCFTab:function(g){this.cfTabItems=[];this.fieldsets={};g.sort("ASC",function(j,h){var l=(j.get("definition").uiconfig&&j.get("definition").uiconfig.order)?j.get("definition").uiconfig.order:0,k=(h.get("definition").uiconfig&&h.get("definition").uiconfig.order)?h.get("definition").uiconfig.order:0;return l>k?1:0});var b=null,c=null,a=null,d=null;g.each(function(j){try{b=j.get("definition");c=Tine.widgets.customfields.Field.get(this.app,j,{anchor:"95%"},this.editDialog);a=b.uiconfig?b.uiconfig:{};d=a.group?a.group:_("General");Tine.log.debug("Tine.widgets.customfields.EditDialogPlugin::addCFTab() - Adding "+j.get("name")+" to group "+d);this.getFieldSet(d).add(c)}catch(h){Tine.log.debug(h);Tine.log.err('Unable to create custom field "'+j.get("name")+'". Check definition!')}},this);this.cfTab=new Ext.Panel({title:_("Custom Fields"),layout:"form",border:true,frame:true,labelAlign:"top",autoScroll:true,items:this.cfTabItems,defaults:{anchor:"100%",labelSeparator:""}});var f=this.editDialog.items.find(function(h){return Ext.isObject(h)&&Ext.isFunction(h.getXType)&&h.getXType()=="tabpanel"});if(f){f.add(this.cfTab)}},getFieldSet:function(b){var c=/\s+/;var a=b.replace(c,"_");if(!this.fieldsets[a]){this.fieldsets[a]=new Ext.form.FieldSet({title:b,autoHeight:true,autoWidth:true,labelAlign:"top",labelWidth:"90%",collapsible:true,name:a,id:Ext.id()+a});this.cfTabItems.push(this.fieldsets[a])}return this.fieldsets[a]}};Ext.preg("tinebase.widgets.customfield.editdialogplugin",Tine.widgets.customfields.EditDialogPlugin);Ext.ns("Tine.widgets","Tine.widgets.customfields");Tine.widgets.customfields.CustomfieldsCombo=Ext.extend(Ext.form.ComboBox,{typeAhead:false,forceSelection:true,mode:"local",triggerAction:"all",initComponent:function(){Tine.widgets.customfields.CustomfieldsCombo.superclass.initComponent.call(this)},stateEvents:["select"],getState:function(){return this.getValue()},applyState:function(a){this.setValue(a)}});Ext.ns("Tine.widgets","Tine.widgets.relation");Tine.widgets.relation.FilterModel=Ext.extend(Tine.widgets.grid.FilterModel,{app:null,valueType:"relation",field:"relation",initComponent:function(){this.label=_("Relation");var a=[];Tine.Tinebase.data.RecordMgr.eachKey(function(c,b){if(b.hasField("relations")&&Ext.isFunction(b.getFilterModel)){var d=Tine.Tinebase.appMgr.get(b.getMeta("appName")).i18n._hidden(b.getMeta("recordsName"));a.push({operator:c,label:d})}},this);this.relatedModelStore=this.fieldStore=new Ext.data.JsonStore({fields:["operator","label"],data:a});this.defaultOperator=this.relatedModelStore.getAt(0).get("operator");Tine.widgets.relation.FilterModel.superclass.initComponent.call(this)},onDefineRelatedRecord:function(b){var a=b.formFields.operator.getValue();console.log(a);console.log(Tine.Tinebase.data.RecordMgr.get(a));if(!b.sheet){b.sheet=new Tine.widgets.grid.FilterToolbar({recordClass:Tine.Tinebase.data.RecordMgr.get(a),defaultFilter:"query"});this.ftb.addFilterSheet(b.sheet)}this.ftb.setActiveSheet(b.sheet);b.formFields.value.setText(_("Defined by ..."))},operatorRenderer:function(c,b){var a=new Ext.form.ComboBox({filter:c,width:80,id:"tw-ftb-frow-operatorcombo-"+c.id,mode:"local",lazyInit:false,emptyText:_("select a operator"),forceSelection:true,typeAhead:true,triggerAction:"all",store:this.relatedModelStore,displayField:"label",valueField:"operator",value:c.get("operator")?c.get("operator"):this.defaultOperator,renderTo:b});a.on("select",function(f,d,g){if(f.value!=f.filter.get("operator")){this.onOperatorChange(f.filter,f.value)}},this);return a},valueRenderer:function(b,a){var c=new Ext.Button({text:_("Define ..."),filter:b,width:this.filterValueWidth,id:"tw-ftb-frow-valuefield-"+b.id,renderTo:a,value:b.data.value?b.data.value:this.defaultValue,handler:this.onDefineRelatedRecord.createDelegate(this,[b]),scope:this,getValue:function(){}});a.addClass("x-btn-over");return c}});Tine.widgets.grid.FilterToolbar.FILTERS["tinebase.relation"]=Tine.widgets.relation.FilterModel;Ext.ns("Tine.widgets.account");Tine.widgets.account.PickerGridPanel=Ext.extend(Tine.widgets.grid.PickerGridPanel,{selectType:"user",selectTypeDefault:"user",selectAnyone:true,showHidden:false,userStatus:"enabled",hasAccountPrefix:false,recordPrefix:"",autoExpandColumn:"name",initComponent:function(){this.recordPrefix=(this.hasAccountPrefix)?"account_":"";this.recordClass=this.recordClass||Tine.Tinebase.Model.Account;this.groupRecordClass=this.groupRecordClass||Tine.Addressbook.Model.List;Tine.widgets.account.PickerGridPanel.superclass.initComponent.call(this);this.store.sort(this.recordPrefix+"name")},initTbar:function(){this.accountTypeSelector=this.getAccountTypeSelector();this.contactSearchCombo=this.getContactSearchCombo();this.groupSearchCombo=this.getGroupSearchCombo();var a=[];switch(this.selectType){case"both":a=a.concat([this.contactSearchCombo,this.groupSearchCombo]);if(this.selectTypeDefault==="user"){this.groupSearchCombo.hide()}else{this.contactSearchCombo.hide()}break;case"user":a=this.contactSearchCombo;break;case"group":a=this.groupSearchCombo;break}this.comboPanel=new Ext.Panel({layout:"hfit",border:false,items:a,columnWidth:1});this.tbar=new Ext.Toolbar({items:[this.accountTypeSelector,this.comboPanel],layout:"column"})},getAccountTypeSelector:function(){var a={text:_("Search User"),scope:this,iconCls:"tinebase-accounttype-user",handler:this.onSwitchCombo.createDelegate(this,["contact","tinebase-accounttype-user"])};var d={text:_("Search Group"),scope:this,iconCls:"tinebase-accounttype-group",handler:this.onSwitchCombo.createDelegate(this,["group","tinebase-accounttype-group"])};var c={text:_("Add Anyone"),scope:this,iconCls:"tinebase-accounttype-addanyone",handler:this.onAddAnyone};var b=[];switch(this.selectType){case"both":b=b.concat([a,d]);if(this.selectAnyone){b.push(c)}break;case"user":b=a;break;case"group":b=d;break}return new Ext.Action({width:20,text:"",disabled:false,iconCls:(this.selectTypeDefault==="user")?"tinebase-accounttype-user":"tinebase-accounttype-group",menu:new Ext.menu.Menu({items:b}),scope:this})},onAddAnyone:function(){var b=(this.recordDefaults!==null)?this.recordDefaults:{};b[this.recordPrefix+"type"]="anyone";b[this.recordPrefix+"name"]=_("Anyone");b[this.recordPrefix+"id"]=0;var a=new this.recordClass(b,0);if(!this.store.getById(a.id)){this.store.add([a])}},getContactSearchCombo:function(){return new Tine.Addressbook.SearchCombo({accountsStore:this.store,emptyText:_("Search for users ..."),newRecordClass:this.recordClass,newRecordDefaults:this.recordDefaults,recordPrefix:this.recordPrefix,userOnly:true,onSelect:this.onAddRecordFromCombo,additionalFilters:(this.showHidden)?[{field:"showDisabled",operator:"equals",value:true}]:[]})},getGroupSearchCombo:function(){return new Tine.Tinebase.widgets.form.RecordPickerComboBox({accountsStore:this.store,blurOnSelect:true,recordClass:this.groupRecordClass,newRecordClass:this.recordClass,newRecordDefaults:this.recordDefaults,recordPrefix:this.recordPrefix,emptyText:_("Search for groups ..."),onSelect:this.onAddRecordFromCombo})},getColumnModel:function(){return new Ext.grid.ColumnModel({defaults:{sortable:true},columns:[{id:"name",header:_("Name"),dataIndex:this.recordPrefix+"name",renderer:Tine.Tinebase.common.accountRenderer}].concat(this.configColumns)})},onAddRecordFromCombo:function(c){var b={},a;if(c.data.account_id){b[this.recordPrefix+"id"]=c.data.account_id;b[this.recordPrefix+"type"]="user";b[this.recordPrefix+"name"]=c.data.n_fileas;b[this.recordPrefix+"data"]=c.data;a=new this.newRecordClass(Ext.applyIf(b,this.newRecordDefaults),c.data.account_id)}else{if(c.data.group_id||c.data.id){b[this.recordPrefix+"id"]=c.data.group_id||c.data.id;b[this.recordPrefix+"type"]="group";b[this.recordPrefix+"name"]=c.data.name;b[this.recordPrefix+"data"]=c.data;a=new this.newRecordClass(Ext.applyIf(b,this.newRecordDefaults),c.id)}}if(!this.accountsStore.getById(a.id)){this.accountsStore.add([a])}this.collapse();this.clearValue();this.reset()},onSwitchCombo:function(a,b){var d=(a==="contact")?this.contactSearchCombo:this.groupSearchCombo;var f=(a==="contact")?this.groupSearchCombo:this.contactSearchCombo;if(!d.isVisible()){var c=f.getWidth();f.hide();d.show();d.setWidth(c-1);d.setWidth(d.getWidth()+1);this.accountTypeSelector.setIconClass(b)}}});Ext.reg("tinerecordpickergrid",Tine.widgets.account.PickerGridPanel);Ext.ns("Tine.widgets","Tine.widgets.container");Tine.widgets.container.selectionComboBox=Ext.extend(Ext.form.ComboBox,{allowNodeSelect:false,defaultContainer:false,displayLength:25,selectedContainer:null,listWidth:400,containerName:"container",containersName:"containers",hideTrigger2:true,startPath:"/",recordClass:null,requiredGrants:null,requiredGrant:null,trigger2width:100,allowBlank:false,triggerAction:"all",forceAll:true,lazyInit:true,editable:false,clearFilterOnReset:false,stateful:true,stateEvents:["select"],mode:"local",valueField:"id",displayField:"name",hasFocusedSubPanels:null,initComponent:function(){if(this.stateful&&!this.stateId){if(!this.recordClass){this.stateful=false}else{this.stateId=this.recordClass.getMeta("appName")+"-tinebase-widgets-container-selectcombo-"+this.recordClass.getMeta("modelName")}}if(this.requiredGrant&&!this.requiredGrants){this.requiredGrants=[this.requiredGrant]}else{if(!this.requiredGrant&&!this.requiredGrants){this.requiredGrants=["readGrant","addGrant","editGrant"]}}this.on("beforestatesave",function(){return this.startPath==="/"},this);this.initStore();this.otherRecord=new Tine.Tinebase.Model.Container({id:"other",name:String.format(_("choose other {0}..."),this.containerName)},"other");this.store.add(this.otherRecord);this.emptyText=String.format(_("Select a {0}"),this.containerName);if(!this.hideTrigger2){if(this.triggerClass=="x-form-arrow-trigger"){this.triggerClass="x-form-arrow-trigger-rectangle"}this.triggerConfig={tag:"span",cls:"x-form-twin-triggers",cn:[{tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger "+this.triggerClass},{tag:"span",cls:"tw-containerselect-trigger2",cn:[{tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger tw-containerselect-trigger2-bg"},{tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger tw-containerselect-trigger2"},{tag:"div",style:{position:"absolute",top:0,left:"5px"}}]}]}}Tine.widgets.container.selectionComboBox.superclass.initComponent.call(this);if(this.defaultContainer){this.selectedContainer=this.defaultContainer;this.value=this.defaultContainer.name}this.on("blur",function(){if(this.hasFocusedSubPanels){return false}},this);this.on("beforequery",this.onBeforeQuery,this)},initStore:function(){var b=this.stateful?Ext.state.Manager.get(this.stateId):null;var a=b&&b.recentsData||[];this.store=new Ext.data.JsonStore({id:"id",data:a,remoteSort:false,fields:Tine.Tinebase.Model.Container,listeners:{beforeload:this.onBeforeLoad.createDelegate(this)}});this.setStoreFilter()},initTrigger:function(){if(!this.hideTrigger2){var b=this.trigger.first();var a=this.trigger.last();this.trigger2=a;b.on("click",this.onTriggerClick,this,{preventDefault:true});a.on("click",this.onTrigger2Click,this,{preventDefault:true});b.addClassOnOver("x-form-trigger-over");b.addClassOnClick("x-form-trigger-click");a.addClassOnOver("x-form-trigger-over");a.addClassOnClick("x-form-trigger-click")}else{Tine.widgets.container.selectionComboBox.superclass.initTrigger.call(this)}},manageRecents:function(b){b.set("dtselect",new Date().getTime());this.store.remove(this.otherRecord);this.store.clearFilter();this.store.sort("dtselect","DESC");var a=0;this.store.each(function(c){if(a<10){if(!c.get("is_container_node")){a+=1}return}this.store.remove(c)},this);this.setStoreFilter();this.store.add(this.otherRecord)},onBeforeLoad:function(a,b){b.params={method:"Tinebase_Container.getContainer",application:this.appName,containerType:Tine.Tinebase.container.TYPE_PERSONAL,owner:Tine.Tinebase.container.pathIsPersonalNode(this.startPath)}},onBeforeQuery:function(a){a.query=new Date().getTime();this.mode=Tine.Tinebase.container.pathIsPersonalNode(this.startPath)?"remote":"local";if(this.mode=="local"){this.onLoad();return false}},setStoreFilter:function(){this.store.clearFilter();this.store.sort("dtselect","DESC");var a=this.store.getAt(Math.max(this.store.getCount(),10)-1);var b=a?a.get("dtselect"):-1;this.store.filterBy(function(c){var d=(this.allowNodeSelect||!c.get("is_container_node"))&&c.get("dtselect")>b;return d},this)},setTrigger2Text:function(b){var a=this.trigger.last().last().update(b)},setTrigger2Disabled:function(a){if(a){this.trigger2.setOpacity(0.5);this.trigger2.un("click",this.onTrigger2Click,this,{preventDefault:true})}else{this.trigger2.setOpacity(1);this.trigger2.on("click",this.onTrigger2Click,this,{preventDefault:true})}},getTrigger2:function(){return this.trigger2},onTrigger2Click:Ext.emptyFn,onBlur:function(){if(!this.dlg){return Tine.widgets.container.selectionComboBox.superclass.onBlur.apply(this,arguments)}},onSelect:function(a,b){this.hasFocusedSubPanels=true;if(a==this.otherRecord){this.onChoseOther()}else{this.manageRecents(a);Tine.widgets.container.selectionComboBox.superclass.onSelect.apply(this,arguments)}},onChoseOther:function(){this.collapse();this.dlg=new Tine.widgets.container.selectionDialog({allowNodeSelect:this.allowNodeSelect,containerName:this.containerName,containersName:this.containersName,requiredGrants:this.requiredGrants,TriggerField:this})},getValue:function(){return(this.selectedContainer!==null)?this.selectedContainer.id:""},setValue:function(a){if(!a){return}if(a.hasOwnProperty("get")&&Ext.isFunction(a.get)){}else{if(this.store.getById(a)){a=this.store.getById(a)}else{if(a.path&&this.store.findExact("path",a.path)>=0){a=this.store.getAt(this.store.findExact("path",a.path))}else{if(a.path||a.id){if(a.path&&a.path===Tine.Tinebase.container.getMyNodePath()){a.name=null}a.name=a.name||Tine.Tinebase.container.path2name(a.path,this.containerName,this.containersName);a.id=a.id||a.path;a=new Tine.Tinebase.Model.Container(a,a.id);this.store.add(a)}else{return this}}}}a.set("is_container_node",!!!Tine.Tinebase.container.pathIsContainer(a.get("path")));this.selectedContainer=a.data;this.store.remove(this.otherRecord);this.store.add(this.otherRecord);Tine.widgets.container.selectionComboBox.superclass.setValue.call(this,a.id);if(a.account_grants){this.setDisabled(!a.account_grants.deleteGrant)}if(this.qtip){this.qtip.remove()}return a},reset:function(){this.supr().setValue(this.originalValue);this.supr().reset.call(this)},applyState:Ext.emptyFn,getState:function(){var a=[];this.store.clearFilter();this.store.remove(this.otherRecord);this.store.each(function(b){var c=Ext.copyTo({},b.data,Tine.Tinebase.Model.Container.getFieldNames());a.push(c)},this);this.setStoreFilter();this.store.add(this.otherRecord);return{recentsData:a}}});Ext.reg("tinewidgetscontainerselectcombo",Tine.widgets.container.selectionComboBox);Tine.widgets.form.RecordPickerManager.register("Tinebase","Container",Tine.widgets.container.selectionComboBox);Tine.widgets.container.selectionDialog=Ext.extend(Ext.Component,{allowNodeSelect:false,containerName:"container",containersName:"containers",title:null,windowHeight:400,win:null,tree:null,requiredGrants:["readGrant"],initComponent:function(){Tine.widgets.container.selectionDialog.superclass.initComponent.call(this);this.title=this.title?this.title:String.format(_("please select a {0}"),this.containerName);this.cancelAction=new Ext.Action({text:_("Cancel"),iconCls:"action_cancel",minWidth:70,handler:this.onCancel,scope:this});this.okAction=new Ext.Action({disabled:true,text:_("Ok"),iconCls:"action_saveAndClose",minWidth:70,handler:this.onOk,scope:this});if(Ext.getBody().getHeight(true)*0.7<this.windowHeight){this.windowHeight=Ext.getBody().getHeight(true)*0.7}this.tree=new Tine.widgets.container.TreePanel({allowMultiSelection:false,containerName:this.TriggerField.containerName,containersName:this.TriggerField.containersName,appName:this.TriggerField.appName,defaultContainer:this.TriggerField.defaultContainer,requiredGrants:this.requiredGrants});this.tree.on("click",this.onTreeNodeClick,this);this.tree.on("dblclick",this.onTreeNoceDblClick,this);this.win=Tine.WindowFactory.getWindow({title:this.title,closeAction:"close",modal:true,width:375,height:this.windowHeight,minWidth:375,minHeight:this.windowHeight,layout:"fit",plain:true,bodyStyle:"padding:5px;",buttonAlign:"right",buttons:[this.cancelAction,this.okAction],items:[this.tree]})},onTreeNodeClick:function(a){this.okAction.setDisabled(!(a.leaf||this.allowNodeSelect));if(!a.leaf){a.expand()}},onTreeNoceDblClick:function(a){if(!this.okAction.isDisabled()){this.onOk()}},onCancel:function(){this.onClose()},onClose:function(){this.win.close()},onOk:function(){var b=this.tree.getSelectionModel().getSelectedNode();if(b){this.TriggerField.hasFocusedSubPanels=false;var a=this.TriggerField.setValue(b.attributes.container);this.TriggerField.manageRecents(a);this.TriggerField.fireEvent("select",this.TriggerField,b.attributes.container);if(this.TriggerField.blurOnSelect){this.TriggerField.fireEvent("blur",this.TriggerField)}this.onClose()}}});Ext.ns("Tine.widgets","Tine.widgets.container");Tine.widgets.container.GrantsGrid=Ext.extend(Tine.widgets.account.PickerGridPanel,{grantContainer:null,alwaysShowAdminGrant:false,selectType:"both",selectTypeDefault:"group",hasAccountPrefix:true,recordClass:Tine.Tinebase.Model.Grant,readGrantTitle:"Read",readGrantDescription:"The grant to read records of this container",addGrantTitle:"Add",addGrantDescription:"The grant to add records to this container",editGrantTitle:"Edit",editGrantDescription:"The grant to edit records in this container",deleteGrantTitle:"Delete",deleteGrantDescription:"The grant to delete records in this container",exportGrantTitle:"Export",exportGrantDescription:"The grant to export records from this container",syncGrantTitle:"Sync",syncGrantDescription:"The grant to synchronise records with this container",adminGrantTitle:"Admin",adminGrantDescription:"The grant to administrate this container",freebusyGrantTitle:"Free Busy",freebusyGrantDescription:"The grant to access free busy information of events in this calendar",privateGrantTitle:"Private",privateGrantDescription:"The grant to access records marked as private in this container",initComponent:function(){this.initColumns();this.recordDefaults={readGrant:true,exportGrant:true,syncGrant:true};Tine.widgets.container.GrantsGrid.superclass.initComponent.call(this);this.getStore().on("update",this.onStoreUpdate,this);this.getStore().on("load",function(a){a.each(function(b){this.onStoreUpdate(a,b)},this)},this)},onStoreUpdate:function(c,a,b){if(this.alwaysShowAdminGrant||(this.grantContainer&&this.grantContainer.type=="shared")){if(a.get("adminGrant")){Ext.each(this.getColumnModel().columns,function(d,g){var f;if((f=d.dataIndex.match(/^([a-z]+)Grant$/))&&f[1]!="admin"){a.set(d.dataIndex,true)}},this)}else{}}},initColumns:function(){var b=["read","add","edit","delete","export","sync"];if(this.alwaysShowAdminGrant||(this.grantContainer&&this.grantContainer.type=="shared")){b.push("admin")}if(this.grantContainer){if(this.grantContainer.application_id&&this.grantContainer.application_id.name){var d=(this.grantContainer.application_id.name=="Calendar")}else{var a=Tine.Tinebase.appMgr.get("Calendar"),c=a?a.id:"none",d=this.grantContainer.application_id===c}if(this.grantContainer.type=="personal"&&d){b.push("freebusy")}if(this.grantContainer.type=="personal"&&this.grantContainer.capabilites_private){b.push("private")}}this.configColumns=[];Ext.each(b,function(f){this.configColumns.push(new Ext.ux.grid.CheckColumn({header:_(this[f+"GrantTitle"]),tooltip:_(this[f+"GrantDescription"]),dataIndex:f+"Grant",width:55}))},this)}});Ext.ns("Tine.widgets","Tine.widgets.container");Tine.widgets.container.GrantsDialog=Ext.extend(Tine.widgets.dialog.EditDialog,{grantContainer:null,containerName:null,grantsStore:null,windowNamePrefix:"ContainerGrantsWindow_",loadRecord:false,tbarItems:[],evalGrants:false,initComponent:function(){this.containerName=this.containerName?this.containerName:_("Folder");this.grantsStore=new Ext.data.JsonStore({baseParams:{method:"Tinebase_Container.getContainerGrants",containerId:this.grantContainer.id},root:"results",totalProperty:"totalcount",id:"account_id",fields:Tine.Tinebase.Model.Grant});this.grantsStore.load();Tine.widgets.container.GrantsDialog.superclass.initComponent.call(this)},initRecord:function(){},getFormItems:function(){this.grantsGrid=new Tine.widgets.container.GrantsGrid({store:this.grantsStore,grantContainer:this.grantContainer});return this.grantsGrid},onApplyChanges:function(b){Ext.MessageBox.wait(_("Please wait"),_("Updating Grants"));var a=[];this.grantsStore.each(function(c){a.push(c.data)});Ext.Ajax.request({params:{method:"Tinebase_Container.setContainerGrants",containerId:this.grantContainer.id,grants:a},scope:this,success:function(f,d){Ext.MessageBox.hide();if(b){this.purgeListeners();this.window.close();return}var c=Ext.util.JSON.decode(f.responseText);this.grantsStore.loadData(c,false)},failure:function(c,d){var g=Ext.util.JSON.decode(c.responseText);if(g.data.code==505){Ext.Msg.show({title:_("Error"),msg:_("You are not allowed to remove all admins for this container!"),icon:Ext.MessageBox.ERROR,buttons:Ext.Msg.OK})}else{var f=g.data?g.data:g;Tine.Tinebase.ExceptionHandler.handleRequestException(f)}}})}});Tine.widgets.container.GrantsDialog.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:700,height:450,name:Tine.widgets.container.GrantsDialog.windowNamePrefix+Ext.id(),contentPanelConstructor:"Tine.widgets.container.GrantsDialog",contentPanelConstructorConfig:a,modal:true});return b};Ext.ns("Tine.widgets","Tine.widgets.container");Tine.widgets.container.TreePanel=function(a){Ext.apply(this,a);this.addEvents("containeradd","containerdelete","containerrename","containerpermissionchange","containercolorset");Tine.widgets.container.TreePanel.superclass.constructor.call(this)};Ext.extend(Tine.widgets.container.TreePanel,Ext.tree.TreePanel,{app:null,allowMultiSelection:true,defaultContainerPath:null,extraItems:null,filterMode:"gridFilter",recordClass:null,requiredGrants:null,useContainerColor:false,useProperties:true,useArrows:true,border:false,autoScroll:true,enableDrop:true,ddGroup:"containerDDGroup",ctxNode:null,initComponent:function(){if(!this.appName&&this.recordClass){this.appName=this.recordClass.getMeta("appName")}if(!this.app){this.app=Tine.Tinebase.appMgr.get(this.appName)}if(this.allowMultiSelection){this.selModel=new Ext.tree.MultiSelectionModel({})}var b=this.recordClass?this.recordClass.getContainerName():"container";var a=this.recordClass?this.recordClass.getContainersName():"containers";this.containerName=this.containerName||this.app.i18n.n_hidden(b,a,1);this.containersName=this.containersName||this.app.i18n._hidden(a);this.loader=this.loader||new Tine.widgets.tree.Loader({getParams:this.onBeforeLoad.createDelegate(this),inspectCreateNode:this.onBeforeCreateNode.createDelegate(this)});this.root={path:"/",cls:"tinebase-tree-hide-collapsetool",expanded:true,children:[{path:this.getRootPath(),id:"personal"},{path:"/shared",id:"shared"},{path:"/personal",id:"otherUsers"}].concat(this.getExtraItems())};this.dropConfig={ddGroup:this.ddGroup||"TreeDD",appendOnly:this.ddAppendOnly===true,onNodeOver:function(h,c,g,f){var d=h.node;if(d.hasChildNodes()&&!d.isExpanded()){this.queueExpand(d)}return d.attributes.allowDrop?"tinebase-tree-drop-move":false},isValidDropPoint:function(g,c,f,d){return g.node.attributes.allowDrop},completeDrop:Ext.emptyFn};this.initContextMenu();this.getSelectionModel().on("beforeselect",this.onBeforeSelect,this);this.getSelectionModel().on("selectionchange",this.onSelectionChange,this);this.on("click",this.onClick,this);this.on("contextmenu",this.onContextMenu,this);this.on("beforenodedrop",this.onBeforeNodeDrop,this);this.on("append",this.onAppendNode,this);Tine.widgets.container.TreePanel.superclass.initComponent.call(this);return},getRootPath:function(){return Tine.Tinebase.container.getMyNodePath()},getDefaultContainerPath:function(){return this.defaultContainerPath||"/"},getExtraItems:function(){return this.extraItems||[]},getFilterPlugin:function(){if(!this.filterPlugin){this.filterPlugin=new Tine.widgets.tree.FilterPlugin({treePanel:this})}return this.filterPlugin},getSelectedContainer:function(b,f,d){var a=f,g=this.getSelectionModel(),c=typeof g.getSelectedNodes=="function"?g.getSelectedNodes():[g.getSelectedNode()];if(Ext.isArray(c)&&c.length>0&&(!d||c.length===1||!a)){a=this.getContainerFromSelection(c,b)||a}return a},getContainerFromSelection:function(c,b){var a=null;Ext.each(c,function(d){if(d&&Tine.Tinebase.container.pathIsContainer(d.attributes.container.path)){if(!b||this.hasGrant(d,b)){a=d.attributes.container;return false}}},this);return a},getContainerFromFilter:function(c){var b=null;var a=this.filterPlugin.getGridPanel().filterToolbar,d=null;a.filterStore.each(function(f){if(f.get("field")==this.recordClass.getMeta("containerProperty")){d=f.get("value");if(f.get("operator")=="equals"){b=d}else{if(f.get("operator")=="in"&&d.length==1){b=d[0]}}return false}},this);return b},getTreePath:function(a){var c="/"+this.getRootNode().id+(a!=="/"?a:"");var b=a.match(/^\/personal\/{0,1}([0-9a-z_\-]*)\/{0,1}/i);if(b){if(b[1]!=Tine.Tinebase.registry.get("currentAccount").accountId){c=c.replace("personal","otherUsers")}else{c=c.replace("personal/"+Tine.Tinebase.registry.get("currentAccount").accountId,"personal")}}return c},hasGrant:function(c,b){var a=c.attributes,d=false;if(a&&a.leaf){d=true;Ext.each(b,function(f){d=d&&a.container.account_grants[f]},this)}return d},afterRender:function(){Tine.widgets.container.TreePanel.superclass.afterRender.call(this);var b=this.getDefaultContainerPath();if(b&&b!="/"){var a="/"+this.getRootNode().id;this.expand();this.selectPath.defer(100,this,[a+b])}if(this.filterMode=="filterToolbar"&&this.filterPlugin){this.filterPlugin.getGridPanel().filterToolbar.on("change",this.onFilterChange,this)}},initContextMenu:function(){this.contextMenuUserFolder=Tine.widgets.tree.ContextMenu.getMenu({nodeName:this.containerName,actions:["add"],scope:this,backend:"Tinebase_Container",backendModel:"Container"});this.contextMenuSingleContainer=Tine.widgets.tree.ContextMenu.getMenu({nodeName:this.containerName,actions:["delete","rename","grants"].concat(this.useProperties?["properties"]:[]).concat(this.useContainerColor?["changecolor"]:[]),scope:this,backend:"Tinebase_Container",backendModel:"Container"});this.contextMenuSingleContainerProperties=Tine.widgets.tree.ContextMenu.getMenu({nodeName:this.containerName,actions:["properties"],scope:this,backend:"Tinebase_Container",backendModel:"Container"})},onAppendNode:function(b,c,d,a){if(d.leaf&&this.hasGrant(d,this.requiredGrants)){if(this.useContainerColor){d.ui.render=d.ui.render.createSequence(function(){this.colorNode=Ext.DomHelper.insertAfter(this.iconNode,{tag:"span",html:"&nbsp;&#9673;&nbsp",style:{color:d.attributes.container.color||"#808080"}},true)},d.ui)}}},onClick:function(a,c){var d=this.getSelectionModel(),b=d.getSelectedNode();if(!this.allowMultiSelection&&a==b){this.onSelectionChange(d,a)}a.expand()},onContextMenu:function(d,c){this.ctxNode=d;var b=d.attributes.container,f=b.path,a;if(!Ext.isString(f)){return}if(Tine.Tinebase.container.pathIsContainer(f)){if(b.account_grants&&b.account_grants.adminGrant){this.contextMenuSingleContainer.showAt(c.getXY())}else{this.contextMenuSingleContainerProperties.showAt(c.getXY())}}else{if(f.match(/^\/shared$/)&&(Tine.Tinebase.common.hasRight("admin",this.app.appName)||Tine.Tinebase.common.hasRight("manage_shared_folders",this.app.appName))){this.contextMenuUserFolder.showAt(c.getXY())}else{if(Tine.Tinebase.registry.get("currentAccount").accountId==Tine.Tinebase.container.pathIsPersonalNode(f)){this.contextMenuUserFolder.showAt(c.getXY())}}}},onBeforeCreateNode:function(a){if(a.accountDisplayName){a.name=a.accountDisplayName;a.path="/personal/"+a.accountId;a.id=a.accountId}if(!a.name&&a.path){a.name=Tine.Tinebase.container.path2name(a.path,this.containerName,this.containersName)}Ext.applyIf(a,{text:Ext.util.Format.htmlEncode(a.name),qtip:Tine.Tinebase.common.doubleEncode(a.name),leaf:!!a.account_grants,allowDrop:!!a.account_grants&&a.account_grants.addGrant});a.container=Ext.copyTo({},a,Tine.Tinebase.Model.Container.getFieldNames())},onBeforeLoad:function(c){var d=c.attributes.path;var b=Tine.Tinebase.container.path2type(d);var a=Tine.Tinebase.container.pathIsPersonalNode(d);if(b==="personal"&&!a){b="otherUsers"}var f={method:"Tinebase_Container.getContainer",application:this.app.appName,containerType:b,requiredGrants:this.requiredGrants,owner:a};return f},onBeforeSelect:function(f,a,b){if(this.requiredGrant&&a.isLeaf()){var c=a.attributes.container.account_grants||{};if(!c[this.requiredGrant]){var d="<b>"+String.format(_("You are not allowed to select the {0} '{1}':"),this.containerName,a.attributes.text)+"</b><br />"+String.format(_("{0} grant is required for desired action"),this.requiredGrant);Ext.Msg.alert(_("Insufficient Grants"),d);return false}}},onBeforeNodeDrop:function(c){var b=c.target.id;var d=this.app.getMainScreen().getCenterPanel().getGrid().getSelectionModel();if(d.getCount()===0){return false}var a=d.getSelectionFilter();Ext.Ajax.request({params:{method:"Tinebase_Container.moveRecordsToContainer",targetContainerId:b,filterData:a,model:this.recordClass.getMeta("modelName"),applicationName:this.recordClass.getMeta("appName")},scope:this,success:function(f,g){this.app.getMainScreen().getCenterPanel().loadGridData()}});c.dropStatus=true;return true},onFilterChange:function(){},onSelectionChange:function(d,c){if(this.filterMode=="gridFilter"&&this.filterPlugin){this.filterPlugin.onFilterChange()}if(this.filterMode=="filterToolbar"&&this.filterPlugin){var a=this.filterPlugin.getGridPanel().filterToolbar;a=a.activeFilterPanel?a.activeFilterPanel:a;a.supressEvents=true;a.filterStore.each(function(f){var g=f.get("field");if(g==="container_id"||g==="attender"||g==="path"){a.deleteFilter(f)}},this);a.supressEvents=false;var b=this.getFilterPlugin().getFilter();a.addFilter(new a.record(b));a.onFiltertrigger();d.suspendEvents();Ext.each(c,function(f){d.select(f,Ext.EventObject,true)},this);d.resumeEvents()}},selectContainerPath:function(b,a,c){return this.selectPath(this.getTreePath(b),a,c)},getDefaultContainer:function(b){if(!b){b="defaultContainer"}var a=Tine[this.appName].registry.get(b);return this.getSelectedContainer("addGrant",a,true)}});Ext.ns("Tine.widgets","Tine.widgets.container");Tine.widgets.container.PropertiesDialog=Ext.extend(Tine.widgets.dialog.EditDialog,{grantContainer:null,containerName:null,windowNamePrefix:"ContainerPropertiesWindow_",loadRecord:false,tbarItems:[],evalGrants:false,initComponent:function(){this.myGrants=[];for(var a in this.grantContainer.account_grants){if(this.grantContainer.account_grants.hasOwnProperty(a)&&this.grantContainer.account_grants[a]&&Tine.widgets.container.GrantsGrid.prototype[a+"Title"]){this.myGrants.push({title:_(Tine.widgets.container.GrantsGrid.prototype[a+"Title"]),description:_(Tine.widgets.container.GrantsGrid.prototype[a+"Description"])})}}this.myGrantsTemplate=new Ext.XTemplate('<tpl for=".">','<span class="tine-wordbox" ext:qtip="',"{[this.encode(values.description)]}",'">',"{[this.encode(values.title)]}","</span>","</tpl>",{encode:function(b){return Tine.Tinebase.common.doubleEncode(b)}}).compile();Tine.widgets.container.PropertiesDialog.superclass.initComponent.call(this)},initRecord:function(){},getFormItems:function(){return{xtype:"tabpanel",border:false,plain:true,activeTab:0,border:false,items:[{title:_("Properties"),border:false,frame:true,layout:"form",labelAlign:"top",labelSeparator:"",layoutConfig:{trackLabels:true},plugins:[{ptype:"ux.itemregistry",key:"Tine.widgets.container.PropertiesDialog.FormItems.Properties"}],items:[{xtype:"textfield",anchor:"100%",readOnly:true,fieldLabel:_("Name"),value:this.grantContainer.name},{xtype:"colorfield",width:40,readOnly:true,fieldLabel:_("Color"),value:this.grantContainer.color},{xtype:"label",anchor:"100%",readOnly:true,fieldLabel:_("My Grants"),html:this.myGrantsTemplate.applyTemplate(this.myGrants)}]}]}},onApplyChanges:function(){this.purgeListeners();this.window.close()}});Tine.widgets.container.PropertiesDialog.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:700,height:450,name:Tine.widgets.container.PropertiesDialog.windowNamePrefix+Ext.id(),contentPanelConstructor:"Tine.widgets.container.PropertiesDialog",contentPanelConstructorConfig:a,modal:true});return b};Ext.ns("Tine.widgets.container");Tine.widgets.container.FilterModel=Ext.extend(Tine.widgets.grid.FilterModel,{app:null,recordClass:null,operators:["equals","in"],field:"container_id",defaultOperator:"equals",defaultValue:{path:"/"},initComponent:function(){if(Ext.isString(this.recordClass)){var a=this.recordClass.split(".");this.recordClass=Tine[a[0]].Model[a[1]]}if(Ext.isString(this.app)){this.app=Tine[this.app]}Tine.widgets.container.FilterModel.superclass.initComponent.call(this);this.containerName=this.app.i18n.n_hidden(this.recordClass.getMeta("containerName"),this.recordClass.getMeta("containersName"),1);this.containersName=this.app.i18n._hidden(this.recordClass.getMeta("containersName"));this.label=this.containerName},getValueType:function(b){var a=b.get("operator")?b.get("operator"):this.defaultOperator;var c="selectionComboBox";switch(a){case"in":c="FilterModelMultipleValueField";break}return c},onOperatorChange:function(b,c){this.supr().onOperatorChange.call(this,b,c);var d=this.getValueType(b);for(var a in b.valueFields){b.valueFields[a][a==d?"show":"hide"]()}b.formFields.value=b.valueFields[d];b.formFields.value.setWidth(b.formFields.value.width);b.formFields.value.wrap.setWidth(b.formFields.value.width);b.formFields.value.syncSize()},valueRenderer:function(b,a){var c=this.getValueType(b);b.valueFields={};b.valueFields.selectionComboBox=new Tine.widgets.container.selectionComboBox({hidden:c!="selectionComboBox",app:this.app,filter:b,width:200,listWidth:200,value:b.data.value?b.data.value:this.defaultValue,renderTo:a,allowNodeSelect:true,recordClass:this.recordClass,appName:this.recordClass.getMeta("appName"),containerName:this.containerName,containersName:this.containersName,getValue:function(){return this.selectedContainer?this.selectedContainer.path:null},setValue:function(f){if(this.filter.get("operator")!=="in"){var d=this.filter.data.operator==="personalNode"?_("is personal of"):_("is equal to");if(f.path&&f.path===Tine.Tinebase.container.getMyNodePath()){d=_("is equal to")}this.filter.formFields.operator.setRawValue(d)}return Tine.widgets.container.selectionComboBox.prototype.setValue.call(this,f)},listeners:{scope:this,select:this.onFiltertrigger,specialkey:function(f,d){if(d.getKey()==d.ENTER){this.onFiltertrigger()}}}});b.valueFields.FilterModelMultipleValueField=new Tine.widgets.container.FilterModelMultipleValueField({hidden:c!="FilterModelMultipleValueField",app:this.app,recordClass:this.recordClass,containerName:this.containerName,containersName:this.containersName,filter:b,width:200,value:b.data.value?b.data.value:this.defaultValue,renderTo:a,listeners:{scope:this,select:this.onFiltertrigger,specialkey:function(f,d){if(d.getKey()==d.ENTER){this.onFiltertrigger()}}}});return b.valueFields[c]}});Tine.widgets.grid.FilterToolbar.FILTERS["tine.widget.container.filtermodel"]=Tine.widgets.container.FilterModel;Tine.widgets.container.FilterModelMultipleValueField=Ext.extend(Ext.ux.form.LayerCombo,{containerName:"container",containersName:"containers",recordClass:null,hideButtons:false,layerAlign:"tr-br?",minLayerWidth:400,layerHeight:300,lazyInit:true,formConfig:{labelAlign:"left",labelWidth:30},initComponent:function(){this.on("beforecollapse",this.onBeforeCollapse,this);this.store=new Ext.data.SimpleStore({fields:this.recordClass});this.supr().initComponent.call(this)},getColumnModel:function(){return new Ext.grid.ColumnModel({defaults:{sortable:false},columns:[{id:"name",header:String.format(_("Selected  {0}"),this.containersName),dataIndex:"name"}]})},getFormValue:function(){var a=[];this.store.each(function(b){a.push(b.data)},this);return a},getItems:function(){var a=this.containerSelectionCombo=new Tine.widgets.container.selectionComboBox({allowNodeSelect:true,allowBlank:true,blurOnSelect:true,recordClass:this.recordClass,appName:this.recordClass.getMeta("appName"),containerName:this.containerName,containersName:this.containersName,listeners:{scope:this,select:this.onContainerSelect}});this.containerGridPanel=new Tine.widgets.grid.PickerGridPanel({height:this.layerHeight||"auto",recordClass:Tine.Tinebase.Model.Container,store:this.store,autoExpandColumn:"name",getColumnModel:this.getColumnModel.createDelegate(this),initActionsAndToolbars:function(){Tine.widgets.grid.PickerGridPanel.prototype.initActionsAndToolbars.call(this);this.tbar=new Ext.Toolbar({layout:"fit",items:[a]})}});var b=[this.containerGridPanel];return b},onBeforeCollapse:function(){var a=this.containerGridPanel.contextMenu&&!this.containerGridPanel.contextMenu.hidden,b=this.containerSelectionCombo.dlg&&!this.containerSelectionCombo.dlg.win.isDestroyed;return !(a||this.containerSelectionCombo.isExpanded()||b)},onContainerSelect:function(d,b){var g=this.store.getById(b.id);if(!g){var c=(b.data)?b.data:b;this.store.add(new Tine.Tinebase.Model.Container(c))}else{var a=this.store.indexOf(g);var f=this.containerGridPanel.getView().getRow(a);Ext.fly(f).highlight()}this.containerSelectionCombo.clearValue()},setValue:function(a){a=Ext.isArray(a)?a:[a];this.currentValue=[];this.store.removeAll();var b=[];Ext.each(a,function(c){if(c.path&&c.path===Tine.Tinebase.container.getMyNodePath()){c.name=null}c.name=c.name||Tine.Tinebase.container.path2name(c.path,this.containerName,this.containersName);c.id=c.id||c.path;this.store.add(new Tine.Tinebase.Model.Container(c));this.currentValue.push(c);b.push(c.name)},this);this.setRawValue(b.join(", "));return this},setFormValue:function(a){}});Ext.ns("Tine.widgets","Tine.widgets.tags");Tine.widgets.tags.TagPanel=Ext.extend(Ext.Panel,{app:null,recordId:"",tags:null,recordTagsStore:null,availableTagsStore:false,searchField:null,iconCls:"action_tag",layout:"fit",bodyStyle:"padding: 2px 2px 2px 2px",collapsible:true,border:false,initComponent:function(){this.title=_("Tags");this.app=Ext.isString(this.app)?Tine.Tinebase.appMgr.get(this.app):this.app;this.tags=[];this.recordTagsStore=new Ext.data.JsonStore({id:"id",fields:Tine.Tinebase.Model.Tag,data:this.tags});this.availableTagsStore=new Ext.data.JsonStore({id:"id",root:"results",totalProperty:"totalCount",fields:Tine.Tinebase.Model.Tag,baseParams:{method:"Tinebase.searchTags",filter:{application:this.app.appName,grant:"use"},paging:{}}});this.initSearchField();this.bottomBar=new Ext.Container({layout:"column",items:[Ext.apply(this.searchField,{columnWidth:0.99}),new Ext.Button({text:"",width:16,iconCls:"action_add",tooltip:_("Add a new personal tag"),scope:this,handler:function(){Ext.Msg.prompt(_("Add New Personal Tag"),_("Please note: You create a personal tag. Only you can see it!")+" <br />"+_("Enter tag name:"),function(b,c){if(b=="ok"){this.onTagAdd(c)}},this,false,this.searchField.lastQuery)}})]});var a=new Ext.XTemplate('<tpl for=".">','<div class="x-widget-tag-tagitem" id="{id}">','<div class="x-widget-tag-tagitem-color" style="background-color: {color};">&#160;</div>','<div class="x-widget-tag-tagitem-text" ext:qtip="',"{[this.encode(values.name)]}","<tpl if=\"type == 'personal' \">&nbsp;<i>("+_("personal")+")</i></tpl>","</i>&nbsp;[{occurrence}]",'<tpl if="description != null && description.length &gt; 1"><hr>{[this.encode(values.description)]}</tpl>" >',"&nbsp;{[this.encode(values.name)]}","</div>","</div>","</tpl>",{encode:function(b){return Tine.Tinebase.common.doubleEncode(b)}});this.dataView=new Ext.DataView({store:this.recordTagsStore,tpl:a,autoHeight:true,multiSelect:true,overClass:"x-widget-tag-tagitem-over",selectedClass:"x-widget-tag-tagitem-selected",itemSelector:"div.x-widget-tag-tagitem",emptyText:_("No Tags to display")});this.dataView.on("contextmenu",function(l,g,d,b){if(!this.dataView.isSelected(g)){this.dataView.clearSelections();this.dataView.select(g)}b.preventDefault();var f=this.dataView.getSelectedRecords();var k=f.length==1?f[0]:null;var j=true;for(var h=0;h<f.length;h++){if(f[h].get("type")=="shared"){j=false}}var c=new Ext.menu.Menu({items:[new Ext.Action({scope:this,text:Tine.Tinebase.translation.ngettext("Detach tag","Detach tags",f.length),iconCls:"x-widget-tag-action-detach",handler:function(){for(var o=0,m=f.length;o<m;o++){this.recordTagsStore.remove(f[o])}}}),"-",{text:_("Edit tag"),disabled:!(k&&j),menu:{items:[new Ext.Action({text:_("Rename Tag"),selectedTag:k,scope:this,handler:function(o){var m=o.selectedTag;Ext.Msg.prompt(_("Rename Tag")+' "'+m.get("name")+'"',_("Please enter a new name:"),function(q,r){if(q=="ok"){m.set("name",r);this.onTagUpdate(m)}},this,false,m.get("name"))}}),new Ext.Action({text:_("Edit Description"),selectedTag:k,scope:this,handler:function(o){var m=o.selectedTag;Ext.Msg.prompt(_("Description for tag")+' "'+m.get("name")+'"',_("Please enter new description:"),function(q,r){if(q=="ok"){m.set("description",r);this.onTagUpdate(m)}},this,30,m.get("description"))}}),new Ext.Action({text:_("Change Color"),iconCls:"action_changecolor",scope:this,menu:new Ext.menu.ColorMenu({scope:this,listeners:{select:function(o,m){m="#"+m;if(k.get("color")!=m){k.set("color",m);this.onTagUpdate(k)}},scope:this}})})]}},new Ext.Action({disabled:!j,scope:this,text:Tine.Tinebase.translation.ngettext("Delete Tag","Delete Tags",f.length),iconCls:"action_delete",handler:function(){var q=[];for(var o=0,m=f.length;o<m;o++){if(f[o].id.length>20){q.push(f[o].id)}}Ext.MessageBox.confirm(Tine.Tinebase.translation.ngettext("Realy Delete Selected Tag?","Realy Delete Selected Tags?",f.length),Tine.Tinebase.translation.ngettext("the selected tag will be deleted and disapear for all entries","The selected tags will be removed and disapear for all entries",f.length),function(r){if(r=="yes"){Ext.MessageBox.wait(_("Please wait a moment..."),Tine.Tinebase.translation.ngettext("Deleting Tag","Deleting Tags",f.length));Ext.Ajax.request({params:{method:"Tinebase.deleteTags",ids:q},success:function(v,t){this.availableTagsStore.lastOptions=null;for(var u=0,s=f.length;u<s;u++){this.recordTagsStore.remove(f[u])}Ext.MessageBox.hide()},failure:function(s,t){Ext.MessageBox.alert(_("Failed"),_("Could not delete Tag(s)."))},scope:this})}},this)}})]});c.showAt(b.getXY())},this);this.formField={layout:"form",items:new Tine.widgets.tags.TagFormField({recordTagsStore:this.recordTagsStore})};this.items=[{xtype:"panel",layout:"fit",bbar:this.bottomBar,items:[this.dataView,this.formField]}];Tine.widgets.dialog.MultipleEditDialogPlugin.prototype.registerSkipItem(this);Tine.widgets.tags.TagPanel.superclass.initComponent.call(this)},getFormField:function(){return this.formField.items},onTagAdd:function(b){if(b.length<3){Ext.Msg.show({title:_("Notice"),msg:_("The minimum tag length is three."),buttons:Ext.Msg.OK,animEl:"elId",icon:Ext.MessageBox.INFO})}else{var a=false;this.recordTagsStore.each(function(d){if(d.data.name==b){a=true}},this);if(!a){var c=false;this.availableTagsStore.each(function(d){if(d.data.name==b){c=d}},this);if(!c){c=new Tine.Tinebase.Model.Tag({name:b,type:"personal",description:"",color:"#FFFFFF"});if(!Ext.isIE){this.el.mask()}Ext.Ajax.request({params:{method:"Tinebase.saveTag",tag:c.data},success:function(f,d){var h=Ext.util.JSON.decode(f.responseText);var g=new Tine.Tinebase.Model.Tag(h,h.id);this.recordTagsStore.add(g);this.availableTagsStore.lastOptions=null;this.el.unmask()},failure:function(d,f){Ext.MessageBox.alert(_("Failed"),_("Could not create tag."));this.el.unmask()},scope:this})}else{this.recordTagsStore.add(c)}}}},onTagUpdate:function(a){if(a.get("name").length<3){Ext.Msg.show({title:_("Notice"),msg:_("The minimum tag length is three."),buttons:Ext.Msg.OK,animEl:"elId",icon:Ext.MessageBox.INFO})}else{this.el.mask();Ext.Ajax.request({params:{method:"Tinebase.saveTag",tag:a.data},success:function(c,b){this.availableTagsStore.lastOptions=null;this.el.unmask()},failure:function(b,c){Ext.MessageBox.alert(_("Failed"),_("Could not update tag."));this.el.unmask()},scope:this})}},initSearchField:function(){var a=new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item" ext:qtip="',"{[this.encode(values.name)]}","<tpl if=\"type == 'personal' \">&nbsp;<i>("+_("personal")+")</i></tpl>","</i>&nbsp;[{occurrence}]",'<tpl if="description != null && description.length &gt; 1"><hr>{[this.encode(values.description)]}</tpl>">',"{[this.encode(values.name)]} <tpl if=\"type == 'personal' \"><i>("+_("personal")+")</i></tpl>","</div></tpl>",{encode:function(b){return Tine.Tinebase.common.doubleEncode(b)}});this.searchField=new Ext.form.ComboBox({store:this.availableTagsStore,mode:"local",enableKeyEvents:true,displayField:"name",typeAhead:true,emptyText:_("Enter tag name"),loadingText:_("Searching..."),typeAheadDelay:10,minChars:1,hideTrigger:false,triggerAction:"all",forceSelection:true,tpl:a});this.searchField.on("focus",function(b){if(!b.store.lastOptions){b.hasFocus=false;this.availableTagsStore.load({scope:this,callback:function(){b.hasFocus=true}})}},this);this.searchField.on("select",function(c,b){if(this.recordTagsStore.getById(b.id)===undefined){this.recordTagsStore.add(b)}c.emptyText="";c.clearValue()},this);this.searchField.on("blur",function(b){b.emptyText=_("Enter tag name");b.clearValue()},this)}});Tine.widgets.tags.TagFormField=Ext.extend(Ext.form.Field,{recordTagsStore:null,name:"tags",hidden:true,labelSeparator:"",initComponent:function(){Tine.widgets.tags.TagFormField.superclass.initComponent.call(this)},getValue:function(){var a=[];this.recordTagsStore.each(function(b){if(b.id.length>5&&!String(b.id).match(/ext-record/)){a.push(b.id)}else{a.push(b.data)}});return a},setValue:function(a){Tine.Tinebase.Model.Tag.replaceTemplateField(a);this.recordTagsStore.loadData(a)}});Tine.widgets.tags.TagEditDialog=Ext.extend(Ext.Window,{width:200,height:300,layout:"fit",margins:"0px 5px 0px 5px",initComponent:function(){this.items=new Ext.form.FormPanel({defaults:{xtype:"textfield",anchor:"100%"},labelAlign:"top",items:[{name:"name",fieldLabel:"Name"},{name:"description",fieldLabel:_("Description")},{name:"color",fieldLabel:_("Color")}]});Tine.widgets.tags.TagEditDialog.superclass.initComponent.call(this)}});Tine.widgets.tags.EditDialog=Ext.extend(Ext.Window,{layout:"border",width:640,heigh:480,initComponent:function(){this.items=[{region:"west",split:true},{region:"center",split:true}];Tine.widgets.tags.EditDialog.superclass.call(this)}});Ext.ns("Tine.widgets","Tine.widgets.tags");Tine.widgets.tags.TagCombo=Ext.extend(Ext.ux.form.ClearableComboBox,{app:null,findGlobalTags:true,onlyUsableTags:false,emptyText:null,typeAhead:true,mode:"remote",triggerAction:"all",displayField:"name",valueField:"id",minChars:3,initComponent:function(){this.emptyText=this.emptyText?this.emptyText:_("tag name");this.initStore();this.initTemplate();Tine.widgets.tags.TagCombo.superclass.initComponent.call(this);this.on("select",this.onSelectRecord,this);this.on("beforequery",this.onBeforeQuery,this)},onSelectRecord:function(){var a=this.getValue();if(String(a)!==String(this.startValue)){this.fireEvent("change",this,a,this.startValue)}},onBeforeQuery:function(b){var a={name:(b.query&&b.query!="")?"%"+b.query+"%":"",application:this.app?this.app.appName:"",grant:(this.onlyUsableTags)?"use":"view"};this.store.baseParams.filter=a},setValue:function(a){if(typeof a==="object"&&Object.prototype.toString.call(a)==="[object Object]"){if(!this.store.getById(a.id)){this.store.addSorted(new Tine.Tinebase.Model.Tag(a))}a=a.id}Tine.widgets.tags.TagCombo.superclass.setValue.call(this,a)},initStore:function(){var a={method:"Tinebase.searchTags",paging:{}};this.store=new Ext.data.JsonStore({id:"id",root:"results",totalProperty:"totalCount",fields:Tine.Tinebase.Model.Tag,baseParams:a})},initTemplate:function(){this.tpl=new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item">','<div class="tb-grid-tags" style="background-color:{values.color};">&#160;</div>','<div class="x-widget-tag-tagitem-text" ext:qtip="',"{[this.encode(values.name)]}","<tpl if=\"type == 'personal' \">&nbsp;<i>("+_("personal")+")</i></tpl>","</i>&nbsp;[{occurrence}]",'<tpl if="description != null && description.length &gt; 1"><hr>{[this.encode(values.description)]}</tpl>" >',"&nbsp;{[this.encode(values.name)]}","<tpl if=\"type == 'personal' \">&nbsp;<i>("+_("personal")+")</i></tpl>","</div>","</div>","</tpl>",{encode:function(a){if(a){return Tine.Tinebase.common.doubleEncode(a)}else{return""}}})}});Ext.reg("Tine.widgets.tags.TagCombo",Tine.widgets.tags.TagCombo);Ext.ns("Tine.widgets","Tine.widgets.tags");Tine.widgets.tags.TagToggleBox=Ext.extend(Ext.form.FormPanel,{layout:"fit",border:false,cls:"tw-editdialog",store:null,buttonAlign:"right",win:null,mode:null,anchor:"100% 100%",loadMask:null,initComponent:function(){this.addEvents("cancel","update","close");this.initStore();this.initTemplate();this.initView();this.initActions();this.initButtons();this.items=this.getFormItems();Tine.widgets.tags.TagToggleBox.superclass.initComponent.call(this)},initActions:function(){this.action_update=new Ext.Action({text:(this.mode=="detach")?_("Detach Tags"):_("Attach Tags"),minWidth:70,scope:this,handler:this.onUpdate,iconCls:"action_saveAndClose"});this.action_cancel=new Ext.Action({text:_("Cancel"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_cancel"})},initStore:function(){this.store=new Ext.data.JsonStore({id:"id",root:"results",totalProperty:"totalCount",fields:Tine.Tinebase.Model.Tag,baseParams:{method:"Tinebase.searchTagsByForeignFilter",filterData:this.selectionModel.getSelectionFilter(),filterName:this.recordClass.getMeta("appName")+"_Model_"+this.recordClass.getMeta("modelName")+"Filter"}});this.store.load()},initButtons:function(){this.fbar=["->",this.action_cancel,this.action_update]},getFormItems:function(){return{border:false,frame:true,layout:"form",items:[{region:"center",layout:{align:"stretch",type:"vbox"}},this.view]}},initTemplate:function(){this.tpl=new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item">','<input class="tagcheckel" type="checkbox" style="margin-right:3px;float:left" id="{values.id}" /><div class="tb-grid-tags" style="margin-top:2px;background-color:{values.color};">&#160;</div>','<div class="x-widget-tag-tagitem-text" style="margin-top:1px" ext:qtip="',"{[this.encode(values.name)]}","<tpl if=\"type == 'personal' \">&nbsp;<i>("+_("personal")+")</i></tpl>","</i>&nbsp;[{occurrence}]",'<tpl if="description != null && description.length &gt; 1"><hr>{[this.encode(values.description)]}</tpl>" >',"&nbsp;{[this.encode(values.name)]}&nbsp;({values.selection_occurrence})","<tpl if=\"type == 'personal' \">&nbsp;<i>("+_("personal")+")</i></tpl>","</div>","</div>","</tpl>",{encode:function(a){if(a){return Tine.Tinebase.common.doubleEncode(a)}else{return""}}})},initView:function(){this.view=new Ext.DataView({anchor:"100% 100%",autoScroll:true,store:this.store,tpl:this.tpl,emptyText:_("No Tags to detach found in the selected records"),loadingText:_("Please Wait..."),style:"background:#fff;"})},onCancel:function(){this.fireEvent("cancel")},onUpdate:function(){this.loadMask=new Ext.LoadMask(this.getEl(),{msg:_("Detaching Tags")});this.loadMask.show();var a=Ext.select("input.tagcheckel");var d=[];a.each(function(f){if(f.dom.checked){d.push(f.id)}});var b=this.selectionModel.getSelectionFilter();var c=this.recordClass.getMeta("appName")+"_Model_"+this.recordClass.getMeta("modelName")+"Filter";Tine.Tinebase.detachTagsFromMultipleRecords(b,c,d,this.onUpdated.createDelegate(this))},onUpdated:function(){this.loadMask.hide();this.fireEvent("updated")}});Ext.ns("Tine.widgets","Tine.widgets.tags");Tine.widgets.tags.TagFilter=Ext.extend(Tine.widgets.grid.PickerFilter,{field:"tag",defaultOperator:"equals",initComponent:function(){this.picker=Tine.widgets.tags.TagCombo;this.recordClass=Tine.Tinebase.Model.Tag;Tine.widgets.tags.TagFilter.superclass.initComponent.call(this);this.label=_("Tag")}});Tine.widgets.grid.FilterToolbar.FILTERS["tinebase.tag"]=Tine.widgets.tags.TagFilter;Ext.ns("Tine.widgets","Tine.widgets.tags");Tine.widgets.tags.TagsMassAttachAction=function(a){a.text=a.text?a.text:_("Add Tag");a.iconCls="action_tag";a.handler=this.handleClick.createDelegate(this);Ext.apply(this,a);Tine.widgets.tags.TagsMassAttachAction.superclass.constructor.call(this,a)};Ext.extend(Tine.widgets.tags.TagsMassAttachAction,Ext.Action,{updateHandler:Ext.emptyFn,updateHandlerScope:null,loadMask:null,selectionModel:null,recordClass:null,getFormItems:function(){this.tagSelect=new Tine.widgets.tags.TagCombo({hideLabel:true,anchor:"100%",onlyUsableTags:true,app:this.app,forceSelection:true,listeners:{scope:this,render:function(a){a.focus(false,500)},select:function(){this.onOk()}}});return[{xtype:"label",text:_("Attach the following tag to all selected items:")},this.tagSelect]},handleClick:function(){this.okButton=new Ext.Button({text:_("Ok"),minWidth:70,scope:this,handler:this.onOk,disabled:true,iconCls:"action_saveAndClose"});this.win=Tine.WindowFactory.getWindow({layout:"fit",width:300,height:150,padding:"5px",modal:true,title:_("Select Tag"),items:[{xtype:"form",buttonAlign:"right",padding:"5px",items:this.getFormItems(),buttons:[{text:_("Cancel"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_cancel"},this.okButton]}]})},onCancel:function(){this.win.close()},onOk:function(){var a=this.tagSelect.getValue();if(!a){return}this.okButton.enable();this.loadMask=new Ext.LoadMask(this.win.getEl(),{msg:_("Attaching Tag")});this.loadMask.show();var b=this.selectionModel.getSelectionFilter();var c=this.recordClass.getMeta("appName")+"_Model_"+this.recordClass.getMeta("modelName")+"Filter";Ext.Ajax.request({scope:this,timeout:1800000,success:this.onSuccess.createDelegate(this),params:{method:"Tinebase.attachTagToMultipleRecords",filterData:b,filterName:c,tag:a},failure:function(d,f){this.loadMask.hide();Tine.Tinebase.ExceptionHandler.handleRequestException(d,f)}})},onSuccess:function(){this.updateHandler.call(this.updateHandlerScope||this);this.loadMask.hide();this.win.close()}});Ext.ns("Tine.widgets","Tine.widgets.tags");Tine.widgets.tags.TagsMassDetachAction=function(a){a.text=a.text?a.text:_("Detach tag(s)");a.iconCls="action_tag_delete";a.handler=this.handleClick.createDelegate(this);Ext.apply(this,a);Tine.widgets.tags.TagsMassDetachAction.superclass.constructor.call(this,a)};Ext.extend(Tine.widgets.tags.TagsMassDetachAction,Ext.Action,{updateHandler:Ext.emptyFn,updateHandlerScope:null,selectionModel:null,recordClass:null,formPanel:null,initFormPanel:function(){this.formPanel=new Tine.widgets.tags.TagToggleBox({selectionModel:this.selectionModel,recordClass:this.recordClass,callingAction:this,mode:"detach"});this.formPanel.on("cancel",function(){this.purgeListeners();this.win.close()});this.formPanel.on("updated",function(){this.callingAction.onSuccess()})},handleClick:function(){this.initFormPanel();this.win=Tine.WindowFactory.getWindow({layout:"fit",width:300,height:150,modal:true,title:_("Select Tag(s) to detach"),items:this.formPanel});this.formPanel.win=this.win},onSuccess:function(){this.updateHandler.call(this.updateHandlerScope||this);this.win.close()}});Ext.ns("Tine.widgets.mainscreen");Tine.widgets.mainscreen.WestPanel=function(a){Ext.apply(this,a);this.defaults={};Tine.widgets.mainscreen.WestPanel.superclass.constructor.apply(this,arguments)};Ext.extend(Tine.widgets.mainscreen.WestPanel,Ext.ux.Portal,{moduleTreePanelClassName:"ContentTypeTreePanel",contentTypes:null,contentType:null,containerTreePanelClassName:"TreePanel",favoritesPanelClassName:"FilterPanel",hasContentTypeTreePanel:null,hasContainerTreePanel:null,hasFavoritesPanel:null,layout:"column",cls:"x-portal",defaultType:"portalcolumn",border:false,stateful:true,stateEvents:["collapse","expand","drop"],initComponent:function(){this.stateId=this.app.appName+this.getContentType()+"-mainscreen-westpanel";var a=this.getContentType()+this.favoritesPanelClassName;this.hasFavoritesPanel=Ext.isBoolean(this.hasFavoritesPanel)?this.hasFavoritesPanel:!!Tine[this.app.appName][a];this.hasContentTypeTreePanel=Ext.isArray(this.contentTypes)&&this.contentTypes.length>1;if(this.hasContainerTreePanel===null){this.hasContainerTreePanel=true;if(this.contentTypes){Ext.each(this.contentTypes,function(b){if(((b.hasOwnProperty("model")&&b.model==this.contentType)||(b.hasOwnProperty("meta")&&b.meta.modelName==this.contentType))&&(b.singularContainerMode)){this.hasContainerTreePanel=false;return false}},this)}}this.items=this.getPortalColumn();Tine.widgets.mainscreen.WestPanel.superclass.initComponent.apply(this,arguments)},afterRender:function(){Tine.widgets.mainscreen.WestPanel.superclass.afterRender.apply(this,arguments);this.getPortalColumn().items.each(function(b,a){if(b.getEl&&b.getEl()){this.xScrollKiller(b)}else{b.on("afterrender",this.xScrollKiller,this)}b.enableBubble(["collapse","expand","selectionchange"])},this);this.body.applyStyles("overflow-y: auto")},initState:function(){var a=Ext.state.Manager.get(this.stateId)?Ext.state.Manager.get(this.stateId):this.getState();if(this.fireEvent("beforestaterestore",this,a)!==false){this.applyState(Ext.apply({},a));this.fireEvent("staterestore",this,a)}},applyState:function(g){var h=this.getPortalColumn().items,j=new Array(h.getCount()),d=h.keys,b=h.items;Ext.each(g.order,function(k,c){j[c]={key:d[k],value:b[k],index:k}},this);for(var f=0,a=h.length;f<a;f++){if(j[f]){b[f]=j[f].value;d[f]=j[f].key}}h.fireEvent("sort",h);h.each(function(k,c){if(typeof k.addFill==="function"){return}if(k.getEl()){k[g.collapsed[c]?"collapse":"expand"](false)}else{k.collapsed=!!g.collapsed[c]}},this)},getAdditionalItems:function(){return this.additionalItems||[]},getContentType:function(){return(this.contentType)?this.contentType:""},getContentTypeTreePanel:function(){if(this.hasContentTypeTreePanel&&!this.contentTypeTreePanel){this.contentTypeTreePanel=new Tine.widgets.ContentTypeTreePanel({app:this.app,contentTypes:this.contentTypes,contentType:this.contentType});this.contentTypeTreePanel.on("click",function(b,a){if(b!=this.lastClickedNode){this.lastClickedNode=b;this.fireEvent("selectionchange")}})}return this.contentTypeTreePanel},getContainerTreePanel:function(){var a=this.app.getMainScreen().getActiveContentType()+"TreePanel";if(!this[a]){if(Tine[this.app.appName].hasOwnProperty(a)){this[a]=new Tine[this.app.appName][a]({app:this.app})}else{this[a]=new Tine.widgets.persistentfilter.PickerPanel({app:this.app})}this[a].on("click",function(c,b){if(c!=this.lastClickedNode){this.lastClickedNode=c;this.fireEvent("selectionchange")}})}return this[a]},getFavoritesPanel:function(){var a=this.app.getMainScreen().getActiveContentType(),c=a+"FilterPanel";try{if(!this[c]){this[c]=new Tine[this.app.appName][c]({rootVisible:false,border:false,collapsible:true,root:null,titleCollapse:true,title:"",baseCls:"ux-arrowcollapse",app:this.app,contentType:a,treePanel:(this.hasContainerTreePanel)?this.getContainerTreePanel():this.getContentTypeTreePanel(),listeners:{scope:this,click:function(f,d){if(f!=this.lastClickedNode){this.lastClickedNode=f;this.fireEvent("selectionchange")}}}})}}catch(b){Tine.log.info("No Favorites Panel created")}return this[c]},getFilterPlugin:function(a){if(this.hasContainerTreePanel){return this.getContainerTreePanel().getFilterPlugin()}else{return new Tine.widgets.grid.FilterPlugin({getValue:function(){return[]}})}},getPortalColumn:function(){if(!this.portalColumn){var b=[];if(this.hasContainerTreePanel){var a=this.getContainerTreePanel();var c=a.recordClass?a.recordClass.getContainersName():_("containers");var d=typeof a.selectContainerPath==="function";if(d){this.defaults={collapsible:true,baseCls:"ux-arrowcollapse",animCollapse:true,titleCollapse:true,draggable:true,autoScroll:false}}b.push(Ext.apply(this.getContainerTreePanel(),{title:d?c:false,collapsed:d},this.defaults))}if(this.hasFavoritesPanel){b.unshift(Ext.apply(this.getFavoritesPanel(),{title:_("Favorites")},this.defaults));if(this.hasContentTypeTreePanel){this.defaults={collapsible:true,baseCls:"ux-arrowcollapse",animCollapse:true,titleCollapse:true,draggable:true,autoScroll:false};b.unshift(Ext.apply(this.getContentTypeTreePanel(),{title:_("Modules"),collapsed:false}))}b.unshift(new Ext.Toolbar({buttonAlign:"center",items:[{xtype:"button",text:_("Save current view as favorite"),iconCls:"action_saveFilter",handler:this.getFavoritesPanel().saveFilter.createDelegate(this.getFavoritesPanel())}]}))}b=b.concat(this.getAdditionalItems());Ext.each(b,function(g,f){g.startPosition=f},this);this.portalColumn=new Ext.ux.PortalColumn({columnWidth:1,items:b});this.portalColumn.on("resize",function(g,f){this.portalColumn.items.each(function(h){h.setWidth(f)},this)},this)}return this.portalColumn},getState:function(){var a={order:[],collapsed:[]};this.getPortalColumn().items.each(function(c,b){a.order.push(c.startPosition);a.collapsed.push(!!c.collapsed)},this);return a},xScrollKiller:function(a){var b=a.getEl().child("div[class^="+this.defaults.baseCls+"-body]");if(b){b.applyStyles("overflow-x: hidden")}}});Ext.reg("tine.widgets.mainscreen.westpanel",Tine.widgets.mainscreen.WestPanel);Ext.ns("Tine.widgets");Tine.widgets.MainScreen=function(a){Ext.apply(this,a);this.addEvents("beforeshow","show");Tine.widgets.MainScreen.superclass.constructor.call(this)};Ext.extend(Tine.widgets.MainScreen,Ext.util.Observable,{app:null,activeContentType:null,contentTypes:null,centerPanelClassNameSuffix:"GridPanel",getActiveContentType:function(){return(this.activeContentType)?this.activeContentType:""},getCenterPanel:function(b){b=b||this.getActiveContentType();if(!this[b+this.centerPanelClassNameSuffix]){try{this[b+this.centerPanelClassNameSuffix]=new Tine[this.app.appName][b+this.centerPanelClassNameSuffix]({app:this.app,plugins:[this.getWestPanel().getFilterPlugin(b)]})}catch(a){Tine.log.err('Could not create centerPanel "Tine.'+this.app.appName+"."+b+this.centerPanelClassNameSuffix+'"');Tine.log.err(a.stack?a.stack:a);this[b+this.centerPanelClassNameSuffix]=new Ext.Panel({html:"ERROR"})}}return this[b+this.centerPanelClassNameSuffix]},getNorthPanel:function(b){b=b||this.getActiveContentType();if(!this[b+"ActionToolbar"]){try{this[b+"ActionToolbar"]=this[b+this.centerPanelClassNameSuffix].getActionToolbar()}catch(a){Tine.log.err("Could not create northPanel");Tine.log.err(a.stack?a.stack:a);this[b+"ActionToolbar"]=new Ext.Panel({html:"ERROR"})}}return this[b+"ActionToolbar"]},getWestPanel:function(){var d=this.getActiveContentType(),b=d+"WestPanel";if(!this[b]){var a={app:this.app,contentTypes:this.contentTypes,contentType:d,listeners:{scope:this,selectionchange:function(){var h=this.getCenterPanel();if(h){try{var f=h.getGrid();if(f){var j=f.getSelectionModel();if(j){j.clearSelections();h.actionUpdater.updateActions(j.getSelectionsCollection())}}}catch(g){}}}}};try{if(Tine[this.app.name].hasOwnProperty(b)){this[b]=new Tine[this.app.appName][b](a)}else{this[b]=new Tine.widgets.mainscreen.WestPanel(a)}}catch(c){Tine.log.err("Could not create westPanel");Tine.log.err(c.stack?c.stack:c);this[b]=new Ext.Panel({html:"ERROR"})}}return this[b]},show:function(){if(this.fireEvent("beforeshow",this)!==false){this.showWestPanel();this.showCenterPanel();this.showNorthPanel();this.fireEvent("show",this)}return this},showCenterPanel:function(){Tine.Tinebase.MainScreen.setActiveContentPanel(this.getCenterPanel(this.getActiveContentType()),true)},showWestPanel:function(){Tine.Tinebase.MainScreen.setActiveTreePanel(this.getWestPanel(),true)},showNorthPanel:function(){Tine.Tinebase.MainScreen.setActiveToolbar(this.getNorthPanel(this.getActiveContentType()),true)}});Ext.ns("Tine.Tinebase");Tine.Tinebase.LicenseScreen=Ext.extend(Ext.Window,{closeAction:"close",modal:true,width:400,height:360,minWidth:400,minHeight:360,layout:"fit",title:null,initComponent:function(){this.title=_("License");this.items={layout:"fit",border:false,padding:10,autoScroll:true,autoLoad:{url:"LICENSE",isUpload:true,method:"GET",callback:function(c,b,a){c.update(Ext.util.Format.nl2br(a.responseText))}},buttons:[{text:_("Ok"),iconCls:"action_saveAndClose",handler:this.close,scope:this}]};Tine.Tinebase.LicenseScreen.superclass.initComponent.call(this)}});Ext.ns("Tine.Tinebase");Tine.Tinebase.CreditsScreen=Ext.extend(Ext.Window,{closeAction:"close",modal:true,width:400,height:360,minWidth:400,minHeight:360,layout:"fit",title:null,initComponent:function(){this.title=_("Credits");this.items={layout:"fit",border:false,padding:10,autoScroll:true,autoLoad:{url:"CREDITS",isUpload:true,method:"GET",callback:function(c,b,a){c.update(Ext.util.Format.nl2br(a.responseText))}},buttons:[{text:_("Ok"),iconCls:"action_saveAndClose",handler:this.close,scope:this}]};Tine.Tinebase.CreditsScreen.superclass.initComponent.call(this)}});Ext.ns("Tine.widgets");Tine.widgets.CountryCombo=Ext.extend(Ext.form.ComboBox,{fieldLabel:"Country",displayField:"translatedName",valueField:"shortName",typeAhead:true,forceSelection:true,mode:"local",triggerAction:"all",selectOnFocus:true,initComponent:function(){this.store=this.getCountryStore();this.emptyText=_("Select a country...");Tine.widgets.CountryCombo.superclass.initComponent.call(this)},getCountryStore:function(){var c=Ext.StoreMgr.get("Countries");if(!c){c=new Ext.data.JsonStore({baseParams:{method:"Tinebase.getCountryList"},root:"results",id:"shortName",fields:["shortName","translatedName"],remoteSort:false,sortInfo:{field:"translatedName",direction:"ASC"}});Ext.StoreMgr.add("Countries",c)}var b=Locale.getTranslationList("CountryList");if(b){var d={results:[]};for(var a in b){d.results.push({shortName:a,translatedName:b[a]})}c.loadData(d)}return c}});Ext.reg("widget-countrycombo",Tine.widgets.CountryCombo);Ext.ns("Tine.widgets","Tine.widgets.activities");Tine.widgets.activities.ActivitiesPanel=Ext.extend(Ext.Panel,{app:"",showAddNoteForm:true,notes:[],translation:null,recordNotesStore:null,title:null,iconCls:"notes_noteIcon",layout:"hfit",bodyStyle:"padding: 2px 2px 2px 2px",autoScroll:true,handlers:{addNote:function(c,f){var h=c.typeId,b=Ext.getCmp("note_textarea"),d=b.getValue(),g,a;if(h&&d){g=Ext.StoreMgr.lookup("NotesStore");a=new Tine.Tinebase.Model.Note({note_type_id:h,note:d});g.insert(0,a);b.setValue("");b.emptyText=b.emptyText}}},initActivitiesDataView:function(){var a=new Ext.XTemplate('<tpl for=".">','<div class="x-widget-activities-activitiesitem" id="{id}">','<div class="x-widget-activities-activitiesitem-text"','   ext:qtip="{[this.encode(values.note)]} - {[this.render(values.creation_time, "timefull")]} - {[this.render(values.created_by, "user")]}" >','{[this.render(values.note_type_id, "icon")]}&nbsp;{[this.render(values.creation_time, "timefull")]}<br/>','{[this.encode(values.note, true)]}<hr color="#aaaaaa">',"</div>","</div>","</tpl>",{encode:function(d,c){var b=Ext.util.Format.nl2br(Tine.Tinebase.common.doubleEncode(d));return(c)?Ext.util.Format.ellipsis(b,300):b},render:function(c,b){switch(b){case"icon":return Tine.widgets.activities.getTypeIcon(c);case"user":if(!c){c=Tine.Tinebase.registry.map.currentAccount.accountDisplayName}var d=c;return"<i>"+d+"</i>";case"time":if(!c){return""}return c.format(Locale.getTranslationData("Date","medium"));case"timefull":if(!c){return""}return c.format(Locale.getTranslationData("Date","medium"))+" "+c.format(Locale.getTranslationData("Time","medium"))}}});this.activities=new Ext.DataView({tpl:a,id:"grid_activities_limited",store:this.recordNotesStore,overClass:"x-view-over",itemSelector:"activities-item-small"})},initNoteForm:function(){var c=new Ext.form.TextArea({id:"note_textarea",emptyText:this.translation.gettext("Add a Note..."),grow:false,preventScrollbars:false,anchor:"100%",height:55,hideLabel:true});var b=[];var f=Tine.widgets.activities.getTypesStore();var a=f.getAt(f.find("is_user_type","1"));f.each(function(g){if(g.data.is_user_type===1){var h=new Ext.Action({text:this.translation.gettext("Add")+" "+this.translation.gettext(g.data.name)+" "+this.translation.gettext("Note"),tooltip:this.translation.gettext(g.data.description),handler:this.handlers.addNote,iconCls:"notes_"+g.data.name+"Icon",typeId:g.data.id,scope:this});b.push(h)}},this);var d=new Ext.SplitButton({text:this.translation.gettext("Add"),tooltip:this.translation.gettext("Add new note"),iconCls:"action_saveAndClose",menu:{items:b},handler:this.handlers.addNote,typeId:a.data.id});this.formFields={layout:"form",items:[c],bbar:["->",d]}},initComponent:function(){this.translation=new Locale.Gettext();this.translation.textdomain("Tinebase");this.title=this.translation.gettext("Notes");this.notes=[];this.recordNotesStore=new Ext.data.JsonStore({id:"id",fields:Tine.Tinebase.Model.Note,data:this.notes,sortInfo:{field:"creation_time",direction:"DESC"}});Ext.StoreMgr.add("NotesStore",this.recordNotesStore);this.initActivitiesDataView();if(this.showAddNoteForm){this.initNoteForm();this.items=[this.formFields,new Tine.widgets.activities.NotesFormField({recordNotesStore:this.recordNotesStore}),this.activities]}else{this.items=[new Tine.widgets.activities.NotesFormField({recordNotesStore:this.recordNotesStore}),this.activities]}Tine.widgets.activities.ActivitiesPanel.superclass.initComponent.call(this)}});Ext.reg("tineactivitiespanel",Tine.widgets.activities.ActivitiesPanel);Tine.widgets.activities.ActivitiesAddButton=Ext.extend(Ext.SplitButton,{iconCls:"notes_noteIcon",handlers:{addNote:function(a,b){this.formPanel=new Ext.FormPanel({layout:"form",labelAlign:"top",border:true,frame:true,items:[{xtype:"textarea",name:"notification",fieldLabel:this.translation.gettext("Enter new note:"),labelSeparator:"",anchor:"100% 100%"}]});this.onClose=function(){this.window.close()};this.onCancel=function(){this.onClose()};this.onOk=function(){var c=this.formPanel.getForm().findField("notification").getValue();this.handlers.onNoteAdd(c,a.typeId);this.onClose()};this.cancelAction=new Ext.Action({text:_("Cancel"),iconCls:"action_cancel",minWidth:70,handler:this.onCancel,scope:this});this.okAction=new Ext.Action({text:_("Ok"),iconCls:"action_saveAndClose",minWidth:70,handler:this.onOk,scope:this});this.window=Tine.WindowFactory.getWindow({title:this.translation.gettext("Add Note"),width:500,height:260,modal:true,layout:"fit",buttonAlign:"right",plain:true,bodyStyle:"padding:5px;",buttons:[this.cancelAction,this.okAction],items:[this.formPanel]})},onNoteAdd:function(d,b){if(d&&b){var c=Ext.StoreMgr.lookup("NotesStore");var a=new Tine.Tinebase.Model.Note({note_type_id:b,note:d});c.insert(0,a)}}},initComponent:function(){this.translation=new Locale.Gettext();this.translation.textdomain("Tinebase");var b=[],c=Tine.widgets.activities.getTypesStore(),a=c.getAt(c.find("is_user_type","1"));c.each(function(d){if(d.data.is_user_type==="1"){var f=new Ext.Action({requiredGrant:"editGrant",text:String.format(this.translation.gettext("Add a {0} Note"),d.data.name),tooltip:this.translation.gettext(d.data.description),handler:this.handlers.addNote,iconCls:d.data.icon_class,typeId:d.data.id,scope:this});b.push(f)}},this);this.requiredGrant="editGrant";this.text=this.translation.gettext("Add Note");this.tooltip=this.translation.gettext("Add new note");this.menu={items:b};this.handler=this.handlers.addNote;this.typeId=a.data.id;Tine.widgets.activities.ActivitiesAddButton.superclass.initComponent.call(this)}});Ext.reg("widget-activitiesaddbutton",Tine.widgets.activities.ActivitiesAddButton);Tine.widgets.activities.ActivitiesTabPanel=Ext.extend(Ext.Panel,{app:"",store:null,translation:null,paging:{start:0,limit:20,sort:"creation_time",dir:"DESC"},record_id:null,record_model:null,title:null,layout:"fit",getActivitiesGrid:function(){var c=new Ext.grid.ColumnModel([{resizable:true,id:"note_type_id",header:this.translation.gettext("Type"),dataIndex:"note_type_id",width:15,renderer:Tine.widgets.activities.getTypeIcon},{resizable:true,id:"note",header:this.translation.gettext("Note"),dataIndex:"note"},{resizable:true,id:"created_by",header:this.translation.gettext("Created By"),dataIndex:"created_by",width:70},{resizable:true,id:"creation_time",header:this.translation.gettext("Timestamp"),dataIndex:"creation_time",width:50,renderer:Tine.Tinebase.common.dateTimeRenderer}]);c.defaultSortable=true;var b=new Ext.grid.RowSelectionModel({multiSelect:true});var d=new Ext.PagingToolbar({pageSize:20,store:this.store,displayInfo:true,displayMsg:this.translation.gettext("Displaying history records {0} - {1} of {2}"),emptyMsg:this.translation.gettext("No history to display")});var a=new Ext.grid.GridPanel({id:"Activities_Grid",cls:"tw-activities-grid",store:this.store,cm:c,tbar:d,selModel:b,border:false,viewConfig:{autoFill:true,forceFit:true,ignoreAdd:true,autoScroll:true}});return a},initStore:function(){this.store=new Ext.data.JsonStore({id:"id",autoLoad:false,root:"results",totalProperty:"totalcount",fields:Tine.Tinebase.Model.Note,remoteSort:true,baseParams:{method:"Tinebase.searchNotes"},sortInfo:{field:this.paging.sort,direction:this.paging.dir}});Ext.StoreMgr.add("NotesGridStore",this.store);this.store.on("beforeload",function(b,c){if(!c.params){c.params={}}c.params.sort=b.getSortState()?b.getSortState().field:this.paging.sort;c.params.dir=b.getSortState()?b.getSortState().direction:this.paging.dir;c.params.start=c.params.start?c.params.start:this.paging.start;c.params.limit=c.params.limit?c.params.limit:this.paging.limit;c.params.paging=Ext.copyTo({},c.params,"sort,dir,start,limit");var a=Ext.getCmp("activitiesFilterToolbar");var d=a?a.getValue():[];d.push({field:"record_model",operator:"equals",value:this.record_model},{field:"record_id",operator:"equals",value:(this.record_id)?this.record_id:0},{field:"record_backend",operator:"equals",value:"Sql"});c.params.filter=d},this);this.store.on("load",function(b,a){var c=Ext.StoreMgr.lookup("NotesStore");if(c){c.each(function(d){if(!d.data.creation_time){b.insert(0,d)}})}},this)},initComponent:function(){this.translation=new Locale.Gettext();this.translation.textdomain("Tinebase");this.title=this.translation.gettext("History");this.initStore();this.activitiesGrid=this.getActivitiesGrid();var a=new Tine.widgets.grid.FilterToolbar({id:"activitiesFilterToolbar",filterModels:[{label:_("Quick search"),field:"query",operators:["contains"]},{label:this.translation.gettext("Time"),field:"creation_time",valueType:"date",pastOnly:true}],defaultFilter:"query",filters:[]});a.on("change",function(){this.store.load({})},this);this.items=[new Ext.Panel({layout:"border",items:[{region:"center",xtype:"panel",layout:"fit",border:false,items:this.activitiesGrid},{region:"north",border:false,items:a,listeners:{scope:this,afterlayout:function(b){b.suspendEvents();b.setHeight(a.getHeight());b.ownerCt.layout.layout();b.resumeEvents()}}}]})];this.on("activate",function(b){b.store.load({})});Tine.widgets.dialog.MultipleEditDialogPlugin.prototype.registerSkipItem(this);Tine.widgets.activities.ActivitiesTabPanel.superclass.initComponent.call(this)}});Ext.reg("tineactivitiestabpanel",Tine.widgets.activities.ActivitiesTabPanel);Tine.widgets.activities.NotesFormField=Ext.extend(Ext.form.Field,{recordNotesStore:null,name:"notes",hidden:true,hideLabel:true,initComponent:function(){Tine.widgets.activities.NotesFormField.superclass.initComponent.call(this);this.hide()},getValue:function(){var a=[];this.recordNotesStore.each(function(b){a.push(b.data)});return a},setValue:function(a){this.recordNotesStore.loadData(a)}});Tine.widgets.activities.getTypesStore=function(){var a=Ext.StoreMgr.get("noteTypesStore");if(!a){a=new Ext.data.JsonStore({fields:Tine.Tinebase.Model.NoteType,baseParams:{method:"Tinebase.getNoteTypes"},root:"results",totalProperty:"totalcount",id:"id",remoteSort:false});if(Tine.Tinebase.registry.get("NoteTypes")){a.loadData(Tine.Tinebase.registry.get("NoteTypes"))}Ext.StoreMgr.add("noteTypesStore",a)}return a};Tine.widgets.activities.getTypeIcon=function(c){var b=Tine.widgets.activities.getTypesStore();var a=b.getById(c);if(a){return'<img src="'+a.data.icon+'" ext:qtip="'+Tine.Tinebase.common.doubleEncode(a.data.description)+'"/>'}else{return""}};Ext.ns("Tine.Tinebase.widgets.form");Tine.Tinebase.widgets.form.RecordPickerComboBox=Ext.extend(Ext.ux.form.ClearableComboBox,{blurOnSelect:false,recordClass:null,recordProxy:null,app:null,selectedRecord:null,sortBy:null,lastStoreTransactionId:null,allowLinkingItself:null,editDialog:null,triggerAction:"all",pageSize:10,minChars:3,forceSelection:true,initComponent:function(){this.app=Tine.Tinebase.appMgr.get(this.recordClass.getMeta("appName"));this.displayField=this.recordClass.getMeta("titleProperty");this.valueField=this.recordClass.getMeta("idProperty");this.disableClearer=!this.allowBlank;this.loadingText=_("Searching...");this.store=new Tine.Tinebase.data.RecordStore(Ext.copyTo({readOnly:true,proxy:this.recordProxy||undefined},this,"totalProperty,root,recordClass"));this.on("beforequery",this.onBeforeQuery,this);this.store.on("beforeloadrecords",this.onStoreBeforeLoadRecords,this);this.initTemplate();Tine.Tinebase.widgets.form.RecordPickerComboBox.superclass.initComponent.call(this)},initTemplate:function(){if(!this.tpl){this.tpl=new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{[this.getTitle(values.'+this.recordClass.getMeta("idProperty")+")]}</div></tpl>",{getTitle:(function(c){var a=this.getStore().getById(c),b=a?a.getTitle():"&nbsp";return Ext.util.Format.htmlEncode(b)}).createDelegate(this)})}},onBeforeLoad:function(b,c){Tine.Tinebase.widgets.form.RecordPickerComboBox.superclass.onBeforeLoad.call(this,b,c);this.lastStoreTransactionId=c.transactionId=Ext.id();var a={start:c.params.start,limit:c.params.limit,sort:(this.sortBy)?this.sortBy:this.valueField,dir:"ASC"};Ext.applyIf(c.params,a);c.params.paging=a},onStoreBeforeLoadRecords:function(d,b,c,a){if(!this.lastStoreTransactionId||b.transactionId&&this.lastStoreTransactionId!==b.transactionId){Tine.log.debug("Tine.Tinebase.widgets.form.RecordPickerComboBox::onStoreBeforeLoadRecords cancelling old transaction request.");return false}},onBeforeQuery:function(a){this.store.baseParams.filter=[{field:"query",operator:"contains",value:a.query}]},onRender:function(b,a){Tine.Tinebase.widgets.form.RecordPickerComboBox.superclass.onRender.call(this,b,a);var d=this.getEl();this.mon(d,{scope:this,contextmenu:Ext.emptyFn});this.relayEvents(d,["contextmenu"])},onSelect:function(a,b){this.selectedRecord=a;return Tine.Tinebase.widgets.form.RecordPickerComboBox.superclass.onSelect.call(this,a,b)},onSpecialkey:function(c,b){if(b.getKey()===b.ENTER){var d=c.getValue();var a=this.store.getById(d);this.onSelect(a)}},setValue:function(c){if(c){if(typeof(c.get)==="function"){if(this.store.indexOf(c)<0){this.store.addSorted(c)}c=c.get(this.valueField)}else{if(Ext.isObject(c)){if(!this.store.getById(c)){var a=this.recordProxy?this.recordProxy.recordReader({responseText:Ext.encode(c)}):new this.recordClass(c);this.store.addSorted(a)}c=c[this.valueField]||""}else{if(Ext.isPrimitive(c)&&c==this.getValue()){return this.setValue(this.selectedRecord)}}}}var b=this.findRecord(this.valueField,c),d=c;if(b){d=b.getTitle();this.selectedRecord=b;if(this.allowLinkingItself===false){if(b.getId()==this.editDialog.record.getId()){Ext.MessageBox.show({title:_("Failure"),msg:_("You tried to link a record with itself. This is not allowed!"),buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR});return}}}else{if(Ext.isDefined(this.valueNotFoundText)){d=this.valueNotFoundText}}this.lastSelectionText=d;if(this.hiddenField){this.hiddenField.value=Ext.value(c,"")}Tine.Tinebase.widgets.form.RecordPickerComboBox.superclass.setValue.call(this,d);this.value=c;return this}});Ext.reg("tinerecordpickercombobox",Tine.Tinebase.widgets.form.RecordPickerComboBox);Ext.ns("Tine.widgets.relation");Tine.widgets.relation.PickerCombo=Ext.extend(Ext.Container,{items:null,combo:null,layout:"fit",editDialog:null,recordClass:null,store:null,initComponent:function(){this.combo=Tine.widgets.form.RecordPickerManager.get(this.app,this.recordClass,Ext.applyIf({},this));this.items=[this.combo];this.deferredLoading()},deferredLoading:function(){if(!this.editDialog.relationsPanel){this.deferredLoading.defer(100,this);return}this.store=this.editDialog.relationsPanel.getStore();this.fullModelName=this.recordClass.getMeta("appName")+"_Model_"+this.recordClass.getMeta("modelName");this.combo.on("select",function(){var g=this.combo.getValue();if(g.length){var c=this.combo.selectedRecord;if(this.modelUnique){var f=false,h;Ext.each(this.editDialog.relationPickers,function(j){if(j!=this){if(j.getValue()==this.getValue()){f=true;h=j.fieldLabel;return false}}},this)}if(f){if(this.combo.startRecord){var d=this.fullModelName.split("_Model_");var b=this.combo.startRecord}else{b=null}this.combo.reset();this.combo.setValue(b);this.combo.selectedRecord=b;this.combo.markInvalid(String.format(_('The {1} "{2}" is already used in the Field "{0}" and can be linked only once!'),h,this.recordClass.getRecordName(),c.get(this.recordClass.getMeta("titleProperty"))));return false}if(g!=this.combo.startValue){this.removeIdFromStore(this.combo.startValue)}if(this.store.findBy(function(j,k){if(j){if(j.get("related_id")==g&&j.get("type")==this.relationType){return true}}},this)==-1){var a=new Tine.Tinebase.Model.Relation(Ext.apply(this.editDialog.relationsPanel.getRelationDefaults(),{related_record:c.data,related_id:c.id,related_model:this.fullModelName,type:this.relationType,own_degree:this.relationDegree}),c.id);this.combo.startRecord=c;this.store.add(a)}}else{this.removeIdFromStore(this.combo.startValue)}},this);if(!this.editDialog.relationPickers){this.editDialog.relationPickers=[]}this.editDialog.relationPickers.push(this);Tine.widgets.relation.PickerCombo.superclass.initComponent.call(this)},removeIdFromStore:function(b){if(b){var a=this.store.findBy(function(c){if(c){if(c.get("related_id")==b&&c.get("type")==this.relationType){return true}}else{return false}},this);this.store.removeAt(a)}},setValue:function(a){return this.combo.setValue(a)},clear:function(){this.combo.startRecord=null;return this.combo.setValue(null)},getValue:function(){return this.combo.getValue()}});Ext.reg("tinerelationpickercombo",Tine.widgets.relation.PickerCombo);Ext.ns("Tine.Tinebase.widgets.form");Tine.Tinebase.widgets.form.ConfigPanel=Ext.extend(Ext.FormPanel,{saveMethod:"",registryKey:"",actionToolbarItems:[],border:false,bodyStyle:"padding:5px 5px 0",labelAlign:"left",labelSeparator:":",labelWidth:150,autoScroll:true,app:null,onSaveConfig:function(){if(this.isValid()){var a=this.form2config();this.loadMask.show();Ext.Ajax.request({scope:this,params:{method:this.saveMethod,data:a},success:function(b){var c=Ext.util.JSON.decode(b.responseText);for(key in c){if(key!="status"){Tine.Setup.registry.replace(key,c[key])}}this.loadMask.hide()},failure:function(b,c){this.loadMask.hide();var f=Ext.util.JSON.decode(b.responseText),d=f.data?f.data:f;switch(d.code){case 503:Ext.MessageBox.show({title:_("Configuration Problem"),msg:d.message,buttons:Ext.Msg.OK,icon:Ext.MessageBox.WARNING,fn:function(){window.location.reload()}});break;default:Tine.Tinebase.ExceptionHandler.handleRequestException(d)}}})}else{this.alertInvalidData()}},alertInvalidData:function(){Ext.Msg.alert(this.app.i18n._("Invalid configuration"),this.app.i18n._("You need to correct the red marked fields before config could be saved"))},initComponent:function(){this.initActions();this.items=this.getFormItems();Tine.Tinebase.widgets.form.ConfigPanel.superclass.initComponent.call(this)},onRender:function(b,a){Tine.Tinebase.widgets.form.ConfigPanel.superclass.onRender.call(this,b,a);var c=this.config2form.defer(250,this,[Tine.Setup.registry.get(this.registryKey)]);Tine.Setup.registry.on("replace",this.applyRegistryState,this);this.loadMask=new Ext.LoadMask(b,{msg:this.app.i18n._("Transferring Configuration...")})},applyRegistryState:function(){},getFormItems:function(){return[]},form2config:function(){var d={};this.getForm().items.each(function(h){d[h.name]=h.getValue()});var a={};var g,c,f,b;for(key in d){g=key.split("_");b=a;while(c=g.shift()){if(g.length==0){b[c]=d[key]}else{if(!b[c]){b[c]={};f=Ext.getCmp("setup-"+c+"-group");if(f&&f.checkboxToggle){b[c].active=!f.collapsed}}b=b[c]}}}return a},config2form:function(b){var c=arguments[1]?arguments[1]:{};var a=arguments[2]?arguments[2]:"";var d;for(key in b){if(typeof b[key]=="object"){this.config2form(b[key],c,a?a+"_"+key:key)}else{c[a+"_"+key]=b[key];d=Ext.getCmp("setup-"+a+"-group");if(d&&key=="active"&&b.active){d.expand()}}}if(!a){this.getForm().setValues(c);this.applyRegistryState()}},initActions:function(){this.action_saveConfig=new Ext.Action({text:this.app.i18n._("Save config"),iconCls:"setup_action_save_config",scope:this,handler:this.onSaveConfig,disabled:true});this.actions=[this.action_saveConfig];this.actionToolbar=new Ext.Toolbar({items:this.actions.concat(this.actionToolbarItems)})},isValid:function(){var a=this.getForm();return a.isValid()},changeCard:function(f,c){var d=f.getValue();Tine.log.debug("changeCard() -> value: "+d);var a=Ext.getCmp(c+"CardLayout"),b=(a)?a.getLayout():null;if(b&&b!=="card"){Tine.log.debug("changeCard() -> set active item: "+c+d);b.setActiveItem(c+d)}}});Ext.ns("Tine.Tinebase.widgets.form");Tine.Tinebase.widgets.form.AutoCompleteField=Ext.extend(Ext.form.ComboBox,{property:null,recordClass:null,forceSelection:false,triggerAction:"all",minChars:3,queryParam:"startswith",hideTrigger:true,initComponent:function(){if(!this.property&&this.name){this.property=this.name}this.displayField=this.valueField=this.property;this.store=new Ext.data.JsonStore({fields:[this.property],baseParams:{method:this.recordClass.getMeta("appName")+".autoComplete"+this.recordClass.getMeta("modelName")+"Property",property:this.property,sort:this.property,dir:"ASC"},root:"results",totalProperty:"totalcount"});Tine.Tinebase.widgets.form.AutoCompleteField.superclass.initComponent.call(this)}});Ext.reg("tine.widget.field.AutoCompleteField",Tine.Tinebase.widgets.form.AutoCompleteField);Ext.ns("Tine.widgets.form");Tine.widgets.form.FileUploadButton=Ext.extend(Ext.Button,{allowedTypes:null,browsePlugin:null,iconCls:"action_import",initComponent:function(){this.origHandler=this.handler;this.origScope=this.scope;this.origIconCls=this.iconCls;this.handler=this.onFileSelect;this.scope=this;this.browsePlugin=new Ext.ux.file.BrowsePlugin({multiple:false});this.plugins=this.plugins||[];this.plugins.push(this.browsePlugin);Tine.widgets.form.FileUploadButton.superclass.initComponent.call(this)},onFileSelect:function(b,a){if(Ext.isArray(this.allowedTypes)&&this.allowedTypes.indexOf(b.getFileCls())<0){Ext.MessageBox.alert(_("Wrong File Type"),[_("Please select a file with one of the following extensions:"),"<br />",this.allowedTypes].join("")).setIcon(Ext.MessageBox.ERROR);return}this.upload=new Ext.ux.file.Upload({fileSelector:b});this.upload.on("uploadcomplete",this.onUploadComplete,this);this.setIconClass("x-tinebase-uploading");this.upload.upload()},onUploadComplete:function(b,a){this.fileRecord=a;this.setText([a.get("name")," (",Tine.Tinebase.common.byteRenderer(a.get("size")),")"].join(""));this.setIconClass("action_saveAndClose");this.setWidth(Ext.util.TextMetrics.measure(this.btnEl,this.text).width+20);if(Ext.isFunction(this.origHandler)){this.origHandler.apply(this.origScope,arguments)}},getTempFileId:function(){return this.fileRecord.get("tempFile").id}});Ext.reg("tw.uploadbutton",Tine.widgets.form.FileUploadButton);Ext.ns("Tine.Tinebase.widgets.form");Tine.Tinebase.widgets.form.UidTriggerField=Ext.extend(Ext.form.TriggerField,{itemCls:"tw-uidTriggerField",enableKeyEvents:true,initComponent:function(){this.on("keyup",this.manageTriggerField);Tine.Tinebase.widgets.form.UidTriggerField.superclass.initComponent.call(this)},manageTriggerField:function(){this.setHideTrigger(this.getValue())},setValue:function(b){var a=Tine.Tinebase.widgets.form.UidTriggerField.superclass.setValue.call(this,b);this.manageTriggerField();return a},onTriggerClick:function(){if(!this.getValue()){this.setValue(Tine.Tinebase.data.Record.generateUID());this.setHideTrigger(true)}}});Ext.reg("tw-uidtriggerfield",Tine.Tinebase.widgets.form.UidTriggerField);Ext.ns("Tine.widgets.persistentfilter.model");Tine.widgets.persistentfilter.model.PersistentFilter=Tine.Tinebase.data.Record.create(Tine.Tinebase.Model.genericFields.concat([{name:"id"},{name:"application_id"},{name:"account_id"},{name:"model"},{name:"filters"},{name:"name"},{name:"description"}]),{appName:"Tinebase",modelName:"PersistentFilter",idProperty:"id",titleProperty:"name",recordName:"Favorite",recordsName:"Favorites",isShared:function(){return this.get("account_id")===null},isShipped:function(){return((this.get("account_id")===null)&&(this.get("created_by")===null))},isDefault:function(){var a=Tine.Tinebase.appMgr.getById(this.get("application_id"));return this.app&&this.get("id")===a.getRegistry().get("preferences").get("defaultpersistentfilter")}});Tine.widgets.persistentfilter.model.PersistentFilter.getDefaultFavorite=function(a){var d=Tine.Tinebase.appMgr.get(a),b=d.getRegistry().get("preferences"),c=b?b.get("defaultpersistentfilter"):null;return c?Tine.widgets.persistentfilter.store.getPersistentFilterStore().getById(c):null};Tine.widgets.persistentfilter.model.persistentFilterProxy=new Tine.Tinebase.data.RecordProxy({appName:"Tinebase_PersistentFilter",modelName:"PersistentFilter",recordClass:Tine.widgets.persistentfilter.model.PersistentFilter});Ext.ns("Tine.widgets.persistentfilter.store");Tine.widgets.persistentfilter.store.PersistentFilterStore=Ext.extend(Ext.data.ArrayStore,{});Tine.widgets.persistentfilter.store.getPersistentFilterStore=function(){if(!Tine.widgets.persistentfilter.store.persistentFilterStore){if(window.isMainWindow){var a=Tine.widgets.persistentfilter.model.PersistentFilter.getFieldDefinitions();var d=Tine.widgets.persistentfilter.store.persistentFilterStore=new Tine.widgets.persistentfilter.store.PersistentFilterStore({fields:a});var b=Tine.Tinebase.registry.get("persistentFilters").results;Ext.each(b,function(h,f){var g=new Tine.widgets.persistentfilter.model.PersistentFilter(h);d.add(g)},this)}else{var c=Ext.ux.PopupWindowMgr.getMainWindow();Tine.widgets.persistentfilter.store.persistentFilterStore=c.Tine.widgets.persistentfilter.store.getPersistentFilterStore()}}return Tine.widgets.persistentfilter.store.persistentFilterStore};Ext.ns("Tine.widgets.persistentfilter");Tine.widgets.persistentfilter.PickerPanel=Ext.extend(Ext.tree.TreePanel,{app:null,filterMountId:null,contentType:null,autoScroll:true,border:false,rootVisible:false,enableDD:true,stateId:null,grid:null,initComponent:function(){this.stateId="widgets-persistentfilter-pickerpanel_"+this.app.name+"_"+this.contentType;this.store=this.store||Tine.widgets.persistentfilter.store.getPersistentFilterStore();var b=Ext.state.Manager.get(this.stateId,{});this.recordCollection=this.store.queryBy(function(d,f){if(d.get("application_id")==this.app.id){if(this.contentType){var c=this.app.appName+"_Model_"+this.contentType+"Filter";if(d.get("model")==c){return true}else{return false}}else{return true}}return false},this);var a=10000;this.recordCollection.each(function(c){if(b[c.get("id")]){c.set("sorting",b[c.get("id")])}else{a++;c.set("sorting",a)}},this);this.loader=new Tine.widgets.persistentfilter.PickerTreePanelLoader({app:this.app,recordCollection:this.recordCollection,contentType:this.contentType});new Ext.tree.TreeSorter(this,{property:"sorting",sortType:function(c){return c.attributes.sorting}});this.on("nodedrop",function(){this.saveState()},this);this.filterNode=this.filterNode||new Ext.tree.AsyncTreeNode({text:_("My favorites"),id:"_persistentFilters",leaf:false,expanded:true});if(this.filterMountId===null){this.root=this.filterNode}Tine.widgets.persistentfilter.PickerPanel.superclass.initComponent.call(this);this.on("click",function(c){if(c.attributes.isPersistentFilter){this.getFilterToolbar().fireEvent("change",this.getFilterToolbar());c.select();this.onFilterSelect(this.recordCollection.get(c.id))}else{if(c.id=="_persistentFilters"){c.expand();return false}}},this);this.on("contextmenu",this.onContextMenu,this)},afterRender:function(){Tine.widgets.persistentfilter.PickerPanel.superclass.afterRender.call(this);if(this.filterMountId!==null){this.getNodeById(this.filterMountId).appendChild(this.filterNode)}this.getFilterToolbar().on("change",this.onFilterChange,this)},saveState:function(){var b={};var a=0;this.getRootNode().eachChild(function(d){a++;d.attributes.sorting=a;var f=this.recordCollection.get(d.attributes.id);var c=f.get("sorting");if(c!=a){f.set("sorting",a);f.commit()}b[d.id]=a},this);Ext.state.Manager.set(this.stateId,b)},onFilterSelect:function(b){var a=this.getGrid().getStore();a.on("beforeload",this.storeOnBeforeload,this);a.load({persistentFilter:b})},storeOnBeforeload:function(a,b){b.params.filter=b.persistentFilter.get("filters");a.un("beforeload",this.storeOnBeforeload,this)},onFilterChange:function(){this.getSelectionModel().clearSelections()},getAdditionalCtxItems:function(c){var b=[];var a=Tine.Tinebase.appMgr.get("ActiveSync");if(a){b=b.concat(a.getPersistentFilterPickerCtxItems(this,c))}return b},getFilterToolbar:function(){if(!this.filterToolbar){this.filterToolbar=this.getGrid().filterToolbar}return this.filterToolbar},getGrid:function(){if(!this.grid){this.grid=this.app.getMainScreen().getCenterPanel()}return this.grid},getPersistentFilterNode:function(){return this.filterNode},onContextMenu:function(c,d){if(!c.attributes.isPersistentFilter){return}var a=this.store.getById(c.id);var b=a.isShipped();var f=new Ext.menu.Menu({items:[{text:_("Delete Favorite"),iconCls:"action_delete",hidden:b,handler:this.onDeletePersistentFilter.createDelegate(this,[c,d])},{text:_("Edit Favorite"),iconCls:"action_edit",hidden:b,handler:this.onEditPersistentFilter.createDelegate(this,[c,d])},{text:_("Overwrite Favorite"),iconCls:"action_saveFilter",hidden:b,handler:this.onOverwritePersistentFilter.createDelegate(this,[c,d])}].concat(this.getAdditionalCtxItems(a))});f.showAt(d.getXY())},onDeletePersistentFilter:function(a){Ext.MessageBox.confirm(_("Confirm"),String.format(_('Do you really want to delete the favorite "{0}"?'),a.text),function(c){if(c=="yes"){Ext.MessageBox.wait(_("Please wait"),String.format(_('Deleting Favorite "{0}"'),this.containerName,a.text));var b=this.store.getById(a.id);Tine.widgets.persistentfilter.model.persistentFilterProxy.deleteRecords([b],{scope:this,success:function(){this.store.remove(b);this.recordCollection.remove(b);this.filterNode.findChild("id",b.get("id")).remove();Ext.MessageBox.hide()}})}},this)},onEditPersistentFilter:function(b){var a=this.store.getById(b.id);this.getEditWindow(a)},onOverwritePersistentFilter:function(b){var a=this.store.getById(b.id);Ext.MessageBox.confirm(_("Overwrite?"),String.format(_('Do you want to overwrite the favorite "{0}"?'),b.text),function(d){if(d=="yes"){Ext.MessageBox.wait(_("Please wait"),String.format(_('Overwriting Favorite "{0}"'),b.text));var c=this.getFilterToolbar();a.set("filters",c.getAllFilterData());this.createOrUpdateFavorite(a)}},this,false,b.text)},saveFilter:function(){var a=this.getFilterToolbar();var b=this.getNewEmptyRecord();b.set("filters",a.getAllFilterData());if(!a.isSaveAllowed()){Ext.Msg.alert(_("Could not save Favorite"),_("Your current view does not support favorites"));return}this.getEditWindow(b)},getEditWindow:function(b){if(b.hasOwnProperty("modified")){var d=_("Create Favorite")}else{var d=_("Edit Favorite")}var a=160;if((Tine.Tinebase.common.hasRight("manage_shared_favorites",this.app.name))&&(!b.isDefault())){a=185}var c=Tine.WindowFactory.getWindow({modal:true,app:this.app,record:b,title:d,width:300,height:a,contentPanelConstructor:"Tine.widgets.persistentfilter.EditPersistentFilterPanel",contentPanelConstructorConfig:null});c.on("update",function(f){Ext.MessageBox.wait(_("Please wait"),String.format(_('Saving Favorite "{0}"'),b.get("name")));this.createOrUpdateFavorite(c.record)},this)},createOrUpdateFavorite:function(a){Tine.widgets.persistentfilter.model.persistentFilterProxy.saveRecord(a,{scope:this,success:function(f){var c=this.recordCollection.get(f.id);if(c){f.set("sorting",c.get("sorting"));this.store.remove(c);this.recordCollection.remove(c);this.filterNode.findChild("id",c.get("id")).remove()}else{var d=0;f.set("sorting",d)}var b=f.data;this.loader.inspectCreateNode(b);this.filterNode.appendChild(new Ext.tree.TreeNode(b));this.store.add(f);this.recordCollection.add(f);this.recordCollection.sort();if(!c){this.saveState()}Ext.Msg.hide();this.selectFilter(f)}})},selectFilter:function(a){if(!a){return}this.getFilterToolbar().fireEvent("change",this.getFilterToolbar());var b=this.getNodeById(a.id);if(b){this.getSelectionModel().select(b)}else{this.getLoader().selectedFilterId=a.id}this.onFilterSelect(a)},getNewEmptyRecord:function(){var c=this.filterModel,a=this.getFilterToolbar();if(!c){var d=this.recordClass||this.treePanel?this.treePanel.recordClass:a.store.reader.recordType;c=d.getMeta("appName")+"_Model_"+d.getMeta("modelName")+"Filter"}var b=new Tine.widgets.persistentfilter.model.PersistentFilter({application_id:this.app.id,account_id:Tine.Tinebase.registry.get("currentAccount").accountId,model:c,filters:null,name:null,description:null});return b}});Tine.widgets.persistentfilter.PickerTreePanelLoader=Ext.extend(Tine.widgets.tree.Loader,{recordCollection:null,selectedFilterId:null,requestData:function(b,c,a){if(this.fireEvent("beforeload",this,b,c)!==false){b.beginUpdate();this.recordCollection.each(function(d){var f=this.createNode(d.copy().data);if(f){b.appendChild(f)}},this);b.endUpdate();this.runCallback(c,a||b,[b])}else{this.runCallback(c,a||b,[])}},inspectCreateNode:function(a){var d=!!a.model&&!!a.filters;var c=(a.account_id===null)?true:false;var b="";var f="";if(c){b=_("(shared)");f="-shared"}if(d){Ext.apply(a,{isPersistentFilter:d,text:Ext.util.Format.htmlEncode(this.app.i18n._hidden(a.name)),qtip:Tine.Tinebase.common.doubleEncode(a.description?this.app.i18n._hidden(a.description)+" "+b:b),selected:a.id===this.selectedFilterId,id:a.id,sorting:a.sorting,draggable:true,allowDrop:false,leaf:a.leaf===false?a.leaf:true,cls:"tinebase-westpanel-node-favorite"+f})}}});Ext.ns("Tine.widgets.persistentfilter");Tine.widgets.persistentfilter.EditPersistentFilterPanel=Ext.extend(Ext.FormPanel,{layout:"fit",border:false,cls:"tw-editdialog",bodyStyle:"padding:5px",labelAlign:"top",anchor:"100% 100%",deferredRender:false,buttonAlign:null,bufferResize:500,initComponent:function(){this.addEvents("cancel","save","close");this.initActions();this.initButtons();this.items=this.getFormItems();Tine.widgets.persistentfilter.EditPersistentFilterPanel.superclass.initComponent.call(this)},initActions:function(){this.action_save=new Ext.Action({text:_("OK"),minWidth:70,scope:this,handler:this.onSave,iconCls:"action_saveAndClose"});this.action_cancel=new Ext.Action({text:_("Cancel"),minWidth:70,scope:this,handler:this.onCancel,iconCls:"action_cancel"})},initButtons:function(){this.fbar=["->",this.action_cancel,this.action_save]},onRender:function(b,a){Tine.widgets.dialog.EditDialog.superclass.onRender.call(this,b,a);new Ext.KeyMap(this.el,[{key:[13],ctrl:false,fn:this.onSave,scope:this}])},onSave:function(){if(!this.window.record){this.window.record=this.getNewEmptyRecord()}if(this.inputTitle.isValid()){if(this.inputTitle.getValue().length<40){this.window.record.set("name",this.inputTitle.getValue())}else{Ext.Msg.alert(_("Favorite not Saved"),_("You have to supply a shorter name! Names of favorite can only be up to 40 characters long."));this.onCancel()}}else{Ext.Msg.alert(_("Favorite not Saved"),_("You have to supply a name for the favorite!"));this.onCancel()}if(this.inputDescription.isValid()){this.window.record.set("description",this.inputDescription.getValue())}this.window.record.set("account_id",Tine.Tinebase.registry.get("currentAccount").accountId);if(Tine.Tinebase.common.hasRight("manage_shared_favorites",this.window.app.name)){if(this.inputCheck.getValue()){this.window.record.set("account_id",null)}}this.window.fireEvent("update");this.purgeListeners();this.window.purgeListeners();this.window.close()},onCancel:function(){this.fireEvent("cancel");this.purgeListeners();this.window.close()},getFormItems:function(){this.inputTitle=new Ext.form.TextField({value:(this.window.record)?this.window.record.get("name"):"",allowBlank:false,fieldLabel:_("Title"),width:"97%",minLength:1,maxLength:40});this.inputDescription=new Ext.form.TextField({value:(this.window.record)?this.window.record.get("description"):"",allowBlank:true,fieldLabel:_("Description"),width:"97%",minLength:0,maxLength:255});this.inputCheck=new Ext.form.Checkbox({checked:(this.window.record)?this.window.record.isShared():false,hideLabel:true,boxLabel:_("Shared Favorite (visible by all users)")});var a=[{region:"center",layout:{align:"stretch",type:"vbox"}},this.inputTitle,this.inputDescription];if(Tine.Tinebase.common.hasRight("manage_shared_favorites",this.window.app.name)){a.push(this.inputCheck)}return{border:false,frame:true,layout:"form",items:a}}});Ext.ns("Tine","Tine.Tinebase");Tine.Tinebase.PasswordChangeDialog=Ext.extend(Ext.Window,{id:"changePassword_window",closeAction:"close",modal:true,width:350,height:230,minWidth:350,minHeight:230,layout:"fit",plain:true,title:null,initComponent:function(){this.currentAccount=Tine.Tinebase.registry.get("currentAccount");this.title=(this.title!==null)?this.title:String.format(_('Change Password For "{0}"'),this.currentAccount.accountDisplayName);this.items=new Ext.FormPanel({bodyStyle:"padding:5px;",buttonAlign:"right",labelAlign:"top",anchor:"100%",id:"changePasswordPanel",defaults:{xtype:"textfield",inputType:"password",anchor:"100%",allowBlank:false},items:[{id:"oldPassword",fieldLabel:_("Old Password"),name:"oldPassword"},{id:"newPassword",fieldLabel:_("New Password"),name:"newPassword"},{id:"newPasswordSecondTime",fieldLabel:_("Repeat new Password"),name:"newPasswordSecondTime"}],buttons:[{text:_("Cancel"),iconCls:"action_cancel",handler:function(){Ext.getCmp("changePassword_window").close()}},{text:_("Ok"),iconCls:"action_saveAndClose",handler:function(){var b=Ext.getCmp("changePasswordPanel").getForm();var a;if(b.isValid()){a=b.getValues();if(a.newPassword==a.newPasswordSecondTime){Ext.Ajax.request({waitTitle:_("Please Wait!"),waitMsg:_("changing password..."),params:{method:"Tinebase.changePassword",oldPassword:a.oldPassword,newPassword:a.newPassword},success:function(f,d){var c=Ext.util.JSON.decode(f.responseText);if(c.success){Ext.getCmp("changePassword_window").close();Ext.MessageBox.show({title:_("Success"),msg:_("Your password has been changed."),buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO});Ext.Ajax.request({params:{method:"Tinebase.updateCredentialCache",password:a.newPassword}})}else{Ext.MessageBox.show({title:_("Failure"),msg:c.errorMessage,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR})}}})}else{Ext.MessageBox.show({title:_("Failure"),msg:_("The new passwords mismatch, please correct them."),buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR})}}}}]});Tine.Tinebase.PasswordChangeDialog.superclass.initComponent.call(this)}});Ext.ns("Tine","Tine.Tinebase");Tine.Tinebase.AboutDialog=Ext.extend(Ext.Window,{closeAction:"close",modal:true,width:400,height:360,minWidth:400,minHeight:360,layout:"fit",title:null,initAboutTpl:function(){this.aboutTpl=new Ext.XTemplate('<div class="tb-about-dlg">','<div class="tb-about-img"><a href="{logoLink}" target="_blank"><img src="{logo}" /></a></div>','<div class="tb-link-home"><a href="{logoLink}" target="_blank">{logoLink}</a></div>','<div class="tb-about-version">Version: {codeName}</div>','<div class="tb-about-build">({packageString})</div>','<div class="tb-about-copyright">Copyright: 2007-{[new Date().getFullYear()]}&nbsp;<a href="http://www.metaways.de" target="_blank">Metaways Infosystems GmbH</a></div>','<div class="tb-about-credits-license"><p><a href="javascript:\'void()\'" class="license" /><a href="javascript:\'void()\'" class="credits" /></p></div>',"</div>")},initComponent:function(){this.title=String.format(_("About {0}"),Tine.title);this.initAboutTpl();var a=(Tine.Tinebase.registry.get("version"))?Tine.Tinebase.registry.get("version"):{codeName:"unknown",packageString:"unknown"};this.items={layout:"fit",border:false,html:this.aboutTpl.applyTemplate({logo:Tine.Tinebase.LoginPanel.prototype.loginLogo,logoLink:Tine.weburl,codeName:a.codeName,packageString:a.packageString}),buttons:[{text:_("Ok"),iconCls:"action_saveAndClose",handler:this.close,scope:this}]};this.on("afterrender",function(){var b=this.getEl().select("div.tb-about-dlg div.tb-about-credits-license a.license");b.insertHtml("beforeBegin"," "+_("Released under different")+" ");b.insertHtml("beforeEnd",_("Open Source Licenses"));b.on("click",function(){var c=new Tine.Tinebase.LicenseScreen();c.show()});var b=this.getEl().select("div.tb-about-dlg div.tb-about-credits-license a.credits");b.insertHtml("beforeBegin"," "+_("with the help of our")+" ");b.insertHtml("beforeEnd",_("Contributors"));b.on("click",function(){var c=new Tine.Tinebase.CreditsScreen();c.show()})},this);Tine.Tinebase.AboutDialog.superclass.initComponent.call(this)}});Ext.ns("Tine.Tinebase");Tine.Tinebase.AppManager=function(){this.apps=new Ext.util.MixedCollection({});this.addEvents("beforeactivate","activate","beforedeactivate","deactivate","windowopenexception");var a=Tine.Tinebase.registry.get("userApplications");var c;for(var b=0;b<a.length;b++){c=a[b];if(Tine[c.name]&&!c.name.match(/(Tinebase)/)){c.appName=c.name;c.isInitialised=false;this.apps.add(c.appName,c)}this.apps.sort("ASC",function(f,d){return parseInt(f.order,10)-parseInt(d.order,10)})}};Ext.extend(Tine.Tinebase.AppManager,Ext.util.Observable,{defaultApp:null,activeApp:null,activate:function(a){if(a||(a=this.getDefault())){if(a==this.getActive()){return true}if(this.activeApp){if((this.fireEvent("beforedeactivate",this.activeApp)===false||this.activeApp.onBeforeDeActivate()===false)){return false}this.activeApp.onDeActivate();this.fireEvent("deactivate",this.activeApp);this.activeApp=null}if(this.fireEvent("beforeactivate",a)===false||a.onBeforeActivate()===false){return false}var b=a.getMainScreen();if(b){b.show()}else{return false}this.activeApp=a;a.onActivate();this.fireEvent("activate",a)}},get:function(a){if(Ext.isObject(a)&&a.hasOwnProperty("appName")){a=a.appName}if(!this.isEnabled(a)){return false}var c=this.apps.get(a);if(!c.isInitialised){var b=this.getAppObj(c);b.isInitialised=true;Ext.applyIf(b,c);this.apps.replace(a,b)}return this.apps.get(a)},getById:function(b){var a=null;Ext.each(Tine.Tinebase.registry.get("userApplications"),function(c){if(c.id===b){a=this.get(c.appName);return false}},this);return a},getActive:function(){return this.activeApp},getDefault:function(){if(!this.defaultApp){var a=(Tine.Tinebase.registry.get("preferences")&&Tine.Tinebase.registry.get("preferences").get("defaultapp"))?Tine.Tinebase.registry.get("preferences").get("defaultapp"):this.defaultAppName;this.defaultApp=this.get(a)||this.apps.find(function(b){return b.hasMainScreen});if(!this.defaultApp){Ext.MessageBox.show({title:_("Missing Applications"),msg:_("There are no applications enabled for you. Please contact your administrator."),buttons:Ext.Msg.OK,icon:Ext.MessageBox.WARNING})}}return this.defaultApp},setDefault:function(a){if(Ext.isString(a)){a=this.get(a)}if(a){this.defaultApp=a}},getAll:function(){this.initAll();return this.apps},isEnabled:function(a){var b=this.apps.get(a);return b?b.status=="enabled":false},initAll:function(){this.apps.each(function(a){this.get(a.appName)},this)},getAppObj:function(b){try{if(typeof(Tine[b.appName].getPanel)=="function"){return this.getLegacyApp(b)}return typeof(Tine[b.appName].Application)=="function"?new Tine[b.appName].Application(b):new Tine.Tinebase.Application(b)}catch(a){console.error('Initialising of Application "'+b.appName+'" failed with the following message:'+a);console.warn(a);return false}},getLegacyApp:function(d){var a=Tine[d.appName].getPanel();var b=new Tine.Tinebase.Application(d);var c=new Tine.widgets.MainScreen({app:b});Ext.apply(c,{appPanel:a,getContainerTreePanel:function(){return this.appPanel},getWestPanel:function(){return this.appPanel},show:function(){Tine.Tinebase.MainScreen.setActiveTreePanel(a,true);a.fireEvent("beforeexpand",a)}});Ext.apply(b,{mainScreen:c});a.on("render",function(f){f.header.remove();f.header=false;f.doLayout()});return b}});Ext.ns("Tine.Tinebase");Tine.Tinebase.AppPile=Ext.extend(Ext.Panel,{apps:null,defaultApp:null,els:{},border:false,layout:"fit",autoScroll:true,initComponent:function(){this.apps=Tine.Tinebase.appMgr.getAll();this.defaultApp=Tine.Tinebase.appMgr.getDefault();Tine.Tinebase.appMgr.on("activate",this.onActivateApp,this);Tine.Tinebase.AppPile.superclass.initComponent.call(this);this.tpl=new Ext.XTemplate('<div class="x-panel-header x-panel-header-noborder x-unselectable x-accordion-hd">','<img class="x-panel-inline-icon {iconCls}" src="'+Ext.BLANK_IMAGE_URL+'"/>','<span class="x-panel-header-text app-panel-apptitle-text">{title}</span>',"</div>").compile()},onRender:function(b,a){Tine.Tinebase.AppPile.superclass.onRender.call(this,b,a);this.apps.each(function(c){if(c.hasMainScreen){this.els[c.appName]=this.tpl.insertFirst(this.body,{title:c.getTitle(),iconCls:c.getIconCls()},true);this.els[c.appName].setStyle("cursor","pointer");this.els[c.appName].addClassOnOver("app-panel-header-over");this.els[c.appName].on("click",this.onAppTitleClick,this,c)}},this);this.on("resize",function(){var f=Ext.DomQuery.select("div[class^=x-panel-header]",this.el.dom);for(var d=0,c=0;d<f.length;d++){c+=Ext.fly(f[d]).getHeight()}if(arguments[2]&&arguments[2]>c){this.setHeight(c)}});this.setActiveItem(this.els[this.defaultApp.appName])},onActivateApp:function(a){this.setActiveItem(this.els[a.appName])},onAppTitleClick:function(a,c,b){this.setActiveItem(Ext.get(c));Tine.Tinebase.appMgr.activate(b)},setActiveItem:function(b){for(var a in this.els){if(b){if(b==this.els[a]||b.parent()==this.els[a]){this.els[a].addClass("app-panel-header-active")}else{this.els[a].removeClass("app-panel-header-active")}}}}});Ext.ns("Tine.Tinebase");Tine.Tinebase.AppTabsPanel=function(a){Ext.apply(this,a);this.plugins=[new Ext.ux.TabPanelSortPlugin({dragZoneConfig:{onBeforeDrag:this.onBeforeDrag.createDelegate(this)},dropZoneConfig:{getTargetFromEvent:this.getTargetFromEvent.createDelegate(this)}})];Tine.Tinebase.AppTabsPanel.superclass.constructor.call(this,a)};Ext.extend(Tine.Tinebase.AppTabsPanel,Ext.TabPanel,{activeTab:1,stateful:true,stateEvents:["add","remove","tabchange","tabsort"],stateId:"tinebase-mainscreen-apptabs",currentTabs:null,findTargets:function(c){var b=null,a=c.getTarget("li:not(.x-tab-edge)",this.strip);if(a){b=this.getComponent(a.id.split(this.idDelimiter)[1]);if(b&&b.disabled){return{close:null,item:null,el:null}}}return{close:c.getTarget(".x-tab-strip-close",this.strip),item:b,el:a}},initComponent:function(){Ext.apply(this,Ext.state.Manager.get(this.stateId));this.initMenu();this.items=[{id:this.app2id("menu"),title:Tine.title,iconCls:"tine-favicon",closable:true,listeners:{scope:this,beforeclose:this.onBeforeTabClose}}].concat(this.getDefaultTabItems());Tine.Tinebase.appMgr.setDefault(this.id2appName(this.activeTab));Tine.Tinebase.appMgr.on("activate",this.onActivateApp,this);this.on("beforetabchange",this.onBeforeTabChange,this);this.on("tabsort",this.onTabChange,this);this.on("add",this.onTabChange,this);this.on("remove",this.onTabChange,this);this.supr().initComponent.call(this);for(var b=1,a=this.items.getCount();b<a;b++){this.stack.add(this.items.get(b))}},initMenu:function(){this.menu=new Ext.menu.Menu({layout:"column",width:400,autoHeight:true,style:{"background-image":"none"},defaults:{xtype:"menu",floating:false,columnWidth:0.5,hidden:false,listeners:{scope:this,itemclick:function(a,b){this.menu.hide()}},style:{border:"0"}},items:[{items:this.getAppItems(),style:{"border-right":"1px solid #E2E2E3"}},{items:Tine.Tinebase.MainScreen.getMainMenu().getMainActions()}]})},afterRender:function(){this.supr().afterRender.apply(this,arguments);this.menuTabEl=Ext.get(this.getTabEl(0));this.menuTabEl.addClass("tine-mainscreen-apptabspanel-menu-tabel");this.header.removeClass("x-tab-panel-header-plain")},getAppItems:function(){var a=[];Tine.Tinebase.appMgr.getAll().each(function(b){if(b.hasMainScreen){a.push({text:b.getTitle(),iconCls:b.getIconCls(),handler:this.onAppItemClick.createDelegate(this,[b])})}},this);return a.reverse()},getDefaultTabItems:function(){if(Ext.isEmpty(this.currentTabs)){this.currentTabs=[this.id2appName(Tine.Tinebase.appMgr.getDefault())]}var a=[];Ext.each(this.currentTabs,function(b){var c=Tine.Tinebase.appMgr.get(b);if(c){a.push(this.getTabItem(c))}},this);return a},onBeforeDrag:function(a,b){return b.getTarget("li[class*=mainscreen-apptabspanel-menu-tabel]",10)?false:true},getTargetFromEvent:function(c){var b=c.getTarget("ul[class^=x-tab]",10),a=this.findTargets(c);if(a.el&&a.el==this.menuTabEl.dom){return false}return b},getState:function(){return{currentTabs:this.currentTabs,activeTab:Ext.isNumber(this.activeTab)?this.activeTab:this.items.indexOf(this.activeTab)}},getTabItem:function(a){return{id:this.app2id(a),title:a.getTitle(),iconCls:a.getIconCls(),closable:true,listeners:{scope:this,beforeclose:this.onBeforeTabClose,activate:this.onTabActivate}}},onActivateApp:function(b){var a=this.getItem(this.app2id(b))||this.add(this.getTabItem(b));this.setActiveTab(a)},onAppItemClick:function(a){Tine.Tinebase.appMgr.activate(a);this.menu.hide()},onBeforeTabChange:function(a,c,b){if(this.id2appName(c)==="menu"){this.menu.show(this.menuTabEl,"tl-bl");return false}},onBeforeTabClose:function(a){if(this.id2appName(a)==="menu"){return this.onBeforeTabChange(this,a,this.activeTab)}return this.items.getCount()>2},onTabActivate:function(b){var a=this.id2appName(b);var c=Tine.Tinebase.appMgr.get(a);if(Ext.getCmp("treecards").rendered){Tine.Tinebase.appMgr.activate(c)}},onTabChange:function(){var a=this.items.getCount();var f=a>2;this.currentTabs=[];for(var b=1,d,c;b<a;b++){d=this.items.get(b);this.currentTabs.push(this.id2appName(d.id));d.closable=f;c=this.getTabEl(b);if(c){Ext.get(c)[f?"addClass":"removeClass"]("x-tab-strip-closable")}}},id2appName:function(a){if(Ext.isNumber(a)){if(Ext.isArray(this.items)){a=this.items[a]?this.items[a].id:null}else{a=this.items.get(a)}}if(Ext.isObject(a)&&!Ext.isEmpty(a)){a=a.id}if(Ext.isString(a)){return a.split("-").pop()}return null},app2id:function(b){var a=b.appName||b;return this.id+"-"+a}});Ext.ns("Tine.Tinebase");Tine.Tinebase.MainMenu=Ext.extend(Ext.Toolbar,{showMainMenu:false,style:{padding:"0px 2px"},cls:"tbar-mainmenu",mainActions:null,initComponent:function(){this.initActions();this.onlineStatus=new Ext.ux.ConnectionStatus({showIcon:false});this.items=this.getItems();var a=new Ext.Template('<table id="{4}" cellspacing="0" class="x-btn {3}"><tbody class="{1}">','<tr><td class="x-btn-ml"><i>&#160;</i></td><td class="x-btn-mc"><em class="{2}" unselectable="on"><button type="{0}"></button></em></td><td class="x-btn-mr"><i>&#160;</i></td></tr>',"</tbody></table>").compile();Ext.each(this.items,function(b){b.template=a},this);this.supr().initComponent.call(this)},getItems:function(){return[{text:Tine.title,hidden:!this.showMainMenu,menu:{id:"Tinebase_System_Menu",items:this.getMainActions()}},"->",{text:String.format(_("User: {0}"),Tine.Tinebase.registry.get("currentAccount").accountDisplayName),menu:this.getUserActions(),menuAlign:"tr-br"},this.onlineStatus,this.action_logout]},getMainActions:function(){if(!this.mainActions){this.mainActions=[this.action_aboutTine,"-",this.getUserActions(),"-",this.action_logout];if(Tine.Tinebase.registry.get("version").buildType.match(/(DEVELOPMENT|DEBUG)/)){this.mainActions.splice(1,0,"-",this.action_showDebugConsole)}}return this.mainActions},getUserActions:function(){if(!this.userActions){this.userActions=[this.action_editProfile,this.action_showPreferencesDialog,this.action_changePassword,this.action_notificationPermissions,this.action_installChromeWebApp]}return this.userActions},initActions:function(){this.action_aboutTine=new Ext.Action({text:String.format(_("About {0}"),Tine.title),handler:this.onAboutTine20,iconCls:"action_about"});this.action_showDebugConsole=new Ext.Action({text:_("Debug Console (Ctrl + F11)"),handler:Tine.Tinebase.common.showDebugConsole,iconCls:"tinebase-action-debug-console"});this.action_showPreferencesDialog=new Ext.Action({text:_("Preferences"),disabled:false,handler:this.onEditPreferences,iconCls:"action_adminMode"});this.action_editProfile=new Ext.Action({text:_("Edit Profile"),disabled:false,handler:this.onEditProfile,iconCls:"tinebase-accounttype-user"});this.action_changePassword=new Ext.Action({text:_("Change password"),handler:this.onChangePassword,disabled:(Tine.Tinebase.registry.get("changepw")=="0"),iconCls:"action_password"});this.action_logout=new Ext.Action({text:_("Logout"),tooltip:String.format(_("Logout from {0}"),Tine.title),iconCls:"action_logOut",handler:this.onLogout,scope:this});this.action_notificationPermissions=new Ext.Action({text:_("Allow desktop notifications"),tooltip:_("Request permissions for webkit desktop notifications."),iconCls:"action_edit",disabled:!(window.webkitNotifications&&window.webkitNotifications.checkPermission()!=0),handler:function(){window.webkitNotifications.requestPermission(Ext.emptyFn)},scope:this});this.action_installChromeWebApp=new Ext.Action({text:_("Install web app"),tooltip:_("Install Tine 2.0 as web app in your browser."),iconCls:"action_edit",disabled:!(Ext.isChrome&&chrome.app&&!chrome.app.isInstalled),handler:function(){chrome.app.install()},scope:this})},onAboutTine20:function(){var a=new Tine.Tinebase.AboutDialog();a.show()},onChangePassword:function(){var a=new Tine.Tinebase.PasswordChangeDialog();a.show()},onEditPreferences:function(){Tine.widgets.dialog.Preferences.openWindow({})},onEditProfile:function(){Tine.widgets.dialog.Preferences.openWindow({initialCardName:"Tinebase.UserProfile"})},onLogout:function(){if(Tine.Tinebase.registry.get("confirmLogout")!="0"){Ext.MessageBox.confirm(_("Confirm"),_("Are you sure you want to logout?"),function(a,b){if(a=="yes"){this._doLogout()}},this)}else{this._doLogout()}},_doLogout:function(){Ext.MessageBox.wait(_("Logging you out..."),_("Please wait!"));Ext.Ajax.request({params:{method:"Tinebase.logout"},callback:function(b,c,a){var d=(Tine.Tinebase.registry.get("redirectUrl"));if(d&&d!=""){window.location=Tine.Tinebase.registry.get("redirectUrl")}else{window.location.reload()}}})}});Ext.ns("Tine.Tinebase");Tine.Tinebase.MainScreen=Ext.extend(Ext.Panel,{border:false,layout:{type:"vbox",align:"stretch",padding:"0"},appPickerStyle:"tabs",initComponent:function(){Tine.Tinebase.MainScreen=this;this.initLayout();Tine.Tinebase.appMgr.on("activate",this.onAppActivate,this);this.supr().initComponent.call(this)},initLayout:function(){this.items=[{cls:"tine-mainscreen-topbox",border:false,html:'<div class="tine-mainscreen-topbox-left"></div><div class="tine-mainscreen-topbox-middle"></div><div class="tine-mainscreen-topbox-right"></div>'},{cls:"tine-mainscreen-mainmenu",height:20,layout:"fit",border:false,items:this.getMainMenu()},{cls:"tine-mainscreen-apptabs",hidden:this.appPickerStyle!="tabs",border:false,height:Ext.isGecko?22:20,items:new Tine.Tinebase.AppTabsPanel({plain:true})},{cls:"tine-mainscreen-centerpanel",flex:1,layout:"border",border:false,items:[{cls:"tine-mainscreen-centerpanel-north",region:"north",layout:"card",activeItem:0,height:59,border:false,id:"north-panel-2",items:[]},{cls:"tine-mainscreen-centerpanel-center",region:"center",id:"center-panel",animate:true,border:false,layout:"card",activeItem:0,items:[]},{cls:"tine-mainscreen-centerpanel-west",region:"west",id:"west",stateful:false,layout:"border",split:true,width:200,minSize:100,maxSize:300,border:false,collapsible:true,collapseMode:"mini",header:false,items:[{cls:"tine-mainscreen-centerpanel-west-apptitle",hidden:this.appPickerStyle!="pile",region:"north",layout:"fit",border:false,height:40,baseCls:"x-panel-header",html:'<div class ="app-panel-title"></div>'},{cls:"tine-mainscreen-centerpanel-west-treecards",border:false,id:"treecards",region:"center",layout:"card",activeItem:0,items:[]},new Tine.Tinebase.AppPile({cls:"tine-mainscreen-centerpanel-west-apppile",hidden:this.appPickerStyle!="pile",region:"south",layout:"fit",border:false,split:true,collapsible:true,collapseMode:"mini",header:false})]}]}]},getMainMenu:function(){if(!this.mainMenu){this.mainMenu=new Tine.Tinebase.MainMenu({showMainMenu:this.appPickerStyle!="tabs"})}return this.mainMenu},onAppActivate:function(b){Tine.log.info("Activating app "+b.appName);var c=(Tine.Tinebase.registry.get("titlePostfix"))?Tine.Tinebase.registry.get("titlePostfix"):"",a=(document.title.match(/^\([0-9]+\) /))?document.title.match(/^\([0-9]+\) /)[0]:"";document.title=a+Tine.title+c+" - "+b.getTitle();Ext.DomQuery.selectNode("div[class=app-panel-title]").innerHTML=b.getTitle()},afterRender:function(){this.supr().afterRender.apply(this,arguments);this.activateDefaultApp();if(Tine.Tinebase.common.hasRight("check_version","Tinebase")){Tine.widgets.VersionCheck()}if(Tine.Tinebase.registry.get("mustchangepw")){var a=new Tine.Tinebase.PasswordChangeDialog({title:_("Your password expired. Please enter a new user password:")});a.show()}},activateDefaultApp:function(){if(Ext.getCmp("treecards").rendered){Tine.Tinebase.appMgr.activate()}else{this.activateDefaultApp.defer(10,this)}},setActiveContentPanel:function(a,b){var c=Ext.getCmp("center-panel");a.keep=b;this.cleanupCardPanelItems(c);this.setActiveCardPanelItem(c,a)},setActiveTreePanel:function(a,b){var c=Ext.getCmp("treecards");a.keep=b;this.cleanupCardPanelItems(c);this.setActiveCardPanelItem(c,a)},setActiveToolbar:function(a,b){var c=Ext.getCmp("north-panel-2");a.keep=b;this.cleanupCardPanelItems(c);this.setActiveCardPanelItem(c,a)},getActiveToolbar:function(){var a=Ext.getCmp("north-panel-2");if(a.layout.activeItem&&a.layout.activeItem.el){return a.layout.activeItem.el}else{return false}},cleanupCardPanelItems:function(b){if(b.items){for(var a=0,c;a<b.items.length;a++){c=b.items.get(a);if(!c.keep){b.remove(c)}}}},setActiveCardPanelItem:function(a,b){if(a.items.indexOf(b)!==-1){a.layout.setActiveItem(b.id)}else{a.add(b);a.layout.setActiveItem(b.id);a.doLayout()}}});Ext.ns("Tine.Tinebase");Tine.Tinebase.LoginPanel=Ext.extend(Ext.Panel,{defaultUsername:"",defaultPassword:"",loginMethod:"Tinebase.login",loginLogo:"images/tine_logo.png",onLogin:Ext.emptyFn,showInfoBox:true,scope:null,layout:"fit",border:false,getLoginPanel:function(){if(!this.loginPanel){this.loginPanel=new Ext.FormPanel({width:460,height:250,frame:true,labelWidth:90,cls:"tb-login-panel",items:[{xtype:"container",cls:"tb-login-lobobox",border:false,html:'<a target="_blank" href="'+Tine.weburl+'" border="0"><img src="'+this.loginLogo+'" /></a>'},{xtype:"label",cls:"tb-login-big-label",text:_("Login")},{xtype:"tinelangchooser",name:"locale",width:170,tabindex:1},{xtype:"textfield",tabindex:2,width:170,fieldLabel:_("Username"),id:"username",name:"username",allowBlank:false,validateOnBlur:false,selectOnFocus:true,value:this.defaultUsername?this.defaultUsername:undefined,listeners:{render:function(a){a.focus(false,250)}}},{xtype:"textfield",tabindex:3,width:170,inputType:"password",fieldLabel:_("Password"),id:"password",name:"password",selectOnFocus:true,value:this.defaultPassword}],buttonAlign:"right",buttons:[{xtype:"button",width:120,text:_("Login"),scope:this,handler:this.onLoginPress}]})}return this.loginPanel},getTinePanel:function(){if(!this.tinePanel){this.tinePanel=new Ext.Container({layout:"fit",cls:"tb-login-tinepanel",border:false,defaults:{xtype:"label"},items:[{cls:"tb-login-big-label",html:_("Tine 2.0 is made for you")},{html:"<p>"+_("Tine 2.0 wants to make business collaboration easier and more enjoyable - for your needs! So you are warmly welcome to discuss with us, bring in ideas and get help.")+"</p>"},{cls:"tb-login-big-label-spacer",html:"&nbsp;"},{html:'<ul><li><a target="_blank" href="'+Tine.weburl+'" border="0">'+_("Tine 2.0 Homepage")+'</a></li><li><a target="_blank" href="'+Tine.weburl+'forum/" border="0">'+_("Tine 2.0 Forum")+"</a></li></ul><br/>"},{cls:"tb-login-big-label",html:_("Translations")},{html:"<p>"+_("If you miss a language, or your language is not supported completely, you can help our translation teams at transifex.")+"</p>"},{html:'<br/><ul><li><a target="_blank" href="https://www.transifex.com/projects/p/tine20/" border="0">'+_("Tine 2.0 Translation Portal")+"</a></li></ul>"}]})}return this.tinePanel},getSurveyData:function(a){var b=new Ext.data.Store({proxy:new Ext.data.ScriptTagProxy({url:"https://versioncheck.officespot20.com/surveyCheck/surveyCheck.php"}),reader:new Ext.data.JsonReader({root:"survey"},["title","subtitle","duration","langs","link","enddate","htmlmessage","version"])});b.on("load",function(d,c){var f=c[0];a.call(this,f)},this);b.load({params:{lang:Tine.Tinebase.registry.get("locale").locale}})},getSurveyPanel:function(){if(!this.surveyPanel){this.surveyPanel=new Ext.Container({layout:"fit",cls:"tb-login-surveypanel",border:false,defaults:{xtype:"label"},items:[]});if(!Tine.Tinebase.registry.get("denySurveys")){this.getSurveyData(function(c){if(typeof c.get==="function"){var a=Date.parseDate(c.get("enddate"),Date.patterns.ISO8601Long);var b=c.get("version");if(Ext.isDate(a)&&a.getTime()>new Date().getTime()&&Tine.clientVersion.packageString.indexOf(b)===0){c.data.lang_duration=String.format(_("about {0} minutes"),c.data.duration);c.data.link="https://versioncheck.officespot20.com/surveyCheck/surveyCheck.php?participate";this.surveyPanel.add([{cls:"tb-login-big-label",html:_("Tine 2.0 needs your help")},{html:"<p>"+_("We regularly need your feedback to make the next Tine 2.0 releases fit your needs even better. Help us and yourself by participating:")+"</p>"},{html:this.getSurveyTemplate().apply(c.data)},{xtype:"button",width:120,text:_("participate!"),handler:function(){window.open(c.data.link)}}]);this.surveyPanel.doLayout()}}})}}return this.surveyPanel},getSurveyTemplate:function(){if(!this.surveyTemplate){this.surveyTemplate=new Ext.XTemplate("<br/ >","<p><b>{title}</b></p>",'<p><a target="_blank" href="{link}" border="0">{subtitle}</a></p>',"<br/>","<p>",_("Languages"),": {langs}</p>","<p>",_("Duration"),": {lang_duration}</p>","<br/>").compile()}return this.surveyTemplate},getBrowserIncompatiblePanel:function(){if(!this.browserIncompatiblePanel){this.browserIncompatiblePanel=new Ext.Container({layout:"fit",cls:"tb-login-surveypanel",border:false,defaults:{xtype:"label"},items:[]});var b="compatible";if(Ext.isIE6||Ext.isGecko2){b="incompatible"}else{if(!(Ext.isWebKit||Ext.isGecko||Ext.isIE)){b="unknown"}}var a=[];if(b=="incompatible"){a=[{cls:"tb-login-big-label",html:_("Browser incompatible")},{html:"<p>"+_("Your browser is not supported by Tine 2.0.")+"<br/><br/></p>"}]}else{if(b=="unknown"){a=[{cls:"tb-login-big-label",html:_("Browser incompatible?")},{html:"<p>"+_("You are using an unrecognized browser. This could result in unexpected behaviour.")+"<br/><br/></p>"}]}}if(b!="compatible"){this.browserIncompatiblePanel.add(a.concat([{html:"<p>"+_("You might try one of these browsers:")+'<br/><a href="http://www.google.com/chrome" target="_blank">Google Chrome</a><br/><a href="http://www.mozilla.com/firefox/" target="_blank">Mozilla Firefox</a><br/><a href="http://www.apple.com/safari/download/" target="_blank">Apple Safari</a><br/><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx" target="_blank">Microsoft Internet Explorer</a><br/></p>'}]));this.browserIncompatiblePanel.doLayout()}}return this.browserIncompatiblePanel},initComponent:function(){this.initLayout();this.supr().initComponent.call(this)},initLayout:function(){var a=(this.showInfoBox)?[this.getBrowserIncompatiblePanel(),this.getTinePanel(),this.getSurveyPanel()]:[];this.infoPanel=new Ext.Container({cls:"tb-login-infosection",border:false,width:300,height:460,layout:"vbox",layoutConfig:{align:"stretch"},items:a});this.items=[{xtype:"container",layout:"absolute",border:false,items:[this.getLoginPanel(),this.infoPanel]}]},onLoginPress:function(){var b=this.getLoginPanel().getForm(),a=b.getValues();if(b.isValid()){Ext.MessageBox.wait(_("Logging you in..."),_("Please wait"));Ext.Ajax.request({scope:this,params:{method:this.loginMethod,username:a.username,password:a.password},timeout:60000,callback:function(g,d,c){var f=Ext.util.JSON.decode(c.responseText);if(f.success===true){Ext.MessageBox.wait(String.format(_("Login successful. Loading {0}..."),Tine.title),_("Please wait!"));window.document.title=this.originalTitle;this.onLogin.call(this.scope)}else{if(f.data&&f.data.code===510){(function(){Ext.MessageBox.hide();alert(_("Connection lost, please check your network!"))}).defer(1000)}else{Ext.MessageBox.show({title:_("Login failure"),msg:_("Your username and/or your password are wrong!!!"),buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR,fn:function(){this.getLoginPanel().getForm().findField("password").focus(true)}.createDelegate(this)})}}}})}else{Ext.MessageBox.alert(_("Errors"),_("Please fix the errors noted."))}},onRender:function(b,a){this.supr().onRender.apply(this,arguments);this.map=new Ext.KeyMap(this.el,[{key:[10,13],scope:this,fn:this.onLoginPress}]);this.originalTitle=window.document.title;var c=(Tine.Tinebase.registry.get("titlePostfix"))?Tine.Tinebase.registry.get("titlePostfix"):"";window.document.title=Tine.title+c+" - "+_("Please enter your login data")},onResize:function(){this.supr().onResize.apply(this,arguments);var c=this.getBox(),a=this.getLoginPanel().rendered?this.getLoginPanel().getBox():{width:this.getLoginPanel().width,height:this.getLoginPanel().height},d=this.infoPanel.rendered?this.infoPanel.getBox():{width:this.infoPanel.width,height:this.infoPanel.height};var f=(c.height-a.height)/2;if(c.height-f<d.height){f=c.height-d.height}var b=(c.width-a.width)/2;if(b+a.width+d.width>c.width){b=c.width-a.width-d.width}this.getLoginPanel().setPosition(b,f);this.infoPanel.setPosition(b+a.width,f)},renderSurveyPanel:function(b){var a=[{cls:"tb-login-big-label",html:_("Tine 2.0 needs your help")},{html:"<p>"+_("We regularly need your feedback to make the next Tine 2.0 releases fit your needs even better. Help us and yourself by participating:")+"</p>"}]}});Ext.ns("Tine.Tinebase");Tine.Tinebase.AdminPanel=Ext.extend(Ext.TabPanel,{activeItem:0,border:false,initComponent:function(){this.items=new Tine.Tinebase.Admin.UserProfileConfigPanel({});Tine.Tinebase.AdminPanel.superclass.initComponent.call(this)}});Tine.Tinebase.AdminPanel.openWindow=function(a){var b=Tine.WindowFactory.getWindow({width:500,height:470,name:"tinebase-admin-panel",contentPanelConstructor:"Tine.Tinebase.AdminPanel",contentPanelConstructorConfig:a})};Ext.ns("Tine.Tinebase.Admin");Tine.Tinebase.Admin.UserProfileConfigPanel=Ext.extend(Ext.Panel,{layout:"fit",border:false,initComponent:function(){this.title=_("Profile Information");this.items=[];this.applyAction=new Ext.Action({text:_("Apply"),disabled:true,iconCls:"action_applyChanges",handler:this.applyConfig.createDelegate(this)});this.buttons=[this.applyAction];Tine.Tinebase.getUserProfileConfig(this.initProfileTable,this);this.supr().initComponent.call(this)},afterRender:function(){this.supr().afterRender.apply(this,arguments);this.loadMask=new Ext.LoadMask(this.getEl(),{msg:_("Please Wait")});if(!this.store){(function(){this.loadMask.show()}).defer(50,this)}},applyConfig:function(){var a={readableFields:[],updateableFields:[]};this.store.each(function(b){var c=b.get("fieldName");if(b.get("readGrant")){a.readableFields.push(c)}if(b.get("editGrant")){a.updateableFields.push(c)}},this);this.loadMask.show();Tine.Tinebase.setUserProfileConfig(a,function(){this.store.commitChanges();this.applyAction.setDisabled(true);this.loadMask.hide()},this)},initProfileTable:function(d){var c=new Locale.Gettext();c.textdomain("Addressbook");var b=[];Ext.each(d.possibleFields,function(g){var f=Tine.Addressbook.Model.Contact.getField(g);b.push([g,c._hidden(f.label),d.readableFields.indexOf(g)>=0,d.updateableFields.indexOf(g)>=0])},this);this.store=new Ext.data.ArrayStore({autoDestroy:true,fields:["fieldName","fieldLabel","readGrant","editGrant"],data:b,listeners:{scope:this,update:this.onStoreUpdate}});var a=[new Ext.ux.grid.CheckColumn({header:_("Read"),tooltip:_("The field is readable part of the profile"),dataIndex:"readGrant",width:55}),new Ext.ux.grid.CheckColumn({header:_("Edit"),tooltip:_("The field is editable part of the profile"),dataIndex:"editGrant",width:55})];this.userProfileConfigGrid=new Ext.grid.EditorGridPanel({layout:"fit",store:this.store,autoExpandColumn:"fieldName",plugins:a,columns:[{id:"fieldName",header:_("Field Name"),dataIndex:"fieldLabel"}].concat(a)});this.add(this.userProfileConfigGrid);this.doLayout();if(this.loadMask){this.loadMask.hide()}},onStoreUpdate:function(){this.applyAction.setDisabled(false)}});Ext.ns("Tine.Tinebase");Tine.Tinebase.UserProfilePanel=Ext.extend(Ext.Panel,{genericFields:["account_id","created_by","creation_time","last_modified_by","last_modified_time","is_deleted","deleted_time","deleted_by"],layout:"form",border:true,labelAlign:"top",autoScroll:true,defaults:{anchor:"95%",labelSeparator:""},bodyStyle:"padding:5px",initComponent:function(){Tine.Tinebase.getUserProfile(Tine.Tinebase.registry.get("currentAccount").accountId,this.onData.createDelegate(this));this.items=[];this.supr().initComponent.apply(this,arguments)},onData:function(b){var a=b.userProfile,c=b.readableFields,f=b.updateableFields;var d=new Locale.Gettext();d.textdomain("Addressbook");Ext.each(c,function(h){var g=Tine.Addressbook.Model.Contact.getField(h);switch(h){default:this.add(new Ext.form.TextField({hidden:this.genericFields.indexOf(h)>=0,name:h,value:a[h],fieldLabel:d._hidden(g.label),readOnly:f.indexOf(h)<0}));break}},this);this.doLayout()}});Ext.namespace("Tine.Tinebase");Tine.Tinebase.prototypeTranslation=function(){Ext.ux.form.HtmlEditor.IndentOutdent.prototype.midasBtns[1].tooltip.title=_("Outdent Text");Ext.ux.form.HtmlEditor.IndentOutdent.prototype.midasBtns[1].overflowText=_("Outdent Text");Ext.ux.form.HtmlEditor.IndentOutdent.prototype.midasBtns[2].tooltip.title=_("Indent Text");Ext.ux.form.HtmlEditor.IndentOutdent.prototype.midasBtns[2].overflowText=_("Indent Text");Ext.ux.form.HtmlEditor.RemoveFormat.prototype.midasBtns[1].tooltip.title=_("Remove Formatting");Ext.ux.form.HtmlEditor.RemoveFormat.prototype.midasBtns[1].overflowText=_("Remove Formatting")};Ext.ux.Printer.BaseRenderer.prototype.stylesheetPath="Tinebase/js/ux/Printer/print.css";Ext.namespace("Tine","Tine.Tinebase","Tine.Calendar");Tine.clientVersion={};Tine.clientVersion.buildType="RELEASE";Tine.clientVersion.buildDate="2013-02-21 16:37:03";Tine.clientVersion.codeName=": 0 ()";Tine.clientVersion.codeName="Joey";Tine.clientVersion.packageString="2012.10.4";Tine.clientVersion.releaseTime="2013-02-21 16:36:24+01:00";Tine.title="Tine 2.0";Tine.weburl="http://www.tine20.com/";Ext.LOGLEVEL=Tine.clientVersion.buildType="RELEASE";Tine.log=Ext.ux.log;Ext.namespace("Tine.Tinebase");Tine.Tinebase.tineInit={getAllRegistryDataMethod:"Tinebase.getAllRegistryData",stateful:true,requestUrl:"index.php",initList:{initWindow:false,initViewport:false,initRegistry:false},initWindow:function(){Ext.getBody().on("keydown",function(a){if(a.ctrlKey&&a.getKey()===a.A&&!(a.getTarget("form")||a.getTarget("input")||a.getTarget("textarea"))){a.preventDefault()}else{if(a.getKey()===a.BACKSPACE&&!(a.getTarget("form")||a.getTarget("input")||a.getTarget("textarea"))){a.preventDefault()}else{if(!window.isMainWindow&&a.ctrlKey&&a.getKey()===a.T){a.preventDefault()}}}});Ext.getBody().on("dragover",function(a){a.stopPropagation();a.preventDefault();a.browserEvent.dataTransfer.dropEffect="none"},this);this.initList.initWindow=true},initDebugConsole:function(){var a=new Ext.KeyMap(Ext.getDoc(),[{key:[122],ctrl:true,fn:Tine.Tinebase.common.showDebugConsole}])},initBootSplash:function(){this.splash={xtype:"container",id:"tine-viewport-waitcycle",border:false,layout:"fit",width:16,height:16,contentEl:Ext.select("div[class^=tine-viewport-]")};Tine.Tinebase.viewport=new Ext.Viewport({layout:"fit",border:false,items:{xtype:"container",id:"tine-viewport-maincardpanel",ref:"tineViewportMaincardpanel",isWindowMainCardPanel:true,layout:"card",border:false,activeItem:0,items:this.splash},listeners:{scope:this,render:function(a){this.initList.initViewport=true}}})},renderWindow:function(){var b=Tine.Tinebase.viewport.tineViewportMaincardpanel;if(!Tine.Tinebase.registry.get("currentAccount")){if(!Tine.loginPanel){Tine.loginPanel=new Tine.Tinebase.LoginPanel({defaultUsername:Tine.Tinebase.registry.get("defaultUsername"),defaultPassword:Tine.Tinebase.registry.get("defaultPassword"),scope:this,onLogin:function(c){Tine.Tinebase.tineInit.initList.initRegistry=false;Tine.Tinebase.tineInit.initRegistry();var f=function(){if(Tine.Tinebase.tineInit.initList.initRegistry){Ext.MessageBox.hide();Tine.Tinebase.tineInit.initExtDirect();Tine.Tinebase.tineInit.initState();Tine.Tinebase.tineInit.renderWindow()}else{f.defer(100)}};f()}});b.add(Tine.loginPanel)}b.layout.setActiveItem(Tine.loginPanel.id);Tine.loginPanel.doLayout();return}Tine.Tinebase.tineInit.initAppMgr();Tine.Tinebase.tineInit.initUploadMgr();if(typeof(Tine.onReady)==="function"){Tine.Tinebase.viewport.destroy();Tine.onReady();return}var d=Ext.ux.PopupWindowMgr.get(window)||{};window.document.title=d.title?d.title:window.document.title;var a=Tine.WindowFactory.getCenterPanel(d);b.add(a);b.layout.setActiveItem(a.id);a.doLayout();window.initializationComplete=true},initAjax:function(){Ext.Ajax.url=Tine.Tinebase.tineInit.requestUrl;Ext.Ajax.method="POST";Ext.Ajax.defaultHeaders={"X-Tine20-Request-Type":"JSON"};Ext.Ajax.transactions={};Ext.Ajax.on("beforerequest",function(a,b){b.headers=b.headers||{};b.headers["X-Tine20-JsonKey"]=Tine.Tinebase.registry&&Tine.Tinebase.registry.get?Tine.Tinebase.registry.get("jsonKey"):"";b.headers["X-Tine20-TransactionId"]=Tine.Tinebase.data.Record.generateUID();b.url=Ext.urlAppend((b.url?b.url:Tine.Tinebase.tineInit.requestUrl),"transactionid="+b.headers["X-Tine20-TransactionId"]);if(b.params&&!b.isUpload){var h={};var d=Tine.Tinebase.registry.get?Tine.Tinebase.registry.get("serviceMap").services[b.params.method]:false;if(d){for(var c=0,f;c<d.parameters.length;c+=1){f=d.parameters[c].name;h[f]=b.params[f]}}else{for(var g in b.params){if(b.params.hasOwnProperty(g)&&g!=="method"){h[g]=b.params[g]}}}b.jsonData=Ext.encode({jsonrpc:"2.0",method:b.params.method,params:h,id:++Ext.Direct.TID});b.cbs={};b.cbs.success=b.success||null;b.cbs.failure=b.failure||null;b.cbs.callback=b.callback||null;b.isImplicitJsonRpc=true;delete b.params;delete b.success;delete b.failure;delete b.callback}Ext.Ajax.transactions[b.headers["X-Tine20-TransactionId"]]={date:new Date(),json:b.jsonData}});Ext.Ajax.on("requestcomplete",function(c,b,d){delete Ext.Ajax.transactions[d.headers["X-Tine20-TransactionId"]];if(!d.isUpload&&!b.responseText.match(/^([{\[])|(<\?xml)+/)){var g={code:b.responseText!==""?530:540,message:b.responseText!==""?"illegal json data in response":"empty response",traceHTML:b.responseText,request:d.jsonData,response:b.responseText};if(b.responseText.match(/^Fatal error: Allowed memory size of /m)){Ext.apply(g,{code:550,message:b.responseText})}var a=Ext.decode(d.jsonData);b.responseText=Ext.encode({jsonrpc:a.jsonrpc,id:a.id,error:{code:-32000,message:g.message,data:g}})}if(d.isImplicitJsonRpc){var f=Ext.decode(b.responseText);if(f.result){b.responseText=Ext.encode(f.result);if(d.cbs.success){d.cbs.success.call(d.scope,b,d)}if(d.cbs.callback){d.cbs.callback.call(d.scope,d,true,b)}}else{b.responseText=Ext.encode(f.error);if(d.cbs.failure){d.cbs.failure.call(d.scope,b,d)}else{if(d.cbs.callback){d.cbs.callback.call(d.scope,d,false,b)}else{var h=Ext.decode(b.responseText);g=h.data?h.data:h;g.request=d.jsonData;g.response=b.responseText;Tine.Tinebase.ExceptionHandler.handleRequestException(g)}}}}});Ext.Ajax.on("requestexception",function(c,b,d){delete Ext.Ajax.transactions[d.headers["X-Tine20-TransactionId"]];var j=b.status>0?b.status:(b.status===0?510:520);if(!d.isUpload){var g={code:j,message:"request exception: "+b.statusText,traceHTML:b.responseText,request:d.jsonData,requestHeaders:d.headers,openTransactions:Ext.Ajax.transactions,response:b.responseText};var a=Ext.decode(d.jsonData);b.responseText=Ext.encode({jsonrpc:a.jsonrpc,id:a.id,error:{code:-32000,message:g.message,data:g}})}if(d.isImplicitJsonRpc){var f=Ext.decode(b.responseText);b.responseText=Ext.encode(f.error);if(d.cbs.failure){d.cbs.failure.call(d.scope,b,d)}else{if(d.cbs.callback){d.cbs.callback.call(d.scope,d,false,b)}else{var h=Ext.decode(b.responseText);g=h.data?h.data:h;Tine.Tinebase.ExceptionHandler.handleRequestException(g)}}}else{if(!d.failure&&!d.callback){Tine.Tinebase.ExceptionHandler.handleRequestException(g)}}})},initRegistry:function(){Ext.namespace("Tine.Tinebase.registry");if(window.isMainWindow){Ext.Ajax.request({timeout:120000,params:{method:Tine.Tinebase.tineInit.getAllRegistryDataMethod},failure:function(){Tine.Tinebase.ExceptionHandler.handleRequestException({code:503})},success:function(d,f){var h=Ext.util.JSON.decode(d.responseText);for(var c in h){if(h.hasOwnProperty(c)){var k=h[c];if(Tine[c]){Tine[c].registry=new Ext.util.MixedCollection();for(var j in k){if(k.hasOwnProperty(j)){if(j==="preferences"){var l=new Ext.util.MixedCollection();for(var m in k[j]){if(k[j].hasOwnProperty(m)){l.add(m,k[j][m])}}l.on("replace",Tine.Tinebase.tineInit.onPreferenceChange);Tine[c].registry.add(j,l)}else{Tine[c].registry.add(j,k[j])}}}}}}if(Tine.Tinebase.registry&&Tine.Tinebase.registry.get("preferences")){var g=Tine.Tinebase.registry.get("preferences").get("windowtype");if(g=="Ext"){Tine.Tinebase.ApplicationStarter.init()}if(Tine.WindowFactory&&Tine.WindowFactory.windowType!==g){Tine.WindowFactory.windowType=g}}Tine.Tinebase.tineInit.overrideFields();Tine.Tinebase.tineInit.initList.initRegistry=true}})}else{var a=Ext.ux.PopupWindowMgr.getMainWindow();for(var b in a.Tine){if(Object.prototype.hasOwnProperty.call(a.Tine[b],"registry")&&Tine.hasOwnProperty(b)){Tine[b].registry=a.Tine[b].registry}}Tine.Tinebase.tineInit.overrideFields();Tine.Tinebase.tineInit.initList.initRegistry=true}},overrideFields:function(){Ext.override(Ext.ux.file.Upload,{maxFileUploadSize:Tine.Tinebase.registry.get("maxFileUploadSize"),maxPostSize:Tine.Tinebase.registry.get("maxPostSize")})},onPreferenceChange:function(c,b,d){switch(c){case"windowtype":case"confirmLogout":case"timezone":case"locale":if(window.google&&google.gears&&google.gears.localServer){var a=google.gears.localServer.openStore("tine20-package-store");if(a){google.gears.localServer.removeStore("tine20-package-store")}}window.location.reload(c=="locale");break}},checkSelfUpdate:function(){if(!Tine.Tinebase.registry.get("version")){return false}var d,a=Tine.Tinebase.registry.get("version"),c=Tine.clientVersion;if(c.codeName.match(/^\$HeadURL/)){return}var h=new Ext.state.CookieProvider({});if(a.packageString!=="none"){d=(a.packageString!==c.packageString)}else{d=(a.codeName!==c.codeName)}if(d){if(window.google&&google.gears&&google.gears.localServer){google.gears.localServer.removeManagedStore("tine20-store");google.gears.localServer.removeStore("tine20-package-store")}if(h.get("clientreload","0")==="0"){h.set("clientreload","1");window.location.reload(true);return}else{h.clear("clientreload");var f=new Ext.LoadMask(Ext.getBody(),{msg:_("Fatal Error: Client self-update failed, please contact your administrator and/or restart/reload your browser."),msgCls:""}).show()}}else{h.clear("clientreload");if(window.google&&google.gears&&google.gears.localServer){if(a.buildType==="RELEASE"){var b=google.gears.localServer.createStore("tine20-package-store");var g=["","index.php","Tinebase/js/Locale/build/"+Tine.Tinebase.registry.get("locale").locale+"-all.js"];Ext.each(g,function(j){if(!b.isCaptured(j)){b.capture(g,function(){})}},this)}else{google.gears.localServer.removeStore("tine20-package-store")}}}},initWindowMgr:function(){Ext.ux.PopupWindow.prototype.url="index.php";var a=(Tine.Tinebase.registry.get("preferences")&&Tine.Tinebase.registry.get("preferences").get("windowtype"))?Tine.Tinebase.registry.get("preferences").get("windowtype"):"Browser";Tine.WindowFactory=new Ext.ux.WindowFactory({windowType:a});if(window.isMainWindow){Ext.ux.PopupWindowMgr.register({name:window.name,popup:window,contentPanelConstructor:"Tine.Tinebase.MainScreen"})}},initState:function(){if(Tine.Tinebase.tineInit.stateful===true){if(window.isMainWindow||Ext.isIE){Ext.state.Manager.setProvider(new Tine.Tinebase.StateProvider())}else{var a=Ext.ux.PopupWindowMgr.getMainWindow();Ext.state.Manager=a.Ext.state.Manager}}},initExtDirect:function(){var a=Tine.Tinebase.registry.get("serviceMap");Ext.Direct.addProvider(Ext.apply(a,{type:"jsonrpcprovider",namespace:"Tine",url:a.target}))},initLibs:function(){if(OpenLayers){OpenLayers._getScriptLocation=function(){return"library/OpenLayers/"}}},initAppMgr:function(){if(!Ext.isIE&&!window.isMainWindow){Tine.Tinebase.appMgr=Ext.ux.PopupWindowMgr.getMainWindow().Tine.Tinebase.appMgr}else{Tine.Tinebase.appMgr=new Tine.Tinebase.AppManager()}},initUploadMgr:function(){Tine.Tinebase.uploadManager=new Ext.ux.file.UploadManager()},initLocale:function(){Tine.Tinebase.translation=new Locale.Gettext();Tine.Tinebase.translation.textdomain("Tinebase");window._=function(a){return Tine.Tinebase.translation.dgettext("Tinebase",a)};Tine.Tinebase.prototypeTranslation()},onLangFilesLoad:function(){}};Ext.onReady(function(){Tine.Tinebase.tineInit.initWindow();Tine.Tinebase.tineInit.initDebugConsole();Tine.Tinebase.tineInit.initBootSplash();Tine.Tinebase.tineInit.initLocale();Tine.Tinebase.tineInit.initAjax();Tine.Tinebase.tineInit.initRegistry();Tine.Tinebase.tineInit.initLibs();var a=function(){if(!Tine.Tinebase.tineInit.initList.initRegistry){a.defer(100)}else{Tine.Tinebase.tineInit.initExtDirect();Tine.Tinebase.tineInit.initState();Tine.Tinebase.tineInit.initWindowMgr();Tine.Tinebase.tineInit.renderWindow()}};a()});