/*

  OpenLayers.js -- OpenLayers Map Viewer Library

  Copyright 2005-2008 MetaCarta, Inc., released under the Clear BSD license.
  Please see http://svn.openlayers.org/trunk/openlayers/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. 
*
**/

/**
 * Contains XMLHttpRequest.js <http://code.google.com/p/xmlhttprequest/>
 * Copyright 2007 Sergey Ilinsky (http://www.ilinsky.com)
 *
 * 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
 */

/**
 * Contains portions of Gears <http://code.google.com/apis/gears/>
 *
 * Copyright 2007, Google Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *  1. Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the documentation
 *     and/or other materials provided with the distribution.
 *  3. Neither the name of Google Inc. nor the names of its contributors may be
 *     used to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Sets up google.gears.*, which is *the only* supported way to access Gears.
 *
 * Circumvent this file at your own risk!
 *
 * In the future, Gears may automatically define google.gears.* without this
 * file. Gears may use these objects to transparently fix bugs and compatibility
 * issues. Applications that use the code below will continue to work seamlessly
 * when that happens.
 */
var OpenLayers={singleFile:true};(function(){var singleFile=(typeof OpenLayers=="object"&&OpenLayers.singleFile);window.OpenLayers={_scriptName:(!singleFile)?"lib/OpenLayers.js":"OpenLayers.js",_getScriptLocation:function(){var scriptLocation="";var isOL=new RegExp("(^|(.*?\\/))("+OpenLayers._scriptName+")(\\?|$)");var scripts=document.getElementsByTagName('script');for(var i=0,len=scripts.length;i<len;i++){var src=scripts[i].getAttribute('src');if(src){var match=src.match(isOL);if(match){scriptLocation=match[1];break;}}}
return scriptLocation;}};if(!singleFile){var jsfiles=new Array("OpenLayers/Util.js","OpenLayers/BaseTypes.js","OpenLayers/BaseTypes/Class.js","OpenLayers/BaseTypes/Bounds.js","OpenLayers/BaseTypes/Element.js","OpenLayers/BaseTypes/LonLat.js","OpenLayers/BaseTypes/Pixel.js","OpenLayers/BaseTypes/Size.js","OpenLayers/Console.js","OpenLayers/Tween.js","Rico/Corner.js","Rico/Color.js","OpenLayers/Ajax.js","OpenLayers/Events.js","OpenLayers/Request.js","OpenLayers/Request/XMLHttpRequest.js","OpenLayers/Projection.js","OpenLayers/Map.js","OpenLayers/Layer.js","OpenLayers/Icon.js","OpenLayers/Marker.js","OpenLayers/Marker/Box.js","OpenLayers/Marker/TemplateMarker.js","OpenLayers/Popup.js","OpenLayers/Tile.js","OpenLayers/Tile/Image.js","OpenLayers/Tile/WFS.js","OpenLayers/Layer/Image.js","OpenLayers/Layer/SphericalMercator.js","OpenLayers/Layer/EventPane.js","OpenLayers/Layer/FixedZoomLevels.js","OpenLayers/Layer/Google.js","OpenLayers/Layer/VirtualEarth.js","OpenLayers/Layer/Yahoo.js","OpenLayers/Layer/HTTPRequest.js","OpenLayers/Layer/Grid.js","OpenLayers/Layer/MapGuide.js","OpenLayers/Layer/MapServer.js","OpenLayers/Layer/MapServer/Untiled.js","OpenLayers/Layer/KaMap.js","OpenLayers/Layer/KaMapCache.js","OpenLayers/Layer/MultiMap.js","OpenLayers/Layer/Markers.js","OpenLayers/Layer/TemplateMarkers.js","OpenLayers/Layer/Text.js","OpenLayers/Layer/WorldWind.js","OpenLayers/Layer/ArcGIS93Rest.js","OpenLayers/Layer/WMS.js","OpenLayers/Layer/WMS/Untiled.js","OpenLayers/Layer/ArcIMS.js","OpenLayers/Layer/GeoRSS.js","OpenLayers/Layer/Boxes.js","OpenLayers/Layer/XYZ.js","OpenLayers/Layer/TMS.js","OpenLayers/Layer/TileCache.js","OpenLayers/Popup/Anchored.js","OpenLayers/Popup/AnchoredBubble.js","OpenLayers/Popup/Framed.js","OpenLayers/Popup/FramedCloud.js","OpenLayers/Feature.js","OpenLayers/Feature/Vector.js","OpenLayers/Feature/WFS.js","OpenLayers/Handler.js","OpenLayers/Handler/Click.js","OpenLayers/Handler/Hover.js","OpenLayers/Handler/Point.js","OpenLayers/Handler/Path.js","OpenLayers/Handler/Polygon.js","OpenLayers/Handler/Feature.js","OpenLayers/Handler/Drag.js","OpenLayers/Handler/RegularPolygon.js","OpenLayers/Handler/Box.js","OpenLayers/Handler/MouseWheel.js","OpenLayers/Handler/Keyboard.js","OpenLayers/Control.js","OpenLayers/Control/Attribution.js","OpenLayers/Control/Button.js","OpenLayers/Control/ZoomBox.js","OpenLayers/Control/ZoomToMaxExtent.js","OpenLayers/Control/DragPan.js","OpenLayers/Control/Navigation.js","OpenLayers/Control/MouseDefaults.js","OpenLayers/Control/MousePosition.js","OpenLayers/Control/OverviewMap.js","OpenLayers/Control/DGOverviewMap.js","OpenLayers/Control/PieOverviewMap.js","OpenLayers/Control/KeyboardDefaults.js","OpenLayers/Control/PanZoom.js","OpenLayers/Control/PanZoomBar.js","OpenLayers/Control/PanZoomBar2.js","OpenLayers/Control/ArgParser.js","OpenLayers/Control/Permalink.js","OpenLayers/Control/Scale.js","OpenLayers/Control/ScaleLine.js","OpenLayers/Control/Snapping.js","OpenLayers/Control/Split.js","OpenLayers/Control/LayerSwitcher.js","OpenLayers/Control/LayerSwitcher2.js","OpenLayers/Control/ImgLayerSwitcher.js","OpenLayers/Control/PieLayerSwitcher.js","OpenLayers/Control/DGLayerSwitcher.js","OpenLayers/Control/ImgNearest.js","OpenLayers/Control/PieNearest.js","OpenLayers/Control/DGSearch.js","OpenLayers/Control/MJSearch.js","OpenLayers/Control/Search.js","OpenLayers/Control/Routing.js","OpenLayers/Control/Feedback.js","OpenLayers/Control/Feedback2.js","OpenLayers/Control/MapFeedback.js","OpenLayers/Control/Pdf.js","OpenLayers/Control/AreaSelector.js","OpenLayers/Control/AirportPlans.js","OpenLayers/Control/CouncilRules.js","OpenLayers/Control/DrawFeature.js","OpenLayers/Control/DragFeature.js","OpenLayers/Control/ModifyFeature.js","OpenLayers/Control/Panel.js","OpenLayers/Control/SelectFeature.js","OpenLayers/Control/SelectTemplateFeature.js","OpenLayers/Control/SiteLocator.js","OpenLayers/Control/WalkingRoutes.js","OpenLayers/Control/NavigationHistory.js","OpenLayers/Control/Measure.js","OpenLayers/Control/WMSGetFeatureInfo.js","OpenLayers/Geometry.js","OpenLayers/Geometry/Rectangle.js","OpenLayers/Geometry/Collection.js","OpenLayers/Geometry/Point.js","OpenLayers/Geometry/MultiPoint.js","OpenLayers/Geometry/Curve.js","OpenLayers/Geometry/LineString.js","OpenLayers/Geometry/LinearRing.js","OpenLayers/Geometry/Polygon.js","OpenLayers/Geometry/MultiLineString.js","OpenLayers/Geometry/MultiPolygon.js","OpenLayers/Geometry/Surface.js","OpenLayers/Renderer.js","OpenLayers/Renderer/Elements.js","OpenLayers/Renderer/SVG.js","OpenLayers/Renderer/Canvas.js","OpenLayers/Renderer/VML.js","OpenLayers/Layer/Vector.js","OpenLayers/Layer/Vector/RootContainer.js","OpenLayers/Strategy.js","OpenLayers/Strategy/Fixed.js","OpenLayers/Strategy/Cluster.js","OpenLayers/Strategy/Paging.js","OpenLayers/Strategy/BBOX.js","OpenLayers/Strategy/Save.js","OpenLayers/Protocol.js","OpenLayers/Protocol/HTTP.js","OpenLayers/Protocol/SQL.js","OpenLayers/Protocol/SQL/Gears.js","OpenLayers/Protocol/WFS.js","OpenLayers/Protocol/WFS/v1.js","OpenLayers/Protocol/WFS/v1_0_0.js","OpenLayers/Protocol/WFS/v1_1_0.js","OpenLayers/Layer/PointTrack.js","OpenLayers/Layer/GML.js","OpenLayers/Style.js","OpenLayers/StyleMap.js","OpenLayers/Rule.js","OpenLayers/Filter.js","OpenLayers/Filter/FeatureId.js","OpenLayers/Filter/Logical.js","OpenLayers/Filter/Comparison.js","OpenLayers/Filter/Spatial.js","OpenLayers/Format.js","OpenLayers/Format/XML.js","OpenLayers/Format/ArcXML.js","OpenLayers/Format/ArcXML/Features.js","OpenLayers/Format/GML.js","OpenLayers/Format/GML/Base.js","OpenLayers/Format/GML/v2.js","OpenLayers/Format/GML/v3.js","OpenLayers/Format/KML.js","OpenLayers/Format/GeoRSS.js","OpenLayers/Format/WFS.js","OpenLayers/Format/WFSCapabilities.js","OpenLayers/Format/WFSCapabilities/v1.js","OpenLayers/Format/WFSCapabilities/v1_0_0.js","OpenLayers/Format/WFSCapabilities/v1_1_0.js","OpenLayers/Format/WFSDescribeFeatureType.js","OpenLayers/Format/WMSDescribeLayer.js","OpenLayers/Format/WMSDescribeLayer/v1_1.js","OpenLayers/Format/WKT.js","OpenLayers/Format/OSM.js","OpenLayers/Format/GPX.js","OpenLayers/Format/Filter.js","OpenLayers/Format/Filter/v1.js","OpenLayers/Format/Filter/v1_0_0.js","OpenLayers/Format/Filter/v1_1_0.js","OpenLayers/Format/SLD.js","OpenLayers/Format/SLD/v1.js","OpenLayers/Format/SLD/v1_0_0.js","OpenLayers/Format/SLD/v1.js","OpenLayers/Format/WFST.js","OpenLayers/Format/WFST/v1.js","OpenLayers/Format/WFST/v1_0_0.js","OpenLayers/Format/WFST/v1_1_0.js","OpenLayers/Format/Text.js","OpenLayers/Format/JSON.js","OpenLayers/Format/GeoJSON.js","OpenLayers/Format/WMC.js","OpenLayers/Format/WMC/v1.js","OpenLayers/Format/WMC/v1_0_0.js","OpenLayers/Format/WMC/v1_1_0.js","OpenLayers/Format/WMSCapabilities.js","OpenLayers/Format/WMSCapabilities/v1_1.js","OpenLayers/Format/WMSCapabilities/v1_1_0.js","OpenLayers/Format/WMSCapabilities/v1_1_1.js","OpenLayers/Format/WMSGetFeatureInfo.js","OpenLayers/Layer/WFS.js","OpenLayers/Control/GetFeature.js","OpenLayers/Control/MouseToolbar.js","OpenLayers/Control/NavToolbar.js","OpenLayers/Control/PanPanel.js","OpenLayers/Control/Pan.js","OpenLayers/Control/ZoomIn.js","OpenLayers/Control/ZoomOut.js","OpenLayers/Control/ZoomPanel.js","OpenLayers/Control/EditingToolbar.js","OpenLayers/Lang.js","OpenLayers/Lang/en.js","OpenLayers/Lang/cy.js");var agent=navigator.userAgent;var docWrite=(agent.match("MSIE")||agent.match("Safari"));if(docWrite){var allScriptTags=new Array(jsfiles.length);}
var host=OpenLayers._getScriptLocation()+"lib/";for(var i=0,len=jsfiles.length;i<len;i++){if(docWrite){allScriptTags[i]="<script src='"+host+jsfiles[i]+"'></script>";}else{var s=document.createElement("script");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(""));}}})();OpenLayers.VERSION_NUMBER="OpenLayers 2.8 -- $Revision: 9492 $";OpenLayers.String={startsWith:function(str,sub){return(str.indexOf(sub)==0);},contains:function(str,sub){return(str.indexOf(sub)!=-1);},trim:function(str){return str.replace(/^\s\s*/,'').replace(/\s\s*$/,'');},camelize:function(str){var oStringList=str.split('-');var camelizedString=oStringList[0];for(var i=1,len=oStringList.length;i<len;i++){var s=oStringList[i];camelizedString+=s.charAt(0).toUpperCase()+s.substring(1);}
return camelizedString;},format:function(template,context,args){if(!context){context=window;}
var replacer=function(str,match){var replacement;var subs=match.split(/\.+/);for(var i=0;i<subs.length;i++){if(i==0){replacement=context;}
replacement=replacement[subs[i]];}
if(typeof replacement=="function"){replacement=args?replacement.apply(null,args):replacement();}
if(typeof replacement=='undefined'){return'undefined';}else{return replacement;}};return template.replace(OpenLayers.String.tokenRegEx,replacer);},tokenRegEx:/\$\{([\w.]+?)\}/g,numberRegEx:/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/,isNumeric:function(value){return OpenLayers.String.numberRegEx.test(value);},numericIf:function(value){return OpenLayers.String.isNumeric(value)?parseFloat(value):value;}};if(!String.prototype.startsWith){String.prototype.startsWith=function(sStart){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'OpenLayers.String.startsWith'}));return OpenLayers.String.startsWith(this,sStart);};}
if(!String.prototype.contains){String.prototype.contains=function(str){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'OpenLayers.String.contains'}));return OpenLayers.String.contains(this,str);};}
if(!String.prototype.trim){String.prototype.trim=function(){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'OpenLayers.String.trim'}));return OpenLayers.String.trim(this);};}
if(!String.prototype.camelize){String.prototype.camelize=function(){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'OpenLayers.String.camelize'}));return OpenLayers.String.camelize(this);};}
OpenLayers.Number={decimalSeparator:".",thousandsSeparator:",",limitSigDigs:function(num,sig){var fig=0;if(sig>0){fig=parseFloat(num.toPrecision(sig));}
return fig;},format:function(num,dec,tsep,dsep){dec=(typeof dec!="undefined")?dec:0;tsep=(typeof tsep!="undefined")?tsep:OpenLayers.Number.thousandsSeparator;dsep=(typeof dsep!="undefined")?dsep:OpenLayers.Number.decimalSeparator;if(dec!=null){num=parseFloat(num.toFixed(dec));}
var parts=num.toString().split(".");if(parts.length==1&&dec==null){dec=0;}
var integer=parts[0];if(tsep){var thousands=/(-?[0-9]+)([0-9]{3})/;while(thousands.test(integer)){integer=integer.replace(thousands,"$1"+tsep+"$2");}}
var str;if(dec==0){str=integer;}else{var rem=parts.length>1?parts[1]:"0";if(dec!=null){rem=rem+new Array(dec-rem.length+1).join("0");}
str=integer+dsep+rem;}
return str;}};if(!Number.prototype.limitSigDigs){Number.prototype.limitSigDigs=function(sig){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'OpenLayers.Number.limitSigDigs'}));return OpenLayers.Number.limitSigDigs(this,sig);};}
OpenLayers.Function={bind:function(func,object){var args=Array.prototype.slice.apply(arguments,[2]);return function(){var newArgs=args.concat(Array.prototype.slice.apply(arguments,[0]));return func.apply(object,newArgs);};},bindAsEventListener:function(func,object){return function(event){return func.call(object,event||window.event);};}};if(!Function.prototype.bind){Function.prototype.bind=function(){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'OpenLayers.Function.bind'}));Array.prototype.unshift.apply(arguments,[this]);return OpenLayers.Function.bind.apply(null,arguments);};}
if(!Function.prototype.bindAsEventListener){Function.prototype.bindAsEventListener=function(object){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'OpenLayers.Function.bindAsEventListener'}));return OpenLayers.Function.bindAsEventListener(this,object);};}
OpenLayers.Array={filter:function(array,callback,caller){var selected=[];if(Array.prototype.filter){selected=array.filter(callback,caller);}else{var len=array.length;if(typeof callback!="function"){throw new TypeError();}
for(var i=0;i<len;i++){if(i in array){var val=array[i];if(callback.call(caller,val,i,array)){selected.push(val);}}}}
return selected;}};OpenLayers.Class=function(){var Class=function(){if(arguments&&arguments[0]!=OpenLayers.Class.isPrototype){this.initialize.apply(this,arguments);}};var extended={};var parent,initialize;for(var i=0,len=arguments.length;i<len;++i){if(typeof arguments[i]=="function"){if(i==0&&len>1){initialize=arguments[i].prototype.initialize;arguments[i].prototype.initialize=function(){};extended=new arguments[i];if(initialize===undefined){delete arguments[i].prototype.initialize;}else{arguments[i].prototype.initialize=initialize;}}
parent=arguments[i].prototype;}else{parent=arguments[i];}
OpenLayers.Util.extend(extended,parent);}
Class.prototype=extended;return Class;};OpenLayers.Class.isPrototype=function(){};OpenLayers.Class.create=function(){return function(){if(arguments&&arguments[0]!=OpenLayers.Class.isPrototype){this.initialize.apply(this,arguments);}};};OpenLayers.Class.inherit=function(){var superClass=arguments[0];var proto=new superClass(OpenLayers.Class.isPrototype);for(var i=1,len=arguments.length;i<len;i++){if(typeof arguments[i]=="function"){var mixin=arguments[i];arguments[i]=new mixin(OpenLayers.Class.isPrototype);}
OpenLayers.Util.extend(proto,arguments[i]);}
return proto;};OpenLayers.Util={};OpenLayers.Util.getElement=function(){var elements=[];for(var i=0,len=arguments.length;i<len;i++){var element=arguments[i];if(typeof element=='string'){element=document.getElementById(element);}
if(arguments.length==1){return element;}
elements.push(element);}
return elements;};OpenLayers.Util.isElement=function(o){return!!(o&&o.nodeType===1);};if(typeof window.$==="undefined"){window.$=OpenLayers.Util.getElement;}
OpenLayers.Util.extend=function(destination,source){destination=destination||{};if(source){for(var property in source){var value=source[property];if(value!==undefined){destination[property]=value;}}
var sourceIsEvt=typeof window.Event=="function"&&source instanceof window.Event;if(!sourceIsEvt&&source.hasOwnProperty&&source.hasOwnProperty('toString')){destination.toString=source.toString;}}
return destination;};OpenLayers.Util.removeItem=function(array,item){for(var i=array.length-1;i>=0;i--){if(array[i]==item){array.splice(i,1);}}
return array;};OpenLayers.Util.clearArray=function(array){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'array = []'}));array.length=0;};OpenLayers.Util.indexOf=function(array,obj){if(typeof array.indexOf=="function"){return array.indexOf(obj);}else{for(var i=0,len=array.length;i<len;i++){if(array[i]==obj){return i;}}
return-1;}};OpenLayers.Util.modifyDOMElement=function(element,id,px,sz,position,border,overflow,opacity){if(id){element.id=id;}
if(px){element.style.left=px.x+"px";element.style.top=px.y+"px";}
if(sz){element.style.width=sz.w+"px";element.style.height=sz.h+"px";}
if(position){element.style.position=position;}
if(border){element.style.border=border;}
if(overflow){element.style.overflow=overflow;}
if(parseFloat(opacity)>=0.0&&parseFloat(opacity)<1.0){element.style.filter='alpha(opacity='+(opacity*100)+')';element.style.opacity=opacity;}else if(parseFloat(opacity)==1.0){element.style.filter='';element.style.opacity='';}};OpenLayers.Util.createDiv=function(id,px,sz,imgURL,position,border,overflow,opacity){var dom=document.createElement('div');if(imgURL){dom.style.backgroundImage='url('+imgURL+')';}
if(!id){id=OpenLayers.Util.createUniqueID("OpenLayersDiv");}
if(!position){position="absolute";}
OpenLayers.Util.modifyDOMElement(dom,id,px,sz,position,border,overflow,opacity);return dom;};OpenLayers.Util.createImage=function(id,px,sz,imgURL,position,border,opacity,delayDisplay){var image=document.createElement("img");if(!id){id=OpenLayers.Util.createUniqueID("OpenLayersDiv");}
if(!position){position="relative";}
OpenLayers.Util.modifyDOMElement(image,id,px,sz,position,border,null,opacity);if(delayDisplay){image.style.display="none";OpenLayers.Event.observe(image,"load",OpenLayers.Function.bind(OpenLayers.Util.onImageLoad,image));OpenLayers.Event.observe(image,"error",OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError,image));}
image.style.alt=id;image.galleryImg="no";if(imgURL){image.src=imgURL;}
return image;};OpenLayers.Util.setOpacity=function(element,opacity){OpenLayers.Util.modifyDOMElement(element,null,null,null,null,null,null,opacity);};OpenLayers.Util.onImageLoad=function(){if(!this.viewRequestID||(this.map&&this.viewRequestID==this.map.viewRequestID)){this.style.display="";}
OpenLayers.Element.removeClass(this,"olImageLoadError");};OpenLayers.IMAGE_RELOAD_ATTEMPTS=0;OpenLayers.Util.onImageLoadError=function(){this._attempts=(this._attempts)?(this._attempts+1):1;if(this._attempts<=OpenLayers.IMAGE_RELOAD_ATTEMPTS){var urls=this.urls;if(urls&&urls instanceof Array&&urls.length>1){var src=this.src.toString();var current_url,k;for(k=0;current_url=urls[k];k++){if(src.indexOf(current_url)!=-1){break;}}
var guess=Math.floor(urls.length*Math.random());var new_url=urls[guess];k=0;while(new_url==current_url&&k++<4){guess=Math.floor(urls.length*Math.random());new_url=urls[guess];}
this.src=src.replace(current_url,new_url);}else{this.src=this.src;}}else{OpenLayers.Element.addClass(this,"olImageLoadError");}
this.style.display="";};OpenLayers.Util.alphaHackNeeded=null;OpenLayers.Util.alphaHack=function(){if(OpenLayers.Util.alphaHackNeeded==null){var arVersion=navigator.appVersion.split("MSIE");var version=parseFloat(arVersion[1]);var filter=false;try{filter=!!(document.body.filters);}catch(e){}
OpenLayers.Util.alphaHackNeeded=(filter&&(version>=5.5)&&(version<7));}
return OpenLayers.Util.alphaHackNeeded;};OpenLayers.Util.modifyAlphaImageDiv=function(div,id,px,sz,imgURL,position,border,sizing,opacity){OpenLayers.Util.modifyDOMElement(div,id,px,sz,position,null,null,opacity);var img=div.childNodes[0];if(imgURL){img.src=imgURL;}
OpenLayers.Util.modifyDOMElement(img,div.id+"_innerImage",null,sz,"relative",border);if(OpenLayers.Util.alphaHack()){if(div.style.display!="none"){div.style.display="inline-block";}
if(sizing==null){sizing="scale";}
div.style.filter="progid:DXImageTransform.Microsoft"+".AlphaImageLoader(src='"+img.src+"', "+"sizingMethod='"+sizing+"')";if(parseFloat(div.style.opacity)>=0.0&&parseFloat(div.style.opacity)<1.0){div.style.filter+=" alpha(opacity="+div.style.opacity*100+")";}
img.style.filter="alpha(opacity=0)";}};OpenLayers.Util.createAlphaImageDiv=function(id,px,sz,imgURL,position,border,sizing,opacity,delayDisplay){var div=OpenLayers.Util.createDiv();var img=OpenLayers.Util.createImage(null,null,null,null,null,null,null,false);div.appendChild(img);if(delayDisplay){img.style.display="none";OpenLayers.Event.observe(img,"load",OpenLayers.Function.bind(OpenLayers.Util.onImageLoad,div));OpenLayers.Event.observe(img,"error",OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError,div));}
OpenLayers.Util.modifyAlphaImageDiv(div,id,px,sz,imgURL,position,border,sizing,opacity);return div;};OpenLayers.Util.upperCaseObject=function(object){var uObject={};for(var key in object){uObject[key.toUpperCase()]=object[key];}
return uObject;};OpenLayers.Util.applyDefaults=function(to,from){to=to||{};var fromIsEvt=typeof window.Event=="function"&&from instanceof window.Event;for(var key in from){if(to[key]===undefined||(!fromIsEvt&&from.hasOwnProperty&&from.hasOwnProperty(key)&&!to.hasOwnProperty(key))){to[key]=from[key];}}
if(!fromIsEvt&&from&&from.hasOwnProperty&&from.hasOwnProperty('toString')&&!to.hasOwnProperty('toString')){to.toString=from.toString;}
return to;};OpenLayers.Util.getParameterString=function(params){var paramsArray=[];for(var key in params){var value=params[key];if((value!=null)&&(typeof value!='function')){var encodedValue;if(typeof value=='object'&&value.constructor==Array){var encodedItemArray=[];var item;for(var itemIndex=0,len=value.length;itemIndex<len;itemIndex++){item=value[itemIndex];encodedItemArray.push(encodeURIComponent((item===null||item===undefined)?"":item));}
encodedValue=encodedItemArray.join(",");}
else{encodedValue=encodeURIComponent(value);}
paramsArray.push(encodeURIComponent(key)+"="+encodedValue);}}
return paramsArray.join("&");};OpenLayers.Util.urlAppend=function(url,paramStr){var newUrl=url;if(paramStr){var parts=(url+" ").split(/[?&]/);newUrl+=(parts.pop()===" "?paramStr:parts.length?"&"+paramStr:"?"+paramStr);}
return newUrl;};OpenLayers.ImgPath='';OpenLayers.Util.getImagesLocation=function(){return OpenLayers.ImgPath||(OpenLayers._getScriptLocation()+"img/");};OpenLayers.Util.Try=function(){var returnValue=null;for(var i=0,len=arguments.length;i<len;i++){var lambda=arguments[i];try{returnValue=lambda();break;}catch(e){}}
return returnValue;};OpenLayers.Util.getNodes=function(p,tagName){var nodes=OpenLayers.Util.Try(function(){return OpenLayers.Util._getNodes(p.documentElement.childNodes,tagName);},function(){return OpenLayers.Util._getNodes(p.childNodes,tagName);});return nodes;};OpenLayers.Util._getNodes=function(nodes,tagName){var retArray=[];for(var i=0,len=nodes.length;i<len;i++){if(nodes[i].nodeName==tagName){retArray.push(nodes[i]);}}
return retArray;};OpenLayers.Util.getTagText=function(parent,item,index){var result=OpenLayers.Util.getNodes(parent,item);if(result&&(result.length>0))
{if(!index){index=0;}
if(result[index].childNodes.length>1){return result.childNodes[1].nodeValue;}
else if(result[index].childNodes.length==1){return result[index].firstChild.nodeValue;}}else{return"";}};OpenLayers.Util.getXmlNodeValue=function(node){var val=null;OpenLayers.Util.Try(function(){val=node.text;if(!val){val=node.textContent;}
if(!val){val=node.firstChild.nodeValue;}},function(){val=node.textContent;});return val;};OpenLayers.Util.mouseLeft=function(evt,div){var target=(evt.relatedTarget)?evt.relatedTarget:evt.toElement;while(target!=div&&target!=null){target=target.parentNode;}
return(target!=div);};OpenLayers.Util.DEFAULT_PRECISION=14;OpenLayers.Util.toFloat=function(number,precision){if(precision==null){precision=OpenLayers.Util.DEFAULT_PRECISION;}
var number;if(precision==0){number=parseFloat(number);}else{number=parseFloat(parseFloat(number).toPrecision(precision));}
return number;};OpenLayers.Util.rad=function(x){return x*Math.PI/180;};OpenLayers.Util.distVincenty=function(p1,p2){var a=6378137,b=6356752.3142,f=1/298.257223563;var L=OpenLayers.Util.rad(p2.lon-p1.lon);var U1=Math.atan((1-f)*Math.tan(OpenLayers.Util.rad(p1.lat)));var U2=Math.atan((1-f)*Math.tan(OpenLayers.Util.rad(p2.lat)));var sinU1=Math.sin(U1),cosU1=Math.cos(U1);var sinU2=Math.sin(U2),cosU2=Math.cos(U2);var lambda=L,lambdaP=2*Math.PI;var iterLimit=20;while(Math.abs(lambda-lambdaP)>1e-12&&--iterLimit>0){var sinLambda=Math.sin(lambda),cosLambda=Math.cos(lambda);var sinSigma=Math.sqrt((cosU2*sinLambda)*(cosU2*sinLambda)+
(cosU1*sinU2-sinU1*cosU2*cosLambda)*(cosU1*sinU2-sinU1*cosU2*cosLambda));if(sinSigma==0){return 0;}
var cosSigma=sinU1*sinU2+cosU1*cosU2*cosLambda;var sigma=Math.atan2(sinSigma,cosSigma);var alpha=Math.asin(cosU1*cosU2*sinLambda/sinSigma);var cosSqAlpha=Math.cos(alpha)*Math.cos(alpha);var cos2SigmaM=cosSigma-2*sinU1*sinU2/cosSqAlpha;var C=f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha));lambdaP=lambda;lambda=L+(1-C)*f*Math.sin(alpha)*(sigma+C*sinSigma*(cos2SigmaM+C*cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)));}
if(iterLimit==0){return NaN;}
var uSq=cosSqAlpha*(a*a-b*b)/(b*b);var A=1+uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq)));var B=uSq/1024*(256+uSq*(-128+uSq*(74-47*uSq)));var deltaSigma=B*sinSigma*(cos2SigmaM+B/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)-
B/6*cos2SigmaM*(-3+4*sinSigma*sinSigma)*(-3+4*cos2SigmaM*cos2SigmaM)));var s=b*A*(sigma-deltaSigma);var d=s.toFixed(3)/1000;return d;};OpenLayers.Util.getParameters=function(url){url=url||window.location.href;var paramsString="";if(OpenLayers.String.contains(url,'?')){var start=url.indexOf('?')+1;var end=OpenLayers.String.contains(url,"#")?url.indexOf('#'):url.length;paramsString=url.substring(start,end);}
var parameters={};var pairs=paramsString.split(/[&;]/);for(var i=0,len=pairs.length;i<len;++i){var keyValue=pairs[i].split('=');if(keyValue[0]){var key=decodeURIComponent(keyValue[0]);var value=keyValue[1]||'';value=decodeURIComponent(value).split(",");if(value.length==1){value=value[0];}
parameters[key]=value;}}
return parameters;};OpenLayers.Util.getArgs=function(url){OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",{'newMethod':'OpenLayers.Util.getParameters'}));return OpenLayers.Util.getParameters(url);};OpenLayers.Util.lastSeqID=0;OpenLayers.Util.createUniqueID=function(prefix){if(prefix==null){prefix="id_";}
OpenLayers.Util.lastSeqID+=1;return prefix+OpenLayers.Util.lastSeqID;};OpenLayers.INCHES_PER_UNIT={'inches':1.0,'ft':12.0,'mi':63360.0,'m':39.3701,'km':39370.1,'dd':4374754,'yd':36};OpenLayers.INCHES_PER_UNIT["in"]=OpenLayers.INCHES_PER_UNIT.inches;OpenLayers.INCHES_PER_UNIT["degrees"]=OpenLayers.INCHES_PER_UNIT.dd;OpenLayers.INCHES_PER_UNIT["nmi"]=1852*OpenLayers.INCHES_PER_UNIT.m;OpenLayers.METERS_PER_INCH=0.02540005080010160020;OpenLayers.Util.extend(OpenLayers.INCHES_PER_UNIT,{"Inch":OpenLayers.INCHES_PER_UNIT.inches,"Meter":1.0/OpenLayers.METERS_PER_INCH,"Foot":0.30480060960121920243/OpenLayers.METERS_PER_INCH,"IFoot":0.30480000000000000000/OpenLayers.METERS_PER_INCH,"ClarkeFoot":0.3047972651151/OpenLayers.METERS_PER_INCH,"SearsFoot":0.30479947153867624624/OpenLayers.METERS_PER_INCH,"GoldCoastFoot":0.30479971018150881758/OpenLayers.METERS_PER_INCH,"IInch":0.02540000000000000000/OpenLayers.METERS_PER_INCH,"MicroInch":0.00002540000000000000/OpenLayers.METERS_PER_INCH,"Mil":0.00000002540000000000/OpenLayers.METERS_PER_INCH,"Centimeter":0.01000000000000000000/OpenLayers.METERS_PER_INCH,"Kilometer":1000.00000000000000000000/OpenLayers.METERS_PER_INCH,"Yard":0.91440182880365760731/OpenLayers.METERS_PER_INCH,"SearsYard":0.914398414616029/OpenLayers.METERS_PER_INCH,"IndianYard":0.91439853074444079983/OpenLayers.METERS_PER_INCH,"IndianYd37":0.91439523/OpenLayers.METERS_PER_INCH,"IndianYd62":0.9143988/OpenLayers.METERS_PER_INCH,"IndianYd75":0.9143985/OpenLayers.METERS_PER_INCH,"IndianFoot":0.30479951/OpenLayers.METERS_PER_INCH,"IndianFt37":0.30479841/OpenLayers.METERS_PER_INCH,"IndianFt62":0.3047996/OpenLayers.METERS_PER_INCH,"IndianFt75":0.3047995/OpenLayers.METERS_PER_INCH,"Mile":1609.34721869443738887477/OpenLayers.METERS_PER_INCH,"IYard":0.91440000000000000000/OpenLayers.METERS_PER_INCH,"IMile":1609.34400000000000000000/OpenLayers.METERS_PER_INCH,"NautM":1852.00000000000000000000/OpenLayers.METERS_PER_INCH,"Lat-66":110943.316488932731/OpenLayers.METERS_PER_INCH,"Lat-83":110946.25736872234125/OpenLayers.METERS_PER_INCH,"Decimeter":0.10000000000000000000/OpenLayers.METERS_PER_INCH,"Millimeter":0.00100000000000000000/OpenLayers.METERS_PER_INCH,"Dekameter":10.00000000000000000000/OpenLayers.METERS_PER_INCH,"Decameter":10.00000000000000000000/OpenLayers.METERS_PER_INCH,"Hectometer":100.00000000000000000000/OpenLayers.METERS_PER_INCH,"GermanMeter":1.0000135965/OpenLayers.METERS_PER_INCH,"CaGrid":0.999738/OpenLayers.METERS_PER_INCH,"ClarkeChain":20.1166194976/OpenLayers.METERS_PER_INCH,"GunterChain":20.11684023368047/OpenLayers.METERS_PER_INCH,"BenoitChain":20.116782494375872/OpenLayers.METERS_PER_INCH,"SearsChain":20.11676512155/OpenLayers.METERS_PER_INCH,"ClarkeLink":0.201166194976/OpenLayers.METERS_PER_INCH,"GunterLink":0.2011684023368047/OpenLayers.METERS_PER_INCH,"BenoitLink":0.20116782494375872/OpenLayers.METERS_PER_INCH,"SearsLink":0.2011676512155/OpenLayers.METERS_PER_INCH,"Rod":5.02921005842012/OpenLayers.METERS_PER_INCH,"IntnlChain":20.1168/OpenLayers.METERS_PER_INCH,"IntnlLink":0.201168/OpenLayers.METERS_PER_INCH,"Perch":5.02921005842012/OpenLayers.METERS_PER_INCH,"Pole":5.02921005842012/OpenLayers.METERS_PER_INCH,"Furlong":201.1684023368046/OpenLayers.METERS_PER_INCH,"Rood":3.778266898/OpenLayers.METERS_PER_INCH,"CapeFoot":0.3047972615/OpenLayers.METERS_PER_INCH,"Brealey":375.00000000000000000000/OpenLayers.METERS_PER_INCH,"ModAmFt":0.304812252984505969011938/OpenLayers.METERS_PER_INCH,"Fathom":1.8288/OpenLayers.METERS_PER_INCH,"NautM-UK":1853.184/OpenLayers.METERS_PER_INCH,"50kilometers":50000.0/OpenLayers.METERS_PER_INCH,"150kilometers":150000.0/OpenLayers.METERS_PER_INCH});OpenLayers.Util.extend(OpenLayers.INCHES_PER_UNIT,{"mm":OpenLayers.INCHES_PER_UNIT["Meter"]/1000.0,"cm":OpenLayers.INCHES_PER_UNIT["Meter"]/100.0,"dm":OpenLayers.INCHES_PER_UNIT["Meter"]*100.0,"km":OpenLayers.INCHES_PER_UNIT["Meter"]*1000.0,"kmi":OpenLayers.INCHES_PER_UNIT["nmi"],"fath":OpenLayers.INCHES_PER_UNIT["Fathom"],"ch":OpenLayers.INCHES_PER_UNIT["IntnlChain"],"link":OpenLayers.INCHES_PER_UNIT["IntnlLink"],"us-in":OpenLayers.INCHES_PER_UNIT["inches"],"us-ft":OpenLayers.INCHES_PER_UNIT["Foot"],"us-yd":OpenLayers.INCHES_PER_UNIT["Yard"],"us-ch":OpenLayers.INCHES_PER_UNIT["GunterChain"],"us-mi":OpenLayers.INCHES_PER_UNIT["Mile"],"ind-yd":OpenLayers.INCHES_PER_UNIT["IndianYd37"],"ind-ft":OpenLayers.INCHES_PER_UNIT["IndianFt37"],"ind-ch":20.11669506/OpenLayers.METERS_PER_INCH});OpenLayers.DOTS_PER_INCH=72;OpenLayers.Util.normalizeScale=function(scale){var normScale=(scale>1.0)?(1.0/scale):scale;return normScale;};OpenLayers.Util.getResolutionFromScale=function(scale,units){var resolution;if(scale){if(units==null){units="degrees";}
var normScale=OpenLayers.Util.normalizeScale(scale);resolution=1/(normScale*OpenLayers.INCHES_PER_UNIT[units]*OpenLayers.DOTS_PER_INCH);}
return resolution;};OpenLayers.Util.getScaleFromResolution=function(resolution,units){if(units==null){units="degrees";}
var scale=resolution*OpenLayers.INCHES_PER_UNIT[units]*OpenLayers.DOTS_PER_INCH;return scale;};OpenLayers.Util.safeStopPropagation=function(evt){OpenLayers.Event.stop(evt,true);};OpenLayers.Util.pagePosition=function(forElement){var valueT=0,valueL=0;var element=forElement;var child=forElement;while(element){if(element==document.body){if(OpenLayers.Element.getStyle(child,'position')=='absolute'){break;}}
valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;child=element;try{element=element.offsetParent;}catch(e){OpenLayers.Console.error(OpenLayers.i18n("pagePositionFailed",{'elemId':element.id}));break;}}
element=forElement;while(element){valueT-=element.scrollTop||0;valueL-=element.scrollLeft||0;element=element.parentNode;}
return[valueL,valueT];};OpenLayers.Util.isEquivalentUrl=function(url1,url2,options){options=options||{};OpenLayers.Util.applyDefaults(options,{ignoreCase:true,ignorePort80:true,ignoreHash:true});var urlObj1=OpenLayers.Util.createUrlObject(url1,options);var urlObj2=OpenLayers.Util.createUrlObject(url2,options);for(var key in urlObj1){if(key!=="args"){if(urlObj1[key]!=urlObj2[key]){return false;}}}
for(var key in urlObj1.args){if(urlObj1.args[key]!=urlObj2.args[key]){return false;}
delete urlObj2.args[key];}
for(var key in urlObj2.args){return false;}
return true;};OpenLayers.Util.createUrlObject=function(url,options){options=options||{};if(!(/^\w+:\/\//).test(url)){var loc=window.location;var port=loc.port?":"+loc.port:"";var fullUrl=loc.protocol+"//"+loc.host.split(":").shift()+port;if(url.indexOf("/")===0){url=fullUrl+url;}else{var parts=loc.pathname.split("/");parts.pop();url=fullUrl+parts.join("/")+"/"+url;}}
if(options.ignoreCase){url=url.toLowerCase();}
var a=document.createElement('a');a.href=url;var urlObject={};urlObject.host=a.host.split(":").shift();urlObject.protocol=a.protocol;if(options.ignorePort80){urlObject.port=(a.port=="80"||a.port=="0")?"":a.port;}else{urlObject.port=(a.port==""||a.port=="0")?"80":a.port;}
urlObject.hash=(options.ignoreHash||a.hash==="#")?"":a.hash;var queryString=a.search;if(!queryString){var qMark=url.indexOf("?");queryString=(qMark!=-1)?url.substr(qMark):"";}
urlObject.args=OpenLayers.Util.getParameters(queryString);urlObject.pathname=(a.pathname.charAt(0)=="/")?a.pathname:"/"+a.pathname;return urlObject;};OpenLayers.Util.removeTail=function(url){var head=null;var qMark=url.indexOf("?");var hashMark=url.indexOf("#");if(qMark==-1){head=(hashMark!=-1)?url.substr(0,hashMark):url;}else{head=(hashMark!=-1)?url.substr(0,Math.min(qMark,hashMark)):url.substr(0,qMark);}
return head;};OpenLayers.Util.getBrowserName=function(){var browserName="";var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("opera")!=-1){browserName="opera";}else if(ua.indexOf("msie")!=-1){browserName="msie";}else if(ua.indexOf("safari")!=-1){browserName="safari";}else if(ua.indexOf("mozilla")!=-1){if(ua.indexOf("firefox")!=-1){browserName="firefox";}else{browserName="mozilla";}}
return browserName;};OpenLayers.Util.getRenderedDimensions=function(contentHTML,size,options){var w,h;var container=document.createElement("div");container.style.visibility="hidden";var containerElement=(options&&options.containerElement)?options.containerElement:document.body;if(size){if(size.w){w=size.w;container.style.width=w+"px";}else if(size.h){h=size.h;container.style.height=h+"px";}}
if(options&&options.displayClass){container.className=options.displayClass;}
var content=document.createElement("div");content.innerHTML=contentHTML;content.style.overflow="visible";if(content.childNodes){for(var i=0,l=content.childNodes.length;i<l;i++){if(!content.childNodes[i].style)continue;content.childNodes[i].style.overflow="visible";}}
container.appendChild(content);containerElement.appendChild(container);var parentHasPositionAbsolute=false;var parent=container.parentNode;while(parent&&parent.tagName.toLowerCase()!="body"){var parentPosition=OpenLayers.Element.getStyle(parent,"position");if(parentPosition=="absolute"){parentHasPositionAbsolute=true;break;}else if(parentPosition&&parentPosition!="static"){break;}
parent=parent.parentNode;}
if(!parentHasPositionAbsolute){container.style.position="absolute";}
if(!w){w=parseInt(content.scrollWidth);container.style.width=w+"px";}
if(!h){h=parseInt(content.scrollHeight);}
container.removeChild(content);containerElement.removeChild(container);return new OpenLayers.Size(w,h);};OpenLayers.Util.getScrollbarWidth=function(){var scrollbarWidth=OpenLayers.Util._scrollbarWidth;if(scrollbarWidth==null){var scr=null;var inn=null;var wNoScroll=0;var wScroll=0;scr=document.createElement('div');scr.style.position='absolute';scr.style.top='-1000px';scr.style.left='-1000px';scr.style.width='100px';scr.style.height='50px';scr.style.overflow='hidden';inn=document.createElement('div');inn.style.width='100%';inn.style.height='200px';scr.appendChild(inn);document.body.appendChild(scr);wNoScroll=inn.offsetWidth;scr.style.overflow='scroll';wScroll=inn.offsetWidth;document.body.removeChild(document.body.lastChild);OpenLayers.Util._scrollbarWidth=(wNoScroll-wScroll);scrollbarWidth=OpenLayers.Util._scrollbarWidth;}
return scrollbarWidth;};OpenLayers.Util.getFormattedLonLat=function(coordinate,axis,dmsOption){if(!dmsOption){dmsOption='dms';}
var abscoordinate=Math.abs(coordinate)
var coordinatedegrees=Math.floor(abscoordinate);var coordinateminutes=(abscoordinate-coordinatedegrees)/(1/60);var tempcoordinateminutes=coordinateminutes;coordinateminutes=Math.floor(coordinateminutes);var coordinateseconds=(tempcoordinateminutes-coordinateminutes)/(1/60);coordinateseconds=Math.round(coordinateseconds*10);coordinateseconds/=10;if(coordinatedegrees<10){coordinatedegrees="0"+coordinatedegrees;}
var str=coordinatedegrees+" ";if(dmsOption.indexOf('dm')>=0){if(coordinateminutes<10){coordinateminutes="0"+coordinateminutes;}
str+=coordinateminutes+"'";if(dmsOption.indexOf('dms')>=0){if(coordinateseconds<10){coordinateseconds="0"+coordinateseconds;}
str+=coordinateseconds+'"';}}
if(axis=="lon"){str+=coordinate<0?OpenLayers.i18n("W"):OpenLayers.i18n("E");}else{str+=coordinate<0?OpenLayers.i18n("S"):OpenLayers.i18n("N");}
return str;};OpenLayers.Rico=new Object();OpenLayers.Rico.Corner={round:function(e,options){e=OpenLayers.Util.getElement(e);this._setOptions(options);var color=this.options.color;if(this.options.color=="fromElement"){color=this._background(e);}
var bgColor=this.options.bgColor;if(this.options.bgColor=="fromParent"){bgColor=this._background(e.offsetParent);}
this._roundCornersImpl(e,color,bgColor);},changeColor:function(theDiv,newColor){theDiv.style.backgroundColor=newColor;var spanElements=theDiv.parentNode.getElementsByTagName("span");for(var currIdx=0;currIdx<spanElements.length;currIdx++){spanElements[currIdx].style.backgroundColor=newColor;}},changeOpacity:function(theDiv,newOpacity){var mozillaOpacity=newOpacity;var ieOpacity='alpha(opacity='+newOpacity*100+')';theDiv.style.opacity=mozillaOpacity;theDiv.style.filter=ieOpacity;var spanElements=theDiv.parentNode.getElementsByTagName("span");for(var currIdx=0;currIdx<spanElements.length;currIdx++){spanElements[currIdx].style.opacity=mozillaOpacity;spanElements[currIdx].style.filter=ieOpacity;}},reRound:function(theDiv,options){var topRico=theDiv.parentNode.childNodes[0];var bottomRico=theDiv.parentNode.childNodes[2];theDiv.parentNode.removeChild(topRico);theDiv.parentNode.removeChild(bottomRico);this.round(theDiv.parentNode,options);},_roundCornersImpl:function(e,color,bgColor){if(this.options.border){this._renderBorder(e,bgColor);}
if(this._isTopRounded()){this._roundTopCorners(e,color,bgColor);}
if(this._isBottomRounded()){this._roundBottomCorners(e,color,bgColor);}},_renderBorder:function(el,bgColor){var borderValue="1px solid "+this._borderColor(bgColor);var borderL="border-left: "+borderValue;var borderR="border-right: "+borderValue;var style="style='"+borderL+";"+borderR+"'";el.innerHTML="<div "+style+">"+el.innerHTML+"</div>";},_roundTopCorners:function(el,color,bgColor){var corner=this._createCorner(bgColor);for(var i=0;i<this.options.numSlices;i++){corner.appendChild(this._createCornerSlice(color,bgColor,i,"top"));}
el.style.paddingTop=0;el.insertBefore(corner,el.firstChild);},_roundBottomCorners:function(el,color,bgColor){var corner=this._createCorner(bgColor);for(var i=(this.options.numSlices-1);i>=0;i--){corner.appendChild(this._createCornerSlice(color,bgColor,i,"bottom"));}
el.style.paddingBottom=0;el.appendChild(corner);},_createCorner:function(bgColor){var corner=document.createElement("div");corner.style.backgroundColor=(this._isTransparent()?"transparent":bgColor);return corner;},_createCornerSlice:function(color,bgColor,n,position){var slice=document.createElement("span");var inStyle=slice.style;inStyle.backgroundColor=color;inStyle.display="block";inStyle.height="1px";inStyle.overflow="hidden";inStyle.fontSize="1px";var borderColor=this._borderColor(color,bgColor);if(this.options.border&&n==0){inStyle.borderTopStyle="solid";inStyle.borderTopWidth="1px";inStyle.borderLeftWidth="0px";inStyle.borderRightWidth="0px";inStyle.borderBottomWidth="0px";inStyle.height="0px";inStyle.borderColor=borderColor;}
else if(borderColor){inStyle.borderColor=borderColor;inStyle.borderStyle="solid";inStyle.borderWidth="0px 1px";}
if(!this.options.compact&&(n==(this.options.numSlices-1))){inStyle.height="2px";}
this._setMargin(slice,n,position);this._setBorder(slice,n,position);return slice;},_setOptions:function(options){this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false};OpenLayers.Util.extend(this.options,options||{});this.options.numSlices=this.options.compact?2:4;if(this._isTransparent()){this.options.blend=false;}},_whichSideTop:function(){if(this._hasString(this.options.corners,"all","top")){return"";}
if(this.options.corners.indexOf("tl")>=0&&this.options.corners.indexOf("tr")>=0){return"";}
if(this.options.corners.indexOf("tl")>=0){return"left";}else if(this.options.corners.indexOf("tr")>=0){return"right";}
return"";},_whichSideBottom:function(){if(this._hasString(this.options.corners,"all","bottom")){return"";}
if(this.options.corners.indexOf("bl")>=0&&this.options.corners.indexOf("br")>=0){return"";}
if(this.options.corners.indexOf("bl")>=0){return"left";}else if(this.options.corners.indexOf("br")>=0){return"right";}
return"";},_borderColor:function(color,bgColor){if(color=="transparent"){return bgColor;}else if(this.options.border){return this.options.border;}else if(this.options.blend){return this._blend(bgColor,color);}else{return"";}},_setMargin:function(el,n,corners){var marginSize=this._marginSize(n);var whichSide=corners=="top"?this._whichSideTop():this._whichSideBottom();if(whichSide=="left"){el.style.marginLeft=marginSize+"px";el.style.marginRight="0px";}
else if(whichSide=="right"){el.style.marginRight=marginSize+"px";el.style.marginLeft="0px";}
else{el.style.marginLeft=marginSize+"px";el.style.marginRight=marginSize+"px";}},_setBorder:function(el,n,corners){var borderSize=this._borderSize(n);var whichSide=corners=="top"?this._whichSideTop():this._whichSideBottom();if(whichSide=="left"){el.style.borderLeftWidth=borderSize+"px";el.style.borderRightWidth="0px";}
else if(whichSide=="right"){el.style.borderRightWidth=borderSize+"px";el.style.borderLeftWidth="0px";}
else{el.style.borderLeftWidth=borderSize+"px";el.style.borderRightWidth=borderSize+"px";}
if(this.options.border!=false){el.style.borderLeftWidth=borderSize+"px";el.style.borderRightWidth=borderSize+"px";}},_marginSize:function(n){if(this._isTransparent()){return 0;}
var marginSizes=[5,3,2,1];var blendedMarginSizes=[3,2,1,0];var compactMarginSizes=[2,1];var smBlendedMarginSizes=[1,0];if(this.options.compact&&this.options.blend){return smBlendedMarginSizes[n];}else if(this.options.compact){return compactMarginSizes[n];}else if(this.options.blend){return blendedMarginSizes[n];}else{return marginSizes[n];}},_borderSize:function(n){var transparentBorderSizes=[5,3,2,1];var blendedBorderSizes=[2,1,1,1];var compactBorderSizes=[1,0];var actualBorderSizes=[0,2,0,0];if(this.options.compact&&(this.options.blend||this._isTransparent())){return 1;}else if(this.options.compact){return compactBorderSizes[n];}else if(this.options.blend){return blendedBorderSizes[n];}else if(this.options.border){return actualBorderSizes[n];}else if(this._isTransparent()){return transparentBorderSizes[n];}
return 0;},_hasString:function(str){for(var i=1;i<arguments.length;i++)if(str.indexOf(arguments[i])>=0){return true;}return false;},_blend:function(c1,c2){var cc1=OpenLayers.Rico.Color.createFromHex(c1);cc1.blend(OpenLayers.Rico.Color.createFromHex(c2));return cc1;},_background:function(el){try{return OpenLayers.Rico.Color.createColorFromBackground(el).asHex();}catch(err){return"#ffffff";}},_isTransparent:function(){return this.options.color=="transparent";},_isTopRounded:function(){return this._hasString(this.options.corners,"all","top","tl","tr");},_isBottomRounded:function(){return this._hasString(this.options.corners,"all","bottom","bl","br");},_hasSingleTextChild:function(el){return el.childNodes.length==1&&el.childNodes[0].nodeType==3;}};(function(){if(window.google&&google.gears){return;}
var factory=null;if(typeof GearsFactory!='undefined'){factory=new GearsFactory();}else{try{factory=new ActiveXObject('Gears.Factory');if(factory.getBuildInfo().indexOf('ie_mobile')!=-1){factory.privateSetGlobalObject(this);}}catch(e){if((typeof navigator.mimeTypes!='undefined')&&navigator.mimeTypes["application/x-googlegears"]){factory=document.createElement("object");factory.style.display="none";factory.width=0;factory.height=0;factory.type="application/x-googlegears";document.documentElement.appendChild(factory);}}}
if(!factory){return;}
if(!window.google){google={};}
if(!google.gears){google.gears={factory:factory};}})();OpenLayers.Element={visible:function(element){return OpenLayers.Util.getElement(element).style.display!='none';},toggle:function(){for(var i=0,len=arguments.length;i<len;i++){var element=OpenLayers.Util.getElement(arguments[i]);var display=OpenLayers.Element.visible(element)?'hide':'show';OpenLayers.Element[display](element);}},hide:function(){for(var i=0,len=arguments.length;i<len;i++){var element=OpenLayers.Util.getElement(arguments[i]);element.style.display='none';}},show:function(){for(var i=0,len=arguments.length;i<len;i++){var element=OpenLayers.Util.getElement(arguments[i]);element.style.display='';}},remove:function(element){element=OpenLayers.Util.getElement(element);element.parentNode.removeChild(element);},getHeight:function(element){element=OpenLayers.Util.getElement(element);return element.offsetHeight;},getDimensions:function(element){element=OpenLayers.Util.getElement(element);if(OpenLayers.Element.getStyle(element,'display')!='none'){return{width:element.offsetWidth,height:element.offsetHeight};}
var els=element.style;var originalVisibility=els.visibility;var originalPosition=els.position;els.visibility='hidden';els.position='absolute';els.display='';var originalWidth=element.clientWidth;var originalHeight=element.clientHeight;els.display='none';els.position=originalPosition;els.visibility=originalVisibility;return{width:originalWidth,height:originalHeight};},hasClass:function(element,name){var names=element.className;return(!!names&&new RegExp("(^|\\s)"+name+"(\\s|$)").test(names));},addClass:function(element,name){if(!OpenLayers.Element.hasClass(element,name)){element.className+=(element.className?" ":"")+name;}
return element;},removeClass:function(element,name){var names=element.className;if(names){element.className=OpenLayers.String.trim(names.replace(new RegExp("(^|\\s+)"+name+"(\\s+|$)")," "));}
return element;},toggleClass:function(element,name){if(OpenLayers.Element.hasClass(element,name)){OpenLayers.Element.removeClass(element,name);}else{OpenLayers.Element.addClass(element,name);}
return element;},getStyle:function(element,style){element=OpenLayers.Util.getElement(element);var value=null;if(element&&element.style){value=element.style[OpenLayers.String.camelize(style)];if(!value){if(document.defaultView&&document.defaultView.getComputedStyle){var css=document.defaultView.getComputedStyle(element,null);value=css?css.getPropertyValue(style):null;}else if(element.currentStyle){value=element.currentStyle[OpenLayers.String.camelize(style)];}}
var positions=['left','top','right','bottom'];if(window.opera&&(OpenLayers.Util.indexOf(positions,style)!=-1)&&(OpenLayers.Element.getStyle(element,'position')=='static')){value='auto';}}
return value=='auto'?null:value;}};OpenLayers.Size=OpenLayers.Class({w:0.0,h:0.0,initialize:function(w,h){this.w=parseFloat(w);this.h=parseFloat(h);},toString:function(){return("w="+this.w+",h="+this.h);},clone:function(){return new OpenLayers.Size(this.w,this.h);},equals:function(sz){var equals=false;if(sz!=null){equals=((this.w==sz.w&&this.h==sz.h)||(isNaN(this.w)&&isNaN(this.h)&&isNaN(sz.w)&&isNaN(sz.h)));}
return equals;},CLASS_NAME:"OpenLayers.Size"});OpenLayers.Console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){},userError:function(error){alert(error);},assert:function(){},dir:function(){},dirxml:function(){},trace:function(){},group:function(){},groupEnd:function(){},time:function(){},timeEnd:function(){},profile:function(){},profileEnd:function(){},count:function(){},CLASS_NAME:"OpenLayers.Console"};(function(){var scripts=document.getElementsByTagName("script");for(var i=0,len=scripts.length;i<len;++i){if(scripts[i].src.indexOf("firebug.js")!=-1){if(console){OpenLayers.Util.extend(OpenLayers.Console,console);break;}}}})();OpenLayers.Icon=OpenLayers.Class({url:null,size:null,offset:null,calculateOffset:null,imageDiv:null,px:null,initialize:function(url,size,offset,calculateOffset){this.url=url;this.size=(size)?size:new OpenLayers.Size(20,20);this.offset=offset?offset:new OpenLayers.Pixel(-(this.size.w/2),-(this.size.h/2));this.calculateOffset=calculateOffset;var id=OpenLayers.Util.createUniqueID("OL_Icon_");this.imageDiv=OpenLayers.Util.createAlphaImageDiv(id);},destroy:function(){this.erase();OpenLayers.Event.stopObservingElement(this.imageDiv.firstChild);this.imageDiv.innerHTML="";this.imageDiv=null;},clone:function(){return new OpenLayers.Icon(this.url,this.size,this.offset,this.calculateOffset);},setSize:function(size){if(size!=null){this.size=size;}
this.draw();},setUrl:function(url){if(url!=null){this.url=url;}
this.draw();},draw:function(px){OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,null,this.size,this.url,"absolute");this.moveTo(px);return this.imageDiv;},erase:function(){if(this.imageDiv!=null&&this.imageDiv.parentNode!=null){OpenLayers.Element.remove(this.imageDiv);}},setOpacity:function(opacity){OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,null,null,null,null,null,null,opacity);},moveTo:function(px){if(px!=null){this.px=px;}
if(this.imageDiv!=null){if(this.px==null){this.display(false);}else{if(this.calculateOffset){this.offset=this.calculateOffset(this.size);}
var offsetPx=this.px.offset(this.offset);OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,offsetPx);}}},animateTo:function(px){if(px!=null){this.px=px;}
if(this.imageDiv!=null){if(this.px==null){this.display(false);}else{if(this.calculateOffset){this.offset=this.calculateOffset(this.size);}
var offsetPx=this.px.offset(this.offset);if(typeof jQuery!='undefined')
jQuery(this.imageDiv).animate({'left':offsetPx.x+'px','top':offsetPx.y+'px'},'slow');else
OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,offsetPx);}}},display:function(display){this.imageDiv.style.display=(display)?"":"none";},isDrawn:function(){var isDrawn=(this.imageDiv&&this.imageDiv.parentNode&&(this.imageDiv.parentNode.nodeType!=11));return isDrawn;},CLASS_NAME:"OpenLayers.Icon"});OpenLayers.Popup=OpenLayers.Class({events:null,id:"",lonlat:null,div:null,contentSize:null,size:null,contentHTML:null,backgroundColor:"",opacity:"",border:"",contentDiv:null,groupDiv:null,closeDiv:null,autoSize:false,minSize:null,maxSize:null,displayClass:"olPopup",contentDisplayClass:"olPopupContent",padding:0,disableFirefoxOverflowHack:false,fixPadding:function(){if(typeof this.padding=="number"){this.padding=new OpenLayers.Bounds(this.padding,this.padding,this.padding,this.padding);}},panMapIfOutOfView:false,keepInMap:false,closeOnMove:false,map:null,initialize:function(id,lonlat,contentSize,contentHTML,closeBox,closeBoxCallback){if(id==null){id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");}
this.id=id;this.lonlat=lonlat;this.contentSize=(contentSize!=null)?contentSize:new OpenLayers.Size(OpenLayers.Popup.WIDTH,OpenLayers.Popup.HEIGHT);if(contentHTML!=null){this.contentHTML=contentHTML;}
this.backgroundColor=OpenLayers.Popup.COLOR;this.opacity=OpenLayers.Popup.OPACITY;this.border=OpenLayers.Popup.BORDER;this.div=OpenLayers.Util.createDiv(this.id,null,null,null,null,null,"hidden");this.div.className=this.displayClass;var groupDivId=this.id+"_GroupDiv";this.groupDiv=OpenLayers.Util.createDiv(groupDivId,null,null,null,"relative",null,"hidden");var id=this.div.id+"_contentDiv";this.contentDiv=OpenLayers.Util.createDiv(id,null,this.contentSize.clone(),null,"relative");this.contentDiv.className=this.contentDisplayClass;this.groupDiv.appendChild(this.contentDiv);this.div.appendChild(this.groupDiv);if(closeBox){this.addCloseBox(closeBoxCallback);}
this.registerEvents();},destroy:function(){this.id=null;this.lonlat=null;this.size=null;this.contentHTML=null;this.backgroundColor=null;this.opacity=null;this.border=null;if(this.closeOnMove&&this.map){this.map.events.unregister("movestart",this,this.hide);}
this.events.destroy();this.events=null;if(this.closeDiv){OpenLayers.Event.stopObservingElement(this.closeDiv);this.groupDiv.removeChild(this.closeDiv);}
this.closeDiv=null;this.div.removeChild(this.groupDiv);this.groupDiv=null;if(this.map!=null){this.map.removePopup(this);}
this.map=null;this.div=null;this.autoSize=null;this.minSize=null;this.maxSize=null;this.padding=null;this.panMapIfOutOfView=null;},draw:function(px){if(px==null){if((this.lonlat!=null)&&(this.map!=null)){px=this.map.getLayerPxFromLonLat(this.lonlat);}}
if(this.closeOnMove){this.map.events.register("movestart",this,this.hide);}
if(!this.disableFirefoxOverflowHack&&OpenLayers.Util.getBrowserName()=='firefox'){this.map.events.register("movestart",this,function(){var style=document.defaultView.getComputedStyle(this.contentDiv,null);var currentOverflow=style.getPropertyValue("overflow");if(currentOverflow!="hidden"){this.contentDiv._oldOverflow=currentOverflow;this.contentDiv.style.overflow="hidden";}});this.map.events.register("moveend",this,function(){var oldOverflow=this.contentDiv._oldOverflow;if(oldOverflow){this.contentDiv.style.overflow=oldOverflow;this.contentDiv._oldOverflow=null;}});}
this.moveTo(px);if(!this.autoSize&&!this.size){this.setSize(this.contentSize);}
this.setBackgroundColor();this.setOpacity();this.setBorder();this.setContentHTML();if(this.panMapIfOutOfView){this.panIntoView();}
return this.div;},updatePosition:function(){if((this.lonlat)&&(this.map)){var px=this.map.getLayerPxFromLonLat(this.lonlat);if(px){this.moveTo(px);}}},moveTo:function(px){if((px!=null)&&(this.div!=null)){this.div.style.left=px.x+"px";this.div.style.top=px.y+"px";}},visible:function(){return OpenLayers.Element.visible(this.div);},toggle:function(){if(this.visible()){this.hide();}else{this.show();}},show:function(){OpenLayers.Element.show(this.div);if(this.panMapIfOutOfView){this.panIntoView();}},hide:function(){OpenLayers.Element.hide(this.div);},setSize:function(contentSize){this.size=contentSize.clone();var contentDivPadding=this.getContentDivPadding();var wPadding=contentDivPadding.left+contentDivPadding.right;var hPadding=contentDivPadding.top+contentDivPadding.bottom;this.fixPadding();wPadding+=this.padding.left+this.padding.right;hPadding+=this.padding.top+this.padding.bottom;if(this.closeDiv){var closeDivWidth=parseInt(this.closeDiv.style.width);wPadding+=closeDivWidth+contentDivPadding.right;}
this.size.w+=wPadding;this.size.h+=hPadding;if(OpenLayers.Util.getBrowserName()=="msie"){this.contentSize.w+=contentDivPadding.left+contentDivPadding.right;this.contentSize.h+=contentDivPadding.bottom+contentDivPadding.top;}
if(this.div!=null){this.div.style.width=this.size.w+"px";this.div.style.height=this.size.h+"px";}
if(this.contentDiv!=null){this.contentDiv.style.width=contentSize.w+"px";this.contentDiv.style.height=contentSize.h+"px";}},updateSize:function(){var preparedHTML="<div class='"+this.contentDisplayClass+"'>"+
this.contentDiv.innerHTML+"</div>";var containerElement=(this.map)?this.map.layerContainerDiv:document.body;var realSize=OpenLayers.Util.getRenderedDimensions(preparedHTML,null,{displayClass:this.displayClass,containerElement:containerElement});var safeSize=this.getSafeContentSize(realSize);var newSize=null;if(safeSize.equals(realSize)){newSize=realSize;}else{var fixedSize=new OpenLayers.Size();fixedSize.w=(safeSize.w<realSize.w)?safeSize.w:null;fixedSize.h=(safeSize.h<realSize.h)?safeSize.h:null;if(fixedSize.w&&fixedSize.h){newSize=safeSize;}else{var clippedSize=OpenLayers.Util.getRenderedDimensions(preparedHTML,fixedSize,{displayClass:this.contentDisplayClass,containerElement:containerElement});var currentOverflow=OpenLayers.Element.getStyle(this.contentDiv,"overflow");if((currentOverflow!="hidden")&&(clippedSize.equals(safeSize))){var scrollBar=OpenLayers.Util.getScrollbarWidth();if(fixedSize.w){clippedSize.h+=scrollBar;}else{clippedSize.w+=scrollBar;}}
newSize=this.getSafeContentSize(clippedSize);}}
this.setSize(newSize);},setBackgroundColor:function(color){if(color!=undefined){this.backgroundColor=color;}
if(this.div!=null){this.div.style.backgroundColor=this.backgroundColor;}},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+')';}},setBorder:function(border){if(border!=undefined){this.border=border;}
if(this.div!=null){this.div.style.border=this.border;}},setContentHTML:function(contentHTML){if(contentHTML!=null){this.contentHTML=contentHTML;}
if((this.contentDiv!=null)&&(this.contentHTML!=null)&&(this.contentHTML!=this.contentDiv.innerHTML)){this.contentDiv.innerHTML=this.contentHTML;if(this.autoSize){this.registerImageListeners();this.updateSize();}}},registerImageListeners:function(){var onImgLoad=function(){this.popup.updateSize();if(this.popup.visible()&&this.popup.panMapIfOutOfView){this.popup.panIntoView();}
OpenLayers.Event.stopObserving(this.img,"load",this.img._onImageLoad);};var images=this.contentDiv.getElementsByTagName("img");for(var i=0,len=images.length;i<len;i++){var img=images[i];if(img.width==0||img.height==0){var context={'popup':this,'img':img};img._onImgLoad=OpenLayers.Function.bind(onImgLoad,context);OpenLayers.Event.observe(img,'load',img._onImgLoad);}}},getSafeContentSize:function(size){var safeContentSize=size.clone();var contentDivPadding=this.getContentDivPadding();var wPadding=contentDivPadding.left+contentDivPadding.right;var hPadding=contentDivPadding.top+contentDivPadding.bottom;this.fixPadding();wPadding+=this.padding.left+this.padding.right;hPadding+=this.padding.top+this.padding.bottom;if(this.closeDiv){var closeDivWidth=parseInt(this.closeDiv.style.width);wPadding+=closeDivWidth+contentDivPadding.right;}
if(this.minSize){safeContentSize.w=Math.max(safeContentSize.w,(this.minSize.w-wPadding));safeContentSize.h=Math.max(safeContentSize.h,(this.minSize.h-hPadding));}
if(this.maxSize){safeContentSize.w=Math.min(safeContentSize.w,(this.maxSize.w-wPadding));safeContentSize.h=Math.min(safeContentSize.h,(this.maxSize.h-hPadding));}
if(this.map&&this.map.size){var extraX=0,extraY=0;if(this.keepInMap&&!this.panMapIfOutOfView){var px=this.map.getPixelFromLonLat(this.lonlat);switch(this.relativePosition){case"tr":extraX=px.x;extraY=this.map.size.h-px.y;break;case"tl":extraX=this.map.size.w-px.x;extraY=this.map.size.h-px.y;break;case"bl":extraX=this.map.size.w-px.x;extraY=px.y;break;case"br":extraX=px.x;extraY=px.y;break;default:extraX=px.x;extraY=this.map.size.h-px.y;break;}}
var maxY=this.map.size.h-
this.map.paddingForPopups.top-
this.map.paddingForPopups.bottom-
hPadding-extraY;var maxX=this.map.size.w-
this.map.paddingForPopups.left-
this.map.paddingForPopups.right-
wPadding-extraX;safeContentSize.w=Math.min(safeContentSize.w,maxX);safeContentSize.h=Math.min(safeContentSize.h,maxY);}
return safeContentSize;},getContentDivPadding:function(){var contentDivPadding=this._contentDivPadding;if(!contentDivPadding){if(this.div.parentNode==null){this.div.style.display="none";document.body.appendChild(this.div);}
contentDivPadding=new OpenLayers.Bounds(OpenLayers.Element.getStyle(this.contentDiv,"padding-left"),OpenLayers.Element.getStyle(this.contentDiv,"padding-bottom"),OpenLayers.Element.getStyle(this.contentDiv,"padding-right"),OpenLayers.Element.getStyle(this.contentDiv,"padding-top"));this._contentDivPadding=contentDivPadding;if(this.div.parentNode==document.body){document.body.removeChild(this.div);this.div.style.display="";}}
return contentDivPadding;},addCloseBox:function(callback){this.closeDiv=OpenLayers.Util.createDiv(this.id+"_close",null,new OpenLayers.Size(20,20));this.closeDiv.className="olPopupCloseBox";var contentDivPadding=this.getContentDivPadding();this.closeDiv.style.right=contentDivPadding.right+"px";this.closeDiv.style.top=contentDivPadding.top+"px";this.groupDiv.appendChild(this.closeDiv);var closePopup=callback||function(e){this.hide();OpenLayers.Event.stop(e);};OpenLayers.Event.observe(this.closeDiv,"click",OpenLayers.Function.bindAsEventListener(closePopup,this));},panIntoView:function(){var mapSize=this.map.getSize();var origTL=this.map.getViewPortPxFromLayerPx(new OpenLayers.Pixel(parseInt(this.div.style.left),parseInt(this.div.style.top)));var newTL=origTL.clone();if(origTL.x<this.map.paddingForPopups.left){newTL.x=this.map.paddingForPopups.left;}else
if((origTL.x+this.size.w)>(mapSize.w-this.map.paddingForPopups.right)){newTL.x=mapSize.w-this.map.paddingForPopups.right-this.size.w;}
if(origTL.y<this.map.paddingForPopups.top){newTL.y=this.map.paddingForPopups.top;}else
if((origTL.y+this.size.h)>(mapSize.h-this.map.paddingForPopups.bottom)){newTL.y=mapSize.h-this.map.paddingForPopups.bottom-this.size.h;}
var dx=origTL.x-newTL.x;var dy=origTL.y-newTL.y;this.map.pan(dx,dy);},registerEvents:function(){this.events=new OpenLayers.Events(this,this.div,null,true);this.events.on({"mousedown":this.onmousedown,"mousemove":this.onmousemove,"mouseup":this.onmouseup,"click":this.onclick,"mouseout":this.onmouseout,"dblclick":this.ondblclick,scope:this});},onmousedown:function(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);},onmouseout:function(evt){this.mousedown=false;},ondblclick:function(evt){OpenLayers.Event.stop(evt,true);},CLASS_NAME:"OpenLayers.Popup"});OpenLayers.Popup.WIDTH=200;OpenLayers.Popup.HEIGHT=200;OpenLayers.Popup.COLOR="white";OpenLayers.Popup.OPACITY=1;OpenLayers.Popup.BORDER="0px";OpenLayers.Protocol=OpenLayers.Class({format:null,options:null,autoDestroy:true,initialize:function(options){options=options||{};OpenLayers.Util.extend(this,options);this.options=options;},destroy:function(){this.options=null;this.format=null;},read:function(){},create:function(){},update:function(){},"delete":function(){},commit:function(){},abort:function(response){},CLASS_NAME:"OpenLayers.Protocol"});OpenLayers.Protocol.Response=OpenLayers.Class({code:null,requestType:null,last:true,features:null,reqFeatures:null,priv:null,initialize:function(options){OpenLayers.Util.extend(this,options);},success:function(){return this.code>0;},CLASS_NAME:"OpenLayers.Protocol.Response"});OpenLayers.Protocol.Response.SUCCESS=1;OpenLayers.Protocol.Response.FAILURE=0;OpenLayers.Renderer=OpenLayers.Class({container:null,root:null,extent:null,locked:false,size:null,resolution:null,map:null,initialize:function(containerID,options){this.container=OpenLayers.Util.getElement(containerID);},destroy:function(){this.container=null;this.extent=null;this.size=null;this.resolution=null;this.map=null;},supported:function(){return false;},setExtent:function(extent,resolutionChanged){this.extent=extent.clone();if(resolutionChanged){this.resolution=null;}},setSize:function(size){this.size=size.clone();this.resolution=null;},getResolution:function(){this.resolution=this.resolution||this.map.getResolution();return this.resolution;},drawFeature:function(feature,style){if(style==null){style=feature.style;}
if(feature.geometry){var bounds=feature.geometry.getBounds();if(bounds){if(!bounds.intersectsBounds(this.extent)){style={display:"none"};}
var rendered=this.drawGeometry(feature.geometry,style,feature.id);if(style.display!="none"&&style.label&&rendered!==false){var location=feature.geometry.getCentroid();if(style.labelXOffset||style.labelYOffset){xOffset=isNaN(style.labelXOffset)?0:style.labelXOffset;yOffset=isNaN(style.labelYOffset)?0:style.labelYOffset;var res=this.getResolution();location.move(xOffset*res,yOffset*res);}
this.drawText(feature.id,style,location);}else{this.removeText(feature.id);}
return rendered;}}},drawGeometry:function(geometry,style,featureId){},drawText:function(featureId,style,location){},removeText:function(featureId){},clear:function(){},getFeatureIdFromEvent:function(evt){},eraseFeatures:function(features){if(!(features instanceof Array)){features=[features];}
for(var i=0,len=features.length;i<len;++i){this.eraseGeometry(features[i].geometry);this.removeText(features[i].id);}},eraseGeometry:function(geometry){},moveRoot:function(renderer){},getRenderLayerId:function(){return this.container.id;},CLASS_NAME:"OpenLayers.Renderer"});OpenLayers.Strategy=OpenLayers.Class({layer:null,options:null,active:null,autoActivate:true,autoDestroy:true,initialize:function(options){OpenLayers.Util.extend(this,options);this.options=options;this.active=false;},destroy:function(){this.deactivate();this.layer=null;this.options=null;},setLayer:function(layer){this.layer=layer;},activate:function(){if(!this.active){this.active=true;return true;}
return false;},deactivate:function(){if(this.active){this.active=false;return true;}
return false;},CLASS_NAME:"OpenLayers.Strategy"});OpenLayers.Rico.Color=OpenLayers.Class({initialize:function(red,green,blue){this.rgb={r:red,g:green,b:blue};},setRed:function(r){this.rgb.r=r;},setGreen:function(g){this.rgb.g=g;},setBlue:function(b){this.rgb.b=b;},setHue:function(h){var hsb=this.asHSB();hsb.h=h;this.rgb=OpenLayers.Rico.Color.HSBtoRGB(hsb.h,hsb.s,hsb.b);},setSaturation:function(s){var hsb=this.asHSB();hsb.s=s;this.rgb=OpenLayers.Rico.Color.HSBtoRGB(hsb.h,hsb.s,hsb.b);},setBrightness:function(b){var hsb=this.asHSB();hsb.b=b;this.rgb=OpenLayers.Rico.Color.HSBtoRGB(hsb.h,hsb.s,hsb.b);},darken:function(percent){var hsb=this.asHSB();this.rgb=OpenLayers.Rico.Color.HSBtoRGB(hsb.h,hsb.s,Math.max(hsb.b-percent,0));},brighten:function(percent){var hsb=this.asHSB();this.rgb=OpenLayers.Rico.Color.HSBtoRGB(hsb.h,hsb.s,Math.min(hsb.b+percent,1));},blend:function(other){this.rgb.r=Math.floor((this.rgb.r+other.rgb.r)/2);this.rgb.g=Math.floor((this.rgb.g+other.rgb.g)/2);this.rgb.b=Math.floor((this.rgb.b+other.rgb.b)/2);},isBright:function(){var hsb=this.asHSB();return this.asHSB().b>0.5;},isDark:function(){return!this.isBright();},asRGB:function(){return"rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")";},asHex:function(){return"#"+this.rgb.r.toColorPart()+this.rgb.g.toColorPart()+this.rgb.b.toColorPart();},asHSB:function(){return OpenLayers.Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b);},toString:function(){return this.asHex();}});OpenLayers.Rico.Color.createFromHex=function(hexCode){if(hexCode.length==4){var shortHexCode=hexCode;var hexCode='#';for(var i=1;i<4;i++){hexCode+=(shortHexCode.charAt(i)+
shortHexCode.charAt(i));}}
if(hexCode.indexOf('#')==0){hexCode=hexCode.substring(1);}
var red=hexCode.substring(0,2);var green=hexCode.substring(2,4);var blue=hexCode.substring(4,6);return new OpenLayers.Rico.Color(parseInt(red,16),parseInt(green,16),parseInt(blue,16));};OpenLayers.Rico.Color.createColorFromBackground=function(elem){var actualColor=RicoUtil.getElementsComputedStyle(OpenLayers.Util.getElement(elem),"backgroundColor","background-color");if(actualColor=="transparent"&&elem.parentNode){return OpenLayers.Rico.Color.createColorFromBackground(elem.parentNode);}
if(actualColor==null){return new OpenLayers.Rico.Color(255,255,255);}
if(actualColor.indexOf("rgb(")==0){var colors=actualColor.substring(4,actualColor.length-1);var colorArray=colors.split(",");return new OpenLayers.Rico.Color(parseInt(colorArray[0]),parseInt(colorArray[1]),parseInt(colorArray[2]));}
else if(actualColor.indexOf("#")==0){return OpenLayers.Rico.Color.createFromHex(actualColor);}
else{return new OpenLayers.Rico.Color(255,255,255);}};OpenLayers.Rico.Color.HSBtoRGB=function(hue,saturation,brightness){var red=0;var green=0;var blue=0;if(saturation==0){red=parseInt(brightness*255.0+0.5);green=red;blue=red;}
else{var h=(hue-Math.floor(hue))*6.0;var f=h-Math.floor(h);var p=brightness*(1.0-saturation);var q=brightness*(1.0-saturation*f);var t=brightness*(1.0-(saturation*(1.0-f)));switch(parseInt(h)){case 0:red=(brightness*255.0+0.5);green=(t*255.0+0.5);blue=(p*255.0+0.5);break;case 1:red=(q*255.0+0.5);green=(brightness*255.0+0.5);blue=(p*255.0+0.5);break;case 2:red=(p*255.0+0.5);green=(brightness*255.0+0.5);blue=(t*255.0+0.5);break;case 3:red=(p*255.0+0.5);green=(q*255.0+0.5);blue=(brightness*255.0+0.5);break;case 4:red=(t*255.0+0.5);green=(p*255.0+0.5);blue=(brightness*255.0+0.5);break;case 5:red=(brightness*255.0+0.5);green=(p*255.0+0.5);blue=(q*255.0+0.5);break;}}
return{r:parseInt(red),g:parseInt(green),b:parseInt(blue)};};OpenLayers.Rico.Color.RGBtoHSB=function(r,g,b){var hue;var saturation;var brightness;var cmax=(r>g)?r:g;if(b>cmax){cmax=b;}
var cmin=(r<g)?r:g;if(b<cmin){cmin=b;}
brightness=cmax/255.0;if(cmax!=0){saturation=(cmax-cmin)/cmax;}else{saturation=0;}
if(saturation==0){hue=0;}else{var redc=(cmax-r)/(cmax-cmin);var greenc=(cmax-g)/(cmax-cmin);var bluec=(cmax-b)/(cmax-cmin);if(r==cmax){hue=bluec-greenc;}else if(g==cmax){hue=2.0+redc-bluec;}else{hue=4.0+greenc-redc;}
hue=hue/6.0;if(hue<0){hue=hue+1.0;}}
return{h:hue,s:saturation,b:brightness};};OpenLayers.Bounds=OpenLayers.Class({left:null,bottom:null,right:null,top:null,centerLonLat:null,initialize:function(left,bottom,right,top){if(left!=null){this.left=OpenLayers.Util.toFloat(left);}
if(bottom!=null){this.bottom=OpenLayers.Util.toFloat(bottom);}
if(right!=null){this.right=OpenLayers.Util.toFloat(right);}
if(top!=null){this.top=OpenLayers.Util.toFloat(top);}},clone:function(){return new OpenLayers.Bounds(this.left,this.bottom,this.right,this.top);},equals:function(bounds){var equals=false;if(bounds!=null){equals=((this.left==bounds.left)&&(this.right==bounds.right)&&(this.top==bounds.top)&&(this.bottom==bounds.bottom));}
return equals;},toString:function(){return("left-bottom=("+this.left+","+this.bottom+")"
+" right-top=("+this.right+","+this.top+")");},toArray:function(){return[this.left,this.bottom,this.right,this.top];},toBBOX:function(decimal){if(decimal==null){decimal=6;}
var mult=Math.pow(10,decimal);var bbox=Math.round(this.left*mult)/mult+","+
Math.round(this.bottom*mult)/mult+","+
Math.round(this.right*mult)/mult+","+
Math.round(this.top*mult)/mult;return bbox;},toGeometry:function(){return new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(this.left,this.bottom),new OpenLayers.Geometry.Point(this.right,this.bottom),new OpenLayers.Geometry.Point(this.right,this.top),new OpenLayers.Geometry.Point(this.left,this.top)])]);},getWidth:function(){return(this.right-this.left);},getHeight:function(){return(this.top-this.bottom);},getSize:function(){return new OpenLayers.Size(this.getWidth(),this.getHeight());},getCenterPixel:function(){return new OpenLayers.Pixel((this.left+this.right)/2,(this.bottom+this.top)/2);},getCenterLonLat:function(){if(!this.centerLonLat){this.centerLonLat=new OpenLayers.LonLat((this.left+this.right)/2,(this.bottom+this.top)/2);}
return this.centerLonLat;},scale:function(ratio,origin){if(origin==null){origin=this.getCenterLonLat();}
var bounds=[];var origx,origy;if(origin.CLASS_NAME=="OpenLayers.LonLat"){origx=origin.lon;origy=origin.lat;}else{origx=origin.x;origy=origin.y;}
var left=(this.left-origx)*ratio+origx;var bottom=(this.bottom-origy)*ratio+origy;var right=(this.right-origx)*ratio+origx;var top=(this.top-origy)*ratio+origy;return new OpenLayers.Bounds(left,bottom,right,top);},add:function(x,y){if((x==null)||(y==null)){var msg=OpenLayers.i18n("boundsAddError");OpenLayers.Console.error(msg);return null;}
return new OpenLayers.Bounds(this.left+x,this.bottom+y,this.right+x,this.top+y);},extend:function(object){var bounds=null;if(object){switch(object.CLASS_NAME){case"OpenLayers.LonLat":bounds=new OpenLayers.Bounds(object.lon,object.lat,object.lon,object.lat);break;case"OpenLayers.Geometry.Point":bounds=new OpenLayers.Bounds(object.x,object.y,object.x,object.y);break;case"OpenLayers.Bounds":bounds=object;break;}
if(bounds){this.centerLonLat=null;if((this.left==null)||(bounds.left<this.left)){this.left=bounds.left;}
if((this.bottom==null)||(bounds.bottom<this.bottom)){this.bottom=bounds.bottom;}
if((this.right==null)||(bounds.right>this.right)){this.right=bounds.right;}
if((this.top==null)||(bounds.top>this.top)){this.top=bounds.top;}}}},containsLonLat:function(ll,inclusive){return this.contains(ll.lon,ll.lat,inclusive);},containsPixel:function(px,inclusive){return this.contains(px.x,px.y,inclusive);},contains:function(x,y,inclusive){if(inclusive==null){inclusive=true;}
if(x==null||y==null){return false;}
x=OpenLayers.Util.toFloat(x);y=OpenLayers.Util.toFloat(y);var contains=false;if(inclusive){contains=((x>=this.left)&&(x<=this.right)&&(y>=this.bottom)&&(y<=this.top));}else{contains=((x>this.left)&&(x<this.right)&&(y>this.bottom)&&(y<this.top));}
return contains;},intersectsBounds:function(bounds,inclusive){if(inclusive==null){inclusive=true;}
var intersects=false;var mightTouch=(this.left==bounds.right||this.right==bounds.left||this.top==bounds.bottom||this.bottom==bounds.top);if(inclusive||!mightTouch){var inBottom=(((bounds.bottom>=this.bottom)&&(bounds.bottom<=this.top))||((this.bottom>=bounds.bottom)&&(this.bottom<=bounds.top)));var inTop=(((bounds.top>=this.bottom)&&(bounds.top<=this.top))||((this.top>bounds.bottom)&&(this.top<bounds.top)));var inLeft=(((bounds.left>=this.left)&&(bounds.left<=this.right))||((this.left>=bounds.left)&&(this.left<=bounds.right)));var inRight=(((bounds.right>=this.left)&&(bounds.right<=this.right))||((this.right>=bounds.left)&&(this.right<=bounds.right)));intersects=((inBottom||inTop)&&(inLeft||inRight));}
return intersects;},containsBounds:function(bounds,partial,inclusive){if(partial==null){partial=false;}
if(inclusive==null){inclusive=true;}
var bottomLeft=this.contains(bounds.left,bounds.bottom,inclusive);var bottomRight=this.contains(bounds.right,bounds.bottom,inclusive);var topLeft=this.contains(bounds.left,bounds.top,inclusive);var topRight=this.contains(bounds.right,bounds.top,inclusive);return(partial)?(bottomLeft||bottomRight||topLeft||topRight):(bottomLeft&&bottomRight&&topLeft&&topRight);},determineQuadrant:function(lonlat){var quadrant="";var center=this.getCenterLonLat();quadrant+=(lonlat.lat<center.lat)?"b":"t";quadrant+=(lonlat.lon<center.lon)?"l":"r";return quadrant;},transform:function(source,dest){this.centerLonLat=null;var ll=OpenLayers.Projection.transform({'x':this.left,'y':this.bottom},source,dest);var lr=OpenLayers.Projection.transform({'x':this.right,'y':this.bottom},source,dest);var ul=OpenLayers.Projection.transform({'x':this.left,'y':this.top},source,dest);var ur=OpenLayers.Projection.transform({'x':this.right,'y':this.top},source,dest);this.left=Math.min(ll.x,ul.x);this.bottom=Math.min(ll.y,lr.y);this.right=Math.max(lr.x,ur.x);this.top=Math.max(ul.y,ur.y);return this;},wrapDateLine:function(maxExtent,options){options=options||{};var leftTolerance=options.leftTolerance||0;var rightTolerance=options.rightTolerance||0;var newBounds=this.clone();if(maxExtent){while(newBounds.left<maxExtent.left&&(newBounds.right-rightTolerance)<=maxExtent.left){newBounds=newBounds.add(maxExtent.getWidth(),0);}
while((newBounds.left+leftTolerance)>=maxExtent.right&&newBounds.right>maxExtent.right){newBounds=newBounds.add(-maxExtent.getWidth(),0);}}
return newBounds;},CLASS_NAME:"OpenLayers.Bounds"});OpenLayers.Bounds.fromString=function(str){var bounds=str.split(",");return OpenLayers.Bounds.fromArray(bounds);};OpenLayers.Bounds.fromArray=function(bbox){return new OpenLayers.Bounds(parseFloat(bbox[0]),parseFloat(bbox[1]),parseFloat(bbox[2]),parseFloat(bbox[3]));};OpenLayers.Bounds.fromSize=function(size){return new OpenLayers.Bounds(0,size.h,size.w,0);};OpenLayers.Bounds.oppositeQuadrant=function(quadrant){var opp="";opp+=(quadrant.charAt(0)=='t')?'b':'t';opp+=(quadrant.charAt(1)=='l')?'r':'l';return opp;};OpenLayers.LonLat=OpenLayers.Class({lon:0.0,lat:0.0,initialize:function(lon,lat){this.lon=OpenLayers.Util.toFloat(lon);this.lat=OpenLayers.Util.toFloat(lat);},toString:function(){return("lon="+this.lon+",lat="+this.lat);},toShortString:function(){return(this.lon+", "+this.lat);},clone:function(){return new OpenLayers.LonLat(this.lon,this.lat);},add:function(lon,lat){if((lon==null)||(lat==null)){var msg=OpenLayers.i18n("lonlatAddError");OpenLayers.Console.error(msg);return null;}
return new OpenLayers.LonLat(this.lon+lon,this.lat+lat);},equals:function(ll){var equals=false;if(ll!=null){equals=((this.lon==ll.lon&&this.lat==ll.lat)||(isNaN(this.lon)&&isNaN(this.lat)&&isNaN(ll.lon)&&isNaN(ll.lat)));}
return equals;},transform:function(source,dest){var point=OpenLayers.Projection.transform({'x':this.lon,'y':this.lat},source,dest);this.lon=point.x;this.lat=point.y;return this;},wrapDateLine:function(maxExtent){var newLonLat=this.clone();if(maxExtent){while(newLonLat.lon<maxExtent.left){newLonLat.lon+=maxExtent.getWidth();}
while(newLonLat.lon>maxExtent.right){newLonLat.lon-=maxExtent.getWidth();}}
return newLonLat;},CLASS_NAME:"OpenLayers.LonLat"});OpenLayers.LonLat.fromString=function(str){var pair=str.split(",");return new OpenLayers.LonLat(parseFloat(pair[0]),parseFloat(pair[1]));};OpenLayers.Pixel=OpenLayers.Class({x:0.0,y:0.0,initialize:function(x,y){this.x=parseFloat(x);this.y=parseFloat(y);},toString:function(){return("x="+this.x+",y="+this.y);},clone:function(){return new OpenLayers.Pixel(this.x,this.y);},equals:function(px){var equals=false;if(px!=null){equals=((this.x==px.x&&this.y==px.y)||(isNaN(this.x)&&isNaN(this.y)&&isNaN(px.x)&&isNaN(px.y)));}
return equals;},add:function(x,y){if((x==null)||(y==null)){var msg=OpenLayers.i18n("pixelAddError");OpenLayers.Console.error(msg);return null;}
return new OpenLayers.Pixel(this.x+x,this.y+y);},offset:function(px){var newPx=this.clone();if(px){newPx=this.add(px.x,px.y);}
return newPx;},CLASS_NAME:"OpenLayers.Pixel"});OpenLayers.Control=OpenLayers.Class({id:null,map:null,div:null,type:null,allowSelection:false,displayClass:"",title:"",active:null,handler:null,eventListeners:null,events:null,EVENT_TYPES:["activate","deactivate"],initialize:function(options){this.displayClass=this.CLASS_NAME.replace("OpenLayers.","ol").replace(/\./g,"");OpenLayers.Util.extend(this,options);this.events=new OpenLayers.Events(this,null,this.EVENT_TYPES);if(this.eventListeners instanceof Object){this.events.on(this.eventListeners);}
if(this.id==null){this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");}},destroy:function(){if(this.events){if(this.eventListeners){this.events.un(this.eventListeners);}
this.events.destroy();this.events=null;}
this.eventListeners=null;if(this.handler){this.handler.destroy();this.handler=null;}
if(this.handlers){for(var key in this.handlers){if(this.handlers.hasOwnProperty(key)&&typeof this.handlers[key].destroy=="function"){this.handlers[key].destroy();}}
this.handlers=null;}
if(this.map){this.map.removeControl(this);this.map=null;}},setMap:function(map){this.map=map;if(this.handler){this.handler.setMap(map);}},draw:function(px){if(this.div==null){this.div=OpenLayers.Util.createDiv(this.id);this.div.className=this.displayClass;if(!this.allowSelection){this.div.className+=" olControlNoSelect";this.div.setAttribute("unselectable","on",0);this.div.onselectstart=function(){return(false);};}
if(this.title!=""){this.div.title=this.title;}}
if(px!=null){this.position=px.clone();}
this.moveTo(this.position);return this.div;},moveTo:function(px){if((px!=null)&&(this.div!=null)){this.div.style.left=px.x+"px";this.div.style.top=px.y+"px";}},activate:function(){if(this.active){return false;}
if(this.handler){this.handler.activate();}
this.active=true;if(this.map){OpenLayers.Element.addClass(this.map.viewPortDiv,this.displayClass.replace(/ /g,"")+"Active");}
this.events.triggerEvent("activate");return true;},deactivate:function(){if(this.active){if(this.handler){this.handler.deactivate();}
this.active=false;if(this.map){OpenLayers.Element.removeClass(this.map.viewPortDiv,this.displayClass.replace(/ /g,"")+"Active");}
this.events.triggerEvent("deactivate");return true;}
return false;},CLASS_NAME:"OpenLayers.Control"});OpenLayers.Control.TYPE_BUTTON=1;OpenLayers.Control.TYPE_TOGGLE=2;OpenLayers.Control.TYPE_TOOL=3;OpenLayers.Lang={code:null,defaultCode:"en",getCode:function(){if(!OpenLayers.Lang.code){OpenLayers.Lang.setCode();}
return OpenLayers.Lang.code;},setCode:function(code){var lang;if(!code){code=(OpenLayers.Util.getBrowserName()=="msie")?navigator.userLanguage:navigator.language;}
var parts=code.split('-');parts[0]=parts[0].toLowerCase();if(typeof OpenLayers.Lang[parts[0]]=="object"){lang=parts[0];}
if(parts[1]){var testLang=parts[0]+'-'+parts[1].toUpperCase();if(typeof OpenLayers.Lang[testLang]=="object"){lang=testLang;}}
if(!lang){OpenLayers.Console.warn('Failed to find OpenLayers.Lang.'+parts.join("-")+' dictionary, falling back to default language');lang=OpenLayers.Lang.defaultCode;}
OpenLayers.Lang.code=lang;},translate:function(key,context){var dictionary=OpenLayers.Lang[OpenLayers.Lang.getCode()];var message=dictionary[key];if(!message){message=key;}
if(context){message=OpenLayers.String.format(message,context);}
return message;}};OpenLayers.i18n=OpenLayers.Lang.translate;OpenLayers.Popup.Anchored=OpenLayers.Class(OpenLayers.Popup,{relativePosition:null,keepInMap:true,anchor:null,initialize:function(id,lonlat,contentSize,contentHTML,anchor,closeBox,closeBoxCallback){var newArguments=[id,lonlat,contentSize,contentHTML,closeBox,closeBoxCallback];OpenLayers.Popup.prototype.initialize.apply(this,newArguments);this.anchor=(anchor!=null)?anchor:{size:new OpenLayers.Size(0,0),offset:new OpenLayers.Pixel(0,0)};},destroy:function(){this.anchor=null;this.relativePosition=null;OpenLayers.Popup.prototype.destroy.apply(this,arguments);},show:function(){this.updatePosition();OpenLayers.Popup.prototype.show.apply(this,arguments);},moveTo:function(px){var oldRelativePosition=this.relativePosition;this.relativePosition=this.calculateRelativePosition(px);var newPx=this.calculateNewPx(px);var newArguments=new Array(newPx);OpenLayers.Popup.prototype.moveTo.apply(this,newArguments);if(this.relativePosition!=oldRelativePosition){this.updateRelativePosition();}},setSize:function(contentSize){OpenLayers.Popup.prototype.setSize.apply(this,arguments);if((this.lonlat)&&(this.map)){var px=this.map.getLayerPxFromLonLat(this.lonlat);this.moveTo(px);}},calculateRelativePosition:function(px){var lonlat=this.map.getLonLatFromLayerPx(px);var extent=this.map.getExtent();var quadrant=extent.determineQuadrant(lonlat);return OpenLayers.Bounds.oppositeQuadrant(quadrant);},updateRelativePosition:function(){},calculateNewPx:function(px){var newPx=px.offset(this.anchor.offset);var size=this.size||this.contentSize;var top=(this.relativePosition.charAt(0)=='t');newPx.y+=(top)?-size.h:this.anchor.size.h;var left=(this.relativePosition.charAt(1)=='l');newPx.x+=(left)?-size.w:this.anchor.size.w;return newPx;},CLASS_NAME:"OpenLayers.Popup.Anchored"});OpenLayers.Protocol.SQL=OpenLayers.Class(OpenLayers.Protocol,{databaseName:'ol',tableName:"ol_vector_features",postReadFiltering:true,initialize:function(options){OpenLayers.Protocol.prototype.initialize.apply(this,[options]);},destroy:function(){OpenLayers.Protocol.prototype.destroy.apply(this);},supported:function(){return false;},evaluateFilter:function(feature,filter){return filter&&this.postReadFiltering?filter.evaluate(feature):true;},CLASS_NAME:"OpenLayers.Protocol.SQL"});OpenLayers.Protocol.WFS=function(options){options=OpenLayers.Util.applyDefaults(options,OpenLayers.Protocol.WFS.DEFAULTS);var cls=OpenLayers.Protocol.WFS["v"+options.version.replace(/\./g,"_")];if(!cls){throw"Unsupported WFS version: "+options.version;}
return new cls(options);};OpenLayers.Protocol.WFS.fromWMSLayer=function(layer,options){var typeName,featurePrefix;var param=layer.params["LAYERS"];var parts=(param instanceof Array?param[0]:param).split(":");if(parts.length>1){featurePrefix=parts[0];}
typeName=parts.pop();var protocolOptions={url:layer.url,featureType:typeName,featurePrefix:featurePrefix,srsName:layer.projection&&layer.projection.getCode()||layer.map&&layer.map.getProjectionObject().getCode(),version:"1.1.0"};return new OpenLayers.Protocol.WFS(OpenLayers.Util.applyDefaults(options,protocolOptions));};OpenLayers.Protocol.WFS.DEFAULTS={"version":"1.0.0"};OpenLayers.Renderer.Canvas=OpenLayers.Class(OpenLayers.Renderer,{canvas:null,features:null,geometryMap:null,initialize:function(containerID){OpenLayers.Renderer.prototype.initialize.apply(this,arguments);this.root=document.createElement("canvas");this.container.appendChild(this.root);this.canvas=this.root.getContext("2d");this.features={};this.geometryMap={};},eraseGeometry:function(geometry){this.eraseFeatures(this.features[this.geometryMap[geometry.id]][0]);},supported:function(){var canvas=document.createElement("canvas");return!!canvas.getContext;},setExtent:function(extent){this.extent=extent.clone();this.resolution=null;this.redraw();},setSize:function(size){this.size=size.clone();this.root.style.width=size.w+"px";this.root.style.height=size.h+"px";this.root.width=size.w;this.root.height=size.h;this.resolution=null;},drawFeature:function(feature,style){if(style==null){style=feature.style;}
style=OpenLayers.Util.extend({'fillColor':'#000000','strokeColor':'#000000','strokeWidth':2,'fillOpacity':1,'strokeOpacity':1},style);this.features[feature.id]=[feature,style];if(feature.geometry){this.geometryMap[feature.geometry.id]=feature.id;}
this.redraw();},drawGeometry:function(geometry,style){var className=geometry.CLASS_NAME;if((className=="OpenLayers.Geometry.Collection")||(className=="OpenLayers.Geometry.MultiPoint")||(className=="OpenLayers.Geometry.MultiLineString")||(className=="OpenLayers.Geometry.MultiPolygon")){for(var i=0;i<geometry.components.length;i++){this.drawGeometry(geometry.components[i],style);}
return;};switch(geometry.CLASS_NAME){case"OpenLayers.Geometry.Point":this.drawPoint(geometry,style);break;case"OpenLayers.Geometry.LineString":this.drawLineString(geometry,style);break;case"OpenLayers.Geometry.LinearRing":this.drawLinearRing(geometry,style);break;case"OpenLayers.Geometry.Polygon":this.drawPolygon(geometry,style);break;default:break;}},drawExternalGraphic:function(pt,style){var img=new Image();img.src=style.externalGraphic;if(style.graphicTitle){img.title=style.graphicTitle;}
var width=style.graphicWidth||style.graphicHeight;var height=style.graphicHeight||style.graphicWidth;width=width?width:style.pointRadius*2;height=height?height:style.pointRadius*2;var xOffset=(style.graphicXOffset!=undefined)?style.graphicXOffset:-(0.5*width);var yOffset=(style.graphicYOffset!=undefined)?style.graphicYOffset:-(0.5*height);var opacity=style.graphicOpacity||style.fillOpacity;var context={img:img,x:(pt[0]+xOffset),y:(pt[1]+yOffset),width:width,height:height,canvas:this.canvas};img.onload=OpenLayers.Function.bind(function(){this.canvas.drawImage(this.img,this.x,this.y,this.width,this.height);},context);},setCanvasStyle:function(type,style){if(type=="fill"){this.canvas.globalAlpha=style['fillOpacity'];this.canvas.fillStyle=style['fillColor'];}else if(type=="stroke"){this.canvas.globalAlpha=style['strokeOpacity'];this.canvas.strokeStyle=style['strokeColor'];this.canvas.lineWidth=style['strokeWidth'];}else{this.canvas.globalAlpha=0;this.canvas.lineWidth=1;}},drawPoint:function(geometry,style){if(style.graphic!==false){var pt=this.getLocalXY(geometry);if(style.externalGraphic){this.drawExternalGraphic(pt,style);}else{if(style.fill!==false){this.setCanvasStyle("fill",style);this.canvas.beginPath();this.canvas.arc(pt[0],pt[1],6,0,Math.PI*2,true);this.canvas.fill();}
if(style.stroke!==false){this.setCanvasStyle("stroke",style);this.canvas.beginPath();this.canvas.arc(pt[0],pt[1],6,0,Math.PI*2,true);this.canvas.stroke();this.setCanvasStyle("reset");}}}},drawLineString:function(geometry,style){if(style.stroke!==false){this.setCanvasStyle("stroke",style);this.canvas.beginPath();var start=this.getLocalXY(geometry.components[0]);this.canvas.moveTo(start[0],start[1]);for(var i=1;i<geometry.components.length;i++){var pt=this.getLocalXY(geometry.components[i]);this.canvas.lineTo(pt[0],pt[1]);}
this.canvas.stroke();}
this.setCanvasStyle("reset");},drawLinearRing:function(geometry,style){if(style.fill!==false){this.setCanvasStyle("fill",style);this.canvas.beginPath();var start=this.getLocalXY(geometry.components[0]);this.canvas.moveTo(start[0],start[1]);for(var i=1;i<geometry.components.length-1;i++){var pt=this.getLocalXY(geometry.components[i]);this.canvas.lineTo(pt[0],pt[1]);}
this.canvas.fill();}
if(style.stroke!==false){var oldWidth=this.canvas.lineWidth;this.setCanvasStyle("stroke",style);this.canvas.beginPath();var start=this.getLocalXY(geometry.components[0]);this.canvas.moveTo(start[0],start[1]);for(var i=1;i<geometry.components.length;i++){var pt=this.getLocalXY(geometry.components[i]);this.canvas.lineTo(pt[0],pt[1]);}
this.canvas.stroke();}
this.setCanvasStyle("reset");},drawPolygon:function(geometry,style){this.drawLinearRing(geometry.components[0],style);for(var i=1;i<geometry.components.length;i++){this.drawLinearRing(geometry.components[i],{fillOpacity:0,strokeWidth:0,strokeOpacity:0,strokeColor:'#000000',fillColor:'#000000'});}},drawText:function(location,style){style=OpenLayers.Util.extend({fontColor:"#000000",labelAlign:"cm"},style);var pt=this.getLocalXY(location);this.setCanvasStyle("reset");this.canvas.fillStyle=style.fontColor;this.canvas.globalAlpha=1;var fontStyle=style.fontWeight+" "+style.fontSize+" "+style.fontFamily;if(this.canvas.fillText){var labelAlign=OpenLayers.Renderer.Canvas.LABEL_ALIGN[style.labelAlign[0]]||"middle";this.canvas.font=fontStyle;this.canvas.textAlign=labelAlign;this.canvas.fillText(style.label,pt[0],pt[1]);}else if(this.canvas.mozDrawText){this.canvas.mozTextStyle=fontStyle;var len=this.canvas.mozMeasureText(style.label);switch(style.labelAlign[0]){case"l":break;case"r":pt[0]-=len;break;case"c":default:pt[0]-=len/2;}
this.canvas.translate(pt[0],pt[1]);this.canvas.mozDrawText(style.label);this.canvas.translate(-1*pt[0],-1*pt[1]);}
this.setCanvasStyle("reset");},getLocalXY:function(point){var resolution=this.getResolution();var extent=this.extent;var x=(point.x/resolution+(-extent.left/resolution));var y=((extent.top/resolution)-point.y/resolution);return[x,y];},clear:function(){this.canvas.clearRect(0,0,this.root.width,this.root.height);},getFeatureIdFromEvent:function(evt){var loc=this.map.getLonLatFromPixel(evt.xy);var resolution=this.getResolution();var bounds=new OpenLayers.Bounds(loc.lon-resolution*5,loc.lat-resolution*5,loc.lon+resolution*5,loc.lat+resolution*5);var geom=bounds.toGeometry();for(var feat in this.features){if(!this.features.hasOwnProperty(feat)){continue;}
if(this.features[feat][0].geometry.intersects(geom)){return feat;}}
return null;},eraseFeatures:function(features){if(!(features instanceof Array)){features=[features];}
for(var i=0;i<features.length;++i){delete this.features[features[i].id];}
this.redraw();},redraw:function(){if(!this.locked){this.clear();var labelMap=[];var feature,style;for(var id in this.features){if(!this.features.hasOwnProperty(id)){continue;}
feature=this.features[id][0];style=this.features[id][1];if(!feature.geometry){continue;}
this.drawGeometry(feature.geometry,style);if(style.label){labelMap.push([feature,style]);}}
var item;for(var i=0;len=labelMap.length,i<len;++i){item=labelMap[i];this.drawText(item[0].geometry.getCentroid(),item[1]);}}},CLASS_NAME:"OpenLayers.Renderer.Canvas"});OpenLayers.Renderer.Canvas.LABEL_ALIGN={"l":"left","r":"right"};OpenLayers.ElementsIndexer=OpenLayers.Class({maxZIndex:null,order:null,indices:null,compare:null,initialize:function(yOrdering){this.compare=yOrdering?OpenLayers.ElementsIndexer.IndexingMethods.Z_ORDER_Y_ORDER:OpenLayers.ElementsIndexer.IndexingMethods.Z_ORDER_DRAWING_ORDER;this.order=[];this.indices={};this.maxZIndex=0;},insert:function(newNode){if(this.exists(newNode)){this.remove(newNode);}
var nodeId=newNode.id;this.determineZIndex(newNode);var leftIndex=-1;var rightIndex=this.order.length;var middle;while(rightIndex-leftIndex>1){middle=parseInt((leftIndex+rightIndex)/2);var placement=this.compare(this,newNode,OpenLayers.Util.getElement(this.order[middle]));if(placement>0){leftIndex=middle;}else{rightIndex=middle;}}
this.order.splice(rightIndex,0,nodeId);this.indices[nodeId]=this.getZIndex(newNode);return this.getNextElement(rightIndex);},remove:function(node){var nodeId=node.id;var arrayIndex=OpenLayers.Util.indexOf(this.order,nodeId);if(arrayIndex>=0){this.order.splice(arrayIndex,1);delete this.indices[nodeId];if(this.order.length>0){var lastId=this.order[this.order.length-1];this.maxZIndex=this.indices[lastId];}else{this.maxZIndex=0;}}},clear:function(){this.order=[];this.indices={};this.maxZIndex=0;},exists:function(node){return(this.indices[node.id]!=null);},getZIndex:function(node){return node._style.graphicZIndex;},determineZIndex:function(node){var zIndex=node._style.graphicZIndex;if(zIndex==null){zIndex=this.maxZIndex;node._style.graphicZIndex=zIndex;}else if(zIndex>this.maxZIndex){this.maxZIndex=zIndex;}},getNextElement:function(index){var nextIndex=index+1;if(nextIndex<this.order.length){var nextElement=OpenLayers.Util.getElement(this.order[nextIndex]);if(nextElement==undefined){nextElement=this.getNextElement(nextIndex);}
return nextElement;}else{return null;}},CLASS_NAME:"OpenLayers.ElementsIndexer"});OpenLayers.ElementsIndexer.IndexingMethods={Z_ORDER:function(indexer,newNode,nextNode){var newZIndex=indexer.getZIndex(newNode);var returnVal=0;if(nextNode){var nextZIndex=indexer.getZIndex(nextNode);returnVal=newZIndex-nextZIndex;}
return returnVal;},Z_ORDER_DRAWING_ORDER:function(indexer,newNode,nextNode){var returnVal=OpenLayers.ElementsIndexer.IndexingMethods.Z_ORDER(indexer,newNode,nextNode);if(nextNode&&returnVal==0){returnVal=1;}
return returnVal;},Z_ORDER_Y_ORDER:function(indexer,newNode,nextNode){var returnVal=OpenLayers.ElementsIndexer.IndexingMethods.Z_ORDER(indexer,newNode,nextNode);if(nextNode&&returnVal==0){var newLat=newNode._geometry.getBounds().bottom;var nextLat=nextNode._geometry.getBounds().bottom;var result=nextLat-newLat;returnVal=(result==0)?1:result;}
return returnVal;}};OpenLayers.Renderer.Elements=OpenLayers.Class(OpenLayers.Renderer,{rendererRoot:null,root:null,vectorRoot:null,textRoot:null,xmlns:null,indexer:null,BACKGROUND_ID_SUFFIX:"_background",LABEL_ID_SUFFIX:"_label",minimumSymbolizer:{strokeLinecap:"round",strokeOpacity:1,strokeDashstyle:"solid",fillOpacity:1,pointRadius:0},initialize:function(containerID,options){OpenLayers.Renderer.prototype.initialize.apply(this,arguments);this.rendererRoot=this.createRenderRoot();this.root=this.createRoot("_root");this.vectorRoot=this.createRoot("_vroot");this.textRoot=this.createRoot("_troot");this.root.appendChild(this.vectorRoot);this.root.appendChild(this.textRoot);this.rendererRoot.appendChild(this.root);this.container.appendChild(this.rendererRoot);if(options&&(options.zIndexing||options.yOrdering)){this.indexer=new OpenLayers.ElementsIndexer(options.yOrdering);}},destroy:function(){this.clear();this.rendererRoot=null;this.root=null;this.xmlns=null;OpenLayers.Renderer.prototype.destroy.apply(this,arguments);},clear:function(){if(this.vectorRoot){while(this.vectorRoot.childNodes.length>0){this.vectorRoot.removeChild(this.vectorRoot.firstChild);}}
if(this.textRoot){while(this.textRoot.childNodes.length>0){this.textRoot.removeChild(this.textRoot.firstChild);}}
if(this.indexer){this.indexer.clear();}},getNodeType:function(geometry,style){},drawGeometry:function(geometry,style,featureId){var className=geometry.CLASS_NAME;var rendered=true;if((className=="OpenLayers.Geometry.Collection")||(className=="OpenLayers.Geometry.MultiPoint")||(className=="OpenLayers.Geometry.MultiLineString")||(className=="OpenLayers.Geometry.MultiPolygon")){for(var i=0,len=geometry.components.length;i<len;i++){rendered=this.drawGeometry(geometry.components[i],style,featureId)&&rendered;}
return rendered;};rendered=false;if(style.display!="none"){if(style.backgroundGraphic){this.redrawBackgroundNode(geometry.id,geometry,style,featureId);}
rendered=this.redrawNode(geometry.id,geometry,style,featureId);}
if(rendered==false){var node=document.getElementById(geometry.id);if(node){if(node._style.backgroundGraphic){node.parentNode.removeChild(document.getElementById(geometry.id+this.BACKGROUND_ID_SUFFIX));}
node.parentNode.removeChild(node);}}
return rendered;},redrawNode:function(id,geometry,style,featureId){var node=this.nodeFactory(id,this.getNodeType(geometry,style));node._featureId=featureId;node._geometry=geometry;node._geometryClass=geometry.CLASS_NAME;node._style=style;var drawResult=this.drawGeometryNode(node,geometry,style);if(drawResult===false){return false;}
node=drawResult.node;if(this.indexer){var insert=this.indexer.insert(node);if(insert){this.vectorRoot.insertBefore(node,insert);}else{this.vectorRoot.appendChild(node);}}else{if(node.parentNode!==this.vectorRoot){this.vectorRoot.appendChild(node);}}
this.postDraw(node);return drawResult.complete;},redrawBackgroundNode:function(id,geometry,style,featureId){var backgroundStyle=OpenLayers.Util.extend({},style);backgroundStyle.externalGraphic=backgroundStyle.backgroundGraphic;backgroundStyle.graphicXOffset=backgroundStyle.backgroundXOffset;backgroundStyle.graphicYOffset=backgroundStyle.backgroundYOffset;backgroundStyle.graphicZIndex=backgroundStyle.backgroundGraphicZIndex;backgroundStyle.graphicWidth=backgroundStyle.backgroundWidth||backgroundStyle.graphicWidth;backgroundStyle.graphicHeight=backgroundStyle.backgroundHeight||backgroundStyle.graphicHeight;backgroundStyle.backgroundGraphic=null;backgroundStyle.backgroundXOffset=null;backgroundStyle.backgroundYOffset=null;backgroundStyle.backgroundGraphicZIndex=null;return this.redrawNode(id+this.BACKGROUND_ID_SUFFIX,geometry,backgroundStyle,null);},drawGeometryNode:function(node,geometry,style){style=style||node._style;OpenLayers.Util.applyDefaults(style,this.minimumSymbolizer);var options={'isFilled':style.fill===undefined?true:style.fill,'isStroked':style.stroke===undefined?!!style.strokeWidth:style.stroke};var drawn;switch(geometry.CLASS_NAME){case"OpenLayers.Geometry.Point":if(style.graphic===false){options.isFilled=false;options.isStroked=false;}
drawn=this.drawPoint(node,geometry);break;case"OpenLayers.Geometry.LineString":options.isFilled=false;drawn=this.drawLineString(node,geometry);break;case"OpenLayers.Geometry.LinearRing":drawn=this.drawLinearRing(node,geometry);break;case"OpenLayers.Geometry.Polygon":drawn=this.drawPolygon(node,geometry);break;case"OpenLayers.Geometry.Surface":drawn=this.drawSurface(node,geometry);break;case"OpenLayers.Geometry.Rectangle":drawn=this.drawRectangle(node,geometry);break;default:break;}
node._style=style;node._options=options;if(drawn!=false){return{node:this.setStyle(node,style,options,geometry),complete:drawn};}else{return false;}},postDraw:function(node){},drawPoint:function(node,geometry){},drawLineString:function(node,geometry){},drawLinearRing:function(node,geometry){},drawPolygon:function(node,geometry){},drawRectangle:function(node,geometry){},drawCircle:function(node,geometry){},drawSurface:function(node,geometry){},removeText:function(featureId){var label=document.getElementById(featureId+this.LABEL_ID_SUFFIX);if(label){this.textRoot.removeChild(label);}},getFeatureIdFromEvent:function(evt){var target=evt.target;var useElement=target&&target.correspondingUseElement;var node=useElement?useElement:(target||evt.srcElement);var featureId=node._featureId;return featureId;},eraseGeometry:function(geometry){if((geometry.CLASS_NAME=="OpenLayers.Geometry.MultiPoint")||(geometry.CLASS_NAME=="OpenLayers.Geometry.MultiLineString")||(geometry.CLASS_NAME=="OpenLayers.Geometry.MultiPolygon")||(geometry.CLASS_NAME=="OpenLayers.Geometry.Collection")){for(var i=0,len=geometry.components.length;i<len;i++){this.eraseGeometry(geometry.components[i]);}}else{var element=OpenLayers.Util.getElement(geometry.id);if(element&&element.parentNode){if(element.geometry){element.geometry.destroy();element.geometry=null;}
element.parentNode.removeChild(element);if(this.indexer){this.indexer.remove(element);}
if(element._style.backgroundGraphic){var backgroundId=geometry.id+this.BACKGROUND_ID_SUFFIX;var bElem=OpenLayers.Util.getElement(backgroundId);if(bElem&&bElem.parentNode){bElem.parentNode.removeChild(bElem);}}}}},nodeFactory:function(id,type){var node=OpenLayers.Util.getElement(id);if(node){if(!this.nodeTypeCompare(node,type)){node.parentNode.removeChild(node);node=this.nodeFactory(id,type);}}else{node=this.createNode(type,id);}
return node;},nodeTypeCompare:function(node,type){},createNode:function(type,id){},moveRoot:function(renderer){var root=this.root;if(renderer.root.parentNode==this.rendererRoot){root=renderer.root;}
root.parentNode.removeChild(root);renderer.rendererRoot.appendChild(root);},getRenderLayerId:function(){return this.root.parentNode.parentNode.id;},isComplexSymbol:function(graphicName){return(graphicName!="circle")&&!!graphicName;},CLASS_NAME:"OpenLayers.Renderer.Elements"});OpenLayers.Renderer.symbol={"star":[350,75,379,161,469,161,397,215,423,301,350,250,277,301,303,215,231,161,321,161,350,75],"cross":[4,0,6,0,6,4,10,4,10,6,6,6,6,10,4,10,4,6,0,6,0,4,4,4,4,0],"x":[0,0,25,0,50,35,75,0,100,0,65,50,100,100,75,100,50,65,25,100,0,100,35,50,0,0],"square":[0,0,0,1,1,1,1,0,0,0],"triangle":[0,10,10,10,5,0,0,10]};OpenLayers.Strategy.Cluster=OpenLayers.Class(OpenLayers.Strategy,{distance:20,threshold:null,features:null,clusters:null,clustering:false,resolution:null,initialize:function(options){OpenLayers.Strategy.prototype.initialize.apply(this,[options]);},activate:function(){var activated=OpenLayers.Strategy.prototype.activate.call(this);if(activated){this.layer.events.on({"beforefeaturesadded":this.cacheFeatures,"moveend":this.cluster,scope:this});}
return activated;},deactivate:function(){var deactivated=OpenLayers.Strategy.prototype.deactivate.call(this);if(deactivated){this.clearCache();this.layer.events.un({"beforefeaturesadded":this.cacheFeatures,"moveend":this.cluster,scope:this});}
return deactivated;},cacheFeatures:function(event){var propagate=true;if(!this.clustering){this.clearCache();this.features=event.features;this.cluster();propagate=false;}
return propagate;},clearCache:function(){this.features=null;},cluster:function(event){if((!event||event.zoomChanged)&&this.features){var resolution=this.layer.map.getResolution();if(resolution!=this.resolution||!this.clustersExist()){this.resolution=resolution;var clusters=[];var feature,clustered,cluster;for(var i=0;i<this.features.length;++i){feature=this.features[i];if(feature.geometry){clustered=false;for(var j=0;j<clusters.length;++j){cluster=clusters[j];if(this.shouldCluster(cluster,feature)){this.addToCluster(cluster,feature);clustered=true;break;}}
if(!clustered){clusters.push(this.createCluster(this.features[i]));}}}
this.layer.destroyFeatures();if(clusters.length>0){if(this.threshold>1){var clone=clusters.slice();clusters=[];var candidate;for(var i=0,len=clone.length;i<len;++i){candidate=clone[i];if(candidate.attributes.count<this.threshold){Array.prototype.push.apply(clusters,candidate.cluster);}else{clusters.push(candidate);}}}
this.clustering=true;this.layer.addFeatures(clusters);this.clustering=false;}
this.clusters=clusters;}}},clustersExist:function(){var exist=false;if(this.clusters&&this.clusters.length>0&&this.clusters.length==this.layer.features.length){exist=true;for(var i=0;i<this.clusters.length;++i){if(this.clusters[i]!=this.layer.features[i]){exist=false;break;}}}
return exist;},shouldCluster:function(cluster,feature){var cc=cluster.geometry.getBounds().getCenterLonLat();var fc=feature.geometry.getBounds().getCenterLonLat();var distance=(Math.sqrt(Math.pow((cc.lon-fc.lon),2)+Math.pow((cc.lat-fc.lat),2))/this.resolution);return(distance<=this.distance);},addToCluster:function(cluster,feature){cluster.cluster.push(feature);cluster.attributes.count+=1;},createCluster:function(feature){var center=feature.geometry.getBounds().getCenterLonLat();var cluster=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(center.lon,center.lat),{count:1});cluster.cluster=[feature];return cluster;},CLASS_NAME:"OpenLayers.Strategy.Cluster"});OpenLayers.Strategy.Fixed=OpenLayers.Class(OpenLayers.Strategy,{preload:false,initialize:function(options){OpenLayers.Strategy.prototype.initialize.apply(this,[options]);},destroy:function(){OpenLayers.Strategy.prototype.destroy.apply(this,arguments);},activate:function(){if(OpenLayers.Strategy.prototype.activate.apply(this,arguments)){this.layer.events.on({"refresh":this.load,scope:this});if(this.layer.visibility==true||this.preload){this.load();}else{this.layer.events.on({"visibilitychanged":this.load,scope:this});}
return true;}
return false;},deactivate:function(){var deactivated=OpenLayers.Strategy.prototype.deactivate.call(this);if(deactivated){this.layer.events.un({"refresh":this.load,"visibilitychanged":this.load,scope:this});}
return deactivated;},load:function(options){this.layer.events.triggerEvent("loadstart");this.layer.protocol.read(OpenLayers.Util.applyDefaults({callback:this.merge,scope:this},options));this.layer.events.un({"visibilitychanged":this.load,scope:this});},merge:function(resp){this.layer.destroyFeatures();var features=resp.features;if(features&&features.length>0){var remote=this.layer.projection;var local=this.layer.map.getProjectionObject();if(!local.equals(remote)){var geom;for(var i=0,len=features.length;i<len;++i){geom=features[i].geometry;if(geom){geom.transform(remote,local);}}}
this.layer.addFeatures(features);}
this.layer.events.triggerEvent("loadend");},CLASS_NAME:"OpenLayers.Strategy.Fixed"});OpenLayers.Strategy.Paging=OpenLayers.Class(OpenLayers.Strategy,{features:null,length:10,num:null,paging:false,initialize:function(options){OpenLayers.Strategy.prototype.initialize.apply(this,[options]);},activate:function(){var activated=OpenLayers.Strategy.prototype.activate.call(this);if(activated){this.layer.events.on({"beforefeaturesadded":this.cacheFeatures,scope:this});}
return activated;},deactivate:function(){var deactivated=OpenLayers.Strategy.prototype.deactivate.call(this);if(deactivated){this.clearCache();this.layer.events.un({"beforefeaturesadded":this.cacheFeatures,scope:this});}
return deactivated;},cacheFeatures:function(event){if(!this.paging){this.clearCache();this.features=event.features;this.pageNext(event);}},clearCache:function(){if(this.features){for(var i=0;i<this.features.length;++i){this.features[i].destroy();}}
this.features=null;this.num=null;},pageCount:function(){var numFeatures=this.features?this.features.length:0;return Math.ceil(numFeatures/this.length);},pageNum:function(){return this.num;},pageLength:function(newLength){if(newLength&&newLength>0){this.length=newLength;}
return this.length;},pageNext:function(event){var changed=false;if(this.features){if(this.num===null){this.num=-1;}
var start=(this.num+1)*this.length;changed=this.page(start,event);}
return changed;},pagePrevious:function(){var changed=false;if(this.features){if(this.num===null){this.num=this.pageCount();}
var start=(this.num-1)*this.length;changed=this.page(start);}
return changed;},page:function(start,event){var changed=false;if(this.features){if(start>=0&&start<this.features.length){var num=Math.floor(start/this.length);if(num!=this.num){this.paging=true;var features=this.features.slice(start,start+this.length);this.layer.removeFeatures(this.layer.features);this.num=num;if(event&&event.features){event.features=features;}else{this.layer.addFeatures(features);}
this.paging=false;changed=true;}}}
return changed;},CLASS_NAME:"OpenLayers.Strategy.Paging"});OpenLayers.Strategy.Save=OpenLayers.Class(OpenLayers.Strategy,{auto:false,timer:null,initialize:function(options){OpenLayers.Strategy.prototype.initialize.apply(this,[options]);},activate:function(){var activated=OpenLayers.Strategy.prototype.activate.call(this);if(activated){if(this.auto){if(typeof this.auto==="number"){this.timer=window.setInterval(OpenLayers.Function.bind(this.save,this),this.auto*1000)}else{this.layer.events.on({"featureadded":this.triggerSave,"afterfeaturemodified":this.triggerSave,scope:this});}}}
return activated;},deactivate:function(){var deactivated=OpenLayers.Strategy.prototype.deactivate.call(this);if(deactivated){if(this.auto){if(typeof this.auto==="number"){window.clearInterval(this.timer);}else{this.layer.events.un({"featureadded":this.triggerSave,"afterfeaturemodified":this.triggerSave,scope:this})}}}
return deactivated;},triggerSave:function(event){var feature=event.feature;if(feature.state===OpenLayers.State.INSERT||feature.state===OpenLayers.State.UPDATE||feature.state===OpenLayers.State.DELETE){this.save([event.feature]);}},save:function(features){if(!features){features=this.layer.features;}
var remote=this.layer.projection;var local=this.layer.map.getProjectionObject();if(!local.equals(remote)){var len=features.length;var clones=new Array(len);var orig,clone;for(var i=0;i<len;++i){orig=features[i];clone=orig.clone();clone.fid=orig.fid;clone.state=orig.state;clone._original=orig;clone.geometry.transform(local,remote);clones[i]=clone;}
features=clones;}
this.layer.protocol.commit(features,{callback:this.onCommit,scope:this});},onCommit:function(response){if(response.success()){var features=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];feature=feature._original||feature;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);}}},CLASS_NAME:"OpenLayers.Strategy.Save"});OpenLayers.Tween=OpenLayers.Class({INTERVAL:10,easing:null,begin:null,finish:null,duration:null,callbacks:null,time:null,interval:null,playing:false,initialize:function(easing){this.easing=(easing)?easing:OpenLayers.Easing.Expo.easeOut;},start:function(begin,finish,duration,options){this.playing=true;this.begin=begin;this.finish=finish;this.duration=duration;this.callbacks=options.callbacks;this.time=0;if(this.interval){window.clearInterval(this.interval);this.interval=null;}
if(this.callbacks&&this.callbacks.start){this.callbacks.start.call(this,this.begin);}
this.interval=window.setInterval(OpenLayers.Function.bind(this.play,this),this.INTERVAL);},stop:function(){if(!this.playing){return;}
if(this.callbacks&&this.callbacks.done){this.callbacks.done.call(this,this.finish);}
window.clearInterval(this.interval);this.interval=null;this.playing=false;},play:function(){var value={};for(var i in this.begin){var b=this.begin[i];var f=this.finish[i];if(b==null||f==null||isNaN(b)||isNaN(f)){OpenLayers.Console.error('invalid value for Tween');}
var c=f-b;value[i]=this.easing.apply(this,[this.time,b,c,this.duration]);}
this.time++;if(this.callbacks&&this.callbacks.eachStep){this.callbacks.eachStep.call(this,value);}
if(this.time>this.duration){if(this.callbacks&&this.callbacks.done){this.callbacks.done.call(this,this.finish);this.playing=false;}
window.clearInterval(this.interval);this.interval=null;}},CLASS_NAME:"OpenLayers.Tween"});OpenLayers.Easing={CLASS_NAME:"OpenLayers.Easing"};OpenLayers.Easing.Linear={easeIn:function(t,b,c,d){return c*t/d+b;},easeOut:function(t,b,c,d){return c*t/d+b;},easeInOut:function(t,b,c,d){return c*t/d+b;},CLASS_NAME:"OpenLayers.Easing.Linear"};OpenLayers.Easing.Expo={easeIn:function(t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b;},easeOut:function(t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b;},easeInOut:function(t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b;},CLASS_NAME:"OpenLayers.Easing.Expo"};OpenLayers.Easing.Quad={easeIn:function(t,b,c,d){return c*(t/=d)*t+b;},easeOut:function(t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeInOut:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},CLASS_NAME:"OpenLayers.Easing.Quad"};OpenLayers.Control.AirportPlans=OpenLayers.Class(OpenLayers.Control,{baseURL:'http://172.25.81.9/map/bluebadge2/airport-plans/',scriptName:'dg.py',scriptURL:'http://172.25.81.9/map-bin/dg.py',initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.baseURL=getBaseURL()+'/airport-plans/';this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='airportPlansControlDiv';}
var h1=document.createElement('h1');h1.innerHTML=OpenLayers.i18n('Airport plans');this.load();},load:function(){var params='req=airportplans';var url=this.scriptURL+"?"+params;this.div.innerHTML=OpenLayers.i18n('Loading')+'...';OpenLayers.loadURL(url,null,this,this.handleResponse,this.failed);},failed:function(){this.div.innerHTML=OpenLayers.i18n('Nothing found.');},handleResponse:function(request){var response=eval('('+request.responseText+')');if(!response){this.div.innerHTML=OpenLayers.i18n('Nothing found.');return false;}
if(response.results['airportplans'].length>0){this.div.innerHTML='';var ul=document.createElement('ul');ul.className='airportPlansUL';this.div.appendChild(ul);results=response.results;for(var len=results['airportplans'].length,currIndex=0;currIndex<len;currIndex++){var airport=results.airportplans[currIndex];var li=document.createElement('li');var a=document.createElement('a');a.href=this.baseURL+airport+'.pdf';a.target='_blank';a.innerHTML=airport;a.style.cursor='pointer';li.appendChild(a);ul.appendChild(li);}}else{this.div.innerHTML=OpenLayers.i18n("Nothing found.");}},mouseOver:function(elem,evt){elem.className='over';},mouseOut:function(elem,evt){elem.className='';},centerMap:function(point){var centrePoint=new OpenLayers.LonLat(point[0],point[1]);this.map.setCenter(centrePoint,this.zoom);},CLASS_NAME:"OpenLayers.Control.AirportPlans"});OpenLayers.Control.AreaSelector=OpenLayers.Class(OpenLayers.Control,{drawFeature:true,layer:null,feature:null,contentDiv:null,zoom:3,scriptName:'dg.py',scriptURL:'http://172.25.81.9/map-bin/dg.py',initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='areaSelectorControlDiv';}
var h1=document.createElement('h1');h1.innerHTML='Areas Covered';this.load();},load:function(){var params='req=areas';var url=this.scriptURL+"?"+params;this.div.innerHTML=OpenLayers.i18n('Loading')+'...';OpenLayers.loadURL(url,null,this,this.handleResponse,this.failed);},failed:function(){this.div.innerHTML=OpenLayers.i18n('Nothing found.');},handleResponse:function(request){var response=eval('('+request.responseText+')');if(!response){this.div.innerHTML=OpenLayers.i18n('Nothing found.');return false;}
if(response.results['features'].length>0){this.div.innerHTML='';var ul=document.createElement('ul');ul.className='areaSelectorUL';this.div.appendChild(ul);results=response.results;for(var len=results['features'].length,currIndex=0;currIndex<len;currIndex++){var li=document.createElement('li');var a=document.createElement('a');var area=results.features[currIndex];a.innerHTML=area.properties['name'];a.style.cursor='pointer';li.innerHTML=area.properties['name'];ul.appendChild(li);OpenLayers.Event.observe(li,'click',this.centerMap.bind(this,area.geometry.coordinates));OpenLayers.Event.observe(li,'mouseover',this.mouseOver.bind(this,li));OpenLayers.Event.observe(li,'mouseout',this.mouseOut.bind(this,li));}}else{this.div.innerHTML=OpenLayers.i18n("Nothing found.");}},mouseOver:function(elem,evt){elem.className='over';},mouseOut:function(elem,evt){elem.className='';},centerMap:function(point){var centrePoint=new OpenLayers.LonLat(point[0],point[1]);this.map.setCenter(centrePoint,this.zoom);},CLASS_NAME:"OpenLayers.Control.AreaSelector"});OpenLayers.Control.ArgParser=OpenLayers.Class(OpenLayers.Control,{center:null,zoom:null,layers:null,displayProjection:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);for(var i=0,len=this.map.controls.length;i<len;i++){var control=this.map.controls[i];if((control!=this)&&(control.CLASS_NAME=="OpenLayers.Control.ArgParser")){if(control.displayProjection!=this.displayProjection){this.displayProjection=control.displayProjection;}
break;}}
if(i==this.map.controls.length){var args=OpenLayers.Util.getParameters();if(args.layers){this.layers=args.layers;this.map.events.register('addlayer',this,this.configureLayers);this.configureLayers();}
if(args.lat&&args.lon){this.center=new OpenLayers.LonLat(parseFloat(args.lon),parseFloat(args.lat));if(args.zoom){this.zoom=parseInt(args.zoom);}
this.map.events.register('changebaselayer',this,this.setCenter);this.setCenter();}}},setCenter:function(){if(this.map.baseLayer){this.map.events.unregister('changebaselayer',this,this.setCenter);if(this.displayProjection){this.center.transform(this.displayProjection,this.map.getProjectionObject());}
this.map.setCenter(this.center,this.zoom);}},configureLayers:function(){if(this.layers.length==this.map.layers.length){this.map.events.unregister('addlayer',this,this.configureLayers);for(var i=0,len=this.layers.length;i<len;i++){var layer=this.map.layers[i];var c=this.layers.charAt(i);if(c=="B"){this.map.setBaseLayer(layer);}else if((c=="T")||(c=="F")){layer.setVisibility(c=="T");}}}},CLASS_NAME:"OpenLayers.Control.ArgParser"});OpenLayers.Control.Attribution=OpenLayers.Class(OpenLayers.Control,{separator:", ",initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);},destroy:function(){this.map.events.un({"removelayer":this.updateAttribution,"addlayer":this.updateAttribution,"changelayer":this.updateAttribution,"changebaselayer":this.updateAttribution,scope:this});OpenLayers.Control.prototype.destroy.apply(this,arguments);},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);this.map.events.on({'changebaselayer':this.updateAttribution,'changelayer':this.updateAttribution,'addlayer':this.updateAttribution,'removelayer':this.updateAttribution,'zoomend':this.updateAttribution,scope:this});this.updateAttribution();return this.div;},updateAttribution:function(){var attributions=[];if(this.map&&this.map.layers){for(var i=0,len=this.map.layers.length;i<len;i++){var layer=this.map.layers[i];if(layer.attribution&&layer.getVisibility()){attributions.push(layer.attribution);}else if(layer.attributionByZoom&&layer.getVisibility()){attributions.push(layer.attributionByZoom[this.map.getZoom()]);}}
this.div.innerHTML=attributions.join(this.separator);}},CLASS_NAME:"OpenLayers.Control.Attribution"});OpenLayers.Control.Button=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){},CLASS_NAME:"OpenLayers.Control.Button"});OpenLayers.Control.MapFeedback=OpenLayers.Class(OpenLayers.Control,{layer:null,feature:null,loadingImg:'loading_ani.gif',scriptName:'mapfeedback.py',projectInfo:{id:8,name:'PIE',client_name:'PIE',client_id:4},initialize:function(options){this.markerURL='http://static.media.thepieguide.com/markers/red_circle.png';this.markerURL='http://172.25.81.9/gmedia/markers/dot_purple2.png';if(typeof _project_info!='undefined'){this.projectInfo=_project_info;}
OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;this.loadingImgURL=OpenLayers.Util.getImagesLocation()+this.loadingImg;if(typeof jQuery=='undefined')
alert('FBC28:A required library is missing');},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.addEventType('mapfeedbackcontroladded');this.addLayer();},addLayer:function(){if(!this.layer){var url=this.markerURL;var size=new OpenLayers.Size(20,21);var offset=new OpenLayers.Pixel(-(size.w/2),-(size.h/2));var icon=new OpenLayers.Icon(url,size,offset);var style=new OpenLayers.Style({graphicXOffset:-10.0,graphicYOffset:-11.0,graphicWidth:20,graphicHeight:21,externalGraphic:this.markerURL});var sMap=new OpenLayers.StyleMap(style);this.layer=new OpenLayers.Layer.Vector('feedback_marker',{styleMap:sMap});this.map.addLayer(this.layer);}
if(!this.dragControl){this.dragControl=new OpenLayers.Control.DragFeature(this.layer);this.map.addControl(this.dragControl);}
if(!this.selectControl){this.selectControl=new OpenLayers.Control.SelectFeature(this.layer);this.map.addControl(this.selectControl);this.selectControl.activate();}},addFeature:function(){if(!this.layer||this.layer==null)
this.addLayer();if(!this.feature){var loc=this.map.getCenter().clone();var geom=new OpenLayers.Geometry.Point(loc.lon,loc.lat);this.feature=new OpenLayers.Feature.Vector(geom);this.layer.addFeatures([this.feature]);this.layer.events.register('featureselected',this,this.show);this.layer.events.register('featureunselected',this,this.onFeatureUnselect);}
else{this.feature.move(this.map.getCenter());}
this.dragControl.activate();},draw:function(){if(!this.feedbackLink){this.feedbackLink=document.createElement('div');this.feedbackLink.innerHTML=OpenLayers.i18n('Provide us your feedback or suggestion')
document.body.appendChild(this.feedbackLink);this.feedbackLink.id='mapFeedbackLinkDiv';this.feedbackLink.className='mapFeedbackLinkDiv';}
OpenLayers.Event.observe(this.feedbackLink,'click',this.addFeature.bind(this));if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='mapFeedbackContainerDiv';this.div.className='feedbackContainerDiv';}
this.hide();var title=document.createElement('div');title.innerHTML=OpenLayers.i18n('Map Feedback');title.className='title';this.div.appendChild(title);this.msgDiv=document.createElement('div');this.msgDiv.className='msgDivContainer';this.msgDiv.style.display='none';this.div.appendChild(this.msgDiv);this.buildForm();this.anchor=document.createElement('a');this.anchor.style.display='none';this.anchor.href='#'+this.div.id;document.body.appendChild(this.anchor);if(typeof jQuery!='undefined'){jQuery(this.anchor).fancybox({'scrolling':'no','titleShow':false,'transitionIn':'elastic','transitionOut':'elastic','autoDimensions':true,'autoScale':true,'overlayOpacity':0.8,'overlayColor':'#000','onClosed':function(){jQuery('#mapFeedbackContainerDiv').hide()}});}else{}
this.progressDiv=document.createElement('div');this.progressDiv.className='imgProgress';var pImg=document.createElement('img');pImg.src=this.loadingImgURL;var pMsg=document.createTextNode(OpenLayers.i18n('Thank you for your feedback. Please wait while we submit your feedback.'));this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';this.div.appendChild(this.progressDiv);this.map.events.triggerEvent("mapfeedbackcontroladded");},loadFeedbackTypes:function(){var params='req=feedbacktypes';var url=this.scriptURL+"?"+params;OpenLayers.loadURL(url,null,this,this.handleFeedbackTypes);return true;},handleFeedbackTypes:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){var feedbackTypes=response.feedback_types;if(feedbackTypes&&feedbackTypes.length>0){for(var ind=0,len=feedbackTypes.length;ind<len;ind++){this.fields.feedbackType.options[this.fields.feedbackType.options.length]=new Option(feedbackTypes[ind].name,feedbackTypes[ind].id);}}}else{}},failed:function(){this.showError('Some error occured. Please try again.');this.showForm();this.hideProgress(true);},handleResponse:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){this.showMsg('Your feedback has been submitted successfully.')}else{this.failed();}
this.hideProgress(true);},addOption:function(text,val,data){var option=document.createElement('option');option.value=val;option.text=text;},_show:function(){log(this);var feature=this.feature;if(feature){try{this.fields.featureName.value=feature.layer.name;this.fields.featureId.value=feature.data.id;this.fields.featureTypeId.value=feature.layer.typeId;this.fields.geometryType.value=feature.layer.types[feature.layer.typename].geo_type;}catch(e){log(e);}}
this.div.style.display='';this.reset();if(typeof jQuery!='undefined'){jQuery(this.anchor).trigger('click');}else{this.fireClickEvent(this.anchor);}},show:function(){this.onFeatureSelect(this.feature);},onFeatureSelect:function(feature){if(this.popup){this.map.removePopup(this.popup);this.popup=null;}
this.selectedFeature=feature;if(true){this.popup=feature.createPopup(true,this.closePopup);this.popup.featurePopup=this;feature.popup=this.popup;this.map.addPopup(this.popup);}
if(this.popup.contentDiv!=null){this.div.style.display='';this.popup.contentDiv.appendChild(this.div);this.popup.updateSize();}},closePopup:function(){if(typeof this.featurePopup!='undefined'){if(this.featurePopup.selectFeatureControl!=null){this.featurePopup.selectFeatureControl.unselectAll();}
if(typeof this.featurePopup.selectedFeature!='undefined'){this.featurePopup.onFeatureUnselect(this.featurePopup.selectedFeature);}}},onFeatureUnselect:function(feature){if(feature.popup!=null)
this.map.removePopup(feature.popup);if(this.popup!=null){this.popup=null;feature.popup.destroy();feature.popup=null;}
this.layer.removeFeatures(this.layer.features);this.feature=null;},hide:function(){this.div.style.display='none';},submitFeedback:function(evt){var check=this.validateForm();if(!check.success){this.showError(check.msg);return false;}
var params={req:'save',fid:this.fields.featureId.value,ftype:this.fields.featureTypeId.value,fname:this.fields.featureName.value,ftable:this.fields.featureTable.value,geo_type:this.fields.geometryType.value,name:this.fields.name.value,email:this.fields.email.value,type:this.fields.feedbackType.options[this.fields.feedbackType.selectedIndex].value,comment:this.fields.comment.value,notify:(this.fields.notify.checked)?'t':'f',client:this.projectInfo.client_id,client_name:this.projectInfo.client_name,project:this.projectInfo.id,project_title:this.projectInfo.title};var request=OpenLayers.Request.POST({url:this.scriptURL,data:OpenLayers.Util.getParameterString(params),headers:{"Content-Type":"application/x-www-form-urlencoded"},callback:this.handleResponse,scope:this});this.hideForm();this.hideError();this.showProgress(true);},reset:function(){this.showForm();this.hideProgress();this.hideError();this.fields.comment.value='';},resize:function(){jQuery.fancybox.resize();},showProgress:function(resize){this.progressDiv.style.display='';if(resize)this.resize();},hideProgress:function(resize){this.progressDiv.style.display='none';if(resize)this.resize();},showError:function(err){this.msgDiv.innerHTML=OpenLayers.i18n(err);this.msgDiv.style.display='block';this.resize();},showMsg:function(msg){this.msgDiv.innerHTML='<p>'+OpenLayers.i18n(msg)+'</p>';this.msgDiv.style.display='block';this.resize();},hideMsg:function(resize){this.msgDiv.style.display='none';if(resize)this.resize();},hideError:function(resize){this.msgDiv.style.display='none';if(resize)this.resize();},showForm:function(resize){this.form.style.display='';if(resize)this.resize();},hideForm:function(resize){this.form.style.display='none';if(resize)this.resize();},validateForm:function(){var msg='';if(this.fields.name.value.length<3){msg+='<li>Please input a valid name</li>';}
var email_str=this.fields.email.value;if(email_str.length<6||email_str.indexOf('@')==-1||email_str.indexOf('.')==-1){msg+='<li>Please provide a valid email address</li>';}
if(this.fields.comment.value.length<=0){msg+='<li>Please provide us with some details of problem</li>';}
if(msg!=''){msg='<ul>'+msg+'</ul>';return{success:false,msg:msg};}else{return{success:true};}},buildForm:function(){this.fields=new Object();this.fields.email=document.createElement('input');this.fields.name=document.createElement('input');this.fields.featureId=document.createElement('input');this.fields.featureId.className='hidden';this.fields.featureTypeId=document.createElement('input');this.fields.featureTypeId.className='hidden';this.fields.featureName=document.createElement('input');this.fields.featureName.className='hidden';this.fields.featureTable=document.createElement('input');this.fields.featureTable.className='hidden';this.fields.projectId=document.createElement('input');this.fields.projectId.className='hidden';this.fields.geometryType=document.createElement('input');this.fields.geometryType.className='hidden';this.fields.feedbackType=document.createElement('select');this.fields.comment=document.createElement('textarea');this.fields.notify=document.createElement('input');this.fields.notify.type='checkbox';this.form=document.createElement('form');var label=document.createElement('label');label.innerHTML='Your Name';this.form.appendChild(label);this.form.appendChild(this.fields.name);var label=document.createElement('label');label.innerHTML='Your Email';this.form.appendChild(label);this.form.appendChild(this.fields.email);this.form.appendChild(this.fields.featureId);this.form.appendChild(this.fields.featureTypeId);this.form.appendChild(this.fields.featureName);this.form.appendChild(this.fields.geometryType);this.form.appendChild(this.fields.featureTable);this.form.appendChild(this.fields.projectId);var label=document.createElement('label');label.innerHTML='What is wrong';this.form.appendChild(label);this.form.appendChild(this.fields.feedbackType);var label=document.createElement('label');label.innerHTML='Comments';this.form.appendChild(label);this.form.appendChild(this.fields.comment);var div=document.createElement('div');div.className='notifyDiv';div.appendChild(this.fields.notify);var label=document.createElement('span');label.innerHTML='Notify me when there is any action taken on this issue';div.appendChild(label);this.form.appendChild(div);this.loadFeedbackTypes();var submit=document.createElement('div');submit.className='submitButton';submit.innerHTML='Submit';this.form.appendChild(submit);OpenLayers.Event.observe(submit,'click',this.submitFeedback.bind(this));this.div.appendChild(this.form);},fireClickEvent:function(domElem){var aElem=(typeof domElem=='string')?document.getElementById(domElem):domElem;if(!aElem)return false;if(document.createEvent){var evt=document.createEvent('HTMLEvents');evt.initEvent('click',false,false);aElem.dispatchEvent(evt);}
else if(document.createEventObject){aElem.fireEvent('onclick');}},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},CLASS_NAME:"OpenLayers.Control.MapFeedback"});OpenLayers.Control.PieLayerSwitcher=OpenLayers.Class(OpenLayers.Control,{activeColor:"darkblue",layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,categories:null,active_category:null,help_text:'Click icon to activate layer',iconDimension:null,legendDimension:null,type:'select',initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.id='olLayerSwitcher';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();this.redraw();},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
this.dataLayersDiv.innerHTML="";var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
var layer_ul=document.createElement('ul');layer_ul.className='olLayerSwitcherUL';var visibleCount=0;for(var i=0;i<layers.length;i++){var layer=layers[i];if(layer.isBaseLayer)
continue;var isVisible=false;if(typeof layer.typename!='undefined'){isVisible=this.layerInActiveCategory(layer.typename);}
layer.setVisibility(isVisible);var li=document.createElement('li');if(isVisible&&(layer.displayInLayerSwitcher&&!layer.unlisted)){var lbl=document.createElement("span");lbl.className='label';lbl.innerHTML=layer.name;visibleCount++;li.className="selectedli";if(layer.types[layer.typename]){var symbol=layer.types[layer.typename].legend.legend;var img=document.createElement("img");img.src=symbol;if(this.legendDimension!=null){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}
li.appendChild(img);}
li.appendChild(lbl);layer_ul.appendChild(li);}}
this.dataLayersDiv.appendChild(layer_ul);this.legendDiv.style.display=(visibleCount==0)?'none':'';return this.div;},layerInActiveCategory:function(typename){if(this.active_category==null)
return false;var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}
return false;},onInputClick:function(e){if(!this.disabled){if(this.type=="radio"){this.checked=true;this.layer.map.setBaseLayer(this.layer,true);this.layer.map.events.triggerEvent("changebaselayer");}else{this.checked=!this.checked;this.control.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){this.nodraw=true;},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},loadContents:function(){var box=this.buildBoxModel(this.div);this.div=box.box;this.div.removeChild(box.title);this.body=box.body;this.body.appendChild(this.buildCategoryNav());OpenLayers.Event.observe(this.div,"mouseup",this.mouseUp.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"click",this.ignoreEvent);OpenLayers.Event.observe(this.div,"mousedown",this.mouseDown.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"dblclick",this.ignoreEvent);this.layersDiv=document.createElement("div");this.layersDiv.id="layersDiv";this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);if(this.legendDiv){this.legendDiv=this.buildLegendDiv();this.legendBody.appendChild(this.layersDiv);}
else{this.legendDiv=this.buildLegendDiv();this.legendBody.appendChild(this.layersDiv);this.body.appendChild(this.legendDiv);}},buildLegendDiv:function(){var box=this.buildBoxModel(this.legendDiv);this.legendDiv=box.box;this.legendTitle=box.title;this.legendBody=box.body;this.legendTitle.innerHTML=OpenLayers.i18n('Legend');return this.legendDiv;},buildBoxModel:function(box){box=(typeof box=='undefined')?document.createElement('div'):box;box.className='box';title=document.createElement('div');title.className='boxTitle';body=document.createElement('div');body.className='boxBody';box.appendChild(title);box.appendChild(body);return{box:box,title:title,body:body};},buildCategoryNav:function(){if(!this.categories)
return false;var div=document.createElement('div');div.className='layerImagesContainer';if(this.type=='select'){var elem=document.createElement('select');elem.options[elem.options.length]=new Option('--Select Mode--','',false,true);div.appendChild(elem);for(var i=0,l=this.categories.length;i<l;i++){var txt=this.categories[i]['title'];var val=this.categories[i]['id'];elem.options[elem.options.length]=new Option(txt,val,false,this.categories[i]['initial_visibility']);if(this.categories[i]['initial_visibility']){this.active_category=this.categories[i];}}
var actCat=this.activateCategory.bind(this,elem);OpenLayers.Event.observe(elem,'change',actCat);this.layerSelect=elem;}
else{for(var i=0,l=this.categories.length;i<l;i++){var elem=document.createElement('div');elem.innerHTML=this.categories[i]['title'];var img=document.createElement('img');img.title=this.categories[i]['title'];if(this.categories[i]['initial_visibility']){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];if(this.iconDimension){img.height=this.iconDimension.height;img.width=this.iconDimension.width;}
div.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}}
this.catsDiv=div;return div;},activateCategory:function(cat,evt){if(this.type=='select'){var catId=cat[cat.selectedIndex].value;this.active_category=null;for(var i=0,l=this.categories.length;i<l;i++){if(this.categories[i]['id']==catId){this.active_category=this.categories[i];}}}
else{this.catsDiv.innerHTML='';for(var i=0,l=this.categories.length;i<l;i++){var img=document.createElement('img');if(this.categories[i]['id']==cat){img.src=this.categories[i]['active_icon'];img.title=this.categories[i]['title'];this.active_category=this.categories[i];}
else{img.src=this.categories[i]['inactive_icon'];img.title=this.categories[i]['title'];}
this.catsDiv.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}}
this.redraw();return true;},getImage:function(img,dimensions){return;},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},CLASS_NAME:"OpenLayers.Control.PieLayerSwitcher"});OpenLayers.Control.CouncilRules=OpenLayers.Class(OpenLayers.Control,{drawFeature:true,layer:null,feature:null,contentDiv:null,zoom:3,scriptName:'dg.py',initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='councilRulesControlDiv';}
var h1=document.createElement('h1');h1.innerHTML=OpenLayers.i18n('Areas Covered');this.load();},load:function(){var params='req=parkingrules';var url=this.scriptURL+"?"+params;this.div.innerHTML=OpenLayers.i18n('Loading')+'...';OpenLayers.loadURL(url,null,this,this.handleResponse,this.failed);},failed:function(){this.div.innerHTML=OpenLayers.i18n('Nothing found.');},handleResponse:function(request){var response=eval('('+request.responseText+')');if(!response){this.div.innerHTML=OpenLayers.i18n('Nothing found.');return false;}
if(response.results['councils'].length>0&&response.results['colours'].length>0){this.div.innerHTML='';var ul=document.createElement('ul');ul.className='councilRulesUL';results=response.results;this.colours=results['colours'];for(var clen=this.colours.length,currInd=0;currInd<clen;currInd++){var colour=this.colours[currInd];var containerDiv=document.createElement('div');containerDiv.className='cpzLegendDiv';var colDiv=document.createElement('div');colDiv.className='cpzColourLegendDiv';colDiv.style.backgroundColor='#'+colour.colour;var txtDiv=document.createElement('div');txtDiv.className='cpzColourTextDiv';txtDiv.style.backgroundColor='#'+colour.colour;txtDiv.innerHTML=colour.description;containerDiv.appendChild(txtDiv);this.div.appendChild(containerDiv);}
var span=document.createElement('span');span.innerHTML="<strong>"+OpenLayers.i18n('For detailed parking rules by council, please select the council from the list below:')+"</strong>";this.div.appendChild(span);this.select=document.createElement('select');this.select.className='optCouncilRules';this.select.size=5;this.div.appendChild(this.select);this.councils=results['councils'];for(var len=this.councils.length,currIndex=0;currIndex<len;currIndex++){var li=document.createElement('li');var a=document.createElement('a');var council=this.councils[currIndex];this.select.options[this.select.options.length]=new Option(council['name'],currIndex,false,false);a.innerHTML=council['name'];a.style.cursor='pointer';li.innerHTML=council['name'];ul.appendChild(li);}
OpenLayers.Event.observe(this.select,'click',this.show.bind(this));}else{this.div.innerHTML="Nothing found...";}},addOption:function(text,val,data){var option=document.createElement('option');option.value=val;option.text=text;},mouseOver:function(elem,evt){elem.className='over';},mouseOut:function(elem,evt){elem.className='';},show:function(){var val=this.select[this.select.selectedIndex].value;var council=this.councils[val];var colour=this.getColour(council.picture_ref)['colour'];var content="<table class='infoTable' style='background-color:#"+colour+"'><tbody>";content+="<tr><th>"+OpenLayers.i18n('Disabled parking')+"</th>";content+="<td>"+council.bb_disabledbay_parking+"</td></tr>";content+="<tr><th>"+OpenLayers.i18n('Pay and display parking')+"</th>";content+="<td>"+council.bb_payanddisplay_parking+"</td></tr>";content+="<tr><th>"+OpenLayers.i18n('Shared use parking')+"</th>";content+="<td>"+council.bb_shareduse_parking+"</td></tr>";content+="<tr><th>"+OpenLayers.i18n('Resident parking')+"</th>";content+="<td>"+council.bb_resident_parking+"</td></tr>";content+="<tr><th>"+OpenLayers.i18n('Yellow line parking')+"</th>";content+="<td>"+council.bb_yellowline_parking+"</td></tr>";content+="<tr><th>"+OpenLayers.i18n('Council car park')+"</th>";content+="<td>"+council.bb_council_carpark+"</td></tr>";if(typeof(council.bb_council_notes)!='undefined'&&council.bb_council_notes!=''){content+="<tr><th>"+OpenLayers.i18n('Council notes')+"</th>";content+="<td>"+council.bb_council_notes+"</td></tr>";}
content+="</tbody></table>";jAlert(content,council.dg_name);},getColour:function(code){for(var len=this.colours.length,currIndex=0;currIndex<len;currIndex++){if((this.colours[currIndex]['code'].replace(/\ /g,''))==code)
return this.colours[currIndex];}
return false;},CLASS_NAME:"OpenLayers.Control.CouncilRules"});OpenLayers.Control.DGLayerSwitcher=OpenLayers.Class.create();OpenLayers.Control.DGLayerSwitcher.prototype=OpenLayers.Class.inherit(OpenLayers.Control,{activeColor:"darkblue",layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,categories:null,active_category:null,footer_text:'',legendDimension:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.id='olLayerSwitcher';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);this.map.events.register("changebaselayer",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();this.redraw();},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
this.clearAll();for(var i=0;i<layers.length;i++){var layer=layers[i];var baseLayer=layer.isBaseLayer;var hasTypename=(typeof layer.typename!='undefined')?true:false;var ul=this.getContainer(layer);var li=document.createElement('li');if(!baseLayer&&(layer.displayInLayerSwitcher&&!layer.unlisted)&&hasTypename){var checked=layer.getVisibility();var lbl=document.createElement("span");lbl.className='label';lbl.innerHTML=layer.name;if(layer.types[layer.typename]){if(layer.types[layer.typename].styles){if(layer.types[layer.typename].styles.length>0)
lbl.innerHTML=layer.types[layer.typename].styles[0].title;}}
if(checked){li.className="selectedli";}
if(!layer.inRange)
li.className=(li.className=='')?'disabledli':li.className+' disabledli';if(layer.types[layer.typename]){var symbol=layer.types[layer.typename].legend.legend;var img=document.createElement("img");img.src=symbol;if(this.legendDimension!=null){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}
li.appendChild(img);}
li.appendChild(lbl);if(ul){ul.appendChild(li);OpenLayers.Event.observe(li,"click",this.onLIClick.bind(this,layer));}}}
return this.div;},clearAll:function(){if(!this.categories)
return false;for(var i=0,l=this.categories.length;i<l;i++){this.categories[i]['container'].innerHTML="";}},getContainer:function(layer){if(!this.categories)
return false;for(var i=0,l=this.categories.length;i<l;i++){var layers=this.categories[i]['features'];for(var ind=0,len=layers.length;ind<len;ind++){if(this.categories[i]['features'][ind]==layer.typename)
return this.categories[i]['container'];}}},layerInActiveCategory:function(typename){if(this.active_category==null)
return false;var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}
return false;},onLIClick:function(layer,e){if(layer.inRange){layer.setVisibility(!layer.getVisibility());}
OpenLayers.Event.stop(e);},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},loadContents:function(){this.div.className='box';var title=document.createElement('div');title.className='title';title.innerHTML='facilities';this.body=document.createElement('div');this.body.className='body';this.div.appendChild(this.body);this.body.appendChild(this.buildCategoryNav());var footer=document.createElement('div');footer.className='footer';footer.innerHTML=this.footer_text;this.body.appendChild(footer);},buildCategoryNav:function(){if(!this.categories)
return false;var div=document.createElement('div');div.className='div_categories';for(var i=0,l=this.categories.length;i<l;i++){var elem=document.createElement('div');div.appendChild(elem);var title=document.createElement('div');title.className='title';var img=document.createElement('img');img.style.paddingRight=4;if(false)
if(this.categories[i]['active_icon']){img.src=this.categories[i]['active_icon'];img.height=15;img.width=16;title.appendChild(img);}
title.appendChild(document.createTextNode(this.categories[i]['title']));elem.appendChild(title);var ul=document.createElement('ul');elem.appendChild(ul);ul.className='olLayerSwitcherUL';this.categories[i]['container']=ul;}
this.catsDiv=div;return div;},activateCategory:function(cat,evt){this.catsDiv.innerHTML='';for(var i=0,l=this.categories.length;i<l;i++){var img=document.createElement('img');img.style.paddingRight=4;if(this.categories[i]['id']==cat){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];this.catsDiv.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.redraw();return true;},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},CLASS_NAME:"OpenLayers.Control.DGLayerSwitcher"});OpenLayers.Control.DGPdf=OpenLayers.Class(OpenLayers.Control,{drawFeature:true,layer:null,div:null,imagesBaseURL:'http://172.25.81.9/map/mj/images/',scriptURL:'http://172.25.81.9/map-bin/search.py',initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='DGPdfControlDiv';}
var img=document.createElement('img');img.src=this.imagesBaseURL+'button-searchsubmit.png';this.div.appendChild(img);OpenLayers.Event.observe(img,'click',this.search.bind(this));},pdfClick:function(){var post={};var width=this.map.div.offsetWidth;var height=this.map.div.offsetHeight;post.width=width;post.height=height;var c1=this.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(0,0));var c2=this.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(width,height));post.bbox=[];post.bbox[0]=c1.lon;post.bbox[1]=c2.lat;post.bbox[2]=c2.lon;post.bbox[3]=c1.lat;post.features=[];post.layers=[];var featurecount=0;var layers=map.getLayersBy("visibility",true);var extent=map.getExtent();for(var i=0,len=layers.length;i<len;i++){if(layers[i].inRange){if(typeof(layers[i].typename)!='undefined'){var layer=layers[i];var curr_layer={};curr_layer.typename=layer.typename;curr_layer.icon=layer.getTypeIcon(layer.typename);log(curr_layer.icon);curr_layer.title=layer.getTypeTitle(layer.typename);if(typeof(layer.features)!='undefined'){var features=[];for(var feat_ind=0,feat_len=layer.features.length;feat_ind<feat_len;feat_ind++){var feature=layer.features[feat_ind];if(feature.onScreen()){var feat={};var pixel=map.getViewPortPxFromLonLat(new OpenLayers.LonLat(feature.geometry.x,feature.geometry.y));feat.x=parseInt(pixel.x);feat.y=parseInt(pixel.y);features.push(feat);}}
curr_layer.features=features;}
post.layers.push(curr_layer);}}}
var jsontext=JSON.stringify(post);var form=document.createElement("form");form.setAttribute("method","post");form.setAttribute("action","pdf_create.php");var hiddenField=document.createElement("input");hiddenField.setAttribute("name","json");hiddenField.setAttribute("value",jsontext);form.appendChild(hiddenField);form.setAttribute("target","_blank");var pdfform=document.getElementById("invisibleform");pdfform.innerHTML="";pdfform.appendChild(form);form.submit();},CLASS_NAME:"OpenLayers.Control.DGPdf"});OpenLayers.Control.DGSearch=OpenLayers.Class.create();OpenLayers.Control.DGSearch=OpenLayers.Class(OpenLayers.Control,{drawFeature:true,updateGeom:false,inputField:null,layer:null,feature:null,div:null,contentDiv:null,searchResultsDiv:null,resultInfo:null,selectControl:null,dragControl:null,dragControlActivated:false,zoom:7,showMarker:true,lookup:'lstg',imagesBaseURL:'images/',scriptName:'search.py',scriptURL:'http://172.25.81.9/map-bin/search.py',restrictSearch:false,maxExtent:null,directSearch:true,initialize:function(options){this.markerURL='http://static.media.thepieguide.com/markers/red_circle.png';OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},draw:function(){this.addMarkerLayer();if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='dgSearchControlDiv';}
var h1=document.createElement('h1');h1.innerHTML=OpenLayers.i18n('Search');var formDiv=document.createElement('div');var p=document.createElement('p');p.innerHTML=OpenLayers.i18n('Enter postcode, street or place');formDiv.appendChild(p);var table=document.createElement('table');var tbody=document.createElement('tbody');var tr=document.createElement('tr');var td1=document.createElement('td');var td2=document.createElement('td');this.inputField=document.createElement('input');this.inputField.type='text';this.inputField.id=this.inputField.name='searchterm';td1.appendChild(this.inputField);var img=document.createElement('img');img.src=this.imagesBaseURL+'dg_arrow_right.gif';img.style.cursor='pointer';td2.appendChild(img);table.appendChild(tbody);tbody.appendChild(tr);tr.appendChild(td1);tr.appendChild(td2);formDiv.appendChild(table);this.div.appendChild(formDiv);OpenLayers.Event.observe(this.inputField,'keyup',this.sniffEnter.bind(this));OpenLayers.Event.observe(img,'click',this.search.bind(this));this.searchResultsDiv=document.createElement('div');this.searchResultsDiv.className='searchResultsDiv';this.div.appendChild(this.searchResultsDiv);var args=OpenLayers.Util.getArgs();if(args.q&&this.directSearch){this.inputField.value=args.q;if(this.map.baseLayer){this.search();}else{this.map.events.register('changebaselayer',this,this.runSearch);}}},runSearch:function(){this.map.events.unregister('changebaselayer',this,this.runSearch);this.search();},sniffEnter:function(evt){if(evt)
if(evt.keyCode==13)
this.search()},search:function(){var query=this.inputField.value;if(query.length==''){this.searchResultsDiv.innerHTML=OpenLayers.i18n('Please enter a valid postcode/street name to search');return false;}
var validPostcode=this.checkPostcode(this.inputField.value);if(validPostcode){this.inputField.value=query=validPostcode;this.lastSearch={lookup:'postcode',q:validPostcode}}
else{if((this.inputField.value).length<3){this.searchResultsDiv.innerHTML=OpenLayers.i18n('Please enter a valid postcode/street name to search');return false;}
else{this.lastSearch={lookup:'lstg',q:this.inputField.value}}}
var lookup=this.lastSearch.lookup;var params='q='+query+'&lookup='+lookup;if(this.restrictSearch){if(!this.maxExtent){this.maxExtent=this.map.maxExtent;}
var ext=this.maxExtent;var extent='&bbox='+ext.left+','+ext.bottom+','+ext.right+','+ext.top;params+=extent;}
var url=this.scriptURL+"?"+params;this.searchResultsDiv.innerHTML="<img src='"+this.imagesBaseURL+"spinner.gif' />";OpenLayers.loadURL(url,null,this,this.handleSearchResponse,this.searchFailed);},onPopupClose:function(evt){this.selectControl.unselect(this.feature);},onFeatureSelect:function(feature){popup=new OpenLayers.Popup.FramedCloud("chicken",feature.geometry.getBounds().getCenterLonLat(),null,"<div style='font-size:.8em'>Feature: "+feature.id+" "+' - attrs '+"</div>",null,true,this.onPopupClose);feature.popup=popup;this.map.addPopup(popup);},onFeatureUnselect:function(feature){this.map.removePopup(feature.popup);feature.popup.destroy();feature.popup=null;},addMarkerLayer:function(){if(typeof this.markerLayer=='undefined'){this.markerLayer=new OpenLayers.Layer.Markers('search_marker');this.map.addLayer(this.markerLayer);}},addMarker:function(result){if(!this.markerLayer)
this.addMarkerLayer();if(!this.marker){var geom=new OpenLayers.Geometry.fromWKT(result.geometry);var url=this.markerURL;var size=new OpenLayers.Size(35,35);var offset=new OpenLayers.Pixel(-(size.w/2),-(size.h/2));var icon=new OpenLayers.Icon(url,size,offset);var loc=new OpenLayers.LonLat(geom.x,geom.y);this.marker=new OpenLayers.Marker(loc,icon);this.markerLayer.addMarker(this.marker);}
else{var geom=new OpenLayers.Geometry.fromWKT(result.geometry);var loc=new OpenLayers.LonLat(geom.x,geom.y);this.marker.moveTo(this.map.getLayerPxFromLonLat(loc));}},searchFailed:function(){this.searchResultsDiv.innerHTML=OpenLayers.i18n('Nothing found.');},handleSearchResponse:function(request){var response=eval('('+request.responseText+')');if(!response)
this.searchResultsDiv.innerHTML=OpenLayers.i18n("We were unable to process this request. Please try again");if(response.results!=false){searchResults=response.results;var rec=(searchResults.length>1)?'records':'record'
if(searchResults.length==1){this.searchResultsDiv.innerHTML='';this.showResult(searchResults[0]);}
else{this.searchResultsDiv.innerHTML="<p>"+OpenLayers.i18n('Showing')+" "+searchResults.length+" "+OpenLayers.i18n('records')+"</p>";var ul=document.createElement('ul');ul.className='searchResultsUL';for(var len=searchResults.length,currIndex=0;currIndex<len;currIndex++){var li=document.createElement('li');var a=document.createElement('a');var result=searchResults[currIndex];var resultText='';if(this.lastSearch.lookup=='postcode')
resultText=result.postcode;else
if(this.lastSearch.lookup=='lstg'){resultText=result.name;resultText+=(typeof(result.district)!='undefined')?', '+result.district:'';}
li.innerHTML=resultText;li.style.cursor='pointer';ul.appendChild(li);OpenLayers.Event.observe(li,'click',this.showResult.bind(this,result));}
this.searchResultsDiv.appendChild(ul);}}else{this.searchResultsDiv.innerHTML=OpenLayers.i18n("Nothing found.");}},showResult:function(result){if(result){var geom=new OpenLayers.Geometry.fromWKT(result.geometry);if(this.showMarker){this.addMarker(result);}
this.map.setCenter(new OpenLayers.LonLat(geom.x,geom.y),this.zoom);}},centerMap:function(point){var centrePoint=new OpenLayers.LonLat(point[0],point[1]);centrePoint.transform(new OpenLayers.Projection('EPSG:4326'),this.map.getProjectionObject());this.map.setCenter(centrePoint,this.zoom);},isPostcode:function(str){var is_postcode=false;var postcode='';for(var i=0;i<str.length;i++)
if(str.charAt(i)!=' ')
postcode=postcode+str.charAt(i);if(postcode.length>8)
return false;if(this.isNumber(postcode.charAt(0))==true)
return false;if(this.isNumber(postcode.charAt(postcode.length-1))==true&&postcode.length<5)
return true;if(this.isNumber(postcode.charAt(postcode.length-2))==true&&postcode.length<5)
return true;var postcode_end=postcode.substr(postcode.length-3,3);var postcode_start=postcode.substr(0,postcode.length-3);if(this.isNumber(postcode_end.charAt(0))==false)
return false;if(this.isNumber(postcode_end.charAt(1))==true)
return false;if(this.isNumber(postcode_end.charAt(2))==true)
return false;var check=false;for(i=0;i<postcode_start.length;i++)
if(this.isNumber(postcode_start.charAt(i))==true)
check=true;if(check==false)
return false;return true;},isNumber:function(c){if(c=='0')return true;if(c=='1')return true;if(c=='2')return true;if(c=='3')return true;if(c=='4')return true;if(c=='5')return true;if(c=='6')return true;if(c=='7')return true;if(c=='8')return true;if(c=='9')return true;return false;},checkPostcode:function(toCheck){var alpha1="[abcdefghijklmnoprstuwyz]";var alpha2="[abcdefghklmnopqrstuvwxy]";var alpha3="[abcdefghjkstuw]";var alpha4="[abehmnprvwxy]";var alpha5="[abdefghjlnpqrstuwxyz]";var pcexp=new Array();pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}[0-9]{1}"+alpha3+"{1})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(/^(GIR)(\s*)(0AA)$/i);pcexp.push(/^(bfpo)(\s*)([0-9]{1,4})$/i);pcexp.push(/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);pcexp.push(/^([A-Z]{4})(\s*)(1ZZ)$/i);var postCode=toCheck;pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}[0-9]{1,2})(\\s*)([0-9]{1})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})(\\s*)([0-9]{1}"+alpha5+"{0,2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]?)$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]{1}"+alpha5+"{1,2})$","i"));var valid=false;for(var i=0;i<pcexp.length;i++){if(pcexp[i].test(postCode)){pcexp[i].exec(postCode);postCode=RegExp.$1.toUpperCase()+" "+RegExp.$3.toUpperCase();postCode=postCode.replace(/C\/O\s*/,"c/o ");valid=true;break;}}
if(valid){return postCode;}else return false;},CLASS_NAME:"OpenLayers.Control.DGSearch"});OpenLayers.Control.Feedback=OpenLayers.Class(OpenLayers.Control,{layer:null,dragStarted:false,layerZIndex:726,opacity:1,markerURL:'http://static.media.thepieguide.com/markers/dot_orange2.png',feature:null,loadingImg:'loading_ani.gif',scriptName:'feedback.py',title:'Feature Feedback',relocateFeatureLinkText:'Click to relocate feature',projectInfo:{id:8,name:'PIE',client_name:'PIE',client_id:4},confirmationEmail:false,confirmationEmailOptions:{email_body:"Thank you for your feedback."},mailerScript:"/commonjs/feedback-tool/mailer.php",commentLimit:0,disclaimerLink:false,commentHelpText:'Please provide as much detail as possible incl. Road Name, Feature Type (ie Loading bay) plus any other useful information or restrictions',initialize:function(options){if(typeof _project_info!='undefined'){this.projectInfo=_project_info;}
OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;this.loadingImgURL=OpenLayers.Util.getImagesLocation()+this.loadingImg;if(typeof jQuery=='undefined')
alert('FBC28:A required library is missing');},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.addEventType('feedbackcontroladded');this.addLayer();},addLayer:function(){if(!this.layer){var url=this.markerURL;var size=new OpenLayers.Size(20,21);var offset=new OpenLayers.Pixel(-(size.w/2),-(size.h/2));var icon=new OpenLayers.Icon(url,size,offset);var style=new OpenLayers.Style({graphicXOffset:-10.0,graphicYOffset:-11.0,graphicWidth:20,graphicHeight:21,externalGraphic:this.markerURL});var sMap=new OpenLayers.StyleMap(style);this.layer=new OpenLayers.Layer.Vector('feature_feedback_marker',{styleMap:sMap});this.map.addLayer(this.layer);this.layer.setZIndex(this.layerZIndex);this.layer.setVisibility(false);}
if(!this.dragControl){this.dragControl=new OpenLayers.Control.DragFeature(this.layer,{onComplete:this.featureDragCompleted,onStart:this.featureDragStarted});this.map.addControl(this.dragControl);}},addFeature:function(){if(!this.layer||this.layer==null)
this.addLayer();if(!this.feature){var loc=(this._updatedLonLat)?this._updatedLonLat.clone():this._feature.lonlat.clone();var geom=new OpenLayers.Geometry.Point(loc.lon,loc.lat);this.feature=new OpenLayers.Feature.Vector(geom);this.feature.popupClass=OpenLayers.Popup.FramedCloud;this.feature.popupSize=new OpenLayers.Size(250,150);this.layer.addFeatures([this.feature]);this.showFeature();}
else{var loc=(this._updatedLonLat)?this._updatedLonLat.clone():this._feature.lonlat.clone();this.feature.move(loc);this.showFeature();}
this.layer.setVisibility(true);this.dragControl.activate();this.layer.events.register('click',this,this.onClick);},featureDragCompleted:function(feature){this.layer.redraw();feature.popup.lonlat=new OpenLayers.LonLat(feature.geometry.x,feature.geometry.y);feature.popup.updatePosition();feature.popup.show();feature.popup.panIntoView();},featureDragStarted:function(feature){this.dragStarted=true;feature.popup.hide();},addPopup:function(){if(!this.popup){this.popup=this.feature.createPopup(true,this.closePopup);this.popup.featurePopup=this;this.feature.popup=this.popup;this.map.addPopup(this.popup);}
if(this.popup.contentDiv!=null){this.popup.contentDiv.innerHTML='';this._popupclose=document.createElement('a');this._popupclose.className='popupdonebutton';this._popupclose.innerHTML='Done';var p=document.createElement('p');p.innerHTML=OpenLayers.i18n("To relocate feature please move following marker on map. <br/>  <img src='"+this.markerURL+"'/><br/>Once done please click on <b>Done</b> button to return to feedback form.");this.popup.contentDiv.className='';this.popup.contentDiv.className='feedbackPopupContainer';this.popup.contentDiv.style.display='';this.popup.contentDiv.appendChild(p);this.popup.contentDiv.appendChild(this._popupclose);this.popup.autoSize=true;this.popup.setSize(new OpenLayers.Size(250,135));OpenLayers.Event.observe(this._popupclose,'click',this.removeFeature.bind(this));}},updatePopup:function(){this.popup.updateSize();this.popup.lonlat=new OpenLayers.LonLat(this.feature.geometry.x,this.feature.geometry.y);this.popup.updatePosition();this.popup.panIntoView();},showFeature:function(){if(!this.popup){this.addPopup();}
this.updatePopup();},closePopup:function(){if(typeof this.featurePopup!='undefined'){if(typeof this.featurePopup.feature!='undefined'){this.featurePopup.removeFeature();}}},removeFeature:function(){this._updatedLonLat=new OpenLayers.LonLat(this.feature.geometry.x,this.feature.geometry.y);if(this.feature.popup!=null)
this.map.removePopup(this.feature.popup);if(this.popup!=null){this.popup=null;this.feature.popup.destroy();this.feature.popup=null;}
this.layer.removeFeatures(this.layer.features);this.feature=null;this.dragControl.deactivate();this.layer.events.unregister('click',this,this.onClick);this.layer.setVisibility(false);this.relocateFeatureDone();},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='feedbackContainerDiv';this.div.className='feedbackContainerDiv';}
this.hide();var title=document.createElement('div');title.innerHTML=OpenLayers.i18n(this.title);title.className='title';this.div.appendChild(title);this.msgDiv=document.createElement('div');this.msgDiv.className='msgDivContainer';this.msgDiv.style.display='none';this.div.appendChild(this.msgDiv);this.buildForm();this.anchor=document.createElement('a');this.anchor.style.display='none';this.anchor.href='#'+this.div.id;document.body.appendChild(this.anchor);if(typeof jQuery!='undefined'){jQuery(this.anchor).fancybox({'scrolling':'no','titleShow':false,'transitionIn':'elastic','transitionOut':'elastic','autoDimensions':true,'autoScale':true,'overlayOpacity':0.8,'overlayColor':'#000','onClosed':function(){jQuery('#feedbackContainerDiv').hide()}});}else{}
this.progressDiv=document.createElement('div');this.progressDiv.className='imgProgress';var pImg=document.createElement('img');pImg.src=this.loadingImgURL;var pMsg=document.createTextNode(OpenLayers.i18n('Thank you for your feedback. Please wait while we submit your feedback.'));this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';this.div.appendChild(this.progressDiv);this.mapDivContainer=document.createElement('div');this.mapDivContainer.className='mapDivContainer';this.mapDiv=document.createElement('div');this.mapDivContainer.style.display='none';this.div.appendChild(this.mapDivContainer);this.map.events.triggerEvent("feedbackcontroladded");},loadFeedbackTypes:function(){var params='req=feedbacktypes';var url=this.scriptURL+"?"+params;OpenLayers.loadURL(url,null,this,this.handleFeedbackTypes);return true;},handleFeedbackTypes:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){var feedbackTypes=response.feedback_types;if(feedbackTypes&&feedbackTypes.length>0){for(var ind=0,len=feedbackTypes.length;ind<len;ind++){this.fields.feedbackType.options[this.fields.feedbackType.options.length]=new Option(feedbackTypes[ind].name,feedbackTypes[ind].id);}}}else{}},failed:function(){this.showError('Some error occurred. Please try again.');this.showForm();this.hideProgress(true);},handleResponse:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){this.showMsg('Your feedback has been submitted successfully.')
if(this.confirmationEmail)
this.sendEmail();}else{this.failed();}
this.hideProgress(true);},sendEmail:function(){var params={feedback_msg:this.confirmationEmailOptions.email_body,feedback_email:this.fields.email.value,feedback_name:this.fields.name.value};var request=OpenLayers.Request.POST({url:this.mailerScript,data:OpenLayers.Util.getParameterString(params),headers:{"Content-Type":"application/x-www-form-urlencoded"}});},addOption:function(text,val,data){var option=document.createElement('option');option.value=val;option.text=text;},show:function(feature){if(feature){this._feature=feature;try{this.fields.featureName.value=feature.layer.name;this.fields.featureId.value=feature.data.id;this.fields.featureTypeId.value=feature.layer.typeId;this.fields.geometryType.value=feature.layer.types[feature.layer.typename].geo_type;if(this.fields.geometryType.value=='POINT'){this.relocFeat.style.display='';}else{this.relocFeat.style.display='none';}}catch(e){log(e);}}
this.div.style.display='';this.reset();if(typeof jQuery!='undefined'){jQuery(this.anchor).trigger('click');}else{this.fireClickEvent(this.anchor);}},hide:function(){this.div.style.display='none';},relocateFeature:function(evt){jQuery.fancybox.close();this.addFeature();this.addPopup();this.hide();},relocateFeatureDone:function(evt){this.div.style.display='';if(typeof jQuery!='undefined'){jQuery(this.anchor).trigger('click');}else{this.fireClickEvent(this.anchor);}},submitFeedback:function(evt){var check=this.validateForm();if(!check.success){this.showError(check.msg);return false;}
var params={req:'save',fid:this.fields.featureId.value,ftype:this.fields.featureTypeId.value,fname:this.fields.featureName.value,ftable:this.fields.featureTable.value,geo_type:this.fields.geometryType.value,name:this.fields.name.value,email:this.fields.email.value,type:this.fields.feedbackType.options[this.fields.feedbackType.selectedIndex].value,comment:this.fields.comment.value,notify:(this.fields.notify.checked)?'t':'f',client:this.projectInfo.client_id,client_name:this.projectInfo.client_name,project:this.projectInfo.id,project_title:this.projectInfo.title};if(params.geo_type=='POINT'){params.x=(this._updatedLonLat)?this._updatedLonLat.lon:this._feature.geometry.x;params.y=(this._updatedLonLat)?this._updatedLonLat.lat:this._feature.geometry.y;}
var request=OpenLayers.Request.POST({url:this.scriptURL,data:OpenLayers.Util.getParameterString(params),headers:{"Content-Type":"application/x-www-form-urlencoded"},callback:this.handleResponse,scope:this});this.hideForm();this.hideError();this.showProgress(true);},reset:function(){this.showForm();this.hideProgress();this.hideError();this.fields.comment.value='';this.commentLimitInfo.innerHTML='';this._updatedLonLat=false;},resize:function(){jQuery.fancybox.resize();},showProgress:function(resize){this.progressDiv.style.display='';if(resize)this.resize();},hideProgress:function(resize){this.progressDiv.style.display='none';if(resize)this.resize();},showError:function(err){this.msgDiv.innerHTML=OpenLayers.i18n(err);this.msgDiv.style.display='block';this.resize();},showMsg:function(msg){this.msgDiv.innerHTML='<p>'+OpenLayers.i18n(msg)+'</p>';this.msgDiv.style.display='block';this.resize();},hideMsg:function(resize){this.msgDiv.style.display='none';if(resize)this.resize();},hideError:function(resize){this.msgDiv.style.display='none';if(resize)this.resize();},showForm:function(resize){this.form.style.display='';if(resize)this.resize();},hideForm:function(resize){this.form.style.display='none';if(resize)this.resize();},validateForm:function(){var msg='';if(this.fields.name.value.length<3){msg+='<li>Please input a valid name</li>';}
var email_str=this.fields.email.value;if(email_str.length<6||email_str.indexOf('@')==-1||email_str.indexOf('.')==-1){msg+='<li>Please provide a valid email address</li>';}
if(this.fields.comment.value.length<=0){msg+='<li>Please provide us with some details of problem</li>';}
if(msg!=''){msg='<ul>'+msg+'</ul>';return{success:false,msg:msg};}else{return{success:true};}},buildForm:function(){this.fields=new Object();this.fields.email=document.createElement('input');this.fields.name=document.createElement('input');this.fields.featureId=document.createElement('input');this.fields.featureId.className='hidden';this.fields.featureTypeId=document.createElement('input');this.fields.featureTypeId.className='hidden';this.fields.featureName=document.createElement('input');this.fields.featureName.className='hidden';this.fields.featureTable=document.createElement('input');this.fields.featureTable.className='hidden';this.fields.projectId=document.createElement('input');this.fields.projectId.className='hidden';this.fields.geometryType=document.createElement('input');this.fields.geometryType.className='hidden';this.fields.feedbackType=document.createElement('select');this.fields.comment=document.createElement('textarea');this.fields.notify=document.createElement('input');this.fields.notify.type='checkbox';this.form=document.createElement('form');var label=document.createElement('label');label.innerHTML='Your Name';this.form.appendChild(label);this.form.appendChild(this.fields.name);var label=document.createElement('label');label.innerHTML='Your Email';this.form.appendChild(label);this.form.appendChild(this.fields.email);this.form.appendChild(this.fields.featureId);this.form.appendChild(this.fields.featureTypeId);this.form.appendChild(this.fields.featureName);this.form.appendChild(this.fields.geometryType);this.form.appendChild(this.fields.featureTable);this.form.appendChild(this.fields.projectId);var label=document.createElement('label');label.innerHTML='What is wrong';this.form.appendChild(label);this.form.appendChild(this.fields.feedbackType);this.relocFeat=document.createElement('p');this.relocFeat.className='relocateFeature';this.form.appendChild(this.relocFeat);this.relocateFeatureA=document.createElement('a');this.relocateFeatureA.innerHTML=OpenLayers.i18n(this.relocateFeatureLinkText);this.relocFeat.appendChild(this.relocateFeatureA);OpenLayers.Event.observe(this.relocateFeatureA,'click',this.relocateFeature.bind(this));this.commentHelp=document.createElement('p');this.commentHelp.className='commentHelp';this.commentHelp.innerHTML=this.commentHelpText;this.form.appendChild(this.commentHelp);var label=document.createElement('label');label.innerHTML='Comments';this.form.appendChild(label);this.form.appendChild(this.fields.comment);var div=document.createElement('div');div.className='notifyDiv';div.appendChild(this.fields.notify);var label=document.createElement('span');label.innerHTML='Notify me when there is any action taken on this issue';div.appendChild(label);this.form.appendChild(div);this.loadFeedbackTypes();this.commentLimitInfo=document.createElement('p');this.commentLimitInfo.className='charLimitInfo';this.commentLimitInfo.innerHTML='&nbsp;';this.form.appendChild(this.commentLimitInfo);var submit=document.createElement('div');submit.className='submitButton';submit.innerHTML='Submit';this.form.appendChild(submit);if(this.disclaimerLink){var disclaimer=document.createElement('a');disclaimer.className='disclaimer';disclaimer.href=this.disclaimerLink;disclaimer.target='_blank';disclaimer.innerHTML='Disclaimer';this.form.appendChild(disclaimer);}
if(this.commentLimit>0){this.commentLimitInfo.innerHTML="Characters remaining: "+(this.commentLimit-this.fields.comment.value.length);OpenLayers.Event.observe(this.fields.comment,'keyup',this.checkLimit.bind(this,this.fields.comment,this.commentLimit,this.commentLimitInfo));}
OpenLayers.Event.observe(submit,'click',this.submitFeedback.bind(this));this.div.appendChild(this.form);},populateFeedbackTypes:function(){var types=['Feature is misplaced','Feature no longer exists','Information is incorrect','Other'];var vals=['misplaced','doesnotexist','dataupdate','other'];for(var i=0,l=types.length;i<l;i++){this.fields.feedbackType.options[this.fields.feedbackType.options.length]=new Option(types[i],vals[i]);}},onClick:function(evt){this.dragStarted=false;},fireClickEvent:function(domElem){var aElem=(typeof domElem=='string')?document.getElementById(domElem):domElem;if(!aElem)return false;if(document.createEvent){var evt=document.createEvent('HTMLEvents');evt.initEvent('click',false,false);aElem.dispatchEvent(evt);}
else if(document.createEventObject){aElem.fireEvent('onclick');}},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},checkLimit:function(elem,limit,infoElem,evt){if(elem.value.length>limit)
elem.value=elem.value.substring(0,limit);if(infoElem){infoElem.innerHTML="Characters remaining: "+(limit-elem.value.length);}},CLASS_NAME:"OpenLayers.Control.Feedback"});OpenLayers.Control.Feedback2=OpenLayers.Class(OpenLayers.Control,{layer:null,feature:null,loadingImg:'loading_ani.gif',scriptName:'feedback.py',title:'Feature Feedback',projectInfo:{id:8,name:'PIE',client_name:'PIE',client_id:4},confirmationEmail:false,confirmationEmailOptions:{email_body:"Thank you for your feedback."},mailerScript:"/commonjs/feedback-tool/mailer.php",commentLimit:0,disclaimerLink:false,commentHelpText:'Please provide as much detail as possible incl. Road Name, Feature Type (ie Loading bay) plus any other useful information or restrictions',initialize:function(options){if(typeof _project_info!='undefined'){this.projectInfo=_project_info;}
OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;this.loadingImgURL=OpenLayers.Util.getImagesLocation()+this.loadingImg;if(typeof jQuery=='undefined')
alert('FBC28:A required library is missing');},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.addEventType('feedbackcontroladded');},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='feedbackContainerDiv';this.div.className='feedbackContainerDiv';}
this.hide();var title=document.createElement('div');title.innerHTML=OpenLayers.i18n(this.title);title.className='title';this.div.appendChild(title);this.msgDiv=document.createElement('div');this.msgDiv.className='msgDivContainer';this.msgDiv.style.display='none';this.div.appendChild(this.msgDiv);this.buildForm();this.anchor=document.createElement('a');this.anchor.style.display='none';this.anchor.href='#'+this.div.id;document.body.appendChild(this.anchor);if(typeof jQuery!='undefined'){jQuery(this.anchor).fancybox({'scrolling':'no','titleShow':false,'transitionIn':'elastic','transitionOut':'elastic','autoDimensions':true,'autoScale':true,'overlayOpacity':0.8,'overlayColor':'#000','onClosed':function(){jQuery('#feedbackContainerDiv').hide()}});}else{}
this.progressDiv=document.createElement('div');this.progressDiv.className='imgProgress';var pImg=document.createElement('img');pImg.src=this.loadingImgURL;var pMsg=document.createTextNode(OpenLayers.i18n('Thank you for your feedback. Please wait while we submit your feedback.'));this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';this.div.appendChild(this.progressDiv);this.map.events.triggerEvent("feedbackcontroladded");},loadFeedbackTypes:function(){var params='req=feedbacktypes';var url=this.scriptURL+"?"+params;OpenLayers.loadURL(url,null,this,this.handleFeedbackTypes);return true;},handleFeedbackTypes:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){var feedbackTypes=response.feedback_types;if(feedbackTypes&&feedbackTypes.length>0){for(var ind=0,len=feedbackTypes.length;ind<len;ind++){this.fields.feedbackType.options[this.fields.feedbackType.options.length]=new Option(feedbackTypes[ind].name,feedbackTypes[ind].id);}}}else{}},failed:function(){this.showError('Some error occurred. Please try again.');this.showForm();this.hideProgress(true);},handleResponse:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){this.showMsg('Your feedback has been submitted successfully.')
if(this.confirmationEmail)
this.sendEmail();}else{this.failed();}
this.hideProgress(true);},sendEmail:function(){var params={feedback_msg:this.confirmationEmailOptions.email_body,feedback_email:this.fields.email.value,feedback_name:this.fields.name.value};var request=OpenLayers.Request.POST({url:this.mailerScript,data:OpenLayers.Util.getParameterString(params),headers:{"Content-Type":"application/x-www-form-urlencoded"}});},addOption:function(text,val,data){var option=document.createElement('option');option.value=val;option.text=text;},show:function(feature){if(feature){try{this.fields.featureName.value=feature.layer.name;this.fields.featureId.value=feature.data.id;this.fields.featureTypeId.value=feature.layer.typeId;this.fields.geometryType.value=feature.layer.types[feature.layer.typename].geo_type;}catch(e){log(e);}}
this.div.style.display='';this.reset();if(typeof jQuery!='undefined'){jQuery(this.anchor).trigger('click');}else{this.fireClickEvent(this.anchor);}},hide:function(){this.div.style.display='none';},submitFeedback:function(evt){var check=this.validateForm();if(!check.success){this.showError(check.msg);return false;}
var params={req:'save',fid:this.fields.featureId.value,ftype:this.fields.featureTypeId.value,fname:this.fields.featureName.value,ftable:this.fields.featureTable.value,geo_type:this.fields.geometryType.value,name:this.fields.name.value,email:this.fields.email.value,type:this.fields.feedbackType.options[this.fields.feedbackType.selectedIndex].value,comment:this.fields.comment.value,notify:(this.fields.notify.checked)?'t':'f',client:this.projectInfo.client_id,client_name:this.projectInfo.client_name,project:this.projectInfo.id,project_title:this.projectInfo.title};var request=OpenLayers.Request.POST({url:this.scriptURL,data:OpenLayers.Util.getParameterString(params),headers:{"Content-Type":"application/x-www-form-urlencoded"},callback:this.handleResponse,scope:this});this.hideForm();this.hideError();this.showProgress(true);},reset:function(){this.showForm();this.hideProgress();this.hideError();this.fields.comment.value='';this.commentLimitInfo.innerHTML='';},resize:function(){jQuery.fancybox.resize();},showProgress:function(resize){this.progressDiv.style.display='';if(resize)this.resize();},hideProgress:function(resize){this.progressDiv.style.display='none';if(resize)this.resize();},showError:function(err){this.msgDiv.innerHTML=OpenLayers.i18n(err);this.msgDiv.style.display='block';this.resize();},showMsg:function(msg){this.msgDiv.innerHTML='<p>'+OpenLayers.i18n(msg)+'</p>';this.msgDiv.style.display='block';this.resize();},hideMsg:function(resize){this.msgDiv.style.display='none';if(resize)this.resize();},hideError:function(resize){this.msgDiv.style.display='none';if(resize)this.resize();},showForm:function(resize){this.form.style.display='';if(resize)this.resize();},hideForm:function(resize){this.form.style.display='none';if(resize)this.resize();},validateForm:function(){var msg='';if(this.fields.name.value.length<3){msg+='<li>Please input a valid name</li>';}
var email_str=this.fields.email.value;if(email_str.length<6||email_str.indexOf('@')==-1||email_str.indexOf('.')==-1){msg+='<li>Please provide a valid email address</li>';}
if(this.fields.comment.value.length<=0){msg+='<li>Please provide us with some details of problem</li>';}
if(msg!=''){msg='<ul>'+msg+'</ul>';return{success:false,msg:msg};}else{return{success:true};}},buildForm:function(){this.fields=new Object();this.fields.email=document.createElement('input');this.fields.name=document.createElement('input');this.fields.featureId=document.createElement('input');this.fields.featureId.className='hidden';this.fields.featureTypeId=document.createElement('input');this.fields.featureTypeId.className='hidden';this.fields.featureName=document.createElement('input');this.fields.featureName.className='hidden';this.fields.featureTable=document.createElement('input');this.fields.featureTable.className='hidden';this.fields.projectId=document.createElement('input');this.fields.projectId.className='hidden';this.fields.geometryType=document.createElement('input');this.fields.geometryType.className='hidden';this.fields.feedbackType=document.createElement('select');this.fields.comment=document.createElement('textarea');this.fields.notify=document.createElement('input');this.fields.notify.type='checkbox';this.form=document.createElement('form');var label=document.createElement('label');label.innerHTML='Your Name';this.form.appendChild(label);this.form.appendChild(this.fields.name);var label=document.createElement('label');label.innerHTML='Your Email';this.form.appendChild(label);this.form.appendChild(this.fields.email);this.form.appendChild(this.fields.featureId);this.form.appendChild(this.fields.featureTypeId);this.form.appendChild(this.fields.featureName);this.form.appendChild(this.fields.geometryType);this.form.appendChild(this.fields.featureTable);this.form.appendChild(this.fields.projectId);var label=document.createElement('label');label.innerHTML='What is wrong';this.form.appendChild(label);this.form.appendChild(this.fields.feedbackType);this.commentHelp=document.createElement('p');this.commentHelp.className='commentHelp';this.commentHelp.innerHTML=this.commentHelpText;this.form.appendChild(this.commentHelp);var label=document.createElement('label');label.innerHTML='Comments';this.form.appendChild(label);this.form.appendChild(this.fields.comment);var div=document.createElement('div');div.className='notifyDiv';div.appendChild(this.fields.notify);var label=document.createElement('span');label.innerHTML='Notify me when there is any action taken on this issue';div.appendChild(label);this.form.appendChild(div);this.loadFeedbackTypes();this.commentLimitInfo=document.createElement('p');this.commentLimitInfo.className='charLimitInfo';this.commentLimitInfo.innerHTML='&nbsp;';this.form.appendChild(this.commentLimitInfo);var submit=document.createElement('div');submit.className='submitButton';submit.innerHTML='Submit';this.form.appendChild(submit);if(this.disclaimerLink){var disclaimer=document.createElement('a');disclaimer.className='disclaimer';disclaimer.href=this.disclaimerLink;disclaimer.target='_blank';disclaimer.innerHTML='Disclaimer';this.form.appendChild(disclaimer);}
if(this.commentLimit>0){this.commentLimitInfo.innerHTML="Characters remaining: "+(this.commentLimit-this.fields.comment.value.length);OpenLayers.Event.observe(this.fields.comment,'keyup',this.checkLimit.bind(this,this.fields.comment,this.commentLimit,this.commentLimitInfo));}
OpenLayers.Event.observe(submit,'click',this.submitFeedback.bind(this));this.div.appendChild(this.form);},populateFeedbackTypes:function(){var types=['Feature is misplaced','Feature no longer exists','Information is incorrect','Other'];var vals=['misplaced','doesnotexist','dataupdate','other'];for(var i=0,l=types.length;i<l;i++){this.fields.feedbackType.options[this.fields.feedbackType.options.length]=new Option(types[i],vals[i]);}},fireClickEvent:function(domElem){var aElem=(typeof domElem=='string')?document.getElementById(domElem):domElem;if(!aElem)return false;if(document.createEvent){var evt=document.createEvent('HTMLEvents');evt.initEvent('click',false,false);aElem.dispatchEvent(evt);}
else if(document.createEventObject){aElem.fireEvent('onclick');}},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},checkLimit:function(elem,limit,infoElem,evt){if(elem.value.length>limit)
elem.value=elem.value.substring(0,limit);if(infoElem){infoElem.innerHTML="Characters remaining: "+(limit-elem.value.length);}},CLASS_NAME:"OpenLayers.Control.Feedback2"});OpenLayers.Control.ImgLayerSwitcher=OpenLayers.Class.create();OpenLayers.Control.ImgLayerSwitcher.prototype=OpenLayers.Class.inherit(OpenLayers.Control,{activeColor:"darkblue",layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,categories:null,active_category:null,footer_text:'',legendDimension:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.id='olLayerSwitcher';this.footer_text='Click the icon to display on map';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);this.map.events.register("changebaselayer",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();this.redraw();},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
this.dataLayersDiv.innerHTML="";this.dataLayerInputs=new Array();var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
if(this.active_category)
this.catHead.innerHTML=this.active_category['title'];var layer_ul=document.createElement('ul');layer_ul.className='olLayerSwitcherUL';for(var i=0;i<layers.length;i++){var layer=layers[i];if(!this.layerInActiveCategory(layer.typename))
continue;var baseLayer=layer.isBaseLayer;var li=document.createElement('li');li.id="li_for_"+layer.name;if(!baseLayer&&(layer.displayInLayerSwitcher&&!layer.unlisted)){var checked=layer.getVisibility();var inputElem=document.createElement("input");inputElem.id="input_"+layer.name;inputElem.name=layer.name;inputElem.type="checkbox";inputElem.value=layer.name;inputElem.checked=checked;inputElem.defaultChecked=checked;inputElem.layer=layer;inputElem.control=this;if(!layer.inRange){inputElem.disabled=true;}
OpenLayers.Event.observe(inputElem,"mouseup",this.onInputClick.bindAsEventListener(inputElem));var lbl=document.createElement("span");lbl.className='label';lbl.id="label_for_"+layer.name;if(checked){lbl.innerHTML=layer.name;li.className="selectedli";}
else
lbl.innerHTML=layer.name;var br=document.createElement("br");this.dataLayerInputs.push(inputElem);if(layer.types[layer.typename]){var symbol=layer.types[layer.typename].legend.legend;var img=document.createElement("img");img.src=symbol;if(this.legendDimension!=null){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}
li.appendChild(img);}
li.appendChild(lbl);layer_ul.appendChild(li);OpenLayers.Event.observe(li,"click",this.onInputClick.bindAsEventListener(inputElem));}}
this.dataLayersDiv.appendChild(layer_ul);return this.div;},layerInActiveCategory:function(typename){if(this.active_category==null)
return false;var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}
return false;},onInputClick:function(e){if(!this.disabled){if(this.type=="radio"){this.checked=true;this.layer.map.setBaseLayer(this.layer,true);this.layer.map.events.triggerEvent("changebaselayer");}else{this.checked=!this.checked;this.control.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){this.nodraw=true;for(var i=0;i<this.dataLayerInputs.length;i++){var input=this.dataLayerInputs[i];var inputLi=document.getElementById("li_for_"+input.name);inputLi.className=input.checked?"selectedli":"";var visibility=input.layer.getVisibility();if(visibility!=input.checked){input.layer.setVisibility(input.checked);}}},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},loadContents:function(){this.div.className='box';var title=document.createElement('div');title.className='title';title.innerHTML='Choose a way of getting about for more facilities';this.div.appendChild(title);this.div.appendChild(this.buildCategoryNav());this.catHead=document.createElement('div');this.catHead.className='categoriesLabel';this.div.appendChild(this.catHead);this.body=document.createElement('div');this.body.className='body';this.div.appendChild(this.body);OpenLayers.Event.observe(this.div,"mouseup",this.mouseUp.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"click",this.ignoreEvent);OpenLayers.Event.observe(this.div,"mousedown",this.mouseDown.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"dblclick",this.ignoreEvent);this.layersDiv=document.createElement("div");this.layersDiv.id="layersDiv";this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);this.body.appendChild(this.layersDiv);var footer=document.createElement('div');footer.className='footer';footer.innerHTML=this.footer_text;this.body.appendChild(footer);},buildCategoryNav:function(){if(!this.categories)
return false;var div=document.createElement('div');div.className='categoriesHead';for(var i=0,l=this.categories.length;i<l;i++){var elem=document.createElement('div');elem.innerHTML=this.categories[i]['title'];var img=document.createElement('img');img.title=this.categories[i]['title'];if(this.categories[i]['initial_visibility']){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];div.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.catsDiv=div;return div;},activateCategory:function(cat,evt){this.catsDiv.innerHTML='';for(var i=0,l=this.categories.length;i<l;i++){var img=document.createElement('img');if(this.categories[i]['id']==cat){img.src=this.categories[i]['active_icon'];img.title=this.categories[i]['title'];this.active_category=this.categories[i];}
else{img.src=this.categories[i]['inactive_icon'];img.title=this.categories[i]['title'];}
this.catsDiv.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.redraw();return true;},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},CLASS_NAME:"OpenLayers.Control.ImgLayerSwitcher"});OpenLayers.Control.ImgLayerSwitcher=OpenLayers.Class.create();OpenLayers.Control.ImgLayerSwitcher.prototype=OpenLayers.Class.inherit(OpenLayers.Control,{activeColor:"darkblue",layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,categories:null,active_category:null,footer_text:'',legendDimension:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.id='olLayerSwitcher';this.footer_text='Click the icon to display on map';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);this.map.events.register("changebaselayer",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();this.redraw();},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
this.dataLayersDiv.innerHTML="";this.dataLayerInputs=new Array();var layers=this.getLayersInActiveCategory();if(this.active_category)
this.catHead.innerHTML=this.active_category['title'];var layer_ul=document.createElement('ul');layer_ul.className='olLayerSwitcherUL';for(var i=0;i<layers.length;i++){var layer=layers[i];var baseLayer=layer.isBaseLayer;var li=document.createElement('li');li.id="li_for_"+layer.name;if(!baseLayer&&(layer.displayInLayerSwitcher&&!layer.unlisted)){var checked=layer.getVisibility();var inputElem=document.createElement("input");inputElem.id="input_"+layer.name;inputElem.name=layer.name;inputElem.type="checkbox";inputElem.value=layer.name;inputElem.checked=checked;inputElem.defaultChecked=checked;inputElem.layer=layer;inputElem.control=this;if(!layer.inRange){inputElem.disabled=true;}
OpenLayers.Event.observe(inputElem,"mouseup",this.onInputClick.bindAsEventListener(inputElem));var lbl=document.createElement("span");lbl.className='label';lbl.id="label_for_"+layer.name;if(checked){lbl.innerHTML=layer.name;li.className="selectedli";}
else
lbl.innerHTML=layer.name;var br=document.createElement("br");this.dataLayerInputs.push(inputElem);if(layer.types[layer.typename]){var symbol=layer.types[layer.typename].legend.legend;var img=document.createElement("img");img.src=symbol;if(this.legendDimension!=null){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}
li.appendChild(img);}
li.appendChild(lbl);layer_ul.appendChild(li);OpenLayers.Event.observe(li,"click",this.onInputClick.bindAsEventListener(inputElem));}}
this.dataLayersDiv.appendChild(layer_ul);return this.div;},layerInActiveCategory:function(typename){if(this.active_category==null)
return false;var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}
return false;},getLayersInActiveCategory:function(){var layers=new Array();if(this.active_category==null)
return layers;var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){var l=this.map.getLayersBy('typename',features[i]);if(l.length>0)
layers.push(l[0]);}
return layers;},onInputClick:function(e){if(!this.disabled){if(this.type=="radio"){this.checked=true;this.layer.map.setBaseLayer(this.layer,true);this.layer.map.events.triggerEvent("changebaselayer");}else{this.checked=!this.checked;this.control.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){this.nodraw=true;for(var i=0;i<this.dataLayerInputs.length;i++){var input=this.dataLayerInputs[i];var inputLi=document.getElementById("li_for_"+input.name);inputLi.className=input.checked?"selectedli":"";var visibility=input.layer.getVisibility();if(visibility!=input.checked){input.layer.setVisibility(input.checked);}}},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},loadContents:function(){this.div.className='box';var title=document.createElement('div');title.className='title';title.innerHTML='Choose a way of getting about for more facilities';this.div.appendChild(title);this.div.appendChild(this.buildCategoryNav());this.catHead=document.createElement('div');this.catHead.className='categoriesLabel';this.div.appendChild(this.catHead);this.body=document.createElement('div');this.body.className='body';this.div.appendChild(this.body);OpenLayers.Event.observe(this.div,"mouseup",this.mouseUp.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"click",this.ignoreEvent);OpenLayers.Event.observe(this.div,"mousedown",this.mouseDown.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"dblclick",this.ignoreEvent);this.layersDiv=document.createElement("div");this.layersDiv.id="layersDiv";this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);this.body.appendChild(this.layersDiv);var footer=document.createElement('div');footer.className='footer';footer.innerHTML=this.footer_text;this.body.appendChild(footer);},buildCategoryNav:function(){if(!this.categories)
return false;var div=document.createElement('div');div.className='categoriesHead';for(var i=0,l=this.categories.length;i<l;i++){var elem=document.createElement('div');elem.innerHTML=this.categories[i]['title'];var img=document.createElement('img');img.title=this.categories[i]['title'];if(this.categories[i]['initial_visibility']){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];div.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.catsDiv=div;return div;},activateCategory:function(cat,evt){this.catsDiv.innerHTML='';for(var i=0,l=this.categories.length;i<l;i++){var img=document.createElement('img');if(this.categories[i]['id']==cat){img.src=this.categories[i]['active_icon'];img.title=this.categories[i]['title'];this.active_category=this.categories[i];}
else{img.src=this.categories[i]['inactive_icon'];img.title=this.categories[i]['title'];}
this.catsDiv.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.redraw();return true;},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},CLASS_NAME:"OpenLayers.Control.ImgLayerSwitcher"});OpenLayers.Control.ImgNearest=OpenLayers.Class.create();OpenLayers.Control.ImgNearest.prototype=OpenLayers.Class.inherit(OpenLayers.Control,{activeColor:"darkblue",layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,categories:null,active_category:null,footer_text:'',active_facility:null,legendDimension:null,maxResults:5,forceAutoZoomToExtent:true,clickedResults:null,selectedResults:null,results:[],iconsBaseURL:'http://172.25.81.9/map/mj/icons/',alphaIcons:'abcdefghijklmnopqrstuvwxyz',currentCharIndex:0,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.id='olImgNearest';this.footer_text='Click the icon to list nearest';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.drawControlStructure();this.redraw();},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
this.dataLayersDiv.innerHTML="";this.dataLayerInputs=new Array();var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
this.catHead.innerHTML=this.active_category['title'];var layer_ul=document.createElement('ul');layer_ul.className='olImgNearestUL';for(var i=0;i<layers.length;i++){var layer=layers[i];if(!this.layerInActiveCategory(layer.typename))
continue;var baseLayer=layer.isBaseLayer;var li=document.createElement('li');if(!baseLayer&&(layer.displayInLayerSwitcher&&!layer.unlisted)){var lbl=document.createElement('span');lbl.className='label';lbl.appendChild(document.createTextNode(layer.name));if(layer.types[layer.typename]){var symbol=layer.types[layer.typename].legend.legend;var img=document.createElement("img");img.src=symbol;if(this.legendDimension){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}
li.appendChild(img);}
li.appendChild(lbl);layer_ul.appendChild(li);OpenLayers.Event.observe(li,"click",this.findNearest.bind(this,layer));}}
this.dataLayersDiv.appendChild(layer_ul);},findNearest:function(facility,evt){this.clearMarkers();this.layersDiv.style.display='none';this.progressDiv.style.display='block';this.resultsDiv.innerHTML="";this.resultsDiv.style.display='block';this.active_facility=facility;var center=map.getCenter();var url='http://172.25.81.9/map-bin/findnearest.py?fid='+facility.typeId+'&x='+center.lon+'&y='+center.lat;OpenLayers.loadURL(url,null,this,this.handleNearestResponse,this.searchFailed);},showNav:function(){this.layersDiv.style.display='block';this.progressDiv.style.display='none';this.resultsDiv.style.display='none';},layerInActiveCategory:function(typename){var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}
return false;},onInputClick:function(e){if(!this.disabled){if(this.type=="radio"){this.checked=true;this.layer.map.setBaseLayer(this.layer,true);this.layer.map.events.triggerEvent("changebaselayer");}else{this.checked=!this.checked;this.control.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){this.nodraw=true;for(var i=0;i<this.dataLayerInputs.length;i++){var input=this.dataLayerInputs[i];var inputLi=document.getElementById("li_for_"+input.name);inputLi.className=input.checked?"selectedli":"";var visibility=input.layer.getVisibility();if(visibility!=input.checked){input.layer.setVisibility(input.checked);}}},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},drawControlStructure:function(){this.div.className='box';var title=document.createElement('div');title.className='title';title.innerHTML='Select service';this.div.appendChild(title);this.div.appendChild(this.buildCategoryNav());this.catHead=document.createElement('div');this.catHead.className='categoriesLabel';this.div.appendChild(this.catHead);this.body=document.createElement('div');this.body.className='body';this.div.appendChild(this.body);this.layersDiv=document.createElement("div");this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);this.body.appendChild(this.layersDiv);this.resultsDiv=document.createElement('div');this.resultsDiv.className='imgNearestResults';this.resultsDiv.style.display='none';this.body.appendChild(this.resultsDiv);this.progressDiv=document.createElement('div');this.progressDiv.className='imgNearestProgress';var pImg=document.createElement('img');pImg.src='images/loading_ani.gif';var pMsg=document.createTextNode('Please wait while we retrive information.');this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';this.body.appendChild(this.progressDiv);},buildCategoryNav:function(){if(!this.categories)
return false;var div=document.createElement('div');div.className='categoriesHead';for(var i=0,l=this.categories.length;i<l;i++){var elem=document.createElement('div');elem.innerHTML=this.categories[i]['title'];var img=document.createElement('img');img.style.paddingRight=4;if(this.categories[i]['initial_visibility']){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];div.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.catsDiv=div;return div;},activateCategory:function(cat,evt){this.catsDiv.innerHTML='';for(var i=0,l=this.categories.length;i<l;i++){var img=document.createElement('img');if(this.categories[i]['id']==cat){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];this.catsDiv.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.redraw();this.showNav();},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},handleNearestResponse:function(request){var response=eval('('+request.responseText+')');if(!response){this.resultsDiv.innerHTML='Some problem occured while retrieving requested information. Please try again.';}
if(request.status==200){var mainDiv=document.createElement('div');mainDiv.id='div_search_results';if(response.results['features'].length>0){if(this.active_facility.types[this.active_facility.typename]){var symbol=this.active_facility.types[this.active_facility.typename].legend.legend;}else{var sumbol='';}
var heading=document.createElement('div');heading.className='subtitle';var txt="Search results for <img src='"+symbol+"'> "+this.active_facility.name;heading.innerHTML=txt;this.resultsDiv.appendChild(heading);var helpText=document.createElement('p');helpText.innerHTML='Click on the service name to centre on the map and view full details';var aClear=document.createElement('a');aClear.innerHTML='Clear results';this.resultsDiv.appendChild(helpText);this.resultsDiv.appendChild(aClear);OpenLayers.Event.observe(aClear,'click',this.clearResults.bind(this));}
else{this.resultsDiv.innerHTML='<p>No results found.</p>';}
for(var len=response.results['features'].length,currIndex=0;currIndex<len;currIndex++){if(this.maxResults&&currIndex==this.maxResults)
break;var feat=response.results['features'][currIndex];var feat_name=(feat['properties']['name'])?feat['properties']['name']:this.active_facility.name;var distance=feat['properties']['distance'];var distance_in_miles=feat['properties']['distance_in_miles'];var dis_str=(distance/1000)+' Km ('+distance_in_miles+' miles)';var div=document.createElement('div');div.className='div_search_result_item';var img=document.createElement('img');img.src=this.iconsBaseURL+(currIndex+1)+'.png';var h3=document.createElement('h3');var a=document.createTextNode(feat_name);h3.appendChild(a);var h4=document.createElement('h4');h4.innerHTML=dis_str;var p=document.createElement('p');div.appendChild(img);div.appendChild(h3);div.appendChild(h4);div.appendChild(p);mainDiv.appendChild(div);var lonlat=new OpenLayers.LonLat(feat.geometry.coordinates[0],feat.geometry.coordinates[1])
var marker=this.addMarker(feat,currIndex+1);marker.events.register('click',marker,this.onMarkerClick.bind(this,marker));console.log(marker);var currResult={feature:feat,icon:img,marker:marker,marker_key:currIndex+1}
this.results.push(currResult);OpenLayers.Event.observe(h3,'click',this.onResultClick.bind(this,currResult,marker));}
this.resultsDiv.appendChild(mainDiv);if(this.forceAutoZoomToExtent)
this.autoZoom();}else{this.resultsDiv.innerHTML='<p>Some problem occured while retrieving requested information. Please try again.</p>';}
this.layersDiv.style.display='none';this.progressDiv.style.display='none';this.resultsDiv.style.display='block';},onMarkerClick:function(marker,evt){marker.onClick(marker,evt);},addMarkerLayer:function(){if(!this.markerLayer){this.markerLayer=new OpenLayers.Layer.Markers("Markers");this.map.addLayer(this.markerLayer);this.markerLayer.setZIndex(this.getMaxZIndexOfMapLayers());}},getMaxZIndexOfMapLayers:function(){var layers=map.layers;var maxZIndex=0;for(var ind=0,len=layers.length;ind<len;ind++){if(maxZIndex<layers[ind].getZIndex())
maxZIndex=layers[ind].getZIndex();}
return maxZIndex;},clearMarkers:function(){if(this.markerLayer){this.markerLayer.clearMarkers();}},clearResults:function(){if(this.markerLayer){this.markerLayer.clearMarkers();}
this.layersDiv.style.display='block';this.progressDiv.style.display='none';this.resultsDiv.style.display='none';},addMarker:function(data,id,evt){if(!this.markerLayer)
this.addMarkerLayer();var template=this.active_facility.getFeatureTemplate(this.active_facility.typename);var htmlContent=(template)?template.process(data.properties):'';var url=this.iconsBaseURL+id+'.png';var size=new OpenLayers.Size(31,36);var icon=new OpenLayers.Icon(url,size);var loc=new OpenLayers.LonLat(data.geometry.coordinates[0],data.geometry.coordinates[1]);var marker=new OpenLayers.Marker.TemplateMarker(loc,icon,htmlContent);marker.events.register('dblclick',marker,function(evt){console.log('dblclicked');OpenLayers.Event.stop(evt);});this.markerLayer.addMarker(marker);return marker;},centerOnMarker:function(lonlat,evt){this.map.panTo(lonlat);},onResultClick:function(result,marker,evt){this.map.panTo(result.marker.lonlat);result.icon.src=this.iconsBaseURL+result.marker_key+'_red.png';result.marker.setUrl(result.icon.src);marker.onClick(marker,evt);OpenLayers.Event.stop(evt);},autoZoom:function(){if(this.markerLayer&&this.markerLayer.markers.length>0)
this.map.zoomToExtent(this.markerLayer.getDataExtent());},CLASS_NAME:"OpenLayers.Control.ImgNearest"});OpenLayers.Control.ImgNearest=OpenLayers.Class(OpenLayers.Control,{layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,categories:null,active_category:null,footer_text:'',active_facility:null,legendDimension:null,maxResults:5,forceAutoZoomToExtent:true,clickedResults:null,selectedResults:[],results:[],iconsBaseURL:'http://172.25.81.9/map/mj/icons/',scriptURL:'http://172.25.81.9/map-bin/nearest.py',scriptName:'nearest.py',alphaIcons:'abcdefghijklmnopqrstuvwxyz',currentCharIndex:0,selectableMarkers:true,selectedResultsDiv:null,searchControl:null,loadingImg:'loading_ani.gif',distanceUnit:'km-mile',backButtonText:'Show List',backButtonDisplay:'top',decPointsInDistance:1,referencePoint:false,showDetails:false,showDetailsLinkText:['Show details','Hide details'],showDetailsInitialState:true,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.loadingImgURL=OpenLayers.Util.getImagesLocation()+this.loadingImg;this.id='olPieNearest';this.footer_text='Click the icon to list nearest';this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;this.iconsBaseURL="http://static.media.thepieguide.com/markers/";},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);this.map.events.register("addlayer",this,this.setMarkerLayerZIndex);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.drawControlStructure();this.redraw();this.preprocessTemplates();if(this.map){this.addMarkerLayer();}},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
this.dataLayersDiv.innerHTML="";this.dataLayerInputs=new Array();var layers=this.active_category['features'];this.catHead.innerHTML=this.active_category['title'];var layer_ul=document.createElement('ul');layer_ul.className='olPieNearestUL';for(var i=0;i<layers.length;i++){var layer=layers[i];var li=document.createElement('li');if(true){var lbl=document.createElement('span');lbl.className='label';lbl.appendChild(document.createTextNode(layer.name));var feature=layer.featuretypes[0];if(feature.geo_type=='POINT'){var symbol=feature.legend.legend;var img=document.createElement("img");img.src=symbol;if(this.legendDimension){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}else{img.height=feature.legend.legend_height;img.width=feature.legend.legend_width;}
li.appendChild(img);}
li.appendChild(lbl);layer_ul.appendChild(li);OpenLayers.Event.observe(li,"click",this.findNearest.bind(this,layer));}}
this.dataLayersDiv.appendChild(layer_ul);},findNearest:function(facility,evt){this.clearResultsAndUpdateMarkers();this.layersDiv.style.display='none';this.progressDiv.style.display='block';this.resultsDiv.innerHTML="";this.resultsDiv.style.display='block';this.active_facility=facility;this.referencePoint=false;if(this.searchControl){if(this.searchControl.lastResult){var geom=new OpenLayers.Geometry.fromWKT(this.searchControl.lastResult.geometry);var center=new OpenLayers.LonLat(geom.x,geom.y);this.referencePoint=center;}else{var center=map.getCenter();var result={geometry:'POINT('+center.lon+' '+center.lat+')'};this.searchControl.showMapCenter(result);this.referencePoint=center;}}
else{var center=map.getCenter();this.referencePoint=center;}
var url=this.scriptURL+'?fid='+facility.typeId+'&x='+center.lon+'&y='+center.lat;OpenLayers.loadURL(url,null,this,this.handleNearestResponse,this.searchFailed);},showNav:function(){this.layersDiv.style.display='block';this.progressDiv.style.display='none';this.resultsDiv.style.display='none';},layerInActiveCategory:function(typename){var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}
return false;},onInputClick:function(e){if(!this.disabled){if(this.type=="radio"){this.checked=true;this.layer.map.setBaseLayer(this.layer,true);this.layer.map.events.triggerEvent("changebaselayer");}else{this.checked=!this.checked;this.control.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){this.nodraw=true;for(var i=0;i<this.dataLayerInputs.length;i++){var input=this.dataLayerInputs[i];var inputLi=document.getElementById("li_for_"+input.name);inputLi.className=input.checked?"selectedli":"";var visibility=input.layer.getVisibility();if(visibility!=input.checked){input.layer.setVisibility(input.checked);}}},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},drawControlStructure:function(){this.div.className='box';var title=document.createElement('div');title.className='boxTitle';title.innerHTML='Find Nearest';this.div.appendChild(title);this.div.appendChild(this.buildCategoryNav());this.catHead=document.createElement('div');this.catHead.className='categoriesLabel';this.div.appendChild(this.catHead);if(this.categories.length==1)
this.catHead.style.display='none';this.body=document.createElement('div');this.body.className='body';this.div.appendChild(this.body);this.layersDiv=document.createElement("div");this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);this.body.appendChild(this.layersDiv);this.resultsDiv=document.createElement('div');this.resultsDiv.className='imgNearestResults';this.resultsDiv.style.display='none';this.body.appendChild(this.resultsDiv);this.progressDiv=document.createElement('div');this.progressDiv.className='imgNearestProgress';var pImg=document.createElement('img');pImg.src=this.loadingImgURL;var pMsg=document.createTextNode('Please wait while we retrive information.');this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';this.body.appendChild(this.progressDiv);},buildCategoryNav:function(){if(!this.categories){this.catsDiv=document.createElement('div');return this.catsDiv;}
this.active_category=this.categories[0];this.categories[0]['initial_visibility']=true;if(this.categories.length==1){this.catsDiv=document.createElement('div');return this.catsDiv;}
var div=document.createElement('div');div.className='categoriesHead';for(var i=0,l=this.categories.length;i<l;i++){var elem=document.createElement('div');elem.innerHTML=this.categories[i]['title'];var img=document.createElement('img');img.title=this.categories[i]['title'];if(this.categories[i]['initial_visibility']){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];div.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.catsDiv=div;return div;},preprocessTemplates:function(){for(var i=0,l=this.categories.length;i<l;i++){for(var ind=0,len=this.categories[i].features.length;ind<len;ind++){var template=this.categories[i].features[ind].featuretypes[0].template;try{var _template=TrimPath.parseTemplate(template);}catch(err){if(typeof console!='undefined')
console.log('WFS:getFeatureTemplate - > template parse error')
template="IMGNearest504: Error parsing data";var _template=TrimPath.parseTemplate(template);}
this.categories[i].features[ind].featuretypes[0]._template=_template;}}},activateCategory:function(cat,evt){this.catsDiv.innerHTML='';for(var i=0,l=this.categories.length;i<l;i++){var img=document.createElement('img');if(this.categories[i]['id']==cat){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];img.title=this.categories[i]['title'];}
else{img.src=this.categories[i]['inactive_icon'];img.title=this.categories[i]['title'];}
this.catsDiv.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.redraw();this.showNav();},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},handleNearestResponse:function(request){var noResults=false;try{var response=eval('('+request.responseText+')');}catch(e){var response=false;}
if(!response){this.resultsDiv.innerHTML='Some problem occurred while retrieving requested information. Please try again.';noResults=true;}
if(request.status==200){var mainDiv=document.createElement('div');mainDiv.id='divPieNearestResults';if(!response.results==false&&response.results['features'].length>0){if(this.active_facility){var active_facility=this.active_facility.featuretypes[0];if(active_facility.geo_type=='POINT'){var symbol=active_facility.legend.legend;var img=document.createElement('img');img.src=symbol;symbol=img;}else if(active_facility.geo_type=='LINESTRING'){var symbol=active_facility.styles[0];var border="0px solid "+symbol.strokeColor;var size=new OpenLayers.Size(15,5);var img=OpenLayers.Util.createDiv(null,null,size,null,'relative',border,'hidden',symbol.fillOpacity);img.style.background=symbol.strokeColor;img.style.marginTop='6px';img.style.cssFloat="left";img.className='img';symbol=img;symbol=document.createTextNode('');}else if(active_facility.geo_type=='POLYGON'){var symbol=active_category.styles[0];var border="1px solid "+symbol.strokeColor;var size=new OpenLayers.Size(15,15);var img=OpenLayers.Util.createDiv(null,null,size,null,'relative',border,'hidden',symbol.fillOpacity);img.style.background=symbol.fillColor;img.style.cssFloat="left";img.className='img';symbol=img;symbol=document.createTextNode('');}}else{var symbol='';}
var heading=document.createElement('div');heading.className='subtitle';heading.appendChild(document.createTextNode('Search results for '));heading.appendChild(symbol);heading.appendChild(document.createTextNode(" "+this.active_facility.name));this.resultsDiv.appendChild(heading);var helpText=document.createElement('p');helpText.innerHTML='Click on the service name to centre on the map and view full details';this.resultsDiv.appendChild(helpText);if(this.backButtonDisplay=='both'||this.backButtonDisplay=='top'){var aClear=document.createElement('a');aClear.className='aButton';aClear.href='javascript:void(0);';aClear.innerHTML=OpenLayers.i18n(this.backButtonText);aClear.title='Click to clear current results and show menu';this.resultsDiv.appendChild(aClear);OpenLayers.Event.observe(aClear,'click',this.clearResultsAndUpdateMarkers.bind(this));}}
else{this.resultsDiv.innerHTML='<p>No results found.</p>';noResults=true;}
if(response.results){for(var len=response.results['features'].length,currIndex=0;currIndex<len;currIndex++){if(this.maxResults&&currIndex==this.maxResults)
break;var feat=response.results['features'][currIndex];var feat_name=(feat['properties']['name'])?feat['properties']['name']:this.active_facility.name;var distance=feat['properties']['distance'];var distance_in_miles=feat['properties']['distance_in_miles'];var dis_str=(distance/1000)+' Km ('+distance_in_miles+' miles)';var dist_in_km=this.roundNumber(distance/1000,this.decPointsInDistance);var dist_in_miles=this.roundNumber(distance_in_miles,this.decPointsInDistance);if(this.distanceUnit=='km'){dis_str=dist_in_km+' Km';}else if(this.distanceUnit=='mile'){dis_str=dist_in_miles+' miles';}else if(this.distanceUnit=='km-mile'){dis_str=dist_in_km+' Km ('+dist_in_miles+' miles)';}else if(this.distanceUnit=='mile-km'){dis_str=dist_in_miles+' miles ('+dist_in_km+' Km)';}else{dis_str=dist_in-km+' Km ('+dist_in_miles+' miles)';}
var feat_id=(feat['properties']['id'])?feat['properties']['id']:0;var div=document.createElement('div');div.className='nearestResultItem';var alpha_key=null;var ind_exists=this.resultExistsInSelected(feat);var alreadySelected=(ind_exists==-1)?false:this.selectedResults[ind_exists];var icon_images={normal:this.iconsBaseURL+(currIndex+1)+'.png',clicked:this.iconsBaseURL+(currIndex+1)+'_red.png',selected:null};var status='normal';if(alreadySelected!=false){status='selected';alpha_key=alreadySelected.alpha_key;icon_images.selected=alreadySelected.icon_images['selected'];alreadySelected.icon_images=icon_images;}
var img=document.createElement('img');img.src=icon_images[status];if(alreadySelected!=false){this.selectedResults[ind_exists].icon=img;}
var h3=document.createElement('h3');var a=document.createTextNode(feat_name);h3.appendChild(a);var h4=document.createElement('h4');h4.innerHTML=dis_str;var p=document.createElement('p');div.appendChild(img);div.appendChild(h3);div.appendChild(h4);div.appendChild(p);mainDiv.appendChild(div);var lonlat=new OpenLayers.LonLat(feat.geometry.coordinates[0],feat.geometry.coordinates[1])
if(status=='selected'){if(alreadySelected.marker){var marker=alreadySelected.marker;}
else
var marker=this.addMarker(feat,(currIndex+1),icon_images[status]);}
else
var marker=this.addMarker(feat,(currIndex+1),icon_images[status]);var currResult={feature:feat,icon:img,icon_images:icon_images,status:status,marker:marker,alpha_key:alpha_key,marker_key:(currIndex+1),selected_result:alreadySelected,symbol:symbol,typename:this.active_facility.featuretypes[0].typename,template:this.active_facility.featuretypes[0]._template,name:this.active_facility.name,id:this.active_facility.featuretypes[0].typename+'_'+feat_id}
marker.events.register('click',marker,this.onMarkerClick.bind(this,currResult));this.results.push(currResult);OpenLayers.Event.observe(h3,'click',this.onResultClick.bind(this,currResult,marker));if(alreadySelected!=false){this.selectedResults[ind_exists]=currResult;}}
this.resultsDiv.appendChild(mainDiv);if(this.forceAutoZoomToExtent)
this.autoZoom();}else{this.resultsDiv.innerHTML='<p>Some problem occurred while retrieving requested information. Please try again.</p>';noResults=true;}}else{this.resultsDiv.innerHTML='<p>Some problem occurred while retrieving requested information. Please try again.</p>';noResults=true;}
if(noResults){var aBack=document.createElement('a');aBack.className='aButton';aBack.href='javascript:void(0);';aBack.innerHTML=OpenLayers.i18n(this.backButtonText);aBack.title='Click to show menu';this.resultsDiv.appendChild(aBack);OpenLayers.Event.observe(aBack,'click',this.showNav.bind(this));}else{if(this.backButtonDisplay=='both'||this.backButtonDisplay=='bottom'){var aClear2=document.createElement('a');aClear2.className='aButton';aClear2.href='javascript:void(0);';aClear2.innerHTML=OpenLayers.i18n(this.backButtonText);aClear2.title='Click to clear current results and show menu';this.resultsDiv.appendChild(aClear2);OpenLayers.Event.observe(aClear2,'click',this.clearResultsAndUpdateMarkers.bind(this));}}
this.layersDiv.style.display='none';this.progressDiv.style.display='none';this.resultsDiv.style.display='block';},resultExistsInSelected:function(feat){if(this.selectedResults!=null){if(this.selectedResults.length==0)
return-1;else{for(var ind=0,len=this.selectedResults.length;ind<len;ind++){var id=this.active_facility.typename+'_'+feat['properties']['id'];if(id==this.selectedResults[ind].id)
return ind;}}}
return-1;},updateSelectedResults:function(){for(var ind=0,len=this.selectedResults.length;ind<len;ind++){this.selectedResultsDiv.removeChild(this.selectedResults[ind].selected_result_div);this.selectResult(this.selectedResults[ind]);}},addMarkerLayer:function(){if(this.map)
if(!this.markerLayer){this.markerLayer=new OpenLayers.Layer.Markers("nearest_markers");this.map.addLayer(this.markerLayer);this.setMarkerLayerZIndex();}},setMarkerLayerZIndex:function(){if(this.markerLayer){this.markerLayer.setZIndex(this.getMaxZIndexOfMapLayers()+1);}},getMaxZIndexOfMapLayers:function(){var layers=map.layers;var maxZIndex=0;for(var ind=0,len=layers.length;ind<len;ind++){if(maxZIndex<layers[ind].getZIndex())
maxZIndex=layers[ind].getZIndex();}
return parseInt(maxZIndex);},clearResultsAndUpdateMarkers:function(){this.results=null;this.results=[];this.clearMarkers();this.clearResults();for(var ind=0,len=this.selectedResults.length;ind<len;ind++){this.selectedResults[ind].icon=null;this.markerLayer.addMarker(this.selectedResults[ind].marker);}},clearMarkers:function(){if(this.markerLayer){this.markerLayer.clearMarkers();}
if(this.popup){this.popup.destroy();this.popup=null;}},clearResults:function(){this.layersDiv.style.display='block';this.progressDiv.style.display='none';this.resultsDiv.style.display='none';},addMarker:function(data,id,img_url,evt){if(!this.markerLayer)
this.addMarkerLayer();var template=this.active_facility.featuretypes[0]._template;var htmlContent=(template)?template.process(data.properties):'';var url=img_url;var size=new OpenLayers.Size(31,36);var icon=new OpenLayers.Icon(url,size);var loc=new OpenLayers.LonLat(data.geometry.coordinates[0],data.geometry.coordinates[1]);var marker=new OpenLayers.Marker.TemplateMarker(loc,icon,htmlContent);this.markerLayer.addMarker(marker);return marker;},centerOnMarker:function(lonlat,evt){this.map.panTo(lonlat);},onResultClick:function(result,marker,evt){this.map.panTo(result.marker.lonlat);if(result.status!='selected'){result.status='clicked';result.icon.src=result.icon_images[result.status];result.marker.setUrl(result.icon.src);}
OpenLayers.Event.stop(evt);},selectedResultClicked:function(result,evt){this.map.panTo(result.marker.lonlat);OpenLayers.Event.stop(evt);},delSelectedResult:function(result,evt){this.selectedResultsDiv.removeChild(result.selected_result_div);result.selected_result_div=null;result.status='normal';var tempArr=[];for(var ind=0,len=this.selectedResults.length;ind<len;ind++){if(this.selectedResults[ind].status=='selected')
tempArr.push(this.selectedResults[ind]);}
this.selectedResults=tempArr;var exists=false;for(var idx=0,len=this.results.length;idx<len;idx++){if(this.results[idx].id==result.id){this.results[idx].status='normal';exists=true;break;}}
if(!exists){result.marker.destroy();}else{result.icon.src=result.icon_images[result.status];result.marker.setUrl(result.icon_images[result.status]);}},autoZoom:function(){if(this.markerLayer&&this.markerLayer.markers.length>0){var extent=this.markerLayer.getDataExtent();if(this.referencePoint){extent.extend(this.referencePoint);}
this.map.zoomToExtent(extent);}},onMarkerClick:function(result,evt){marker=result.marker;if(this.popup)
this.popup.destroy();var htmlContent=marker.htmlContent;if(this.selectableMarkers){if(!this.selectedResultsDiv){this.selectedResultsDiv=document.createElement('div');document.body.appendChild(this.selectedResultsDiv);}}
this.popup=new OpenLayers.Popup.FramedCloud("chicken",marker.lonlat,null,"<div style='font-size:.9em'>"+htmlContent+"</div>",null,true,this.onPopupClose);this.map.addPopup(this.popup);if(this.selectableMarkers&&result.status!='selected'){if(this.popup.contentDiv!=null){var d=document.createElement('div');d.style.position='relative';d.style.textAlign='right';var a=document.createElement('a');a.href="javascript: void(0);";a.innerHTML='Select';d.appendChild(a);this.popup.contentDiv.appendChild(d);}
this.popup.updateSize();OpenLayers.Event.observe(a,'click',this.selectResult.bind(this,result));}
OpenLayers.Event.stop(evt);},selectResult:function(result,evt){var feat=result.feature;var feat_name=(feat['properties']['name'])?feat['properties']['name']:this.active_facility.name;var distance=feat['properties']['distance'];var distance_in_miles=feat['properties']['distance_in_miles'];var dis_str=(distance/1000)+' Km ('+distance_in_miles+' miles)';var div=document.createElement('div');div.className='div_selected_destination_item';if(!result.alpha_key){if(this.currentCharIndex<this.alphaIcons.length)
result.alpha_key=this.alphaIcons.charAt([this.currentCharIndex++]);else
result.alpha_key='z';}
if(result.status!='selected'){result.status='selected';result.icon_images['selected']=this.iconsBaseURL+result.alpha_key+'_red.png';}
var img=document.createElement('img');result.icon.src=img.src=result.icon_images[result.status];result.marker.setUrl(img.src);var h3=document.createElement('h3');var a=document.createTextNode(feat_name);h3.appendChild(a);var h4=document.createElement('h4');h4.appendChild(result.symbol);h4.innerHTML+=result.name;var p=document.createElement('p');var delLink=document.createElement('a');delLink.href='javascript:void(0);';delLink.innerHTML='Delete';p.appendChild(delLink);if(this.showDetails){var detailsLink=document.createElement('a');detailsLink.href='javascript:void(0);';detailsLink.innerHTML=(this.showDetailsInitialState)?this.showDetailsLinkText[1]:this.showDetailsLinkText[0];p.appendChild(detailsLink);var detailsDiv=document.createElement('div');detailsDiv.className='selectedResultDetailsDiv';detailsDiv.innerHTML=result.template.process(result.feature.properties);detailsDiv.style.display=(this.showDetailsInitialState)?'':'none';}
div.appendChild(img);div.appendChild(h3);div.appendChild(h4);div.appendChild(p);if(this.showDetails)
div.appendChild(detailsDiv);this.selectedResultsDiv.appendChild(div);result.selected_result_div=div;result.selected=true;this.selectedResults.push(result);OpenLayers.Event.observe(h3,'click',this.selectedResultClicked.bind(this,result));OpenLayers.Event.observe(delLink,'click',this.delSelectedResult.bind(this,result));if(this.showDetails){OpenLayers.Event.observe(detailsLink,'click',this.toggleResultDetails.bind(this,detailsLink,detailsDiv));}
if(evt){var target=(evt.srcElement)?evt.srcElement:evt.target;target.style.display='none';this.popup.updateSize();OpenLayers.Event.stop(evt);}},toggleResultDetails:function(detailsLink,detailsDiv,evt){if(detailsDiv.style.display=='none'){detailsDiv.style.display='';detailsLink.innerHTML=this.showDetailsLinkText[1];}else{detailsDiv.style.display='none';detailsLink.innerHTML=this.showDetailsLinkText[0];}},onPopupClose:function(){this.hide();},searchFailed:function(){log('failed');this.progressDiv.style.display='none';this.showNav();},roundNumber:function(num,dec){var result=Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);return result;},CLASS_NAME:"OpenLayers.Control.ImgNearest"});OpenLayers.Control.LayerSwitcher=OpenLayers.Class(OpenLayers.Control,{activeColor:"darkblue",layerStates:null,layersDiv:null,baseLayersDiv:null,baseLayers:null,dataLbl:null,dataLayersDiv:null,dataLayers:null,minimizeDiv:null,maximizeDiv:null,ascending:true,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.layerStates=[];},destroy:function(){OpenLayers.Event.stopObservingElement(this.div);OpenLayers.Event.stopObservingElement(this.minimizeDiv);OpenLayers.Event.stopObservingElement(this.maximizeDiv);this.clearLayersArray("base");this.clearLayersArray("data");this.map.events.un({"addlayer":this.redraw,"changelayer":this.redraw,"removelayer":this.redraw,"changebaselayer":this.redraw,scope:this});OpenLayers.Control.prototype.destroy.apply(this,arguments);},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.on({"addlayer":this.redraw,"changelayer":this.redraw,"removelayer":this.redraw,"changebaselayer":this.redraw,scope:this});},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();if(!this.outsideViewport){this.minimizeControl();}
this.redraw();return this.div;},clearLayersArray:function(layersType){var layers=this[layersType+"Layers"];if(layers){for(var i=0,len=layers.length;i<len;i++){var layer=layers[i];OpenLayers.Event.stopObservingElement(layer.inputElem);OpenLayers.Event.stopObservingElement(layer.labelSpan);}}
this[layersType+"LayersDiv"].innerHTML="";this[layersType+"Layers"]=[];},checkRedraw:function(){var redraw=false;if(!this.layerStates.length||(this.map.layers.length!=this.layerStates.length)){redraw=true;}else{for(var i=0,len=this.layerStates.length;i<len;i++){var layerState=this.layerStates[i];var layer=this.map.layers[i];if((layerState.name!=layer.name)||(layerState.inRange!=layer.inRange)||(layerState.id!=layer.id)||(layerState.visibility!=layer.visibility)){redraw=true;break;}}}
return redraw;},redraw:function(){if(!this.checkRedraw()){return this.div;}
this.clearLayersArray("base");this.clearLayersArray("data");var containsOverlays=false;var containsBaseLayers=false;var len=this.map.layers.length;this.layerStates=new Array(len);for(var i=0;i<len;i++){var layer=this.map.layers[i];this.layerStates[i]={'name':layer.name,'visibility':layer.visibility,'inRange':layer.inRange,'id':layer.id};}
var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
for(var i=0,len=layers.length;i<len;i++){var layer=layers[i];var baseLayer=layer.isBaseLayer;if(layer.displayInLayerSwitcher){if(baseLayer){containsBaseLayers=true;}else{containsOverlays=true;}
var checked=(baseLayer)?(layer==this.map.baseLayer):layer.getVisibility();var inputElem=document.createElement("input");inputElem.id=this.id+"_input_"+layer.name;inputElem.name=(baseLayer)?"baseLayers":layer.name;inputElem.type=(baseLayer)?"radio":"checkbox";inputElem.value=layer.name;inputElem.checked=checked;inputElem.defaultChecked=checked;if(!baseLayer&&!layer.inRange){inputElem.disabled=true;}
var context={'inputElem':inputElem,'layer':layer,'layerSwitcher':this};OpenLayers.Event.observe(inputElem,"mouseup",OpenLayers.Function.bindAsEventListener(this.onInputClick,context));var labelSpan=document.createElement("span");if(!baseLayer&&!layer.inRange){labelSpan.style.color="gray";}
labelSpan.innerHTML=layer.name;labelSpan.style.verticalAlign=(baseLayer)?"bottom":"baseline";OpenLayers.Event.observe(labelSpan,"click",OpenLayers.Function.bindAsEventListener(this.onInputClick,context));var br=document.createElement("br");var groupArray=(baseLayer)?this.baseLayers:this.dataLayers;groupArray.push({'layer':layer,'inputElem':inputElem,'labelSpan':labelSpan});var groupDiv=(baseLayer)?this.baseLayersDiv:this.dataLayersDiv;groupDiv.appendChild(inputElem);groupDiv.appendChild(labelSpan);groupDiv.appendChild(br);}}
this.dataLbl.style.display=(containsOverlays)?"":"none";this.baseLbl.style.display=(containsBaseLayers)?"":"none";return this.div;},onInputClick:function(e){if(!this.inputElem.disabled){if(this.inputElem.type=="radio"){this.inputElem.checked=true;this.layer.map.setBaseLayer(this.layer);}else{this.inputElem.checked=!this.inputElem.checked;this.layerSwitcher.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){for(var i=0,len=this.baseLayers.length;i<len;i++){var layerEntry=this.baseLayers[i];if(layerEntry.inputElem.checked){this.map.setBaseLayer(layerEntry.layer,false);}}
for(var i=0,len=this.dataLayers.length;i<len;i++){var layerEntry=this.dataLayers[i];layerEntry.layer.setVisibility(layerEntry.inputElem.checked);}},maximizeControl:function(e){this.div.style.width="20em";this.div.style.height="";this.showControls(false);if(e!=null){OpenLayers.Event.stop(e);}},minimizeControl:function(e){this.div.style.width="0px";this.div.style.height="0px";this.showControls(true);if(e!=null){OpenLayers.Event.stop(e);}},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},loadContents:function(){this.div.style.position="absolute";this.div.style.top="25px";this.div.style.right="0px";this.div.style.left="";this.div.style.fontFamily="sans-serif";this.div.style.fontWeight="bold";this.div.style.marginTop="3px";this.div.style.marginLeft="3px";this.div.style.marginBottom="3px";this.div.style.fontSize="smaller";this.div.style.color="white";this.div.style.backgroundColor="transparent";OpenLayers.Event.observe(this.div,"mouseup",OpenLayers.Function.bindAsEventListener(this.mouseUp,this));OpenLayers.Event.observe(this.div,"click",this.ignoreEvent);OpenLayers.Event.observe(this.div,"mousedown",OpenLayers.Function.bindAsEventListener(this.mouseDown,this));OpenLayers.Event.observe(this.div,"dblclick",this.ignoreEvent);this.layersDiv=document.createElement("div");this.layersDiv.id=this.id+"_layersDiv";this.layersDiv.style.paddingTop="5px";this.layersDiv.style.paddingLeft="10px";this.layersDiv.style.paddingBottom="5px";this.layersDiv.style.paddingRight="75px";this.layersDiv.style.backgroundColor=this.activeColor;this.layersDiv.style.width="100%";this.layersDiv.style.height="100%";this.baseLbl=document.createElement("div");this.baseLbl.innerHTML=OpenLayers.i18n("baseLayer");this.baseLbl.style.marginTop="3px";this.baseLbl.style.marginLeft="3px";this.baseLbl.style.marginBottom="3px";this.baseLayersDiv=document.createElement("div");this.baseLayersDiv.style.paddingLeft="10px";this.dataLbl=document.createElement("div");this.dataLbl.innerHTML=OpenLayers.i18n("overlays");this.dataLbl.style.marginTop="3px";this.dataLbl.style.marginLeft="3px";this.dataLbl.style.marginBottom="3px";this.dataLayersDiv=document.createElement("div");this.dataLayersDiv.style.paddingLeft="10px";if(this.ascending){this.layersDiv.appendChild(this.baseLbl);this.layersDiv.appendChild(this.baseLayersDiv);this.layersDiv.appendChild(this.dataLbl);this.layersDiv.appendChild(this.dataLayersDiv);}else{this.layersDiv.appendChild(this.dataLbl);this.layersDiv.appendChild(this.dataLayersDiv);this.layersDiv.appendChild(this.baseLbl);this.layersDiv.appendChild(this.baseLayersDiv);}
this.div.appendChild(this.layersDiv);OpenLayers.Rico.Corner.round(this.div,{corners:"tl bl",bgColor:"transparent",color:this.activeColor,blend:false});OpenLayers.Rico.Corner.changeOpacity(this.layersDiv,0.75);var imgLocation=OpenLayers.Util.getImagesLocation();var sz=new OpenLayers.Size(18,18);var img=imgLocation+'layer-switcher-maximize.png';this.maximizeDiv=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_MaximizeDiv",null,sz,img,"absolute");this.maximizeDiv.style.top="5px";this.maximizeDiv.style.right="0px";this.maximizeDiv.style.left="";this.maximizeDiv.style.display="none";OpenLayers.Event.observe(this.maximizeDiv,"click",OpenLayers.Function.bindAsEventListener(this.maximizeControl,this));this.div.appendChild(this.maximizeDiv);var img=imgLocation+'layer-switcher-minimize.png';var sz=new OpenLayers.Size(18,18);this.minimizeDiv=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_MinimizeDiv",null,sz,img,"absolute");this.minimizeDiv.style.top="5px";this.minimizeDiv.style.right="0px";this.minimizeDiv.style.left="";this.minimizeDiv.style.display="none";OpenLayers.Event.observe(this.minimizeDiv,"click",OpenLayers.Function.bindAsEventListener(this.minimizeControl,this));this.div.appendChild(this.minimizeDiv);},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.isMouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.isMouseDown){this.isMouseDown=false;this.ignoreEvent(evt);}},CLASS_NAME:"OpenLayers.Control.LayerSwitcher"});OpenLayers.Control.LayerSwitcher1=OpenLayers.Class.create();OpenLayers.Control.LayerSwitcher1.prototype=OpenLayers.Class.inherit(OpenLayers.Control,{activeColor:"darkblue",activeCSSClass:"selected",layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.id='olLayerSwitcher';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);this.map.events.register("changebaselayer",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();this.redraw();},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
this.dataLayersDiv.innerHTML="";this.dataLayerInputs=new Array();var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
var layer_ul=document.createElement('ul');layer_ul.className='olLayerSwitcherUL';for(var i=0;i<layers.length;i++){var layer=layers[i];var baseLayer=layer.isBaseLayer;var li=document.createElement('li');if(!baseLayer&&(layer.displayInLayerSwitcher&&!layer.unlisted)){var checked=layer.getVisibility();var inputElem=document.createElement("input");inputElem.id="input_"+layer.name;inputElem.name=layer.name;inputElem.type="checkbox";inputElem.value=layer.name;inputElem.checked=checked;inputElem.defaultChecked=checked;inputElem.layer=layer;inputElem.control=this;if(!layer.inRange){inputElem.disabled=true;}
OpenLayers.Event.observe(inputElem,"mouseup",this.onInputClick.bindAsEventListener(inputElem));var lbl=document.createElement("label");lbl.id="label_for_"+layer.name;lbl.style.cursor="pointer";lbl.setAttribute('for',"input_"+layer.name);if(!layer.inRange){lbl.style.color="gray";}
if(checked){lbl.innerHTML=layer.name;lbl.className="selectedlabel";}
else
lbl.innerHTML=layer.name;OpenLayers.Event.observe(lbl,"click",this.onInputClick.bindAsEventListener(inputElem));var br=document.createElement("br");this.dataLayerInputs.push(inputElem);li.appendChild(inputElem);li.appendChild(lbl);layer_ul.appendChild(li);}}
this.dataLayersDiv.appendChild(layer_ul);return this.div;},onInputClick:function(e){if(!this.disabled){if(this.type=="radio"){this.checked=true;this.layer.map.setBaseLayer(this.layer,true);this.layer.map.events.triggerEvent("changebaselayer");}else{this.checked=!this.checked;this.control.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){this.nodraw=true;for(var i=0;i<this.dataLayerInputs.length;i++){var input=this.dataLayerInputs[i];var inputLabel=document.getElementById("label_for_"+input.name);inputLabel.className=input.checked?"selectedlabel":"";var visibility=input.layer.getVisibility();if(visibility!=input.checked){input.layer.setVisibility(input.checked);}}},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},loadContents:function(){this.div.className='box';this.titleDiv=document.createElement('div');this.titleDiv.className='title';var title=document.createElement('h2');title.innerHTML='Category';this.titleDiv.appendChild(title);this.div.appendChild(this.titleDiv);this.body=document.createElement('div');this.body.className='body';this.div.appendChild(this.body);OpenLayers.Event.observe(this.div,"mouseup",this.mouseUp.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"click",this.ignoreEvent);OpenLayers.Event.observe(this.div,"mousedown",this.mouseDown.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"dblclick",this.ignoreEvent);this.layersDiv=document.createElement("div");this.layersDiv.id="layersDiv";this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);this.body.appendChild(this.layersDiv);},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},CLASS_NAME:"OpenLayers.Control.LayerSwitcher1"});OpenLayers.Control.LayerSwitcher2=OpenLayers.Class.create();OpenLayers.Control.LayerSwitcher2.prototype=OpenLayers.Class.inherit(OpenLayers.Control,{activeColor:"darkblue",layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.id='olLayerSwitcher';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);this.map.events.register("changebaselayer",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();this.redraw();},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
this.dataLayersDiv.innerHTML="";this.dataLayerInputs=new Array();var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
var layer_ul=document.createElement('ul');layer_ul.className='olLayerSwitcherUL';for(var i=0;i<layers.length;i++){var layer=layers[i];var baseLayer=layer.isBaseLayer;var li=document.createElement('li');li.id="li_for_"+layer.name;if(!baseLayer&&(layer.displayInLayerSwitcher&&!layer.unlisted)){var checked=layer.getVisibility();var inputElem=document.createElement("input");inputElem.id="input_"+layer.name;inputElem.name=layer.name;inputElem.type="checkbox";inputElem.value=layer.name;inputElem.checked=checked;inputElem.defaultChecked=checked;inputElem.layer=layer;inputElem.control=this;if(!layer.inRange){inputElem.disabled=true;}
OpenLayers.Event.observe(inputElem,"mouseup",this.onInputClick.bindAsEventListener(inputElem));var lbl=document.createElement("label");lbl.id="label_for_"+layer.name;lbl.style.cursor="pointer";lbl.setAttribute('for',"input_"+layer.name);if(!layer.inRange){lbl.style.color="gray";}
if(checked){lbl.innerHTML=layer.name;li.className="selected";jslog.debug(li.className);}
else
lbl.innerHTML=layer.name;var br=document.createElement("br");this.dataLayerInputs.push(inputElem);if(layer.types[layer.typename]){var symbol=layer.types[layer.typename].legend.legend;var img=document.createElement("img");img.src=symbol;li.appendChild(img);}
li.appendChild(inputElem);li.appendChild(lbl);layer_ul.appendChild(li);OpenLayers.Event.observe(li,"click",this.onInputClick.bindAsEventListener(inputElem));}}
this.dataLayersDiv.appendChild(layer_ul);return this.div;},onInputClick:function(e){if(!this.disabled){if(this.type=="radio"){this.checked=true;this.layer.map.setBaseLayer(this.layer,true);this.layer.map.events.triggerEvent("changebaselayer");}else{this.checked=!this.checked;this.control.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){this.nodraw=true;for(var i=0;i<this.dataLayerInputs.length;i++){var input=this.dataLayerInputs[i];var inputLi=document.getElementById("li_for_"+input.name);inputLi.className=input.checked?"selectedli":"";jslog.debug(input.checked);var visibility=input.layer.getVisibility();if(visibility!=input.checked){input.layer.setVisibility(input.checked);}}},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},loadContents:function(){this.div.className='box';var title=document.createElement('h2');title.innerHTML='Category';this.div.appendChild(title);this.body=document.createElement('div');this.body.className='body';this.div.appendChild(this.body);OpenLayers.Event.observe(this.div,"mouseup",this.mouseUp.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"click",this.ignoreEvent);OpenLayers.Event.observe(this.div,"mousedown",this.mouseDown.bindAsEventListener(this));OpenLayers.Event.observe(this.div,"dblclick",this.ignoreEvent);this.layersDiv=document.createElement("div");this.layersDiv.id="layersDiv";this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);this.body.appendChild(this.layersDiv);},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},CLASS_NAME:"OpenLayers.Control.LayerSwitcher2"});OpenLayers.Control.MJSearch=OpenLayers.Class(OpenLayers.Control,{drawFeature:true,updateGeom:false,inputField:null,layer:null,feature:null,div:null,contentDiv:null,searchResultsDiv:null,resultInfo:null,selectControl:null,dragControl:null,dragControlActivated:false,zoom:5,showMarker:true,lookup:'lstg',scriptName:'search.py',searchTitle:'Find my nearest',searchLabel:'Enter a postcode or street in Camden or Islington',imagesBaseURL:'images/',lastResult:false,clearSearch:true,scriptURL:'http://172.25.81.9/map-bin/search.py',restrictSearch:true,maxExtent:null,directSearch:true,initialize:function(options){this.markerURL='http://static.media.thepieguide.com/markers/red_circle.png';OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='mjSearchControlDiv';}
var h1=document.createElement('h1');h1.innerHTML=this.searchTitle;this.div.appendChild(h1);var formDiv=document.createElement('div');var p=document.createElement('p');p.innerHTML=this.searchLabel;formDiv.appendChild(p);var table=document.createElement('table');var tbody=document.createElement('tbody');var tr=document.createElement('tr');var td1=document.createElement('td');var td2=document.createElement('td');this.inputField=document.createElement('input');this.inputField.type='text';this.inputField.id=this.inputField.name='searchterm';td1.appendChild(this.inputField);var img=document.createElement('img');img.src=this.imagesBaseURL+'button-searchsubmit.png';td2.appendChild(img);table.appendChild(tbody);tbody.appendChild(tr);tr.appendChild(td1);tr.appendChild(td2);formDiv.appendChild(table);this.div.appendChild(formDiv);OpenLayers.Event.observe(this.inputField,'keyup',this.sniffEnter.bind(this));OpenLayers.Event.observe(img,'click',this.search.bind(this));this.searchResultsDiv=document.createElement('div');this.div.appendChild(this.searchResultsDiv);var args=OpenLayers.Util.getArgs();if(args.q&&this.directSearch){this.inputField.value=args.q;if(this.map.baseLayer){this.search();}else{this.map.events.register('changebaselayer',this,this.runSearch);}}},runSearch:function(){this.map.events.unregister('changebaselayer',this,this.runSearch);this.search();},sniffEnter:function(evt){if(evt)
if(evt.keyCode==13)
this.search()},search:function(){var query=this.inputField.value;if(query.length==''){this.searchResultsDiv.innerHTML=OpenLayers.i18n('Please enter a valid postcode/street name to search');return false;}
var validPostcode=this.checkPostcode(this.inputField.value);if(validPostcode){this.inputField.value=query=validPostcode;this.lastSearch={lookup:'postcode',q:validPostcode}}
else{if((this.inputField.value).length<3){this.searchResultsDiv.innerHTML=OpenLayers.i18n('Please enter a valid postcode/street name to search');return false;}
else{this.lastSearch={lookup:'lstg',q:this.inputField.value}}}
var lookup=this.lastSearch.lookup;var params='q='+query+'&lookup='+lookup;if(this.restrictSearch){if(!this.maxExtent){this.maxExtent=this.map.maxExtent;}
var ext=this.maxExtent;var extent='&bbox='+ext.left+','+ext.bottom+','+ext.right+','+ext.top;params+=extent;}
var url=this.scriptURL+"?"+params;this.searchResultsDiv.innerHTML="<img src='"+this.imagesBaseURL+"spinner.gif' />";OpenLayers.loadURL(url,null,this,this.handleSearchResponse,this.searchFailed);},onPopupClose:function(evt){this.selectControl.unselect(this.feature);},onFeatureSelect:function(feature){popup=new OpenLayers.Popup.FramedCloud("chicken",feature.geometry.getBounds().getCenterLonLat(),null,"<div style='font-size:.8em'>Feature: "+feature.id+" "+' - attrs '+"</div>",null,true,this.onPopupClose);feature.popup=popup;this.map.addPopup(popup);},onFeatureUnselect:function(feature){this.map.removePopup(feature.popup);feature.popup.destroy();feature.popup=null;},addMarkerLayer:function(){if(typeof this.markerLayer=='undefined'){this.markerLayer=new OpenLayers.Layer.Markers('search_marker');this.map.addLayer(this.markerLayer);}},addMarker:function(result){if(!this.markerLayer)
this.addMarkerLayer();if(!this.marker){var geom=new OpenLayers.Geometry.fromWKT(result.geometry);var url=this.markerURL;var size=new OpenLayers.Size(35,35);var offset=new OpenLayers.Pixel(-(size.w/2),-(size.h/2));var icon=new OpenLayers.Icon(url,size,offset);var loc=new OpenLayers.LonLat(geom.x,geom.y);this.marker=new OpenLayers.Marker(loc,icon);this.markerLayer.addMarker(this.marker);}
else{var geom=new OpenLayers.Geometry.fromWKT(result.geometry);var loc=new OpenLayers.LonLat(geom.x,geom.y);this.marker.moveTo(this.map.getLayerPxFromLonLat(loc));}},removeMarker:function(){if(this.markerLayer&&this.marker){this.markerLayer.removeMarker(this.marker);this.markerLayer.clearMarkers();this.marker=null;}},searchFailed:function(){this.searchResultsDiv.innerHTML=OpenLayers.i18n('Nothing found.');},handleSearchResponse:function(request){var response=eval('('+request.responseText+')');if(!response)
this.searchResultsDiv.innerHTML=OpenLayers.i18n("We were unable to process this request. Please try again");if(response.results!=false){searchResults=response.results;var rec=(searchResults.length>1)?'records':'record'
if(searchResults.length==1){this.searchResultsDiv.innerHTML='';this.showResult(searchResults[0]);}
else{this.searchResultsDiv.innerHTML="<p>"+OpenLayers.i18n('Showing')+" "+searchResults.length+" "+OpenLayers.i18n('records')+"</p>";var ul=document.createElement('ul');ul.className='searchResultsUL';for(var len=searchResults.length,currIndex=0;currIndex<len;currIndex++){var li=document.createElement('li');var a=document.createElement('a');var result=searchResults[currIndex];var resultText='';if(this.lastSearch.lookup=='postcode')
resultText=result.postcode;else
if(this.lastSearch.lookup=='lstg'){resultText=result.name;resultText+=(typeof(result.district)!='undefined')?', '+result.district:'';}
li.innerHTML=resultText;li.style.cursor='pointer';ul.appendChild(li);OpenLayers.Event.observe(li,'click',this.showResult.bind(this,result));}
this.searchResultsDiv.appendChild(ul);}}else{this.searchResultsDiv.innerHTML=OpenLayers.i18n("Nothing found.");}},showResult:function(result){if(result){this.lastResult=result;var geom=new OpenLayers.Geometry.fromWKT(result.geometry);if(this.showMarker){this.addMarker(result);if(this.clearSearch){this.searchResultsDiv.innerHTML="";var clear=document.createElement('a');this.searchResultsDiv.appendChild(clear);clear.innerHTML=OpenLayers.i18n('Clear Search Marker');clear.className='clearSearch';OpenLayers.Event.observe(clear,'click',this.clearSearch.bind(this));}}
this.map.setCenter(new OpenLayers.LonLat(geom.x,geom.y),this.zoom);}},showMapCenter:function(result){if(result){this.lastResult=result;var geom=new OpenLayers.Geometry.fromWKT(result.geometry);if(this.showMarker){this.addMarker(result);if(this.clearSearch){this.searchResultsDiv.innerHTML="";var clear=document.createElement('a');this.searchResultsDiv.appendChild(clear);clear.innerHTML=OpenLayers.i18n('Clear Search Marker');clear.className='clearSearch';OpenLayers.Event.observe(clear,'click',this.clearSearch.bind(this));}}}},clearSearch:function(){this.lastResult=false;this.inputField.value='';if(this.showMarker){this.removeMarker();}
this.searchResultsDiv.innerHTML="";},centerMap:function(point){var centrePoint=new OpenLayers.LonLat(point[0],point[1]);centrePoint.transform(new OpenLayers.Projection('EPSG:4326'),this.map.getProjectionObject());this.map.setCenter(centrePoint,this.zoom);},isPostcode:function(str){var is_postcode=false;var postcode='';for(var i=0;i<str.length;i++)
if(str.charAt(i)!=' ')
postcode=postcode+str.charAt(i);if(postcode.length>8)
return false;if(this.isNumber(postcode.charAt(0))==true)
return false;if(this.isNumber(postcode.charAt(postcode.length-1))==true&&postcode.length<5)
return true;if(this.isNumber(postcode.charAt(postcode.length-2))==true&&postcode.length<5)
return true;var postcode_end=postcode.substr(postcode.length-3,3);var postcode_start=postcode.substr(0,postcode.length-3);if(this.isNumber(postcode_end.charAt(0))==false)
return false;if(this.isNumber(postcode_end.charAt(1))==true)
return false;if(this.isNumber(postcode_end.charAt(2))==true)
return false;var check=false;for(i=0;i<postcode_start.length;i++)
if(this.isNumber(postcode_start.charAt(i))==true)
check=true;if(check==false)
return false;return true;},isNumber:function(c){if(c=='0')return true;if(c=='1')return true;if(c=='2')return true;if(c=='3')return true;if(c=='4')return true;if(c=='5')return true;if(c=='6')return true;if(c=='7')return true;if(c=='8')return true;if(c=='9')return true;return false;},checkPostcode:function(toCheck){var alpha1="[abcdefghijklmnoprstuwyz]";var alpha2="[abcdefghklmnopqrstuvwxy]";var alpha3="[abcdefghjkstuw]";var alpha4="[abehmnprvwxy]";var alpha5="[abdefghjlnpqrstuwxyz]";var pcexp=new Array();pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}[0-9]{1}"+alpha3+"{1})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(/^(GIR)(\s*)(0AA)$/i);pcexp.push(/^(bfpo)(\s*)([0-9]{1,4})$/i);pcexp.push(/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);pcexp.push(/^([A-Z]{4})(\s*)(1ZZ)$/i);var postCode=toCheck;pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}[0-9]{1,2})(\\s*)([0-9]{1})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})(\\s*)([0-9]{1}"+alpha5+"{0,2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]?)$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]{1}"+alpha5+"{1,2})$","i"));var valid=false;for(var i=0;i<pcexp.length;i++){if(pcexp[i].test(postCode)){pcexp[i].exec(postCode);postCode=RegExp.$1.toUpperCase()+" "+RegExp.$3.toUpperCase();postCode=postCode.replace(/C\/O\s*/,"c/o ");valid=true;break;}}
if(valid){return postCode;}else return false;},CLASS_NAME:"OpenLayers.Control.MJSearch"});OpenLayers.Control.MapFeedback=OpenLayers.Class(OpenLayers.Control,{layer:null,layerZIndex:726,feature:null,loadingImg:'loading_ani.gif',scriptName:'mapfeedback.py',dragStarted:false,opacity:1,linkText:'Map Feedback',zoomRestriction:[],projectInfo:{id:8,name:'PIE',client_name:'PIE',client_id:4},confirmationEmail:false,confirmationEmailOptions:{email_body:"Thank you for your feedback."},mailerScript:"/commonjs/feedback-tool/mailer.php",commentLimit:0,commentHelpText:'Please provide as much detail as possible incl. Road Name, Feature Type (ie Loading bay) plus any other useful information or restrictions',initialize:function(options){this.markerURL='http://static.media.thepieguide.com/markers/red_circle.png';this.markerURL='http://172.25.81.9/gmedia/markers/dot_purple2.png';this.markerURL='http://static.media.thepieguide.com/markers/dot_purple2.png';this.type=OpenLayers.Control.TYPE_BUTTON;if(typeof _project_info!='undefined'){this.projectInfo=_project_info;}
OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;this.loadingImgURL=OpenLayers.Util.getImagesLocation()+this.loadingImg;this.displayClass='mapFeedbackLinkDiv';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.addEventType('mapfeedbackcontroladded');this.addLayer();if(this.zoomRestriction.length>0)
this.map.events.register('zoomend',this,this.checkZoomRestriction);this.map.events.register('changebaselayer',this,this.firstCheck);},firstCheck:function(){this.map.events.unregister('changebaselayer',this,this.runSearch);this.checkZoomRestriction();},checkZoomRestriction:function(){var zoom=this.map.getZoom();var show=true;for(ind in this.zoomRestriction){if(zoom==this.zoomRestriction[ind]){show=false;break;}}
this.toggleControl(show);},addLayer:function(){if(!this.layer){var url=this.markerURL;var size=new OpenLayers.Size(20,21);var offset=new OpenLayers.Pixel(-(size.w/2),-(size.h/2));var icon=new OpenLayers.Icon(url,size,offset);var style=new OpenLayers.Style({graphicXOffset:-10.0,graphicYOffset:-11.0,graphicWidth:20,graphicHeight:21,externalGraphic:this.markerURL});var sMap=new OpenLayers.StyleMap(style);this.layer=new OpenLayers.Layer.Vector('feedback_marker',{styleMap:sMap});this.map.addLayer(this.layer);this.layer.setZIndex(this.layerZIndex);this.layer.setVisibility(false);}
if(!this.dragControl){this.dragControl=new OpenLayers.Control.DragFeature(this.layer,{onComplete:this.featureDragCompleted,onStart:this.featureDragStarted});this.map.addControl(this.dragControl);}},addFeature:function(){if(!this.layer||this.layer==null)
this.addLayer();if(!this.feature){var loc=this.map.getCenter().clone();var geom=new OpenLayers.Geometry.Point(loc.lon,loc.lat);this.feature=new OpenLayers.Feature.Vector(geom);this.feature.popupClass=OpenLayers.Popup.FramedCloud;this.feature.popupSize=new OpenLayers.Size(460,400);this.layer.addFeatures([this.feature]);this.show();}
else{var loc=this.map.getCenter().clone();this.feature.move(loc);this.show();}
this.layer.setVisibility(true);this.dragControl.activate();this.layer.events.register('click',this,this.onClick);},featureDragCompleted:function(feature){this.layer.redraw();feature.popup.lonlat=new OpenLayers.LonLat(feature.geometry.x,feature.geometry.y);feature.popup.updatePosition();feature.popup.show();feature.popup.panIntoView();},featureDragStarted:function(feature){this.dragStarted=true;feature.popup.hide();},addPopup:function(){if(!this.popup){this.popup=this.feature.createPopup(true,this.closePopup);this.popup.featurePopup=this;this.feature.popup=this.popup;this.map.addPopup(this.popup);}
if(this.popup.contentDiv!=null){this.popup.autoSize=true;this.popup.contentDiv.className='';this.popup.contentDiv.className=this._div.className;this._div.style.display='';this.popup.contentDiv.appendChild(this._div);this.popup.contentDiv.style.width='400px';}},updatePopup:function(){this.popup.updateSize();this.popup.lonlat=new OpenLayers.LonLat(this.feature.geometry.x,this.feature.geometry.y);this.popup.updatePosition();this.popup.panIntoView();},show:function(){if(!this.popup){this.addPopup();}
this.updatePopup();},closePopup:function(){if(typeof this.featurePopup!='undefined'){if(typeof this.featurePopup.feature!='undefined'){this.featurePopup.removeFeature();}}},removeFeature:function(){if(this.feature.popup!=null)
this.map.removePopup(this.feature.popup);if(this.popup!=null){this.popup=null;this.feature.popup.destroy();this.feature.popup=null;}
this.layer.removeFeatures(this.layer.features);this.feature=null;this.reset();this.dragControl.deactivate();this.layer.events.unregister('click',this,this.onClick);this.layer.setVisibility(false);},onClick:function(evt){this.dragStarted=false;},hide:function(){this._div.style.display='none';},submitFeedback:function(evt){var check=this.validateForm();if(!check.success){this.showError(check.msg);return false;}
var params={req:'save',fid:1,ftype:0,fname:'',ftable:'',geo_type:'POINT',x:this.feature.geometry.x,y:this.feature.geometry.y,name:this.fields.name.value,email:this.fields.email.value,type:this.fields.feedbackType.options[this.fields.feedbackType.selectedIndex].value,comment:this.fields.comment.value,notify:(this.fields.notify.checked)?'t':'f',client:this.projectInfo.client_id,client_name:this.projectInfo.client_name,project:this.projectInfo.id,project_title:this.projectInfo.title};var request=OpenLayers.Request.POST({url:this.scriptURL,data:OpenLayers.Util.getParameterString(params),headers:{"Content-Type":"application/x-www-form-urlencoded"},callback:this.handleResponse,scope:this});this.hideForm();this.hideError();this.showProgress(true);},reset:function(){this.showForm();this.hideProgress();this.hideError();this.fields.comment.value='';this.commentLimitInfo.innerHTML='';},resize:function(){if(this.popup){this.popup.updateSize();this.popup.updatePosition();this.popup.panIntoView();}},toggleControl:function(show){this.div.style.display=(show)?'':'none';},showProgress:function(resize){this.progressDiv.style.display='';if(resize)this.resize();},hideProgress:function(resize){this.progressDiv.style.display='none';if(resize)this.resize();},showError:function(err){this.msgDiv.innerHTML=OpenLayers.i18n(err);this.msgDiv.style.display='block';this.resize();},showMsg:function(msg){this.msgDiv.innerHTML='<p>'+OpenLayers.i18n(msg)+'</p>';this.msgDiv.style.display='block';this.resize();},hideMsg:function(resize){this.msgDiv.style.display='none';if(resize)this.resize();},hideError:function(resize){this.msgDiv.style.display='none';if(resize)this.resize();},showForm:function(resize){this.form.style.display='';if(resize)this.resize();},hideForm:function(resize){this.form.style.display='none';if(resize)this.resize();},validateForm:function(){var msg='';if(this.fields.name.value.length<3){msg+='<li>Please input a valid name</li>';}
var email_str=this.fields.email.value;if(email_str.length<6||email_str.indexOf('@')==-1||email_str.indexOf('.')==-1){msg+='<li>Please provide a valid email address</li>';}
if(this.fields.comment.value.length<=0){msg+='<li>Please provide us with some details of problem</li>';}
if(msg!=''){msg='<ul>'+msg+'</ul>';return{success:false,msg:msg};}else{return{success:true};}},buildForm:function(){this.fields=new Object();this.fields.email=document.createElement('input');this.fields.name=document.createElement('input');this.fields.featureId=document.createElement('input');this.fields.featureId.className='hidden';this.fields.featureTypeId=document.createElement('input');this.fields.featureTypeId.className='hidden';this.fields.featureName=document.createElement('input');this.fields.featureName.className='hidden';this.fields.featureTable=document.createElement('input');this.fields.featureTable.className='hidden';this.fields.projectId=document.createElement('input');this.fields.projectId.className='hidden';this.fields.geometryType=document.createElement('input');this.fields.geometryType.className='hidden';this.fields.feedbackType=document.createElement('select');this.fields.comment=document.createElement('textarea');this.fields.notify=document.createElement('input');this.fields.notify.type='checkbox';this.form=document.createElement('form');var helpText=document.createElement('p');helpText.innerHTML=OpenLayers.i18n('Please move marker on map if you have location specific feedback');this.form.appendChild(helpText);var label=document.createElement('label');label.innerHTML='Your Name';this.form.appendChild(label);this.form.appendChild(this.fields.name);var label=document.createElement('label');label.innerHTML='Your Email';this.form.appendChild(label);this.form.appendChild(this.fields.email);this.form.appendChild(this.fields.featureId);this.form.appendChild(this.fields.featureTypeId);this.form.appendChild(this.fields.featureName);this.form.appendChild(this.fields.geometryType);this.form.appendChild(this.fields.featureTable);this.form.appendChild(this.fields.projectId);var label=document.createElement('label');label.innerHTML='Report';this.form.appendChild(label);this.form.appendChild(this.fields.feedbackType);this.commentHelp=document.createElement('p');this.commentHelp.className='commentHelp';this.commentHelp.innerHTML=this.commentHelpText;this.form.appendChild(this.commentHelp);var label=document.createElement('label');label.innerHTML='Comments';this.form.appendChild(label);this.form.appendChild(this.fields.comment);this.commentLimitInfo=document.createElement('p');this.commentLimitInfo.className='charLimitInfo';this.form.appendChild(this.commentLimitInfo);var div=document.createElement('div');div.className='notifyDiv';div.appendChild(this.fields.notify);var label=document.createElement('span');label.innerHTML='Notify me when there is any action taken on this issue';div.appendChild(label);this.form.appendChild(div);this.loadFeedbackTypes();var submit=document.createElement('div');submit.className='submitButton';submit.innerHTML='Submit';this.form.appendChild(submit);if(this.commentLimit>0){this.commentLimitInfo.innerHTML="Characters remaining: "+(this.commentLimit-this.fields.comment.value.length);OpenLayers.Event.observe(this.fields.comment,'keyup',this.checkLimit.bind(this,this.fields.comment,this.commentLimit,this.commentLimitInfo));}
OpenLayers.Event.observe(submit,'click',this.submitFeedback.bind(this));var disclaimer=document.createElement('a');disclaimer.className='disclaimer';disclaimer.href=this.disclaimerLink;disclaimer.target='_blank';disclaimer.innerHTML='Disclaimer';this.form.appendChild(disclaimer);this._div.appendChild(this.form);},setControlOpacity:function(opacity){OpenLayers.Util.modifyDOMElement(this.div,this.div.id,null,null,null,null,null,opacity);},draw:function(){if(this.div==null){this.div=OpenLayers.Util.createDiv(this.id);this.div.style.zIndex=1005;this.div.style.top='0px';this.div.style.right='0px';if(!this.allowSelection){this.div.className+=" olControlNoSelect";this.div.setAttribute("unselectable","on",0);this.div.onselectstart=function(){return(false);};}
this.map.viewPortDiv.appendChild(this.div);if(typeof(this.opacity)=='number'){OpenLayers.Util.setOpacity(this.div,this.opacity);if(this.opacity<1){OpenLayers.Event.observe(this.div,'mouseover',this.setControlOpacity.bind(this,1));OpenLayers.Event.observe(this.div,'mouseout',this.setControlOpacity.bind(this,this.opacity));}}}
this.div.className=this.displayClass;this.div.innerHTML=OpenLayers.i18n(this.linkText);OpenLayers.Event.observe(this.div,'click',this.addFeature.bind(this));if(!this._div){this._div=document.createElement('div');document.body.appendChild(this._div);this._div.id='mapFeedbackContainerDiv';this._div.className='mapFeedbackContainerDiv';}
this.hide();var title=document.createElement('div');title.innerHTML=OpenLayers.i18n('Map Feedback');title.className='title';this._div.appendChild(title);this.msgDiv=document.createElement('div');this.msgDiv.className='msgDivContainer';this.msgDiv.style.display='none';this._div.appendChild(this.msgDiv);this.buildForm();this.progressDiv=document.createElement('div');this.progressDiv.className='imgProgress';var pImg=document.createElement('img');pImg.src=this.loadingImgURL;var pMsg=document.createTextNode(OpenLayers.i18n('Thank you for your feedback. Please wait while we submit your feedback.'));this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';this._div.appendChild(this.progressDiv);this.map.events.triggerEvent("mapfeedbackcontroladded");},loadFeedbackTypes:function(){var params='req=feedbacktypes';var url=this.scriptURL+"?"+params;OpenLayers.loadURL(url,null,this,this.handleFeedbackTypes);return true;},handleFeedbackTypes:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){var feedbackTypes=response.feedback_types;if(feedbackTypes&&feedbackTypes.length>0){for(var ind=0,len=feedbackTypes.length;ind<len;ind++){this.fields.feedbackType.options[this.fields.feedbackType.options.length]=new Option(feedbackTypes[ind].name,feedbackTypes[ind].id);}}}else{}},failed:function(){this.showError('Some error occured. Please try again.');this.showForm();this.hideProgress(true);},handleResponse:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){this.showMsg('Your feedback has been submitted successfully.')
if(this.confirmationEmail)
this.sendEmail();}else{this.failed();}
this.hideProgress(true);},sendEmail:function(){var params={feedback_msg:this.confirmationEmailOptions.email_body,feedback_email:this.fields.email.value,feedback_name:this.fields.name.value};var request=OpenLayers.Request.POST({url:this.mailerScript,data:OpenLayers.Util.getParameterString(params),headers:{"Content-Type":"application/x-www-form-urlencoded"}});},addOption:function(text,val,data){var option=document.createElement('option');option.value=val;option.text=text;},fireClickEvent:function(domElem){var aElem=(typeof domElem=='string')?document.getElementById(domElem):domElem;if(!aElem)return false;if(document.createEvent){var evt=document.createEvent('HTMLEvents');evt.initEvent('click',false,false);aElem.dispatchEvent(evt);}
else if(document.createEventObject){aElem.fireEvent('onclick');}},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},checkLimit:function(elem,limit,infoElem,evt){if(elem.value.length>limit)
elem.value=elem.value.substring(0,limit);if(infoElem){infoElem.innerHTML="Characters remaining: "+(limit-elem.value.length);}},CLASS_NAME:"OpenLayers.Control.MapFeedback"});OpenLayers.Control.MouseDefaults=OpenLayers.Class(OpenLayers.Control,{performedDrag:false,wheelObserver:null,initialize:function(){OpenLayers.Control.prototype.initialize.apply(this,arguments);},destroy:function(){if(this.handler){this.handler.destroy();}
this.handler=null;this.map.events.un({"click":this.defaultClick,"dblclick":this.defaultDblClick,"mousedown":this.defaultMouseDown,"mouseup":this.defaultMouseUp,"mousemove":this.defaultMouseMove,"mouseout":this.defaultMouseOut,scope:this});OpenLayers.Event.stopObserving(window,"DOMMouseScroll",this.wheelObserver);OpenLayers.Event.stopObserving(window,"mousewheel",this.wheelObserver);OpenLayers.Event.stopObserving(document,"mousewheel",this.wheelObserver);this.wheelObserver=null;OpenLayers.Control.prototype.destroy.apply(this,arguments);},draw:function(){this.map.events.on({"click":this.defaultClick,"dblclick":this.defaultDblClick,"mousedown":this.defaultMouseDown,"mouseup":this.defaultMouseUp,"mousemove":this.defaultMouseMove,"mouseout":this.defaultMouseOut,scope:this});this.registerWheelEvents();},registerWheelEvents:function(){this.wheelObserver=OpenLayers.Function.bindAsEventListener(this.onWheelEvent,this);OpenLayers.Event.observe(window,"DOMMouseScroll",this.wheelObserver);OpenLayers.Event.observe(window,"mousewheel",this.wheelObserver);OpenLayers.Event.observe(document,"mousewheel",this.wheelObserver);},defaultClick:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
var notAfterDrag=!this.performedDrag;this.performedDrag=false;return notAfterDrag;},defaultDblClick:function(evt){var newCenter=this.map.getLonLatFromViewPortPx(evt.xy);this.map.setCenter(newCenter,this.map.zoom+1);OpenLayers.Event.stop(evt);return false;},defaultMouseDown:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
this.mouseDragStart=evt.xy.clone();this.performedDrag=false;if(evt.shiftKey){this.map.div.style.cursor="crosshair";this.zoomBox=OpenLayers.Util.createDiv('zoomBox',this.mouseDragStart,null,null,"absolute","2px solid red");this.zoomBox.style.backgroundColor="white";this.zoomBox.style.filter="alpha(opacity=50)";this.zoomBox.style.opacity="0.50";this.zoomBox.style.fontSize="1px";this.zoomBox.style.zIndex=this.map.Z_INDEX_BASE["Popup"]-1;this.map.viewPortDiv.appendChild(this.zoomBox);}
document.onselectstart=function(){return false;};OpenLayers.Event.stop(evt);},defaultMouseMove:function(evt){this.mousePosition=evt.xy.clone();if(this.mouseDragStart!=null){if(this.zoomBox){var deltaX=Math.abs(this.mouseDragStart.x-evt.xy.x);var deltaY=Math.abs(this.mouseDragStart.y-evt.xy.y);this.zoomBox.style.width=Math.max(1,deltaX)+"px";this.zoomBox.style.height=Math.max(1,deltaY)+"px";if(evt.xy.x<this.mouseDragStart.x){this.zoomBox.style.left=evt.xy.x+"px";}
if(evt.xy.y<this.mouseDragStart.y){this.zoomBox.style.top=evt.xy.y+"px";}}else{var deltaX=this.mouseDragStart.x-evt.xy.x;var deltaY=this.mouseDragStart.y-evt.xy.y;var size=this.map.getSize();var newXY=new OpenLayers.Pixel(size.w/2+deltaX,size.h/2+deltaY);var newCenter=this.map.getLonLatFromViewPortPx(newXY);this.map.setCenter(newCenter,null,true);this.mouseDragStart=evt.xy.clone();this.map.div.style.cursor="move";}
this.performedDrag=true;}},defaultMouseUp:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
if(this.zoomBox){this.zoomBoxEnd(evt);}else{if(this.performedDrag){this.map.setCenter(this.map.center);}}
document.onselectstart=null;this.mouseDragStart=null;this.map.div.style.cursor="";},defaultMouseOut:function(evt){if(this.mouseDragStart!=null&&OpenLayers.Util.mouseLeft(evt,this.map.div)){if(this.zoomBox){this.removeZoomBox();}
this.mouseDragStart=null;}},defaultWheelUp:function(evt){if(this.map.getZoom()<=this.map.getNumZoomLevels()){this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),this.map.getZoom()+1);}},defaultWheelDown:function(evt){if(this.map.getZoom()>0){this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),this.map.getZoom()-1);}},zoomBoxEnd:function(evt){if(this.mouseDragStart!=null){if(Math.abs(this.mouseDragStart.x-evt.xy.x)>5||Math.abs(this.mouseDragStart.y-evt.xy.y)>5){var start=this.map.getLonLatFromViewPortPx(this.mouseDragStart);var end=this.map.getLonLatFromViewPortPx(evt.xy);var top=Math.max(start.lat,end.lat);var bottom=Math.min(start.lat,end.lat);var left=Math.min(start.lon,end.lon);var right=Math.max(start.lon,end.lon);var bounds=new OpenLayers.Bounds(left,bottom,right,top);this.map.zoomToExtent(bounds);}else{var end=this.map.getLonLatFromViewPortPx(evt.xy);this.map.setCenter(new OpenLayers.LonLat((end.lon),(end.lat)),this.map.getZoom()+1);}
this.removeZoomBox();}},removeZoomBox:function(){this.map.viewPortDiv.removeChild(this.zoomBox);this.zoomBox=null;},onWheelEvent:function(e){var inMap=false;var elem=OpenLayers.Event.element(e);while(elem!=null){if(this.map&&elem==this.map.div){inMap=true;break;}
elem=elem.parentNode;}
if(inMap){var delta=0;if(!e){e=window.event;}
if(e.wheelDelta){delta=e.wheelDelta/120;if(window.opera&&window.opera.version()<9.2){delta=-delta;}}else if(e.detail){delta=-e.detail/3;}
if(delta){e.xy=this.mousePosition;if(delta<0){this.defaultWheelDown(e);}else{this.defaultWheelUp(e);}}
OpenLayers.Event.stop(e);}},CLASS_NAME:"OpenLayers.Control.MouseDefaults"});OpenLayers.Control.MousePosition=OpenLayers.Class(OpenLayers.Control,{element:null,prefix:'',separator:', ',suffix:'',numDigits:5,granularity:10,lastXy:null,displayProjection:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);},destroy:function(){if(this.map){this.map.events.unregister('mousemove',this,this.redraw);}
OpenLayers.Control.prototype.destroy.apply(this,arguments);},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!this.element){this.div.left="";this.div.top="";this.element=this.div;}
this.redraw();return this.div;},redraw:function(evt){var lonLat;if(evt==null){lonLat=new OpenLayers.LonLat(0,0);}else{if(this.lastXy==null||Math.abs(evt.xy.x-this.lastXy.x)>this.granularity||Math.abs(evt.xy.y-this.lastXy.y)>this.granularity)
{this.lastXy=evt.xy;return;}
lonLat=this.map.getLonLatFromPixel(evt.xy);if(!lonLat){return;}
if(this.displayProjection){lonLat.transform(this.map.getProjectionObject(),this.displayProjection);}
this.lastXy=evt.xy;}
var newHtml=this.formatOutput(lonLat);if(newHtml!=this.element.innerHTML){this.element.innerHTML=newHtml;}},formatOutput:function(lonLat){var digits=parseInt(this.numDigits);var newHtml=this.prefix+
lonLat.lon.toFixed(digits)+
this.separator+
lonLat.lat.toFixed(digits)+
this.suffix;return newHtml;},setMap:function(){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register('mousemove',this,this.redraw);},CLASS_NAME:"OpenLayers.Control.MousePosition"});OpenLayers.Control.Pan=OpenLayers.Class(OpenLayers.Control,{slideFactor:50,direction:null,type:OpenLayers.Control.TYPE_BUTTON,initialize:function(direction,options){this.direction=direction;this.CLASS_NAME+=this.direction;OpenLayers.Control.prototype.initialize.apply(this,[options]);},trigger:function(){switch(this.direction){case OpenLayers.Control.Pan.NORTH:this.map.pan(0,-this.slideFactor);break;case OpenLayers.Control.Pan.SOUTH:this.map.pan(0,this.slideFactor);break;case OpenLayers.Control.Pan.WEST:this.map.pan(-this.slideFactor,0);break;case OpenLayers.Control.Pan.EAST:this.map.pan(this.slideFactor,0);break;}},CLASS_NAME:"OpenLayers.Control.Pan"});OpenLayers.Control.Pan.NORTH="North";OpenLayers.Control.Pan.SOUTH="South";OpenLayers.Control.Pan.EAST="East";OpenLayers.Control.Pan.WEST="West";OpenLayers.Control.PanZoom=OpenLayers.Class(OpenLayers.Control,{slideFactor:50,slideRatio:null,buttons:null,position:null,initialize:function(options){this.position=new OpenLayers.Pixel(OpenLayers.Control.PanZoom.X,OpenLayers.Control.PanZoom.Y);OpenLayers.Control.prototype.initialize.apply(this,arguments);},destroy:function(){OpenLayers.Control.prototype.destroy.apply(this,arguments);this.removeButtons();this.buttons=null;this.position=null;},draw:function(px){OpenLayers.Control.prototype.draw.apply(this,arguments);px=this.position;this.buttons=[];var sz=new OpenLayers.Size(18,18);var centered=new OpenLayers.Pixel(px.x+sz.w/2,px.y);this._addButton("panup","north-mini.png",centered,sz);px.y=centered.y+sz.h;this._addButton("panleft","west-mini.png",px,sz);this._addButton("panright","east-mini.png",px.add(sz.w,0),sz);this._addButton("pandown","south-mini.png",centered.add(0,sz.h*2),sz);this._addButton("zoomin","zoom-plus-mini.png",centered.add(0,sz.h*3+5),sz);this._addButton("zoomworld","zoom-world-mini.png",centered.add(0,sz.h*4+5),sz);this._addButton("zoomout","zoom-minus-mini.png",centered.add(0,sz.h*5+5),sz);return this.div;},_addButton:function(id,img,xy,sz){var imgLocation=OpenLayers.Util.getImagesLocation()+img;var btn=OpenLayers.Util.createAlphaImageDiv(this.id+"_"+id,xy,sz,imgLocation,"absolute");this.div.appendChild(btn);OpenLayers.Event.observe(btn,"mousedown",OpenLayers.Function.bindAsEventListener(this.buttonDown,btn));OpenLayers.Event.observe(btn,"dblclick",OpenLayers.Function.bindAsEventListener(this.doubleClick,btn));OpenLayers.Event.observe(btn,"click",OpenLayers.Function.bindAsEventListener(this.doubleClick,btn));btn.action=id;btn.map=this.map;if(!this.slideRatio){var slideFactorPixels=this.slideFactor;var getSlideFactor=function(){return slideFactorPixels;};}else{var slideRatio=this.slideRatio;var getSlideFactor=function(dim){return this.map.getSize()[dim]*slideRatio;};}
btn.getSlideFactor=getSlideFactor;this.buttons.push(btn);return btn;},_removeButton:function(btn){OpenLayers.Event.stopObservingElement(btn);btn.map=null;this.div.removeChild(btn);OpenLayers.Util.removeItem(this.buttons,btn);},removeButtons:function(){for(var i=this.buttons.length-1;i>=0;--i){this._removeButton(this.buttons[i]);}},doubleClick:function(evt){OpenLayers.Event.stop(evt);return false;},buttonDown:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
switch(this.action){case"panup":this.map.pan(0,-this.getSlideFactor("h"));break;case"pandown":this.map.pan(0,this.getSlideFactor("h"));break;case"panleft":this.map.pan(-this.getSlideFactor("w"),0);break;case"panright":this.map.pan(this.getSlideFactor("w"),0);break;case"zoomin":this.map.zoomIn();break;case"zoomout":this.map.zoomOut();break;case"zoomworld":this.map.zoomToMaxExtent();break;}
OpenLayers.Event.stop(evt);},CLASS_NAME:"OpenLayers.Control.PanZoom"});OpenLayers.Control.PanZoom.X=4;OpenLayers.Control.PanZoom.Y=4;OpenLayers.Control.Panel=OpenLayers.Class(OpenLayers.Control,{controls:null,defaultControl:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,[options]);this.controls=[];},destroy:function(){OpenLayers.Control.prototype.destroy.apply(this,arguments);for(var i=this.controls.length-1;i>=0;i--){if(this.controls[i].events){this.controls[i].events.un({"activate":this.redraw,"deactivate":this.redraw,scope:this});}
OpenLayers.Event.stopObservingElement(this.controls[i].panel_div);this.controls[i].panel_div=null;}},activate:function(){if(OpenLayers.Control.prototype.activate.apply(this,arguments)){for(var i=0,len=this.controls.length;i<len;i++){if(this.controls[i]==this.defaultControl){this.controls[i].activate();}}
this.redraw();return true;}else{return false;}},deactivate:function(){if(OpenLayers.Control.prototype.deactivate.apply(this,arguments)){for(var i=0,len=this.controls.length;i<len;i++){this.controls[i].deactivate();}
return true;}else{return false;}},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);for(var i=0,len=this.controls.length;i<len;i++){this.map.addControl(this.controls[i]);this.controls[i].deactivate();this.controls[i].events.on({"activate":this.redraw,"deactivate":this.redraw,scope:this});}
this.activate();return this.div;},redraw:function(){this.div.innerHTML="";if(this.active){for(var i=0,len=this.controls.length;i<len;i++){var element=this.controls[i].panel_div;if(this.controls[i].active){element.className=this.controls[i].displayClass+"ItemActive";}else{element.className=this.controls[i].displayClass+"ItemInactive";}
this.div.appendChild(element);}}},activateControl:function(control){if(!this.active){return false;}
if(control.type==OpenLayers.Control.TYPE_BUTTON){control.trigger();this.redraw();return;}
if(control.type==OpenLayers.Control.TYPE_TOGGLE){if(control.active){control.deactivate();}else{control.activate();}
this.redraw();return;}
for(var i=0,len=this.controls.length;i<len;i++){if(this.controls[i]!=control){if(this.controls[i].type!=OpenLayers.Control.TYPE_TOGGLE){this.controls[i].deactivate();}}}
control.activate();},addControls:function(controls){if(!(controls instanceof Array)){controls=[controls];}
this.controls=this.controls.concat(controls);for(var i=0,len=controls.length;i<len;i++){var element=document.createElement("div");var textNode=document.createTextNode(" ");controls[i].panel_div=element;if(controls[i].title!=""){controls[i].panel_div.title=controls[i].title;}
OpenLayers.Event.observe(controls[i].panel_div,"click",OpenLayers.Function.bind(this.onClick,this,controls[i]));OpenLayers.Event.observe(controls[i].panel_div,"mousedown",OpenLayers.Function.bindAsEventListener(OpenLayers.Event.stop));}
if(this.map){for(var i=0,len=controls.length;i<len;i++){this.map.addControl(controls[i]);controls[i].deactivate();controls[i].events.on({"activate":this.redraw,"deactivate":this.redraw,scope:this});}
this.redraw();}},onClick:function(ctrl,evt){OpenLayers.Event.stop(evt?evt:window.event);this.activateControl(ctrl);},getControlsBy:function(property,match){var test=(typeof match.test=="function");var found=OpenLayers.Array.filter(this.controls,function(item){return item[property]==match||(test&&match.test(item[property]));});return found;},getControlsByName:function(match){return this.getControlsBy("name",match);},getControlsByClass:function(match){return this.getControlsBy("CLASS_NAME",match);},CLASS_NAME:"OpenLayers.Control.Panel"});OpenLayers.Control.Pdf=OpenLayers.Class(OpenLayers.Control,{drawFeature:true,div:null,imagesBaseURL:'http://172.25.81.9/map/mj/images/',scriptURL:'gen_pdf.php',linkText:'Print',initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='PdfControlDiv';}
this.div.className='olControlPdf';this.link=document.createElement('a');this.link.innerHTML=OpenLayers.i18n(this.linkText);this.div.appendChild(this.link);OpenLayers.Event.observe(this.link,'click',this.pdfClick.bind(this));},pdfClick:function(){var post={};var width=this.map.div.offsetWidth;var height=this.map.div.offsetHeight;post.width=width;post.height=height;var c1=this.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(0,0));var c2=this.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(width,height));var center=this.map.getCenter();post.center={x:center.lon,y:center.lat};post.baseLayer={name:this.map.baseLayer.name,url:this.map.baseLayer.url};post.bbox=[];post.bbox[0]=c1.lon;post.bbox[1]=c2.lat;post.bbox[2]=c2.lon;post.bbox[3]=c1.lat;post.features=[];post.layers=[];var featurecount=0;var layers=this.map.getLayersBy("visibility",true);var extent=this.map.getExtent();for(var i=0,len=layers.length;i<len;i++){if(layers[i].inRange){if(typeof(layers[i]['typename'])!='undefined'){var layer=layers[i];var curr_layer={};curr_layer.typename=layer.typename;curr_layer.name=layer.name;if(typeof(layer.types[layer.typename])!='undefined'){curr_layer.legend=layer.types[layer.typename].legend;}
if(typeof(layer.features)!='undefined'){post.layers.push(curr_layer);}}}}
var cntrl=this.map.getControlsBy("CLASS_NAME","OpenLayers.Control.PieNearest");cntrl=(cntrl.length>0)?cntrl[0]:false;var nearestFeatures=(cntrl)?cntrl.results:[];var selectedFeatures=(cntrl)?cntrl.selectedResults:[];post.nearestFeatures=[];post.selectedFeatures=[];if(nearestFeatures.length>0){for(var i=0,len=nearestFeatures.length;i<len;i++){var curr_feat=nearestFeatures[i];var feat={};feat.icon={};feat.icon.src=curr_feat.icon.src;feat.name=(curr_feat.feature.properties.name)?curr_feat.feature.properties.name:curr_feat.name;feat.distance=curr_feat.feature.properties.distance;feat.distance_in_miles=curr_feat.feature.properties.distance_in_miles;post.nearestFeatures.push(feat);}
post.nearestFeaturesName=nearestFeatures[0].name;}
if(selectedFeatures.length>0){for(var i=0,len=selectedFeatures.length;i<len;i++){var curr_feat=selectedFeatures[i];var feat={};feat.icon={};feat.icon.src=curr_feat.icon_images.selected;feat.name=(curr_feat.feature.properties.name)?curr_feat.feature.properties.name:curr_feat.name;feat.distance=curr_feat.feature.distance;feat.distance_in_miles=curr_feat.feature.distance_in_miles;post.selectedFeatures.push(feat);}}
post.markers=[];var markerLayer=(cntrl)?cntrl.markerLayer:false;var markers=(markerLayer)?markerLayer.markers:[];if(markers.length>0){for(var i=0,len=markers.length;i<len;i++){var curr_marker=markers[i];var marker={};marker.offset={};marker.offset.x=curr_marker.icon.offset.x;marker.offset.y=curr_marker.icon.offset.y;marker.px={};marker.px.x=curr_marker.icon.px.x;marker.px.y=curr_marker.icon.px.y;marker.size={};marker.size.h=curr_marker.icon.size.h;marker.size.w=curr_marker.icon.size.w;marker.url=curr_marker.icon.url;marker.lonlat={};marker.lonlat.lat=curr_marker.lonlat.lat;marker.lonlat.lon=curr_marker.lonlat.lon;post.markers.push(marker);}}
post.routes=[];var routingControl=this.map.getControlsBy("CLASS_NAME","OpenLayers.Control.Routing");routingControl=(routingControl.length>0)?routingControl[0]:false;var routes=(routingControl.routeLayer)?routingControl.routeLayer.features:[];if(routes.length>0){for(var i=0,len=routes.length;i<len;i++){var curr_route=routes[i];var route_geom_segments=curr_route.geometry.getSortedSegments();var px_route_segments=[];for(var seg_i=0,seg_len=route_geom_segments.length;seg_i<seg_len;seg_i++){var start_seg=this.map.getViewPortPxFromLonLat({lon:route_geom_segments[seg_i].x1,lat:route_geom_segments[seg_i].y1});var end_seg=this.map.getViewPortPxFromLonLat({lon:route_geom_segments[seg_i].x2,lat:route_geom_segments[seg_i].y2});px_route_segments.push({x1:start_seg.x,x2:end_seg.x,y1:start_seg.y,y2:end_seg.y});}
post.routes.push(px_route_segments);}
post.routeDirections=routingControl.textDirections;}
try{var jsontext=JSON.stringify(post);}catch(e){this.post=post;return;}
var form=document.createElement("form");form.setAttribute("method","post");form.setAttribute("action","gen_pdf.php");var hiddenField=document.createElement("input");hiddenField.setAttribute("name","json");hiddenField.setAttribute("value",jsontext);form.appendChild(hiddenField);form.setAttribute("target","_blank");var pdfform=document.getElementById("invisibleform");if(!pdfform){pdfform=document.createElement('div');pdfform.id='invisibleform';pdfform.style.display='none';document.body.appendChild(pdfform);}
pdfform.innerHTML="";pdfform.appendChild(form);form.submit();},CLASS_NAME:"OpenLayers.Control.Pdf"});OpenLayers.Control.PieLayerSwitcher=OpenLayers.Class(OpenLayers.Control,{activeColor:"darkblue",layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,categories:null,active_category:null,help_text:'Click icon to activate layer',iconDimension:null,legendDimension:null,type:'select',noBorder:false,noTitle:false,allowFeatureToggle:false,layerStates:[],updateLegendDivVisibility:true,legendTitle:'Legend',showVisibleFeaturesInfo:false,basemapLegends:[],initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.id='olLayerSwitcher';},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);if(this.basemapLegends.length>0)
this.map.events.register("zoomend",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();this.redraw();},update:function(evt){if(!this.checkRedraw()){return true;}
this.redraw();},checkRedraw:function(){var redraw=false;if(!this.layerStates.length||(this.map.layers.length!=this.layerStates.length)){redraw=true;}else{for(var i=0,len=this.layerStates.length;i<len;i++){var layerState=this.layerStates[i];var layer=this.map.layers[i];if((layerState.name!=layer.name)||(layerState.inRange!=layer.inRange)||(layerState.id!=layer.id)||(layerState.visibility!=layer.visibility)){redraw=true;break;}}}
return redraw;},redraw:function(){if(!this.checkRedraw())
return true;var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
var layer_ul=document.createElement('ul');layer_ul.className='olLayerSwitcherUL';this.dataLayersDiv.innerHTML="";this.dataLayersDiv.appendChild(layer_ul);var visibleCount=0;var totalFeatures=0;var visibleFeatures=0;for(var i=0;i<layers.length;i++){var layer=layers[i];if(layer.isBaseLayer)
continue;var isVisible=false;if(typeof layer.typename!='undefined'){if(this.layerInCategories(layer.typename)){isVisible=this.layerInActiveCategory(layer.typename);if(!this.allowFeatureToggle)
layer.setVisibility(isVisible);}}
var li=document.createElement('li');if(isVisible&&(layer.displayInLayerSwitcher&&!layer.unlisted)){var lbl=document.createElement("span");lbl.className='label';lbl.innerHTML=layer.name;if(layer.types[layer.typename]){if(layer.types[layer.typename].styles){if(layer.types[layer.typename].styles.length>0)
lbl.innerHTML=layer.types[layer.typename].styles[0].title;}}
visibleCount++;totalFeatures++;if(!layer.inRange){li.className='disabledli';}
else if(layer.getVisibility()){li.className="selectedli";visibleFeatures++;}else{visibleFeatures++;}
if(layer.types[layer.typename]){if(layer.types[layer.typename].geo_type=='POLYGON'){var symbol=layer.types[layer.typename].styles[0];var border="1px solid "+symbol.strokeColor;var size=(this.legendDimension!=null)?new OpenLayers.Size(this.legendDimension.width-2,this.legendDimension.height-5):new OpenLayers.Size(15,15);var img=OpenLayers.Util.createDiv(null,null,size,null,'relative',border,'hidden',symbol.fillOpacity);img.style.background=symbol.fillColor;img.style.cssFloat="left";img.className='img';}
else if(layer.types[layer.typename].geo_type=='LINESTRING'){var symbol=layer.types[layer.typename].styles[0];var border="0px solid "+symbol.strokeColor;var size=(this.legendDimension!=null)?new OpenLayers.Size(this.legendDimension.width,this.legendDimension.height-11):new OpenLayers.Size(15,5);var img=OpenLayers.Util.createDiv(null,null,size,null,'relative',border,'hidden',symbol.fillOpacity);img.style.background=symbol.strokeColor;img.style.marginTop='6px';img.style.cssFloat="left";img.className='img';}
else{var symbol=layer.types[layer.typename].legend.legend;var img=document.createElement("img");img.src=symbol;}
if(this.legendDimension!=null){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}
if(!layer.inRange)li.title=OpenLayers.i18n('');li.appendChild(img);}
li.appendChild(lbl);layer_ul.appendChild(li);if(this.allowFeatureToggle){var toggleFeature=this.onLayerClick.bind(this,layer);OpenLayers.Event.observe(li,'click',OpenLayers.Function.bindAsEventListener(toggleFeature,this));}}}
for(var ind=0;ind<this.basemapLegends.length;ind++){totalFeatures++;if(!this.showAtCurrentZoom(this.basemapLegends[ind].zoom))
continue;var li=document.createElement('li');var lbl=document.createElement("span");lbl.className='label';lbl.innerHTML=this.basemapLegends[ind].title;li.className="basemaplegendli";var symbol=this.basemapLegends[ind].img;var img=document.createElement("img");img.src=symbol;if(this.legendDimension!=null){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}
li.appendChild(img);li.appendChild(lbl);layer_ul.appendChild(li);visibleCount++;visibleFeatures++;}
if(this.updateLegendDivVisibility)
this.legendDiv.style.display=(visibleCount==0)?'none':'';if(this.showVisibleFeaturesInfo){var f_text=(visibleFeatures>1)?"features":"feature";var text="Displaying "+visibleFeatures+" "+f_text+" out of "+totalFeatures+".";this.footer.innerHTML=text;if(visibleFeatures!=totalFeatures)
this.footer.innerHTML+=" Zoom in to view more features.";}},showAtCurrentZoom:function(arr){if(typeof arr=='undefined')return true;if(arr.length==0)return true;var z=this.map.getZoom();for(var i=0,l=arr.length;i<l;i++){if(arr[i]==z)
return true;}
return false;},onLayerClick:function(layer,evt){layer.setVisibility(!layer.getVisibility());OpenLayers.Event.stop(evt);this.redraw();},layerInActiveCategory:function(typename){if(this.active_category==null)
return false;var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}
return false;},layerInCategories:function(typename){for(var ind=0,l=this.categories.length;ind<l;ind++){var features=this.categories[ind]['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}}
return false;},loadContents:function(){var box=this.buildBoxModel(this.div);this.div=box.box;box.title.innerHTML=OpenLayers.i18n('Select mode');if(this.noTitle)
this.div.removeChild(box.title);if(this.noBorder)
this.div.style.border=0;if(this.type=='image'&&this.noTitle)
this.div.className='';this.body=box.body;this.body.appendChild(this.buildCategoryNav());this.layersDiv=document.createElement("div");this.layersDiv.id="layersDiv";this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);if(this.legendDiv){this.legendDiv=this.buildLegendDiv();this.legendBody.appendChild(this.layersDiv);}
else{this.legendDiv=this.buildLegendDiv();this.legendBody.appendChild(this.layersDiv);this.body.appendChild(this.legendDiv);}
this.footer=document.createElement('div');this.footer.className='legendFooter';this.legendBody.appendChild(this.footer);},buildLegendDiv:function(){var box=this.buildBoxModel(this.legendDiv);this.legendDiv=box.box;this.legendTitleContainer=box.title;this.legendBody=box.body;this.legendTitleContainer.innerHTML=OpenLayers.i18n(this.legendTitle);return this.legendDiv;},buildBoxModel:function(box){box=(typeof box=='undefined'||box==null)?document.createElement('div'):box;box.className='box';title=document.createElement('div');title.className='boxTitle';body=document.createElement('div');body.className='boxBody';box.appendChild(title);box.appendChild(body);return{box:box,title:title,body:body};},buildCategoryNav:function(){if(!this.categories){this.catsDiv=document.createElement('div');return this.catsDiv;}
if(this.categories.length==1){this.active_category=this.categories[0];this.catsDiv=document.createElement('div');return this.catsDiv;}
var div=document.createElement('div');div.className='layerImagesContainer';if(this.type=='select'){var elem=document.createElement('select');elem.options[elem.options.length]=new Option('--Select Mode--','',true,true);div.appendChild(elem);for(var i=0,l=this.categories.length;i<l;i++){var txt=this.categories[i]['title'];var val=this.categories[i]['id'];elem.options[elem.options.length]=new Option(txt,val,false,this.categories[i]['initial_visibility']);if(this.categories[i]['initial_visibility']){this.active_category=this.categories[i];}}
var actCat=this.activateCategory.bind(this,elem);OpenLayers.Event.observe(elem,'change',actCat);this.layerSelect=elem;}
else{for(var i=0,l=this.categories.length;i<l;i++){var elem=document.createElement('div');elem.innerHTML=this.categories[i]['title'];var img=document.createElement('img');img.title=this.categories[i]['title'];if(this.categories[i]['initial_visibility']){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];if(this.iconDimension){img.height=this.iconDimension.height;img.width=this.iconDimension.width;}
div.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}}
this.catsDiv=div;return div;},activateCategory:function(cat,evt){if(this.type=='select'){var catId=cat[cat.selectedIndex].value;this.active_category=null;for(var i=0,l=this.categories.length;i<l;i++){if(this.categories[i]['id']==catId){this.active_category=this.categories[i];}}}
else{this.catsDiv.innerHTML='';for(var i=0,l=this.categories.length;i<l;i++){var img=document.createElement('img');if(this.categories[i]['id']==cat){img.src=this.categories[i]['active_icon'];img.title=this.categories[i]['title'];this.active_category=this.categories[i];}
else{img.src=this.categories[i]['inactive_icon'];img.title=this.categories[i]['title'];}
this.catsDiv.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}}
this.redraw();},CLASS_NAME:"OpenLayers.Control.PieLayerSwitcher"});OpenLayers.Control.PieNearest=OpenLayers.Class(OpenLayers.Control,{layersDiv:null,baseLayersDiv:null,baseLayerInputs:null,dataLbl:null,dataLayersDiv:null,dataLayerInputs:null,minimizeDiv:null,maximizeDiv:null,ascending:true,nodraw:false,categories:null,active_category:null,footer_text:'',active_facility:null,legendDimension:null,maxResults:5,forceAutoZoomToExtent:true,clickedResults:null,selectedResults:[],results:[],iconsBaseURL:'http://static.media.thepieguide.com/markers/',scriptURL:'http://172.25.81.9/map-bin/nearest.py',scriptName:'nearest.py',alphaIcons:'abcdefghijklmnopqrstuvwxyz',currentCharIndex:0,selectableMarkers:true,selectedResultsDiv:null,searchControl:null,loadingImg:'loading_ani.gif',distanceUnit:'km-mile',backButtonText:'Show List',backButtonDisplay:'top',decPointsInDistance:1,referencePoint:false,markerOffset:false,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.loadingImgURL=OpenLayers.Util.getImagesLocation()+this.loadingImg;this.id='olPieNearest';this.footer_text='Click the icon to list nearest';this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.redraw);this.map.events.register("changelayer",this,this.redraw);this.map.events.register("removelayer",this,this.redraw);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.drawControlStructure();this.redraw();if(this.map)
this.addMarkerLayer();},redraw:function(){if(this.nodraw){this.nodraw=false;return;}
this.dataLayersDiv.innerHTML="";this.dataLayerInputs=new Array();var layers=this.map.layers.slice();if(!this.ascending){layers.reverse();}
this.catHead.innerHTML=this.active_category['title'];var layer_ul=document.createElement('ul');layer_ul.className='olPieNearestUL';for(var i=0;i<layers.length;i++){var layer=layers[i];if(!this.layerInActiveCategory(layer.typename))
continue;var baseLayer=layer.isBaseLayer;var li=document.createElement('li');if(!baseLayer&&(layer.displayInLayerSwitcher&&!layer.unlisted)){var lbl=document.createElement('span');lbl.className='label';lbl.appendChild(document.createTextNode(layer.name));if(layer.types[layer.typename]){var symbol=layer.types[layer.typename].legend.legend;var img=document.createElement("img");img.src=symbol;if(this.legendDimension){img.height=this.legendDimension.height;img.width=this.legendDimension.width;}
li.appendChild(img);}
li.appendChild(lbl);layer_ul.appendChild(li);OpenLayers.Event.observe(li,"click",this.findNearest.bind(this,layer));}}
this.dataLayersDiv.appendChild(layer_ul);},findNearest:function(facility,evt){this.clearResultsAndUpdateMarkers();this.layersDiv.style.display='none';this.progressDiv.style.display='block';this.resultsDiv.innerHTML="";this.resultsDiv.style.display='block';this.active_facility=facility;this.referencePoint=false;if(this.searchControl){if(this.searchControl.lastResult){var geom=new OpenLayers.Geometry.fromWKT(this.searchControl.lastResult.geometry);var center=new OpenLayers.LonLat(geom.x,geom.y);this.referencePoint=center;}else{var center=map.getCenter();var result={geometry:'POINT('+center.lon+' '+center.lat+')'};this.searchControl.showMapCenter(result);this.referencePoint=center;}}
else{var center=map.getCenter();this.referencePoint=center;}
var url=this.scriptURL+'?fid='+facility.typeId+'&x='+center.lon+'&y='+center.lat;OpenLayers.loadURL(url,null,this,this.handleNearestResponse,this.searchFailed);},showNav:function(){this.layersDiv.style.display='block';this.progressDiv.style.display='none';this.resultsDiv.style.display='none';},layerInActiveCategory:function(typename){var features=this.active_category['features'];for(var i=0,len=features.length;i<len;i++){if(features[i]==typename)
return true;}
return false;},onInputClick:function(e){if(!this.disabled){if(this.type=="radio"){this.checked=true;this.layer.map.setBaseLayer(this.layer,true);this.layer.map.events.triggerEvent("changebaselayer");}else{this.checked=!this.checked;this.control.updateMap();}}
OpenLayers.Event.stop(e);},onLayerClick:function(e){this.updateMap();},updateMap:function(){this.nodraw=true;for(var i=0;i<this.dataLayerInputs.length;i++){var input=this.dataLayerInputs[i];var inputLi=document.getElementById("li_for_"+input.name);inputLi.className=input.checked?"selectedli":"";var visibility=input.layer.getVisibility();if(visibility!=input.checked){input.layer.setVisibility(input.checked);}}},showControls:function(minimize){this.maximizeDiv.style.display=minimize?"":"none";this.minimizeDiv.style.display=minimize?"none":"";this.layersDiv.style.display=minimize?"none":"";},drawControlStructure:function(){this.div.className='box';var title=document.createElement('div');title.className='boxTitle';title.innerHTML='Find Nearest';this.div.appendChild(title);this.div.appendChild(this.buildCategoryNav());this.catHead=document.createElement('div');this.catHead.className='categoriesLabel';this.div.appendChild(this.catHead);if(this.categories.length==1)
this.catHead.style.display='none';this.body=document.createElement('div');this.body.className='body';this.div.appendChild(this.body);this.layersDiv=document.createElement("div");this.dataLayersDiv=document.createElement("div");this.layersDiv.appendChild(this.dataLayersDiv);this.body.appendChild(this.layersDiv);this.resultsDiv=document.createElement('div');this.resultsDiv.className='imgNearestResults';this.resultsDiv.style.display='none';this.body.appendChild(this.resultsDiv);this.progressDiv=document.createElement('div');this.progressDiv.className='imgNearestProgress';var pImg=document.createElement('img');pImg.src=this.loadingImgURL;var pMsg=document.createTextNode('Please wait while we retrive information.');this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';this.body.appendChild(this.progressDiv);},buildCategoryNav:function(){if(!this.categories){this.catsDiv=document.createElement('div');return this.catsDiv;}
if(this.categories.length==1){this.active_category=this.categories[0];this.catsDiv=document.createElement('div');return this.catsDiv;}
var div=document.createElement('div');div.className='categoriesHead';for(var i=0,l=this.categories.length;i<l;i++){var elem=document.createElement('div');elem.innerHTML=this.categories[i]['title'];var img=document.createElement('img');img.title=this.categories[i]['title'];if(this.categories[i]['initial_visibility']){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];}
else
img.src=this.categories[i]['inactive_icon'];div.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.catsDiv=div;return div;},activateCategory:function(cat,evt){this.catsDiv.innerHTML='';for(var i=0,l=this.categories.length;i<l;i++){var img=document.createElement('img');if(this.categories[i]['id']==cat){img.src=this.categories[i]['active_icon'];this.active_category=this.categories[i];img.title=this.categories[i]['title'];}
else{img.src=this.categories[i]['inactive_icon'];img.title=this.categories[i]['title'];}
this.catsDiv.appendChild(img);var actCat=this.activateCategory.bind(this,this.categories[i]['id']);OpenLayers.Event.observe(img,'click',OpenLayers.Function.bindAsEventListener(actCat,this));}
this.redraw();this.showNav();},ignoreEvent:function(evt){OpenLayers.Event.stop(evt);},mouseDown:function(evt){this.mouseDown=true;this.ignoreEvent(evt);},mouseUp:function(evt){if(this.mouseDown){this.mouseDown=false;this.ignoreEvent(evt);}},handleNearestResponse:function(request){var noResults=false;try{var response=eval('('+request.responseText+')');}catch(e){var response=false;}
if(!response){this.resultsDiv.innerHTML='Some problem occurred while retrieving requested information. Please try again.';noResults=true;}
if(request.status==200){var mainDiv=document.createElement('div');mainDiv.id='divPieNearestResults';if(!response.results==false&&response.results['features'].length>0){if(this.active_facility.types[this.active_facility.typename]){var active_facility=this.active_facility.types[this.active_facility.typename];if(active_facility.geo_type=='POINT'){var symbol=this.active_facility.types[this.active_facility.typename].legend.legend;var img=document.createElement('img');img.src=symbol;symbol=img;}else if(active_facility.geo_type=='LINESTRING'){var symbol=active_facility.styles[0];var border="0px solid "+symbol.strokeColor;var size=new OpenLayers.Size(15,5);var img=OpenLayers.Util.createDiv(null,null,size,null,'relative',border,'hidden',symbol.fillOpacity);img.style.background=symbol.strokeColor;img.style.marginTop='6px';img.style.cssFloat="left";img.className='img';symbol=img;symbol=document.createTextNode('');}else if(active_facility.geo_type=='POLYGON'){var symbol=active_facility.styles[0];var border="1px solid "+symbol.strokeColor;var size=new OpenLayers.Size(15,15);var img=OpenLayers.Util.createDiv(null,null,size,null,'relative',border,'hidden',symbol.fillOpacity);img.style.background=symbol.fillColor;img.style.cssFloat="left";img.className='img';symbol=img;symbol=document.createTextNode('');}}else{var symbol='';}
var heading=document.createElement('div');heading.className='subtitle';heading.appendChild(document.createTextNode('Search results for '));heading.appendChild(symbol);heading.appendChild(document.createTextNode(" "+this.active_facility.name));this.resultsDiv.appendChild(heading);var helpText=document.createElement('p');helpText.innerHTML='Click on the service name to centre on the map and view full details';this.resultsDiv.appendChild(helpText);if(this.backButtonDisplay=='both'||this.backButtonDisplay=='top'){var aClear=document.createElement('a');aClear.className='aButton';aClear.href='javascript:void(0);';aClear.innerHTML=OpenLayers.i18n(this.backButtonText);aClear.title='Click to clear current results and show menu';this.resultsDiv.appendChild(aClear);OpenLayers.Event.observe(aClear,'click',this.clearResultsAndUpdateMarkers.bind(this));}}
else{this.resultsDiv.innerHTML='<p>No results found.</p>';noResults=true;}
if(response.results){for(var len=response.results['features'].length,currIndex=0;currIndex<len;currIndex++){if(this.maxResults&&currIndex==this.maxResults)
break;var feat=response.results['features'][currIndex];var feat_name=(feat['properties']['name'])?feat['properties']['name']:this.active_facility.name;var distance=feat['properties']['distance'];var distance_in_miles=feat['properties']['distance_in_miles'];var dis_str=(distance/1000)+' Km ('+distance_in_miles+' miles)';var dist_in_km=this.roundNumber(distance/1000,this.decPointsInDistance);var dist_in_miles=this.roundNumber(distance_in_miles,this.decPointsInDistance);if(this.distanceUnit=='km'){dis_str=dist_in_km+' Km';}else if(this.distanceUnit=='mile'){dis_str=dist_in_miles+' miles';}else if(this.distanceUnit=='km-mile'){dis_str=dist_in_km+' Km ('+dist_in_miles+' miles)';}else if(this.distanceUnit=='mile-km'){dis_str=dist_in_miles+' miles ('+dist_in_km+' Km)';}else{dis_str=dist_in-km+' Km ('+dist_in_miles+' miles)';}
var feat_id=(feat['properties']['id'])?feat['properties']['id']:0;var div=document.createElement('div');div.className='nearestResultItem';var alpha_key=null;var ind_exists=this.resultExistsInSelected(feat);var alreadySelected=(ind_exists==-1)?false:this.selectedResults[ind_exists];var icon_images={normal:this.iconsBaseURL+(currIndex+1)+'.png',clicked:this.iconsBaseURL+(currIndex+1)+'_red.png',selected:null};var status='normal';if(alreadySelected!=false){status='selected';alpha_key=alreadySelected.alpha_key;icon_images.selected=alreadySelected.icon_images['selected'];alreadySelected.icon_images=icon_images;}
var img=document.createElement('img');img.src=icon_images[status];if(alreadySelected!=false){this.selectedResults[ind_exists].icon=img;}
var h3=document.createElement('h3');var a=document.createTextNode(feat_name);h3.appendChild(a);var h4=document.createElement('h4');h4.innerHTML=dis_str;var p=document.createElement('p');div.appendChild(img);div.appendChild(h3);div.appendChild(h4);div.appendChild(p);mainDiv.appendChild(div);var lonlat=new OpenLayers.LonLat(feat.geometry.coordinates[0],feat.geometry.coordinates[1])
if(status=='selected'){if(alreadySelected.marker){var marker=alreadySelected.marker;}
else
var marker=this.addMarker(feat,(currIndex+1),icon_images[status]);}
else
var marker=this.addMarker(feat,(currIndex+1),icon_images[status]);var currResult={feature:feat,icon:img,icon_images:icon_images,status:status,marker:marker,alpha_key:alpha_key,marker_key:(currIndex+1),selected_result:alreadySelected,symbol:symbol,typename:this.active_facility.typename,name:this.active_facility.name,id:this.active_facility.typename+'_'+feat_id}
marker.events.register('click',marker,this.onMarkerClick.bind(this,currResult));this.results.push(currResult);OpenLayers.Event.observe(h3,'click',this.onResultClick.bind(this,currResult,marker));if(alreadySelected!=false){this.selectedResults[ind_exists]=currResult;}}
this.resultsDiv.appendChild(mainDiv);if(this.forceAutoZoomToExtent)
this.autoZoom();}else{this.resultsDiv.innerHTML='<p>Some problem occurred while retrieving requested information. Please try again.</p>';noResults=true;}}else{this.resultsDiv.innerHTML='<p>Some problem occurred while retrieving requested information. Please try again.</p>';noResults=true;}
if(noResults){var aBack=document.createElement('a');aBack.className='aButton';aBack.href='javascript:void(0);';aBack.innerHTML=OpenLayers.i18n(this.backButtonText);aBack.title='Click to show menu';this.resultsDiv.appendChild(aBack);OpenLayers.Event.observe(aBack,'click',this.showNav.bind(this));}else{if(this.backButtonDisplay=='both'||this.backButtonDisplay=='bottom'){var aClear2=document.createElement('a');aClear2.className='aButton';aClear2.href='javascript:void(0);';aClear2.innerHTML=OpenLayers.i18n(this.backButtonText);aClear2.title='Click to clear current results and show menu';this.resultsDiv.appendChild(aClear2);OpenLayers.Event.observe(aClear2,'click',this.clearResultsAndUpdateMarkers.bind(this));}}
this.layersDiv.style.display='none';this.progressDiv.style.display='none';this.resultsDiv.style.display='block';},resultExistsInSelected:function(feat){if(this.selectedResults!=null){if(this.selectedResults.length==0)
return-1;else{for(var ind=0,len=this.selectedResults.length;ind<len;ind++){var id=this.active_facility.typename+'_'+feat['properties']['id'];if(id==this.selectedResults[ind].id)
return ind;}}}
return-1;},updateSelectedResults:function(){for(var ind=0,len=this.selectedResults.length;ind<len;ind++){this.selectedResultsDiv.removeChild(this.selectedResults[ind].selected_result_div);this.selectResult(this.selectedResults[ind]);}},addMarkerLayer:function(){if(!this.markerLayer){this.markerLayer=new OpenLayers.Layer.Markers("nearest_markers");this.map.addLayer(this.markerLayer);this.markerLayer.setZIndex(this.getMaxZIndexOfMapLayers());}},getMaxZIndexOfMapLayers:function(){var layers=map.layers;var maxZIndex=0;for(var ind=0,len=layers.length;ind<len;ind++){if(maxZIndex<layers[ind].getZIndex())
maxZIndex=layers[ind].getZIndex();}
return maxZIndex;},clearResultsAndUpdateMarkers:function(){this.results=null;this.results=[];this.clearMarkers();this.clearResults();for(var ind=0,len=this.selectedResults.length;ind<len;ind++){this.selectedResults[ind].icon=null;this.markerLayer.addMarker(this.selectedResults[ind].marker);}},clearMarkers:function(){if(this.markerLayer){this.markerLayer.clearMarkers();}
if(this.popup){this.popup.destroy();this.popup=null;}},clearResults:function(){this.layersDiv.style.display='block';this.progressDiv.style.display='none';this.resultsDiv.style.display='none';},addMarker:function(data,id,img_url,evt){if(!this.markerLayer)
this.addMarkerLayer();var template=this.active_facility.getFeatureTemplate(this.active_facility.typename);var htmlContent=(template)?template.process(data.properties):'';var url=img_url;var size=new OpenLayers.Size(31,36);if(this.markerOffset){var offset=new OpenLayers.Pixel(this.markerOffset.x,this.markerOffset.y);var icon=new OpenLayers.Icon(url,size,offset);}else{var icon=new OpenLayers.Icon(url,size);}
var loc=new OpenLayers.LonLat(data.geometry.coordinates[0],data.geometry.coordinates[1]);var marker=new OpenLayers.Marker.TemplateMarker(loc,icon,htmlContent);this.markerLayer.addMarker(marker);return marker;},centerOnMarker:function(lonlat,evt){this.map.panTo(lonlat);},onResultClick:function(result,marker,evt){this.map.panTo(result.marker.lonlat);if(result.status!='selected'){result.status='clicked';result.icon.src=result.icon_images[result.status];result.marker.setUrl(result.icon.src);}
OpenLayers.Event.stop(evt);},selectedResultClicked:function(result,evt){this.map.panTo(result.marker.lonlat);OpenLayers.Event.stop(evt);},delSelectedResult:function(result,evt){this.selectedResultsDiv.removeChild(result.selected_result_div);result.selected_result_div=null;result.status='normal';var tempArr=[];for(var ind=0,len=this.selectedResults.length;ind<len;ind++){if(this.selectedResults[ind].status=='selected')
tempArr.push(this.selectedResults[ind]);}
this.selectedResults=tempArr;var exists=false;for(var idx=0,len=this.results.length;idx<len;idx++){if(this.results[idx].id==result.id){this.results[idx].status='normal';exists=true;break;}}
if(!exists){result.marker.destroy();}else{result.icon.src=result.icon_images[result.status];result.marker.setUrl(result.icon_images[result.status]);}},autoZoom:function(){if(this.markerLayer&&this.markerLayer.markers.length>0){var extent=this.markerLayer.getDataExtent();if(this.referencePoint){extent.extend(this.referencePoint);}
this.map.zoomToExtent(extent);}},onMarkerClick:function(result,evt){marker=result.marker;if(this.popup)
this.popup.destroy();var htmlContent=marker.htmlContent;if(this.selectableMarkers){if(!this.selectedResultsDiv){this.selectedResultsDiv=document.createElement('div');document.body.appendChild(this.selectedResultsDiv);}}
this.popup=new OpenLayers.Popup.FramedCloud("chicken",marker.lonlat,null,"<div style='font-size:.9em'>"+htmlContent+"</div>",null,true,this.onPopupClose);this.map.addPopup(this.popup);if(this.selectableMarkers&&result.status!='selected'){if(this.popup.contentDiv!=null){var d=document.createElement('div');d.style.position='relative';d.style.textAlign='right';var a=document.createElement('a');a.href="javascript: void(0);";a.innerHTML='Select';d.appendChild(a);this.popup.contentDiv.appendChild(d);}
this.popup.updateSize();OpenLayers.Event.observe(a,'click',this.selectResult.bind(this,result));}
OpenLayers.Event.stop(evt);},selectResult:function(result,evt){var feat=result.feature;var feat_name=(feat['properties']['name'])?feat['properties']['name']:this.active_facility.name;var distance=feat['properties']['distance'];var distance_in_miles=feat['properties']['distance_in_miles'];var dis_str=(distance/1000)+' Km ('+distance_in_miles+' miles)';var div=document.createElement('div');div.className='div_selected_destination_item';if(!result.alpha_key){if(this.currentCharIndex<this.alphaIcons.length)
result.alpha_key=this.alphaIcons.charAt([this.currentCharIndex++]);else
result.alpha_key='z';}
if(result.status!='selected'){result.status='selected';result.icon_images['selected']=this.iconsBaseURL+result.alpha_key+'_red.png';}
var img=document.createElement('img');result.icon.src=img.src=result.icon_images[result.status];result.marker.setUrl(img.src);var h3=document.createElement('h3');var a=document.createTextNode(feat_name);h3.appendChild(a);var h4=document.createElement('h4');h4.appendChild(result.symbol);h4.innerHTML+=" "+result.name;var p=document.createElement('p');var delLink=document.createElement('a');delLink.href='javascript:void(0);';delLink.innerHTML='Delete';delLink.style.textAlign='right';p.appendChild(delLink);div.appendChild(img);div.appendChild(h3);div.appendChild(h4);div.appendChild(p);this.selectedResultsDiv.appendChild(div);result.selected_result_div=div;result.selected=true;this.selectedResults.push(result);OpenLayers.Event.observe(h3,'click',this.selectedResultClicked.bind(this,result));OpenLayers.Event.observe(delLink,'click',this.delSelectedResult.bind(this,result));if(evt){var target=(evt.srcElement)?evt.srcElement:evt.target;target.style.display='none';this.popup.updateSize();OpenLayers.Event.stop(evt);}},onPopupClose:function(){this.hide();},searchFailed:function(){log('failed');this.progressDiv.style.display='none';this.showNav();},roundNumber:function(num,dec){var result=Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);return result;},CLASS_NAME:"OpenLayers.Control.PieNearest"});OpenLayers.Control.Routing=OpenLayers.Class(OpenLayers.Control,{routesPlotted:false,form:null,layer:null,feature:null,controls:null,contentDiv:null,formDiv:null,directionsDiv:null,searchResultsDiv:null,resultInfo:null,zoom:5,jobs:0,maxDestinations:5,destinations:[],destinationOptions:0,networkTypes:[['Lorry',1],['By Cycle',5],['Walking',6],['By Car',7],['Lorry old',4],['By Cycle old',2],['Walking old',3]],routeTypes:[['Fatest','SETFASTEST'],['Shortest','SETSHORTEST']],alpha:'abcdefghijklmnopqrstuvwxyz',currentCharIndex:0,showMarker:true,lookup:'lstg',scriptName:'routing.py',imagesBaseURL:'images/',lastResult:false,clearSearch:true,scriptURL:'/map-bin/search.py',restrictSearch:true,maxExtent:null,markerURL:'http://static.media.thepieguide.com/markers/red_circle.png',loadingImg:'loading_ani.gif',title:'Get Directions',allowHeightFilter:false,allowWeightFilter:false,allowWidthFilter:false,decPointsInDistance:1,routesAvailable:false,noRouteError:'No routes were found.',initialize:function(options){this.searchButton=this.imagesBaseURL+'button-searchsubmit.png';OpenLayers.Control.prototype.initialize.apply(this,arguments);this.loadingImgURL=OpenLayers.Util.getImagesLocation()+this.loadingImg;this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;this.searchScriptURL=OpenLayers.Util.getScriptsLocation()+'multisearch.py';this.markersBaseURL="http://static.media.thepieguide.com/markers/";this.staticBaseURL="http://static.media.thepieguide.com/";},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='routingControlDiv';this.div.className='routingControl';}else{this.div.className='routingControl';}
var title=document.createElement('div');title.innerHTML=OpenLayers.i18n(this.title);title.className='title';this.div.appendChild(title);var containerDiv=document.createElement('div');containerDiv.className='routingContainerDiv';this.div.appendChild(containerDiv);this.formDiv=document.createElement('div');containerDiv.appendChild(this.formDiv);this.addDestination();this.addDestination();this.addDestinationLink=document.createElement('div');this.addDestinationLink.innerHTML='Add destination';this.addDestinationLink.className='addDestination';containerDiv.appendChild(this.addDestinationLink);OpenLayers.Event.observe(this.addDestinationLink,'click',this.addDestination.bind(this));this.reverseLink=document.createElement('div');this.reverseLink.innerHTML='Reverse destinations';this.reverseLink.className='reverseDestinations';containerDiv.appendChild(this.reverseLink);OpenLayers.Event.observe(this.reverseLink,'click',this.reverseDestinations.bind(this));this.routingOptionsContainer=document.createElement('div');this.routingOptionsContainer.className='routingOptionsContainer';containerDiv.appendChild(this.routingOptionsContainer);this.networkTypeSelect=document.createElement('select');for(var ind=0,end=this.networkTypes.length;ind<end;ind++){this.networkTypeSelect.options[this.networkTypeSelect.options.length]=new Option(this.networkTypes[ind][0],this.networkTypes[ind][1]);}
var modeDiv=document.createElement('div');modeDiv.className='routingModeDiv';var modeLabel=document.createElement('label');modeLabel.innerHTML='Mode';modeDiv.appendChild(modeLabel);modeDiv.appendChild(this.networkTypeSelect);this.routingOptionsContainer.appendChild(modeDiv);this.routeTypeSelect=document.createElement('select');for(var ind=0,end=this.routeTypes.length;ind<end;ind++){this.routeTypeSelect.options[this.routeTypeSelect.options.length]=new Option(this.routeTypes[ind][0],this.routeTypes[ind][1]);}
this.routingOptionsContainer.appendChild(this.routeTypeSelect);this.routeTypeSelect.style.display='none';if(this.allowHeightFilter){this.heightFilter={};this.heightFilter.input=document.createElement('input');this.heightFilter.label=document.createElement('label');this.heightFilter.label.innerHTML='Height (m)';this.heightFilter.div=document.createElement('div');this.heightFilter.div.className='dimensionFilterDiv';this.heightFilter.div.appendChild(this.heightFilter.label);this.heightFilter.div.appendChild(this.heightFilter.input);this.routingOptionsContainer.appendChild(this.heightFilter.div);}
if(this.allowWeightFilter){this.weightFilter={};this.weightFilter.input=document.createElement('input');this.weightFilter.label=document.createElement('label');this.weightFilter.label.innerHTML='Weight (T)';this.weightFilter.div=document.createElement('div');this.weightFilter.div.className='dimensionFilterDiv';this.weightFilter.div.appendChild(this.weightFilter.label);this.weightFilter.div.appendChild(this.weightFilter.input);this.routingOptionsContainer.appendChild(this.weightFilter.div);}
if(this.allowWidthFilter){this.widthFilter={};this.widthFilter.input=document.createElement('input');this.widthFilter.label=document.createElement('label');this.widthFilter.label.innerHTML='Width (m)';this.widthFilter.div=document.createElement('div');this.widthFilter.div.className='dimensionFilterDiv';this.widthFilter.div.appendChild(this.widthFilter.label);this.widthFilter.div.appendChild(this.widthFilter.input);this.routingOptionsContainer.appendChild(this.widthFilter.div);}
var submit=document.createElement('input');submit.type='button';submit.value='Get Directions';submit.className='btnGetDirections';containerDiv.appendChild(submit);OpenLayers.Event.observe(submit,'click',this.acquireDestinationGeoms.bind(this));this.searchResultsDiv=document.createElement('div');this.div.appendChild(this.searchResultsDiv);this.destinationSelectionDiv=document.createElement('div');this.destinationSelectionDiv.className='routingDestinationSelectionDiv';var c_url=this.staticBaseURL+'images/img_icon_cross.gif';var c_img=OpenLayers.Util.createAlphaImageDiv(null,null,null,c_url,'absolute','','scale',1,false);c_img.className='close';this.destinationSelectionDiv.appendChild(c_img);document.body.appendChild(this.destinationSelectionDiv);OpenLayers.Util.modifyDOMElement(this.destinationSelectionDiv,null,null,null,null,null,null,0.9);OpenLayers.Event.observe(c_img,'click',this.closeDestinationSelectionDiv.bind(this));this.progressDiv=document.createElement('div');this.progressDiv.className='imgProgress';var pImg=document.createElement('img');pImg.src=this.loadingImgURL;var pMsg=document.createTextNode(OpenLayers.i18n('Please wait while we retrive information.'));this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';containerDiv.appendChild(this.progressDiv);this.directionsDiv=document.createElement('div');this.directionsDiv.className='routeDirectionsDiv';containerDiv.appendChild(this.directionsDiv);this.updateAddDestinationLinkVisibility();if(this.map){this.addMarkerLayer();this.addRouteLayer();}},resetAllDestinations:function(){this.destinations=[];this.addDestination();this.addDestination();},resetControl:function(){this.resetAllDestinations();this.updateDestinations();this.updateAddDestinationLinkVisibility();},forTest:function(){this.destinations[0].input.value='n19ng';this.destinations[1].input.value='pentonville';var submit=document.createElement('input');submit.type='button';submit.value='Plot';OpenLayers.Event.observe(submit,'click',this.getRoute.bind(this));this.acquireDestinationGeoms();},updateAddDestinationLinkVisibility:function(){if(this.addDestinationLink)
this.addDestinationLink.style.display=(this.currentCharIndex<this.maxDestinations)?'':'none';},getFilterElemVal:function(elem){if(elem){if(elem.value.trim()==''){return false;}else{var num=parseFloat(elem.value);if(isNaN(num)){elem.value='';return false;}else{elem.value=num;return num;}}}else{return false;}},getRoute:function(){if(this.jobs==0){var post={};post.destinations=[];for(var i=0,l=this.destinations.length;i<l;i++){var destination={id:i,location:this.destinations[i].geometry_for,lon:this.destinations[i].lon,lat:this.destinations[i].lat};post.destinations.push(destination);}
post.network=this.networkTypeSelect.options[this.networkTypeSelect.selectedIndex].value;post.route_type=this.routeTypeSelect.options[this.routeTypeSelect.selectedIndex].value;if(this.allowHeightFilter){post.height=this.getFilterElemVal(this.heightFilter.input);}else{post.height=false;}
if(this.allowWeightFilter){post.weight=this.getFilterElemVal(this.weightFilter.input);}else{post.weight=false;}
if(this.allowWidthFilter){post.width=this.getFilterElemVal(this.widthFilter.input);}else{post.width=false;}
post.restrictions=(post.height!==false)||(post.weight!==false)||(post.width!==false);var jsontext='';try{jsontext=JSON.stringify(post);}catch(e){return;}
var params="network="+this.networkTypeSelect.options[this.networkTypeSelect.selectedIndex].value+'&';params+="route_type="+this.routeTypeSelect.options[this.routeTypeSelect.selectedIndex].value+'&';OpenLayers.Request.POST({method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},data:"json="+jsontext,url:this.scriptURL,scope:this,success:this.cbGetRouteSuccess,failure:this.cbGetRouteFailure});this.processingRoute(true);}},addRouteLayer:function(){if(!this.routeLayer){var routeStyleMap=new OpenLayers.StyleMap({strokeColor:"#0000FF",strokeWidth:4,strokeOpacity:0.7,fill:"#0000FF",fillOpacity:0.2});var lookup={0:{strokeColor:"#0000FF",strokeWidth:5},1:{strokeColor:"#FF0000",strokeWidth:3,strokeOpacity:0.9}}
routeStyleMap.addUniqueValueRules("default","type",lookup);this.routeLayer=new OpenLayers.Layer.Vector("Route",{projection:"EPSG:27700",styleMap:routeStyleMap});this.map.addLayer(this.routeLayer);}},plotRoutes:function(){if(!this.routeLayer){this.addRouteLayer();}
if(typeof this.routes!='undefined'){this.routeLayer.destroyFeatures();for(var indx=0,len=this.routes.length;indx<len;indx++){if(this.routes[indx].route==-1)
continue;if(this.routes[indx].route.geometry==null)
continue;var parser=new OpenLayers.Format.WKT({externalProjection:new OpenLayers.Projection('EPSG:4326'),internalProjection:new OpenLayers.Projection('EPSG:27700')});var lineFeat=parser.read(this.routes[indx].route.geometry);lineFeat.attributes.type=0;this.routeLayer.addFeatures([lineFeat]);}
if(this.routeLayer.getDataExtent())
this.map.zoomToExtent(this.routeLayer.getDataExtent());this.showDirections();}},cbGetRouteSuccess:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response={success:false};}
if(request.status==200&&response.success){var routes=response.routes;this.routes=null;this.routes=new Array();this.routes=routes;this.plotRoutes();}else{}
this.processingRoute(false);},cbGetRouteFailure:function(request){this.processingRoute(false);},addDestination:function(){var currentIndex=this.currentCharIndex++;var container=document.createElement('div');container.className='dd_container';var legend=document.createElement('div');legend.className='legend';var url=this.markersBaseURL+this.alpha.charAt(currentIndex)+'_square.png';var marker=OpenLayers.Util.createAlphaImageDiv(null,null,null,url,'relative','','scale',1,false);legend.appendChild(marker);var input=document.createElement('div');input.className='input';var query=document.createElement('input');query.type='text';input.appendChild(query);var cross=document.createElement('div');cross.className='cross';var c_url=this.staticBaseURL+'images/img_icon_cross.gif';var c_img=OpenLayers.Util.createAlphaImageDiv(null,null,null,c_url,'relative','','scale',1,false);cross.appendChild(c_img);container.appendChild(legend);container.appendChild(input);container.appendChild(cross);var dest={index:currentIndex,legend:marker,input:query,cross:cross,container:container};this.destinations.push(dest);this.formDiv.appendChild(container);OpenLayers.Event.observe(cross,'click',this.removeDestination.bind(this,dest));OpenLayers.Event.observe(query,'keyup',this.sniffEnter.bind(this));this.updateDestinations();this.updateAddDestinationLinkVisibility();},redrawDestinations:function(){},removeDestination:function(destination){this.removeMarker(destination.index);this.formDiv.removeChild(destination.container);this.destinations.splice(destination.index,1);this.currentCharIndex--;this.updateDestinations();this.updateAddDestinationLinkVisibility();if(typeof destination.geometry!='undefined'&&typeof destination.geometry_for!='undefined')
this.acquireDestinationGeoms();destination=null;},removeEmptyDestinations:function(){var len=this.destinations.length;for(var index=0;index<len;index++){if(len==2)
return;if(this.destinations[index].input.value==''){this.removeDestination(this.destinations[index]);len--;index--;}}},removeInvalidDestinations:function(){var len=this.destinations.length;for(var index=0;index<len;index++){if(len==2)
return;if(typeof this.destinations[id]['geometry']!='undefined'){if(this.destinations[id]['geometry']==null){this.removeDestination(this.destinations[index]);len--;index--;}}}},reverseDestinations:function(){this.destinations.reverse();this.updateDestinations();this.updateDestinationDOMElements();this.acquireDestinationGeoms();},updateDestinations:function(){var display_remove=(this.destinations.length==2)?'none':'';for(var index=0,end=this.destinations.length;index<end;index++){if(this.destinations[index].index!=index){this.destinations[index].index=index;var url=this.markersBaseURL+this.alpha.charAt(index)+'_square.png';OpenLayers.Util.modifyAlphaImageDiv(this.destinations[index].legend,null,null,null,url,'relative','','scale',1);if(this.destinations[index].marker){this.updateMarker(index);}}
this.destinations[index].cross.style.display=display_remove;}},updateDestinationDOMElements:function(){for(var index=0,end=this.destinations.length;index<end;index++){this.formDiv.removeChild(this.destinations[index].container);}
for(var index=0,end=this.destinations.length;index<end;index++){this.formDiv.appendChild(this.destinations[index].container);}},calculateRoutes:function(){},preSearch:function(){if(typeof this.routeLayer!='undefined')
this.routeLayer.destroyFeatures();this.resetDirections();this.removeEmptyDestinations();this.closeDestinationSelectionDiv();},acquireDestinationGeoms:function(){this.preSearch();for(var index=0,end=this.destinations.length;index<end;index++){if(typeof this.destinations[index]['geometry']=='undefined'&&typeof this.destinations[index]['geometry_for']=='undefined')
this.search(this.destinations[index]);else
if(this.destinations[index].geometry_for!=this.destinations[index].input.value){this.destinations[index]['geometry']=null;this.destinations[index]['geometry_for']=null;this.destinations[index]['lon']=null;this.destinations[index]['lat']=null;if(typeof this.destinations[index]['marker']!='undefined')
if(this.destinations[index]['marker']!=null){this.destinations[index]['marker'].destroy();this.markerLayer.removeMarker(this.destinations[index].marker);}
this.destinations[index]['marker']=null;this.search(this.destinations[index]);}}
this.getRoute();},sniffEnter:function(evt){if(evt)
if(evt.keyCode==13)
this.acquireDestinationGeoms()},search:function(destination){var query=destination.input.value;if(query.length==''){return false;}
var validPostcode=this.checkPostcode(query);if(validPostcode){query.value=query=validPostcode;this.lastSearch={lookup:'postcode',q:validPostcode}}
else{if(query.length<3){return false;}
else{this.lastSearch={lookup:'lstg',q:query}}}
var lookup=this.lastSearch.lookup;var params='q='+query+'&lookup='+lookup+'&id='+destination.index;if(this.restrictSearch){if(!this.maxExtent){this.maxExtent=this.map.maxExtent;}
var ext=this.maxExtent;var extent='&bbox='+ext.left+','+ext.bottom+','+ext.right+','+ext.top;params+=extent;}
var url=this.searchScriptURL+"?"+params;this.destinationSelectionDiv.style.display='none';OpenLayers.loadURL(url,null,this,this.handleSearchResponse,this.searchFailed);this.processing(true);},addMarkerLayer:function(){if(typeof this.markerLayer=='undefined'){this.markerLayer=new OpenLayers.Layer.Markers('routing_search_marker');this.map.addLayer(this.markerLayer);}},addMarker:function(result,id){if(!this.markerLayer)
this.addMarkerLayer();if(!this.destinations[id].marker||this.destinations[id].marker==null){var geom=new OpenLayers.Geometry.fromWKT(result.geometry);var url=this.markersBaseURL+this.alpha.charAt(id)+'_red.png';var size=new OpenLayers.Size(31,36);var offset=new OpenLayers.Pixel(-(size.w/2),-(size.h));var icon=new OpenLayers.Icon(url,size,offset);var loc=new OpenLayers.LonLat(geom.x,geom.y);this.destinations[id]['marker']=new OpenLayers.Marker(loc,icon,offset);this.markerLayer.addMarker(this.destinations[id]['marker']);}
else{var geom=new OpenLayers.Geometry.fromWKT(result.geometry);var loc=new OpenLayers.LonLat(geom.x,geom.y);this.destinations[id]['marker'].moveTo(this.map.getLayerPxFromLonLat(loc));var url=this.markersBaseURL+this.alpha.charAt(id)+'_red.png';this.destinations[id].marker.icon.url=url;}},updateMarker:function(id){if(this.markerLayer&&this.destinations[id].marker){if(this.destinations[id]['marker']!=null){var url=this.markersBaseURL+this.alpha.charAt(id)+'_red.png';this.destinations[id].marker.setUrl(url);this.markerLayer.redraw();}}},removeMarker:function(id){if(this.markerLayer&&this.destinations[id].marker){if(this.destinations[id]['marker']!=null){this.destinations[id].marker.destroy();this.markerLayer.removeMarker(this.destinations[id].marker);this.destinations[id].marker=null;this.markerLayer.redraw();}}},removeMarkers:function(id){if(this.markerLayer&&this.destinations[id].marker){if(this.destinations[id]['marker']!=null){this.markerLayer.clearMarkers();this.markerLayer.redraw();}}},processing:function(on){this.jobs=(on)?this.jobs+1:this.jobs-1;this.progressDiv.style.display=(this.jobs>0)?'block':'none';if(this.jobs==0&&this.destinationOptions==0){this.getRoute();}},processingRoute:function(on){this.progressDiv.style.display=(on)?'block':'none';},searching:function(on){this.progressDiv.style.display=(on)?'block':'none';},toggleClearButton:function(on){this.clearButton.style.display=(on)?'block':'none';},searchFailed:function(){this.processing(false);},handleSearchResponse:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response=false;}
if(!response)
this.searchResultsDiv.innerHTML=OpenLayers.i18n("We were unable to process this request. Please try again");if(response.results!=false){searchResults=response.results;var rec=(searchResults.length>1)?'records':'record'
if(searchResults.length==1){if(response.id!='undefined'){this.selectResult(response.id,response.lookup,searchResults[0]);this.routesAvailable=this.routesAvailable&&true;}}
else{this.routesAvailable=this.routesAvailable&&false;this.showResultOptions(response);}}else{}
this.processing(false);},showResultOptions:function(response){var searchResults=response.results;var div=document.createElement('div');div.className='destinationOptionsContainer';this.destinationSelectionDiv.appendChild(div);this.destinationOptions++;var legend=this.destinations[response.id].legend.cloneNode(true);legend.id='cloned_'+legend.id;legend.setAttribute('style',legend.getAttribute('style')+";float:left");var info=document.createElement('p');var infoTxt=OpenLayers.i18n('Click to select one from')+" "+searchResults.length+" "+OpenLayers.i18n('records');info.appendChild(legend);info.appendChild(document.createTextNode(infoTxt));var ul=document.createElement('ul');ul.className='options';for(var len=searchResults.length,currIndex=0;currIndex<len;currIndex++){var li=document.createElement('li');var a=document.createElement('a');var result=searchResults[currIndex];var resultText='';if(response.lookup=='postcode')
resultText=result.postcode;else
if(response.lookup=='lstg'){resultText=result.name;resultText+=(typeof(result.district)!='undefined')?', '+result.district:'';}
li.innerHTML=resultText;li.style.cursor='pointer';ul.appendChild(li);OpenLayers.Event.observe(li,'click',this.selectResult.bind(this,response.id,response.lookup,result,div));}
div.appendChild(info);div.appendChild(ul);var ul_height=searchResults.length*16;ul_height=(ul_height>100)?100:ul_height;ul.style.height=ul_height+'px';if(this.destinationOptions>0){this.destinationSelectionDiv.style.display='block';var pos=OpenLayers.Util.pagePosition(this.div);var sz=OpenLayers.Util.getRenderedDimensions(this.div);var left=pos[0]+sz.w+35;var top=pos[1]+40;this.destinationSelectionDiv.style.left=left+'px';this.destinationSelectionDiv.style.top=top+'px';}},closeDestinationSelectionDiv:function(){this.destinationOptions=0;this.destinationSelectionDiv.innerHTML="";var c_url=this.staticBaseURL+'images/img_icon_cross.gif';var c_img=OpenLayers.Util.createAlphaImageDiv(null,null,null,c_url,'absolute','','scale',1,false);c_img.className='close';this.destinationSelectionDiv.appendChild(c_img);OpenLayers.Event.observe(c_img,'click',this.closeDestinationSelectionDiv.bind(this));this.destinationSelectionDiv.style.display='none';},selectResult:function(id,lookup,result,div){this.destinations[id]['geometry']=result.geometry;var geom=new OpenLayers.Geometry.fromWKT(result.geometry);geom=geom.transform(new OpenLayers.Projection('EPSG:27700'),new OpenLayers.Projection('EPSG:4326'));if(lookup=='postcode')
this.destinations[id].input.value=result.postcode;else if(lookup=='lstg')
this.destinations[id].input.value=result.name;this.destinations[id]['geometry_for']=this.destinations[id].input.value;this.destinations[id]['lon']=geom.x;this.destinations[id]['lat']=geom.y;if(div){this.destinationSelectionDiv.removeChild(div);this.destinationOptions--;if(this.destinationOptions==0){this.destinationSelectionDiv.style.display='none';this.getRoute();}}
this.addMarker(result,id);},previewResult:function(result){if(result){this.addMarker(result);}},showResult:function(result){if(result){this.lastResult=result;var geom=new OpenLayers.Geometry.fromWKT(result.geometry);if(this.showMarker){this.addMarker(result);if(this.clearSearch){this.searchResultsDiv.innerHTML="";this.toggleClearButton(true);}}
this.map.setCenter(new OpenLayers.LonLat(geom.x,geom.y),this.zoom);}},showOptions:function(){return},clearSearch:function(){this.lastResult=false;this.inputField.value='';if(this.showMarker){this.removeMarker();}
this.toggleClearButton(false);},resetDirections:function(){this.directionsDiv.innerHTML='';},showDirections:function(){var routes=this.routes;var info='';var lastTurn=-1;this.textDirections=[];for(var ind in routes){var textDirection={title:'',info:this.noRouteError,directions:[]};var route=routes[ind].route;if(route==-1){textDirection.title="Directions from "+this.destinations[routes[ind].from].geometry_for+' to '+this.destinations[routes[ind].to].input.value;info+="<div class='title'><div id='route_color_"+ind+"'></div>Directions from "+this.destinations[routes[ind].from].geometry_for+' to '+this.destinations[routes[ind].to].input.value+'</div>';info+="<div class='error'>"+this.noRouteError+"</div>";continue;}
textDirection.title="Directions from "+this.destinations[routes[ind].from].geometry_for+' to '+this.destinations[routes[ind].to].geometry_for;info+="<div class='title'><div id='route_color_"+ind+"'></div>Directions from "+this.destinations[routes[ind].from].geometry_for+' to '+this.destinations[routes[ind].to].geometry_for+'</div>';var dist_in_km=route.segments[route.segments.length-1].TotalDist;var dist_in_miles=dist_in_km*0.622;dist_in_km=this.roundNumber(dist_in_km,this.decPointsInDistance);dist_in_miles=this.roundNumber(dist_in_miles,this.decPointsInDistance);info+="<div class='total_distance'><b>Total distance:</b> "+dist_in_km+" Km ("+dist_in_miles+" miles)</div>";textDirection.info="Total distance: "+dist_in_km+" Km ("+dist_in_miles+" miles)";info+="<ul class='routeDirections'>";for(var i in route.segments){if(i==0)
lastTurn=this.getTurnInfo(-1);else
if(i==route.segments.length)
lastturn=this.getTurninfo(-3);else
lastTurn=this.getTurnInfo(route.segments[i-1].Turn);ind=parseInt(i)+1;var parsedDirection=this.getTextDirection(route.segments[i],lastTurn);textDirection.directions.push(parsedDirection);info+='<li>'+this.getTextDirection(route.segments[i],lastTurn)+'</li>';}
info+='</ul>';this.textDirections.push(textDirection);}
this.directionsDiv.innerHTML=info;},getTextDirection:function(segment,lastTurn){var dist=segment.Dist;var speed=segment.Speed;var time=segment.Time;var totalDist=segment.TotalDist;var totalTime=segment.TotalTime;var turn=this.getTurnInfo(segment.Turn);var road=(segment.Name.trim()==''||segment.Name==undefined)?'Unnamed road':segment.Name;var geometry=segment.geometry;if(dist<1){dist=dist*1000;dist=this.roundNumber(dist,this.decPointsInDistance);dist=dist+' metres'}else{dist=this.roundNumber(dist,this.decPointsInDistance);dist=dist+' km'}
var str=lastTurn.text+' at '+road+' ('+dist+')';return str;},getTurnInfo:function(angle){var angleInfo=new Array();angleInfo[0]={text:'Straight on'};angleInfo[1]={text:'Slight turn to the left'};angleInfo[2]={text:'Turn left'};angleInfo[3]={text:'Sharp turn to the left'};angleInfo[4]={text:'U-turn'};angleInfo[5]={text:'Sharp turn to the right'};angleInfo[6]={text:'Turn right'};angleInfo[7]={text:'Slight turn to the right'};angleInfo[8]={text:'Straight on'};angleInfo[9]={text:'Starting on'};angleInfo[10]={text:'Via'};angleInfo[11]={text:'End at'};angleInfo[12]={text:'Not possible'};angleInfo[13]={text:'Exit from roundabout'};angleInfo[14]={text:'Unkown'};var angleIndex=14;if(angle>=0&&angle<=22){angleIndex=0;}
else if(angle>=23&&angle<=67){angleIndex=1;}
else if(angle>=68&&angle<=112){angleIndex=2;}
else if(angle>=113&&angle<=157){angleIndex=3;}
else if(angle>=158&&angle<=202){angleIndex=4;}
else if(angle>=203&&angle<=247){angleIndex=5;}
else if(angle>=248&&angle<=292){angleIndex=6;}
else if(angle>=293&&angle<=337){angleIndex=7;}
else if(angle>=338&&angle<=359){angleIndex=8;}
else if(angle==-1){angleIndex=9;}
else if(angle==-2){angleIndex=10;}
else if(angle==-3){angleIndex=11;}
else if(angle==360){angleIndex=12;}
else if(angle>=361||angle==-360){angleIndex=13;}
else{angleIndex=14;}
var turnInfo=angleInfo[angleIndex];turnInfo.text='<b>'+turnInfo.text+'</b>';return turnInfo;},isPostcode:function(str){var is_postcode=false;var postcode='';for(var i=0;i<str.length;i++)
if(str.charAt(i)!=' ')
postcode=postcode+str.charAt(i);if(postcode.length>8)
return false;if(this.isNumber(postcode.charAt(0))==true)
return false;if(this.isNumber(postcode.charAt(postcode.length-1))==true&&postcode.length<5)
return true;if(this.isNumber(postcode.charAt(postcode.length-2))==true&&postcode.length<5)
return true;var postcode_end=postcode.substr(postcode.length-3,3);var postcode_start=postcode.substr(0,postcode.length-3);if(this.isNumber(postcode_end.charAt(0))==false)
return false;if(this.isNumber(postcode_end.charAt(1))==true)
return false;if(this.isNumber(postcode_end.charAt(2))==true)
return false;var check=false;for(i=0;i<postcode_start.length;i++)
if(this.isNumber(postcode_start.charAt(i))==true)
check=true;if(check==false)
return false;return true;},roundNumber:function(num,dec){var result=Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);return result;},isNumber:function(c){if(c=='0')return true;if(c=='1')return true;if(c=='2')return true;if(c=='3')return true;if(c=='4')return true;if(c=='5')return true;if(c=='6')return true;if(c=='7')return true;if(c=='8')return true;if(c=='9')return true;return false;},checkPostcode:function(toCheck){var alpha1="[abcdefghijklmnoprstuwyz]";var alpha2="[abcdefghklmnopqrstuvwxy]";var alpha3="[abcdefghjkstuw]";var alpha4="[abehmnprvwxy]";var alpha5="[abdefghjlnpqrstuwxyz]";var pcexp=new Array();pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}[0-9]{1}"+alpha3+"{1})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(/^(GIR)(\s*)(0AA)$/i);pcexp.push(/^(bfpo)(\s*)([0-9]{1,4})$/i);pcexp.push(/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);pcexp.push(/^([A-Z]{4})(\s*)(1ZZ)$/i);var postCode=toCheck;pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}[0-9]{1,2})(\\s*)([0-9]{1})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})(\\s*)([0-9]{1}"+alpha5+"{0,2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]?)$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]{1}"+alpha5+"{1,2})$","i"));var valid=false;for(var i=0;i<pcexp.length;i++){if(pcexp[i].test(postCode)){pcexp[i].exec(postCode);postCode=RegExp.$1.toUpperCase()+" "+RegExp.$3.toUpperCase();postCode=postCode.replace(/C\/O\s*/,"c/o ");valid=true;break;}}
if(valid){return postCode;}else return false;},CLASS_NAME:"OpenLayers.Control.Routing"});OpenLayers.Control.Scale=OpenLayers.Class(OpenLayers.Control,{element:null,initialize:function(element,options){OpenLayers.Control.prototype.initialize.apply(this,[options]);this.element=OpenLayers.Util.getElement(element);},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!this.element){this.element=document.createElement("div");this.div.appendChild(this.element);}
this.map.events.register('moveend',this,this.updateScale);this.updateScale();return this.div;},updateScale:function(){var scale=this.map.getScale();if(!scale){return;}
if(scale>=9500&&scale<=950000){scale=Math.round(scale/1000)+"K";}else if(scale>=950000){scale=Math.round(scale/1000000)+"M";}else{scale=Math.round(scale);}
this.element.innerHTML=OpenLayers.i18n("scale",{'scaleDenom':scale});},CLASS_NAME:"OpenLayers.Control.Scale"});OpenLayers.Control.ScaleLine=OpenLayers.Class(OpenLayers.Control,{maxWidth:100,topOutUnits:"km",topInUnits:"m",bottomOutUnits:"mi",bottomInUnits:"ft",eTop:null,eBottom:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,[options]);},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!this.eTop){this.div.style.display="block";this.div.style.position="absolute";this.eTop=document.createElement("div");this.eTop.className=this.displayClass+"Top";var theLen=this.topInUnits.length;this.div.appendChild(this.eTop);if((this.topOutUnits=="")||(this.topInUnits=="")){this.eTop.style.visibility="hidden";}else{this.eTop.style.visibility="visible";}
this.eBottom=document.createElement("div");this.eBottom.className=this.displayClass+"Bottom";this.div.appendChild(this.eBottom);if((this.bottomOutUnits=="")||(this.bottomInUnits=="")){this.eBottom.style.visibility="hidden";}else{this.eBottom.style.visibility="visible";}}
this.map.events.register('moveend',this,this.update);this.update();return this.div;},getBarLen:function(maxLen){var digits=parseInt(Math.log(maxLen)/Math.log(10));var pow10=Math.pow(10,digits);var firstChar=parseInt(maxLen/pow10);var barLen;if(firstChar>5){barLen=5;}else if(firstChar>2){barLen=2;}else{barLen=1;}
return barLen*pow10;},update:function(){var res=this.map.getResolution();if(!res){return;}
var curMapUnits=this.map.getUnits();var inches=OpenLayers.INCHES_PER_UNIT;var maxSizeData=this.maxWidth*res*inches[curMapUnits];var topUnits;var bottomUnits;if(maxSizeData>100000){topUnits=this.topOutUnits;bottomUnits=this.bottomOutUnits;}else{topUnits=this.topInUnits;bottomUnits=this.bottomInUnits;}
var topMax=maxSizeData/inches[topUnits];var bottomMax=maxSizeData/inches[bottomUnits];var topRounded=this.getBarLen(topMax);var bottomRounded=this.getBarLen(bottomMax);topMax=topRounded/inches[curMapUnits]*inches[topUnits];bottomMax=bottomRounded/inches[curMapUnits]*inches[bottomUnits];var topPx=topMax/res;var bottomPx=bottomMax/res;if(this.eBottom.style.visibility=="visible"){this.eBottom.style.width=Math.round(bottomPx)+"px";this.eBottom.innerHTML=bottomRounded+" "+bottomUnits;}
if(this.eTop.style.visibility=="visible"){this.eTop.style.width=Math.round(topPx)+"px";this.eTop.innerHTML=topRounded+" "+topUnits;}},CLASS_NAME:"OpenLayers.Control.ScaleLine"});OpenLayers.Control.Search=OpenLayers.Class(OpenLayers.Control,{inputField:null,layer:null,feature:null,div:null,contentDiv:null,searchResultsDiv:null,resultInfo:null,zoom:5,showMarker:true,lookup:'lstg',scriptName:'search.py',searchTitle:'Search',searchLabel:'Enter a postcode or street',imagesBaseURL:'images/',lastResult:false,clearSearch:true,scriptURL:'/map-bin/search.py',restrictSearch:true,maxExtent:null,directSearch:true,markerURL:'http://static.media.thepieguide.com/markers/red_circle.png',loadingImg:'loading_ani.gif',initialize:function(options){this.searchButton=this.imagesBaseURL+'button-searchsubmit.png';this.markerSize=new OpenLayers.Size(35,35);this.markerOffset=new OpenLayers.Pixel(-(this.markerSize.w/2),-(this.markerSize.h/2));OpenLayers.Control.prototype.initialize.apply(this,arguments);this.loadingImgURL=OpenLayers.Util.getImagesLocation()+this.loadingImg;this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},draw:function(){if(!this.div){this.div=document.createElement('div');document.body.appendChild(this.div);this.div.id='searchControlDiv';this.div.className='searchControl';}else{this.div.className='searchControl';}
var title=document.createElement('div');title.innerHTML=OpenLayers.i18n(this.searchTitle);title.className='title';this.div.appendChild(title);var formDiv=document.createElement('div');var label=document.createElement('label');label.innerHTML=OpenLayers.i18n(this.searchLabel);formDiv.appendChild(label);this.inputField=document.createElement('input');this.inputField.type='text';this.inputField.id=this.inputField.name='q';formDiv.appendChild(this.inputField);var submit=document.createElement('input');submit.id='search_submit';submit.type='image';submit.src=this.searchButton;formDiv.appendChild(submit);this.div.appendChild(formDiv);var clearDiv=document.createElement('div');clearDiv.style.clear='both';this.div.appendChild(clearDiv);OpenLayers.Event.observe(this.inputField,'keyup',this.sniffEnter.bind(this));OpenLayers.Event.observe(submit,'click',this.search.bind(this));this.searchResultsDiv=document.createElement('div');this.div.appendChild(this.searchResultsDiv);this.progressDiv=document.createElement('div');this.progressDiv.className='imgProgress';var pImg=document.createElement('img');pImg.src=this.loadingImgURL;var pMsg=document.createTextNode(OpenLayers.i18n('Please wait while we retrive information.'));this.progressDiv.appendChild(pImg);this.progressDiv.appendChild(pMsg);this.progressDiv.style.display='none';this.div.appendChild(this.progressDiv);this.clearButton=document.createElement('a');this.div.appendChild(this.clearButton);this.clearButton.innerHTML=OpenLayers.i18n('Clear Search Marker');this.clearButton.className='clearSearch';OpenLayers.Event.observe(this.clearButton,'click',this.clearSearch.bind(this));this.clearButton.style.display='none';if(this.map){this.addMarkerLayer();}
var args=OpenLayers.Util.getArgs();if(args.q&&this.directSearch){this.inputField.value=args.q;if(this.map.baseLayer){this.search();}else{this.map.events.register('changebaselayer',this,this.runSearch);}}},runSearch:function(){this.map.events.unregister('changebaselayer',this,this.runSearch);this.search();},sniffEnter:function(evt){if(evt)
if(evt.keyCode==13)
this.search()},search:function(){var query=this.inputField.value;if(query.length==''){this.searchResultsDiv.innerHTML=OpenLayers.i18n('Please enter a valid postcode/street name to search');return false;}
var validPostcode=this.checkPostcode(this.inputField.value);if(validPostcode){this.inputField.value=query=validPostcode;this.lastSearch={lookup:'postcode',q:validPostcode}}
else{if((this.inputField.value).length<3){this.searchResultsDiv.innerHTML=OpenLayers.i18n('Please enter a valid postcode/street name to search');return false;}
else{this.lastSearch={lookup:'lstg',q:this.inputField.value}}}
var lookup=this.lastSearch.lookup;var params='q='+query+'&lookup='+lookup;if(this.restrictSearch){if(!this.maxExtent){this.maxExtent=this.map.maxExtent;}
var ext=this.maxExtent;var extent='&bbox='+ext.left+','+ext.bottom+','+ext.right+','+ext.top;params+=extent;}
var url=this.scriptURL+"?"+params;this.searchResultsDiv.innerHTML="";OpenLayers.loadURL(url,null,this,this.handleSearchResponse,this.searchFailed);this.searching(true);},addMarkerLayer:function(){if(typeof this.markerLayer=='undefined'){this.markerLayer=new OpenLayers.Layer.Markers('search_marker');this.map.addLayer(this.markerLayer);}},addMarker:function(result){if(!this.markerLayer)
this.addMarkerLayer();if(!this.marker){var geom=new OpenLayers.Geometry.fromWKT(result.geometry);geom.transform(new OpenLayers.Projection('EPSG:27700'),this.map.getProjectionObject());var icon=new OpenLayers.Icon(this.markerURL,this.markerSize,this.markerOffset);var loc=new OpenLayers.LonLat(geom.x,geom.y);this.marker=new OpenLayers.Marker(loc,icon);this.markerLayer.addMarker(this.marker);}
else{var geom=new OpenLayers.Geometry.fromWKT(result.geometry);geom.transform(new OpenLayers.Projection('EPSG:27700'),this.map.getProjectionObject());var loc=new OpenLayers.LonLat(geom.x,geom.y);this.marker.moveTo(this.map.getLayerPxFromLonLat(loc));}},removeMarker:function(){if(this.markerLayer&&this.marker){this.markerLayer.removeMarker(this.marker);this.markerLayer.clearMarkers();this.marker=null;}},searching:function(on){this.progressDiv.style.display=(on)?'block':'none';},toggleClearButton:function(on){this.clearButton.style.display=(on)?'block':'none';},searchFailed:function(){this.searching(false);this.searchResultsDiv.innerHTML=OpenLayers.i18n('Nothing found.');},handleSearchResponse:function(request){try{var response=eval('('+request.responseText+')');}catch(e){var response=false;}
if(!response)
this.searchResultsDiv.innerHTML=OpenLayers.i18n("We were unable to process this request. Please try again");if(response.results!=false){searchResults=response.results;var rec=(searchResults.length>1)?'records':'record'
if(searchResults.length==1){this.searchResultsDiv.innerHTML='';this.showResult(searchResults[0]);}
else{this.searchResultsDiv.innerHTML="<p>"+OpenLayers.i18n('Showing')+" "+searchResults.length+" "+OpenLayers.i18n('records')+"</p>";var ul=document.createElement('ul');ul.className='searchResultsUL';for(var len=searchResults.length,currIndex=0;currIndex<len;currIndex++){var li=document.createElement('li');var a=document.createElement('a');var result=searchResults[currIndex];var resultText='';if(this.lastSearch.lookup=='postcode')
resultText=result.postcode;else
if(this.lastSearch.lookup=='lstg'){resultText=result.name;resultText+=(typeof(result.district)!='undefined')?', '+result.district:'';}
li.innerHTML=resultText;li.style.cursor='pointer';ul.appendChild(li);OpenLayers.Event.observe(li,'click',this.showResult.bind(this,result));}
this.searchResultsDiv.appendChild(ul);}}else{this.searchResultsDiv.innerHTML=OpenLayers.i18n("Nothing found.");}
this.searching(false);},showResult:function(result){if(result){this.lastResult=result;var geom=new OpenLayers.Geometry.fromWKT(result.geometry);geom.transform(new OpenLayers.Projection('EPSG:27700'),this.map.getProjectionObject());if(this.showMarker){this.addMarker(result);if(this.clearSearch){this.searchResultsDiv.innerHTML="";this.toggleClearButton(true);}}
this.map.setCenter(new OpenLayers.LonLat(geom.x,geom.y),this.zoom);}},showMapCenter:function(result){if(result){this.lastResult=result;var geom=new OpenLayers.Geometry.fromWKT(result.geometry);geom.transform(new OpenLayers.Projection('EPSG:27700'),this.map.getProjectionObject());if(this.showMarker){this.addMarker(result);if(this.clearSearch){this.toggleClearButton(true);}}}},clearSearch:function(){this.lastResult=false;this.inputField.value='';if(this.showMarker){this.removeMarker();}
this.toggleClearButton(false);},centerMap:function(point){var centrePoint=new OpenLayers.LonLat(point[0],point[1]);centrePoint.transform(new OpenLayers.Projection('EPSG:4326'),this.map.getProjectionObject());this.map.setCenter(centrePoint,this.zoom);},isPostcode:function(str){var is_postcode=false;var postcode='';for(var i=0;i<str.length;i++)
if(str.charAt(i)!=' ')
postcode=postcode+str.charAt(i);if(postcode.length>8)
return false;if(this.isNumber(postcode.charAt(0))==true)
return false;if(this.isNumber(postcode.charAt(postcode.length-1))==true&&postcode.length<5)
return true;if(this.isNumber(postcode.charAt(postcode.length-2))==true&&postcode.length<5)
return true;var postcode_end=postcode.substr(postcode.length-3,3);var postcode_start=postcode.substr(0,postcode.length-3);if(this.isNumber(postcode_end.charAt(0))==false)
return false;if(this.isNumber(postcode_end.charAt(1))==true)
return false;if(this.isNumber(postcode_end.charAt(2))==true)
return false;var check=false;for(i=0;i<postcode_start.length;i++)
if(this.isNumber(postcode_start.charAt(i))==true)
check=true;if(check==false)
return false;return true;},isNumber:function(c){if(c=='0')return true;if(c=='1')return true;if(c=='2')return true;if(c=='3')return true;if(c=='4')return true;if(c=='5')return true;if(c=='6')return true;if(c=='7')return true;if(c=='8')return true;if(c=='9')return true;return false;},checkPostcode:function(toCheck){var alpha1="[abcdefghijklmnoprstuwyz]";var alpha2="[abcdefghklmnopqrstuvwxy]";var alpha3="[abcdefghjkstuw]";var alpha4="[abehmnprvwxy]";var alpha5="[abdefghjlnpqrstuwxyz]";var pcexp=new Array();pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}[0-9]{1}"+alpha3+"{1})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]{1}"+alpha5+"{2})$","i"));pcexp.push(/^(GIR)(\s*)(0AA)$/i);pcexp.push(/^(bfpo)(\s*)([0-9]{1,4})$/i);pcexp.push(/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);pcexp.push(/^([A-Z]{4})(\s*)(1ZZ)$/i);var postCode=toCheck;pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}[0-9]{1,2})(\\s*)([0-9]{1})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1,2})(\\s*)([0-9]{1}"+alpha5+"{0,2})$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]?)$","i"));pcexp.push(new RegExp("^("+alpha1+"{1}"+alpha2+"?[0-9]{1}"+alpha4+"{1})(\\s*)([0-9]{1}"+alpha5+"{1,2})$","i"));var valid=false;for(var i=0;i<pcexp.length;i++){if(pcexp[i].test(postCode)){pcexp[i].exec(postCode);postCode=RegExp.$1.toUpperCase()+" "+RegExp.$3.toUpperCase();postCode=postCode.replace(/C\/O\s*/,"c/o ");valid=true;break;}}
if(valid){return postCode;}else return false;},CLASS_NAME:"OpenLayers.Control.Search"});OpenLayers.Control.SelectTemplateFeature=OpenLayers.Class(OpenLayers.Control,{selectFeatureControl:null,selectedFeature:null,popup:null,feedbackControlClass:'OpenLayers.Control.Feedback',allowFeedback:true,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);},destroy:function(){OpenLayers.Control.prototype.destroy.apply(this,arguments);},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.setFeedback();this.map.events.addEventType('feedbackcontroladded');this.map.events.register('feedbackcontroladded',this,this.setFeedback);},setFeedback:function(evt){var controls=this.map.getControlsBy('CLASS_NAME',this.feedbackControlClass);if(controls.length>0){this.feedbackControl=controls[0];this.allowFeedback=true;}else{this.allowFeedback=false;}},activate:function(){if(this.layers!=null){this.selectFeatureControl=new OpenLayers.Control.SelectFeature(this.layers);this.map.addControl(this.selectFeatureControl);this.setSelectFeatureControl(this.selectFeatureControl);this.selectFeatureControl.activate();}},setSelectFeatureControl:function(control){control.onSelect=this.onFeatureSelect;control.onUnselect=this.onFeatureUnselect;control.scope=this;this.selectFeatureControl=control;},onFeatureUnselect:function(feature){if(feature.popup!=null)
this.map.removePopup(feature.popup);if(this.popup!=null){this.popup=null;feature.popup.destroy();feature.popup=null;}},closePopup:function(){if(typeof this.featurePopup!='undefined'){if(this.featurePopup.selectFeatureControl!=null){this.featurePopup.selectFeatureControl.unselectAll();}
if(typeof this.featurePopup.selectedFeature!='undefined'){this.featurePopup.onFeatureUnselect(this.featurePopup.selectedFeature);}}},onFeatureSelect:function(feature,evt){if(this.popup){this.map.removePopup(this.popup);this.popup=null;}
this.selectedFeature=feature;if(feature.getHTML()!=''||this.allowFeedback){if(feature.geometry.CLASS_NAME!="OpenLayers.Geometry.Point"){if(this.map&&this.selectFeatureControl&&this.selectFeatureControl.handlers&&this.selectFeatureControl.handlers.feature&&this.selectFeatureControl.handlers.feature.evt&&this.selectFeatureControl.handlers.feature.evt.xy){feature.lonlat=this.map.getLonLatFromViewPortPx(this.selectFeatureControl.handlers.feature.evt.xy);}}
this.popup=feature.createPopup(true,this.closePopup);this.popup.featurePopup=this;feature.popup=this.popup;this.map.addPopup(this.popup);}
if(this.allowFeedback&&true){if(this.popup.contentDiv!=null){var d=document.createElement('div');d.style.position='relative';d.style.textAlign='right';d.className='feedbackLinkContainer';var a=document.createElement('a');a.href="javascript: void(0);";a.innerHTML='Feature Feedback';d.appendChild(a);a.className='featureFeedbackLink'
this.popup.contentDiv.appendChild(d);}
this.popup.updateSize();OpenLayers.Event.observe(a,'click',this.closePopup.bind(this.popup));OpenLayers.Event.observe(a,'click',this.feedback.bind(this,feature));}},feedback:function(feature,evt){if(this.feedbackControl)
this.feedbackControl.show(feature);},CLASS_NAME:"OpenLayers.Control.SelectTemplateFeature"});OpenLayers.Control.SiteLocator=OpenLayers.Class(OpenLayers.Control,{partner_id:null,locationinfo:null,markerLayer:null,linkWalkingRoutes:false,activeLocation:null,showLocationInfo:false,locationInfoDiv:null,autoLocation:true,zoom:0,scriptName:'sitelocator.py',scriptURL:'/map-bin/sitelocator.py',initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},update:function(){var nothing='do nothing';},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);this.div.style.display='none';if(this.body==null){this.div.className='box';var title=document.createElement('div');title.className='boxTitle';title.innerHTML='Site Locator';this.div.appendChild(title);this.body=document.createElement('div');this.body.className='boxBody';this.div.appendChild(this.body);}
if(this.showLocationInfo&&this.locationInfoDiv==null){this.locationInfoDiv=document.createElement('div');this.locationInfoDiv.id='sitelocationinfo';this.div.appendChild(this.locationInfoDiv);}
var url=this.scriptURL+'?partner_id='+this.partner_id;OpenLayers.loadURL(url,null,this,this.cbGetSites);},updateLocation:function(){this.map.events.unregister('changebaselayer',this,this.runSearch);this.search();},cbGetSites:function(request){var response=eval('('+request.responseText+')');this.sites=response.results;this.select=document.createElement('select');this.select.options[this.select.options.length]=new Option('Select location',-1);OpenLayers.Event.observe(this.select,"change",this.selectChange.bindAsEventListener(this));for(var i=0,l=this.sites.length;i<l;i++){this.select.options[this.select.options.length]=new Option(this.sites[i][0],i);}
this.body.appendChild(this.select);this.div.style.display='block';if(this.autoLocation){if(this.sites.length==1){this.select.selectedIndex=1;this.div.style.display='none';this.selectChange();}else{var args=OpenLayers.Util.getArgs();var loc_id=parseInt(args.loc_id);if(typeof(loc_id)=='number'){if(loc_id>0&&loc_id<this.select.options.length){this.select.selectedIndex=loc_id;this.selectChange();}}}}},selectChange:function(evt){var index=this.select.options[this.select.selectedIndex].value;if(index==-1){this.hideWalkingRoutes();if(this.showLocationInfo)this.hideLocationInfo();return;}
var site=this.sites[index];this.listClick2.apply(this,site);},listClick2:function(name,x,y,description,address_1,address_2,address_3,address_4,city,postcode,phone,web,email,logo,routes,missing,location){if(this.zoom>0)
this.map.setCenter(new OpenLayers.LonLat(x,y),this.zoom);else
this.map.setCenter(new OpenLayers.LonLat(x,y));if(this.showLocationInfo){var str="<b>"+name+"</b>";str+=(address_1)?"<br/>"+address_1:'';str+=(address_2)?"<br/>"+address_2:'';str+=(address_3)?"<br/>"+address_3:'';str+=(address_4)?"<br/>"+address_4:'';str+=(city)?"<br/>"+city:'';str+=(postcode)?"<br/>"+postcode:'';str+=(phone)?"<br/>"+phone:'';str+=(web)?"<br/><a target=_blank href='"+web+"'>Visit website</a>":'';str+=(email)?"<br/><a href='mailto:"+email+"'>"+email+"</a>":'';str+=(logo)?"<br/><img src='http://custom.media.thepieguide.com/"+logo+"'/>":'';this.locationInfoDiv.innerHTML=str;this.locationInfoDiv.style.display='';}
if(this.linkWalkingRoutes)
this.updateWalkingRoutes(location);},hideLocationInfo:function(){if(this.locationInfoDiv){this.locationInfoDiv.style.display='none';}},hideWalkingRoutes:function(){if(this.linkWalkingRoutes){var control=null;for(i in map.controls){if(map.controls[i].CLASS_NAME=="OpenLayers.Control.WalkingRoutes"){control=map.controls[i];break;}}
if(control){if(control.animStop!=null)
control.animStop();control.routes=[];control.update();}}},updateWalkingRoutes:function(location_id){var control=null;for(i in map.controls){if(map.controls[i].CLASS_NAME=="OpenLayers.Control.WalkingRoutes"){control=map.controls[i];break;}}
if(control){if(control.animStop!=null)
control.animStop();control.location_id=location_id;control.routes=null;control.update();}},CLASS_NAME:"OpenLayers.Control.SiteLocator"});OpenLayers.Control.WalkingRoutes=OpenLayers.Class(OpenLayers.Control,{body:null,activeLayer:null,activeLayerObj:null,location_id:null,markerLayer:null,routes:null,scriptName:'walkingroutes.py',scriptURL:'/map-bin/walkingroutes.py',enableAnimation:false,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.scriptURL=OpenLayers.Util.getScriptsLocation()+this.scriptName;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register("addlayer",this,this.update);this.map.events.register("changelayer",this,this.update);},draw:function(px){OpenLayers.Control.prototype.draw.apply(this,arguments);if(this.body==null){this.div.className='box';var title=document.createElement('div');title.innerHTML='Walking Routes';title.className='boxTitle';this.div.appendChild(title);this.body=document.createElement('div');this.body.className='boxBody';this.div.appendChild(this.body);}
this.update();},update:function(){if(this.activeLayerObj==null){for(var i=0,l=this.map.layers.length;i<l;i++){var layer=this.map.layers[i];if(layer.name==this.activeLayer){this.activeLayerObj=layer;break;}}}
if(this.activeLayerObj==null||!this.activeLayerObj.visibility||!this.activeLayerObj.inRange){this.div.style.display='none';if(this.animStop!=null)this.animStop();return;}
if(this.routes!=null){this.div.style.display=(this.routes.length>0)?'block':'none';}else{if(this.location_id!=undefined)
var url=this.scriptURL+'?location_id='+this.location_id;OpenLayers.loadURL(url,null,this,this.cbGotRoutes);}},cbGotRoutes:function(request){var response=eval('('+request.responseText+')');this.routes=response.results;this.body.innerHTML='';for(var i=0,l=this.routes.length;i<l;i++){var route=this.routes[i];var b=document.createElement('b');b.appendChild(document.createTextNode(route[1]));this.body.appendChild(b);var desc=document.createElement('div');desc.style.display='none';desc.appendChild(document.createTextNode(route[3]));this.body.appendChild(desc);var div=document.createElement('div');div.style.textAlign='right';var a=document.createElement('a');a.href='javascript:return false;';a.innerHTML='details';var showRoute=this.showRoute.bind(this,desc,a);OpenLayers.Event.observe(a,"click",showRoute.bindAsEventListener(this));div.appendChild(a);div.appendChild(document.createTextNode(' - '));var a=document.createElement('a');a.href='javascript:return false;';a.innerHTML='animate';var animate=this.animateRoute.bind(this,a,route[2],route[4]);OpenLayers.Event.observe(a,"click",animate.bindAsEventListener(this));div.appendChild(a);this.body.appendChild(div);}
this.div.style.display=(this.routes.length>0)?'block':'none';},showRoute:function(desc,a,evt){OpenLayers.Event.stop(evt);OpenLayers.Element.toggle(desc);a.innerHTML=(a.innerHTML=='details')?'hide details':'details';},animateRoute:function(a,points,bbox,evt){OpenLayers.Event.stop(evt);if(a.animating){if(this.animStop!=null)this.animStop();}else{if(this.animStop!=null)this.animStop();a.innerHTML='';a.appendChild(document.createTextNode('stop animating'));a.animating=true;var bbox=OpenLayers.Bounds.fromArray(bbox);this.map.zoomToExtent(bbox);var icon=this._getIcon();var startpoint=new OpenLayers.LonLat(points[0][0],points[0][1]);var marker=new OpenLayers.Marker(startpoint,icon);if(this.markerLayer==null){this.markerLayer=new OpenLayers.Layer.Markers("Walking Routes",this.map.baseLayer.options);this.markerLayer.displayInLayerSwitcher=false;this.map.addLayer(this.markerLayer);}
this.markerLayer.addMarker(marker);this.index=0;var animate=this.animFrame.bind(this,marker,points);var timer=window.setInterval(animate,500);this.animStop=this._animStop.bind(this,marker,timer,a);}},animFrame:function(marker,points){var point=points[this.index++];if(typeof point=='undefined'){this.index=0;point=points[0];}
var point=new OpenLayers.LonLat(point[0],point[1]);var px=this.map.getLayerPxFromLonLat(point);if(this.enableAnimation)
marker.animateTo(px);else
marker.moveTo(px);},_animStop:function(marker,timer,a){window.clearInterval(timer);this.markerLayer.removeMarker(marker);a.innerHTML='';a.appendChild(document.createTextNode('animate'));a.animating=false;this.animStop=null;},_getIcon:function(){if(typeof this._icon=='undefined'){var url="http://static.media.thepieguide.com/markers/circle_green.png"
var size=new OpenLayers.Size(32,32);var calculateOffset=function(size){return new OpenLayers.Pixel(-(size.w/2),-size.h);}
this._icon=new OpenLayers.Icon(url,size,null,calculateOffset);}
return this._icon;},CLASS_NAME:"OpenLayers.Control.WalkingRoutes"});OpenLayers.Control.ZoomIn=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){this.map.zoomIn();},CLASS_NAME:"OpenLayers.Control.ZoomIn"});OpenLayers.Control.ZoomOut=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){this.map.zoomOut();},CLASS_NAME:"OpenLayers.Control.ZoomOut"});OpenLayers.Control.ZoomToMaxExtent=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_BUTTON,trigger:function(){if(this.map){this.map.zoomToMaxExtent();}},CLASS_NAME:"OpenLayers.Control.ZoomToMaxExtent"});OpenLayers.Event={observers:false,KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,element:function(event){return event.target||event.srcElement;},isLeftClick:function(event){return(((event.which)&&(event.which==1))||((event.button)&&(event.button==1)));},isRightClick:function(event){return(((event.which)&&(event.which==3))||((event.button)&&(event.button==2)));},stop:function(event,allowDefault){if(!allowDefault){if(event.preventDefault){event.preventDefault();}else{event.returnValue=false;}}
if(event.stopPropagation){event.stopPropagation();}else{event.cancelBubble=true;}},findElement:function(event,tagName){var element=OpenLayers.Event.element(event);while(element.parentNode&&(!element.tagName||(element.tagName.toUpperCase()!=tagName.toUpperCase()))){element=element.parentNode;}
return element;},observe:function(elementParam,name,observer,useCapture){var element=OpenLayers.Util.getElement(elementParam);useCapture=useCapture||false;if(name=='keypress'&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||element.attachEvent)){name='keydown';}
if(!this.observers){this.observers={};}
if(!element._eventCacheID){var idPrefix="eventCacheID_";if(element.id){idPrefix=element.id+"_"+idPrefix;}
element._eventCacheID=OpenLayers.Util.createUniqueID(idPrefix);}
var cacheID=element._eventCacheID;if(!this.observers[cacheID]){this.observers[cacheID]=[];}
this.observers[cacheID].push({'element':element,'name':name,'observer':observer,'useCapture':useCapture});if(element.addEventListener){element.addEventListener(name,observer,useCapture);}else if(element.attachEvent){element.attachEvent('on'+name,observer);}},stopObservingElement:function(elementParam){var element=OpenLayers.Util.getElement(elementParam);var cacheID=element._eventCacheID;this._removeElementObservers(OpenLayers.Event.observers[cacheID]);},_removeElementObservers:function(elementObservers){if(elementObservers){for(var i=elementObservers.length-1;i>=0;i--){var entry=elementObservers[i];var args=new Array(entry.element,entry.name,entry.observer,entry.useCapture);var removed=OpenLayers.Event.stopObserving.apply(this,args);}}},stopObserving:function(elementParam,name,observer,useCapture){useCapture=useCapture||false;var element=OpenLayers.Util.getElement(elementParam);var cacheID=element._eventCacheID;if(name=='keypress'){if(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||element.detachEvent){name='keydown';}}
var foundEntry=false;var elementObservers=OpenLayers.Event.observers[cacheID];if(elementObservers){var i=0;while(!foundEntry&&i<elementObservers.length){var cacheEntry=elementObservers[i];if((cacheEntry.name==name)&&(cacheEntry.observer==observer)&&(cacheEntry.useCapture==useCapture)){elementObservers.splice(i,1);if(elementObservers.length==0){delete OpenLayers.Event.observers[cacheID];}
foundEntry=true;break;}
i++;}}
if(foundEntry){if(element.removeEventListener){element.removeEventListener(name,observer,useCapture);}else if(element&&element.detachEvent){element.detachEvent('on'+name,observer);}}
return foundEntry;},unloadCache:function(){if(OpenLayers.Event&&OpenLayers.Event.observers){for(var cacheID in OpenLayers.Event.observers){var elementObservers=OpenLayers.Event.observers[cacheID];OpenLayers.Event._removeElementObservers.apply(this,[elementObservers]);}
OpenLayers.Event.observers=false;}},CLASS_NAME:"OpenLayers.Event"};OpenLayers.Event.observe(window,'unload',OpenLayers.Event.unloadCache,false);if(window.Event){OpenLayers.Util.applyDefaults(window.Event,OpenLayers.Event);}else{var Event=OpenLayers.Event;}
OpenLayers.Events=OpenLayers.Class({BROWSER_EVENTS:["mouseover","mouseout","mousedown","mouseup","mousemove","click","dblclick","rightclick","dblrightclick","resize","focus","blur"],listeners:null,object:null,element:null,eventTypes:null,eventHandler:null,fallThrough:null,includeXY:false,clearMouseListener:null,initialize:function(object,element,eventTypes,fallThrough,options){OpenLayers.Util.extend(this,options);this.object=object;this.fallThrough=fallThrough;this.listeners={};this.eventHandler=OpenLayers.Function.bindAsEventListener(this.handleBrowserEvent,this);this.clearMouseListener=OpenLayers.Function.bind(this.clearMouseCache,this);this.eventTypes=[];if(eventTypes!=null){for(var i=0,len=eventTypes.length;i<len;i++){this.addEventType(eventTypes[i]);}}
if(element!=null){this.attachToElement(element);}},destroy:function(){if(this.element){OpenLayers.Event.stopObservingElement(this.element);if(this.element.hasScrollEvent){OpenLayers.Event.stopObserving(window,"scroll",this.clearMouseListener);}}
this.element=null;this.listeners=null;this.object=null;this.eventTypes=null;this.fallThrough=null;this.eventHandler=null;},addEventType:function(eventName){if(!this.listeners[eventName]){this.eventTypes.push(eventName);this.listeners[eventName]=[];}},attachToElement:function(element){if(this.element){OpenLayers.Event.stopObservingElement(this.element);}
this.element=element;for(var i=0,len=this.BROWSER_EVENTS.length;i<len;i++){var eventType=this.BROWSER_EVENTS[i];this.addEventType(eventType);OpenLayers.Event.observe(element,eventType,this.eventHandler);}
OpenLayers.Event.observe(element,"dragstart",OpenLayers.Event.stop);},on:function(object){for(var type in object){if(type!="scope"){this.register(type,object.scope,object[type]);}}},register:function(type,obj,func){if((func!=null)&&(OpenLayers.Util.indexOf(this.eventTypes,type)!=-1)){if(obj==null){obj=this.object;}
var listeners=this.listeners[type];listeners.push({obj:obj,func:func});}},registerPriority:function(type,obj,func){if(func!=null){if(obj==null){obj=this.object;}
var listeners=this.listeners[type];if(listeners!=null){listeners.unshift({obj:obj,func:func});}}},un:function(object){for(var type in object){if(type!="scope"){this.unregister(type,object.scope,object[type]);}}},unregister:function(type,obj,func){if(obj==null){obj=this.object;}
var listeners=this.listeners[type];if(listeners!=null){for(var i=0,len=listeners.length;i<len;i++){if(listeners[i].obj==obj&&listeners[i].func==func){listeners.splice(i,1);break;}}}},remove:function(type){if(this.listeners[type]!=null){this.listeners[type]=[];}},triggerEvent:function(type,evt){var listeners=this.listeners[type];if(!listeners||listeners.length==0){return;}
if(evt==null){evt={};}
evt.object=this.object;evt.element=this.element;if(!evt.type){evt.type=type;}
var listeners=listeners.slice(),continueChain;for(var i=0,len=listeners.length;i<len;i++){var callback=listeners[i];continueChain=callback.func.apply(callback.obj,[evt]);if((continueChain!=undefined)&&(continueChain==false)){break;}}
if(!this.fallThrough){OpenLayers.Event.stop(evt,true);}
return continueChain;},handleBrowserEvent:function(evt){if(this.includeXY){evt.xy=this.getMousePosition(evt);}
this.triggerEvent(evt.type,evt);},clearMouseCache:function(){this.element.scrolls=null;this.element.lefttop=null;this.element.offsets=null;},getMousePosition:function(evt){if(!this.includeXY){this.clearMouseCache();}else if(!this.element.hasScrollEvent){OpenLayers.Event.observe(window,"scroll",this.clearMouseListener);this.element.hasScrollEvent=true;}
if(!this.element.scrolls){this.element.scrolls=[(document.documentElement.scrollLeft||document.body.scrollLeft),(document.documentElement.scrollTop||document.body.scrollTop)];}
if(!this.element.lefttop){this.element.lefttop=[(document.documentElement.clientLeft||0),(document.documentElement.clientTop||0)];}
if(!this.element.offsets){this.element.offsets=OpenLayers.Util.pagePosition(this.element);this.element.offsets[0]+=this.element.scrolls[0];this.element.offsets[1]+=this.element.scrolls[1];}
return new OpenLayers.Pixel((evt.clientX+this.element.scrolls[0])-this.element.offsets[0]
-this.element.lefttop[0],(evt.clientY+this.element.scrolls[1])-this.element.offsets[1]
-this.element.lefttop[1]);},CLASS_NAME:"OpenLayers.Events"});OpenLayers.Format=OpenLayers.Class({options:null,externalProjection:null,internalProjection:null,data:null,keepData:false,initialize:function(options){OpenLayers.Util.extend(this,options);this.options=options;},destroy:function(){},read:function(data){OpenLayers.Console.userError(OpenLayers.i18n("readNotImplemented"));},write:function(object){OpenLayers.Console.userError(OpenLayers.i18n("writeNotImplemented"));},CLASS_NAME:"OpenLayers.Format"});OpenLayers.Lang.cy={'Search':"Chwilio",'Enter postcode, street or place':"Rhowch god post, stryd neu le",'Please enter a valid postcode/street name to search':"Please enter a valid postcode/street name to search",'For detailed parking rules by council, please select the council from the list below:':"I gael rheolau parcio manwl gan gyngor, dewiswch y cyngor o blith y rhestr isod:",'Disabled parking':'Parcio i bobl anabl','Pay and display parking':'Parcio Talu ac Arddangos','Shared use parking':'Mannau parcio a rennir','Resident parking':'Parcio i breswylwyr','Yellow line parking':'Parcio ar linellau melyn','Council car park':'Maes parcio cyngor','Council notes':'Nodiadau cyngor','unhandledRequest':"Unhandled request return ${statusText}"};OpenLayers.Lang.en={'unhandledRequest':"Unhandled request return ${statusText}",'permalink':"Permalink",'overlays':"Overlays",'baseLayer':"Base Layer",'sameProjection':"The overview map only works when it is in the same projection as the main map",'readNotImplemented':"Read not implemented.",'writeNotImplemented':"Write not implemented.",'noFID':"Can't update a feature for which there is no FID.",'errorLoadingGML':"Error in loading GML file ${url}",'browserNotSupported':"Your browser does not support vector rendering. Currently supported renderers are:\n${renderers}",'componentShouldBe':"addFeatures : component should be an ${geomType}",'getFeatureError':"getFeatureFromEvent called on layer with no renderer. This usually means you "+"destroyed a layer, but not some handler which is associated with it.",'minZoomLevelError':"The minZoomLevel property is only intended for use "+"with the FixedZoomLevels-descendent layers. That this "+"wfs layer checks for minZoomLevel is a relic of the"+"past. We cannot, however, remove it without possibly "+"breaking OL based applications that may depend on it."+" Therefore we are deprecating it -- the minZoomLevel "+"check below will be removed at 3.0. Please instead "+"use min/max resolution setting as described here: "+"http://trac.openlayers.org/wiki/SettingZoomLevels",'commitSuccess':"WFS Transaction: SUCCESS ${response}",'commitFailed':"WFS Transaction: FAILED ${response}",'googleWarning':"The Google Layer was unable to load correctly.<br><br>"+"To get rid of this message, select a new BaseLayer "+"in the layer switcher in the upper-right corner.<br><br>"+"Most likely, this is because the Google Maps library "+"script was either not included, or does not contain the "+"correct API key for your site.<br><br>"+"Developers: For help getting this working correctly, "+"<a href='http://trac.openlayers.org/wiki/Google' "+"target='_blank'>click here</a>",'getLayerWarning':"The ${layerType} Layer was unable to load correctly.<br><br>"+"To get rid of this message, select a new BaseLayer "+"in the layer switcher in the upper-right corner.<br><br>"+"Most likely, this is because the ${layerLib} library "+"script was not correctly included.<br><br>"+"Developers: For help getting this working correctly, "+"<a href='http://trac.openlayers.org/wiki/${layerLib}' "+"target='_blank'>click here</a>",'scale':"Scale = 1 : ${scaleDenom}",'layerAlreadyAdded':"You tried to add the layer: ${layerName} to the map, but it has already been added",'reprojectDeprecated':"You are using the 'reproject' option "+"on the ${layerName} layer. This option is deprecated: "+"its use was designed to support displaying data over commercial "+"basemaps, but that functionality should now be achieved by using "+"Spherical Mercator support. More information is available from "+"http://trac.openlayers.org/wiki/SphericalMercator.",'methodDeprecated':"This method has been deprecated and will be removed in 3.0. "+"Please use ${newMethod} instead.",'boundsAddError':"You must pass both x and y values to the add function.",'lonlatAddError':"You must pass both lon and lat values to the add function.",'pixelAddError':"You must pass both x and y values to the add function.",'unsupportedGeometryType':"Unsupported geometry type: ${geomType}",'pagePositionFailed':"OpenLayers.Util.pagePosition failed: element with id ${elemId} may be misplaced.",'end':'','filterEvaluateNotImplemented':"evaluate is not implemented for this filter type."};OpenLayers.Popup.AnchoredBubble=OpenLayers.Class(OpenLayers.Popup.Anchored,{rounded:false,initialize:function(id,lonlat,contentSize,contentHTML,anchor,closeBox,closeBoxCallback){this.padding=new OpenLayers.Bounds(0,OpenLayers.Popup.AnchoredBubble.CORNER_SIZE,0,OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);OpenLayers.Popup.Anchored.prototype.initialize.apply(this,arguments);},draw:function(px){OpenLayers.Popup.Anchored.prototype.draw.apply(this,arguments);this.setContentHTML();this.setBackgroundColor();this.setOpacity();return this.div;},updateRelativePosition:function(){this.setRicoCorners();},setSize:function(contentSize){OpenLayers.Popup.Anchored.prototype.setSize.apply(this,arguments);this.setRicoCorners();},setBackgroundColor:function(color){if(color!=undefined){this.backgroundColor=color;}
if(this.div!=null){if(this.contentDiv!=null){this.div.style.background="transparent";OpenLayers.Rico.Corner.changeColor(this.groupDiv,this.backgroundColor);}}},setOpacity:function(opacity){OpenLayers.Popup.Anchored.prototype.setOpacity.call(this,opacity);if(this.div!=null){if(this.groupDiv!=null){OpenLayers.Rico.Corner.changeOpacity(this.groupDiv,this.opacity);}}},setBorder:function(border){this.border=0;},setRicoCorners:function(){var corners=this.getCornersToRound(this.relativePosition);var options={corners:corners,color:this.backgroundColor,bgColor:"transparent",blend:false};if(!this.rounded){OpenLayers.Rico.Corner.round(this.div,options);this.rounded=true;}else{OpenLayers.Rico.Corner.reRound(this.groupDiv,options);this.setBackgroundColor();this.setOpacity();}},getCornersToRound:function(){var corners=['tl','tr','bl','br'];var corner=OpenLayers.Bounds.oppositeQuadrant(this.relativePosition);OpenLayers.Util.removeItem(corners,corner);return corners.join(" ");},CLASS_NAME:"OpenLayers.Popup.AnchoredBubble"});OpenLayers.Popup.AnchoredBubble.CORNER_SIZE=5;OpenLayers.Popup.Framed=OpenLayers.Class(OpenLayers.Popup.Anchored,{imageSrc:null,imageSize:null,isAlphaImage:false,positionBlocks:null,blocks:null,fixedRelativePosition:false,initialize:function(id,lonlat,contentSize,contentHTML,anchor,closeBox,closeBoxCallback){OpenLayers.Popup.Anchored.prototype.initialize.apply(this,arguments);if(this.fixedRelativePosition){this.updateRelativePosition();this.calculateRelativePosition=function(px){return this.relativePosition;};}
this.contentDiv.style.position="absolute";this.contentDiv.style.zIndex=1;if(closeBox){this.closeDiv.style.zIndex=1;}
this.groupDiv.style.position="absolute";this.groupDiv.style.top="0px";this.groupDiv.style.left="0px";this.groupDiv.style.height="100%";this.groupDiv.style.width="100%";},destroy:function(){this.imageSrc=null;this.imageSize=null;this.isAlphaImage=null;this.fixedRelativePosition=false;this.positionBlocks=null;for(var i=0;i<this.blocks.length;i++){var block=this.blocks[i];if(block.image){block.div.removeChild(block.image);}
block.image=null;if(block.div){this.groupDiv.removeChild(block.div);}
block.div=null;}
this.blocks=null;OpenLayers.Popup.Anchored.prototype.destroy.apply(this,arguments);},setBackgroundColor:function(color){},setBorder:function(){},setOpacity:function(opacity){},setSize:function(contentSize){OpenLayers.Popup.Anchored.prototype.setSize.apply(this,arguments);this.updateBlocks();},updateRelativePosition:function(){this.padding=this.positionBlocks[this.relativePosition].padding;if(this.closeDiv){var contentDivPadding=this.getContentDivPadding();this.closeDiv.style.right=contentDivPadding.right+
this.padding.right+"px";this.closeDiv.style.top=contentDivPadding.top+
this.padding.top+"px";}
this.updateBlocks();},calculateNewPx:function(px){var newPx=OpenLayers.Popup.Anchored.prototype.calculateNewPx.apply(this,arguments);newPx=newPx.offset(this.positionBlocks[this.relativePosition].offset);return newPx;},createBlocks:function(){this.blocks=[];var firstPosition=null;for(var key in this.positionBlocks){firstPosition=key;break;}
var position=this.positionBlocks[firstPosition];for(var i=0;i<position.blocks.length;i++){var block={};this.blocks.push(block);var divId=this.id+'_FrameDecorationDiv_'+i;block.div=OpenLayers.Util.createDiv(divId,null,null,null,"absolute",null,"hidden",null);var imgId=this.id+'_FrameDecorationImg_'+i;var imageCreator=(this.isAlphaImage)?OpenLayers.Util.createAlphaImageDiv:OpenLayers.Util.createImage;block.image=imageCreator(imgId,null,this.imageSize,this.imageSrc,"absolute",null,null,null);block.div.appendChild(block.image);this.groupDiv.appendChild(block.div);}},updateBlocks:function(){if(!this.blocks){this.createBlocks();}
if(this.size&&this.relativePosition){var position=this.positionBlocks[this.relativePosition];for(var i=0;i<position.blocks.length;i++){var positionBlock=position.blocks[i];var block=this.blocks[i];var l=positionBlock.anchor.left;var b=positionBlock.anchor.bottom;var r=positionBlock.anchor.right;var t=positionBlock.anchor.top;var w=(isNaN(positionBlock.size.w))?this.size.w-(r+l):positionBlock.size.w;var h=(isNaN(positionBlock.size.h))?this.size.h-(b+t):positionBlock.size.h;block.div.style.width=(w<0?0:w)+'px';block.div.style.height=(h<0?0:h)+'px';block.div.style.left=(l!=null)?l+'px':'';block.div.style.bottom=(b!=null)?b+'px':'';block.div.style.right=(r!=null)?r+'px':'';block.div.style.top=(t!=null)?t+'px':'';block.image.style.left=positionBlock.position.x+'px';block.image.style.top=positionBlock.position.y+'px';}
this.contentDiv.style.left=this.padding.left+"px";this.contentDiv.style.top=this.padding.top+"px";}},CLASS_NAME:"OpenLayers.Popup.Framed"});OpenLayers.Projection=OpenLayers.Class({proj:null,projCode:null,initialize:function(projCode,options){OpenLayers.Util.extend(this,options);this.projCode=projCode;if(window.Proj4js){this.proj=new Proj4js.Proj(projCode);}},getCode:function(){return this.proj?this.proj.srsCode:this.projCode;},getUnits:function(){return this.proj?this.proj.units:null;},toString:function(){return this.getCode();},equals:function(projection){if(projection&&projection.getCode){return this.getCode()==projection.getCode();}else{return false;}},destroy:function(){delete this.proj;delete this.projCode;},CLASS_NAME:"OpenLayers.Projection"});OpenLayers.Projection.transforms={};OpenLayers.Projection.addTransform=function(from,to,method){if(!OpenLayers.Projection.transforms[from]){OpenLayers.Projection.transforms[from]={};}
OpenLayers.Projection.transforms[from][to]=method;};OpenLayers.Projection.transform=function(point,source,dest){if(source.proj&&dest.proj){point=Proj4js.transform(source.proj,dest.proj,point);}else if(source&&dest&&OpenLayers.Projection.transforms[source.getCode()]&&OpenLayers.Projection.transforms[source.getCode()][dest.getCode()]){OpenLayers.Projection.transforms[source.getCode()][dest.getCode()](point);}
return point;};OpenLayers.Protocol.WFS.v1=OpenLayers.Class(OpenLayers.Protocol,{version:null,srsName:"EPSG:4326",featureType:null,featureNS:null,geometryName:"the_geom",schema:null,featurePrefix:"feature",formatOptions:null,initialize:function(options){OpenLayers.Protocol.prototype.initialize.apply(this,[options]);if(!options.format){this.format=OpenLayers.Format.WFST(OpenLayers.Util.extend({version:this.version,featureType:this.featureType,featureNS:this.featureNS,featurePrefix:this.featurePrefix,geometryName:this.geometryName,srsName:this.srsName,schema:this.schema},this.formatOptions));}
if(!this.featureNS){var readNode=this.format.readNode;this.format.readNode=function(node,obj){if(!this.featureNS&&node.prefix==this.featurePrefix){this.featureNS=node.namespaceURI;this.setNamespace("feature",this.featureNS);}
return readNode.apply(this,arguments);}}},destroy:function(){if(this.options&&!this.options.format){this.format.destroy();}
this.format=null;OpenLayers.Protocol.prototype.destroy.apply(this);},createCallback:function(method,response,options){return OpenLayers.Function.bind(function(){method.apply(this,[response,options]);},this);},read:function(options){options=OpenLayers.Util.extend({},options);OpenLayers.Util.applyDefaults(options,this.options||{});var response=new OpenLayers.Protocol.Response({requestType:"read"});var data=OpenLayers.Format.XML.prototype.write.apply(this.format,[this.format.writeNode("wfs:GetFeature",options)]);response.priv=OpenLayers.Request.POST({url:options.url,callback:this.createCallback(this.handleRead,response,options),params:options.params,headers:options.headers,data:data});return response;},handleRead:function(response,options){if(options.callback){var request=response.priv;if(request.status>=200&&request.status<300){response.features=this.parseFeatures(request);response.code=OpenLayers.Protocol.Response.SUCCESS;}else{response.code=OpenLayers.Protocol.Response.FAILURE;}
options.callback.call(options.scope,response);};},parseFeatures:function(request){var doc=request.responseXML;if(!doc||!doc.documentElement){doc=request.responseText;}
if(!doc||doc.length<=0){return null;}
return this.format.read(doc);},commit:function(features,options){options=OpenLayers.Util.extend({},options);OpenLayers.Util.applyDefaults(options,this.options);var response=new OpenLayers.Protocol.Response({requestType:"commit",reqFeatures:features});response.priv=OpenLayers.Request.POST({url:options.url,data:this.format.write(features,options),callback:this.createCallback(this.handleCommit,response,options)});return response;},handleCommit:function(response,options){if(options.callback){var request=response.priv;var data=request.responseXML;if(!data||!data.documentElement){data=request.responseText;}
var obj=this.format.read(data)||{};response.insertIds=obj.insertIds||[];response.code=(obj.success)?OpenLayers.Protocol.Response.SUCCESS:OpenLayers.Protocol.Response.FAILURE;options.callback.call(options.scope,response);}},filterDelete:function(filter,options){options=OpenLayers.Util.extend({},options);OpenLayers.Util.applyDefaults(options,this.options);var response=new OpenLayers.Protocol.Response({requestType:"commit"});var root=this.format.createElementNSPlus("wfs:Transaction",{attributes:{service:"WFS",version:this.version}});var deleteNode=this.format.createElementNSPlus("wfs:Delete",{attributes:{typeName:(options.featureNS?this.featurePrefix+":":"")+
options.featureType}});if(options.featureNS){deleteNode.setAttribute("xmlns:"+this.featurePrefix,options.featureNS);}
var filterNode=this.format.writeNode("ogc:Filter",filter);deleteNode.appendChild(filterNode);root.appendChild(deleteNode);var data=OpenLayers.Format.XML.prototype.write.apply(this.format,[root]);return OpenLayers.Request.POST({url:this.url,callback:options.callback||function(){},data:data});},abort:function(response){if(response){response.priv.abort();}},CLASS_NAME:"OpenLayers.Protocol.WFS.v1"});OpenLayers.Renderer.SVG=OpenLayers.Class(OpenLayers.Renderer.Elements,{xmlns:"http://www.w3.org/2000/svg",xlinkns:"http://www.w3.org/1999/xlink",MAX_PIXEL:15000,translationParameters:null,symbolSize:{},isGecko:null,initialize:function(containerID){if(!this.supported()){return;}
OpenLayers.Renderer.Elements.prototype.initialize.apply(this,arguments);this.translationParameters={x:0,y:0};this.isGecko=(navigator.userAgent.toLowerCase().indexOf("gecko/")!=-1);},destroy:function(){OpenLayers.Renderer.Elements.prototype.destroy.apply(this,arguments);},supported:function(){var svgFeature="http://www.w3.org/TR/SVG11/feature#";return(document.implementation&&(document.implementation.hasFeature("org.w3c.svg","1.0")||document.implementation.hasFeature(svgFeature+"SVG","1.1")||document.implementation.hasFeature(svgFeature+"BasicStructure","1.1")));},inValidRange:function(x,y,xyOnly){var left=x+(xyOnly?0:this.translationParameters.x);var top=y+(xyOnly?0:this.translationParameters.y);return(left>=-this.MAX_PIXEL&&left<=this.MAX_PIXEL&&top>=-this.MAX_PIXEL&&top<=this.MAX_PIXEL);},setExtent:function(extent,resolutionChanged){OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,arguments);var resolution=this.getResolution();var left=-extent.left/resolution;var top=extent.top/resolution;if(resolutionChanged){this.left=left;this.top=top;var extentString="0 0 "+this.size.w+" "+this.size.h;this.rendererRoot.setAttributeNS(null,"viewBox",extentString);this.translate(0,0);return true;}else{var inRange=this.translate(left-this.left,top-this.top);if(!inRange){this.setExtent(extent,true);}
return inRange;}},translate:function(x,y){if(!this.inValidRange(x,y,true)){return false;}else{var transformString="";if(x||y){transformString="translate("+x+","+y+")";}
this.root.setAttributeNS(null,"transform",transformString);this.translationParameters={x:x,y:y};return true;}},setSize:function(size){OpenLayers.Renderer.prototype.setSize.apply(this,arguments);this.rendererRoot.setAttributeNS(null,"width",this.size.w);this.rendererRoot.setAttributeNS(null,"height",this.size.h);},getNodeType:function(geometry,style){var nodeType=null;switch(geometry.CLASS_NAME){case"OpenLayers.Geometry.Point":if(style.externalGraphic){nodeType="image";}else if(this.isComplexSymbol(style.graphicName)){nodeType="use";}else{nodeType="circle";}
break;case"OpenLayers.Geometry.Rectangle":nodeType="rect";break;case"OpenLayers.Geometry.LineString":nodeType="polyline";break;case"OpenLayers.Geometry.LinearRing":nodeType="polygon";break;case"OpenLayers.Geometry.Polygon":case"OpenLayers.Geometry.Curve":case"OpenLayers.Geometry.Surface":nodeType="path";break;default:break;}
return nodeType;},setStyle:function(node,style,options){style=style||node._style;options=options||node._options;var r=parseFloat(node.getAttributeNS(null,"r"));var widthFactor=1;var pos;if(node._geometryClass=="OpenLayers.Geometry.Point"&&r){node.style.visibility="";if(style.graphic===false){node.style.visibility="hidden";}else if(style.externalGraphic){pos=this.getPosition(node);if(style.graphicTitle){node.setAttributeNS(null,"title",style.graphicTitle);}
if(style.graphicWidth&&style.graphicHeight){node.setAttributeNS(null,"preserveAspectRatio","none");}
var width=style.graphicWidth||style.graphicHeight;var height=style.graphicHeight||style.graphicWidth;width=width?width:style.pointRadius*2;height=height?height:style.pointRadius*2;var xOffset=(style.graphicXOffset!=undefined)?style.graphicXOffset:-(0.5*width);var yOffset=(style.graphicYOffset!=undefined)?style.graphicYOffset:-(0.5*height);var opacity=style.graphicOpacity||style.fillOpacity;node.setAttributeNS(null,"x",(pos.x+xOffset).toFixed());node.setAttributeNS(null,"y",(pos.y+yOffset).toFixed());node.setAttributeNS(null,"width",width);node.setAttributeNS(null,"height",height);node.setAttributeNS(this.xlinkns,"href",style.externalGraphic);node.setAttributeNS(null,"style","opacity: "+opacity);}else if(this.isComplexSymbol(style.graphicName)){var offset=style.pointRadius*3;var size=offset*2;var id=this.importSymbol(style.graphicName);var href="#"+id;pos=this.getPosition(node);widthFactor=this.symbolSize[id]/size;var parent=node.parentNode;var nextSibling=node.nextSibling;if(parent){parent.removeChild(node);}
node.setAttributeNS(this.xlinkns,"href",href);node.setAttributeNS(null,"width",size);node.setAttributeNS(null,"height",size);node.setAttributeNS(null,"x",pos.x-offset);node.setAttributeNS(null,"y",pos.y-offset);if(nextSibling){parent.insertBefore(node,nextSibling);}else if(parent){parent.appendChild(node);}}else{node.setAttributeNS(null,"r",style.pointRadius);}
if(typeof style.rotation!="undefined"&&pos){var rotation=OpenLayers.String.format("rotate(${0} ${1} ${2})",[style.rotation,pos.x,pos.y]);node.setAttributeNS(null,"transform",rotation);}}
if(options.isFilled){node.setAttributeNS(null,"fill",style.fillColor);node.setAttributeNS(null,"fill-opacity",style.fillOpacity);}else{node.setAttributeNS(null,"fill","none");}
if(options.isStroked){node.setAttributeNS(null,"stroke",style.strokeColor);node.setAttributeNS(null,"stroke-opacity",style.strokeOpacity);node.setAttributeNS(null,"stroke-width",style.strokeWidth*widthFactor);node.setAttributeNS(null,"stroke-linecap",style.strokeLinecap);node.setAttributeNS(null,"stroke-linejoin","round");node.setAttributeNS(null,"stroke-dasharray",this.dashStyle(style,widthFactor));}else{node.setAttributeNS(null,"stroke","none");}
if(style.pointerEvents){node.setAttributeNS(null,"pointer-events",style.pointerEvents);}
if(style.cursor!=null){node.setAttributeNS(null,"cursor",style.cursor);}
return node;},dashStyle:function(style,widthFactor){var w=style.strokeWidth*widthFactor;switch(style.strokeDashstyle){case'solid':return'none';case'dot':return[1,4*w].join();case'dash':return[4*w,4*w].join();case'dashdot':return[4*w,4*w,1,4*w].join();case'longdash':return[8*w,4*w].join();case'longdashdot':return[8*w,4*w,1,4*w].join();default:return style.strokeDashstyle.replace(/ /g,",");}},createNode:function(type,id){var node=document.createElementNS(this.xmlns,type);if(id){node.setAttributeNS(null,"id",id);}
return node;},nodeTypeCompare:function(node,type){return(type==node.nodeName);},createRenderRoot:function(){return this.nodeFactory(this.container.id+"_svgRoot","svg");},createRoot:function(suffix){return this.nodeFactory(this.container.id+suffix,"g");},createDefs:function(){var defs=this.nodeFactory(this.container.id+"_defs","defs");this.rendererRoot.appendChild(defs);return defs;},drawPoint:function(node,geometry){return this.drawCircle(node,geometry,1);},drawCircle:function(node,geometry,radius){var resolution=this.getResolution();var x=(geometry.x/resolution+this.left);var y=(this.top-geometry.y/resolution);if(this.inValidRange(x,y)){node.setAttributeNS(null,"cx",x);node.setAttributeNS(null,"cy",y);node.setAttributeNS(null,"r",radius);return node;}else{return false;}},drawLineString:function(node,geometry){var componentsResult=this.getComponentsString(geometry.components);if(componentsResult.path){node.setAttributeNS(null,"points",componentsResult.path);return(componentsResult.complete?node:null);}else{return false;}},drawLinearRing:function(node,geometry){var componentsResult=this.getComponentsString(geometry.components);if(componentsResult.path){node.setAttributeNS(null,"points",componentsResult.path);return(componentsResult.complete?node:null);}else{return false;}},drawPolygon:function(node,geometry){var d="";var draw=true;var complete=true;var linearRingResult,path;for(var j=0,len=geometry.components.length;j<len;j++){d+=" M";linearRingResult=this.getComponentsString(geometry.components[j].components," ");path=linearRingResult.path;if(path){d+=" "+path;complete=linearRingResult.complete&&complete;}else{draw=false;}}
d+=" z";if(draw){node.setAttributeNS(null,"d",d);node.setAttributeNS(null,"fill-rule","evenodd");return complete?node:null;}else{return false;}},drawRectangle:function(node,geometry){var resolution=this.getResolution();var x=(geometry.x/resolution+this.left);var y=(this.top-geometry.y/resolution);if(this.inValidRange(x,y)){node.setAttributeNS(null,"x",x);node.setAttributeNS(null,"y",y);node.setAttributeNS(null,"width",geometry.width/resolution);node.setAttributeNS(null,"height",geometry.height/resolution);return node;}else{return false;}},drawSurface:function(node,geometry){var d=null;var draw=true;for(var i=0,len=geometry.components.length;i<len;i++){if((i%3)==0&&(i/3)==0){var component=this.getShortString(geometry.components[i]);if(!component){draw=false;}
d="M "+component;}else if((i%3)==1){var component=this.getShortString(geometry.components[i]);if(!component){draw=false;}
d+=" C "+component;}else{var component=this.getShortString(geometry.components[i]);if(!component){draw=false;}
d+=" "+component;}}
d+=" Z";if(draw){node.setAttributeNS(null,"d",d);return node;}else{return false;}},drawText:function(featureId,style,location){var resolution=this.getResolution();var x=(location.x/resolution+this.left);var y=(location.y/resolution-this.top);var label=this.nodeFactory(featureId+this.LABEL_ID_SUFFIX,"text");var tspan=this.nodeFactory(featureId+this.LABEL_ID_SUFFIX+"_tspan","tspan");label.setAttributeNS(null,"x",x);label.setAttributeNS(null,"y",-y);label.setAttributeNS(null,"pointer-events","none");if(style.fontColor){label.setAttributeNS(null,"fill",style.fontColor);}
if(style.fontFamily){label.setAttributeNS(null,"font-family",style.fontFamily);}
if(style.fontSize){label.setAttributeNS(null,"font-size",style.fontSize);}
if(style.fontWeight){label.setAttributeNS(null,"font-weight",style.fontWeight);}
var align=style.labelAlign||"cm";label.setAttributeNS(null,"text-anchor",OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]]||"middle");if(this.isGecko){label.setAttributeNS(null,"dominant-baseline",OpenLayers.Renderer.SVG.LABEL_ALIGN[align[1]]||"central");}else{tspan.setAttributeNS(null,"baseline-shift",OpenLayers.Renderer.SVG.LABEL_VSHIFT[align[1]]||"-35%");}
tspan.textContent=style.label;if(!label.parentNode){label.appendChild(tspan);this.textRoot.appendChild(label);}},getComponentsString:function(components,separator){var renderCmp=[];var complete=true;var len=components.length;var strings=[];var str,component,j;for(var i=0;i<len;i++){component=components[i];renderCmp.push(component);str=this.getShortString(component);if(str){strings.push(str);}else{if(i>0){if(this.getShortString(components[i-1])){strings.push(this.clipLine(components[i],components[i-1]));}}
if(i<len-1){if(this.getShortString(components[i+1])){strings.push(this.clipLine(components[i],components[i+1]));}}
complete=false;}}
return{path:strings.join(separator||","),complete:complete};},clipLine:function(badComponent,goodComponent){if(goodComponent.equals(badComponent)){return"";}
var resolution=this.getResolution();var maxX=this.MAX_PIXEL-this.translationParameters.x;var maxY=this.MAX_PIXEL-this.translationParameters.y;var x1=goodComponent.x/resolution+this.left;var y1=this.top-goodComponent.y/resolution;var x2=badComponent.x/resolution+this.left;var y2=this.top-badComponent.y/resolution;var k;if(x2<-maxX||x2>maxX){k=(y2-y1)/(x2-x1);x2=x2<0?-maxX:maxX;y2=y1+(x2-x1)*k;}
if(y2<-maxY||y2>maxY){k=(x2-x1)/(y2-y1);y2=y2<0?-maxY:maxY;x2=x1+(y2-y1)*k;}
return x2+","+y2;},getShortString:function(point){var resolution=this.getResolution();var x=(point.x/resolution+this.left);var y=(this.top-point.y/resolution);if(this.inValidRange(x,y)){return x+","+y;}else{return false;}},getPosition:function(node){return({x:parseFloat(node.getAttributeNS(null,"cx")),y:parseFloat(node.getAttributeNS(null,"cy"))});},importSymbol:function(graphicName){if(!this.defs){this.defs=this.createDefs();}
var id=this.container.id+"-"+graphicName;if(document.getElementById(id)!=null){return id;}
var symbol=OpenLayers.Renderer.symbol[graphicName];if(!symbol){throw new Error(graphicName+' is not a valid symbol name');return;}
var symbolNode=this.nodeFactory(id,"symbol");var node=this.nodeFactory(null,"polygon");symbolNode.appendChild(node);var symbolExtent=new OpenLayers.Bounds(Number.MAX_VALUE,Number.MAX_VALUE,0,0);var points="";var x,y;for(var i=0;i<symbol.length;i=i+2){x=symbol[i];y=symbol[i+1];symbolExtent.left=Math.min(symbolExtent.left,x);symbolExtent.bottom=Math.min(symbolExtent.bottom,y);symbolExtent.right=Math.max(symbolExtent.right,x);symbolExtent.top=Math.max(symbolExtent.top,y);points+=" "+x+","+y;}
node.setAttributeNS(null,"points",points);var width=symbolExtent.getWidth();var height=symbolExtent.getHeight();var viewBox=[symbolExtent.left-width,symbolExtent.bottom-height,width*3,height*3];symbolNode.setAttributeNS(null,"viewBox",viewBox.join(" "));this.symbolSize[id]=Math.max(width,height)*3;this.defs.appendChild(symbolNode);return symbolNode.id;},CLASS_NAME:"OpenLayers.Renderer.SVG"});OpenLayers.Renderer.SVG.LABEL_ALIGN={"l":"start","r":"end","b":"bottom","t":"hanging"};OpenLayers.Renderer.SVG.LABEL_VSHIFT={"t":"-70%","b":"0"};OpenLayers.Renderer.VML=OpenLayers.Class(OpenLayers.Renderer.Elements,{xmlns:"urn:schemas-microsoft-com:vml",symbolCache:{},offset:null,initialize:function(containerID){if(!this.supported()){return;}
if(!document.namespaces.olv){document.namespaces.add("olv",this.xmlns);var style=document.createStyleSheet();var shapes=['shape','rect','oval','fill','stroke','imagedata','group','textbox'];for(var i=0,len=shapes.length;i<len;i++){style.addRule('olv\\:'+shapes[i],"behavior: url(#default#VML); "+"position: absolute; display: inline-block;");}}
OpenLayers.Renderer.Elements.prototype.initialize.apply(this,arguments);this.offset={x:0,y:0};},destroy:function(){OpenLayers.Renderer.Elements.prototype.destroy.apply(this,arguments);},supported:function(){return!!(document.namespaces);},setExtent:function(extent,resolutionChanged){OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,arguments);var resolution=this.getResolution();var left=extent.left/resolution;var top=extent.top/resolution-this.size.h;if(resolutionChanged){this.offset={x:left,y:top};left=0;top=0;}else{left=left-this.offset.x;top=top-this.offset.y;}
var org=left+" "+top;this.root.coordorigin=org;var roots=[this.root,this.vectorRoot,this.textRoot];var root;for(var i=0,len=roots.length;i<len;++i){root=roots[i];var size=this.size.w+" "+this.size.h;root.coordsize=size;}
this.root.style.flip="y";return true;},setSize:function(size){OpenLayers.Renderer.prototype.setSize.apply(this,arguments);var roots=[this.rendererRoot,this.root,this.vectorRoot,this.textRoot];var w=this.size.w+"px";var h=this.size.h+"px";var root;for(var i=0,len=roots.length;i<len;++i){root=roots[i];root.style.width=w;root.style.height=h;}},getNodeType:function(geometry,style){var nodeType=null;switch(geometry.CLASS_NAME){case"OpenLayers.Geometry.Point":if(style.externalGraphic){nodeType="olv:rect";}else if(this.isComplexSymbol(style.graphicName)){nodeType="olv:shape";}else{nodeType="olv:oval";}
break;case"OpenLayers.Geometry.Rectangle":nodeType="olv:rect";break;case"OpenLayers.Geometry.LineString":case"OpenLayers.Geometry.LinearRing":case"OpenLayers.Geometry.Polygon":case"OpenLayers.Geometry.Curve":case"OpenLayers.Geometry.Surface":nodeType="olv:shape";break;default:break;}
return nodeType;},setStyle:function(node,style,options,geometry){style=style||node._style;options=options||node._options;var widthFactor=1;if(node._geometryClass=="OpenLayers.Geometry.Point"){if(style.externalGraphic){if(style.graphicTitle){node.title=style.graphicTitle;}
var width=style.graphicWidth||style.graphicHeight;var height=style.graphicHeight||style.graphicWidth;width=width?width:style.pointRadius*2;height=height?height:style.pointRadius*2;var resolution=this.getResolution();var xOffset=(style.graphicXOffset!=undefined)?style.graphicXOffset:-(0.5*width);var yOffset=(style.graphicYOffset!=undefined)?style.graphicYOffset:-(0.5*height);node.style.left=((geometry.x/resolution-this.offset.x)+xOffset).toFixed();node.style.top=((geometry.y/resolution-this.offset.y)-(yOffset+height)).toFixed();node.style.width=width+"px";node.style.height=height+"px";node.style.flip="y";style.fillColor="none";options.isStroked=false;}else if(this.isComplexSymbol(style.graphicName)){var cache=this.importSymbol(style.graphicName);node.path=cache.path;node.coordorigin=cache.left+","+cache.bottom;var size=cache.size;node.coordsize=size+","+size;this.drawCircle(node,geometry,style.pointRadius);node.style.flip="y";}else{this.drawCircle(node,geometry,style.pointRadius);}}
if(options.isFilled){node.fillcolor=style.fillColor;}else{node.filled="false";}
var fills=node.getElementsByTagName("fill");var fill=(fills.length==0)?null:fills[0];if(!options.isFilled){if(fill){node.removeChild(fill);}}else{if(!fill){fill=this.createNode('olv:fill',node.id+"_fill");}
fill.opacity=style.fillOpacity;if(node._geometryClass=="OpenLayers.Geometry.Point"&&style.externalGraphic){if(style.graphicOpacity){fill.opacity=style.graphicOpacity;}
fill.src=style.externalGraphic;fill.type="frame";if(!(style.graphicWidth&&style.graphicHeight)){fill.aspect="atmost";}}
if(fill.parentNode!=node){node.appendChild(fill);}}
if(typeof style.rotation!="undefined"){if(style.externalGraphic){this.graphicRotate(node,xOffset,yOffset);fill.opacity=0;}else{node.style.rotation=style.rotation;}}
if(options.isStroked){node.strokecolor=style.strokeColor;node.strokeweight=style.strokeWidth+"px";}else{node.stroked=false;}
var strokes=node.getElementsByTagName("stroke");var stroke=(strokes.length==0)?null:strokes[0];if(!options.isStroked){if(stroke){node.removeChild(stroke);}}else{if(!stroke){stroke=this.createNode('olv:stroke',node.id+"_stroke");node.appendChild(stroke);}
stroke.opacity=style.strokeOpacity;stroke.endcap=!style.strokeLinecap||style.strokeLinecap=='butt'?'flat':style.strokeLinecap;stroke.dashstyle=this.dashStyle(style);}
if(style.cursor!="inherit"&&style.cursor!=null){node.style.cursor=style.cursor;}
return node;},graphicRotate:function(node,xOffset,yOffset){var style=style||node._style;var options=node._options;var aspectRatio,size;if(!(style.graphicWidth&&style.graphicHeight)){var img=new Image();img.onreadystatechange=OpenLayers.Function.bind(function(){if(img.readyState=="complete"||img.readyState=="interactive"){aspectRatio=img.width/img.height;size=Math.max(style.pointRadius*2,style.graphicWidth||0,style.graphicHeight||0);xOffset=xOffset*aspectRatio;style.graphicWidth=size*aspectRatio;style.graphicHeight=size;this.graphicRotate(node,xOffset,yOffset);}},this);img.src=style.externalGraphic;return;}else{size=Math.max(style.graphicWidth,style.graphicHeight);aspectRatio=style.graphicWidth/style.graphicHeight;}
var width=Math.round(style.graphicWidth||size*aspectRatio);var height=Math.round(style.graphicHeight||size);node.style.width=width+"px";node.style.height=height+"px";var image=document.getElementById(node.id+"_image");if(!image){image=this.createNode("olv:imagedata",node.id+"_image");node.appendChild(image);}
image.style.width=width+"px";image.style.height=height+"px";image.src=style.externalGraphic;image.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader("+"src='', sizingMethod='scale')";var rotation=style.rotation*Math.PI/180;var sintheta=Math.sin(rotation);var costheta=Math.cos(rotation);var filter="progid:DXImageTransform.Microsoft.Matrix(M11="+costheta+",M12="+(-sintheta)+",M21="+sintheta+",M22="+costheta+",SizingMethod='auto expand')\n";var opacity=style.graphicOpacity||style.fillOpacity;if(opacity&&opacity!=1){filter+="progid:DXImageTransform.Microsoft.BasicImage(opacity="+
opacity+")\n";}
node.style.filter=filter;var centerPoint=new OpenLayers.Geometry.Point(-xOffset,-yOffset);var imgBox=new OpenLayers.Bounds(0,0,width,height).toGeometry();imgBox.rotate(style.rotation,centerPoint);var imgBounds=imgBox.getBounds();node.style.left=Math.round(parseInt(node.style.left)+imgBounds.left)+"px";node.style.top=Math.round(parseInt(node.style.top)-imgBounds.bottom)+"px";},postDraw:function(node){var fillColor=node._style.fillColor;var strokeColor=node._style.strokeColor;if(fillColor=="none"&&node.fillcolor!=fillColor){node.fillcolor=fillColor;}
if(strokeColor=="none"&&node.strokecolor!=strokeColor){node.strokecolor=strokeColor;}},setNodeDimension:function(node,geometry){var bbox=geometry.getBounds();if(bbox){var resolution=this.getResolution();var scaledBox=new OpenLayers.Bounds((bbox.left/resolution-this.offset.x).toFixed(),(bbox.bottom/resolution-this.offset.y).toFixed(),(bbox.right/resolution-this.offset.x).toFixed(),(bbox.top/resolution-this.offset.y).toFixed());node.style.left=scaledBox.left+"px";node.style.top=scaledBox.top+"px";node.style.width=scaledBox.getWidth()+"px";node.style.height=scaledBox.getHeight()+"px";node.coordorigin=scaledBox.left+" "+scaledBox.top;node.coordsize=scaledBox.getWidth()+" "+scaledBox.getHeight();}},dashStyle:function(style){var dash=style.strokeDashstyle;switch(dash){case'solid':case'dot':case'dash':case'dashdot':case'longdash':case'longdashdot':return dash;default:var parts=dash.split(/[ ,]/);if(parts.length==2){if(1*parts[0]>=2*parts[1]){return"longdash";}
return(parts[0]==1||parts[1]==1)?"dot":"dash";}else if(parts.length==4){return(1*parts[0]>=2*parts[1])?"longdashdot":"dashdot";}
return"solid";}},createNode:function(type,id){var node=document.createElement(type);if(id){node.id=id;}
node.unselectable='on';node.onselectstart=function(){return(false);};return node;},nodeTypeCompare:function(node,type){var subType=type;var splitIndex=subType.indexOf(":");if(splitIndex!=-1){subType=subType.substr(splitIndex+1);}
var nodeName=node.nodeName;splitIndex=nodeName.indexOf(":");if(splitIndex!=-1){nodeName=nodeName.substr(splitIndex+1);}
return(subType==nodeName);},createRenderRoot:function(){return this.nodeFactory(this.container.id+"_vmlRoot","div");},createRoot:function(suffix){return this.nodeFactory(this.container.id+suffix,"olv:group");},drawPoint:function(node,geometry){return this.drawCircle(node,geometry,1);},drawCircle:function(node,geometry,radius){if(!isNaN(geometry.x)&&!isNaN(geometry.y)){var resolution=this.getResolution();node.style.left=((geometry.x/resolution-this.offset.x).toFixed()-radius)+"px";node.style.top=((geometry.y/resolution-this.offset.y).toFixed()-radius)+"px";var diameter=radius*2;node.style.width=diameter+"px";node.style.height=diameter+"px";return node;}
return false;},drawLineString:function(node,geometry){return this.drawLine(node,geometry,false);},drawLinearRing:function(node,geometry){return this.drawLine(node,geometry,true);},drawLine:function(node,geometry,closeLine){this.setNodeDimension(node,geometry);var resolution=this.getResolution();var numComponents=geometry.components.length;var parts=new Array(numComponents);var comp,x,y;for(var i=0;i<numComponents;i++){comp=geometry.components[i];x=(comp.x/resolution-this.offset.x);y=(comp.y/resolution-this.offset.y);parts[i]=" "+x.toFixed()+","+y.toFixed()+" l ";}
var end=(closeLine)?" x e":" e";node.path="m"+parts.join("")+end;return node;},drawPolygon:function(node,geometry){this.setNodeDimension(node,geometry);var resolution=this.getResolution();var path=[];var linearRing,i,j,len,ilen,comp,x,y;for(j=0,len=geometry.components.length;j<len;j++){linearRing=geometry.components[j];path.push("m");for(i=0,ilen=linearRing.components.length;i<ilen;i++){comp=linearRing.components[i];x=comp.x/resolution-this.offset.x;y=comp.y/resolution-this.offset.y;path.push(" "+x.toFixed()+","+y.toFixed());if(i==0){path.push(" l");}}
path.push(" x ");}
path.push("e");node.path=path.join("");return node;},drawRectangle:function(node,geometry){var resolution=this.getResolution();node.style.left=(geometry.x/resolution-this.offset.x)+"px";node.style.top=(geometry.y/resolution-this.offset.y)+"px";node.style.width=geometry.width/resolution+"px";node.style.height=geometry.height/resolution+"px";return node;},drawText:function(featureId,style,location){var label=this.nodeFactory(featureId+this.LABEL_ID_SUFFIX,"olv:rect");var textbox=this.nodeFactory(featureId+this.LABEL_ID_SUFFIX+"_textbox","olv:textbox");var resolution=this.getResolution();label.style.left=(location.x/resolution-this.offset.x).toFixed()+"px";label.style.top=(location.y/resolution-this.offset.y).toFixed()+"px";label.style.flip="y";textbox.innerText=style.label;if(style.fillColor){textbox.style.color=style.fontColor;}
if(style.fontFamily){textbox.style.fontFamily=style.fontFamily;}
if(style.fontSize){textbox.style.fontSize=style.fontSize;}
if(style.fontWeight){textbox.style.fontWeight=style.fontWeight;}
textbox.style.whiteSpace="nowrap";textbox.inset="1px,0px,0px,0px";if(!label.parentNode){label.appendChild(textbox);this.textRoot.appendChild(label);}
var align=style.labelAlign||"cm";var xshift=textbox.clientWidth*(OpenLayers.Renderer.VML.LABEL_SHIFT[align.substr(0,1)]);var yshift=textbox.clientHeight*(OpenLayers.Renderer.VML.LABEL_SHIFT[align.substr(1,1)]);label.style.left=parseInt(label.style.left)-xshift-1+"px";label.style.top=parseInt(label.style.top)+yshift+"px";},drawSurface:function(node,geometry){this.setNodeDimension(node,geometry);var resolution=this.getResolution();var path=[];var comp,x,y;for(var i=0,len=geometry.components.length;i<len;i++){comp=geometry.components[i];x=comp.x/resolution-this.offset.x;y=comp.y/resolution-this.offset.y;if((i%3)==0&&(i/3)==0){path.push("m");}else if((i%3)==1){path.push(" c");}
path.push(" "+x+","+y);}
path.push(" x e");node.path=path.join("");return node;},moveRoot:function(renderer){var layer=this.map.getLayer(renderer.container.id);if(layer instanceof OpenLayers.Layer.Vector.RootContainer){layer=this.map.getLayer(this.container.id);}
layer&&layer.renderer.clear();OpenLayers.Renderer.Elements.prototype.moveRoot.apply(this,arguments);layer&&layer.redraw();},importSymbol:function(graphicName){var id=this.container.id+"-"+graphicName;var cache=this.symbolCache[id];if(cache){return cache;}
var symbol=OpenLayers.Renderer.symbol[graphicName];if(!symbol){throw new Error(graphicName+' is not a valid symbol name');return;}
var symbolExtent=new OpenLayers.Bounds(Number.MAX_VALUE,Number.MAX_VALUE,0,0);var pathitems=["m"];for(var i=0;i<symbol.length;i=i+2){x=symbol[i];y=symbol[i+1];symbolExtent.left=Math.min(symbolExtent.left,x);symbolExtent.bottom=Math.min(symbolExtent.bottom,y);symbolExtent.right=Math.max(symbolExtent.right,x);symbolExtent.top=Math.max(symbolExtent.top,y);pathitems.push(x);pathitems.push(y);if(i==0){pathitems.push("l");}}
pathitems.push("x e");var path=pathitems.join(" ");var diff=(symbolExtent.getWidth()-symbolExtent.getHeight())/2;if(diff>0){symbolExtent.bottom=symbolExtent.bottom-diff;symbolExtent.top=symbolExtent.top+diff;}else{symbolExtent.left=symbolExtent.left-diff;symbolExtent.right=symbolExtent.right+diff;}
cache={path:path,size:symbolExtent.getWidth(),left:symbolExtent.left,bottom:symbolExtent.bottom};this.symbolCache[id]=cache;return cache;},CLASS_NAME:"OpenLayers.Renderer.VML"});OpenLayers.Renderer.VML.LABEL_SHIFT={"l":0,"c":.5,"r":1,"t":0,"m":.5,"b":1};OpenLayers.Tile=OpenLayers.Class({EVENT_TYPES:["loadstart","loadend","reload","unload"],events:null,id:null,layer:null,url:null,bounds:null,size:null,position:null,isLoading:false,initialize:function(layer,position,bounds,url,size){this.layer=layer;this.position=position.clone();this.bounds=bounds.clone();this.url=url;this.size=size.clone();this.id=OpenLayers.Util.createUniqueID("Tile_");this.events=new OpenLayers.Events(this,null,this.EVENT_TYPES);},unload:function(){if(this.isLoading){this.isLoading=false;this.events.triggerEvent("unload");}},destroy:function(){this.layer=null;this.bounds=null;this.size=null;this.position=null;this.events.destroy();this.events=null;},clone:function(obj){if(obj==null){obj=new OpenLayers.Tile(this.layer,this.position,this.bounds,this.url,this.size);}
OpenLayers.Util.applyDefaults(obj,this);return obj;},draw:function(){var maxExtent=this.layer.maxExtent;var withinMaxExtent=(maxExtent&&this.bounds.intersectsBounds(maxExtent,false));this.shouldDraw=(withinMaxExtent||this.layer.displayOutsideMaxExtent);this.clear();return this.shouldDraw;},moveTo:function(bounds,position,redraw){if(redraw==null){redraw=true;}
this.bounds=bounds.clone();this.position=position.clone();if(redraw){this.draw();}},clear:function(){},getBoundsFromBaseLayer:function(position){var msg=OpenLayers.i18n('reprojectDeprecated',{'layerName':this.layer.name});OpenLayers.Console.warn(msg);var topLeft=this.layer.map.getLonLatFromLayerPx(position);var bottomRightPx=position.clone();bottomRightPx.x+=this.size.w;bottomRightPx.y+=this.size.h;var bottomRight=this.layer.map.getLonLatFromLayerPx(bottomRightPx);if(topLeft.lon>bottomRight.lon){if(topLeft.lon<0){topLeft.lon=-180-(topLeft.lon+180);}else{bottomRight.lon=180+bottomRight.lon+180;}}
var bounds=new OpenLayers.Bounds(topLeft.lon,bottomRight.lat,bottomRight.lon,topLeft.lat);return bounds;},showTile:function(){if(this.shouldDraw){this.show();}},show:function(){},hide:function(){},CLASS_NAME:"OpenLayers.Tile"});OpenLayers.Control.MouseToolbar=OpenLayers.Class(OpenLayers.Control.MouseDefaults,{mode:null,buttons:null,direction:"vertical",buttonClicked:null,initialize:function(position,direction){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.position=new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,OpenLayers.Control.MouseToolbar.Y);if(position){this.position=position;}
if(direction){this.direction=direction;}
this.measureDivs=[];},destroy:function(){for(var btnId in this.buttons){var btn=this.buttons[btnId];btn.map=null;btn.events.destroy();}
OpenLayers.Control.MouseDefaults.prototype.destroy.apply(this,arguments);},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);OpenLayers.Control.MouseDefaults.prototype.draw.apply(this,arguments);this.buttons={};var sz=new OpenLayers.Size(28,28);var centered=new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,0);this._addButton("zoombox","drag-rectangle-off.png","drag-rectangle-on.png",centered,sz,"Shift->Drag to zoom to area");centered=centered.add((this.direction=="vertical"?0:sz.w),(this.direction=="vertical"?sz.h:0));this._addButton("pan","panning-hand-off.png","panning-hand-on.png",centered,sz,"Drag the map to pan.");centered=centered.add((this.direction=="vertical"?0:sz.w),(this.direction=="vertical"?sz.h:0));this.switchModeTo("pan");return this.div;},_addButton:function(id,img,activeImg,xy,sz,title){var imgLocation=OpenLayers.Util.getImagesLocation()+img;var activeImgLocation=OpenLayers.Util.getImagesLocation()+activeImg;var btn=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_MouseToolbar_"+id,xy,sz,imgLocation,"absolute");this.div.appendChild(btn);btn.imgLocation=imgLocation;btn.activeImgLocation=activeImgLocation;btn.events=new OpenLayers.Events(this,btn,null,true);btn.events.on({"mousedown":this.buttonDown,"mouseup":this.buttonUp,"dblclick":OpenLayers.Event.stop,scope:this});btn.action=id;btn.title=title;btn.alt=title;btn.map=this.map;this.buttons[id]=btn;return btn;},buttonDown:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
this.buttonClicked=evt.element.action;OpenLayers.Event.stop(evt);},buttonUp:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
if(this.buttonClicked!=null){if(this.buttonClicked==evt.element.action){this.switchModeTo(evt.element.action);}
OpenLayers.Event.stop(evt);this.buttonClicked=null;}},defaultDblClick:function(evt){this.switchModeTo("pan");this.performedDrag=false;var newCenter=this.map.getLonLatFromViewPortPx(evt.xy);this.map.setCenter(newCenter,this.map.zoom+1);OpenLayers.Event.stop(evt);return false;},defaultMouseDown:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
this.mouseDragStart=evt.xy.clone();this.performedDrag=false;this.startViaKeyboard=false;if(evt.shiftKey&&this.mode!="zoombox"){this.switchModeTo("zoombox");this.startViaKeyboard=true;}else if(evt.altKey&&this.mode!="measure"){this.switchModeTo("measure");}else if(!this.mode){this.switchModeTo("pan");}
switch(this.mode){case"zoombox":this.map.div.style.cursor="crosshair";this.zoomBox=OpenLayers.Util.createDiv('zoomBox',this.mouseDragStart,null,null,"absolute","2px solid red");this.zoomBox.style.backgroundColor="white";this.zoomBox.style.filter="alpha(opacity=50)";this.zoomBox.style.opacity="0.50";this.zoomBox.style.fontSize="1px";this.zoomBox.style.zIndex=this.map.Z_INDEX_BASE["Popup"]-1;this.map.viewPortDiv.appendChild(this.zoomBox);this.performedDrag=true;break;case"measure":var distance="";if(this.measureStart){var measureEnd=this.map.getLonLatFromViewPortPx(this.mouseDragStart);distance=OpenLayers.Util.distVincenty(this.measureStart,measureEnd);distance=Math.round(distance*100)/100;distance=distance+"km";this.measureStartBox=this.measureBox;}
this.measureStart=this.map.getLonLatFromViewPortPx(this.mouseDragStart);;this.measureBox=OpenLayers.Util.createDiv(null,this.mouseDragStart.add(-2-parseInt(this.map.layerContainerDiv.style.left),-2-parseInt(this.map.layerContainerDiv.style.top)),null,null,"absolute");this.measureBox.style.width="4px";this.measureBox.style.height="4px";this.measureBox.style.fontSize="1px";this.measureBox.style.backgroundColor="red";this.measureBox.style.zIndex=this.map.Z_INDEX_BASE["Popup"]-1;this.map.layerContainerDiv.appendChild(this.measureBox);if(distance){this.measureBoxDistance=OpenLayers.Util.createDiv(null,this.mouseDragStart.add(-2-parseInt(this.map.layerContainerDiv.style.left),2-parseInt(this.map.layerContainerDiv.style.top)),null,null,"absolute");this.measureBoxDistance.innerHTML=distance;this.measureBoxDistance.style.zIndex=this.map.Z_INDEX_BASE["Popup"]-1;this.map.layerContainerDiv.appendChild(this.measureBoxDistance);this.measureDivs.push(this.measureBoxDistance);}
this.measureBox.style.zIndex=this.map.Z_INDEX_BASE["Popup"]-1;this.map.layerContainerDiv.appendChild(this.measureBox);this.measureDivs.push(this.measureBox);break;default:this.map.div.style.cursor="move";break;}
document.onselectstart=function(){return false;};OpenLayers.Event.stop(evt);},switchModeTo:function(mode){if(mode!=this.mode){if(this.mode&&this.buttons[this.mode]){OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode],null,null,null,this.buttons[this.mode].imgLocation);}
if(this.mode=="measure"&&mode!="measure"){for(var i=0,len=this.measureDivs.length;i<len;i++){if(this.measureDivs[i]){this.map.layerContainerDiv.removeChild(this.measureDivs[i]);}}
this.measureDivs=[];this.measureStart=null;}
this.mode=mode;if(this.buttons[mode]){OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode],null,null,null,this.buttons[mode].activeImgLocation);}
switch(this.mode){case"zoombox":this.map.div.style.cursor="crosshair";break;default:this.map.div.style.cursor="";break;}}},leaveMode:function(){this.switchModeTo("pan");},defaultMouseMove:function(evt){if(this.mouseDragStart!=null){switch(this.mode){case"zoombox":var deltaX=Math.abs(this.mouseDragStart.x-evt.xy.x);var deltaY=Math.abs(this.mouseDragStart.y-evt.xy.y);this.zoomBox.style.width=Math.max(1,deltaX)+"px";this.zoomBox.style.height=Math.max(1,deltaY)+"px";if(evt.xy.x<this.mouseDragStart.x){this.zoomBox.style.left=evt.xy.x+"px";}
if(evt.xy.y<this.mouseDragStart.y){this.zoomBox.style.top=evt.xy.y+"px";}
break;default:var deltaX=this.mouseDragStart.x-evt.xy.x;var deltaY=this.mouseDragStart.y-evt.xy.y;var size=this.map.getSize();var newXY=new OpenLayers.Pixel(size.w/2+deltaX,size.h/2+deltaY);var newCenter=this.map.getLonLatFromViewPortPx(newXY);this.map.setCenter(newCenter,null,true);this.mouseDragStart=evt.xy.clone();}
this.performedDrag=true;}},defaultMouseUp:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
switch(this.mode){case"zoombox":this.zoomBoxEnd(evt);if(this.startViaKeyboard){this.leaveMode();}
break;case"pan":if(this.performedDrag){this.map.setCenter(this.map.center);}}
document.onselectstart=null;this.mouseDragStart=null;this.map.div.style.cursor="default";},defaultMouseOut:function(evt){if(this.mouseDragStart!=null&&OpenLayers.Util.mouseLeft(evt,this.map.div)){if(this.zoomBox){this.removeZoomBox();if(this.startViaKeyboard){this.leaveMode();}}
this.mouseDragStart=null;this.map.div.style.cursor="default";}},defaultClick:function(evt){if(this.performedDrag){this.performedDrag=false;return false;}},CLASS_NAME:"OpenLayers.Control.MouseToolbar"});OpenLayers.Control.MouseToolbar.X=6;OpenLayers.Control.MouseToolbar.Y=300;OpenLayers.Control.NavigationHistory=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOGGLE,previous:null,previousOptions:null,next:null,nextOptions:null,limit:50,activateOnDraw:true,clearOnDeactivate:false,registry:null,nextStack:null,previousStack:null,listeners:null,restoring:false,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,[options]);this.registry=OpenLayers.Util.extend({"moveend":function(){return{center:this.map.getCenter(),resolution:this.map.getResolution()};}},this.registry);this.clear();var previousOptions={trigger:OpenLayers.Function.bind(this.previousTrigger,this),displayClass:this.displayClass+" "+this.displayClass+"Previous"};OpenLayers.Util.extend(previousOptions,this.previousOptions);this.previous=new OpenLayers.Control.Button(previousOptions);var nextOptions={trigger:OpenLayers.Function.bind(this.nextTrigger,this),displayClass:this.displayClass+" "+this.displayClass+"Next"};OpenLayers.Util.extend(nextOptions,this.nextOptions);this.next=new OpenLayers.Control.Button(nextOptions);},onPreviousChange:function(state,length){if(state&&!this.previous.active){this.previous.activate();}else if(!state&&this.previous.active){this.previous.deactivate();}},onNextChange:function(state,length){if(state&&!this.next.active){this.next.activate();}else if(!state&&this.next.active){this.next.deactivate();}},destroy:function(){OpenLayers.Control.prototype.destroy.apply(this);this.previous.destroy();this.next.destroy();this.deactivate();for(var prop in this){this[prop]=null;}},setMap:function(map){this.map=map;this.next.setMap(map);this.previous.setMap(map);},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);this.next.draw();this.previous.draw();if(this.activateOnDraw){this.activate();}},previousTrigger:function(){var current=this.previousStack.shift();var state=this.previousStack.shift();if(state!=undefined){this.nextStack.unshift(current);this.previousStack.unshift(state);this.restoring=true;this.restore(state);this.restoring=false;this.onNextChange(this.nextStack[0],this.nextStack.length);this.onPreviousChange(this.previousStack[1],this.previousStack.length-1);}else{this.previousStack.unshift(current);}
return state;},nextTrigger:function(){var state=this.nextStack.shift();if(state!=undefined){this.previousStack.unshift(state);this.restoring=true;this.restore(state);this.restoring=false;this.onNextChange(this.nextStack[0],this.nextStack.length);this.onPreviousChange(this.previousStack[1],this.previousStack.length-1);}
return state;},clear:function(){this.previousStack=[];this.nextStack=[];},restore:function(state){var zoom=this.map.getZoomForResolution(state.resolution);this.map.setCenter(state.center,zoom);},setListeners:function(){this.listeners={};for(var type in this.registry){this.listeners[type]=OpenLayers.Function.bind(function(){if(!this.restoring){var state=this.registry[type].apply(this,arguments);this.previousStack.unshift(state);if(this.previousStack.length>1){this.onPreviousChange(this.previousStack[1],this.previousStack.length-1);}
if(this.previousStack.length>(this.limit+1)){this.previousStack.pop();}
if(this.nextStack.length>0){this.nextStack=[];this.onNextChange(null,0);}}
return true;},this);}},activate:function(){var activated=false;if(this.map){if(OpenLayers.Control.prototype.activate.apply(this)){if(this.listeners==null){this.setListeners();}
for(var type in this.listeners){this.map.events.register(type,this,this.listeners[type]);}
activated=true;if(this.previousStack.length==0){this.initStack();}}}
return activated;},initStack:function(){if(this.map.getCenter()){this.listeners.moveend();}},deactivate:function(){var deactivated=false;if(this.map){if(OpenLayers.Control.prototype.deactivate.apply(this)){for(var type in this.listeners){this.map.events.unregister(type,this,this.listeners[type]);}
if(this.clearOnDeactivate){this.clear();}
deactivated=true;}}
return deactivated;},CLASS_NAME:"OpenLayers.Control.NavigationHistory"});OpenLayers.Control.PanPanel=OpenLayers.Class(OpenLayers.Control.Panel,{initialize:function(options){OpenLayers.Control.Panel.prototype.initialize.apply(this,[options]);this.addControls([new OpenLayers.Control.Pan(OpenLayers.Control.Pan.NORTH),new OpenLayers.Control.Pan(OpenLayers.Control.Pan.SOUTH),new OpenLayers.Control.Pan(OpenLayers.Control.Pan.EAST),new OpenLayers.Control.Pan(OpenLayers.Control.Pan.WEST)]);},CLASS_NAME:"OpenLayers.Control.PanPanel"});OpenLayers.Control.PanZoomBar=OpenLayers.Class(OpenLayers.Control.PanZoom,{zoomStopWidth:18,zoomStopHeight:11,slider:null,sliderEvents:null,zoomBarDiv:null,divEvents:null,zoomWorldIcon:false,initialize:function(){OpenLayers.Control.PanZoom.prototype.initialize.apply(this,arguments);},destroy:function(){this._removeZoomBar();this.map.events.un({"changebaselayer":this.redraw,scope:this});OpenLayers.Control.PanZoom.prototype.destroy.apply(this,arguments);},setMap:function(map){OpenLayers.Control.PanZoom.prototype.setMap.apply(this,arguments);this.map.events.register("changebaselayer",this,this.redraw);},redraw:function(){if(this.div!=null){this.removeButtons();this._removeZoomBar();}
this.draw();},draw:function(px){OpenLayers.Control.prototype.draw.apply(this,arguments);px=this.position.clone();this.buttons=[];var sz=new OpenLayers.Size(18,18);var centered=new OpenLayers.Pixel(px.x+sz.w/2,px.y);var wposition=sz.w;if(this.zoomWorldIcon){centered=new OpenLayers.Pixel(px.x+sz.w,px.y);}
this._addButton("panup","north-mini.png",centered,sz);px.y=centered.y+sz.h;this._addButton("panleft","west-mini.png",px,sz);if(this.zoomWorldIcon){this._addButton("zoomworld","zoom-world-mini.png",px.add(sz.w,0),sz);wposition*=2;}
this._addButton("panright","east-mini.png",px.add(wposition,0),sz);this._addButton("pandown","south-mini.png",centered.add(0,sz.h*2),sz);this._addButton("zoomin","zoom-plus-mini.png",centered.add(0,sz.h*3+5),sz);centered=this._addZoomBar(centered.add(0,sz.h*4+5));this._addButton("zoomout","zoom-minus-mini.png",centered,sz);return this.div;},_addZoomBar:function(centered){var imgLocation=OpenLayers.Util.getImagesLocation();var id=this.id+"_"+this.map.id;var zoomsToEnd=this.map.getNumZoomLevels()-1-this.map.getZoom();var slider=OpenLayers.Util.createAlphaImageDiv(id,centered.add(-1,zoomsToEnd*this.zoomStopHeight),new OpenLayers.Size(20,9),imgLocation+"slider.png","absolute");this.slider=slider;this.sliderEvents=new OpenLayers.Events(this,slider,null,true,{includeXY:true});this.sliderEvents.on({"mousedown":this.zoomBarDown,"mousemove":this.zoomBarDrag,"mouseup":this.zoomBarUp,"dblclick":this.doubleClick,"click":this.doubleClick});var sz=new OpenLayers.Size();sz.h=this.zoomStopHeight*this.map.getNumZoomLevels();sz.w=this.zoomStopWidth;var div=null;if(OpenLayers.Util.alphaHack()){var id=this.id+"_"+this.map.id;div=OpenLayers.Util.createAlphaImageDiv(id,centered,new OpenLayers.Size(sz.w,this.zoomStopHeight),imgLocation+"zoombar.png","absolute",null,"crop");div.style.height=sz.h+"px";}else{div=OpenLayers.Util.createDiv('OpenLayers_Control_PanZoomBar_Zoombar'+this.map.id,centered,sz,imgLocation+"zoombar.png");}
this.zoombarDiv=div;this.divEvents=new OpenLayers.Events(this,div,null,true,{includeXY:true});this.divEvents.on({"mousedown":this.divClick,"mousemove":this.passEventToSlider,"dblclick":this.doubleClick,"click":this.doubleClick});this.div.appendChild(div);this.startTop=parseInt(div.style.top);this.div.appendChild(slider);this.map.events.register("zoomend",this,this.moveZoomBar);centered=centered.add(0,this.zoomStopHeight*this.map.getNumZoomLevels());return centered;},_removeZoomBar:function(){this.sliderEvents.un({"mousedown":this.zoomBarDown,"mousemove":this.zoomBarDrag,"mouseup":this.zoomBarUp,"dblclick":this.doubleClick,"click":this.doubleClick});this.sliderEvents.destroy();this.divEvents.un({"mousedown":this.divClick,"mousemove":this.passEventToSlider,"dblclick":this.doubleClick,"click":this.doubleClick});this.divEvents.destroy();this.div.removeChild(this.zoombarDiv);this.zoombarDiv=null;this.div.removeChild(this.slider);this.slider=null;this.map.events.unregister("zoomend",this,this.moveZoomBar);},passEventToSlider:function(evt){this.sliderEvents.handleBrowserEvent(evt);},divClick:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
var y=evt.xy.y;var top=OpenLayers.Util.pagePosition(evt.object)[1];var levels=(y-top)/this.zoomStopHeight;if(!this.map.fractionalZoom){levels=Math.floor(levels);}
var zoom=(this.map.getNumZoomLevels()-1)-levels;zoom=Math.min(Math.max(zoom,0),this.map.getNumZoomLevels()-1);this.map.zoomTo(zoom);OpenLayers.Event.stop(evt);},zoomBarDown:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
this.map.events.on({"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider,scope:this});this.mouseDragStart=evt.xy.clone();this.zoomStart=evt.xy.clone();this.div.style.cursor="move";this.zoombarDiv.offsets=null;OpenLayers.Event.stop(evt);},zoomBarDrag:function(evt){if(this.mouseDragStart!=null){var deltaY=this.mouseDragStart.y-evt.xy.y;var offsets=OpenLayers.Util.pagePosition(this.zoombarDiv);if((evt.clientY-offsets[1])>0&&(evt.clientY-offsets[1])<parseInt(this.zoombarDiv.style.height)-2){var newTop=parseInt(this.slider.style.top)-deltaY;this.slider.style.top=newTop+"px";this.mouseDragStart=evt.xy.clone();}
OpenLayers.Event.stop(evt);}},zoomBarUp:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
if(this.zoomStart){this.div.style.cursor="";this.map.events.un({"mouseup":this.passEventToSlider,"mousemove":this.passEventToSlider,scope:this});var deltaY=this.zoomStart.y-evt.xy.y;var zoomLevel=this.map.zoom;if(this.map.fractionalZoom){zoomLevel+=deltaY/this.zoomStopHeight;zoomLevel=Math.min(Math.max(zoomLevel,0),this.map.getNumZoomLevels()-1);}else{zoomLevel+=Math.round(deltaY/this.zoomStopHeight);}
this.map.zoomTo(zoomLevel);this.moveZoomBar();this.mouseDragStart=null;OpenLayers.Event.stop(evt);}},moveZoomBar:function(){var newTop=((this.map.getNumZoomLevels()-1)-this.map.getZoom())*this.zoomStopHeight+this.startTop+1;this.slider.style.top=newTop+"px";},CLASS_NAME:"OpenLayers.Control.PanZoomBar"});OpenLayers.Control.PanZoomBar2=OpenLayers.Class(OpenLayers.Control.PanZoom,{zoomStopWidth:13,zoomStopHeight:8,slider:null,sliderEvents:null,zoomBarDiv:null,divEvents:null,zoomWorldIcon:false,initialize:function(){OpenLayers.Control.PanZoom.prototype.initialize.apply(this,arguments);},destroy:function(){this._removeZoomBar();this.map.events.un({"changebaselayer":this.redraw,scope:this});OpenLayers.Control.PanZoom.prototype.destroy.apply(this,arguments);},setMap:function(map){OpenLayers.Control.PanZoom.prototype.setMap.apply(this,arguments);this.map.events.register("changebaselayer",this,this.redraw);},redraw:function(){if(this.div!=null){this.removeButtons();this._removeZoomBar();}
this.draw();},draw:function(px){OpenLayers.Control.prototype.draw.apply(this,arguments);px=this.position.clone();this.buttons=[];var sz=new OpenLayers.Size(21,20);var centered=new OpenLayers.Pixel(px.x+sz.w/2,px.y);var wposition=sz.w;if(this.zoomWorldIcon){centered=new OpenLayers.Pixel(px.x+sz.w,px.y);}
this._addButton("panup","pan_up.png",centered,sz);px.y=centered.y+sz.h;this._addButton("panleft","pan_left.png",px,sz);if(this.zoomWorldIcon){this._addButton("zoomworld","zoom-world-mini.png",px.add(sz.w,0),sz);wposition*=2;}
this._addButton("panright","pan_right.png",px.add(wposition,0),sz);this._addButton("pandown","pan_down.png",centered.add(0,sz.h*2),sz);sz=new OpenLayers.Size(22,20);this._addButton("zoomin","zoom_in_2.png",centered.add(0,sz.h*3),sz);centered=this._addZoomBar(centered.add(0,sz.h*4));this._addButton("zoomout","zoom_out_2.png",centered,sz);return this.div;},_addZoomBar:function(centered){var imgLocation=OpenLayers.Util.getImagesLocation();var widthOffset=1;var id=this.id+"_"+this.map.id;var zoomsToEnd=this.map.getNumZoomLevels()-1-this.map.getZoom();if(OpenLayers.Util.alphaHack()){var slider=OpenLayers.Util.createAlphaImageDiv(id,centered.add(widthOffset,zoomsToEnd*this.zoomStopHeight),new OpenLayers.Size(18,8),imgLocation+"increment_current_2.png","absolute");}
else{var slider=OpenLayers.Util.createDiv(id,centered.add(widthOffset,zoomsToEnd*this.zoomStopHeight),new OpenLayers.Size(18,8),imgLocation+"increment_current_2.png","absolute");}
this.slider=slider;this.sliderEvents=new OpenLayers.Events(this,slider,null,true,{includeXY:true});this.sliderEvents.on({"mousedown":this.zoomBarDown,"mousemove":this.zoomBarDrag,"mouseup":this.zoomBarUp,"dblclick":this.doubleClick,"click":this.doubleClick});var sz=new OpenLayers.Size();sz.h=this.zoomStopHeight*this.map.getNumZoomLevels();sz.w=this.zoomStopWidth;var div=null;if(OpenLayers.Util.alphaHack()){var id=this.id+"_"+this.map.id;div=OpenLayers.Util.createAlphaImageDiv(id,centered.add(widthOffset,0),new OpenLayers.Size(sz.w,this.zoomStopHeight),imgLocation+"increment.png","absolute",null,"crop");div.style.height=sz.h+"px";}else{div=OpenLayers.Util.createDiv('OpenLayers_Control_PanZoomBar_Zoombar'+this.map.id,centered.add(widthOffset,0),sz,imgLocation+"increment.png");}
this.zoombarDiv=div;this.divEvents=new OpenLayers.Events(this,div,null,true,{includeXY:true});this.divEvents.on({"mousedown":this.divClick,"mousemove":this.passEventToSlider,"dblclick":this.doubleClick,"click":this.doubleClick});this.div.appendChild(div);this.startTop=parseInt(div.style.top);this.div.appendChild(slider);this.map.events.register("zoomend",this,this.moveZoomBar);centered=centered.add(0,this.zoomStopHeight*this.map.getNumZoomLevels());return centered;},_removeZoomBar:function(){this.sliderEvents.un({"mousedown":this.zoomBarDown,"mousemove":this.zoomBarDrag,"mouseup":this.zoomBarUp,"dblclick":this.doubleClick,"click":this.doubleClick});this.sliderEvents.destroy();this.divEvents.un({"mousedown":this.divClick,"mousemove":this.passEventToSlider,"dblclick":this.doubleClick,"click":this.doubleClick});this.divEvents.destroy();this.div.removeChild(this.zoombarDiv);this.zoombarDiv=null;this.div.removeChild(this.slider);this.slider=null;this.map.events.unregister("zoomend",this,this.moveZoomBar);},passEventToSlider:function(evt){this.sliderEvents.handleBrowserEvent(evt);},divClick:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
var y=evt.xy.y;var top=OpenLayers.Util.pagePosition(evt.object)[1];var levels=(y-top)/this.zoomStopHeight;if(!this.map.fractionalZoom){levels=Math.floor(levels);}
var zoom=(this.map.getNumZoomLevels()-1)-levels;zoom=Math.min(Math.max(zoom,0),this.map.getNumZoomLevels()-1);this.map.zoomTo(zoom);OpenLayers.Event.stop(evt);},zoomBarDown:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
this.map.events.on({"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider,scope:this});this.mouseDragStart=evt.xy.clone();this.zoomStart=evt.xy.clone();this.div.style.cursor="move";this.zoombarDiv.offsets=null;OpenLayers.Event.stop(evt);},zoomBarDrag:function(evt){if(this.mouseDragStart!=null){var deltaY=this.mouseDragStart.y-evt.xy.y;var offsets=OpenLayers.Util.pagePosition(this.zoombarDiv);if((evt.clientY-offsets[1])>0&&(evt.clientY-offsets[1])<parseInt(this.zoombarDiv.style.height)-2){var newTop=parseInt(this.slider.style.top)-deltaY;this.slider.style.top=newTop+"px";this.mouseDragStart=evt.xy.clone();}
OpenLayers.Event.stop(evt);}},zoomBarUp:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
if(this.zoomStart){this.div.style.cursor="";this.map.events.un({"mouseup":this.passEventToSlider,"mousemove":this.passEventToSlider,scope:this});var deltaY=this.zoomStart.y-evt.xy.y;var zoomLevel=this.map.zoom;if(this.map.fractionalZoom){zoomLevel+=deltaY/this.zoomStopHeight;zoomLevel=Math.min(Math.max(zoomLevel,0),this.map.getNumZoomLevels()-1);}else{zoomLevel+=Math.round(deltaY/this.zoomStopHeight);}
this.map.zoomTo(zoomLevel);this.moveZoomBar();this.mouseDragStart=null;OpenLayers.Event.stop(evt);}},moveZoomBar:function(){var newTop=((this.map.getNumZoomLevels()-1)-this.map.getZoom())*this.zoomStopHeight+this.startTop+1;this.slider.style.top=newTop+"px";},CLASS_NAME:"OpenLayers.Control.PanZoomBar2"});OpenLayers.Control.Permalink=OpenLayers.Class(OpenLayers.Control,{argParserClass:OpenLayers.Control.ArgParser,element:null,base:'',displayProjection:null,initialize:function(element,base,options){OpenLayers.Control.prototype.initialize.apply(this,[options]);this.element=OpenLayers.Util.getElement(element);this.base=base||document.location.href;},destroy:function(){if(this.element.parentNode==this.div){this.div.removeChild(this.element);}
this.element=null;this.map.events.unregister('moveend',this,this.updateLink);OpenLayers.Control.prototype.destroy.apply(this,arguments);},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);for(var i=0,len=this.map.controls.length;i<len;i++){var control=this.map.controls[i];if(control.CLASS_NAME==this.argParserClass.CLASS_NAME){if(control.displayProjection!=this.displayProjection){this.displayProjection=control.displayProjection;}
break;}}
if(i==this.map.controls.length){this.map.addControl(new this.argParserClass({'displayProjection':this.displayProjection}));}},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!this.element){this.div.className=this.displayClass;this.element=document.createElement("a");this.element.innerHTML=OpenLayers.i18n("permalink");this.element.href="";this.div.appendChild(this.element);}
this.map.events.on({'moveend':this.updateLink,'changelayer':this.updateLink,'changebaselayer':this.updateLink,scope:this});this.updateLink();return this.div;},updateLink:function(){var href=this.base;if(href.indexOf('?')!=-1){href=href.substring(0,href.indexOf('?'));}
href+='?'+OpenLayers.Util.getParameterString(this.createParams());this.element.href=href;},createParams:function(center,zoom,layers){center=center||this.map.getCenter();var params=OpenLayers.Util.getParameters(this.base);if(center){params.zoom=zoom||this.map.getZoom();var lat=center.lat;var lon=center.lon;if(this.displayProjection){var mapPosition=OpenLayers.Projection.transform({x:lon,y:lat},this.map.getProjectionObject(),this.displayProjection);lon=mapPosition.x;lat=mapPosition.y;}
params.lat=Math.round(lat*100000)/100000;params.lon=Math.round(lon*100000)/100000;layers=layers||this.map.layers;params.layers='';for(var i=0,len=layers.length;i<len;i++){var layer=layers[i];if(layer.isBaseLayer){params.layers+=(layer==this.map.baseLayer)?"B":"0";}else{params.layers+=(layer.getVisibility())?"T":"F";}}}
return params;},CLASS_NAME:"OpenLayers.Control.Permalink"});OpenLayers.Control.ZoomPanel=OpenLayers.Class(OpenLayers.Control.Panel,{initialize:function(options){OpenLayers.Control.Panel.prototype.initialize.apply(this,[options]);this.addControls([new OpenLayers.Control.ZoomIn(),new OpenLayers.Control.ZoomToMaxExtent(),new OpenLayers.Control.ZoomOut()]);},CLASS_NAME:"OpenLayers.Control.ZoomPanel"});OpenLayers.Format.JSON=OpenLayers.Class(OpenLayers.Format,{indent:"    ",space:" ",newline:"\n",level:0,pretty:false,initialize:function(options){OpenLayers.Format.prototype.initialize.apply(this,[options]);},read:function(json,filter){try{if(/^[\],:{}\s]*$/.test(json.replace(/\\["\\\/bfnrtu]/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){var object=eval('('+json+')');if(typeof filter==='function'){function walk(k,v){if(v&&typeof v==='object'){for(var i in v){if(v.hasOwnProperty(i)){v[i]=walk(i,v[i]);}}}
return filter(k,v);}
object=walk('',object);}
if(this.keepData){this.data=object;}
return object;}}catch(e){}
return null;},write:function(value,pretty){this.pretty=!!pretty;var json=null;var type=typeof value;if(this.serialize[type]){try{json=this.serialize[type].apply(this,[value]);}catch(err){OpenLayers.Console.error("Trouble serializing: "+err);}}
return json;},writeIndent:function(){var pieces=[];if(this.pretty){for(var i=0;i<this.level;++i){pieces.push(this.indent);}}
return pieces.join('');},writeNewline:function(){return(this.pretty)?this.newline:'';},writeSpace:function(){return(this.pretty)?this.space:'';},serialize:{'object':function(object){if(object==null){return"null";}
if(object.constructor==Date){return this.serialize.date.apply(this,[object]);}
if(object.constructor==Array){return this.serialize.array.apply(this,[object]);}
var pieces=['{'];this.level+=1;var key,keyJSON,valueJSON;var addComma=false;for(key in object){if(object.hasOwnProperty(key)){keyJSON=OpenLayers.Format.JSON.prototype.write.apply(this,[key,this.pretty]);valueJSON=OpenLayers.Format.JSON.prototype.write.apply(this,[object[key],this.pretty]);if(keyJSON!=null&&valueJSON!=null){if(addComma){pieces.push(',');}
pieces.push(this.writeNewline(),this.writeIndent(),keyJSON,':',this.writeSpace(),valueJSON);addComma=true;}}}
this.level-=1;pieces.push(this.writeNewline(),this.writeIndent(),'}');return pieces.join('');},'array':function(array){var json;var pieces=['['];this.level+=1;for(var i=0,len=array.length;i<len;++i){json=OpenLayers.Format.JSON.prototype.write.apply(this,[array[i],this.pretty]);if(json!=null){if(i>0){pieces.push(',');}
pieces.push(this.writeNewline(),this.writeIndent(),json);}}
this.level-=1;pieces.push(this.writeNewline(),this.writeIndent(),']');return pieces.join('');},'string':function(string){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};if(/["\\\x00-\x1f]/.test(string)){return'"'+string.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
c=b.charCodeAt();return'\\u00'+
Math.floor(c/16).toString(16)+
(c%16).toString(16);})+'"';}
return'"'+string+'"';},'number':function(number){return isFinite(number)?String(number):"null";},'boolean':function(bool){return String(bool);},'date':function(date){function format(number){return(number<10)?'0'+number:number;}
return'"'+date.getFullYear()+'-'+
format(date.getMonth()+1)+'-'+
format(date.getDate())+'T'+
format(date.getHours())+':'+
format(date.getMinutes())+':'+
format(date.getSeconds())+'"';}},CLASS_NAME:"OpenLayers.Format.JSON"});OpenLayers.Format.WFST=function(options){options=OpenLayers.Util.applyDefaults(options,OpenLayers.Format.WFST.DEFAULTS);var cls=OpenLayers.Format.WFST["v"+options.version.replace(/\./g,"_")];if(!cls){throw"Unsupported WFST version: "+options.version;}
return new cls(options);};OpenLayers.Format.WFST.DEFAULTS={"version":"1.0.0"};OpenLayers.Format.WMSCapabilities=OpenLayers.Class(OpenLayers.Format.XML,{defaultVersion:"1.1.1",version:null,parser:null,initialize:function(options){OpenLayers.Format.prototype.initialize.apply(this,[options]);this.options=options;},read:function(data){if(typeof data=="string"){data=OpenLayers.Format.XML.prototype.read.apply(this,[data]);}
var root=data.documentElement;var version=this.version||root.getAttribute("version")||this.defaultVersion;if(!this.parser||this.parser.version!==version){var constr=OpenLayers.Format.WMSCapabilities["v"+version.replace(/\./g,"_")];if(!constr){throw"Can't find a WMS capabilities parser for version "+version;}
var parser=new constr(this.options);}
var capabilities=parser.read(data);capabilities.version=version;return capabilities;},CLASS_NAME:"OpenLayers.Format.WMSCapabilities"});OpenLayers.Format.XML=OpenLayers.Class(OpenLayers.Format,{namespaces:null,namespaceAlias:null,defaultPrefix:null,readers:{},writers:{},xmldom:null,initialize:function(options){if(window.ActiveXObject){this.xmldom=new ActiveXObject("Microsoft.XMLDOM");}
OpenLayers.Format.prototype.initialize.apply(this,[options]);this.namespaces=OpenLayers.Util.extend({},this.namespaces);this.namespaceAlias={};for(var alias in this.namespaces){this.namespaceAlias[this.namespaces[alias]]=alias;}},destroy:function(){this.xmldom=null;OpenLayers.Format.prototype.destroy.apply(this,arguments);},setNamespace:function(alias,uri){this.namespaces[alias]=uri;this.namespaceAlias[uri]=alias;},read:function(text){var index=text.indexOf('<');if(index>0){text=text.substring(index);}
var node=OpenLayers.Util.Try(OpenLayers.Function.bind((function(){var xmldom;if(window.ActiveXObject&&!this.xmldom){xmldom=new ActiveXObject("Microsoft.XMLDOM");}else{xmldom=this.xmldom;}
xmldom.loadXML(text);return xmldom;}),this),function(){return new DOMParser().parseFromString(text,'text/xml');},function(){var req=new XMLHttpRequest();req.open("GET","data:"+"text/xml"+";charset=utf-8,"+encodeURIComponent(text),false);if(req.overrideMimeType){req.overrideMimeType("text/xml");}
req.send(null);return req.responseXML;});if(this.keepData){this.data=node;}
return node;},write:function(node){var data;if(this.xmldom){data=node.xml;}else{var serializer=new XMLSerializer();if(node.nodeType==1){var doc=document.implementation.createDocument("","",null);if(doc.importNode){node=doc.importNode(node,true);}
doc.appendChild(node);data=serializer.serializeToString(doc);}else{data=serializer.serializeToString(node);}}
return data;},createElementNS:function(uri,name){var element;if(this.xmldom){if(typeof uri=="string"){element=this.xmldom.createNode(1,name,uri);}else{element=this.xmldom.createNode(1,name,"");}}else{element=document.createElementNS(uri,name);}
return element;},createTextNode:function(text){var node;if(this.xmldom){node=this.xmldom.createTextNode(text);}else{node=document.createTextNode(text);}
return node;},getElementsByTagNameNS:function(node,uri,name){var elements=[];if(node.getElementsByTagNameNS){elements=node.getElementsByTagNameNS(uri,name);}else{var allNodes=node.getElementsByTagName("*");var potentialNode,fullName;for(var i=0,len=allNodes.length;i<len;++i){potentialNode=allNodes[i];fullName=(potentialNode.prefix)?(potentialNode.prefix+":"+name):name;if((name=="*")||(fullName==potentialNode.nodeName)){if((uri=="*")||(uri==potentialNode.namespaceURI)){elements.push(potentialNode);}}}}
return elements;},getAttributeNodeNS:function(node,uri,name){var attributeNode=null;if(node.getAttributeNodeNS){attributeNode=node.getAttributeNodeNS(uri,name);}else{var attributes=node.attributes;var potentialNode,fullName;for(var i=0,len=attributes.length;i<len;++i){potentialNode=attributes[i];if(potentialNode.namespaceURI==uri){fullName=(potentialNode.prefix)?(potentialNode.prefix+":"+name):name;if(fullName==potentialNode.nodeName){attributeNode=potentialNode;break;}}}}
return attributeNode;},getAttributeNS:function(node,uri,name){var attributeValue="";if(node.getAttributeNS){attributeValue=node.getAttributeNS(uri,name)||"";}else{var attributeNode=this.getAttributeNodeNS(node,uri,name);if(attributeNode){attributeValue=attributeNode.nodeValue;}}
return attributeValue;},getChildValue:function(node,def){var value=def||"";if(node){for(var child=node.firstChild;child;child=child.nextSibling){switch(child.nodeType){case 3:case 4:value+=child.nodeValue;}}}
return value;},concatChildValues:function(node,def){var value="";var child=node.firstChild;var childValue;while(child){childValue=child.nodeValue;if(childValue){value+=childValue;}
child=child.nextSibling;}
if(value==""&&def!=undefined){value=def;}
return value;},isSimpleContent:function(node){var simple=true;for(var child=node.firstChild;child;child=child.nextSibling){if(child.nodeType===1){simple=false;break;}}
return simple;},contentType:function(node){var simple=false,complex=false;var type=OpenLayers.Format.XML.CONTENT_TYPE.EMPTY;for(var child=node.firstChild;child;child=child.nextSibling){switch(child.nodeType){case 1:complex=true;break;case 8:break;default:simple=true;}
if(complex&&simple){break;}}
if(complex&&simple){type=OpenLayers.Format.XML.CONTENT_TYPE.MIXED;}else if(complex){return OpenLayers.Format.XML.CONTENT_TYPE.COMPLEX;}else if(simple){return OpenLayers.Format.XML.CONTENT_TYPE.SIMPLE;}
return type;},hasAttributeNS:function(node,uri,name){var found=false;if(node.hasAttributeNS){found=node.hasAttributeNS(uri,name);}else{found=!!this.getAttributeNodeNS(node,uri,name);}
return found;},setAttributeNS:function(node,uri,name,value){if(node.setAttributeNS){node.setAttributeNS(uri,name,value);}else{if(this.xmldom){if(uri){var attribute=node.ownerDocument.createNode(2,name,uri);attribute.nodeValue=value;node.setAttributeNode(attribute);}else{node.setAttribute(name,value);}}else{throw"setAttributeNS not implemented";}}},createElementNSPlus:function(name,options){options=options||{};var uri=options.uri||this.namespaces[options.prefix];if(!uri){var loc=name.indexOf(":");uri=this.namespaces[name.substring(0,loc)];}
if(!uri){uri=this.namespaces[this.defaultPrefix];}
var node=this.createElementNS(uri,name);if(options.attributes){this.setAttributes(node,options.attributes);}
var value=options.value;if(value!=null){if(typeof value=="boolean"){value=String(value);}
node.appendChild(this.createTextNode(value));}
return node;},setAttributes:function(node,obj){var value,uri;for(var name in obj){if(obj[name]!=null&&obj[name].toString){value=obj[name].toString();uri=this.namespaces[name.substring(0,name.indexOf(":"))]||null;this.setAttributeNS(node,uri,name,value);}}},readNode:function(node,obj){if(!obj){obj={};}
var group=this.readers[this.namespaceAlias[node.namespaceURI]];if(group){var local=node.localName||node.nodeName.split(":").pop();var reader=group[local]||group["*"];if(reader){reader.apply(this,[node,obj]);}}
return obj;},readChildNodes:function(node,obj){if(!obj){obj={};}
var children=node.childNodes;var child;for(var i=0,len=children.length;i<len;++i){child=children[i];if(child.nodeType==1){this.readNode(child,obj);}}
return obj;},writeNode:function(name,obj,parent){var prefix,local;var split=name.indexOf(":");if(split>0){prefix=name.substring(0,split);local=name.substring(split+1);}else{if(parent){prefix=this.namespaceAlias[parent.namespaceURI];}else{prefix=this.defaultPrefix;}
local=name;}
var child=this.writers[prefix][local].apply(this,[obj]);if(parent){parent.appendChild(child);}
return child;},getChildEl:function(node,name,uri){return node&&this.getThisOrNextEl(node.firstChild,name,uri);},getNextEl:function(node,name,uri){return node&&this.getThisOrNextEl(node.nextSibling,name,uri);},getThisOrNextEl:function(node,name,uri){outer:for(var sibling=node;sibling;sibling=sibling.nextSibling){switch(sibling.nodeType){case 1:if((!name||name===(sibling.localName||sibling.nodeName.split(":").pop()))&&(!uri||uri===sibling.namespaceURI)){break outer;}
sibling=null;break outer;case 3:if(/^\s*$/.test(sibling.nodeValue)){break;}
case 4:case 6:case 12:case 10:case 11:sibling=null;break outer;}}
return sibling||null;},lookupNamespaceURI:function(node,prefix){var uri=null;if(node){if(node.lookupNamespaceURI){uri=node.lookupNamespaceURI(prefix);}else{outer:switch(node.nodeType){case 1:if(node.namespaceURI!==null&&node.prefix===prefix){uri=node.namespaceURI;break outer;}
var len=node.attributes.length;if(len){var attr;for(var i=0;i<len;++i){attr=node.attributes[i];if(attr.prefix==="xmlns"&&attr.name==="xmlns:"+prefix){uri=attr.value||null;break outer;}else if(attr.name==="xmlns"&&prefix===null){uri=attr.value||null;break outer;}}}
uri=this.lookupNamespaceURI(node.parentNode,prefix);break outer;case 2:uri=this.lookupNamespaceURI(node.ownerElement,prefix);break outer;case 9:uri=this.lookupNamespaceURI(node.documentElement,prefix);break outer;case 6:case 12:case 10:case 11:break outer;default:uri=this.lookupNamespaceURI(node.parentNode,prefix);break outer;}}}
return uri;},CLASS_NAME:"OpenLayers.Format.XML"});OpenLayers.Format.XML.CONTENT_TYPE={EMPTY:0,SIMPLE:1,COMPLEX:2,MIXED:3};OpenLayers.Format.XML.lookupNamespaceURI=OpenLayers.Function.bind(OpenLayers.Format.XML.prototype.lookupNamespaceURI,OpenLayers.Format.XML.prototype);OpenLayers.Handler=OpenLayers.Class({id:null,control:null,map:null,keyMask:null,active:false,evt:null,initialize:function(control,callbacks,options){OpenLayers.Util.extend(this,options);this.control=control;this.callbacks=callbacks;if(control.map){this.setMap(control.map);}
OpenLayers.Util.extend(this,options);this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");},setMap:function(map){this.map=map;},checkModifiers:function(evt){if(this.keyMask==null){return true;}
var keyModifiers=(evt.shiftKey?OpenLayers.Handler.MOD_SHIFT:0)|(evt.ctrlKey?OpenLayers.Handler.MOD_CTRL:0)|(evt.altKey?OpenLayers.Handler.MOD_ALT:0);return(keyModifiers==this.keyMask);},activate:function(){if(this.active){return false;}
var events=OpenLayers.Events.prototype.BROWSER_EVENTS;for(var i=0,len=events.length;i<len;i++){if(this[events[i]]){this.register(events[i],this[events[i]]);}}
this.active=true;return true;},deactivate:function(){if(!this.active){return false;}
var events=OpenLayers.Events.prototype.BROWSER_EVENTS;for(var i=0,len=events.length;i<len;i++){if(this[events[i]]){this.unregister(events[i],this[events[i]]);}}
this.active=false;return true;},callback:function(name,args){if(name&&this.callbacks[name]){this.callbacks[name].apply(this.control,args);}},register:function(name,method){this.map.events.registerPriority(name,this,method);this.map.events.registerPriority(name,this,this.setEvent);},unregister:function(name,method){this.map.events.unregister(name,this,method);this.map.events.unregister(name,this,this.setEvent);},setEvent:function(evt){this.evt=evt;return true;},destroy:function(){this.deactivate();this.control=this.map=null;},CLASS_NAME:"OpenLayers.Handler"});OpenLayers.Handler.MOD_NONE=0;OpenLayers.Handler.MOD_SHIFT=1;OpenLayers.Handler.MOD_CTRL=2;OpenLayers.Handler.MOD_ALT=4;OpenLayers.Map=OpenLayers.Class({Z_INDEX_BASE:{BaseLayer:100,Overlay:325,Feature:725,Popup:750,Control:1000},EVENT_TYPES:["preaddlayer","addlayer","removelayer","changelayer","movestart","move","moveend","zoomend","popupopen","popupclose","addmarker","removemarker","clearmarkers","mouseover","mouseout","mousemove","dragstart","drag","dragend","changebaselayer"],id:null,fractionalZoom:false,events:null,allOverlays:false,div:null,dragging:false,size:null,viewPortDiv:null,layerContainerOrigin:null,layerContainerDiv:null,layers:null,controls:null,popups:null,baseLayer:null,center:null,resolution:null,zoom:0,panRatio:1.5,viewRequestID:0,tileSize:null,projection:"EPSG:4326",units:'degrees',resolutions:null,maxResolution:1.40625,minResolution:null,maxScale:null,minScale:null,maxExtent:null,minExtent:null,restrictedExtent:null,numZoomLevels:16,theme:null,displayProjection:null,fallThrough:true,panTween:null,eventListeners:null,panMethod:OpenLayers.Easing.Expo.easeOut,panDuration:50,paddingForPopups:null,initialize:function(div,options){if(arguments.length===1&&typeof div==="object"){options=div;div=options&&options.div;}
this.tileSize=new OpenLayers.Size(OpenLayers.Map.TILE_WIDTH,OpenLayers.Map.TILE_HEIGHT);this.maxExtent=new OpenLayers.Bounds(-180,-90,180,90);this.paddingForPopups=new OpenLayers.Bounds(15,15,15,15);this.theme=OpenLayers._getScriptLocation()+'theme/default/style.css';OpenLayers.Util.extend(this,options);this.id=OpenLayers.Util.createUniqueID("OpenLayers.Map_");this.div=OpenLayers.Util.getElement(div);if(!this.div){this.div=document.createElement("div");this.div.style.height="1px";this.div.style.width="1px";}
OpenLayers.Element.addClass(this.div,'olMap');var id=this.div.id+"_OpenLayers_ViewPort";this.viewPortDiv=OpenLayers.Util.createDiv(id,null,null,null,"relative",null,"hidden");this.viewPortDiv.style.width="100%";this.viewPortDiv.style.height="100%";this.viewPortDiv.className="olMapViewport";this.div.appendChild(this.viewPortDiv);id=this.div.id+"_OpenLayers_Container";this.layerContainerDiv=OpenLayers.Util.createDiv(id);this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1;this.viewPortDiv.appendChild(this.layerContainerDiv);this.events=new OpenLayers.Events(this,this.div,this.EVENT_TYPES,this.fallThrough,{includeXY:true});this.updateSize();if(this.eventListeners instanceof Object){this.events.on(this.eventListeners);}
this.events.register("movestart",this,this.updateSize);if(OpenLayers.String.contains(navigator.appName,"Microsoft")){this.events.register("resize",this,this.updateSize);}else{this.updateSizeDestroy=OpenLayers.Function.bind(this.updateSize,this);OpenLayers.Event.observe(window,'resize',this.updateSizeDestroy);}
if(this.theme){var addNode=true;var nodes=document.getElementsByTagName('link');for(var i=0,len=nodes.length;i<len;++i){if(OpenLayers.Util.isEquivalentUrl(nodes.item(i).href,this.theme)){addNode=false;break;}}
if(addNode){var cssNode=document.createElement('link');cssNode.setAttribute('rel','stylesheet');cssNode.setAttribute('type','text/css');cssNode.setAttribute('href',this.theme);document.getElementsByTagName('head')[0].appendChild(cssNode);}}
this.layers=[];if(this.controls==null){if(OpenLayers.Control!=null){this.controls=[new OpenLayers.Control.Navigation(),new OpenLayers.Control.PanZoom(),new OpenLayers.Control.ArgParser(),new OpenLayers.Control.Attribution()];}else{this.controls=[];}}
for(var i=0,len=this.controls.length;i<len;i++){this.addControlToMap(this.controls[i]);}
this.popups=[];this.unloadDestroy=OpenLayers.Function.bind(this.destroy,this);OpenLayers.Event.observe(window,'unload',this.unloadDestroy);},render:function(div){this.div=OpenLayers.Util.getElement(div);OpenLayers.Element.addClass(this.div,'olMap');this.events.attachToElement(this.div);this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);this.div.appendChild(this.viewPortDiv);this.updateSize();},unloadDestroy:null,updateSizeDestroy:null,destroy:function(){if(!this.unloadDestroy){return false;}
OpenLayers.Event.stopObserving(window,'unload',this.unloadDestroy);this.unloadDestroy=null;if(this.updateSizeDestroy){OpenLayers.Event.stopObserving(window,'resize',this.updateSizeDestroy);}else{this.events.unregister("resize",this,this.updateSize);}
this.paddingForPopups=null;if(this.controls!=null){for(var i=this.controls.length-1;i>=0;--i){this.controls[i].destroy();}
this.controls=null;}
if(this.layers!=null){for(var i=this.layers.length-1;i>=0;--i){this.layers[i].destroy(false);}
this.layers=null;}
if(this.viewPortDiv){this.div.removeChild(this.viewPortDiv);}
this.viewPortDiv=null;if(this.eventListeners){this.events.un(this.eventListeners);this.eventListeners=null;}
this.events.destroy();this.events=null;},setOptions:function(options){OpenLayers.Util.extend(this,options);},getTileSize:function(){return this.tileSize;},getBy:function(array,property,match){var test=(typeof match.test=="function");var found=OpenLayers.Array.filter(this[array],function(item){return item[property]==match||(test&&match.test(item[property]));});return found;},getLayersBy:function(property,match){return this.getBy("layers",property,match);},getLayersByName:function(match){return this.getLayersBy("name",match);},getLayersByClass:function(match){return this.getLayersBy("CLASS_NAME",match);},getControlsBy:function(property,match){return this.getBy("controls",property,match);},getControlsByClass:function(match){return this.getControlsBy("CLASS_NAME",match);},getLayer:function(id){var foundLayer=null;for(var i=0,len=this.layers.length;i<len;i++){var layer=this.layers[i];if(layer.id==id){foundLayer=layer;break;}}
return foundLayer;},setLayerZIndex:function(layer,zIdx){layer.setZIndex(this.Z_INDEX_BASE[layer.isBaseLayer?'BaseLayer':'Overlay']
+zIdx*5);},resetLayersZIndex:function(){for(var i=0,len=this.layers.length;i<len;i++){var layer=this.layers[i];this.setLayerZIndex(layer,i);}},addLayer:function(layer){for(var i=0,len=this.layers.length;i<len;i++){if(this.layers[i]==layer){var msg=OpenLayers.i18n('layerAlreadyAdded',{'layerName':layer.name});OpenLayers.Console.warn(msg);return false;}}
if(this.allOverlays){layer.isBaseLayer=false;}
this.events.triggerEvent("preaddlayer",{layer:layer});layer.div.className="olLayerDiv";layer.div.style.overflow="";this.setLayerZIndex(layer,this.layers.length);if(layer.isFixed){this.viewPortDiv.appendChild(layer.div);}else{this.layerContainerDiv.appendChild(layer.div);}
this.layers.push(layer);layer.setMap(this);if(layer.isBaseLayer||(this.allOverlays&&!this.baseLayer)){if(this.baseLayer==null){this.setBaseLayer(layer);}else{layer.setVisibility(false);}}else{layer.redraw();}
this.events.triggerEvent("addlayer",{layer:layer});layer.afterAdd();},addLayers:function(layers){for(var i=0,len=layers.length;i<len;i++){this.addLayer(layers[i]);}},removeLayer:function(layer,setNewBaseLayer){if(setNewBaseLayer==null){setNewBaseLayer=true;}
if(layer.isFixed){this.viewPortDiv.removeChild(layer.div);}else{this.layerContainerDiv.removeChild(layer.div);}
OpenLayers.Util.removeItem(this.layers,layer);layer.removeMap(this);layer.map=null;if(this.baseLayer==layer){this.baseLayer=null;if(setNewBaseLayer){for(var i=0,len=this.layers.length;i<len;i++){var iLayer=this.layers[i];if(iLayer.isBaseLayer||this.allOverlays){this.setBaseLayer(iLayer);break;}}}}
this.resetLayersZIndex();this.events.triggerEvent("removelayer",{layer:layer});},getNumLayers:function(){return this.layers.length;},getLayerIndex:function(layer){return OpenLayers.Util.indexOf(this.layers,layer);},setLayerIndex:function(layer,idx){var base=this.getLayerIndex(layer);if(idx<0){idx=0;}else if(idx>this.layers.length){idx=this.layers.length;}
if(base!=idx){this.layers.splice(base,1);this.layers.splice(idx,0,layer);for(var i=0,len=this.layers.length;i<len;i++){this.setLayerZIndex(this.layers[i],i);}
this.events.triggerEvent("changelayer",{layer:layer,property:"order"});if(this.allOverlays){if(idx===0){this.setBaseLayer(layer);}else if(this.baseLayer!==this.layers[0]){this.setBaseLayer(this.layers[0]);}}}},raiseLayer:function(layer,delta){var idx=this.getLayerIndex(layer)+delta;this.setLayerIndex(layer,idx);},setBaseLayer:function(newBaseLayer){var oldExtent=null;if(this.baseLayer){oldExtent=this.baseLayer.getExtent();}
if(newBaseLayer!=this.baseLayer){if(OpenLayers.Util.indexOf(this.layers,newBaseLayer)!=-1){if(this.baseLayer!=null&&!this.allOverlays){this.baseLayer.setVisibility(false);}
this.baseLayer=newBaseLayer;this.viewRequestID++;if(!this.allOverlays){this.baseLayer.visibility=true;}
var center=this.getCenter();if(center!=null){var newCenter=(oldExtent)?oldExtent.getCenterLonLat():center;var newZoom=(oldExtent)?this.getZoomForExtent(oldExtent,true):this.getZoomForResolution(this.resolution,true);this.setCenter(newCenter,newZoom,false,true);}
this.events.triggerEvent("changebaselayer",{layer:this.baseLayer});}}},addControl:function(control,px){this.controls.push(control);this.addControlToMap(control,px);},addControlToMap:function(control,px){control.outsideViewport=(control.div!=null);if(this.displayProjection&&!control.displayProjection){control.displayProjection=this.displayProjection;}
control.setMap(this);var div=control.draw(px);if(div){if(!control.outsideViewport){div.style.zIndex=this.Z_INDEX_BASE['Control']+
this.controls.length;this.viewPortDiv.appendChild(div);}}},getControl:function(id){var returnControl=null;for(var i=0,len=this.controls.length;i<len;i++){var control=this.controls[i];if(control.id==id){returnControl=control;break;}}
return returnControl;},removeControl:function(control){if((control)&&(control==this.getControl(control.id))){if(control.div&&(control.div.parentNode==this.viewPortDiv)){this.viewPortDiv.removeChild(control.div);}
OpenLayers.Util.removeItem(this.controls,control);}},addPopup:function(popup,exclusive){if(exclusive){for(var i=this.popups.length-1;i>=0;--i){this.removePopup(this.popups[i]);}}
popup.map=this;this.popups.push(popup);var popupDiv=popup.draw();if(popupDiv){popupDiv.style.zIndex=this.Z_INDEX_BASE['Popup']+
this.popups.length;this.layerContainerDiv.appendChild(popupDiv);}},removePopup:function(popup){OpenLayers.Util.removeItem(this.popups,popup);if(popup.div){try{this.layerContainerDiv.removeChild(popup.div);}
catch(e){}}
popup.map=null;},getSize:function(){var size=null;if(this.size!=null){size=this.size.clone();}
return size;},updateSize:function(){this.events.clearMouseCache();var newSize=this.getCurrentSize();var oldSize=this.getSize();if(oldSize==null){this.size=oldSize=newSize;}
if(!newSize.equals(oldSize)){this.size=newSize;for(var i=0,len=this.layers.length;i<len;i++){this.layers[i].onMapResize();}
if(this.baseLayer!=null){var center=new OpenLayers.Pixel(newSize.w/2,newSize.h/2);var centerLL=this.getLonLatFromViewPortPx(center);var zoom=this.getZoom();this.zoom=null;this.setCenter(this.getCenter(),zoom);}}},getCurrentSize:function(){var size=new OpenLayers.Size(this.div.clientWidth,this.div.clientHeight);if(size.w==0&&size.h==0||isNaN(size.w)&&isNaN(size.h)){var dim=OpenLayers.Element.getDimensions(this.div);size.w=dim.width;size.h=dim.height;}
if(size.w==0&&size.h==0||isNaN(size.w)&&isNaN(size.h)){size.w=parseInt(this.div.style.width);size.h=parseInt(this.div.style.height);}
return size;},calculateBounds:function(center,resolution){var extent=null;if(center==null){center=this.getCenter();}
if(resolution==null){resolution=this.getResolution();}
if((center!=null)&&(resolution!=null)){var size=this.getSize();var w_deg=size.w*resolution;var h_deg=size.h*resolution;extent=new OpenLayers.Bounds(center.lon-w_deg/2,center.lat-h_deg/2,center.lon+w_deg/2,center.lat+h_deg/2);}
return extent;},getCenter:function(){var center=null;if(this.center){center=this.center.clone();}
return center;},getZoom:function(){return this.zoom;},pan:function(dx,dy,options){options=OpenLayers.Util.applyDefaults(options,{animate:true,dragging:false});var centerPx=this.getViewPortPxFromLonLat(this.getCenter());var newCenterPx=centerPx.add(dx,dy);if(!options.dragging||!newCenterPx.equals(centerPx)){var newCenterLonLat=this.getLonLatFromViewPortPx(newCenterPx);if(options.animate){this.panTo(newCenterLonLat);}else{this.setCenter(newCenterLonLat,null,options.dragging);}}},panTo:function(lonlat){if(this.panMethod&&this.getExtent().scale(this.panRatio).containsLonLat(lonlat)){if(!this.panTween){this.panTween=new OpenLayers.Tween(this.panMethod);}
var center=this.getCenter();if(lonlat.lon==center.lon&&lonlat.lat==center.lat){return;}
var from={lon:center.lon,lat:center.lat};var to={lon:lonlat.lon,lat:lonlat.lat};this.panTween.start(from,to,this.panDuration,{callbacks:{start:OpenLayers.Function.bind(function(lonlat){this.events.triggerEvent("movestart");},this),eachStep:OpenLayers.Function.bind(function(lonlat){lonlat=new OpenLayers.LonLat(lonlat.lon,lonlat.lat);this.moveTo(lonlat,this.zoom,{'dragging':true,'noEvent':true});},this),done:OpenLayers.Function.bind(function(lonlat){lonlat=new OpenLayers.LonLat(lonlat.lon,lonlat.lat);this.moveTo(lonlat,this.zoom,{'noEvent':true});this.events.triggerEvent("moveend");},this)}});}else{this.setCenter(lonlat);}},setCenter:function(lonlat,zoom,dragging,forceZoomChange){this.moveTo(lonlat,zoom,{'dragging':dragging,'forceZoomChange':forceZoomChange,'caller':'setCenter'});},moveTo:function(lonlat,zoom,options){if(!options){options={};}
var dragging=options.dragging;var forceZoomChange=options.forceZoomChange;var noEvent=options.noEvent;if(this.panTween&&options.caller=="setCenter"){this.panTween.stop();}
if(!this.center&&!this.isValidLonLat(lonlat)){lonlat=this.maxExtent.getCenterLonLat();}
if(this.restrictedExtent!=null){if(lonlat==null){lonlat=this.getCenter();}
if(zoom==null){zoom=this.getZoom();}
var resolution=this.getResolutionForZoom(zoom);var extent=this.calculateBounds(lonlat,resolution);if(!this.restrictedExtent.containsBounds(extent)){var maxCenter=this.restrictedExtent.getCenterLonLat();if(extent.getWidth()>this.restrictedExtent.getWidth()){lonlat=new OpenLayers.LonLat(maxCenter.lon,lonlat.lat);}else if(extent.left<this.restrictedExtent.left){lonlat=lonlat.add(this.restrictedExtent.left-
extent.left,0);}else if(extent.right>this.restrictedExtent.right){lonlat=lonlat.add(this.restrictedExtent.right-
extent.right,0);}
if(extent.getHeight()>this.restrictedExtent.getHeight()){lonlat=new OpenLayers.LonLat(lonlat.lon,maxCenter.lat);}else if(extent.bottom<this.restrictedExtent.bottom){lonlat=lonlat.add(0,this.restrictedExtent.bottom-
extent.bottom);}
else if(extent.top>this.restrictedExtent.top){lonlat=lonlat.add(0,this.restrictedExtent.top-
extent.top);}}}
var zoomChanged=forceZoomChange||((this.isValidZoomLevel(zoom))&&(zoom!=this.getZoom()));var centerChanged=(this.isValidLonLat(lonlat))&&(!lonlat.equals(this.center));if(zoomChanged||centerChanged||!dragging){if(!this.dragging&&!noEvent){this.events.triggerEvent("movestart");}
if(centerChanged){if((!zoomChanged)&&(this.center)){this.centerLayerContainer(lonlat);}
this.center=lonlat.clone();}
if((zoomChanged)||(this.layerContainerOrigin==null)){this.layerContainerOrigin=this.center.clone();this.layerContainerDiv.style.left="0px";this.layerContainerDiv.style.top="0px";}
if(zoomChanged){this.zoom=zoom;this.resolution=this.getResolutionForZoom(zoom);this.viewRequestID++;}
var bounds=this.getExtent();if(this.baseLayer.visibility){this.baseLayer.moveTo(bounds,zoomChanged,dragging);if(dragging){this.baseLayer.events.triggerEvent("move");}else{this.baseLayer.events.triggerEvent("moveend",{"zoomChanged":zoomChanged});}}
bounds=this.baseLayer.getExtent();for(var i=0,len=this.layers.length;i<len;i++){var layer=this.layers[i];if(layer!==this.baseLayer&&!layer.isBaseLayer){var inRange=layer.calculateInRange();if(layer.inRange!=inRange){layer.inRange=inRange;if(!inRange){layer.display(false);}
this.events.triggerEvent("changelayer",{layer:layer,property:"visibility"});}
if(inRange&&layer.visibility){layer.moveTo(bounds,zoomChanged,dragging);if(dragging){layer.events.triggerEvent("move");}else{layer.events.triggerEvent("moveend",{"zoomChanged":zoomChanged});}}}}
if(zoomChanged){for(var i=0,len=this.popups.length;i<len;i++){this.popups[i].updatePosition();}}
this.events.triggerEvent("move");if(zoomChanged){this.events.triggerEvent("zoomend");}}
if(!dragging&&!noEvent){this.events.triggerEvent("moveend");}
this.dragging=!!dragging;},centerLayerContainer:function(lonlat){var originPx=this.getViewPortPxFromLonLat(this.layerContainerOrigin);var newPx=this.getViewPortPxFromLonLat(lonlat);if((originPx!=null)&&(newPx!=null)){this.layerContainerDiv.style.left=Math.round(originPx.x-newPx.x)+"px";this.layerContainerDiv.style.top=Math.round(originPx.y-newPx.y)+"px";}},isValidZoomLevel:function(zoomLevel){return((zoomLevel!=null)&&(zoomLevel>=0)&&(zoomLevel<this.getNumZoomLevels()));},isValidLonLat:function(lonlat){var valid=false;if(lonlat!=null){var maxExtent=this.getMaxExtent();valid=maxExtent.containsLonLat(lonlat);}
return valid;},getProjection:function(){var projection=this.getProjectionObject();return projection?projection.getCode():null;},getProjectionObject:function(){var projection=null;if(this.baseLayer!=null){projection=this.baseLayer.projection;}
return projection;},getMaxResolution:function(){var maxResolution=null;if(this.baseLayer!=null){maxResolution=this.baseLayer.maxResolution;}
return maxResolution;},getMaxExtent:function(options){var maxExtent=null;if(options&&options.restricted&&this.restrictedExtent){maxExtent=this.restrictedExtent;}else if(this.baseLayer!=null){maxExtent=this.baseLayer.maxExtent;}
return maxExtent;},getNumZoomLevels:function(){var numZoomLevels=null;if(this.baseLayer!=null){numZoomLevels=this.baseLayer.numZoomLevels;}
return numZoomLevels;},getExtent:function(){var extent=null;if(this.baseLayer!=null){extent=this.baseLayer.getExtent();}
return extent;},getResolution:function(){var resolution=null;if(this.baseLayer!=null){resolution=this.baseLayer.getResolution();}
return resolution;},getUnits:function(){var units=null;if(this.baseLayer!=null){units=this.baseLayer.units;}
return units;},getScale:function(){var scale=null;if(this.baseLayer!=null){var res=this.getResolution();var units=this.baseLayer.units;scale=OpenLayers.Util.getScaleFromResolution(res,units);}
return scale;},getZoomForExtent:function(bounds,closest){var zoom=null;if(this.baseLayer!=null){zoom=this.baseLayer.getZoomForExtent(bounds,closest);}
return zoom;},getResolutionForZoom:function(zoom){var resolution=null;if(this.baseLayer){resolution=this.baseLayer.getResolutionForZoom(zoom);}
return resolution;},getZoomForResolution:function(resolution,closest){var zoom=null;if(this.baseLayer!=null){zoom=this.baseLayer.getZoomForResolution(resolution,closest);}
return zoom;},zoomTo:function(zoom){if(this.isValidZoomLevel(zoom)){this.setCenter(null,zoom);}},zoomIn:function(){this.zoomTo(this.getZoom()+1);},zoomOut:function(){this.zoomTo(this.getZoom()-1);},zoomToExtent:function(bounds,closest){var center=bounds.getCenterLonLat();if(this.baseLayer.wrapDateLine){var maxExtent=this.getMaxExtent();bounds=bounds.clone();while(bounds.right<bounds.left){bounds.right+=maxExtent.getWidth();}
center=bounds.getCenterLonLat().wrapDateLine(maxExtent);}
this.setCenter(center,this.getZoomForExtent(bounds,closest));},zoomToMaxExtent:function(options){var restricted=(options)?options.restricted:true;var maxExtent=this.getMaxExtent({'restricted':restricted});this.zoomToExtent(maxExtent);},zoomToScale:function(scale,closest){var res=OpenLayers.Util.getResolutionFromScale(scale,this.baseLayer.units);var size=this.getSize();var w_deg=size.w*res;var h_deg=size.h*res;var center=this.getCenter();var extent=new OpenLayers.Bounds(center.lon-w_deg/2,center.lat-h_deg/2,center.lon+w_deg/2,center.lat+h_deg/2);this.zoomToExtent(extent,closest);},getLonLatFromViewPortPx:function(viewPortPx){var lonlat=null;if(this.baseLayer!=null){lonlat=this.baseLayer.getLonLatFromViewPortPx(viewPortPx);}
return lonlat;},getViewPortPxFromLonLat:function(lonlat){var px=null;if(this.baseLayer!=null){px=this.baseLayer.getViewPortPxFromLonLat(lonlat);}
return px;},getLonLatFromPixel:function(px){return this.getLonLatFromViewPortPx(px);},getPixelFromLonLat:function(lonlat){var px=this.getViewPortPxFromLonLat(lonlat);px.x=Math.round(px.x);px.y=Math.round(px.y);return px;},getViewPortPxFromLayerPx:function(layerPx){var viewPortPx=null;if(layerPx!=null){var dX=parseInt(this.layerContainerDiv.style.left);var dY=parseInt(this.layerContainerDiv.style.top);viewPortPx=layerPx.add(dX,dY);}
return viewPortPx;},getLayerPxFromViewPortPx:function(viewPortPx){var layerPx=null;if(viewPortPx!=null){var dX=-parseInt(this.layerContainerDiv.style.left);var dY=-parseInt(this.layerContainerDiv.style.top);layerPx=viewPortPx.add(dX,dY);if(isNaN(layerPx.x)||isNaN(layerPx.y)){layerPx=null;}}
return layerPx;},getLonLatFromLayerPx:function(px){px=this.getViewPortPxFromLayerPx(px);return this.getLonLatFromViewPortPx(px);},getLayerPxFromLonLat:function(lonlat){var px=this.getPixelFromLonLat(lonlat);return this.getLayerPxFromViewPortPx(px);},CLASS_NAME:"OpenLayers.Map"});OpenLayers.Map.TILE_WIDTH=256;OpenLayers.Map.TILE_HEIGHT=256;OpenLayers.Marker=OpenLayers.Class({icon:null,lonlat:null,events:null,map:null,initialize:function(lonlat,icon){this.lonlat=lonlat;var newIcon=(icon)?icon:OpenLayers.Marker.defaultIcon();if(this.icon==null){this.icon=newIcon;}else{this.icon.url=newIcon.url;this.icon.size=newIcon.size;this.icon.offset=newIcon.offset;this.icon.calculateOffset=newIcon.calculateOffset;}
this.events=new OpenLayers.Events(this,this.icon.imageDiv,null);},destroy:function(){this.erase();this.map=null;this.events.destroy();this.events=null;if(this.icon!=null){this.icon.destroy();this.icon=null;}},draw:function(px){return this.icon.draw(px);},erase:function(){if(this.icon!=null){this.icon.erase();}},moveTo:function(px){if((px!=null)&&(this.icon!=null)){this.icon.moveTo(px);}
this.lonlat=this.map.getLonLatFromLayerPx(px);},animateTo:function(px){if((px!=null)&&(this.icon!=null)){this.icon.animateTo(px);}
this.lonlat=this.map.getLonLatFromLayerPx(px);},isDrawn:function(){var isDrawn=(this.icon&&this.icon.isDrawn());return isDrawn;},onScreen:function(){var onScreen=false;if(this.map){var screenBounds=this.map.getExtent();onScreen=screenBounds.containsLonLat(this.lonlat);}
return onScreen;},inflate:function(inflate){if(this.icon){var newSize=new OpenLayers.Size(this.icon.size.w*inflate,this.icon.size.h*inflate);this.icon.setSize(newSize);}},setOpacity:function(opacity){this.icon.setOpacity(opacity);},setUrl:function(url){this.icon.setUrl(url);},display:function(display){this.icon.display(display);},CLASS_NAME:"OpenLayers.Marker"});OpenLayers.Marker.defaultIcon=function(){var url=OpenLayers.Util.getImagesLocation()+"marker.png";var size=new OpenLayers.Size(21,25);var calculateOffset=function(size){return new OpenLayers.Pixel(-(size.w/2),-size.h);};return new OpenLayers.Icon(url,size,null,calculateOffset);};OpenLayers.Popup.FramedCloud=OpenLayers.Class(OpenLayers.Popup.Framed,{contentDisplayClass:"olFramedCloudPopupContent",autoSize:true,panMapIfOutOfView:true,imageSize:new OpenLayers.Size(676,736),isAlphaImage:false,fixedRelativePosition:false,positionBlocks:{"tl":{'offset':new OpenLayers.Pixel(44,0),'padding':new OpenLayers.Bounds(8,40,8,9),'blocks':[{size:new OpenLayers.Size('auto','auto'),anchor:new OpenLayers.Bounds(0,51,22,0),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,'auto'),anchor:new OpenLayers.Bounds(null,50,0,0),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size('auto',19),anchor:new OpenLayers.Bounds(0,32,22,null),position:new OpenLayers.Pixel(0,-631)},{size:new OpenLayers.Size(22,18),anchor:new OpenLayers.Bounds(null,32,0,null),position:new OpenLayers.Pixel(-638,-632)},{size:new OpenLayers.Size(81,35),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(0,-688)}]},"tr":{'offset':new OpenLayers.Pixel(-45,0),'padding':new OpenLayers.Bounds(8,40,8,9),'blocks':[{size:new OpenLayers.Size('auto','auto'),anchor:new OpenLayers.Bounds(0,51,22,0),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,'auto'),anchor:new OpenLayers.Bounds(null,50,0,0),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size('auto',19),anchor:new OpenLayers.Bounds(0,32,22,null),position:new OpenLayers.Pixel(0,-631)},{size:new OpenLayers.Size(22,19),anchor:new OpenLayers.Bounds(null,32,0,null),position:new OpenLayers.Pixel(-638,-631)},{size:new OpenLayers.Size(81,35),anchor:new OpenLayers.Bounds(0,0,null,null),position:new OpenLayers.Pixel(-215,-687)}]},"bl":{'offset':new OpenLayers.Pixel(45,0),'padding':new OpenLayers.Bounds(8,9,8,40),'blocks':[{size:new OpenLayers.Size('auto','auto'),anchor:new OpenLayers.Bounds(0,21,22,32),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,'auto'),anchor:new OpenLayers.Bounds(null,21,0,32),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size('auto',21),anchor:new OpenLayers.Bounds(0,0,22,null),position:new OpenLayers.Pixel(0,-629)},{size:new OpenLayers.Size(22,21),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(-638,-629)},{size:new OpenLayers.Size(81,33),anchor:new OpenLayers.Bounds(null,null,0,0),position:new OpenLayers.Pixel(-101,-674)}]},"br":{'offset':new OpenLayers.Pixel(-44,0),'padding':new OpenLayers.Bounds(8,9,8,40),'blocks':[{size:new OpenLayers.Size('auto','auto'),anchor:new OpenLayers.Bounds(0,21,22,32),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,'auto'),anchor:new OpenLayers.Bounds(null,21,0,32),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size('auto',21),anchor:new OpenLayers.Bounds(0,0,22,null),position:new OpenLayers.Pixel(0,-629)},{size:new OpenLayers.Size(22,21),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(-638,-629)},{size:new OpenLayers.Size(81,33),anchor:new OpenLayers.Bounds(0,null,null,0),position:new OpenLayers.Pixel(-311,-674)}]}},minSize:new OpenLayers.Size(205,10),maxSize:new OpenLayers.Size(600,660),initialize:function(id,lonlat,contentSize,contentHTML,anchor,closeBox,closeBoxCallback){this.imageSrc=OpenLayers.Util.getImagesLocation()+'cloud-popup-relative.png';OpenLayers.Popup.Framed.prototype.initialize.apply(this,arguments);this.contentDiv.className=this.contentDisplayClass;},destroy:function(){OpenLayers.Popup.Framed.prototype.destroy.apply(this,arguments);},CLASS_NAME:"OpenLayers.Popup.FramedCloud"});OpenLayers.Popup.FramedCloud2=OpenLayers.Class(OpenLayers.Popup.Framed,{contentDisplayClass:"olFramedCloudPopupContent",autoSize:true,panMapIfOutOfView:true,imageSize:new OpenLayers.Size(676,736),isAlphaImage:false,fixedRelativePosition:false,positionBlocks:{"tl":{'offset':new OpenLayers.Pixel(44,0),'padding':new OpenLayers.Bounds(8,40,8,9),'blocks':[{size:new OpenLayers.Size('auto','auto'),anchor:new OpenLayers.Bounds(0,51,22,0),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,'auto'),anchor:new OpenLayers.Bounds(null,50,0,0),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size('auto',19),anchor:new OpenLayers.Bounds(0,32,22,null),position:new OpenLayers.Pixel(0,-631)},{size:new OpenLayers.Size(22,18),anchor:new OpenLayers.Bounds(null,32,0,null),position:new OpenLayers.Pixel(-638,-632)},{size:new OpenLayers.Size(81,35),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(0,-688)}]},"tr":{'offset':new OpenLayers.Pixel(-45,0),'padding':new OpenLayers.Bounds(8,40,8,9),'blocks':[{size:new OpenLayers.Size('auto','auto'),anchor:new OpenLayers.Bounds(0,51,22,0),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,'auto'),anchor:new OpenLayers.Bounds(null,50,0,0),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size('auto',19),anchor:new OpenLayers.Bounds(0,32,22,null),position:new OpenLayers.Pixel(0,-631)},{size:new OpenLayers.Size(22,19),anchor:new OpenLayers.Bounds(null,32,0,null),position:new OpenLayers.Pixel(-638,-631)},{size:new OpenLayers.Size(81,35),anchor:new OpenLayers.Bounds(0,0,null,null),position:new OpenLayers.Pixel(-215,-687)}]},"bl":{'offset':new OpenLayers.Pixel(45,0),'padding':new OpenLayers.Bounds(8,9,8,40),'blocks':[{size:new OpenLayers.Size('auto','auto'),anchor:new OpenLayers.Bounds(0,21,22,32),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,'auto'),anchor:new OpenLayers.Bounds(null,21,0,32),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size('auto',21),anchor:new OpenLayers.Bounds(0,0,22,null),position:new OpenLayers.Pixel(0,-629)},{size:new OpenLayers.Size(22,21),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(-638,-629)},{size:new OpenLayers.Size(81,33),anchor:new OpenLayers.Bounds(null,null,0,0),position:new OpenLayers.Pixel(-101,-674)}]},"br":{'offset':new OpenLayers.Pixel(-44,0),'padding':new OpenLayers.Bounds(8,9,8,40),'blocks':[{size:new OpenLayers.Size('auto','auto'),anchor:new OpenLayers.Bounds(0,21,22,32),position:new OpenLayers.Pixel(0,0)},{size:new OpenLayers.Size(22,'auto'),anchor:new OpenLayers.Bounds(null,21,0,32),position:new OpenLayers.Pixel(-638,0)},{size:new OpenLayers.Size('auto',21),anchor:new OpenLayers.Bounds(0,0,22,null),position:new OpenLayers.Pixel(0,-629)},{size:new OpenLayers.Size(22,21),anchor:new OpenLayers.Bounds(null,0,0,null),position:new OpenLayers.Pixel(-638,-629)},{size:new OpenLayers.Size(81,33),anchor:new OpenLayers.Bounds(0,null,null,0),position:new OpenLayers.Pixel(-311,-674)}]}},minSize:new OpenLayers.Size(305,10),maxSize:new OpenLayers.Size(600,660),initialize:function(id,lonlat,contentSize,contentHTML,anchor,closeBox,closeBoxCallback){this.imageSrc=OpenLayers.Util.getImagesLocation()+'cloud-popup-relative.png';OpenLayers.Popup.Framed.prototype.initialize.apply(this,arguments);this.contentDiv.className=this.contentDisplayClass;},destroy:function(){OpenLayers.Popup.Framed.prototype.destroy.apply(this,arguments);},addCloseBox:function(callback){this.closeDiv=OpenLayers.Util.createDiv(this.id+"_close",null,new OpenLayers.Size(20,20));this.closeDiv.className="olPopupCloseBox";var contentDivPadding=this.getContentDivPadding();this.closeDiv.style.right=contentDivPadding.right+"px";this.closeDiv.style.top=contentDivPadding.top+"px";this.groupDiv.appendChild(this.closeDiv);var closePopup=callback||function(e){this.hide();OpenLayers.Event.stop(e);};OpenLayers.Event.observe(this.closeDiv,"click",OpenLayers.Function.bindAsEventListener(closePopup,this));},CLASS_NAME:"OpenLayers.Popup.FramedCloud2"});OpenLayers.Request={DEFAULT_CONFIG:{method:"GET",url:window.location.href,async:true,user:undefined,password:undefined,params:null,proxy:OpenLayers.ProxyHost,headers:{},data:null,callback:function(){},success:null,failure:null,scope:null},events:new OpenLayers.Events(this,null,["complete","success","failure"]),issue:function(config){var defaultConfig=OpenLayers.Util.extend(this.DEFAULT_CONFIG,{proxy:OpenLayers.ProxyHost});config=OpenLayers.Util.applyDefaults(config,defaultConfig);var request=new OpenLayers.Request.XMLHttpRequest();var url=config.url;if(config.params){var paramString=OpenLayers.Util.getParameterString(config.params);if(paramString.length>0){var separator=(url.indexOf('?')>-1)?'&':'?';url+=separator+paramString;}}
if(config.proxy&&(url.indexOf("http")==0)){url=config.proxy+encodeURIComponent(url);}
request.open(config.method,url,config.async,config.user,config.password);for(var header in config.headers){request.setRequestHeader(header,config.headers[header]);}
var complete=(config.scope)?OpenLayers.Function.bind(config.callback,config.scope):config.callback;var success;if(config.success){success=(config.scope)?OpenLayers.Function.bind(config.success,config.scope):config.success;}
var failure;if(config.failure){failure=(config.scope)?OpenLayers.Function.bind(config.failure,config.scope):config.failure;}
var events=this.events;request.onreadystatechange=function(){if(request.readyState==OpenLayers.Request.XMLHttpRequest.DONE){var proceed=events.triggerEvent("complete",{request:request,config:config,requestUrl:url});if(proceed!==false){complete(request);if(!request.status||(request.status>=200&&request.status<300)){events.triggerEvent("success",{request:request,config:config,requestUrl:url});if(success){success(request);}}
if(request.status&&(request.status<200||request.status>=300)){events.triggerEvent("failure",{request:request,config:config,requestUrl:url});if(failure){failure(request);}}}}};if(config.async===false){request.send(config.data);}else{window.setTimeout(function(){request.send(config.data);},0);}
return request;},GET:function(config){config=OpenLayers.Util.extend(config,{method:"GET"});return OpenLayers.Request.issue(config);},POST:function(config){config=OpenLayers.Util.extend(config,{method:"POST"});config.headers=config.headers?config.headers:{};if(!("CONTENT-TYPE"in OpenLayers.Util.upperCaseObject(config.headers))){config.headers["Content-Type"]="application/xml";}
return OpenLayers.Request.issue(config);},PUT:function(config){config=OpenLayers.Util.extend(config,{method:"PUT"});config.headers=config.headers?config.headers:{};if(!("CONTENT-TYPE"in OpenLayers.Util.upperCaseObject(config.headers))){config.headers["Content-Type"]="application/xml";}
return OpenLayers.Request.issue(config);},DELETE:function(config){config=OpenLayers.Util.extend(config,{method:"DELETE"});return OpenLayers.Request.issue(config);},HEAD:function(config){config=OpenLayers.Util.extend(config,{method:"HEAD"});return OpenLayers.Request.issue(config);},OPTIONS:function(config){config=OpenLayers.Util.extend(config,{method:"OPTIONS"});return OpenLayers.Request.issue(config);}};OpenLayers.Tile.Image=OpenLayers.Class(OpenLayers.Tile,{url:null,imgDiv:null,frame:null,layerAlphaHack:null,isBackBuffer:false,lastRatio:1,isFirstDraw:true,backBufferTile:null,initialize:function(layer,position,bounds,url,size){OpenLayers.Tile.prototype.initialize.apply(this,arguments);this.url=url;this.frame=document.createElement('div');this.frame.style.overflow='hidden';this.frame.style.position='absolute';this.layerAlphaHack=this.layer.alpha&&OpenLayers.Util.alphaHack();},destroy:function(){if(this.imgDiv!=null){if(this.layerAlphaHack){OpenLayers.Event.stopObservingElement(this.imgDiv.childNodes[0].id);}
OpenLayers.Event.stopObservingElement(this.imgDiv.id);if(this.imgDiv.parentNode==this.frame){this.frame.removeChild(this.imgDiv);this.imgDiv.map=null;}
this.imgDiv.urls=null;this.imgDiv.src=OpenLayers.Util.getImagesLocation()+"blank.gif";}
this.imgDiv=null;if((this.frame!=null)&&(this.frame.parentNode==this.layer.div)){this.layer.div.removeChild(this.frame);}
this.frame=null;if(this.backBufferTile){this.backBufferTile.destroy();this.backBufferTile=null;}
this.layer.events.unregister("loadend",this,this.resetBackBuffer);OpenLayers.Tile.prototype.destroy.apply(this,arguments);},clone:function(obj){if(obj==null){obj=new OpenLayers.Tile.Image(this.layer,this.position,this.bounds,this.url,this.size);}
obj=OpenLayers.Tile.prototype.clone.apply(this,[obj]);obj.imgDiv=null;return obj;},draw:function(){if(this.layer!=this.layer.map.baseLayer&&this.layer.reproject){this.bounds=this.getBoundsFromBaseLayer(this.position);}
var drawTile=OpenLayers.Tile.prototype.draw.apply(this,arguments);if(OpenLayers.Util.indexOf(this.layer.SUPPORTED_TRANSITIONS,this.layer.transitionEffect)!=-1){if(drawTile){if(!this.backBufferTile){this.backBufferTile=this.clone();this.backBufferTile.hide();this.backBufferTile.isBackBuffer=true;this.events.register('loadend',this,this.resetBackBuffer);this.layer.events.register("loadend",this,this.resetBackBuffer);}
this.startTransition();}else{if(this.backBufferTile){this.backBufferTile.clear();}}}else{if(drawTile&&this.isFirstDraw){this.events.register('loadend',this,this.showTile);this.isFirstDraw=false;}}
if(!drawTile){return false;}
if(this.isLoading){this.events.triggerEvent("reload");}else{this.isLoading=true;this.events.triggerEvent("loadstart");}
return this.renderTile();},resetBackBuffer:function(){this.showTile();if(this.backBufferTile&&(this.isFirstDraw||!this.layer.numLoadingTiles)){this.isFirstDraw=false;var maxExtent=this.layer.maxExtent;var withinMaxExtent=(maxExtent&&this.bounds.intersectsBounds(maxExtent,false));if(withinMaxExtent){this.backBufferTile.position=this.position;this.backBufferTile.bounds=this.bounds;this.backBufferTile.size=this.size;this.backBufferTile.imageSize=this.layer.imageSize||this.size;this.backBufferTile.imageOffset=this.layer.imageOffset;this.backBufferTile.resolution=this.layer.getResolution();this.backBufferTile.renderTile();}
this.backBufferTile.hide();}},renderTile:function(){if(this.imgDiv==null){this.initImgDiv();}
this.imgDiv.viewRequestID=this.layer.map.viewRequestID;if(this.layer.async){this.layer.getURLasync(this.bounds,this,"url",this.positionImage);}else{if(this.layer.url instanceof Array){this.imgDiv.urls=this.layer.url.slice();}
this.url=this.layer.getURL(this.bounds);this.positionImage();}
return true;},positionImage:function(){if(this.layer==null)
return;OpenLayers.Util.modifyDOMElement(this.frame,null,this.position,this.size);var imageSize=this.layer.getImageSize();if(this.layerAlphaHack){OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,null,null,imageSize,this.url);}else{OpenLayers.Util.modifyDOMElement(this.imgDiv,null,null,imageSize);this.imgDiv.src=this.url;}},clear:function(){if(this.imgDiv){this.hide();if(OpenLayers.Tile.Image.useBlankTile){this.imgDiv.src=OpenLayers.Util.getImagesLocation()+"blank.gif";}}},initImgDiv:function(){var offset=this.layer.imageOffset;var size=this.layer.getImageSize();if(this.layerAlphaHack){this.imgDiv=OpenLayers.Util.createAlphaImageDiv(null,offset,size,null,"relative",null,null,null,true);}else{this.imgDiv=OpenLayers.Util.createImage(null,offset,size,null,"relative",null,null,true);}
this.imgDiv.className='olTileImage';this.frame.style.zIndex=this.isBackBuffer?0:1;this.frame.appendChild(this.imgDiv);this.layer.div.appendChild(this.frame);if(this.layer.opacity!=null){OpenLayers.Util.modifyDOMElement(this.imgDiv,null,null,null,null,null,null,this.layer.opacity);}
this.imgDiv.map=this.layer.map;var onload=function(){if(this.isLoading){this.isLoading=false;this.events.triggerEvent("loadend");}};if(this.layerAlphaHack){OpenLayers.Event.observe(this.imgDiv.childNodes[0],'load',OpenLayers.Function.bind(onload,this));}else{OpenLayers.Event.observe(this.imgDiv,'load',OpenLayers.Function.bind(onload,this));}
var onerror=function(){if(this.imgDiv._attempts>OpenLayers.IMAGE_RELOAD_ATTEMPTS){onload.call(this);}};OpenLayers.Event.observe(this.imgDiv,"error",OpenLayers.Function.bind(onerror,this));},checkImgURL:function(){if(this.layer){var loaded=this.layerAlphaHack?this.imgDiv.firstChild.src:this.imgDiv.src;if(!OpenLayers.Util.isEquivalentUrl(loaded,this.url)){this.hide();}}},startTransition:function(){if(!this.backBufferTile||!this.backBufferTile.imgDiv){return;}
var ratio=1;if(this.backBufferTile.resolution){ratio=this.backBufferTile.resolution/this.layer.getResolution();}
if(ratio!=this.lastRatio){if(this.layer.transitionEffect=='resize'){var upperLeft=new OpenLayers.LonLat(this.backBufferTile.bounds.left,this.backBufferTile.bounds.top);var size=new OpenLayers.Size(this.backBufferTile.size.w*ratio,this.backBufferTile.size.h*ratio);var px=this.layer.map.getLayerPxFromLonLat(upperLeft);OpenLayers.Util.modifyDOMElement(this.backBufferTile.frame,null,px,size);var imageSize=this.backBufferTile.imageSize;imageSize=new OpenLayers.Size(imageSize.w*ratio,imageSize.h*ratio);var imageOffset=this.backBufferTile.imageOffset;if(imageOffset){imageOffset=new OpenLayers.Pixel(imageOffset.x*ratio,imageOffset.y*ratio);}
OpenLayers.Util.modifyDOMElement(this.backBufferTile.imgDiv,null,imageOffset,imageSize);this.backBufferTile.show();}}else{if(this.layer.singleTile){this.backBufferTile.show();}else{this.backBufferTile.hide();}}
this.lastRatio=ratio;},show:function(){this.frame.style.display='';if(OpenLayers.Util.indexOf(this.layer.SUPPORTED_TRANSITIONS,this.layer.transitionEffect)!=-1){if(navigator.userAgent.toLowerCase().indexOf("gecko")!=-1){this.frame.scrollLeft=this.frame.scrollLeft;}}},hide:function(){this.frame.style.display='none';},CLASS_NAME:"OpenLayers.Tile.Image"});OpenLayers.Tile.Image.useBlankTile=(OpenLayers.Util.getBrowserName()=="safari"||OpenLayers.Util.getBrowserName()=="opera");OpenLayers.Control.DGOverviewMap=OpenLayers.Class(OpenLayers.Control,{element:null,ovmap:null,size:new OpenLayers.Size(180,90),layers:null,minRectSize:15,minRectDisplayClass:"RectReplacement",minRatio:8,maxRatio:32,mapOptions:null,autoPan:false,handlers:null,resolutionFactor:1,initialize:function(options){this.layers=[];this.handlers={};OpenLayers.Control.prototype.initialize.apply(this,[options]);},destroy:function(){if(!this.mapDiv){return;}
this.handlers.click.destroy();this.mapDiv.removeChild(this.extentRectangle);this.extentRectangle=null;this.rectEvents.destroy();this.rectEvents=null;this.ovmap.destroy();this.ovmap=null;this.element.removeChild(this.mapDiv);this.mapDiv=null;this.div.removeChild(this.element);this.element=null;if(this.maximizeDiv){OpenLayers.Event.stopObservingElement(this.maximizeDiv);this.div.removeChild(this.maximizeDiv);this.maximizeDiv=null;}
if(this.minimizeDiv){OpenLayers.Event.stopObservingElement(this.minimizeDiv);this.div.removeChild(this.minimizeDiv);this.minimizeDiv=null;}
this.map.events.un({"moveend":this.update,"changebaselayer":this.baseLayerDraw,scope:this});OpenLayers.Control.prototype.destroy.apply(this,arguments);},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);if(!(this.layers.length>0)){if(this.map.baseLayer){var layer=this.map.baseLayer.clone();this.layers=[layer];}else{this.map.events.register("changebaselayer",this,this.baseLayerDraw);return this.div;}}
this.element=document.createElement('div');this.element.className=this.displayClass+'Element';this.element.style.display='none';this.mapDiv=document.createElement('div');this.mapDiv.style.width=this.size.w+'px';this.mapDiv.style.height=this.size.h+'px';this.mapDiv.style.position='relative';this.mapDiv.style.overflow='hidden';this.mapDiv.id=OpenLayers.Util.createUniqueID('overviewMap');this.extentRectangle=document.createElement('div');this.extentRectangle.style.position='absolute';this.extentRectangle.style.zIndex=1000;this.extentRectangle.style.border='2px solid #FF0000';this.extentRectangle.className=this.displayClass+'ExtentRectangle';this.mapDiv.appendChild(this.extentRectangle);this.element.appendChild(this.mapDiv);this.div.appendChild(this.element);if(!this.outsideViewport){this.div.className+=" "+this.displayClass+'Container';var imgLocation=OpenLayers.Util.getImagesLocation();var img=imgLocation+'layer-switcher-maximize.png';this.maximizeDiv=OpenLayers.Util.createAlphaImageDiv(this.displayClass+'MaximizeButton',null,new OpenLayers.Size(18,18),img,'absolute');this.maximizeDiv.style.display='none';this.maximizeDiv.className=this.displayClass+'MaximizeButton';OpenLayers.Event.observe(this.maximizeDiv,'click',OpenLayers.Function.bindAsEventListener(this.maximizeControl,this));this.div.appendChild(this.maximizeDiv);var img=imgLocation+'layer-switcher-minimize.png';this.minimizeDiv=OpenLayers.Util.createAlphaImageDiv('OpenLayers_Control_minimizeDiv',null,new OpenLayers.Size(18,18),img,'absolute');this.minimizeDiv.style.display='none';this.minimizeDiv.className=this.displayClass+'MinimizeButton';OpenLayers.Event.observe(this.minimizeDiv,'click',OpenLayers.Function.bindAsEventListener(this.minimizeControl,this));this.div.appendChild(this.minimizeDiv);var eventsToStop=['dblclick','mousedown'];for(var i=0,len=eventsToStop.length;i<len;i++){OpenLayers.Event.observe(this.maximizeDiv,eventsToStop[i],OpenLayers.Event.stop);OpenLayers.Event.observe(this.minimizeDiv,eventsToStop[i],OpenLayers.Event.stop);}
this.minimizeControl();}else{this.element.style.display='';}
if(this.map.getExtent()){this.update();}
this.map.events.register('moveend',this,this.update);return this.div;},baseLayerDraw:function(){this.draw();this.map.events.unregister("changebaselayer",this,this.baseLayerDraw);},rectDrag:function(px){var deltaX=this.handlers.drag.last.x-px.x;var deltaY=this.handlers.drag.last.y-px.y;if(deltaX!=0||deltaY!=0){var rectTop=this.rectPxBounds.top;var rectLeft=this.rectPxBounds.left;var rectHeight=Math.abs(this.rectPxBounds.getHeight());var rectWidth=this.rectPxBounds.getWidth();var newTop=Math.max(0,(rectTop-deltaY));newTop=Math.min(newTop,this.ovmap.size.h-this.hComp-rectHeight);var newLeft=Math.max(0,(rectLeft-deltaX));newLeft=Math.min(newLeft,this.ovmap.size.w-this.wComp-rectWidth);this.setRectPxBounds(new OpenLayers.Bounds(newLeft,newTop+rectHeight,newLeft+rectWidth,newTop));}},mapDivClick:function(evt){var pxCenter=this.rectPxBounds.getCenterPixel();var deltaX=evt.xy.x-pxCenter.x;var deltaY=evt.xy.y-pxCenter.y;var top=this.rectPxBounds.top;var left=this.rectPxBounds.left;var height=Math.abs(this.rectPxBounds.getHeight());var width=this.rectPxBounds.getWidth();var newTop=Math.max(0,(top+deltaY));newTop=Math.min(newTop,this.ovmap.size.h-height);var newLeft=Math.max(0,(left+deltaX));newLeft=Math.min(newLeft,this.ovmap.size.w-width);this.setRectPxBounds(new OpenLayers.Bounds(newLeft,newTop+height,newLeft+width,newTop));this.updateMapToRect();},maximizeControl:function(e){this.element.style.display='';this.showToggle(false);if(e!=null){OpenLayers.Event.stop(e);}},minimizeControl:function(e){this.element.style.display='none';this.showToggle(true);if(e!=null){OpenLayers.Event.stop(e);}},showToggle:function(minimize){this.maximizeDiv.style.display=minimize?'':'none';this.minimizeDiv.style.display=minimize?'none':'';},update:function(){if(this.ovmap==null){this.createMap();}
if(this.autoPan||!this.isSuitableOverview()){this.updateOverview();}
this.updateRectToMap();},isSuitableOverview:function(){var mapExtent=this.map.getExtent();var maxExtent=this.map.maxExtent;var testExtent=new OpenLayers.Bounds(Math.max(mapExtent.left,maxExtent.left),Math.max(mapExtent.bottom,maxExtent.bottom),Math.min(mapExtent.right,maxExtent.right),Math.min(mapExtent.top,maxExtent.top));if(this.ovmap.getProjection()!=this.map.getProjection()){testExtent=testExtent.transform(this.map.getProjectionObject(),this.ovmap.getProjectionObject());}
var resRatio=this.ovmap.getResolution()/this.map.getResolution();return((resRatio>this.minRatio)&&(resRatio<=this.maxRatio)&&(this.ovmap.getExtent().containsBounds(testExtent)));},updateOverview:function(){var mapRes=this.map.getResolution();var targetRes=this.ovmap.getResolution();var resRatio=targetRes/mapRes;if(resRatio>this.maxRatio){targetRes=this.minRatio*mapRes;}else if(resRatio<=this.minRatio){targetRes=this.maxRatio*mapRes;}
var center;if(this.ovmap.getProjection()!=this.map.getProjection()){center=this.map.center.clone();center.transform(this.map.getProjectionObject(),this.ovmap.getProjectionObject());}else{center=this.map.center;}
this.ovmap.setCenter(center,this.ovmap.getZoomForResolution(targetRes*this.resolutionFactor));this.updateRectToMap();},createMap:function(){var options=OpenLayers.Util.extend({controls:[],maxResolution:'auto',fallThrough:false},this.mapOptions);this.ovmap=new OpenLayers.Map(this.mapDiv,options);OpenLayers.Event.stopObserving(window,'unload',this.ovmap.unloadDestroy);this.ovmap.addLayers
