/*

  OpenLayers.js -- OpenLayers Map Viewer Library

  Copyright 2005-2007 MetaCarta, Inc., released under a modified BSD license.
  Please see http://svn.openlayers.org/trunk/openlayers/repository-license.txt
  for the full text of the license.

  Includes compressed code under the following licenses:

  (For uncompressed versions of the code used please see the
  OpenLayers SVN repository: <http://openlayers.org/>)

*/

/* Contains portions of Prototype.js:
 *
 * Prototype JavaScript framework, version 1.4.0
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
 *
/*--------------------------------------------------------------------------*/

/**  
*  
*  Contains portions of Rico <http://openrico.org/>
* 
*  Copyright 2005 Sabre Airline Solutions  
*  
*  Licensed under the Apache License, Version 2.0 (the "License"); you
*  may not use this file except in compliance with the License. You
*  may obtain a copy of the License at
*  
*         http://www.apache.org/licenses/LICENSE-2.0  
*  
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
*  implied. See the License for the specific language governing
*  permissions and limitations under the License. 
*
**/

var Vespucci={singleFile:true};Jugl=window["http://jugl.tschaub.net/trunk/lib/Jugl.js"];(function(){var singleFile=(typeof Vespucci=="object"&&Vespucci.singleFile);if(!(typeof Vespucci=="object")){Vespucci={};}
Vespucci._scriptName="Vespucci/Vespucci.js",Vespucci._scriptsLoaded=false;Vespucci._geckoWaitForTheBodyToLoad=Vespucci._geckoWaitForTheBodyToLoad||false;Vespucci._getScriptLocation=function(){var scriptLocation="";var scriptName=Vespucci._scriptName;var scripts=document.getElementsByTagName('script');for(var i=0;i<scripts.length;i++){var src=scripts[i].getAttribute('src');if(src){var index=src.lastIndexOf(scriptName);if((index>-1)){scriptLocation=src.slice(0,-scriptName.length);break;}}}
return scriptLocation;};if(singleFile){Vespucci._scriptsLoaded=true;}else{var jsfiles=new Array("Vespucci/Application.js","Vespucci/PopupBase.js","Vespucci/PopupBase/Anchored.js","Vespucci/PopupBase/AnchoredBubble.js","Vespucci/Popup.js","Vespucci/Util.js","Vespucci/Feature.js","Vespucci/Sidebar.js","Vespucci/LoginScreen.js","Vespucci/Handlers/Point.js","Vespucci/Controls/DynamicToolbar.js","Vespucci/Controls/FeaturePermalink.js","Vespucci/Controls/SelectionArgParser.js","Vespucci/Controls/MoveFeature.js","Vespucci/Controls/DrawVespucciFeature.js","Vespucci/Popups/FeaturePopup.js","Vespucci/Popups/ViewPopup.js","Vespucci/Popups/MovePopup.js","Vespucci/Popups/EditPopup.js","Vespucci/Popups/PermalinkPopup.js","Vespucci/Features/Note.js","Vespucci/Features/Comment.js","Vespucci/LoginHandler.js","Vespucci/LoginHandlers/OpenPlans.js","Vespucci/LoginHandlers/LivableStreets.js","Vespucci/LoginHandlers/LivableStreetsStage.js","Vespucci/Request.js","Vespucci/Requests/FeatureRequest.js","Vespucci/Requests/SaveFeaturesRequest.js","Vespucci/Requests/Read/GetCommentsRequest.js","Vespucci/Requests/Read/HistoryFeedRequest.js","Vespucci/Requests/Read/HistoryRequest.js","Vespucci/Requests/Read/GetFeatureRequest.js","Vespucci/Requests/Write/AddCommentRequest.js","Vespucci/Requests/Write/DeleteCommentsRequest.js","Vespucci/Requests/Write/DeleteFeatureRequest.js","Vespucci/Requests/Write/UpdateFeatureRequest.js","Vespucci/Requests/Write/InsertFeatureRequest.js","Vespucci/RequestQueue.js","Vespucci/SidebarView.js","Vespucci/SidebarViews/HelpView.js","Vespucci/SidebarViews/RequestView.js","Vespucci/SidebarViews/HistoryFeedView.js","Vespucci/SidebarViews/CommentsView.js","Vespucci/SidebarViews/FeatureHistoryView.js","Vespucci/SidebarViews/FeatureDiffView.js","Vespucci/SidebarViews/HistoryView.js","Vespucci/SidebarViews/AddFeatureView.js","Vespucci/Topbar.js","Vespucci/Rule.js","Vespucci/Rules/FeatureTypeRule.js","Vespucci/Rules/SubtypeRule.js","Vespucci/Strategies/Transactions.js","Vespucci/Layers/WFSVFilterLayer.js","Vespucci/Configuration/Configuration.js","Vespucci/TestCase.js","Vespucci/TestCases/TestUtil.js");var numberOfScriptsLoaded=0;function scriptLoaded(){numberOfScriptsLoaded+=1;if(numberOfScriptsLoaded==jsfiles.length){Vespucci._scriptsLoaded=true;}}
var agent=navigator.userAgent;var docWrite=(agent.match("MSIE")||agent.match("Safari"));function loadScripts(){if(!docWrite&&Vespucci._geckoWaitForTheBodyToLoad&&!document.body){alert("waiting");setTimeout(loadScripts,10);}
else{if(docWrite){var allScriptTags=new Array(jsfiles.length);}
var host=Vespucci._getScriptLocation();for(var i=0;i<jsfiles.length;i++){if(docWrite){allScriptTags[i]="<script src='"+host+jsfiles[i]+"'></script>";}
else{var s=document.createElement("script");s.onload=scriptLoaded();s.src=host+jsfiles[i];var h=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;h.appendChild(s);}}
if(docWrite){document.write(allScriptTags.join(""));Vespucci._scriptsLoaded=true;}}}
loadScripts();}
Vespucci.ImgPath="./Vespucci/Theme/img/"})();Vespucci.Util={};Vespucci.Util.setOnclick=function(element,funktion){if(typeof element=="string"){element=document.getElementById(element);}
element.onclick=funktion;}
Vespucci.Util.setOnMouseDown=function(element,funktion){if(typeof element=="string"){element=document.getElementById(element);}
element.onmousedown=funktion;}
Vespucci.Util.assert=function(exp,message){if(!exp){OpenLayers.Console.log("Assert failed: "+message);}};Vespucci.Util.toArray=function(notarray){return Array.prototype.slice.apply(notarray);};Vespucci.Util.prettyDate=function(dateString){var parseDate=function(dateString){var split1=dateString.split("T");var split2=split1[1].split(".");var yearMonthDay=split1[0].split("-");var hoursMinutesSeconds=split2[0].split(":");var milis=split2[1];var date=new Date();date.setFullYear(parseInt(yearMonthDay[0]),parseInt(yearMonthDay[1])-1,parseInt(yearMonthDay[2]));date.setHours(parseInt(hoursMinutesSeconds[0]));date.setMinutes(parseInt(hoursMinutesSeconds[1]));date.setSeconds(parseInt(hoursMinutesSeconds[2]));date.setMilliseconds(parseInt(milis));return date;}
var formatDate=function(date){var today=new Date();var increments={day:86400000,hour:3600000,minute:60000,second:1000};var interval=today.getTime()-date.getTime();if(interval>increments.day*2){return"on "+(date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear();}else if(interval>increments.day-30*increments.minute){return"yesterday";}else if(interval>increments.hour/2){var hours=Math.round(interval/increments.hour)
return hours+(hours>1?" hours ago":" hour ago");}else if(interval>increments.minute){var minutes=Math.round(interval/increments.minute)
return minutes+(minutes>1?" minutes ago":" minute ago");}else{return 1+" minute ago";}
return date.toLocaleString();}
return formatDate(parseDate(dateString));};Vespucci.Util.makeAuthorUrl=function(author,configuration){return configuration.peopleUrlPrefix+author+configuration.peopleUrlSuffix;}
Vespucci.Util.DEFAULT_WAIT_TIME=100;Vespucci.Util.wait=function(keepWaiting,funktion,waitTime){if(!waitTime){waitTime=Vespucci.Util.DEFAULT_WAIT_TIME;}
function waitFunction(){if(keepWaiting()){setTimeout(waitFunction,waitTime);}else{funktion();}}
waitFunction();}
Vespucci.Util.objectToString=function(objekt){var string="{";for(prop in objekt){string=string+"\n"+prop+": "+objekt[prop];}
string=string+"\n}";return string;}
Vespucci.Util.addTransparencyToGraphics=function(domElt){var arVersion=navigator.appVersion.split("MSIE")
var version=parseFloat(arVersion[1])
if((version>=5.5)&&(document.body.filters)){var images=domElt.getElementsByTagName("img")
for(var i=images.length-1;i>=0;i--){Vespucci.Util.imageTransparency(images.item(i));}}}
Vespucci.Util.compareAttributes=function(subtypeAttributes,typeAttributes){var match=true;for(attr in subtypeAttributes){match=match&&subtypeAttributes[attr]==typeAttributes[attr];}
return match;}
Vespucci.Util.imageTransparency=function(img){var imgName=img.src.toUpperCase();if(imgName.substring(imgName.length-3,imgName.length)=="PNG"){var imgID=(img.id)?"id='"+img.id+"' ":"";var imgClass=(img.className)?"class='"+img.className+"' ":"";var imgTitle=(img.title)?"title='"+img.title+"' ":"title='"+img.alt+"' ";var imgStyle="display:inline-block;"+img.style.cssText;if(img.align=="left"){imgStyle="float:left;"+imgStyle;}
if(img.align=="right"){imgStyle="float:right;"+imgStyle;}
if(img.parentElement&&img.parentElement.href){imgStyle="cursor:hand;"+imgStyle}
var strNewHTML="<span "+imgID+imgClass+imgTitle+" style=\""+"width:"+
img.width+"px; height:"+
img.height+"px;"+
imgStyle+";"+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src=\'"+
img.src+"\', sizingMethod='scale');\"></span>"
img.outerHTML=strNewHTML}}
Vespucci.Application=OpenLayers.Class({initialize:function(configuration){this.configuration=configuration;},map:null,configuration:null,wfsLayer:null,panZoomBar:null,navigationControl:null,selectControl:null,moveControl:{},drawControl:{},permalinkControl:null,selectionArgParser:null,editingToolbar:null,sidebar:null,topbar:null,loginScreen:null,loginHandler:null,requestQueue:null,isEditing:false,templates:{notesPopupEditTemplate:"notes-popup-edit-template",notesPopupViewTemplate:"notes-popup-view-template",notesPopupMoveTemplate:"notes-popup-move-template",notesPopupPermalinkTemplate:"notes-popup-permalink-template",sidebarCommentsTemplate:"sidebar-comments-template",sidebarFeatureHistoryTemplate:"sidebar-feature-history-template",sidebarFeatureDiffTemplate:"sidebar-feature-diff-template",sidebarHistoryFeedTemplate:"sidebar-historyfeed-template",sidebarHistoryTemplate:"sidebar-history-template",sidebarHelpTemplate:"sidebar-help-template",sidebarLoadingTemplate:"sidebar-loading-template",topbarTemplate:"topbar-template",loginScreenTemplate:"login-screen-template",sidebarAddNoteTemplate:"sidebar-add-notes-template"},load:function(){OpenLayers.ProxyHost=this.configuration.proxy;OpenLayers.ImgPath=Vespucci.ImgPath;OpenLayers.IMAGE_RELOAD_ATTEMPTS=this.configuration.imageReloadAttempts;OpenLayers.Popup.POPUP_MARGIN=this.configuration.popupMargins;var map=document.getElementById(this.configuration.mapDivId);map.className=this.configuration.mainVespucciCSSClass+" "+map.className;this.loadImages();this.loadRequestQueue();this.loadTemplates();this.loadMap();this.loadLayers();this.loadLoginHandler();if(this.configuration.defaultZoomLevel){this.map.setCenter(this.configuration.defaultZoomCenter,this.configuration.defaultZoomLevel);}else{this.map.zoomToMaxExtent();}
var application=this;var finishLoading=function(){application.loadTopbar();application.loadControls();application.loadSidebar();if(application.configuration.startInViewMode){application.switchToViewMode();}else{application.switchToEditMode();}
application.showHome();};var keepWaiting=function(){return!application.templatesLoaded();};Vespucci.Util.wait(keepWaiting,finishLoading);},loadImages:function(){for(var index=0;index<this.configuration.icons.length;index++){var src=this.configuration.icons[index];var image=new Image();image.onerror=function(){OpenLayers.Console.error("Trouble preloading image '"+src+"'.");};image.src=src;}},loadRequestQueue:function(){this.requestQueue=new Vespucci.RequestQueue();},loadTemplates:function(){var application=this;function onSuccess(response){var templateContainer=document.createElement("DIV");templateContainer.className=application.configuration.templateContainerCSSClass;templateContainer.innerHTML=response.responseText;document.body.appendChild(templateContainer);for(var name in application.templates){var id=application.templates[name];var element=document.getElementById(id);application.templates[name]=new Jugl.Template(element);}
document.body.removeChild(templateContainer);}
function onFailure(response){OpenLayers.Console.error("Could not retrieve template file.");}
var request=new OpenLayers.Ajax.Request(this.configuration.templateFile,{method:"get",onSuccess:onSuccess,onFailure:onFailure});},loadMap:function(){var restrictedExtent=(this.configuration.restrictExtent?this.configuration.maxExtent:null);var options={projection:this.configuration.projection,maxExtent:this.configuration.maxExtent,restrictedExtent:restrictedExtent,maxResolution:this.configuration.maxResolution,controls:[],numZoomLevels:this.configuration.numZoomLevels,paddingForPopups:new OpenLayers.Bounds(50,0,350,35),theme:Vespucci._getScriptLocation()+"Vespucci/Theme/map.css"};OpenLayers.Util.extend(options,this.configuration.mapOptions);this.map=new OpenLayers.Map(this.configuration.mapDivId,options);},loadLayers:function(){var wms=new OpenLayers.Layer.WMS(this.configuration.wmsLayerName,this.configuration.wmsUrl,this.configuration.wmsOptions);var styleMap=this.createStyleMap();this.wfsLayer=new Vespucci.WFSVFilterLayer(this.configuration,this.configuration.wfsLayerName,this.configuration.wfsvUrl,{typename:this.getWFSTypeString(),featureNS:this.configuration.namespaceUri,srsName:this.configuration.projection},{extractAttributes:true,yOrdering:true,styleMap:styleMap});this.map.addLayers([wms,this.wfsLayer]);},createStyleMap:function(){var rules=[];for(type in this.configuration.featureStyles){rules.push(new Vespucci.Rule.FeatureTypeRule(type,this.configuration.featureStyles[type]));if(this.configuration.subtypes[type]){for(var i=0;i<this.configuration.subtypes[type].length;i++){rules.push(new Vespucci.Rule.SubtypeRule(type,this.configuration.subtypes[type][i]));}}}
var style=new OpenLayers.Style();style.addRules(rules);var styleMap=new OpenLayers.StyleMap({'default':style,'select':{}});return styleMap;},loadControls:function(){var application=this;var selectOptions={onSelect:function(feature){feature.selected(application);}};this.map.events.register("zoomend",application,function(){var popup=this.getPopup();if(popup){this.map.setCenter(popup.lonlat);}});for(var name in application.configuration.moveControls){var moveHandler=application.configuration.moveControls[name];moveStyle=OpenLayers.Util.extend({},application.configuration.featureStyles[name]);var moveControlOptions={handlerOptions:{layer:this.wfsLayer,style:moveStyle}};this.moveControl[name]=new Vespucci.MoveFeature(this.wfsLayer,moveHandler,moveControlOptions);this.moveControl[name].featureMoved=function(feature){this.deactivate();feature.edit(application);}}
for(var type in application.configuration.addControls){var handler=application.configuration.addControls[type];var style=null;if(application.configuration.featureStyles[type]){style=OpenLayers.Util.extend({},application.configuration.featureStyles[type]);}
var controlOptions={handlerOptions:{layer:application.wfsLayer,style:style}};this.drawControl[type]=new Vespucci.DrawVespucciFeature(type,application.configuration,application.wfsLayer,handler,controlOptions);this.drawControl[type].featureAdded=function(feature){feature.state=OpenLayers.State.INSERT;feature.edit(application);};this.drawControl[type].name=type;}
this.panZoomBar=new OpenLayers.Control.PanZoomBar();this.selectControl=new OpenLayers.Control.SelectFeature(this.wfsLayer,selectOptions);this.navigationControl=new OpenLayers.Control.Navigation();this.selectionParser=new Vespucci.SelectionArgParser(this);this.permalinkControl=new Vespucci.FeaturePermalink();this.map.addControl(this.panZoomBar);this.map.addControl(this.navigationControl);this.map.addControl(this.selectControl);for(var name in this.moveControl){this.map.addControl(this.moveControl[name]);}
for(type in this.drawControl){this.map.addControl(this.drawControl[type]);}
this.map.addControl(this.selectionParser);this.map.addControl(this.permalinkControl);},loadSidebar:function(){this.sidebar=new Vespucci.Sidebar(this);},loadTopbar:function(){this.topbar=new Vespucci.Topbar(this);},loadLoginHandler:function(){this.loginHandler=new this.configuration.loginHandlerClass(this);},templatesLoaded:function(){for(var name in this.templates){if(typeof this.templates[name]=="string"){return false;}}
return true;},switchToEditMode:function(){this.selectControl.deactivate();this.selectControl.activate();this.isEditing=true;},switchToViewMode:function(){this.isEditing=false;this.navigationControl.activate();this.selectControl.activate();},updateMargins:function(){var margins=this.configuration.margins;OpenLayers.Control.PanZoom.Y=this.configuration.margins.top;if(this.panZoomBar){this.panZoomBar.moveTo(new OpenLayers.Pixel(margins.left,margins.top));}
if(this.sidebar){this.sidebar.calculatePosition();}},getWFSTypeString:function(){var output="";for(var typeIndex=0;typeIndex<this.configuration.wfsLayerTypes.length;typeIndex++){if(output!="")output+=",";output=this.configuration.namespace
+":"+this.configuration.wfsLayerTypes[typeIndex];}
return output;},getWFSParams:function(index){index=index||0;return{featureNS:this.configuration.namespaceUri,featureType:this.configuration.wfsLayerTypes[index],featurePrefix:this.configuration.namespace}},addPopup:function(popup){for(var i=0;i<this.map.popups.length;i++){this.map.popups[i].close();}
this.map.addPopup(popup,true);},getPopup:function(){return this.map.popups[0];},updateFeature:function(feature,onSuccess,onFailureOrCancel){feature.state=OpenLayers.State.UPDATE;this.wfsLayer.commitFeature(feature,onSuccess,onFailureOrCancel);},insertFeature:function(feature,onSuccess,onFailureOrCancel){feature.state=OpenLayers.State.INSERT;this.wfsLayer.commitFeature(feature,onSuccess,onFailureOrCancel);},deleteFeature:function(feature,onSuccess,onFailureOrCancel){feature.state=OpenLayers.State.DELETE;this.wfsLayer.commitFeature(feature,onSuccess,onFailureOrCancel);},rollback:function(feature,options,onSuccess,onFailureOrCancel){this.wfsLayer.rollback(feature,options,onSuccess,onFailureOrCancel);},showSidebar:function(){this.sidebar.show();},showHistoryFeed:function(){this.loadView(new Vespucci.SidebarView.HistoryFeedView(this));this.showSidebar();},showHome:function(){this.loadHomeViewInSidebar();this.showSidebar();},loadHomeViewInSidebar:function(){this.loadView(new Vespucci.SidebarView.HelpView(this));},contextualShowHome:function(){if(this.sidebar.view.hasFeatureContext()){this.loadHomeViewInSidebar();}},showAddFeature:function(type){this.loadView(new Vespucci.SidebarView.AddFeatureView(this,type,this.drawControl[type]));this.showSidebar();},showHistory:function(){this.loadView(new Vespucci.SidebarView.HistoryView(this));},showLoginScreen:function(onSuccess,onCancel){var application=this;var updateTopBarOnSuccess=function(){application.topbar.updateLoginLinkText();if(onSuccess){onSuccess();}}
if(!this.loginScreen){this.loginScreen=new Vespucci.LoginScreen(this,updateTopBarOnSuccess,onCancel);}},loadCommentsInSidebar:function(feature,scrollPosition){this.loadView(new Vespucci.SidebarView.CommentsView(this,feature,scrollPosition));},loadFeatureHistoryInSidebar:function(feature,scrollPosition){this.loadView(new Vespucci.SidebarView.FeatureHistoryView(this,feature,scrollPosition));},loadFeatureDiff:function(feature,fromFeatureVersion,toFeatureVersion){this.loadView(new Vespucci.SidebarView.FeatureDiffView(this,feature,fromFeatureVersion,toFeatureVersion));},loadView:function(view){this.sidebar.loadView(view);},login:function(username,password,onValidate,onInvalid){this.loginHandler.validate(username,password,onValidate,onInvalid);},logout:function(){this.loginHandler.logout();this.topbar.updateLoginLinkText();},isLoggedIn:function(){return this.loginHandler.isLoggedIn();},showPleaseLoginError:function(){},showForbiddenError:function(){alert("You do not have permission to perform that action. If you feel you have received this message in error please contact an administrator.")},enableZoomWheel:function(){this.navigationControl.enableZoomWheel();},disableZoomWheel:function(){this.navigationControl.disableZoomWheel();},refreshFeatures:function(){this.wfsLayer.redraw();},unselectFeature:function(feature){if(feature.geometry){this.selectControl.unselect(feature);}},removeFeatures:function(features){this.wfsLayer.removeFeatures(features);},addFeatures:function(features){this.wfsLayer.addFeatures(features);},getFeatureByFid:function(fid){return this.wfsLayer.getFeatureByFid(fid);},hasFeature:function(feature){return this.getFeatureByFid(feature.getFID())!=null;},moveFeature:function(feature){this.wfsLayer.eraseFeatures([feature]);this.moveControl[feature.type].activate(feature);},getPermalink:function(feature){var title=document.title;if(feature){title=feature.getTitle();}
var url=this.permalinkControl.createUrl(feature);return url;},CLASS_NAME:"Vespucci.Application"});Vespucci.DrawVespucciFeature=OpenLayers.Class(OpenLayers.Control.DrawFeature,{type:null,configuration:null,subtype:null,initialize:function(type,configuration,layer,handler,options){this.type=type;this.configuration=configuration;OpenLayers.Control.DrawFeature.prototype.initialize.apply(this,[layer,handler,options]);},activate:function(subtype){if(subtype){this.oldSubtype=this.subtype;this.subtype=subtype;}
if(this.handler.setStyle&&this.subtype){this.handler.setStyle(this.subtype.style);}
OpenLayers.Control.DrawFeature.prototype.activate.apply(this,arguments)},cancel:function(){if(this.active){this.handler.cancel();}
this.deactivate();},deactivate:function(){this.subtype=this.oldSubtype;this.oldSubtype=null;if(this.handler.setStyle){this.handler.setStyle();}
OpenLayers.Control.DrawFeature.prototype.deactivate.apply(this,arguments);},drawFeature:function(geometry){var feature=new OpenLayers.Feature.Vector(geometry);Vespucci.Feature.extendOpenLayersFeatures(feature,this.configuration,this.type);feature.setDefaultAttributes();feature.setSubtype(this.subtype);this.layer.addFeatures([feature]);this.featureAdded(feature);},CLASS_NAME:"Vespucci.DrawSubtypedFeature"})
Vespucci.FeaturePermalink=OpenLayers.Class(OpenLayers.Control.Permalink,{ARG_PARSER_CLASS_NAME:"Vespucci.SelectionArgParser",SELECT_ARGUMENT_KEY:"select",initialize:function(options){OpenLayers.Control.Permalink.prototype.initialize.apply(this,arguments);},createUrl:function(feature){var center=null;if(feature){center=feature.getLocation();}
var url=OpenLayers.Control.Permalink.prototype.createUrl.apply(this,[center]);if(feature){url+="&"+this.SELECT_ARGUMENT_KEY+"="+feature.getFID();}
return url;},CLASS_NAME:"Vespucci.FeaturePermalink"});Vespucci.MoveFeature=OpenLayers.Class(OpenLayers.Control,{layer:null,callbacks:null,featureMoved:function(){},beforeMove:function(){},handlerOptions:null,feature:null,initialize:function(layer,handler,options){OpenLayers.Control.prototype.initialize.apply(this,[options]);this.callbacks=OpenLayers.Util.extend({done:this.moveFeature},this.callbacks);this.layer=layer;this.handler=new handler(this,this.callbacks,this.handlerOptions);},moveFeature:function(geometry){this.beforeMove(this.feature);this.feature.layer=this.feature.layer||this.layer;this.feature.move(geometry.getBounds().getCenterLonLat());this.featureMoved(this.feature);},activate:function(feature){this.feature=feature;if(this.handler.setStyle){this.handler.setStyle(feature.getSubtype().style);}
OpenLayers.Control.prototype.activate.apply(this,[])},deactivate:function(){this.feature=null;OpenLayers.Control.prototype.deactivate.apply(this,arguments)},CLASS_NAME:"Vespucci.MoveFeature"});Vespucci.SelectionArgParser=OpenLayers.Class(OpenLayers.Control.ArgParser,{SELECT_ARGUMENT_KEY:"select",application:null,centerSet:false,initialize:function(application,options){OpenLayers.Control.ArgParser.prototype.initialize.apply(this,[options]);this.application=application;},setMap:function(map){OpenLayers.Control.ArgParser.prototype.setMap.apply(this,arguments);this.application.wfsLayer.events.register("loadend",this,this.wfsLayerLoaded);},setCenter:function(){OpenLayers.Control.ArgParser.prototype.setCenter.apply(this,arguments);this.centerSet=true;},wfsLayerLoaded:function(){var args=OpenLayers.Util.getParameters();var selectedFID=args[this.SELECT_ARGUMENT_KEY];if(selectedFID){var feature=this.application.getFeatureByFid(selectedFID);feature.selected(this.application);}
this.application.wfsLayer.events.unregister("loadend",this,this.wfsLayerLoaded);},CLASS_NAME:"Vespucci.SelectionArgParser"});Vespucci.Feature=OpenLayers.Class(OpenLayers.Feature.Vector,{FEATURE_WAIT_TIME:100,selected:function(application){},dragged:function(application){},edit:function(application){},creationDate:null,createdBy:null,creationVersion:null,movedFrom:null,configuration:null,setConfiguration:function(configuration){this.configuration=configuration;},toHTML:function(application){return"";},getCreator:function(){return this.createdBy||"unknown";},getCreatorUrl:function(){return Vespucci.Util.makeAuthorUrl(this.getCreator(),this.configuration);},getLastUpdater:function(){return this.lastUpdatedBy||"unknown";},getLastUpdaterUrl:function(){return Vespucci.Util.makeAuthorUrl(this.getLastUpdater(),this.configuration);},getPrettyCreationDate:function(){return Vespucci.Util.prettyDate(this.getCreationDate());},getCreationDate:function(){return this.creationDate;},getPrettyUpdateDate:function(){return Vespucci.Util.prettyDate(this.getUpdateDate());},getUpdateDate:function(){return this.lastUpdateDate;},getVersion:function(){return this.version;},getGID:function(){return this.fid.split(".")[1];},getFID:function(){return this.fid;},getID:function(){return this.id;},getType:function(){return this.type;},setType:function(type){this.type=type;},getFullType:function(){return this.configuration.namespace+":"+this.type;},moveThis:function(application){this.movedFrom=this.getLocation();application.moveFeature(this);},resetLocation:function(){if(this.movedFrom){this.move(this.movedFrom);this.movedFrom=null;}},getLocation:function(){var location=null;if(this.geometry){location=this.geometry.getBounds().getCenterLonLat();}
return location;},shiftMapUntilVisible:function(application,onVisible){var originalFeature=this;function waitForFeatureToAppearOnMap(){var featureOnMap=application.getFeatureByFid(originalFeature.getFID());if(featureOnMap==null){setTimeout(waitForFeatureToAppearOnMap,originalFeature.FEATURE_WAIT_TIME);}else{onVisible(featureOnMap);}}
if(!application.hasFeature(this)){application.map.shiftToLonLat(this.getLocation());}
waitForFeatureToAppearOnMap();},setAsDirty:function(){if(this.state!=OpenLayers.State.INSERT){this.state=OpenLayers.State.UPDATE;}},getStyle:function(){return this.style;},updateStyle:function(){this.setStyle();},setStyle:function(){if(this.layer){this.layer.drawFeature(this);}},getDefaultStyle:function(){var style=null;if(this.configuration.featureStyles[this.type]){style=this.configuration.featureStyles[this.type];}
return style;},setDefaultAttributes:function(){var defaultAttributes=this.configuration.featureDefaults[this.type]||{};for(var name in defaultAttributes){this.attributes[name]=defaultAttributes[name];}},setAttributes:function(attributes){OpenLayers.Util.extend(this.attributes,attributes);this.setStyle(this.getSubtype().style);},getSubtype:function(){var subtypes=this.configuration.subtypes[this.type];if(subtypes){var subtype;for(var i=0;i<subtypes.length;i++){subtype=subtypes[i];if(Vespucci.Util.compareAttributes(subtype.attributes,this.attributes)){return subtype;}}}
return subtypes[0]},setSubtype:function(subtype){OpenLayers.Util.extend(this.attributes,subtype.attributes);this.setStyle(subtype.style);},setNamespace:function(){if(!this.featureNS){this.featureNS=this.configuration.namespaceUri;}
if(!this.featureNSName){this.featureNSName=this.configuration.namespace;}},CLASS_NAME:"Vespucci.Feature"});Vespucci.Feature.extendOpenLayersFeatures=function(features,configuration,type){if(!(features instanceof Array)){features=[features];}
for(var featureIndex=0;featureIndex<features.length;featureIndex++){var feature=features[featureIndex];if(type){feature.type=type;}
if(feature.CLASS_NAME.indexOf(Vespucci.Feature.prototype.CLASS_NAME)!=-1)continue;var klass=configuration.featureClasses[feature.type];if(klass){for(property in klass.prototype){if(typeof klass.prototype[property]=="function"||feature[property]==null){feature[property]=klass.prototype[property];}}
feature.CLASS_NAME=klass.prototype.CLASS_NAME;feature.setConfiguration(configuration);feature.setNamespace();var style=feature.getDefaultStyle();feature.setStyle(style);feature.updateStyle();}
Vespucci.Feature.handleVersioningAttributes(feature);}};Vespucci.Feature.handleVersioningAttributes=function(feature){OpenLayers.Util.extend(feature,feature.versioning);};Vespucci.Handler={};Vespucci.Handler.Point=OpenLayers.Class(OpenLayers.Handler,{point:null,layer:null,useTemporaryLayer:true,mouseDown:false,lastDown:null,lastUp:null,persist:false,layerOptions:null,initialize:function(control,callbacks,options){if(!options||!options.style){options.style=OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'],{});}
OpenLayers.Handler.prototype.initialize.apply(this,arguments);this.defaultStyle=this.style;if(options&&options.layer){this.layer=options.layer;this.useTemporaryLayer=false;}},activate:function(){if(!OpenLayers.Handler.prototype.activate.apply(this,arguments)){return false;}
if(this.useTemporaryLayer){var options={displayInLayerSwitcher:false,calculateInRange:function(){return true;}};this.layer=new OpenLayers.Layer.Vector(this.CLASS_NAME,options);this.map.addLayer(this.layer);}
this.createFeature();return true;},createFeature:function(){this.point=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point());this.point.style=OpenLayers.Util.extend({},this.style);},deactivate:function(){if(!OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){return false;}
if(this.useTemporaryLayer){this.map.removeLayer(this.layer);this.layer=null;}
return true;},destroyFeature:function(){if(this.point){this.point.destroy();}
this.point=null;},finalize:function(){this.cleanup("done");},cancel:function(){this.cleanup("cancel");},cleanup:function(callback){this.layer.eraseFeatures(this.point);this.mouseDown=false;this.lastDown=null;this.lastUp=null;this.callback(callback,[this.geometryClone()]);this.destroyFeature();},click:function(evt){this.finalize();return false;},dblclick:function(evt){OpenLayers.Event.stop(evt);return false;},drawFeature:function(){this.layer.bringToFront(this.point);},geometryClone:function(){return this.point.geometry.clone();},mousedown:function(evt){return false;},mousemove:function(evt){var lonlat=this.map.getLonLatFromPixel(evt.xy);this.point.geometry.x=lonlat.lon;this.point.geometry.y=lonlat.lat;this.point.geometry.clearBounds();this.drawFeature();return true;},mouseup:function(evt){},setStyle:function(style){this.style=OpenLayers.Util.extend({},this.defaultStyle);if(style){OpenLayers.Util.extend(this.style,style);}
if(this.point){this.point.style=OpenLayers.Util.extend({},this.style);}},CLASS_NAME:"OpenLayers.Handler.Point"});Vespucci.WFSVFilterLayer=OpenLayers.Class(OpenLayers.Layer.Vector,{configuration:null,initialize:function(configuration,name,url,params,options){this.configuration=configuration;this.type=params.typename.split(":")[1];this.saveStrategy=new Vespucci.Strategy.Transactions();options=OpenLayers.Util.extend(options,{strategies:[new OpenLayers.Strategy.BBOX(),this.saveStrategy],protocol:new OpenLayers.Protocol.WFSV({url:url,featureNS:params.featureNS,featurePrefix:params.typename.split(":")[0],featureType:params.typename.split(":")[1],srsName:params.srsName,version:"1.1.0"})});OpenLayers.Layer.Vector.prototype.initialize.apply(this,[name,options]);},addFeatures:function(features,options){Vespucci.Feature.extendOpenLayersFeatures(features,this.configuration,this.type);return OpenLayers.Layer.Vector.prototype.addFeatures.apply(this,arguments);},commitFeature:function(feature,onSuccess,onFailureOrCancel){this.saveStrategy.save(feature,onSuccess,onFailureOrCancel);},rollback:function(feature,options,onSuccess,onFailureOrCancel){this.saveStrategy.rollback(feature,options,onSuccess,onFailureOrCancel);},CLASS_NAME:"Vespucci.Feature.WFSFilterLayer"});Vespucci.LoginHandler=OpenLayers.Class({application:null,USERNAME_OR_PASSWORD_INVALID_ERROR_TEXT:"Your username or password is invalid.",UNEXPECTED_ERROR_TEXT:"There was an unexpected error while validating your credentials. Please try again later.",NO_LOGIN_HANDLER_ERROR_TEXT:"No login handler present.",COOKIES_NOT_ENABLED:"It appears cookies are not enabled in your browser. You must enable cookies before you can log in.",initialize:function(application){this.application=application;},validate:function(username,password,onValidate,onInvalid){onInvalid(this.NO_LOGIN_HANDLER_ERROR_TEXT);},isLoggedIn:function(){return false;},logout:function(){},createCookie:function(name,value,days,domain){var expires="";if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires=";expires="+date.toGMTString();}
var cookieString=name+"="+value+";path=/"+(expires?expires:"")+(domain?";domain="+escape(domain)+"":"")+";";document.cookie=cookieString;},readCookie:function(name){var value=null;var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i].replace(/^s+/,'');if(c.indexOf(nameEQ)==0){value=c.substring(nameEQ.length,c.length);break;}}
return value;},deleteCookie:function(name,domain){this.createCookie(name,"",-1,domain);}});Vespucci.LoginScreen=OpenLayers.Class({application:null,containerDiv:null,shadowDiv:null,SHADOW_CSS_CLASS_NAME:"VespucciShadowScreen",USERNAME_TEXT_BOX_ID:"username",PASSWORD_TEXT_BOX_ID:"password",SUBMIT_BUTTON_ID:"submit",MESSAGE_BOX_ID:"error-message",NOTIFICATION_IMAGE_ID:"notification-image",IMAGE_VISIBLE_CSS_CLASS_NAME:"notification visible",IMAGE_HIDDEN_CSS_CLASS_NAME:"notification hidden",MESSAGE_BOX_VISIBLE_CLASS_NAME:"message",MESSAGE_BOX_HIDDEN_CLASS_NAME:"message hidden",SUBMIT_BUTTON_DEFAULT_TEXT:"Log In",SUBMIT_BUTTON_LOGGING_IN_TEXT:"Logging In&hellip",usernameTextBox:null,passwordTextBox:null,messageBox:null,submitButton:null,notificationImage:null,closeButton:null,onSuccess:null,onCancel:null,initialize:function(application,onSuccess,onCancel){this.application=application;this.onSuccess=onSuccess||function(){};this.onCancel=onCancel||function(){};this.createContainerDiv();this.createShadowDiv();this.createCloseButton();this.application.map.div.appendChild(this.shadowDiv);this.application.map.div.appendChild(this.containerDiv);this.containerDiv.appendChild(this.closeButton);this.setDOMElements();this.adjustPosition();this.addBehaviors();this.resetFormState();this.usernameTextBox.focus();},close:function(){this.application.map.div.removeChild(this.containerDiv);this.application.map.div.removeChild(this.shadowDiv);this.application.loginScreen=null;this.resetFormState();},handleInvalid:function(message){this.messageBox.innerHTML=message;this.messageBox.className=this.MESSAGE_BOX_VISIBLE_CLASS_NAME;this.hideNotification();this.enableButton();},handleValid:function(){this.close();this.onSuccess();},createCloseButton:function(){this.closeButton=document.createElement("A");this.closeButton.className="close";this.closeButton.href="#";},addBehaviors:function(){var loginScreen=this;Vespucci.Util.setOnclick(this.submitButton,function(){loginScreen.disableButton();loginScreen.showNotification();var username=loginScreen.usernameTextBox.value;var password=loginScreen.passwordTextBox.value;var handleValid=OpenLayers.Function.bind(loginScreen.handleValid,loginScreen);var handleInvalid=OpenLayers.Function.bind(loginScreen.handleInvalid,loginScreen);loginScreen.application.login(username,password,handleValid,handleInvalid);return false;});Vespucci.Util.setOnclick(this.closeButton,function(){loginScreen.close();loginScreen.onCancel();});},adjustPosition:function(){var loginBounds=OpenLayers.Util.getDOMElementBounds(this.containerDiv);var mapSize=this.application.map.getSize();this.containerDiv.style.left=((mapSize.w-loginBounds.width)/2)+"px";this.containerDiv.style.top=((mapSize.h-loginBounds.height)/2)+"px";},hideNotification:function(){this.notificationImage.className=this.IMAGE_HIDDEN_CSS_CLASS_NAME;},showNotification:function(){this.notificationImage.className=this.IMAGE_VISIBLE_CSS_CLASS_NAME;},disableButton:function(){this.submitButton.innerHTML=this.SUBMIT_BUTTON_LOGGING_IN_TEXT;this.submitButton.disabled=true;},enableButton:function(){this.submitButton.innerHTML=this.SUBMIT_BUTTON_DEFAULT_TEXT;this.submitButton.disabled=false;},resetFormState:function(){this.usernameTextBox.value="";this.passwordTextBox.value="";this.messageBox.innerHTML="";this.messageBox.className=this.MESSAGE_BOX_HIDDEN_CLASS_NAME;this.enableButton();this.hideNotification();},setDOMElements:function(){this.usernameTextBox=document.getElementById(this.USERNAME_TEXT_BOX_ID);this.passwordTextBox=document.getElementById(this.PASSWORD_TEXT_BOX_ID);this.submitButton=document.getElementById(this.SUBMIT_BUTTON_ID);this.messageBox=document.getElementById(this.MESSAGE_BOX_ID);this.notificationImage=document.getElementById(this.NOTIFICATION_IMAGE_ID);},createContainerDiv:function(){var data={configuration:this.application.configuration};this.containerDiv=this.application.templates.loginScreenTemplate.process(data);this.registerEvents(this.containerDiv);},createShadowDiv:function(){this.shadowDiv=document.createElement("DIV");this.shadowDiv.className=this.SHADOW_CSS_CLASS_NAME;this.registerEvents(this.shadowDiv);},registerEvents:function(div){this.events=new OpenLayers.Events(this,div,null,true);this.events.register("mousedown",this,this.onmousedown);this.events.register("mousemove",this,this.onmousemove);this.events.register("mouseup",this,this.onmouseup);this.events.register("click",this,this.onclick);this.events.register("mouseover",this,this.onmouseover);this.events.register("mouseout",this,this.onmouseout);this.events.register("dblclick",this,this.ondblclick);},onmousedown:function(evt){this.mousedown=true;OpenLayers.Event.stop(evt,true);},onmousemove:function(evt){if(this.mousedown){OpenLayers.Event.stop(evt,true);}},onmouseup:function(evt){if(this.mousedown){this.mousedown=false;OpenLayers.Event.stop(evt,true);}},onclick:function(evt){OpenLayers.Event.stop(evt,true);},onmouseover:function(evt){this.application.disableZoomWheel();},onmouseout:function(evt){this.mousedown=false;this.application.enableZoomWheel();},ondblclick:function(evt){OpenLayers.Event.stop(evt,true);},stop:function(evt){OpenLayers.Event.stop(evt,true);}});OpenLayers.Position={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right"};Vespucci.PopupBase=OpenLayers.Class(OpenLayers.Popup,{RESIZE_INTERVAL:10,resizeTimeoutId:null,events:null,id:"",lonlat:null,div:null,size:null,contentHTML:"",opacity:"",map:null,closeButton:true,relativePosition:OpenLayers.Position.TOP_LEFT,onLoad:function(){},onClose:function(){},initialize:function(id,lonlat,size,content,closeButton){OpenLayers.Popup.prototype.initialize.apply(this,arguments);if(id==null){id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");}
this.id=id;this.lonlat=lonlat;if(closeButton!=null){this.closeButton=closeButton;}
this.div=OpenLayers.Util.createDiv(id,null,this.size,null,"absolute",null);this.div.className='olPopup';this.div.style.left="-99999px";this.div.style.top="0px";if(typeof content=="string"){this.div.innerHTML=content;}else{this.div.appendChild(content);}
if(size!=null)this.size=size.clone();this.registerEvents();if(!OpenLayers.Popup.SCROLL_BAR_WIDTH){OpenLayers.Popup.SCROLL_BAR_WIDTH=OpenLayers.Util.getScrollbarWidth();}},getPackedSize:function(){return OpenLayers.Util.getDOMElementPackedSize(this.div);},getContainer:function(){return this.div;},resize:function(newSize){var currentSize=this.size;newSize=this.constrainSizeToView(newSize);var differenceX=newSize.w-currentSize.w;var differenceY=newSize.h-currentSize.h;this.sizeDifference=new OpenLayers.Size(differenceX,differenceY);var popup=this;popup.resizeStart=(new Date()).getTime();if(this.resizeTimeoutId!=null)clearTimeout(this.resizeTimeoutId);function animateResize(){var elapsed=(new Date()).getTime()-popup.resizeStart;var madeChange=false;var newSize=popup.size;if(popup.sizeDifference.w!=0){var increment=Math.round(Math.min(elapsed/popup.RESIZE_ANIMATION_TIME,1)*Math.abs(popup.sizeDifference.w));direction=(popup.sizeDifference.w/Math.abs(popup.sizeDifference.w));increment=increment*direction;popup.sizeDifference.w-=increment;newSize.w+=increment;madeChange=true;}
if(popup.sizeDifference.h!=0){var increment=Math.round(Math.min(elapsed/popup.RESIZE_ANIMATION_TIME,1)*Math.abs(popup.sizeDifference.h));direction=(popup.sizeDifference.h/Math.abs(popup.sizeDifference.h));increment=increment*direction;popup.sizeDifference.h-=increment;newSize.h+=increment;madeChange=true;}
if(madeChange){popup.setSize(newSize,true);this.resizeTimeoutId=setTimeout(animateResize,popup.RESIZE_INTERVAL);}else{popup.resizeStart=null;this.resizeTimeoutId=null;}}
if(this.sizeDifference.w!=0||this.sizeDifference.h!=0){animateResize();}},pack:function(){this.resize(this.getPackedSize());},setSize:function(size,ignoreMapBounds){if(!ignoreMapBounds){size=this.constrainSizeToView(size);}
this.size=size;this.div.style.width=this.size.w+"px";this.div.style.height=this.size.h+"px";this.updatePosition();},constrainSizeToView:function(size){size=size.clone();var mapSize=this.map.size;var heightDifference=size.h-(mapSize.h-OpenLayers.Popup.POPUP_MARGIN.top-OpenLayers.Popup.POPUP_MARGIN.bottom);if(heightDifference>0){size.h-=heightDifference;}
var widthDifference=size.w-
(mapSize.w-
OpenLayers.Popup.POPUP_MARGIN.left-
OpenLayers.Popup.POPUP_MARGIN.right+
OpenLayers.Popup.SCROLL_BAR_WIDTH);if(widthDifference>0){size.w-=widthDifference;}else if(size.w+OpenLayers.Popup.SCROLL_BAR_WIDTH<mapSize.w){size.w+=OpenLayers.Popup.SCROLL_BAR_WIDTH;}
return size;},createCloseButton:function(){var oBtnClose=document.createElement("A");oBtnClose.id="olPopupCloseButton";oBtnClose.className="close";oBtnClose.style.position="absolute";oBtnClose.title="close popup";oBtnClose.href="#";this.div.appendChild(oBtnClose);var closeEvents=new OpenLayers.Events(this,oBtnClose);closeEvents.register("mousedown",this,this.onCloseButton);},onCloseButton:function(){this.hide();},destroy:function(){if(this.map!=null){this.map.removePopup(this);}
this.div=null;this.map=null;},draw:function(px){if(this.size==null){this.setSize(this.getPackedSize());}else{this.setSize(this.size);}
if(this.closeButton){this.createCloseButton();}
this.onLoad();if(this.panMapIfOutOfView){this.panIntoView();}
return this.div;},calculateRelativePosition:function(px,size){px=px.clone();if(this.relativePosition==OpenLayers.Position.TOP_RIGHT||this.relativePosition==OpenLayers.Position.BOTTOM_RIGHT){px.x-=size.w;}
if(this.relativePosition==OpenLayers.Position.BOTTOM_LEFT||this.relativePosition==OpenLayers.Position.BOTTOM_RIGHT){px.y-=size.h;}
return px;},moveTo:function(px){px=this.calculateRelativePosition(px,this.size);this.div.style.left=px.x+"px";this.div.style.top=px.y+"px";},visible:function(){return OpenLayers.Element.visible(this.div);},toggle:function(){OpenLayers.Element.toggle(this.div);},show:function(){OpenLayers.Element.show(this.div);},hide:function(){if(this.map)this.map.removePopup(this);OpenLayers.Element.hide(this.div);this.onClose();},setOpacity:function(opacity){if(opacity!=undefined){this.opacity=opacity;}
if(this.div!=null){this.div.style.opacity=this.opacity;this.div.style.filter='alpha(opacity='+this.opacity*100+')';}},registerEvents:function(){this.events=new OpenLayers.Events(this,this.div,null,true);this.events.register("mousedown",this,this.onmousedown);this.events.register("mousemove",this,this.onmousemove);this.events.register("mouseup",this,this.onmouseup);this.events.register("click",this,this.onclick);this.events.register("mouseout",this,this.onmouseout);this.events.register("dblclick",this,this.ondblclick);this.events.register("mouseover",this,this.onmouseover);},onmousedown:function(evt){this.mousedown=true;OpenLayers.Event.stop(evt,true);},onmousemove:function(evt){if(this.mousedown){OpenLayers.Event.stop(evt,true);}},onmouseover:function(evt){},onmouseup:function(evt){if(this.mousedown){this.mousedown=false;OpenLayers.Event.stop(evt,true);}},onclick:function(evt){OpenLayers.Event.stop(evt,true);},onmouseout:function(evt){this.mousedown=false;},ondblclick:function(evt){OpenLayers.Event.stop(evt,true);},CLASS_NAME:"Vespucci.PopupBase"});Vespucci.Request=OpenLayers.Class({application:null,SUCCESS_CODE:200,NOT_AUTHORIZED_ERROR_CODE:401,FORBIDDEN_ERROR_CODE:403,url:null,data:null,onSuccess:null,onFailure:null,onCancel:null,initialize:function(application){this.application=application;this.url=this.application.configuration.wfsvUrl;},createPostData:function(){return"";},send:function(onSuccess,onFailure,onCancel){this.data=this.createPostData();this.onSuccess=onSuccess||function(){};this.onFailure=onFailure||OpenLayers.Function.bind(this.defaultFailure,this);this.onCancel=onCancel||function(){};this.sendRequest(this.url,this.data,this.onSuccess,this.onFailure,this.onCancel);},resend:function(onSuccess,onFailure,onCancel){Vespucci.Request.prototype.send.apply(this,[onSuccess||this.onSuccess,onFailure||this.onFailure,onCancel||this.onCancel]);},createWFSVNamespace:function(xml,type){var element=xml.createElementNS(this.application.configuration.wfsvns,type);element.setAttribute("version","1.0.0");element.setAttribute("service","WFSV");element.setAttribute("outputFormat","GML2");element.setAttribute("xmlns:topp","http://www.openplans.org/topp");element.setAttribute("xmlns:ogc","http://www.opengis.net/ogc");element.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");element.setAttribute("xsi:schemaLocation","http://www.opengis.net/wfsv http://localhost:8080/geoserver/schemas/wfs/1.0.0/WFS-versioning.xsd");return element;},createWFSNamespace:function(xml,type){var element=xml.createElementNS(this.application.configuration.wfsns,type);element.setAttribute("version","1.0.0");element.setAttribute("service","WFS");element.setAttribute("outputFormat","GML2");element.setAttribute("xmlns:topp","http://www.openplans.org/topp");element.setAttribute("xmlns:ogc","http://www.opengis.net/ogc");element.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");return element;},sendRequest:function(url,data,onSuccess,onFailure,onCancel){if(OpenLayers.ProxyHost&&OpenLayers.String.startsWith(url,"http")){url=OpenLayers.ProxyHost+escape(url);}
var request=this;var processStatusCode=function(httpRequest){request.processStatusCode(httpRequest,onSuccess,onFailure,onCancel);};new OpenLayers.Ajax.Request(url,{method:'post',postBody:data,onComplete:processStatusCode});},processStatusCode:function(httpRequest,onSuccess,onFailure,onCancel){var request=this;switch(httpRequest.status){case this.NOT_AUTHORIZED_ERROR_CODE:var showError=function(){request.application.showPleaseLoginError();onCancel(httpRequest);}
var resendRequest=function(){request.resend(onSuccess,onFailure,onCancel);}
this.application.showLoginScreen(resendRequest,showError);break;case this.FORBIDDEN_ERROR_CODE:this.application.showForbiddenError();break;case this.SUCCESS_CODE:onSuccess(httpRequest);break;default:onFailure(httpRequest);break;}},defaultFailure:function(response){alert("Request of type '"+this.CLASS_NAME+"' failed with error code "+response.status+". Map may not work properly.");},CLASS_NAME:"Vespucci.Request"});Vespucci.RequestQueue=OpenLayers.Class({queue:null,processing:false,initialize:function(){this.queue=[];},hasNext:function(){return this.queue.length!=0;},isProcessing:function(){return this.processing;},enqueue:function(request,onSuccess,onFailure,onCancel){var queue=this;var processNextOnSuccess=function(response){queue.processNext();if(onSuccess){onSuccess(response);}}
var clearAllOnFailure=function(response){queue.clearAll();if(onFailure){onFailure(response);}}
var clearAllOnCancel=function(response){queue.clearAll();if(onCancel){onCancel(response);}}
var queueItem=new Vespucci.RequestQueue.QueueItem(request,processNextOnSuccess,clearAllOnFailure,clearAllOnCancel);this.queue.push(queueItem);if(!this.isProcessing()){this.processNext();}},dequeue:function(request){return this.queue.shift();},clearAll:function(){this.queue.length=0;this.processing=false;},processNext:function(){if(!this.hasNext()){this.processing=false;return;}
this.processing=true;var queueItem=this.dequeue();var request=queueItem.request;var onSuccess=queueItem.onSuccess;var onFailure=queueItem.onFailure;var onCancel=queueItem.onCancel;request.send(onSuccess,onFailure,onCancel);}});Vespucci.RequestQueue.QueueItem=OpenLayers.Class({request:null,onSuccess:null,onFailure:null,onCancel:null,initialize:function(request,onSuccess,onFailure,onCancel){this.request=request;this.onSuccess=onSuccess;this.onFailure=onFailure;this.onCancel=onCancel;}});Vespucci.Rule={}
Vespucci.Rule.FeatureTypeRule=OpenLayers.Class(OpenLayers.Rule,{symbolizer:null,initialize:function(type,symbolizer,options){this.value=type;this.filter=new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,value:type,property:"type"})
this.symbolizer=symbolizer;},getContext:function(feature){return feature;},CLASS_NAME:"Vespucci.Rule.FeatureTypeRule"});Vespucci.Rule.SubtypeRule=OpenLayers.Class(OpenLayers.Rule,{symbolizer:null,initialize:function(type,subtype,options){var filters=[];for(attribute in subtype.attributes){filters.push(new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:attribute,value:subtype.attributes[attribute]}));}
this.filter=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:filters});OpenLayers.Rule.prototype.initialize.apply(this,[options]);this.symbolizer=OpenLayers.Util.extend({},subtype.style);},CLASS_NAME:"Vespucci.Rule.SubtypeRule"});Vespucci.ScrollPosition={NONE:"none",TOP:"top",BOTTOM:"bottom"};Vespucci.Sidebar=OpenLayers.Class({application:null,container:null,contentDiv:null,toggleBarDiv:null,VISIBLE_CSS_CLASS_NAME:"VespucciSidebar",HIDDEN_CSS_CLASS_NAME:"VespucciSidebar hidden",CONTENT_CLASS_NAME:"SidebarContentDiv",TOGGLE_BAR_CLASS_NAME:"SidebarToggleBarDiv",marginChanged:null,view:null,initialize:function(application){this.application=application;this.container=document.createElement("DIV");this.container.className=this.HIDDEN_CSS_CLASS_NAME;this.createToggleDiv();this.createContentDiv();this.calculatePosition();this.registerEvents();this.application.map.div.appendChild(this.container);},calculatePosition:function(){var containerHeight=this.application.map.size.h-this.application.configuration.margins.top-this.application.configuration.margins.bottom;this.container.style.height=containerHeight+"px";this.container.style.top=this.application.configuration.margins.top+"px";this.container.style.right=this.application.configuration.margins.right+"px";this.container.style.bottom=this.application.configuration.margins.bottom+"px";},isShown:function(){return this.container.className==this.VISIBLE_CSS_CLASS_NAME;},show:function(){if(this.isShown())return;if(!this.view.loaded){this.reload();}
this.container.className=this.VISIBLE_CSS_CLASS_NAME;this.marginChanged=OpenLayers.Util.getDOMElementBounds(this.container).width;this.application.configuration.popupMargins.right+=this.marginChanged;var popup=this.application.getPopup()
if(popup){popup.shiftMapIfNotViewable();}},hide:function(){if(!this.isShown())return;this.container.className=this.HIDDEN_CSS_CLASS_NAME;this.application.configuration.popupMargins.right-=this.marginChanged;},toggle:function(){if(this.isShown()){this.hide();}else{this.show();}},replaceContent:function(content){this.contentDiv.innerHTML="";if(typeof content=="string"){this.contentDiv.innerHTML=content;}else{this.contentDiv.appendChild(content.cloneNode(true));Vespucci.Util.addTransparencyToGraphics(this.contentDiv);}},loadView:function(view){if(this.view){this.view.close();}
this.view=view;this.view.setSidebar(this);if(this.isShown()){this.reload();}},reload:function(){this.showLoading();this.view.load();},showLoading:function(){this.replaceContent(this.application.templates.sidebarLoadingTemplate.process());},scrollTo:function(scrollPosition){switch(scrollPosition)
{case Vespucci.ScrollPosition.TOP:this.container.scrollTop=0;break;case Vespucci.ScrollPosition.BOTTOM:this.container.scrollTop=this.container.scrollHeight;break;}},createToggleDiv:function(){this.toggleBarDiv=document.createElement("div");this.toggleBarDiv.className=this.TOGGLE_BAR_CLASS_NAME;this.container.appendChild(this.toggleBarDiv);var closeEvents=new OpenLayers.Events(this,this.toggleBarDiv);closeEvents.register("mousedown",this,this.toggle);},createContentDiv:function(){this.contentDiv=document.createElement("div");this.contentDiv.className=this.CONTENT_CLASS_NAME;this.container.appendChild(this.contentDiv);},registerEvents:function(){this.events=new OpenLayers.Events(this,this.container,null,true);this.events.register("mousedown",this,this.onmousedown);this.events.register("mousemove",this,this.onmousemove);this.events.register("mouseup",this,this.onmouseup);this.events.register("click",this,this.onclick);this.events.register("mouseover",this,this.onmouseover);this.events.register("mouseout",this,this.onmouseout);this.events.register("dblclick",this,this.ondblclick);if(OpenLayers.String.contains(navigator.appName,"Microsoft")){this.application.map.events.register("resize",this,this.calculatePosition);}
else{OpenLayers.Event.observe(window,'resize',OpenLayers.Function.bind(this.calculatePosition,this));}},onmousedown:function(evt){this.mousedown=true;OpenLayers.Event.stop(evt,true);},onmousemove:function(evt){if(this.mousedown){OpenLayers.Event.stop(evt,true);}},onmouseup:function(evt){if(this.mousedown){this.mousedown=false;OpenLayers.Event.stop(evt,true);}},onclick:function(evt){OpenLayers.Event.stop(evt,true);},onmouseover:function(evt){this.application.disableZoomWheel();},onmouseout:function(evt){this.mousedown=false;this.application.enableZoomWheel();},ondblclick:function(evt){OpenLayers.Event.stop(evt,true);},stop:function(evt){OpenLayers.Event.stop(evt,true);},CLASS_NAME:"Vespucci.Sidebar"});var notesvar;Vespucci.SidebarView=OpenLayers.Class({sidebar:null,content:null,loaded:false,initialize:function(application){this.application=application;},setSidebar:function(sidebar){this.sidebar=sidebar;},load:function(){this.processContent();this.sidebar.replaceContent(this.content);this.addBehaviors();this.loaded=true;},reload:function(){this.sidebar.reload();},processContent:function(){this.content="";},addBehaviors:function(){},hasFeatureContext:function(){return!!this.feature;},close:function(){}});Vespucci.Strategy={}
Vespucci.Strategy.Transactions=OpenLayers.Class(OpenLayers.Strategy,{SUCCESS_CODE:200,NOT_AUTHORIZED_ERROR_CODE:401,FORBIDDEN_ERROR_CODE:403,initialize:function(options){OpenLayers.Strategy.prototype.initialize.apply(this,[options]);this.callback[OpenLayers.State.INSERT]=this.inserted;this.callback[OpenLayers.State.UPDATE]=this.updated;this.callback[OpenLayers.State.DELETE]=this.deleted;this.message[OpenLayers.State.INSERT]=function(){return"Inserted feature";};this.message[OpenLayers.State.UPDATE]=function(feature){return"Updated feature "+feature.fid;};this.message[OpenLayers.State.DELETE]=function(feature){return"Deleted feature "+feature.fid;};},save:function(feature,onSuccess,onFailure){onFailure=onFailure||function(){};var strategy=this;var callback=function(response){strategy.processStatusCode(response,function(response){OpenLayers.Function.bind(strategy.callback[feature.state],strategy)(response,onSuccess);},onFailure,function(){});};this.layer.protocol.commit([feature],{callback:callback,scope:this,handle:this.message[feature.state](feature)});},inserted:function(response,onSuccess){var feature=response.reqFeatures[0];var insertIds=response.insertIds||[];if(insertIds.length>0){feature.fid=insertIds[0];this.refreshFeature(feature,onSuccess)}},refreshFeature:function(feature,onSuccess){var fidFilter=new OpenLayers.Filter.FeatureId({fids:[feature.fid]});var strategy=this;this.layer.protocol.read({filter:fidFilter,callback:function(resp){strategy.layer.destroyFeatures([feature]);strategy.layer.addFeatures(resp.features);onSuccess(resp.features[0])},scope:this});},updated:function(response,onSuccess){var feature=response.reqFeatures[0];feature.state=null;this.refreshFeature(feature,onSuccess)},deleted:function(response,onSuccess){var feature=response.reqFeatures[0];this.layer.destroyFeatures([feature]);this.deleteComments(response,onSuccess);},deleteComments:function(response,onSuccess){var feature=response.reqFeatures[0];var gid=feature.getGID();var filter=new OpenLayers.Filter.Comparison({type:"==",property:"notes_gid",value:gid+""});var deleteCommentsFailure=function(){OpenLayers.Console.error("Deleting comments for feature '"+feature.getFID()+"' failed.");}
var callback=function(){if(response.success()){onSuccess(feature);}else{deleteCommentsFailure();}}
this.layer.protocol.filterDelete(filter,{featureType:"comments",callback:callback})},callback:{},message:{},onCommit:function(response){if(response.success()){var feature=response.reqFeatures;var state,feature;var destroys=[];var insertIds=response.insertIds||[];var j=0;for(var i=0,len=features.length;i<len;++i){feature=features[i];state=feature.state;if(state){if(state==OpenLayers.State.DELETE){destroys.push(feature);}else if(state==OpenLayers.State.INSERT){feature.fid=insertIds[j];++j;}
feature.state=null;}}
if(destroys.length>0){this.layer.destroyFeatures(destroys);}}},remove:function(){var features=[];for(var i=0;i<this.layer.features.length;i++){if(this.layer.features[i].state==OpenLayers.State.INSERT){features.push(this.layer.features[i]);}}
this.layer.destroyFeatures(features);},rollback:function(feature,options,onSuccess,onFailure){options.filter=new OpenLayers.Filter.FeatureId({fids:[feature.fid]});onSuccess=onSuccess||function(){};onFailure=onFailure||function(){};var strategy=this;var callback=function(response){if(response.success()){strategy.refreshFeature(feature,onSuccess);}else{onFailure(response);}}
options.callback=callback;options.handle="Rolled back feature "+feature.fid+" from r"+options.fromFeatureVersion+" to r"+options.toFeatureVersion;this.layer.protocol.rollback(options);},processStatusCode:function(response,onSuccess,onFailure,onCancel){var strategy=this;switch(response.priv.status){case this.NOT_AUTHORIZED_ERROR_CODE:alert("You are not authorized to make this change.");onFailure(response);break;case this.FORBIDDEN_ERROR_CODE:alert("You are not authorized to make this change.");onFailure(response);break;case this.SUCCESS_CODE:onSuccess(response);break;default:onFailure(response);break;}},CLASS_NAME:"Vespucci.Strategy.Transactions"});Vespucci.Topbar=OpenLayers.Class({application:null,containerDiv:null,backgroundDiv:null,textDiv:null,panelDiv:null,addNoteListItemId:"vespucci-add-note-li",historyListItemId:"vespucci-history-li",loginListItemId:"vespucci-login-li",historyLink:null,loginLink:null,LOGIN_LINK_TEXT:"Login",LOGOUT_LINK_TEXT:"Logout",initialize:function(application){this.application=application;this.createContainer();this.createBackgroundDiv();this.createTextDiv();this.createPanelDiv();this.containerDiv.appendChild(this.backgroundDiv);this.containerDiv.appendChild(this.textDiv);this.containerDiv.appendChild(this.panelDiv);this.application.map.div.appendChild(this.containerDiv);this.adjustMargins();this.registerEvents();this.addBehaviors();this.updateLoginLinkText();},createContainer:function(){this.containerDiv=document.createElement("DIV");this.containerDiv.className=this.application.configuration.topbarContainerCSSClass;},createBackgroundDiv:function(){this.backgroundDiv=document.createElement("DIV");this.backgroundDiv.className=this.application.configuration.topbarBackgroundCSSClass;},createTextDiv:function(){this.textDiv=this.application.templates.topbarTemplate.process();this.textDiv.className=this.application.configuration.topbarTextCSSClass;},createPanelDiv:function(){this.panelDiv=document.createElement("DIV");this.panelDiv.className=this.application.configuration.topbarPanelCSSClass;},addBehaviors:function(){var topbar=this;var addNoteLi=document.getElementById(this.addNoteListItemId);var historyLi=document.getElementById(this.historyListItemId);var loginLi=document.getElementById(this.loginListItemId);this.addNoteLink=addNoteLi.getElementsByTagName("A")[0];this.historyLink=historyLi.getElementsByTagName("A")[0];this.loginLink=loginLi.getElementsByTagName("A")[0];Vespucci.Util.setOnclick(this.addNoteLink,function(){topbar.application.showAddFeature("notes");})
Vespucci.Util.setOnclick(this.historyLink,function(){topbar.application.showHistory();});Vespucci.Util.setOnclick(this.loginLink,function(){var onSuccess=function(){topbar.updateLoginLinkText();}
if(topbar.application.isLoggedIn()){topbar.application.logout();onSuccess();}else{topbar.application.showLoginScreen(onSuccess);}});},updateLoginLinkText:function(){if(this.application.isLoggedIn()){this.loginLink.innerHTML=this.LOGOUT_LINK_TEXT;}else{this.loginLink.innerHTML=this.LOGIN_LINK_TEXT;}},adjustMargins:function(){var topbarBounds=OpenLayers.Util.getDOMElementBounds(this.containerDiv);this.application.configuration.margins.top+=topbarBounds.height;this.application.configuration.popupMargins.top+=topbarBounds.height;this.application.updateMargins();},registerEvents:function(){this.events=new OpenLayers.Events(this,this.containerDiv,null,true);this.events.register("mousedown",this,this.onmousedown);this.events.register("mousemove",this,this.onmousemove);this.events.register("mouseup",this,this.onmouseup);this.events.register("click",this,this.onclick);this.events.register("mouseover",this,this.onmouseover);this.events.register("mouseout",this,this.onmouseout);this.events.register("dblclick",this,this.ondblclick);},onmousedown:function(evt){this.mousedown=true;OpenLayers.Event.stop(evt,true);},onmousemove:function(evt){if(this.mousedown){OpenLayers.Event.stop(evt,true);}},onmouseup:function(evt){if(this.mousedown){this.mousedown=false;OpenLayers.Event.stop(evt,true);}},onclick:function(evt){OpenLayers.Event.stop(evt,true);},onmouseover:function(evt){},onmouseout:function(evt){this.mousedown=false;},ondblclick:function(evt){OpenLayers.Event.stop(evt,true);},stop:function(evt){OpenLayers.Event.stop(evt,true);}});Vespucci.GeometryType={Point:Vespucci.Handler.Point,Polygon:OpenLayers.Handler.Polygon,getName:function(type){var className=type.prototype.CLASS_NAME;var lastDot=className.lastIndexOf(".");return className.substring(lastDot+1);}}
Vespucci.DynamicToolbar=OpenLayers.Class(OpenLayers.Control.Panel,{CSS_CLASS_PART:"DrawFeature",initialize:function(application,options){OpenLayers.Control.Panel.prototype.initialize.apply(this,[options]);var panel=this;var controls=[];for(var name in application.configuration.addControls){var handler=application.configuration.addControls[name];var style=null;if(application.configuration.featureStyles[name]){style=OpenLayers.Util.extend({},application.configuration.featureStyles[name]);}
var controlOptions={displayClass:this.createControlCSSClass(application,handler),handlerOptions:{layer:application.wfsLayer,style:style},subtype:application.configuration.subtypes["notes"][0]};var control=new Vespucci.DrawSubtypedFeature(application.configuration,application.wfsLayer,handler,controlOptions);control.beforeAdd=function(feature){feature.featureNS=application.configuration.namespaceUri;feature.featureNSName=application.configuration.namespace;feature.type=name;}
control.featureAdded=function(feature){feature.state=OpenLayers.State.INSERT;feature.edit(application);panel.deactivateControl(feature.type);}
control.name=name;control.type=OpenLayers.Control.TYPE_TOGGLE;controls.push(control);}
this.addControls(controls);},deactivateControl:function(name){for(var index=0;index<this.controls.length;index++){var control=this.controls[index];if(control.name==name){control.deactivate();this.redraw();break;}}},createControlCSSClass:function(application,handler){var handlerName=Vespucci.GeometryType.getName(handler);return application.configuration.mainVespucciCSSClass+this.CSS_CLASS_PART+handlerName;},CLASS_NAME:"Vespucci.DynamicToolbar"});Vespucci.Feature.Comment=OpenLayers.Class(Vespucci.Feature,{note:null,selected:function(application){var afterRequest=function(note){note.selected(application);}
this.requestNote(application,afterRequest);},toHtml:function(){return"Comment added by "+this.getCreator()+" "+this.getPrettyCreationDate();},getTitle:function(){return this.attributes.title;},getText:function(){return this.attributes.comment;},getNoteGID:function(){return this.attributes.notes_gid;},getNoteFID:function(){return"notes."+this.getNoteGID();},setTitle:function(title){this.attributes.title=title;},setText:function(text){this.attributes.comment=text;},setNoteGID:function(notes_gid){this.attributes.notes_gid=notes_gid;},shiftMapUntilVisible:function(application,onVisible){var shiftAfterRequestingNote=function(note){note.shiftMapUntilVisible(application,onVisible);}
this.requestNote(application,shiftAfterRequestingNote)},requestNote:function(application,afterRequest){var comment=this;this.note=application.wfsLayer.getFeatureByFid(this.getNoteFID());if(this.note==null){var request=new Vespucci.Request.GetFeatureRequest(application,"notes",this.getNoteFID());request.send(afterRequest);}else{afterRequest(this.note);}},CLASS_NAME:"Vespucci.Feature.Comments"});Vespucci.Feature.Note=OpenLayers.Class(Vespucci.Feature,{selected:function(application){function selectNote(note){application.addPopup(new Vespucci.Popup.ViewPopup(application,note));if(application.sidebar.view.CLASS_NAME!="Vespucci.SidebarView.HistoryFeedView"){application.loadCommentsInSidebar(note,Vespucci.ScrollPosition.TOP);}}
this.runWhenVisible(application,selectNote);},dragged:function(application,from){function dragNote(note){application.addPopup(new Vespucci.Popup.MovePopup(application,note,from));}
this.runWhenVisible(application,dragNote);},edit:function(application){function editNote(note){application.addPopup(new Vespucci.Popup.EditPopup(application,note));}
this.runWhenVisible(application,editNote);},getTitle:function(){return this.attributes.title;},getContent:function(){return this.attributes.content;},getTypeId:function(){return this.attributes.typeid;},setTitle:function(title){this.attributes.title=title;},setContent:function(content){this.attributes.content=content;},setTypeId:function(typeid){this.attributes.typeid=typeid;this.updateStyle();},runWhenVisible:function(application,funktion){if(this.fid&&!application.hasFeature(this)){this.shiftMapUntilVisible(application,funktion);}else{funktion(application.getFeatureByFid(this.fid)||this);}},toHtml:function(){return"<span><img src='"+this.getSubtype().style.externalGraphic+"'>Note added by "+this.getCreator()+" "+this.getPrettyCreationDate()+"</span>";},getIcon:function(){var iconIndex=Math.min(this.getTypeId()||0,this.configuration.icons.length-1);return this.configuration.icons[iconIndex];},CLASS_NAME:"Vespucci.Feature.Notes"});Vespucci.LoginHandler.OpenPlans=OpenLayers.Class(Vespucci.LoginHandler,{OPENPLANS_URI:"http://www.openplans.org",DAYS_TO_SET_COOKIE:1,OPENPLANS_PASSWORD_ID:"__ac_password",OPENPLANS_COOKIE_NAME:"__ac",OPENPLANS_DOMAIN:".openplans.org",CONTENT_TYPE:"application/x-www-form-urlencoded",PASSWORD_NOT_VALID_STATUS_CODE:400,USERNAME_NOT_FOUND_STATUS_CODE:404,validate:function(username,password,onValidate,onInvalid){var postParameters={};postParameters[this.OPENPLANS_PASSWORD_ID]=password;var url=this.createUrl(username);var handler=this;var processValidLogin=function(response){handler.processValidLogin(response);onValidate();}
var processInvalidLogin=function(response){switch(response.status){case handler.PASSWORD_NOT_VALID_STATUS_CODE:case handler.USERNAME_NOT_FOUND_STATUS_CODE:onInvalid(handler.USERNAME_OR_PASSWORD_INVALID_ERROR_TEXT);break;default:onInvalid(handler.UNEXPECTED_ERROR_TEXT);break;}}
var request=new OpenLayers.Ajax.Request(url,{method:'post',parameters:postParameters,contentType:this.CONTENT_TYPE,onSuccess:processValidLogin,onFailure:processInvalidLogin});},logout:function(){this.deleteCookie(this.OPENPLANS_COOKIE_NAME,this.OPENPLANS_DOMAIN);},processValidLogin:function(xmlHttpRequest){var response=xmlHttpRequest.responseText;var indexOfEqualSign=response.indexOf("=");var cookieName=response.substring(0,indexOfEqualSign);var cookieValue=response.substring(indexOfEqualSign+1,response.length);if(cookieValue.lastIndexOf("\n")==cookieValue.length-1){cookieValue=cookieValue.substring(0,cookieValue.length-1);}
this.createCookie(cookieName,cookieValue,this.DAYS_TO_SET_COOKIE,this.OPENPLANS_DOMAIN);if(document.cookie==""){alert(this.COOKIES_NOT_ENABLED);}},isLoggedIn:function(){return this.readCookie(this.OPENPLANS_COOKIE_NAME)!=null;},createUrl:function(username){return this.application.configuration.proxy+this.OPENPLANS_URI+"/people/"+username+"/get-hash";},CLASS_NAME:"Vespucci.LoginHandler.OpenPlans"});Vespucci.PopupBase.Anchored=OpenLayers.Class(Vespucci.PopupBase,{anchor:null,initialize:function(id,lonlat,size,contentHTML,anchor,closeButton)
{this.anchor=(anchor!=null)?anchor:{size:new OpenLayers.Size(0,0),offset:new OpenLayers.Pixel(0,0)};Vespucci.PopupBase.prototype.initialize.apply(this,[id,lonlat,size,contentHTML,closeButton]);},calculateRelativePosition:function(px,size){if(this.anchor){px.y-=this.anchor.size.h/2;}
return Vespucci.PopupBase.prototype.calculateRelativePosition.apply(this,[px,size]);},CLASS_NAME:"Vespucci.PopupBase.Anchored"});Vespucci.Request.FeatureRequest=OpenLayers.Class(Vespucci.Request,{send:function(onSuccess,onFailure,onCancel){var request=this;var newSuccess=function(response){var options=request.application.getWFSParams();if(this.type){options.featureType=request.type;}
var features=(new OpenLayers.Format.WFSV(options)).read(response.responseXML);Vespucci.Feature.extendOpenLayersFeatures(features,request.application.configuration,request.type);onSuccess(features);}
Vespucci.Request.prototype.send.apply(this,[newSuccess,onFailure,onCancel]);},CLASS_NAME:"Vespucci.Request.FeatureRequest"});Vespucci.Request.SaveFeaturesRequest=OpenLayers.Class(Vespucci.Request,{formatClass:OpenLayers.Format.WFS,format:null,layer:null,features:null,initialize:function(application,features){this.layer=application.wfsLayer;if(features==null){features=this.layer.features;}
if(!(features instanceof Array)){features=[features];}
this.features=features;var formatOptions={layerName:application.getWFSTypeString()};this.format=new this.formatClass(formatOptions,this.layer);this.format.srsName=application.configuration.projection;Vespucci.Request.prototype.initialize.apply(this,[application]);},createPostData:function(){return this.format.write(this.features);},send:function(onSuccess,onFailure,onCancel){var request=this;var newSuccess=function(response){var xml=new OpenLayers.Format.XML();var inserts=[];var insertResults=response.responseXML.getElementsByTagName("InsertResult");for(var index=0;index<insertResults.length;index++){var featureId=insertResults[index].getElementsByTagName("FeatureId")[0];if(featureId){var fid=xml.getAttributeNS(featureId,"","fid");inserts.push(fid);}}
onSuccess(inserts);}
Vespucci.Request.prototype.send.apply(this,[newSuccess,onFailure,onCancel]);},CLASS_NAME:"Vespucci.Request.SaveFeaturesRequest"});Vespucci.Request.AddCommentRequest=OpenLayers.Class(Vespucci.Request,{feature:null,comment:null,initialize:function(application,feature,comment){this.feature=feature;this.comment=comment;Vespucci.Request.prototype.initialize.apply(this,[application]);},createPostData:function(){var xml=new OpenLayers.Format.XML();var transaction=this.createWFSNamespace(xml,"wfs:Transaction");var insert=xml.createElementNS(this.application.configuration.wfsvns,"wfs:Insert");var commentType=xml.createElementNS(this.application.configuration.toppns,"topp:comments");var title=xml.createElementNS(this.application.configuration.toppns,"topp:title");title.appendChild(xml.createTextNode(this.comment.getTitle()));var commentContent=xml.createElementNS(this.application.configuration.toppns,"topp:comment");commentContent.appendChild(xml.createTextNode(this.comment.getText()));var notesGID=xml.createElementNS(this.application.configuration.toppns,"topp:notes_gid");notesGID.appendChild(xml.createTextNode(this.feature.getGID()));commentType.appendChild(title);commentType.appendChild(commentContent);commentType.appendChild(notesGID);insert.appendChild(commentType);transaction.appendChild(insert);return xml.write(transaction);},CLASS_NAME:"Vespucci.Request.AddCommentRequest"});Vespucci.Request.DeleteCommentsRequest=OpenLayers.Class(Vespucci.Request,{initialize:function(application,feature){this.feature=feature;Vespucci.Request.prototype.initialize.apply(this,[application]);},createPostData:function(){var xml=new OpenLayers.Format.XML();var transaction=this.createWFSNamespace(xml,"wfs:Transaction");var deleteNode=xml.createElementNS(this.application.configuration.wfsns,"wfs:Delete");deleteNode.setAttribute("typeName","topp:comments");var filterNode=xml.createElementNS(this.application.configuration.ogcns,"ogc:Filter");var propertyIsEqualTo=xml.createElementNS(this.application.configuration.ogcns,"ogc:PropertyIsEqualTo");var propertyName=xml.createElementNS(this.application.configuration.ogcns,"ogc:PropertyName");propertyName.appendChild(xml.createTextNode("notes_gid"));var literal=xml.createElementNS(this.application.configuration.ogcns,"ogc:Literal");literal.appendChild(xml.createTextNode(this.feature.getFID()));propertyIsEqualTo.appendChild(propertyName);propertyIsEqualTo.appendChild(literal);filterNode.appendChild(propertyIsEqualTo);deleteNode.appendChild(filterNode);transaction.appendChild(deleteNode);return xml.write(transaction);},CLASS_NAME:"Vespucci.Request.DeleteCommentsRequest"});Vespucci.SidebarView.AddFeatureView=OpenLayers.Class(Vespucci.SidebarView,{features:null,type:null,subtypes:null,drawControl:null,unselectedCSSClass:"unselected",selectedCSSClass:"selected",selectedSubtype:null,initialize:function(application,type,drawControl){this.type=type;this.drawControl=drawControl;view=this;var oldFeatureAdded=OpenLayers.Function.bind(this.drawControl.featureAdded,this.drawControl);this.drawControl.featureAdded=function(feature){view.unselect();this.deactivate();oldFeatureAdded(feature);}
Vespucci.SidebarView.prototype.initialize.apply(this,[application]);},processContent:function(){this.content=this.application.templates.sidebarAddNoteTemplate.process({subtypes:this.application.configuration.subtypes[this.type]})},addBehaviors:function(){var view=this;var generateMouseDown=function(eltSubtype){return function(){if(view.selectedSubtype==eltSubtype){view.unselect();}else{view.select(eltSubtype);}};};var generateCancelOnClick=function(subtype){return function(){view.unselect();return false;}};this.subtypes=this.application.configuration.subtypes[this.type];var subtype;var domElt;for(var i=0;i<this.subtypes.length;i++){subtype=this.subtypes[i];domElt=this.getDomEltFromSubtype(subtype);Vespucci.Util.setOnMouseDown(domElt,generateMouseDown(subtype));Vespucci.Util.setOnclick(domElt.getElementsByTagName("A")[0],generateCancelOnClick(subtype));}},close:function(){this.drawControl.cancel();},select:function(subtype){if(this.selectedSubtype!=null){this.unselect();}
var domElt=this.getDomEltFromSubtype(subtype);domElt.selected=true;domElt.className=this.selectedCSSClass;this.selectedSubtype=subtype;this.drawControl.activate(subtype);},unselect:function(){if(this.selectedSubtype==null){return;}
var domElt=this.getDomEltFromSubtype(this.selectedSubtype);domElt.selected=false;domElt.className=this.unselectedCSSClass;this.selectedSubtype=null;this.drawControl.cancel();},getDomEltFromSubtype:function(subtype){return document.getElementById("VespucciSidebarAddFeatureCategorySelector:"+subtype.name);},CLASS_NAME:"Vespucci.SidebarView.AddNoteView"})
Vespucci.SidebarView.FeatureDiffView=OpenLayers.Class(Vespucci.SidebarView,{feature:null,fromFeatureVersion:null,toFeatureVersion:null,initialize:function(application,feature,fromFeatureVersion,toFeatureVersion){this.feature=feature;this.fromFeatureVersion=fromFeatureVersion;this.toFeatureVersion=toFeatureVersion;Vespucci.SidebarView.prototype.initialize.apply(this,[application]);},load:function(){var view=this;var onSuccess=function(response){view.diffResponse=response;var onSuccess=function(response){view.readResponse=response;Vespucci.SidebarView.prototype.load.apply(view,[]);};var options={filter:new OpenLayers.Filter.FeatureId({fids:[view.feature.fid]}),featureVersion:view.fromFeatureVersion,callback:onSuccess};view.feature.layer.protocol.read(options);}
var options={filter:new OpenLayers.Filter.FeatureId({fids:[this.feature.fid]}),fromFeatureVersion:this.fromFeatureVersion,toFeatureVersion:this.toFeatureVersion,callback:onSuccess};this.feature.layer.protocol.getDiff(options);},processContent:function(){this.featureFrom=this.readResponse.features[0];var diff=this.diffResponse.features;OpenLayers.Console.log(diff);this.update=diff.updates[0]?diff.updates[0].properties:{};if(this.update["the_geom"]){}
this.content=this.application.templates.sidebarFeatureDiffTemplate.process({fromFeatureVersion:this.fromFeatureVersion||"FIRST",toFeatureVersion:this.toFeatureVersion||"LAST",feature:this.feature,featureFrom:this.featureFrom,update:this.update,configuration:this.application.configuration,prettyDate:Vespucci.Util.prettyDate},true);},addBehaviors:function(){var view=this;var successfulRollback=function(feature){feature.selected(view.application);};Vespucci.Util.setOnclick("olSidebarFeatureDiffRollbackLink",function(){view.application.rollback(view.feature,{toFeatureVersion:view.fromFeatureVersion,fromFeatureVersion:view.toFeatureVersion},successfulRollback);return false;})
Vespucci.Util.setOnclick("olSidebarFeatureDiffHistoryLink",function(){view.application.loadFeatureHistoryInSidebar(view.feature,Vespucci.ScrollPosition.TOP);return false;})
var fromWMSLayer=new OpenLayers.Layer.WMS(view.application.configuration.wmsLayerName+":From",view.application.configuration.wmsUrl,view.application.configuration.wmsOptions);var diffMapOptions={projection:view.application.configuration.projection,maxExtent:view.application.configuration.maxExtent,maxResolution:view.application.configuration.maxResolution,controls:[]};OpenLayers.Util.extend(diffMapOptions,view.application.configuration.mapOptions);var fromFeature=view.featureFrom.clone();fromFeature.type=view.feature.layer.protocol.format.featureType;var fromFeatureLayer=new OpenLayers.Layer.Vector("From Layer",{styleMap:view.application.createStyleMap()});fromFeatureLayer.addFeatures([fromFeature]);var fromMap=new OpenLayers.Map("fromMap",diffMapOptions);fromMap.addLayers([fromWMSLayer,fromFeatureLayer]);fromMap.setCenter(fromFeature.geometry.getBounds().getCenterLonLat(),view.application.configuration.defaultDiffZoomLevel);var toWMSLayer=new OpenLayers.Layer.WMS(view.application.configuration.wmsLayerName+":To",view.application.configuration.wmsUrl,view.application.configuration.wmsOptions);var toFeature=view.featureFrom.clone();toFeature.type=view.feature.layer.protocol.format.featureType;if(this.update["the_geom"]){var geometry=this.update["the_geom"].components[0];geometry.transform(new OpenLayers.Projection("EPSG:4326"),view.application.map.getProjectionObject());toFeature.geometry=geometry;}
OpenLayers.Util.extend(toFeature.attributes,this.update);var toFeatureLayer=new OpenLayers.Layer.Vector("To Layer",{styleMap:view.application.createStyleMap()});toFeatureLayer.addFeatures([toFeature]);var toMap=new OpenLayers.Map("toMap",diffMapOptions);toMap.addLayers([toWMSLayer,toFeatureLayer]);toMap.setCenter(toFeature.geometry.getBounds().getCenterLonLat(),view.application.configuration.defaultDiffZoomLevel);if(this.scrollPosition){this.sidebar.scrollTo(this.scrollPosition);}},CLASS_NAME:"Vespucci.SidebarView.FeatureHistoryView"});Vespucci.SidebarView.FeatureHistoryView=OpenLayers.Class(Vespucci.SidebarView,{feature:null,comments:null,initialize:function(application,feature,scrollPosition){this.feature=feature;this.scrollPosition=scrollPosition;Vespucci.SidebarView.prototype.initialize.apply(this,[application]);},load:function(){var view=this;var onSuccess=function(response){view.response=response;Vespucci.SidebarView.prototype.load.apply(view,[]);}
var options={filter:new OpenLayers.Filter.FeatureId({fids:[this.feature.fid]}),callback:onSuccess};this.feature.layer.protocol.getLog(options);},processContent:function(){var revisions=this.response.features;this.content=this.application.templates.sidebarFeatureHistoryTemplate.process({revisions:revisions,feature:this.feature,description:this.feature.attributes.content||"",configuration:this.application.configuration,prettyDate:Vespucci.Util.prettyDate},true);},addBehaviors:function(){var view=this;Vespucci.Util.setOnclick("diff",function(){var to;for(var i=0;i<document.olSidebarFeatureHistoryForm.to.length;i++){if(document.olSidebarFeatureHistoryForm.to[i].checked){to=document.olSidebarFeatureHistoryForm.to[i].value;}}
to=to||document.olSidebarFeatureHistoryForm.to.value;var from;for(var i=0;i<document.olSidebarFeatureHistoryForm.from.length;i++){if(document.olSidebarFeatureHistoryForm.from[i].checked){from=document.olSidebarFeatureHistoryForm.from[i].value;}}
from=from||document.olSidebarFeatureHistoryForm.from.value;view.application.loadFeatureDiff(view.feature,from,to);return false;});if(this.scrollPosition){this.sidebar.scrollTo(this.scrollPosition);}},CLASS_NAME:"Vespucci.SidebarView.FeatureHistoryView"});Vespucci.SidebarView.HelpView=OpenLayers.Class(Vespucci.SidebarView,{processContent:function(){this.content=this.application.templates.sidebarHelpTemplate.process();},CLASS_NAME:"Vespucci.SidebarView.HelpView"});Vespucci.SidebarView.RequestView=OpenLayers.Class(Vespucci.SidebarView,{request:null,response:null,load:function(){var view=this;var onSuccess=function(response){view.response=response;Vespucci.SidebarView.prototype.load.apply(view,[]);}
this.request.send(onSuccess);}});Vespucci.LoginHandler.LivableStreets=OpenLayers.Class(Vespucci.LoginHandler.OpenPlans,{OPENPLANS_URI:"http://www.livablestreets.com",OPENPLANS_DOMAIN:".livablestreets.com",CLASS_NAME:"Vespucci.LoginHandler.LivableStreets"});Vespucci.PopupBase.AnchoredBubble=OpenLayers.Class(Vespucci.PopupBase.Anchored,{relativePosition:OpenLayers.Position.BOTTOM_RIGHT,CONTENT_PADDING:15,PADDING_BOTTOM:78,SHADOW_SIZE:15,IMAGE_CSS_CLASS:"olBubblePopup frameImage",MARKER_OFFSET:new OpenLayers.Pixel(55,13),images:{TL:null,TM:null,TR:null,ML:null,MR:null,BL:null,BM:null,BR:null},imagesSrcs:{TL:"corners/topl.png",TM:"corners/topm.png",TR:"corners/topr.png",ML:"corners/midl.png",MR:"corners/midr.png",BL:"corners/botl.png",BM:"corners/botm.png",BR:"corners/botr.png"},imageIds:{TL:"top-left",TM:"top-middle",TR:"top-right",ML:"middle-left",MR:"middle-right",BL:"bottom-left",BM:"bottom-middle",BR:"bottom-right"},frameDiv:null,contentDiv:null,initialize:function(id,lonlat,size,contentHTML,anchor,closeButton){Vespucci.PopupBase.Anchored.prototype.initialize.apply(this,arguments);this.convertFrameImages();this.frameDiv=OpenLayers.Util.createDiv(this.id+"Frame",null,this.size,null,"static",null);this.frameDiv.className="olBubbleFrame";this.frameDiv.style.display="block";this.frameDiv.style.position="absolute";this.frameDiv.style.left="-9999px";this.frameDiv.style.top="0px";this.contentDiv=this.div;var parentNode=this.div.parentNode;this.frameDiv.appendChild(this.div);if(parentNode){parentNode.appendChild(this.frameDiv);}
this.div=this.frameDiv;this.appendImagesToFrame();this.contentDiv.style.left=this.CONTENT_PADDING+"px";this.contentDiv.style.top=this.CONTENT_PADDING+"px";this.contentDiv.style.position="relative";},destroy:function(){Vespucci.PopupBase.Anchored.prototype.destroy.apply(this,arguments);this.frameDiv=null;this.contentDiv=null;this.images=null;this.imageIds=null;},convertFrameImages:function(){for(var name in this.images){var src=this.imagesSrcs[name];this.images[name]=OpenLayers.Util.createAlphaImageDiv(this.imageIds[name],null,null,OpenLayers.ImgPath+src,null,null,null,null,false);var image=this.images[name].childNodes[0];image.className=this.IMAGE_CSS_CLASS;}},appendImagesToFrame:function(){this.frameDiv.insertBefore(this.images.TL,this.contentDiv);this.frameDiv.insertBefore(this.images.TM,this.contentDiv);this.frameDiv.insertBefore(this.images.TR,this.contentDiv);this.frameDiv.insertBefore(this.images.ML,this.contentDiv);this.frameDiv.insertBefore(this.images.MR,this.contentDiv);this.frameDiv.insertBefore(this.images.BL,this.contentDiv);this.frameDiv.insertBefore(this.images.BM,this.contentDiv);this.frameDiv.insertBefore(this.images.BR,this.contentDiv);},adjustContentSize:function(){this.contentDiv.style.width=(this.size.w-this.totalHorizontalPadding())+"px";this.contentDiv.style.height=(this.size.h-this.totalVerticalPadding())+"px";},adjustVariableSizedDivDimensionsForIE:function(){var middleHeight=(this.size.h-parseInt(this.images.BR.style.height)-parseInt(this.images.TL.style.height));this.setDivDimensions(this.images.ML,null,middleHeight);this.setDivDimensions(this.images.MR,null,middleHeight);var topMiddleWidth=(this.size.w-parseInt(this.images.TL.style.width)-parseInt(this.images.TR.style.width));var bottomMiddleWidth=(this.size.w-parseInt(this.images.BL.style.width)-parseInt(this.images.BR.style.width));this.setDivDimensions(this.images.TM,topMiddleWidth,null);this.setDivDimensions(this.images.BM,bottomMiddleWidth,null);},setFixedSizedDivDimensionsForIE:function(){var fixedSizedDivs=[this.images.TL,this.images.TR,this.images.BL,this.images.BR];for(var index=0;index<fixedSizedDivs.length;index++){var div=fixedSizedDivs[index];var bounds=OpenLayers.Util.getDOMElementBounds(div);this.setDivDimensions(div,bounds.width,bounds.height);}},setDivDimensions:function(div,width,height){var image=div.childNodes[0];if(width){div.style.width=width+"px";image.style.width=width+"px";}
if(height){div.style.height=height+"px";image.style.height=height+"px";}},stringify:function(value){return(typeof value=="string")?value:value+"px";},totalHorizontalPadding:function(){return(2*this.CONTENT_PADDING)+this.SHADOW_SIZE;},totalVerticalPadding:function(){return this.PADDING_BOTTOM;},setSize:function(size,ignoreMapBounds){Vespucci.PopupBase.Anchored.prototype.setSize.apply(this,arguments);if(OpenLayers.Util.getBrowserName()=="msie"){this.setFixedSizedDivDimensionsForIE();this.adjustVariableSizedDivDimensionsForIE();}
this.adjustContentSize();},getPackedSize:function(){var contentSize=OpenLayers.Util.getDOMElementPackedSize(this.contentDiv);contentSize.w+=this.totalHorizontalPadding();contentSize.h+=this.totalVerticalPadding();return contentSize;},calculateRelativePosition:function(px,size){px.x+=this.MARKER_OFFSET.x;px.y+=this.MARKER_OFFSET.y;return Vespucci.PopupBase.Anchored.prototype.calculateRelativePosition.apply(this,arguments);},CLASS_NAME:"Vespucci.PopupBase.AnchoredBubble"});Vespucci.Request.GetCommentsRequest=OpenLayers.Class(Vespucci.Request.FeatureRequest,{feature:null,type:"comments",initialize:function(application,feature){this.feature=feature;Vespucci.Request.FeatureRequest.prototype.initialize.apply(this,[application]);},createPostData:function(){var gid=this.feature.getGID();var options=this.application.getWFSParams();if(this.type){options.featureType=this.type;}
var filter=new OpenLayers.Filter.Comparison({type:"==",property:"notes_gid",value:gid+""});var format=new OpenLayers.Format.WFSV(options);return OpenLayers.Format.XML.prototype.write.apply(format,[format.writeNode("wfsv:GetVersionedFeature",{filter:filter})]);},CLASS_NAME:"Vespucci.Request.GetCommentsRequest"});Vespucci.Request.GetFeatureRequest=OpenLayers.Class(Vespucci.Request.FeatureRequest,{typename:null,fid:null,initialize:function(application,type,fid){this.typename=application.configuration.namespace+":"+type;this.fid=fid;Vespucci.Request.prototype.initialize.apply(this,[application]);},send:function(onSuccess,onFailure,onCancel){var newSuccess=function(features){onSuccess(features[0]);}
Vespucci.Request.FeatureRequest.prototype.send.apply(this,[newSuccess,onFailure,onCancel]);},createPostData:function(){var xml=new OpenLayers.Format.XML();var getFeature=this.createWFSVNamespace(xml,"wfsv:GetVersionedFeature");var query=xml.createElementNS(this.application.configuration.wfsvns,"wfsv:Query");query.setAttribute("typeName",this.typename);query.setAttribute("srsName",this.application.configuration.projection);var filter=xml.createElementNS(this.application.configuration.ogcns,"ogc:Filter");var featureId=xml.createElementNS(this.application.configuration.ogcns,"ogc:FeatureId");featureId.setAttribute("fid",this.fid);filter.appendChild(featureId);query.appendChild(filter);getFeature.appendChild(query);return xml.write(getFeature);},CLASS_NAME:"Vespucci.Request.GetFeatureRequest"});Vespucci.Request.HistoryFeedRequest=OpenLayers.Class(Vespucci.Request.FeatureRequest,{types:["topp:notes","topp:comments"],createPostData:function(){var xml=new OpenLayers.Format.XML();var getFeature=this.createWFSVNamespace(xml,"wfsv:GetVersionedFeature");for(var i=0;i<this.types.length;i++){var query=xml.createElementNS(this.application.configuration.wfsns,"wfs:Query");query.setAttribute("typeName",this.types[i]);query.setAttribute("srsName",this.application.configuration.projection);getFeature.appendChild(query);}
return xml.write(getFeature);},CLASS_NAME:"Vespucci.Request.HistoryFeedRequest"});Vespucci.SidebarView.CommentsView=OpenLayers.Class(Vespucci.SidebarView.RequestView,{feature:null,comments:null,initialize:function(application,feature,scrollPosition){this.feature=feature;this.scrollPosition=scrollPosition;this.request=new Vespucci.Request.GetCommentsRequest(application,feature);Vespucci.SidebarView.RequestView.prototype.initialize.apply(this,[application]);},processContent:function(){var comments=this.response;this.content=this.application.templates.sidebarCommentsTemplate.process({comments:comments,feature:this.feature,description:this.feature.attributes.content||"",configuration:this.application.configuration},true);},addBehaviors:function(){var view=this;Vespucci.Util.setOnclick("olSidebarCommentsAddCommentLink",function(){var title=" ";var text=document.getElementById("olSidebarCommentsTextarea").value;var note_gid=view.feature.getGID();var comment=new Vespucci.Feature.Comment();comment.setTitle(title);comment.setText(text);comment.setNoteGID(note_gid);var onAdd=function(){view.scrollPosition=Vespucci.ScrollPosition.BOTTOM;view.reload();}
var addRequest=new Vespucci.Request.AddCommentRequest(view.application,view.feature,comment);addRequest.send(onAdd);return false;})
Vespucci.Util.setOnclick("olSidebarCommentsCancelLink",function(){view.sidebar.hide();})
if(this.scrollPosition){this.sidebar.scrollTo(this.scrollPosition);}},CLASS_NAME:"Vespucci.SidebarView.CommentsView"});Vespucci.SidebarView.HistoryFeedView=OpenLayers.Class(Vespucci.SidebarView.RequestView,{features:null,initialize:function(application){this.request=new Vespucci.Request.HistoryFeedRequest(application);Vespucci.SidebarView.RequestView.prototype.initialize.apply(this,[application]);},processContent:function(){this.features=this.response;var sortBy=function(a,b){if(a.getCreationDate()>b.getCreationDate()){return-1;}else if(a.getCreationDate()<b.getCreationDate()){return 1;}else{return 0;}}
this.features.sort(sortBy);this.content=this.application.templates.sidebarHistoryFeedTemplate.process({features:this.features,configuration:this.application.configuration});},addBehaviors:function(){var view=this;var generateOnClick=function(feature){return function(){feature.selected(view.application);};};for(var i=0;i<this.features.length;i++){Vespucci.Util.setOnclick("olSidebarHistoryFeedItem:"+this.features[i].getFID(),generateOnClick(this.features[i]));}},CLASS_NAME:"Vespucci.SidebarView.HistoryFeedView"});Vespucci.SidebarView.HistoryView=OpenLayers.Class(Vespucci.SidebarView,{initialize:function(application){Vespucci.SidebarView.prototype.initialize.apply(this,[application]);},load:function(){var view=this;var onSuccess=function(response){view.response=response;Vespucci.SidebarView.prototype.load.apply(view,[]);}
var options={callback:onSuccess};this.application.wfsLayer.protocol.getLog(options);},processContent:function(){this.content=this.application.templates.sidebarHistoryTemplate.process({revisions:this.response.features,prettyDate:Vespucci.Util.prettyDate},true);},CLASS_NAME:"Vespucci.SidebarView.HistoryView"});Vespucci.LoginHandler.LivableStreets.Stage=OpenLayers.Class(Vespucci.LoginHandler.LivableStreets,{OPENPLANS_URI:"http://design.livablestreets.com",CLASS_NAME:"Vespucci.LoginHandler.LivableStreets.Stage"});Vespucci.Popup=OpenLayers.Class(Vespucci.PopupBase.AnchoredBubble,{application:null,popupDivId:"chicken",panMapIfOutOfView:true,popupSize:null,initialize:function(application,location,content,anchor){this.application=application;Vespucci.PopupBase.AnchoredBubble.prototype.initialize.apply(this,[this.popupDivId,location,this.popupSize,content,anchor,this.closeButton]);},onLoad:function(){},close:function(){this.hide();},onCloseButton:function(){this.close();},onClose:function(){this.destroy();this.application.enableZoomWheel();},onmouseover:function(evt){this.application.disableZoomWheel();Vespucci.PopupBase.AnchoredBubble.prototype.onmouseover.apply(this,arguments);},onmouseout:function(evt){this.application.enableZoomWheel();Vespucci.PopupBase.AnchoredBubble.prototype.onmouseout.apply(this,arguments);},CLASS_NAME:"Vespucci.Popup"});Vespucci.Popup.FeaturePopup=OpenLayers.Class(Vespucci.Popup,{feature:null,initialize:function(application,feature,content){this.feature=feature;this.feature.popup=this;Vespucci.Popup.prototype.initialize.apply(this,[application,feature.getLocation(),content,null]);},destroy:function(){Vespucci.Popup.prototype.destroy.apply(this,[]);this.feature.popup=null;this.application.unselectFeature(this.feature);},calculateRelativePosition:function(px,size){var style=this.feature.layer.styleMap.createSymbolizer(this.feature);px.x+=(style.graphicXOffset||0)/2;px.y+=(style.graphicYOffset||0)/2;return Vespucci.Popup.prototype.calculateRelativePosition.apply(this,arguments);},onCloseButton:function(){this.application.contextualShowHome();Vespucci.Popup.prototype.onCloseButton.apply(this,arguments);},CLASS_NAME:"Vespucci.Popup.FeaturePopup"});Vespucci.Popup.EditPopup=OpenLayers.Class(Vespucci.Popup.FeaturePopup,{feature:null,inserting:false,saved:false,oldAttributes:{},initialize:function(application,feature){if(feature.state==OpenLayers.State.INSERT){this.inserting=true;}
for(var name in feature.attributes){this.oldAttributes[name]=feature.attributes[name];}
data={feature:feature,subtypes:application.configuration.subtypes[feature.type]}
var content=application.templates.notesPopupEditTemplate.process(data,true);Vespucci.Popup.FeaturePopup.prototype.initialize.apply(this,[application,feature,content]);},onLoad:function(){Vespucci.Popup.prototype.onLoad.apply(this,[]);var iconList=document.getElementById("olPopupIconList");var anchors=iconList.getElementsByTagName("A");var subtype;for(var i=0;i<anchors.length;i++){var anchor=anchors[i];this.setIconOnclick(anchor,i,this.feature,this.application.configuration);}
popup=this;Vespucci.Util.setOnclick("olPopupViewFeatureMoveButton",function(){popup.close();popup.feature.moveThis(popup.application);return false;})
Vespucci.Util.setOnclick("olPopupViewFeatureDeleteButton",function(){var confirmation=confirm("Are you sure you want to delete this note?");if(confirmation){var successfulDelete=function(){popup.close();var view=new Vespucci.SidebarView.HelpView(popup.application);popup.application.loadView(view);}
popup.application.deleteFeature(popup.feature,successfulDelete);}
return false;});Vespucci.Util.setOnclick("olPopupEditFeatureCancelButton",function(){popup.revertAttributes();popup.application.contextualShowHome();Vespucci.Popup.prototype.close.apply(popup,[]);});Vespucci.Util.setOnclick("olPopupEditFeatureOKButton",function(){popup.saved=true;var title=(document.getElementById("olPopupEditFeatureTitleText")).value;var content=document.getElementById("olPopupEditFeatureDescriptionTextarea").value;popup.feature.setTitle(title);popup.feature.setContent(content);var successfulRequest=function(){popup.close();popup.feature.selected(popup.application);}
var successfulInsert=function(feature){popup.feature=feature;successfulRequest();}
var onFailure=function(){popup.saved=false;}
if(popup.inserting==true){popup.application.insertFeature(popup.feature,successfulInsert,onFailure);}else{popup.application.updateFeature(popup.feature,successfulRequest,onFailure);}});},setIconOnclick:function(anchor,typeid,feature,configuration){var popup=this;var subtype=configuration.subtypes[feature.type][typeid];anchor.onclick=function(){feature.setSubtype(subtype);return false;}},revertAttributes:function(){this.feature.setAttributes(this.oldAttributes);this.feature.resetLocation();},onClose:function(){Vespucci.Popup.prototype.onClose.apply(this,[]);if(this.saved==false){this.revertAttributes();}
if(this.feature.state==OpenLayers.State.INSERT){this.application.removeFeatures([this.feature]);}},CLASS_NAME:"Vespucci.Popup.EditPopup"});Vespucci.Popup.MovePopup=OpenLayers.Class(Vespucci.Popup.FeaturePopup,{feature:null,from:null,saved:false,closeButton:false,initialize:function(application,feature,from){var content=application.templates.notesPopupMoveTemplate.process({feature:feature},true);Vespucci.Popup.FeaturePopup.prototype.initialize.apply(this,[application,feature,content]);this.from=from;},onLoad:function(){Vespucci.Popup.prototype.onLoad.apply(this,[]);popup=this;Vespucci.Util.setOnclick("olPopupMoveFeatureDoneButton",function(){var oldState=popup.feature.state;var successfulMove=function(){popup.saved=true;popup.close();}
var revertState=function(){popup.feature.state=oldState;}
popup.application.saveFeature(popup.feature,successfulMove,revertState);});Vespucci.Util.setOnclick("olPopupMoveFeatureCancelButton",function(){popup.close();});},revertLocation:function(){this.feature.move(this.from);},onClose:function(){if(this.saved==false){this.revertLocation();}},CLASS_NAME:"Vespucci.Popup.MovePopup"});Vespucci.Popup.PermalinkPopup=OpenLayers.Class(Vespucci.Popup.FeaturePopup,{feature:null,saved:false,initialize:function(application,feature){var content=application.templates.notesPopupPermalinkTemplate.process({feature:feature,link:application.getPermalink(feature)},true);Vespucci.Popup.FeaturePopup.prototype.initialize.apply(this,[application,feature,content]);},onLoad:function(){Vespucci.Popup.prototype.onLoad.apply(this,[]);},CLASS_NAME:"Vespucci.Popup.MovePopup"});Vespucci.Popup.ViewPopup=OpenLayers.Class(Vespucci.Popup.FeaturePopup,{WAITING_IMAGE:Vespucci.ImgPath+"large-spinner.gif",feature:null,initialize:function(application,feature){var content=application.templates.notesPopupViewTemplate.process({feature:feature,isEditing:application.isEditing},true);var images=content.getElementsByTagName("IMG");var preloaded=[];var popup=this;for(var index=0;index<images.length;index++){preloaded[index]=new Image();preloaded[index].oldImage=images[index];preloaded[index].index=index;var imageLoaded=function(){var loaded=preloaded[this.index];var oldImage=loaded.oldImage;var oldImageReverted=function(){popup.pack();}
oldImage.onload=oldImageReverted;oldImage.onerror=oldImageReverted;oldImage.src=loaded.src;}
OpenLayers.Function.bind(imageLoaded,preloaded[index]);preloaded[index].onload=imageLoaded;preloaded[index].onerror=imageLoaded;if(images[index].complete||(images[index].width!=0&&images[index].height!=0))continue;var oldSrc=images[index].src;images[index].src=this.WAITING_IMAGE;preloaded[index].src=oldSrc;}
Vespucci.Popup.FeaturePopup.prototype.initialize.apply(this,[application,feature,content]);},onLoad:function(){Vespucci.Popup.prototype.onLoad.apply(this,[]);if(this.application.isEditing){popup=this;Vespucci.Util.setOnclick("olPopupViewFeatureEditButton",function(){popup.close();popup.feature.edit(popup.application);return false;});Vespucci.Util.setOnclick("olPopupViewNotesCommentsLink",function(){popup.application.loadCommentsInSidebar(popup.feature,Vespucci.ScrollPosition.TOP);popup.application.showSidebar();return false;});Vespucci.Util.setOnclick("olPopupViewNotesHistoryLink",function(){popup.application.loadFeatureHistoryInSidebar(popup.feature,Vespucci.ScrollPosition.TOP);popup.application.showSidebar();return false;});Vespucci.Util.setOnclick("olPopupViewNotesPermalinkLink",function(){popup.close();popup.application.addPopup(new Vespucci.Popup.PermalinkPopup(popup.application,popup.feature));return false;});}},CLASS_NAME:"Vespucci.Popup.ViewPopup"});Vespucci.Configuration=OpenLayers.Class({initialize:function(){},startInViewMode:true,proxy:"",wfsvUrl:"http://www.example.com:8080/geoserver/ows",wmsUrl:"http://www.example.com:8081/geoserver/wms",wfsns:"http://www.opengis.net/wfs",wfsvns:"http://www.opengis.net/wfsv",ogcns:"http://www.opengis.net/ogc",toppns:"http://www.openplans.org/topp",wmsOptions:{layers:"layer",bgcolor:'0xECECC6',format:'image/png8'},wfsLayerTypes:[],featureClasses:{},featureDefaults:{},featureStyles:{},addControls:{},moveControls:{},namespaceUri:"",namespace:"",wmsLayerName:"WMS",wfsLayerName:"WFS",projection:"EPSG:900913",maxExtent:new OpenLayers.Bounds(-180,-90,180,90),restrictExtent:true,maxResolution:1.40625,overviewResolutions:[1],defaultZoomLevel:null,numZoomLevels:10,margins:new OpenLayers.Bounds(0,0,0,0),mapDivId:"map",templateFile:Vespucci._getScriptLocation()+"Vespucci/Templates/all-templates.html",icons:[Vespucci.ImgPath+"marker.png",Vespucci.ImgPath+"marker-blue.png",Vespucci.ImgPath+"marker-gold.png",Vespucci.ImgPath+"marker-green.png"],subtypes:{"exampleType":[{name:"Subtype Name",attributes:{someAttribute:"An attribute value"},style:{externalGraphic:"pictureURL.png"}},{name:"Another subtype",attributes:{someAttribute:"A different attribute value"},style:{externalGraphic:"someOtherPictureURL.png"}}]},imageReloadAttempts:3,sidebarDomEltId:null,popupMargins:new OpenLayers.Bounds(0,0,0,0),dragPixelTolerance:5,dragTimeTolerance:400,mainVespucciCSSClass:"Vespucci",templateContainerCSSClass:"VespucciTemplateContainer",topbarContainerCSSClass:"VespucciTopbar",topbarBackgroundCSSClass:"background",topbarTextCSSClass:"text",topbarPanelCSSClass:"panel",loginHandlerClass:Vespucci.LoginHandler.OpenPlans,peopleUrlPrefix:"http://www.example.org/people/",peopleUrlSuffix:"/profile",notRegisteredUrl:"http://www.example.org/join",forgotCredentialsUrl:"http://www.example.org/forgot",CLASS_NAME:"Vespucci.Configuration"});