OpenLayers.FeatureFBS=OpenLayers.Class(OpenLayers.Feature,{createPopup:function(closeBox){if(this.lonlat!=null){var id=this.id+"_popup";var anchor=(this.marker)?this.marker.icon:null;this.popup=new this.popupClass(id,this.lonlat,this.data.popupSize,this.data.popupContentHTML,anchor,closeBox,this.data.server);if(this.data.overflow!=null){this.popup.contentDiv.style.overflow=this.data.overflow;}
this.popup.feature=this;}
return this.popup;},CLASS_NAME:"OpenLayers.FeatureFBS"});function fbsScalebar(map,o)
{this.km=map;var imgLocation=o.server?o.server:"images/";var szLeftImg=imgLocation+(o.leftImg?o.leftImg:'sbar_l.png');var szCenterImg=imgLocation+(o.centerImg?o.centerImg:'sbar_c.png');var szRightImg=imgLocation+(o.rightImg?o.rightImg:'sbar_r.png');this.domObj=document.createElement('div');this.domObj.id='fbs_scale';this.id=this.domObj.id;this.domObj.style.position='absolute';this.domObj.style.bottom=o.bottom?o.bottom+'px':'80px';this.domObj.style.left=o.left?o.left+'px':'10px';this.domObj.style.width='0px';this.domObj.style.height='0px';this.domObj.style.zIndex=1000;this.domObj.style.visibility='hidden';this.domObj.innerHTML='<img class="png24" src="'+szLeftImg+'" width="12" height="23" border="0" ><img id="kmBar" class="png24" src="'+szCenterImg+'" width="75" height="23" border="0"><img class="png24" src="'+szRightImg+'" width="12" height="23" border="0"><br><img class="png24" src="'+szLeftImg+'" width="12" height="23" border="0" ><img id="miBar" class="png24" src="'+szCenterImg+'" width="75" height="23" border="0"><img class="png24" src="'+szRightImg+'" width="12" height="23" border="0"><div id="kmText" style="position:absolute;top:4px;left:12px; font-family:arial;font-size:12px;color:white;">km</div><div id="miText"style="position:absolute;top:27px;left:12px;font-family:arial; font-size:12px;color:white;">mi</div></div>';this.add();};fbsScalebar.prototype.add=function(){this.km.viewPortDiv.appendChild(this.domObj);this.show();};fbsScalebar.prototype.update=function()
{var oExtent=this.km.getExtent();var oTempCenterLonLat=this.km.getCenter();var oCenterLonLat=new OpenLayers.LonLat();oCenterLonLat.lon=oTempCenterLonLat.lon;oCenterLonLat.lat=oTempCenterLonLat.lat;var oCenterPix=this.km.getPixelFromLonLat(oCenterLonLat);var o100pxLatLon=this.km.getLonLatFromPixel(new OpenLayers.Pixel(oCenterPix.x+100,oCenterPix.y));if(this.km.units=='m')
{oCenterLonLat=oCenterLonLat.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));o100pxLatLon=o100pxLatLon.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));}
var kmPerPixel=OpenLayers.Util.distVincenty(oCenterLonLat,o100pxLatLon)/100;var mPerPixel=kmPerPixel*1000;var miPerPixel=kmPerPixel*0.621371192;var ftPerPixel=kmPerPixel*3280.8399;var nTargetPixelSize=150;var oMetricScale=this._getScaleFromTarget(nTargetPixelSize,kmPerPixel);var szMetricUnits='km';if(oMetricScale.unit<=1.0)
{oMetricScale=this._getScaleFromTarget(nTargetPixelSize,mPerPixel);szMetricUnits='m';}
var oImpScale=this._getScaleFromTarget(nTargetPixelSize,miPerPixel);var szImpUnits='mi';if(oImpScale.unit<1.0)
{oImpScale=this._getScaleFromTarget(nTargetPixelSize,ftPerPixel);szImpUnits='ft';}
var sbMax=Math.max(oImpScale.pixel,oMetricScale.pixel)+2;this.domObj.style.width=sbMax+'px';(document.getElementById(this.id)).style.width=sbMax+'px';this.domObj.childNodes[1].style.width=(oMetricScale.pixel-24)+"px";this.domObj.childNodes[7].innerHTML=oMetricScale.unit+' '+szMetricUnits;this.domObj.childNodes[5].style.width=(oImpScale.pixel-24)+"px";this.domObj.childNodes[8].innerHTML=oImpScale.unit+' '+szImpUnits;};fbsScalebar.prototype._getScaleFromTarget=function(nPixTargetSize,dUnitsPerPix)
{var dTargetUnitsSize=dUnitsPerPix*nPixTargetSize;var dRoundFactor=1;var dActualUnitsSize=0;var dActualPixSize=0;if(dTargetUnitsSize<1)
{dRoundFactor=0.1;}
else if(dTargetUnitsSize<10)
{dRoundFactor=1;}
else if(dTargetUnitsSize<100)
{dRoundFactor=10;}
else if(dTargetUnitsSize<1000)
{dRoundFactor=100;}
else if(dTargetUnitsSize<10000)
{dRoundFactor=1000;}
else
{dRoundFactor=10000;}
dActualUnitsSize=Math.round(dTargetUnitsSize/dRoundFactor)*dRoundFactor;if(dActualUnitsSize<1)
{dActualUnitsSize=(dActualUnitsSize+'').substr(0,3);dActualUnitsSize=parseFloat(dActualUnitsSize);}
dActualPixSize=dActualUnitsSize/dUnitsPerPix;return{'unit':dActualUnitsSize,'pixel':dActualPixSize}};fbsScalebar.prototype.show=function(){this.update();this.km.events.register('zoomend',this,this.update);var d=document.getElementById(this.id);d.style.visibility='visible';d.style.display='block';};fbsScalebar.prototype.hide=function(){this.km.events.unregister('zoomend',this,this.update);var d=document.getElementById(this.id);d.style.visibility='hidden';d.style.display='none';};function kaDigitizer(mapController,type,target,options){this.name='kaDigitizer';this.mapController=mapController;this.kaMap=mapController.getMap();this.type=type;this.isDigitizing=false;this.featureCanvas=null;this.targetFeatureCanvas=target||mapController.initialFeatureCanvasLayer;this.listeners=[];this.style=OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default']);if(options.style){this.style=OpenLayers.Util.extend({},options.style);}
this.currentFeature=null;this.drawStyle=null;if(options.drawStyle){this.drawStyle=OpenLayers.Util.extend({},options.drawStyle);}
var drawStyle=this.drawStyle||{'strokeColor':'#0069ff','strokeOpacity':1.0,'dash':[5,2],'fillColor':'#6900ff','fillOpacity':0.4,'strokeLinecap':'round','strokeWidth':2,'pointRadius':3};this.measureClass=options.measureClass;this.nodes=[];this.control=null;this.userProjection=new OpenLayers.Projection("EPSG:4326");this.mapProjection=new OpenLayers.Projection("EPSG:900913");this.transformUserToMap=function(input){input.transform(this.userProjection,this.mapProjection);};this.transformMapToUser=function(input){input.transform(this.mapProjection,this.userProjection);};var callbacks={'done':OpenLayers.Function.bind(this._preFeatureInsert,this)}
switch(type){case"point":this.control=new OpenLayers.Control.DrawFeature(this.targetFeatureCanvas,OpenLayers.Handler.Point,{'callbacks':callbacks,'handlerOptions':{'style':drawStyle},'displayClass':'olControlDrawFeaturePoint'});this.setStyle(this.style);break;case"line":this.control=new OpenLayers.Control.DrawFeature(this.targetFeatureCanvas,OpenLayers.Handler.Path,{'callbacks':callbacks,'handlerOptions':{'style':drawStyle},'displayClass':'olControlDrawFeaturePath'});this.setStyle(this.style);break;case"polygon":this.control=new OpenLayers.Control.DrawFeature(this.targetFeatureCanvas,OpenLayers.Handler.Polygon,{'callbacks':callbacks,'handlerOptions':{'style':drawStyle}});this.setStyle(this.style);break;case"radius":this.control=new OpenLayers.Control.DrawFeature(this.targetFeatureCanvas,OpenLayers.Handler.Radius,{'callbacks':callbacks,'measureClass':this.measureClass});break;case"rectangle":this.control=new OpenLayers.Control.DrawFeature(this.targetFeatureCanvas,OpenLayers.Handler.Rect,{'callbacks':callbacks,'displayClass':'olControlDrawFeaturePolygon','measureClass':this.measureClass},{'style':this.style});break;}
OpenLayers.Util.extend(this.control.handler.style,drawStyle);this.control.featureAdded=this.callListeners.bind(this);this.kaMap.addControl(this.control);};kaDigitizer.prototype.activate=function(){this.mapController.deactivateAllTools();this.mapController.toolset.digitizer=this.control;this.control.activate();};kaDigitizer.prototype._preFeatureInsert=function(geometry){var feature=new OpenLayers.Feature.Vector(geometry);feature.attributes=OpenLayers.Util.extend({},this.style);feature.attributes.type=this.type;feature.attributes.isUserFeature=true;if(this.control.measureClass){feature.attributes.signBoardClass=this.control.measureClass;};this.control.layer.addFeatures([feature]);this.control.featureAdded(feature);};kaDigitizer.prototype.deactivate=function(){this.control.deactivate();};kaDigitizer.prototype.deactivateCanvas=function(){this.featureCanvas.remove();};kaDigitizer.prototype.addListener=function(f){this.listeners.push(f);};kaDigitizer.prototype.callListeners=function(feature){for(var i=0;i<this.listeners.length;i++){this.listeners[i](feature);};this.mapController.features.push(feature);};kaDigitizer.prototype.setStyle=function(style){this.attributes=style;this.style=style;};OpenLayers.PopupFBS=OpenLayers.Class.create();CORNERS={TL:{src:'corners/topl.png',sizing:'scale'},TM:{src:'corners/topm.png',sizing:'crop'},TR:{src:'corners/topr.png',sizing:'scale'},ML:{src:'corners/midl.png',sizing:'crop'},MR:{src:'corners/midr.png',sizing:'crop'},BL:{src:'corners/botl.png',sizing:'scale'},BM:{src:'corners/botm.png',sizing:'crop'},BR:{src:'corners/botr.png',sizing:'scale'}}
OpenLayers.PopupFBS.SlideTimerInterval=10;OpenLayers.PopupFBS.SlideAnimationTime=2000;OpenLayers.PopupFBS.prototype={events:null,id:"",lonlat:null,div:null,size:null,contentHTML:"",opacity:"",contentDiv:null,server:'',padding:0,map:null,initialize:function(id,lonlat,size,contentHTML,closeBox,server)
{if(id==null)
{id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");}
this.size=(size!=null)?size:new OpenLayers.Size(200,200);this.id=id;this.lonlat=lonlat;this.server=server;this.offsetX=0;this.offsetY=-20;if(contentHTML!=null)this.contentHTML=contentHTML;this.div=OpenLayers.Util.createDiv(this.id,null,null,null,null,null);this.div.className='olPopup';var id=this.div.id+"_contentDiv";this.contentDiv=OpenLayers.Util.createDiv(id,null,this.size.clone(),null,"static",null);this.contentDiv.className='olPopupContent';if(parseInt(this.contentDiv.style.width)<parseInt(this.contentDiv.style.minWidth)){this.size.w=120;this.contentDiv.style.width="120px";}
this.getRenderedDimensions();this.insertCorners();this.addClose();this.updatePosition();},addClose:function(){var oBtnClose=document.createElement("A");oBtnClose.className="close";oBtnClose.style.position="absolute";oBtnClose.style.height=14+"px";oBtnClose.style.width=14+"px";oBtnClose.title="close popup";oBtnClose.href="#";this.div.appendChild(oBtnClose);var closeEvents=new OpenLayers.Events(this,oBtnClose,null,false);closeEvents.register("click",this,this.hide);this.registerEvents();},insertCorners:function()
{var arVersion=navigator.appVersion.split("MSIE");var version=parseFloat(arVersion[1]);var sImgLoc=this.server;while(this.div.childNodes.length){this.div.removeChild(this.div.childNodes[0]);}
var topl=OpenLayers.Util.createAlphaImageDiv("",new OpenLayers.Pixel(0,0),new OpenLayers.Size(38,28),sImgLoc+CORNERS.TL.src,"absolute",0,CORNERS.TL.sizing);this.div.appendChild(topl);var topm=OpenLayers.Util.createAlphaImageDiv("",new OpenLayers.Pixel(38,0),new OpenLayers.Size(parseInt(this.size.w-22),28),sImgLoc+CORNERS.TM.src,"absolute",0,CORNERS.TM.sizing);this.div.appendChild(topm);var topr=OpenLayers.Util.createAlphaImageDiv("",new OpenLayers.Pixel(parseInt(38+this.size.w-((version<7)?22:23)),0),new OpenLayers.Size(38,28),sImgLoc+CORNERS.TR.src,"absolute",0,CORNERS.TR.sizing);this.div.appendChild(topr);var midl=OpenLayers.Util.createAlphaImageDiv("",new OpenLayers.Pixel(0,28),new OpenLayers.Size(38,parseInt(this.size.h-12)),sImgLoc+CORNERS.ML.src,"absolute",0,CORNERS.ML.sizing);this.div.appendChild(midl);this.contentDiv.style.position="absolute";this.contentDiv.style.backgroundColor="#ffffff";this.contentDiv.style.top=15+"px";this.contentDiv.style.left=15+"px";this.contentDiv.style.width=Math.max(this.size.w,120)+"px";this.contentDiv.style.height=this.size.h+"px";var midr=OpenLayers.Util.createAlphaImageDiv("",new OpenLayers.Pixel(parseInt(38+this.size.w-22),28),new OpenLayers.Size(38,parseInt(this.size.h-13)),sImgLoc+CORNERS.MR.src,"absolute",0,CORNERS.MR.sizing);this.div.appendChild(midr);var iMaxW=38+this.size.w+38;var botl=OpenLayers.Util.createAlphaImageDiv("",new OpenLayers.Pixel(0,28+this.size.h-12),new OpenLayers.Size(38,39),sImgLoc+CORNERS.BL.src,"absolute",0,CORNERS.BL.sizing);this.div.appendChild(botl);var botm=OpenLayers.Util.createAlphaImageDiv("",new OpenLayers.Pixel(38,28+this.size.h-13),new OpenLayers.Size(Math.max(iMaxW-(38+97)-((version<7)?21:22),50),40),sImgLoc+CORNERS.BM.src,"absolute",0,CORNERS.BM.sizing);this.div.appendChild(botm);var botr=OpenLayers.Util.createAlphaImageDiv("",new OpenLayers.Pixel((iMaxW-(38+97))+38-((version<7)?21:22),28+this.size.h-13),new OpenLayers.Size(97,68),sImgLoc+CORNERS.BR.src,"absolute",0,CORNERS.BR.sizing);this.div.appendChild(botr);this.div.appendChild(this.contentDiv);this.size=new OpenLayers.Size(this.size.w+53,this.size.h+40);},getRenderedDimensions:function()
{this.setContentHTML();var container=document.createElement("div");container.className='olPopup';container.style.overflow="";container.style.position="absolute";container.style.left="-9999999999px";container.style.width="20px";container.style.height="20px";var content=document.createElement("div");content.innerHTML=this.contentHTML;content.className='olPopupContent';content.style.overflow="auto";container.appendChild(content);document.body.appendChild(container);var w=parseInt(content.scrollWidth);container.style.width=w+"px";var h=parseInt(content.scrollHeight);this.size=new OpenLayers.Size(w,h);document.body.removeChild(container);container=null;content=null;},destroy:function(){if(this.map!=null){this.map.removePopup(this);}
this.div=null;this.map=null;},draw:function(px)
{if(px==null)
{if((this.lonlat!=null)&&(this.map!=null))
{px=this.map.getLayerPxFromLonLat(this.lonlat);px.x=(px.x+this.offsetX);px.y=(px.y+this.offsetY);}}
this.setSize();this.setContentHTML();this.moveTo(px);return this.div;},refreshWithContent:function(content){this.hide();this.contentHTML=content||'';this.getRenderedDimensions();this.insertCorners();this.addClose();this.map.addPopup(this);this.show();},updatePosition:function()
{if((this.lonlat)&&(this.map)&&(this.anchor))
{var px=this.map.getLayerPxFromLonLat(this.lonlat);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()
{OpenLayers.Element.toggle(this.div);},show:function()
{OpenLayers.Element.show(this.div);},hide:function()
{if(arguments[0]){OpenLayers.Event.stop(arguments[0]);}
OpenLayers.Element.hide(this.div);return false;},setSize:function(size)
{if(size!=undefined)
{this.size=size;}
if(this.div!=null)
{this.div.style.width=this.size.w+"px";this.div.style.height=this.size.h+"px";}},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+')';}},setContentHTML:function(contentHTML){if(contentHTML!=null){this.contentHTML=contentHTML;}
if(this.contentDiv!=null){this.contentDiv.innerHTML=this.contentHTML;}},registerEvents:function(){this.events=new OpenLayers.Events(this,this.div,null,true);this.events.register("mousedown",this,this.onmousedown);this.events.register("mousemove",this,this.onmousemove);this.events.register("mouseup",this,this.onmouseup);this.events.register("click",this,OpenLayers.Util.safeStopPropagation);this.events.register("mouseout",this,this.onmouseout);this.events.register("dblclick",this,OpenLayers.Util.safeStopPropagation);},onmousedown:function(evt){this.mousedown=true;OpenLayers.Util.safeStopPropagation(evt);},onmousemove:function(evt){if(this.mousedown){OpenLayers.Util.safeStopPropagation(evt);}},onmouseup:function(evt){if(this.mousedown){this.mousedown=false;OpenLayers.Util.safeStopPropagation(evt);}},onmouseout:function(evt){this.mousedown=false;},CLASS_NAME:"OpenLayers.PopupFBS"};OpenLayers.PopupFBS.Anchored=OpenLayers.Class.create();OpenLayers.PopupFBS.Anchored.prototype=OpenLayers.Class.inherit(OpenLayers.PopupFBS,{relativePosition:"tl",anchor:null,differenceX:0,differenceY:0,initialize:function(id,lonlat,size,contentHTML,anchor,closeBox,server)
{var newArguments=new Array(id,lonlat,size,contentHTML,closeBox,server);OpenLayers.PopupFBS.prototype.initialize.apply(this,newArguments);this.anchor=(anchor!=null)?anchor:{size:new OpenLayers.Size(0,0),offset:new OpenLayers.Pixel(0,0)};this.registerEvents();},draw:function(px)
{if(px==null)
{if((this.lonlat!=null)&&(this.map!=null))
{px=this.map.getLayerPxFromLonLat(this.lonlat);}}
this.updatePos();return OpenLayers.PopupFBS.prototype.draw.apply(this,arguments);},updatePos:function()
{var oMapSize=support.getPos(this.map.div);var oPopupPx=this.calculateNewPx(this.map.getLayerPxFromLonLat(this.lonlat));oPopupPx=this.map.getViewPortPxFromLayerPx(oPopupPx);var x2=parseInt(oPopupPx.x+this.size.w);var y2=parseInt(oPopupPx.y+this.size.h);if(oPopupPx.x<oMapSize.x)
{this.differenceX=parseInt(oPopupPx.x-oMapSize.x-10);}
if(x2>oMapSize.w)
{this.differenceX=parseInt(x2-oMapSize.w);}
if(y2>oMapSize.h-60)
{this.differenceY=parseInt(y2-oMapSize.h+60);}
if(oPopupPx.y<oMapSize.y)
{this.differenceY=parseInt(oPopupPx.y-oMapSize.y-30);}
if(this.differenceX!=0||this.differenceY!=0)
{ShiftMap(this);}},moveTo:function(px)
{var newPx=this.calculateNewPx(px);var newArguments=new Array(newPx);OpenLayers.PopupFBS.prototype.moveTo.apply(this,newArguments);},setSize:function(size)
{OpenLayers.PopupFBS.prototype.setSize.apply(this,arguments);if((this.lonlat)&&(this.map))
{var px=this.map.getLayerPxFromLonLat(this.lonlat);this.moveTo(px);}},calculateNewPx:function(px){var newPx=px.offset(this.anchor.offset);var top=(this.relativePosition.charAt(0)=='t');newPx.y+=(top)?-this.size.h:this.anchor.size.h;var left=(this.relativePosition.charAt(1)=='l');newPx.x+=(left)?-this.size.w:this.anchor.size.w;newPx.x+=55;newPx.y-=15;return newPx;},CLASS_NAME:"OpenLayers.PopupFBS.Anchored"});OpenLayers.PopupFBS.AnchoredBubble=OpenLayers.Class.create();OpenLayers.PopupFBS.AnchoredBubble.prototype=OpenLayers.Class.inherit(OpenLayers.PopupFBS.Anchored,{initialize:function(id,lonlat,size,contentHTML,anchor,closeBox,server)
{OpenLayers.PopupFBS.Anchored.prototype.initialize.apply(this,arguments);},draw:function(px){OpenLayers.PopupFBS.Anchored.prototype.draw.apply(this,arguments);this.setContentHTML();return this.div;},setSize:function(size)
{OpenLayers.PopupFBS.Anchored.prototype.setSize.apply(this,arguments);},setOpacity:function(opacity)
{if(opacity!=undefined)
{this.opacity=opacity;}
if(this.div!=null)
{if(this.contentDiv!=null)
{OpenLayers.Rico.Corner.changeOpacity(this.contentDiv,this.opacity);}}},CLASS_NAME:"OpenLayers.PopupFBS.AnchoredBubble"});OpenLayers.Layer.Text=OpenLayers.Class.create();OpenLayers.Layer.Text.prototype=OpenLayers.Class.inherit(OpenLayers.Layer.Markers,{location:null,features:null,selectedFeature:null,initialize:function(name,options){OpenLayers.Layer.Markers.prototype.initialize.apply(this,arguments);this.features=new Array();if(this.location!=null)
{OpenLayers.loadURL(this.location,null,this,this.parseData);}},destroy:function(){this.clearFeatures();this.features=null;OpenLayers.Layer.Markers.prototype.destroy.apply(this,arguments);},parseData:function(ajaxRequest){var text=ajaxRequest.responseText;var lines=text.split('\n');var columns;for(var lcv=0;lcv<(lines.length-1);lcv++)
{var currLine=lines[lcv].replace(/^\s*/,'').replace(/\s*$/,'');if(currLine.charAt(0)!='#'){if(!columns)
{columns=currLine.split('\t');}
else
{var vals=currLine.split('\t');var location=new OpenLayers.LonLat(0,0);var title;var url;var icon,iconSize,iconOffset;var set=false;for(var valIndex=0;valIndex<vals.length;valIndex++)
{if(vals[valIndex])
{if(columns[valIndex]=='point')
{var coords=vals[valIndex].split(',');location.lat=parseFloat(coords[0]);location.lon=parseFloat(coords[1]);set=true;}
else if(columns[valIndex]=='lat')
{location.lat=parseFloat(vals[valIndex]);set=true;}
else if(columns[valIndex]=='lon')
{location.lon=parseFloat(vals[valIndex]);set=true;}
else if(columns[valIndex]=='title')title=vals[valIndex];else if(columns[valIndex]=='image'||columns[valIndex]=='icon')url=vals[valIndex];else if(columns[valIndex]=='iconSize')
{var size=vals[valIndex].split(',');iconSize=new OpenLayers.Size(parseFloat(size[0]),parseFloat(size[1]));}
else if(columns[valIndex]=='iconOffset')
{var offset=vals[valIndex].split(',');iconOffset=new OpenLayers.Pixel(parseFloat(offset[0]),parseFloat(offset[1]));}
else if(columns[valIndex]=='title')
{title=vals[valIndex];}
else if(columns[valIndex]=='description')
{description=vals[valIndex];}}}
if(set)
{var data=new Object();if(url!=null)
{data.icon=new OpenLayers.Icon(url,iconSize,iconOffset);}
else
{data.icon=OpenLayers.Marker.defaultIcon();if(iconSize!=null)
{data.icon.setSize(iconSize);}}
if((title!=null)&&(description!=null))
{data['popupContentHTML']='<h2>'+title+'</h2><p>'+description+'</p>';}
var feature=new OpenLayers.Feature(this,location,data);this.features.push(feature);var marker=feature.createMarker();marker.events.register('click',feature,this.markerClick);this.addMarker(marker);}}}}},markerClick:function(evt)
{sameMarkerClicked=(this==this.layer.selectedFeature);this.layer.selectedFeature=(!sameMarkerClicked)?this:null;for(var i=0;i<this.layer.map.popups.length;i++){this.layer.map.removePopup(this.layer.map.popups[i]);}
this.layer.map.addPopup(this.createPopup());OpenLayers.Event.stop(evt);},clearFeatures:function(){if(this.features!=null){while(this.features.length>0){var feature=this.features[0];OpenLayers.Util.removeItem(this.features,feature);feature.destroy();}}},CLASS_NAME:"OpenLayers.Layer.Text"});function ShiftMap(obj)
{var o=obj;if(o!=null)
{if(!o.ShiftStartTime)o.ShiftStartTime=(new Date()).getTime();if(o.differenceX!=0)
{var dir=(o.differenceX>0)?"+":"-";var elapsed=(new Date()).getTime()-o.ShiftStartTime;var increment=Math.round(elapsed/OpenLayers.PopupFBS.SlideAnimationTime*Math.abs(o.differenceX));switch(dir)
{case"+":{if((o)&&(o.differenceX>1)&&(o.map))
{o.differenceX-=increment;o.map.pan(+increment,0,{animate:false});window.setTimeout(function(){ShiftMap(o);},OpenLayers.PopupFBS.SlideTimerInterval);}}break;case"-":{if((o)&&(o.differenceX<1)&&(o.map))
{o.differenceX+=increment;o.map.pan(-increment,0,{animate:false});window.setTimeout(function(){ShiftMap(o);},OpenLayers.PopupFBS.SlideTimerInterval);}}break;}}
if(o.differenceY!=0)
{var dir=(o.differenceY>0)?"+":"-";var elapsed=(new Date()).getTime()-o.ShiftStartTime;var increment=Math.round(elapsed/OpenLayers.PopupFBS.SlideAnimationTime*Math.abs(o.differenceY));switch(dir)
{case"+":{if((o)&&(o.differenceY>1)&&(o.map))
{o.differenceY-=increment;o.map.pan(0,+increment,{animate:false});window.setTimeout(function(){ShiftMap(o);},OpenLayers.PopupFBS.SlideTimerInterval);}}break;case"-":{if((o)&&(o.differenceY<1)&&(o.map))
{o.differenceY+=increment;o.map.pan(0,-increment,{animate:false});window.setTimeout(function(){ShiftMap(o);},OpenLayers.PopupFBS.SlideTimerInterval);}}break;}}}}
var support={viewport:function()
{return{height:(document.body.clientHeight||document.documentElement.clientHeight||window.innerHeight||0),width:(document.body.clientWidth||document.documentElement.clientWidth||window.innerWidth||0),scrollX:(document.body.scrollLeft||document.documentElement.scrollLeft||self.pageXOffset||0),scrollY:(document.body.scrollTop||document.documentElement.scrollTop||self.pageYOffset||0)};},getPos:function(el)
{var x=0,y=0,w=0,h=0;if(document.getBoxObjectFor)
{var bo=document.getBoxObjectFor(el);return{x:bo.x,y:bo.y,w:bo.width,h:bo.height}}
else if(el.getBoundingClientRect)
{var rect=el.getBoundingClientRect();return{x:rect.left+support.viewport().scrollX,y:rect.top+support.viewport().scrollY,w:(rect.right-rect.left),h:(rect.bottom-rect.top)}}
else
{w=el.offsetWidth;h=el.offsetHeight;do{x+=el.offsetLeft||0;y+=el.offsetTop||0;el=el.offsetParent;}while(el);return{x:x,y:y,w:w,h:h}}},fade:function(id,opacStart,opacEnd,millisec,func)
{var speed=Math.round(millisec/100);var timer=0;if(opacStart>opacEnd)
{for(i=opacStart;i>=opacEnd;i--)
{setTimeout("support.changeOpac("+i+",'"+id+"')",(timer*speed));timer++;}}
else if(opacStart<opacEnd)
{for(i=opacStart;i<=opacEnd;i++)
{setTimeout("support.changeOpac("+i+",'"+id+"')",(timer*speed));timer++;}}
if(opacStart==opacEnd)
{func();}},changeOpac:function(opacity,id)
{var object=document.getElementById(id).style;object.opacity=(opacity/100);object.MozOpacity=(opacity/100);object.KhtmlOpacity=(opacity/100);object.filter="alpha(opacity="+opacity+")";}}
OpenLayers.SignBoard=OpenLayers.Class({id:null,content:null,lonlat:null,map:null,zindex:null,div:null,offsetx:null,offsety:null,initialize:function(lonlat,content,offsetx,offsety,map,zindex)
{this.lonlat=lonlat;this.content=content;this.offsetx=offsetx;this.offsety=offsety;this.map=map;this.zindex=zindex;this.div=document.createElement('div');this.div.style.display='none';this.div.style.position='absolute';this.map.layerContainerDiv.appendChild(this.div);this.id=OpenLayers.Util.createUniqueID('SignBoard');},draw:function()
{this.div.style.zIndex=this.zindex;this.div.innerHTML=this.content;var pix=this.map.getLayerPxFromLonLat(this.lonlat);this.div.style.left=(pix.x+this.offsetx)+'px';this.div.style.top=(pix.y+this.offsety)+'px';this.div.style.display='block';this.div.style.whiteSpace='nowrap';},destroy:function()
{this.map.layerContainerDiv.removeChild(this.div);},CLASS_NAME:"OpenLayers.SignBoard"});OpenLayers.SignBoardGroup=OpenLayers.Class({signboards:null,map:null,initialize:function(map)
{this.signboards=[];this.map=map;this.map.events.register('zoomend',this,this.draw);},addSignBoard:function(lonlat,content,offsetx,offsety,zindex){var newBoard=new OpenLayers.SignBoard(lonlat,content,offsetx,offsety,this.map,zindex);this.signboards.push(newBoard);return newBoard;},draw:function(){for(var i=0;i<this.signboards.length;i++)
{this.signboards[i].draw();}},destroy:function(){for(var i=0;i<this.signboards.length;i++)
{this.signboards[i].destroy();}
this.map.events.unregister('zoomend',this,this.draw);this.signboards=[];},CLASS_NAME:"OpenLayers.SignBoardGroup"});OpenLayers.Units=OpenLayers.Class({INCHES:null,FEET:null,MILES:null,METERS:null,KILOMETERS:null,DEGREES:null,PIXELS:null,UnitPerMeter:null,MeterPerUnit:null,UnitNames:null,UnitAbbr:null,initialize:function(){this.INCHES=0;this.FEET=1;this.MILES=2;this.METERS=3;this.KILOMETERS=4;this.DEGREES=5;this.MERCATOR=6;this.UnitPerMeter=[39.37,3.2808,0.00062137,1.0,0.001,0.000009044,1.0];this.MeterPerUnit=[0.0254,0.3048,1609.3445,1.0,1000.0,110570,1.0];this.UnitNames=['Inches','Feet','Miles','Meters','Kilometers','Degrees','m'];this.UnitAbbr=['in','ft','mi','m','km','&deg;','m'];},ConvertUnits:function(unitsIn,unitsOut,value){if(unitsIn>=0&&unitsIn<=6&&unitsOut>=0&&unitsOut<=6)
{return this.FromMeter(unitsOut,this.ToMeter(unitsIn,value));}
console.log(unitsIn+" "+unitsOut+" : something is wrong?");return false;},ToMeter:function(unit,value){if(unit>=0&&unit<=6)
{return(this.MeterPerUnit[unit]*value);}
return false;},FromMeter:function(unit,value){if(unit>=0&&unit<=6)
{return(this.UnitPerMeter[unit]*value);}
return false;},GetUnitsIndex:function(units){var szUnits=units.toLowerCase();for(var i=0;i<this.UnitNames.length;i++)
{if(this.UnitNames[i].toLowerCase()==szUnits)
{return i;}}},CLASS_NAME:"OpenLayers.Units"});OpenLayers.Control.MapTip=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOOL,delay:250,domObj:null,serverInfo:null,validScales:null,hover:true,draw:function(){if(this.hover){this.handler=new OpenLayers.Handler.Hover(this,{"hoverstart":this.trigger,'hoverend':this.end},{delay:this.delay});};},trigger:function(xy){if(this.validScales){var max=parseFloat(this.validScales[0]);var min=max;for(var i=1;i<this.validScales.length;i++){max=Math.max(max,parseFloat(this.validScales[i]));min=Math.min(min,parseFloat(this.validScales[i]));}
if(this.map.getScale()>max||this.map.getScale()<min){return;}}
var extents=this.map.getExtent();var szExtents='&IMGEXT='+extents['left']+'+'+
extents['bottom']+'+'+
extents['right']+'+'+
extents['top'];var szLayer='&LAYER='+this.serverInfo.symbol;var szImgSize='&IMGSIZE='+this.map.size.w+'+'+this.map.size.h;if(this.domObj){this.domObj.style.display='none';}
if(this.mapTipScript){document.getElementsByTagName('head')[0].removeChild(this.mapTipScript);}
this.mapTipScript=document.createElement('script');document.getElementsByTagName('head')[0].appendChild(this.mapTipScript);this.mapTipScript.src=this.serverInfo.url+'?MAP='+this.serverInfo.map+'&MODE=QUERY'+'&IMG.X='+xy.x+'&IMG.Y='+xy.y+'&subst='+this.serverInfo.layer+'&theme='+this.serverInfo.theme+
szImgSize+szExtents+szLayer;},show:function(json){},hide:function(){if(this.domObj){this.domObj.style.display='none';}},end:function(){setTimeout(OpenLayers.Function.bind(this.hide,this),this.delay);},CLASS_NAME:"OpenLayers.Control.MapTip"});OpenLayers.Control.NavigationFBS=OpenLayers.Class(OpenLayers.Control.Navigation,{bShowFeedback:true,initialize:function(options){OpenLayers.Control.Navigation.prototype.initialize.apply(this,arguments);var d=document.createElement('div');d.id='zoomRects';d.style.position='absolute';var c=document.createElement('div');c.style.position='absolute';c.style.lineHeight=0;c.style.width='10px';c.style.height='10px';c.style.top='0px';c.style.left='0px';c.style.borderLeft='2px solid blue';c.style.borderTop='2px solid blue';d.appendChild(c);var c=document.createElement('div');c.style.position='absolute';c.style.lineHeight=0;c.style.width='10px';c.style.height='10px';c.style.top='0px';c.style.right='0px';c.style.borderRight='2px solid blue';c.style.borderTop='2px solid blue';d.appendChild(c);var c=document.createElement('div');c.style.position='absolute';c.style.lineHeight=0;c.style.width='10px';c.style.height='10px';c.style.bottom='0px';c.style.right='0px';c.style.borderBottom='2px solid blue';c.style.borderRight='2px solid blue';d.appendChild(c);var c=document.createElement('div');c.style.position='absolute';c.style.lineHeight=0;c.style.width='10px';c.style.height='10px';c.style.bottom='0px';c.style.left='0px';c.style.borderLeft='2px solid blue';c.style.borderBottom='2px solid blue';d.appendChild(c);this.zoomInRect=d;d=document.createElement('div');d.id='zoomRects';d.style.position='absolute';var c=document.createElement('div');c.style.position='absolute';c.style.lineHeight=0;c.style.width='10px';c.style.height='10px';c.style.top='0px';c.style.left='0px';c.style.borderRight='2px solid blue';c.style.borderBottom='2px solid blue';d.appendChild(c);var c=document.createElement('div');c.style.position='absolute';c.style.lineHeight=0;c.style.width='10px';c.style.height='10px';c.style.top='0px';c.style.right='0px';c.style.borderLeft='2px solid blue';c.style.borderBottom='2px solid blue';d.appendChild(c);var c=document.createElement('div');c.style.position='absolute';c.style.lineHeight=0;c.style.width='10px';c.style.height='10px';c.style.bottom='0px';c.style.right='0px';c.style.borderTop='2px solid blue';c.style.borderLeft='2px solid blue';d.appendChild(c);var c=document.createElement('div');c.style.position='absolute';c.style.lineHeight=0;c.style.width='10px';c.style.height='10px';c.style.bottom='0px';c.style.left='0px';c.style.borderRight='2px solid blue';c.style.borderTop='2px solid blue';d.appendChild(c);this.zoomOutRect=d;},wheelChange:function(evt,deltaZ){this.zoomRectCanvas=this.map.viewPortDiv;var initialRect=null;if(this.timer){clearTimeout(this.timer);}else{this.cumulativeDelta=0;}
this.cumulativeDelta+=(deltaZ<0)?-1:1;if(this.cumulativeDelta<0){initialRect=this.zoomOutRect;}
if(this.cumulativeDelta>0){initialRect=this.zoomInRect;}
if(initialRect){var feedbackDelta=(this.cumulativeDelta-1);(feedbackDelta<0)?feedbackDelta*=2:feedbackDelta*=20;initialRect.style.top=evt.xy.y-Math.max(10,50+feedbackDelta)+'px';initialRect.style.left=evt.xy.x-Math.max(10,50+feedbackDelta)+'px';initialRect.style.width=Math.max(20,100+2*feedbackDelta)+'px';initialRect.style.height=Math.max(20,100+2*feedbackDelta)+'px';this.zoomRectCanvas.appendChild(initialRect);this.currentRect=initialRect;}
this.timer=setTimeout(OpenLayers.Function.bind(function(){this.doIt(evt,deltaZ);},this),200);},doIt:function(evt,deltaZ){this.timer=null;var newZoom=this.map.getZoom()+this.cumulativeDelta;if(this.cumulativeDelta==0){return;}
var maxZoom=this.map.getNumZoomLevels()-1;if(!this.map.isValidZoomLevel(newZoom)){if(OpenLayers.Util.getElement('zoomRects')){this.zoomRectCanvas.removeChild(OpenLayers.Util.getElement('zoomRects'));}
if((newZoom<0&&this.map.getZoom()==0)||(newZoom>=maxZoom&&this.map.getZoom()==maxZoom)){return;}
newZoom=(newZoom<0)?0:maxZoom;}
var size=this.map.getSize();var deltaX=size.w/2-evt.xy.x;var deltaY=evt.xy.y-size.h/2;var newRes=this.map.baseLayer.getResolutionForZoom(newZoom);var zoomPoint=this.map.getLonLatFromPixel(evt.xy);var newCenter=new OpenLayers.LonLat(zoomPoint.lon+deltaX*newRes,zoomPoint.lat+deltaY*newRes);var direction=(deltaZ>0)?1:-1;if(this.bShowFeedback){var w=100-direction*25;var h=100-direction*25;var step=10;var frames=5;var d;if(this.currentRect){d=this.currentRect;this.currentRect=null;}else{if(direction==1){d=this.zoomInRect;}else{d=this.zoomOutRect;}
d.style.top=evt.xy.y-h/2+'px';d.style.left=evt.xy.x-w/2+'px';d.style.width=w+'px';d.style.height=h+'px';}
d.style.zIndex=1600;if(this.animationTimer){clearInterval(this.animationTimer);var rect=OpenLayers.Util.getElement('zoomRects');if(rect){this.zoomRectCanvas.removeChild(rect);}
if(d.canvas){d.canvas=null;}}
d.canvas=this.zoomRectCanvas;this.zoomRectCanvas.appendChild(d);this.animationTimer=setInterval(OpenLayers.Function.bind(function(){if(!d.canvas){clearInterval(this.animationTimer);this.animationTimer=null;return;}
if(this.currentDirection&&this.currentDirection!=direction){frames=0;}
this.currentDirection=direction;var t=parseInt(d.style.top)-(direction*step/2);var l=parseInt(d.style.left)-(direction*step/2);var w=parseInt(d.style.width)+(direction*step);var h=parseInt(d.style.height)+(direction*step);if(w>0&&h>0&&frames>0){d.style.top=t+'px';d.style.left=l+'px';d.style.width=w+'px';d.style.height=h+'px';frames--;}else{clearInterval(this.animationTimer);if(d.canvas){d.canvas.removeChild(d);d.canvas=null;}
this.animationTimer=null;this.currentDirection=null;}},this),75);}
this.map.setCenter(newCenter,newZoom);},CLASS_NAME:"OpenLayers.Control.NavigationFBS"});OpenLayers.Handler.MouseWheel.prototype.onWheelEvent=function(e){if(!this.map||!this.checkModifiers(e)){return;}
var overScrollableDiv=false;var overLayerDiv=false;var overMapDiv=false;var elem=OpenLayers.Event.element(e);while((elem!=null)&&!overMapDiv&&!overScrollableDiv){if(!overScrollableDiv){try{if(elem.currentStyle){overflow=elem.currentStyle["overflow"];}else{var style=document.defaultView.getComputedStyle(elem,null);var overflow=style.getPropertyValue("overflow");}
overScrollableDiv=(overflow&&(overflow=="auto")||(overflow=="scroll"));}catch(err){}}
if(!overLayerDiv){for(var i=0;i<this.map.layers.length;i++){if(elem==this.map.layers[i].div||elem==this.map.layers[i].pane||elem.id=='zoomRects'){overLayerDiv=true;break;}}}
overMapDiv=(elem==this.map.div);elem=elem.parentNode;}
if(!overScrollableDiv&&overMapDiv){if(overLayerDiv){this.wheelZoom(e);}
OpenLayers.Event.stop(e);}};OpenLayers.Control.PanZoomBarFBS=OpenLayers.Class(OpenLayers.Control.PanZoomBar,{zoomStopWidth:18,zoomStopHeight:11,zoomEndWidth:18,zoomEndHeight:18,panImgDim:18,slider:null,initialize:function(){OpenLayers.Control.PanZoomBar.prototype.initialize.apply(this,arguments);},draw:function(px){OpenLayers.Control.prototype.draw.apply(this,arguments);px=this.position.clone();this.buttons=[];var sz=new OpenLayers.Size(this.panImgDim,this.panImgDim);var szZoom=new OpenLayers.Size(this.zoomEndWidth,this.zoomEndHeight);var centered=new OpenLayers.Pixel(px.x+sz.w/2,px.y);var northButton=this.panNorthImg||'north-mini.png';var eastButton=this.panEastImg||'east-mini.png';var westButton=this.panWestImg||'west-mini.png';var southButton=this.panSouthImg||'south-mini.png';var zoomInButton=this.zoomInImg||'zoom-plus-mini.png';var zoomOutButton=this.zoomOutImg||'zoom-minus-mini.png';this._addButton("panup",northButton,centered,sz);px.y=centered.y+sz.h;this._addButton("panleft",westButton,px,sz);this._addButton("panright",eastButton,px.add(sz.w,0),sz);this._addButton("pandown",southButton,centered.add(0,sz.h*2),sz);this._addButton("zoomin",zoomInButton,centered.add(0,sz.h*3),szZoom);centered=this._addZoomBar(centered.add(0,sz.h*4+(szZoom.h-26)));this._addButton("zoomout",zoomOutButton,centered,szZoom);return this.div;},_addButton:function(id,img,xy,sz){var imgLocation=(this.imgUrl)?this.imgUrl+img:OpenLayers.Util.getImagesLocation()+img;var btn=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_PanZoom_"+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;btn.slideFactor=this.slideFactor;this.buttons.push(btn);return btn;},_addZoomBar:function(centered){var imgLocation=this.imgUrl||OpenLayers.Util.getImagesLocation();var sliderImg=this.sliderImg||"slider.png";var zoombarImg=this.zoombarImg||"zoombar.png";var id="OpenLayers_Control_PanZoomBar_Slider"+this.map.id;var zoomsToEnd=this.map.getNumZoomLevels()-1-this.map.getZoom();var slider=OpenLayers.Util.createAlphaImageDiv(id,centered.add(0,zoomsToEnd*this.zoomStopHeight),new OpenLayers.Size(this.zoomStopWidth,this.zoomStopHeight),imgLocation+sliderImg,"absolute");this.slider=slider;this.sliderEvents=new OpenLayers.Events(this,slider,null,true,{includeXY:true});this.sliderEvents.register("mousedown",this,this.zoomBarDown);this.sliderEvents.register("mousemove",this,this.zoomBarDrag);this.sliderEvents.register("mouseup",this,this.zoomBarUp);this.sliderEvents.register("dblclick",this,this.doubleClick);this.sliderEvents.register("click",this,this.doubleClick);sz=new OpenLayers.Size();sz.h=this.zoomStopHeight*this.map.getNumZoomLevels();sz.w=this.zoomStopWidth;var div=null
if(OpenLayers.Util.alphaHack()){var id="OpenLayers_Control_PanZoomBarFBS"+this.map.id;div=OpenLayers.Util.createAlphaImageDiv(id,centered,new OpenLayers.Size(sz.w,this.zoomStopHeight),imgLocation+zoombarImg,"absolute",null,"crop");div.style.height=sz.h;}else{div=OpenLayers.Util.createDiv('OpenLayers_Control_PanZoomBarFBS_Zoombar'+this.map.id,centered,sz,imgLocation+zoombarImg);}
div.style.backgroundRepeat="repeat-y";this.zoombarDiv=div;this.divEvents=new OpenLayers.Events(this,div,null,true,{includeXY:true});this.divEvents.register("mousedown",this,this.divClick);this.divEvents.register("mousemove",this,this.passEventToSlider);this.divEvents.register("dblclick",this,this.doubleClick);this.divEvents.register("click",this,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;},CLASS_NAME:"OpenLayers.Control.PanZoomBarFBS"});OpenLayers.Control.ModifyFeatureFBS=OpenLayers.Class(OpenLayers.Control.ModifyFeature,{dragVertex:function(vertex){if(this.feature.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"){if(this.feature!=vertex){this.feature=vertex;}}else{if(vertex._index){vertex.geometry.parent.addComponent(vertex.geometry,vertex._index);delete vertex._index;OpenLayers.Util.removeItem(this.virtualVertices,vertex);this.vertices.push(vertex);}else if(vertex==this.dragHandle){this.layer.removeFeatures(this.vertices);this.vertices=[];if(this.radiusHandle){this.layer.destroyFeatures([this.radiusHandle]);this.radiusHandle=null;}}else if(this.feature.attributes.type=='rectangle'&&this.feature.geometry.components&&this.feature.geometry.components.length){this.layer.removeFeatures(this.vertices);var lring=this.feature.geometry.components[0].components;for(var i=lring.length-1;i>=0;i--){if(lring[i].id==vertex.geometry.id){break;}}
if(i%2){lring[i-1].y=lring[i].y;lring[i-1].clearBounds();lring[i+1].x=lring[i].x;}else{lring[i-1].x=lring[i].x;i=i%4;lring[i+1].y=lring[i].y;}
for(var i=lring.length-1;i>=0;i--){lring[i].clearBounds();}}
if(this.virtualVertices.length>0){this.layer.destroyFeatures(this.virtualVertices);this.virtualVertices=[];}
this.layer.drawFeature(this.feature,this.selectControl.renderIntent);}
this.layer.drawFeature(vertex);},collectVertices:function(){this.vertices=[];this.virtualVertices=[];var control=this;function collectComponentVertices(geometry){var i,vertex,component;if(geometry.CLASS_NAME=="OpenLayers.Geometry.Point"){vertex=new OpenLayers.Feature.Vector(geometry);control.vertices.push(vertex);}else{var numVert=geometry.components.length;if(geometry.CLASS_NAME=="OpenLayers.Geometry.LinearRing"){numVert-=1;}
for(i=0;i<numVert;++i){component=geometry.components[i];if(component.CLASS_NAME=="OpenLayers.Geometry.Point"){vertex=new OpenLayers.Feature.Vector(component);control.vertices.push(vertex);}else{collectComponentVertices(component);}}
if(geometry.CLASS_NAME!="OpenLayers.Geometry.MultiPoint"&&control.feature.attributes.type!='rectangle'){for(i=0;i<geometry.components.length-1;++i){var prevVertex=geometry.components[i];var nextVertex=geometry.components[i+1];if(prevVertex.CLASS_NAME=="OpenLayers.Geometry.Point"&&nextVertex.CLASS_NAME=="OpenLayers.Geometry.Point"){var x=(prevVertex.x+nextVertex.x)/2;var y=(prevVertex.y+nextVertex.y)/2;var point=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(x,y),null,control.styleVirtual);point.geometry.parent=geometry;point._index=i+1;control.virtualVertices.push(point);}}}}}
collectComponentVertices.call(this,this.feature.geometry);this.layer.addFeatures(this.vertices,{silent:true});this.layer.addFeatures(this.virtualVertices,{silent:true});},collectRadiusHandle:function(){var geometry=this.feature.geometry;var bounds=geometry.getBounds();var center=bounds.getCenterLonLat();var control=this;var feature=this.feature;var originGeometry=new OpenLayers.Geometry.Point(center.lon,center.lat);var resizeHandleOffset=0;if(feature.attributes.type=='radius'){resizeHandleOffset=Math.sqrt(2*Math.pow(feature.attributes.displayRadius,2))/2;}
var radiusGeometry=new OpenLayers.Geometry.Point(bounds.right+resizeHandleOffset,bounds.bottom+resizeHandleOffset);var radius=new OpenLayers.Feature.Vector(radiusGeometry);var resize=(this.mode&OpenLayers.Control.ModifyFeature.RESIZE);var rotate=(this.mode&OpenLayers.Control.ModifyFeature.ROTATE);radiusGeometry.move=function(x,y){OpenLayers.Geometry.Point.prototype.move.call(this,x,y);var dx1=this.x-originGeometry.x;var dy1=this.y-originGeometry.y;var dx0=dx1-x;var dy0=dy1-y;if(rotate){var a0=Math.atan2(dy0,dx0);var a1=Math.atan2(dy1,dx1);var angle=a1-a0;angle*=180/Math.PI;geometry.rotate(angle,originGeometry);}
if(resize){var l0=Math.sqrt((dx0*dx0)+(dy0*dy0));var l1=Math.sqrt((dx1*dx1)+(dy1*dy1));geometry.resize(l1/l0,originGeometry);if(feature.attributes.type=='radius'){feature.style.pointRadius=l1/feature.layer.map.getResolution();feature.attributes.displayRadius=l1;if(feature.attributes.signBoardClass){control._setSignBoard(feature);};};}};this.radiusHandle=radius;this.layer.addFeatures([this.radiusHandle],{silent:true});},_setSignBoard:function(feature){if(!feature.sbg){feature.sbg=new OpenLayers.SignBoardGroup(this.map);};switch(feature.attributes.type){case'radius':if(feature.sbg.signboards.length==0){feature.sbg.addSignBoard(new OpenLayers.LonLat(0,0),'',-20,-8,2002);};var sb=feature.sbg.signboards[0];var radius=feature.style.pointRadius*feature.layer.map.getResolution();var map=this.map;var mapController=map.mapController;var units=mapController.units;sb.lonlat.lon=feature.geometry.components[0].x+parseFloat(radius);sb.lonlat.lat=feature.geometry.components[0].y;var szUnitAbbr=null;var Rad=null;var rad=mapController._convertLengthUnits(radius,mapController.sb_unitType,map.units);sb.content='<div class="'+feature.attributes.signBoardClass+'">'+Math.round(rad.dimension*100)/100+' '+rad.units+'</div>';break;case'rect':break;default:break;};feature.sbg.draw();},CLASS_NAME:"OpenLayers.Control.ModifyFeatureFBS"});OpenLayers.Control.Query=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOOL,callback:null,draw:function(){this.handler=new OpenLayers.Handler.Click(this,{click:this.goCallback});},activate:function(){this.handler.activate();},deactivate:function(){this.handler.deactivate();},setCallBack:function(callback){this.callback=callback;},goCallback:function(evt){if(this.callback){var lonlat=this.map.getLonLatFromViewPortPx(evt.xy);if(this.map.units=='m'){var lonlat=OpenLayers.Layer.SphericalMercator.inverseMercator(lonlat.lon,lonlat.lat);}
this.callback(new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat));}},CLASS_NAME:"OpenLayers.Control.Query"});OpenLayers.Control.Ruler=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOOL,setUnits:function(szUnits){rulerUnits=oUnits.GetUnitsIndex(szUnits);},setStyle:function(oStyle){oRulerStyle=oStyle;},setSBClassName:function(szClassName){szSBClassName=szClassName;},draw:function(){this.handler=new OpenLayers.Handler.Path(this,{done:this.clearRuler});this.handler.zoomEnd=this.zoomEnd;this.handler.activate=function(){if(!OpenLayers.Handler.prototype.activate.apply(this,arguments)){return false;}
var options={displayInLayerSwitcher:false};this.layer=new OpenLayers.Layer.Vector(this.CLASS_NAME,options);this.map.addLayer(this.layer);this.map.div.style.cursor='crosshair';totalSignBoard.style.left='-1000px';totalSignBoard.style.top='-1000px';totalSignBoard.style.visibility='visible';this.style=oRulerStyle;this.map.events.register('zoomend',this,this.zoomEnd);return true;};this.handler.deactivate=function(){if(!OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){return false;}
if(this.drawing){this.cancel();}
this.map.removeLayer(this.layer,false);this.layer.destroy();this.layer=null;totalSignBoard.style.visibility='hidden';dRulerTotalDist=0;dRulerCurTotalDist=0;dRulerSegDist=0;rulerDrawTotalBoard();for(var i=0;i<aszRulerSegIds.length;i++){this.map.layerContainerDiv.removeChild(OpenLayers.Util.getElement(aszRulerSegIds[i]));}
aszRulerSegIds=[];this.map.div.style.cursor='default';this.lastUp=null;this.lastDown=null;this.map.events.unregister('zoomend',this,this.zoomEnd);return true;};this.handler.mousedown=function(evt){if(this.lastDown&&this.lastDown.equals(evt.xy)){return false;}
if(this.lastDown==null){this.createFeature(evt.xy);}
this.mouseDown=true;this.lastDown=evt.xy;var lonlat=this.control.map.getLonLatFromPixel(evt.xy);this.point.geometry.x=lonlat.lon;this.point.geometry.y=lonlat.lat;if((this.lastUp==null)||!this.lastUp.equals(evt.xy)){this.addPoint(evt.xy);}
this.drawFeature();this.drawing=true;if(this.lastUp){var d=document.createElement('div');d.id='segment'+aszRulerSegIds.length;var dTempSegDist=Math.round(dRulerSegDist*100)/100;var dTempUnits=rulerUnits;if(dRulerSegDist<1&&oUnits.UnitAbbr[rulerUnits]=='mi')
{dTempSegDist=Math.round(dRulerSegDist*5280);dTempUnits=oUnits.FEET;}
d.innerHTML=dTempSegDist+' '+oUnits.UnitAbbr[dTempUnits];d.style.position='absolute';d.style.zIndex=700;d.style.whiteSpace='nowrap';if(szSBClassName=='')
{d.color="#FF8C00";d.style.backgroundColor="#FFFFFF";d.style.border='1px solid #FF8C00';d.style.padding="1";d.style.lineHeight="11px";d.style.fontFamily="arial";d.style.fontSize="11px";d.style.fontWeight='bold';d.style.textAlign="center";d.style.width="70px";d.style.height="11px";}
else
{d.className=szSBClassName;}
var viewPortXYPos=new OpenLayers.Pixel(((this.lastUp.x-this.lastDown.x)/2)+this.lastDown.x-35,((this.lastUp.y-this.lastDown.y)/2)+this.lastDown.y-5);var newXY=this.map.getLayerPxFromViewPortPx(viewPortXYPos);d.style.left=newXY.x+'px';d.style.top=newXY.y+'px';this.map.layerContainerDiv.appendChild(d);aszRulerSegIds.push(d.id);}
dRulerTotalDist=dRulerTotalDist+dRulerSegDist;dRulerSegDist=0;rulerDrawTotalBoard();return false;};this.handler.mousemove=function(evt){if(this.drawing){var lonlat=this.map.getLonLatFromPixel(evt.xy);this.point.geometry.x=lonlat.lon;this.point.geometry.y=lonlat.lat;if(this.mouseDown&&this.freehandMode(evt)){this.addPoint(evt.xy);}else{this.modifyFeature(evt.xy);}
this.drawFeature();if(this.lastUp){dRulerSegDist=0;var prevlonlat=this.map.getLonLatFromPixel(this.lastUp);if(this.map.units=='m')
{prevlonlat=prevlonlat.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));lonlat=lonlat.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));}
dRulerSegDistVincenty=OpenLayers.Util.distVincenty(prevlonlat,lonlat)*1000;dRulerSegDist=oUnits.ConvertUnits(oUnits.METERS,rulerUnits,dRulerSegDistVincenty);}
dRulerCurTotalDist=dRulerTotalDist+dRulerSegDist;rulerDrawTotalBoard();}
var newXY=this.map.getLayerPxFromViewPortPx(evt.xy);totalSignBoard.style.left=(newXY.x+10)+'px';totalSignBoard.style.top=(newXY.y-10)+'px';return true;};totalSignBoard=document.createElement('div');totalSignBoard.id='rulerTotal';totalSignBoard.style.position='absolute';totalSignBoard.style.zIndex=700;totalSignBoard.style.visibility='hidden';totalSignBoard.style.left='-1000px';totalSignBoard.style.top='-1000px';totalSignBoard.style.whiteSpace='nowrap';rulerDrawTotalBoard();this.map.layerContainerDiv.appendChild(totalSignBoard);},zoomEnd:function(){this.deactivate();this.activate();},clearRuler:function(xy){dRulerTotalDist=0;dRulerCurTotalDist=0;dRulerSegDist=0;rulerDrawTotalBoard();for(var i=0;i<aszRulerSegIds.length;i++){this.map.layerContainerDiv.removeChild(OpenLayers.Util.getElement(aszRulerSegIds[i]));}
aszRulerSegIds=[];},CLASS_NAME:"OpenLayers.Control.Ruler"});var oUnits=new OpenLayers.Units();var rulerUnits=oUnits.MILES;var aszRulerSegIds=[];var totalSignBoard=null;var dRulerTotalDist=0;var dRulerCurTotalDist=0;var dRulerSegDist=0;var oRulerStyle=null;var szSBClassName='';var rulerDrawTotalBoard=function(){var dTempSegDist=Math.round(dRulerSegDist*100)/100;var dTempUnits=rulerUnits;var dTempTotalDist=Math.round(dRulerCurTotalDist*100)/100;var dTempTotalUnits=rulerUnits;if(dRulerSegDist<1&&oUnits.UnitAbbr[rulerUnits]=='mi')
{dTempSegDist=Math.round(dRulerSegDist*5280);dTempUnits=oUnits.FEET;}
if(dRulerCurTotalDist<1&&oUnits.UnitAbbr[rulerUnits]=='mi')
{dTempTotalDist=Math.round(dRulerCurTotalDist*5280);dTempTotalUnits=oUnits.FEET;}
if(szSBClassName!='')
{totalSignBoard.className=szSBClassName;}
else
{totalSignBoard.style.border='1px solid #000000';totalSignBoard.style.backgroundColor='#ffffff';totalSignBoard.style.padding="2px";totalSignBoard.style.lineHeight="11px";totalSignBoard.style.fontFamily="arial";totalSignBoard.style.fontSize="11px";}
totalSignBoard.innerHTML="<table>"+"<tr><td align='right'>segment:</td>"+"<td>"+dTempSegDist+" "+oUnits.UnitAbbr[dTempUnits]+"</td></tr>"+"<tr><td align='right'>total:</td>"+"<td>"+dTempTotalDist+" "+oUnits.UnitAbbr[dTempTotalUnits]+"</td></tr>"+"</table>";};OpenLayers.Handler.Hover=OpenLayers.Class(OpenLayers.Handler,{buttonDown:false,hovering:false,delay:250,initialize:function(control,callbacks,options){OpenLayers.Handler.prototype.initialize.apply(this,arguments);},hover:function(evt){if(this.timer){this.timer=null;this.callback('hoverstart',[evt.xy]);this.hovering=true;}},mousedown:function(evt){this.buttonDown=true;if(this.timer){window.clearTimeout(this.timer);}
if(this.hovering){this.hovering=false;this.callback('hoverend',[]);}
return true;},mousemove:function(evt){if(this.hovering){this.hovering=false;this.callback('hoverend',[]);}
if(!this.buttonDown){if(this.timer){window.clearTimeout(this.timer);}
this.timer=window.setTimeout(OpenLayers.Function.bind(this.hover,this,evt),this.delay);}
return true;},mouseup:function(evt){this.buttonDown=false;if(this.hovering){this.hovering=false;this.callback('hoverend',[]);}
return true;},mouseout:function(evt){if(this.started&&OpenLayers.Util.mouseLeft(evt,this.map.div)){this.hovering=false;if(this.hovering){this.hovering=false;this.callback('hoverout',[]);}}
return true;},activate:function(){var activated=false;if(OpenLayers.Handler.prototype.activate.apply(this,arguments)){this.hovering=false;activated=true;}
return activated;},deactivate:function(){var deactivated=false;if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){this.buttonDown=false;this.hovering=false;deactivated=true;}
return deactivated;},CLASS_NAME:"OpenLayers.Handler.Hover"});OpenLayers.Handler.Radius=OpenLayers.Class(OpenLayers.Handler.Point,{line:null,radius:null,radiusStyle:null,measureClass:null,freehand:false,freehandToggle:'shiftKey',initialize:function(control,callbacks,options){OpenLayers.Handler.Point.prototype.initialize.apply(this,arguments);if(this.control.measureClass){this.unitType=this.control.unitType||'imperial';this.signBoardGroup=new OpenLayers.SignBoardGroup(this.control.layer.map);this.units=new OpenLayers.Units();}},createFeature:function(){this.line=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPoint());this.point=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point());this.radius=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point());this.radiusStyle=OpenLayers.Util.extend({},this.style);this.radiusStyle.pointRadius=0;if(this.signBoardGroup){this.signBoard=this.signBoardGroup.addSignBoard(new OpenLayers.LonLat(0,0),'',-20,-8,2002);}
this.layer.addFeatures([this.line],{silent:true});},destroyFeature:function(){OpenLayers.Handler.Point.prototype.destroyFeature.apply(this);},addPoint:function(){this.line.geometry.addComponent(this.point.geometry.clone(),this.line.geometry.components.length);this.radius.geometry=this.line.geometry.components[0];},freehandMode:function(evt){return(this.freehandToggle&&evt[this.freehandToggle])?!this.freehand:this.freehand;},modifyFeature:function(){var index=this.line.geometry.components.length-1;this.line.geometry.components[index].x=this.point.geometry.x;this.line.geometry.components[index].y=this.point.geometry.y;this.line.geometry.components[index].clearBounds();var radius=Math.sqrt(Math.pow(this.point.geometry.x-this.line.geometry.components[0].x,2)+
Math.pow(this.point.geometry.y-this.line.geometry.components[0].y,2));this.radiusStyle.pointRadius=radius/this.control.map.getResolution();var label=radius;if(this.control.map.units='m'){var center=OpenLayers.Layer.SphericalMercator.inverseMercator(this.line.geometry.components[0].x,this.line.geometry.components[0].y);var arc=OpenLayers.Layer.SphericalMercator.inverseMercator(this.point.geometry.x,this.point.geometry.y);label=OpenLayers.Util.distVincenty(center,arc)*1000;}
if(this.control.measureClass){this._setSignBoard(radius,label);this.signBoard.draw();}},_setSignBoard:function(radius,label){var sb=this.signBoard;sb.lonlat.lon=this.line.geometry.components[0].x+radius;sb.lonlat.lat=this.line.geometry.components[0].y;var szUnitAbbr=null;var Rad=null;if(this.unitType.toLowerCase()=='imperial')
{Rad=this.units.ConvertUnits(this.units.GetUnitsIndex(this.control.map.units),this.units.MILES,label);szUnitAbbr=this.units.UnitAbbr[this.units.MILES];if(Rad<0.5)
{Rad=Math.round(this.units.ConvertUnits(this.units.GetUnitsIndex(this.control.map.units),this.units.FEET,label));szUnitAbbr=this.units.UnitAbbr[this.units.FEET];}}
else
{Rad=this.units.ConvertUnits(this.units.GetUnitsIndex(this.control.map.units),this.units.KILOMETERS,label);szUnitAbbr=this.units.UnitAbbr[this.units.KILOMETERS];if(Rad<0.5)
{Rad=Math.round(this.units.ConvertUnits(this.units.GetUnitsIndex(this.control.map.units),this.units.METERS,label));szUnitAbbr=this.units.UnitAbbr[this.units.METERS];}}
sb.content='<div class="'+this.control.measureClass+'">'+Math.round(Rad*100)/100+' '+szUnitAbbr+'</div>';},drawFeature:function(){this.layer.drawFeature(this.radius,this.radiusStyle);},geometryClone:function(){return this.line.geometry.clone();},mousedown:function(evt){if(this.lastDown&&this.lastDown.equals(evt.xy)){return false;}
if(this.lastDown==null){this.createFeature();}
this.mouseDown=true;this.lastDown=evt.xy;var lonlat=this.control.map.getLonLatFromPixel(evt.xy);if(this.line.geometry.components.length==2){if(this.signBoardGroup){this.signBoardGroup.destroy();}
this.finalize();return false;}
this.point.geometry.x=lonlat.lon;this.point.geometry.y=lonlat.lat;if((this.lastUp==null)||!this.lastUp.equals(evt.xy)){this.addPoint();}
this.drawFeature();this.drawing=true;return false;},mousemove:function(evt){if(this.drawing){var lonlat=this.map.getLonLatFromPixel(evt.xy);this.point.geometry.x=lonlat.lon;this.point.geometry.y=lonlat.lat;if(this.mouseDown&&this.freehandMode(evt)){this.addPoint();}else{this.modifyFeature();}
this.drawFeature();}
return true;},mouseup:function(evt){this.mouseDown=false;if(this.drawing){if(this.freehandMode(evt)){this.finalize();}else{if(this.lastUp==null){this.addPoint();}
this.lastUp=evt.xy;}
return false;}
return true;},dblclick:function(evt){this.cancel();return false;},CLASS_NAME:"OpenLayers.Handler.Radius"});OpenLayers.Handler.Rect=OpenLayers.Class(OpenLayers.Handler.Point,{line:null,rect:null,freehand:false,freehandToggle:'shiftKey',initialize:function(control,callbacks,options){OpenLayers.Handler.Point.prototype.initialize.apply(this,arguments);},createFeature:function(){this.line=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPoint());this.point=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point());this.rect=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon());},destroyFeature:function(){if(this.rect){this.rect.destroy();}},addPoint:function(){this.line.geometry.addComponent(this.point.geometry.clone(),this.line.geometry.components.length);this.rect.geometry=new OpenLayers.Bounds(this.line.geometry.components[0].x,this.line.geometry.components[0].y,this.line.geometry.components[0].x,this.line.geometry.components[0].y).toGeometry();this.layer.addFeatures([this.rect],{silent:true});},freehandMode:function(evt){return(this.freehandToggle&&evt[this.freehandToggle])?!this.freehand:this.freehand;},modifyFeature:function(){var index=this.line.geometry.components.length-1;this.line.geometry.components[index].x=this.point.geometry.x;this.line.geometry.components[index].y=this.point.geometry.y;if(this.line.geometry.components.length==2){this.rect.geometry=new OpenLayers.Bounds(this.line.geometry.components[0].x,this.line.geometry.components[0].y,this.line.geometry.components[1].x,this.line.geometry.components[1].y).toGeometry();};},drawFeature:function(){this.layer.drawFeature(this.rect,this.style);},geometryClone:function(){return this.rect.geometry.clone();},mousedown:function(evt){if(this.lastDown&&this.lastDown.equals(evt.xy)){return false;}
if(this.lastDown==null){this.createFeature();}
this.mouseDown=true;this.lastDown=evt.xy;var lonlat=this.control.map.getLonLatFromPixel(evt.xy);if(this.line.geometry.components.length==2){this.finalize();return false;}
this.point.geometry.x=lonlat.lon;this.point.geometry.y=lonlat.lat;if((this.lastUp==null)||!this.lastUp.equals(evt.xy)){this.addPoint();}
this.drawFeature();this.drawing=true;return false;},mousemove:function(evt){if(this.drawing){var lonlat=this.map.getLonLatFromPixel(evt.xy);this.point.geometry.x=lonlat.lon;this.point.geometry.y=lonlat.lat;if(this.mouseDown&&this.freehandMode(evt)){this.addPoint();}else{this.layer.eraseFeatures(this.rect);this.modifyFeature();}
this.drawFeature();}
return true;},mouseup:function(evt){this.mouseDown=false;if(this.drawing){if(this.freehandMode(evt)){this.finalize();}else{if(this.lastUp==null){this.addPoint();}
this.lastUp=evt.xy;}
return false;}
return true;},dblclick:function(evt){this.cancel();return false;},CLASS_NAME:"OpenLayers.Handler.Rect"});OpenLayers.Layer.KaMapFBS=OpenLayers.Class(OpenLayers.Layer.KaMap,{DEFAULT_PARAMS:{i:'png',map:'',group:'__base__',a:true},getURL:function(bounds){bounds=this.adjustBounds(bounds);var mapRes=this.map.getResolution();var scale=Math.round(this.map.getScale());var pX=Math.round(bounds.left/mapRes);var pY=-Math.round(bounds.top/mapRes);var p=this.params;var w=p.metaSize.w*p.tileSize.w;var h=p.metaSize.h*p.tileSize.h;var metaLeft=Math.floor(pX/w)*w;var metaTop=Math.floor(pY/h)*h;var metaMetaLeft=Math.floor(metaLeft/(p.metaSize.w*w))*p.metaSize.w*w;var metaMetaTop=Math.floor(metaTop/(p.metaSize.h*h))*p.metaSize.h*h;var metaTileId='t'+metaMetaTop+'/l'+metaMetaLeft+'/t'+metaTop+'/l'+metaLeft;var tileId="t"+pY+"l"+pX;var groupsDir=(p.group!='')?p.group.replace(/\W/g,'_'):'__base__';var dir='/'+p.map+'/'+scale+'/'+groupsDir+'/def/'+metaTileId+"/"+tileId;var imageExtension=this.params.i.toLowerCase().replace(/[\de]/g,'');dir+="."+imageExtension;var cacheDir=this.selectUrl(dir,this.url)+dir;if(p.a){this.handleAccounting();}
return cacheDir;},initGriddedTiles:function(){OpenLayers.Layer.KaMap.prototype.initGriddedTiles.apply(this,arguments);if(!this.map.navteqAccounting){var na;this.events.register("tileloaded",this,this.incrementTileCount);na={};na.mapSize=this.grid.length*this.grid[0].length;na.userInfo=(this.map.userInfo)?this.map.userInfo.join('|'):'';na.tileCount=0;na.tileLimit=na.mapSize*1;na.scriptTag=document.createElement('script');document.getElementsByTagName('head')[0].appendChild(na.scriptTag);this.map.navteqAccounting=na;}},handleAccounting:function(){if(this.map.navteqAccounting){var na;na=this.map.navteqAccounting;if(na.tileCount>=na.tileLimit){var nTiles=Math.floor(na.tileCount/na.tileLimit)*na.tileLimit;na.tileCount-=nTiles;var p=na.scriptTag.parentNode;p.removeChild(na.scriptTag);na.scriptTag=document.createElement('script');na.scriptTag.src='http://mapserv1.flexmls.com/flexmaps/www/accounting/accounting.php?mapsize='+na.mapSize+'&tiles='+na.tileLimit+"&seq="+Math.random()+"&CLIENT_KEY="+NAVTEQ_CLIENT_ID+'&USERINFO='+na.userInfo;p.appendChild(na.scriptTag);}}},incrementTileCount:function(){if(this.map.navteqAccounting){this.map.navteqAccounting.tileCount++;}},addTile:function(bounds,position){var url=this.getURL(bounds);var tile=new OpenLayers.Tile.Image(this,position,bounds,url,this.tileSize);this.addTileMonitoringHooks(tile);return tile;},CLASS_NAME:"OpenLayers.Layer.KaMapFBS"});var NAVTEQ_CLIENT_ID='0703913ece42ef16d40efe469f25abee';function fbsKaMap(szID,sMap){this.sMap=sMap;this.extentsHistory=[];this.currentExtentsIndex=0;this.bHistorySwitch=false;this.items=[];this.initialMarkerLayer=null;this.features=[];this.featureListeners=[];this.popupListeners=[];this.editListeners=[];this.dynamicLayer=null;this.options={};this.aInitialExtents=null;this.aCenter=null;this.toolset={};this.queryParams=[];this.aFeatureCanvases=[];this.initialFeatureCanvasLayer=null;this.mapTipDiv=null;this.aBaseResolutions=[];this.aResolutions=[];this.aTileServers=[];this.aMaxExtent=[];this.olMap=null;this.olLayer=null;this.dCurrentScale=null;this.tileFormat='png';this.controls=[];this.sb_className='';this.sb_unitType='imperial';this.sb_minSegLen=10;if(arguments.length==4){this.setOptions(arguments[3]);}
var scaleEffect=(this.zoomEffect==='scale')?'resize':null;var animateEffect=(this.zoomEffect==='animate');var mapOptionsGeographic={controls:this.controls,resolutions:this.aResolutions,maxExtent:new OpenLayers.Bounds(this.aMaxExtent[0],this.aMaxExtent[1],this.aMaxExtent[2],this.aMaxExtent[3]),maxResolution:'auto',theme:null};this.userProjection=new OpenLayers.Projection("EPSG:4326");this.mapProjection=new OpenLayers.Projection("EPSG:900913");this.transformUserToMap=function(input){input.transform(this.userProjection,this.mapProjection);};this.transformMapToUser=function(input){input.transform(this.mapProjection,this.userProjection);};var mapOptionsMercator={controls:this.controls,projection:new OpenLayers.Projection("EPSG:900913"),displayProjection:new OpenLayers.Projection("EPSG:4326"),units:"m",maxResolution:156543.0339,numZoomLevels:30,maxExtent:new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508.34),theme:null};this.olMap=new OpenLayers.Map(szID,mapOptionsMercator);this.olMap.mapController=this;this.olMap.userInfo=this.userInfo;if(this.aBaseScales){this.aBaseResolutions=this.scalesToResolutions(this.aBaseScales);};if(this.masterScales){this.aResolutions=this.scalesToResolutions(this.masterScales);};this.olGoogleLayer=null;if(typeof G_NORMAL_MAP!=='undefined'){var olGoogleOptions={isBaseLayer:true,maxResolution:156543.0339,buffer:1};var olGoogleParams={'type':this.googleLayerType,'sphericalMercator':this.sphericalMercator,'dragObject':true};if(this.zoomRange){OpenLayers.Util.extend(olGoogleParams,{MIN_ZOOM_LEVEL:this.zoomRange.min,MAX_ZOOM_LEVEL:this.zoomRange.max});}
this.olGoogleLayer=new OpenLayers.Layer.Google("Google Layer",olGoogleParams,olGoogleOptions);};this.olBingLayer=null;if(typeof VEMapStyle!=='undefined'){var olBingOptions={isBaseLayer:true,maxResolution:156543.0339,buffer:1};var olBingParams={'type':this.bingLayerType,'sphericalMercator':this.sphericalMercator,'dragObject':true};if(this.zoomRange){OpenLayers.Util.extend(olBingParams,{MIN_ZOOM_LEVEL:this.zoomRange.min,MAX_ZOOM_LEVEL:this.zoomRange.max});}
this.olBingLayer=new OpenLayers.Layer.VirtualEarth("Bing Layer",olBingParams,olBingOptions);};this.olLayer=new OpenLayers.Layer.KaMapFBS(sMap,this.aTileServers,{map:sMap,group:this.baseLayerName,i:this.tileFormat,tileSize:{w:256,h:256},metaSize:{w:24,h:24},sphericalMercator:this.sphericalMercator},{resolutions:this.aBaseResolutions,isBaseLayer:true,opacity:1.0,buffer:1,maxResolution:156543.0339,transitionEffect:scaleEffect});if(this.olGoogleLayer&&(this.commercialBaseLayer=='google')){this.olMap.addLayer(this.olGoogleLayer);this.addCommercialImageryLayer('google');}else if(this.olBingLayer&&this.commercialBaseLayer=='bing'){this.olMap.addLayer(this.olBingLayer);this.addCommercialImageryLayer('bing');}else{this.olMap.addLayer(this.olLayer);if(this.olGoogleLayer){this.olMap.addLayer(this.olGoogleLayer);}
if(this.olBingLayer){this.olMap.addLayer(this.olBingLayer);}}
if(this.aInitialExtents){var bounds=new OpenLayers.Bounds(parseFloat(this.aInitialExtents[0]),parseFloat(this.aInitialExtents[1]),parseFloat(this.aInitialExtents[2]),parseFloat(this.aInitialExtents[3]));if(this.olMap.units=='m'){this.transformUserToMap(bounds);};this.olMap.zoomToExtent(bounds);}else if(this.aCenter){var resolution=OpenLayers.Util.getResolutionFromScale(this.aCenter[2],this.olMap.units);if(parseFloat(resolution)){var center=new OpenLayers.LonLat(this.aCenter[0],this.aCenter[1]);if(this.olMap.units=='m'){this.transformUserToMap(center);};this.olMap.setCenter(center,this.olMap.getZoomForResolution(resolution,true));}}else{this.olMap.zoomToMaxExtent();}
this.scalebar=null;this.navigatorTool=null;this.mapTipTool=null;this.rubberBandTool=null;this.rulerTool=null;this.zoomer=null;this.units=new OpenLayers.Units();this.initialize(sMap);};fbsKaMap.prototype.initialize=function(sMap){this.olMap.events.register('moveend',this,this.processMoveEnd);this.olMap.events.register('movestart',this,this.processMoveStart);this.dCurrentScale=this.olMap.getScale();this.navigatorTool=new OpenLayers.Control.NavigationFBS();this.olMap.addControl(new OpenLayers.Control.KeyboardDefaults());this.olMap.addControl(this.navigatorTool);if(this.bRuler){this.toolset.ruler=new OpenLayers.Control.Ruler();if(this.oRulerStyle)
{this.toolset.ruler.setStyle(this.oRulerStyle);}
else
{this.toolset.ruler.setStyle({strokeColor:'#00ff00',fillColor:'#b4b4fa',fillOpacity:'0.5',strokeLinecap:'round','lineJoin':'round',strokeWidth:2,pointRadius:10});}
if(this.sb_className!='')
{this.toolset.ruler.setSBClassName(this.sb_className);}}
if(this.bScalebar){this.scalebar=new fbsScalebar(this.olMap,this.scalebarOptions);}
if(this.bZoom){this.zoomer=new OpenLayers.Control.PanZoomBarFBS(this.zoomOptions);this.olMap.addControl(this.zoomer);}
if(this.bRubberZoom){this.toolset.rubberBandZoom=new OpenLayers.Control.ZoomBox({map:this.olMap});this.rubberBandTool=this.toolset.rubberBandZoom;}
if(this.bQuery){var queryFn=this.queryCB||this.goQuery.bind(this);this.toolset.query=new OpenLayers.Control.Query({callback:queryFn});}
for(var key in this.toolset){this.olMap.addControl(this.toolset[key]);}
this.featureList=[];this.goPopup=null;this.initialized();};fbsKaMap.prototype.addCommercialImageryLayer=function(type){var provider=type||'google';this.olCommercialLayer=null;switch(provider){case'google':if(this.olGoogleLayer!=undefined){this.olMap.addLayer(this.olGoogleLayer);this.olMap.setBaseLayer(this.olGoogleLayer);this.olCommercialLayer=this.olGoogleLayer;}
break;case'bing':if(this.olBingLayer!=undefined){this.olMap.addLayer(this.olBingLayer);this.olMap.setBaseLayer(this.olBingLayer);this.olCommercialLayer=this.olBingLayer;}
break;default:return this.olCommercialLayer;break;};for(var i=0;i<this.olMap.layers.length;i++){this.olMap.layers[i].onMapResize();}
var zoom=this.olMap.getZoom();this.olMap.setCenter(this.olMap.getCenter(),zoom,false,true);return(this.olCommercialLayer);};fbsKaMap.prototype.removeCommercialImageryLayer=function(){if(this.olCommercialLayer){this.olMap.setBaseLayer(this.olLayer);}
return(this.olCommercialLayer==null);};fbsKaMap.prototype.resize=function(){this.olMap.updateSize();};fbsKaMap.prototype.switchMap=function(sMap){};fbsKaMap.prototype.scalesToResolutions=function(scales){var resolutions=[];for(var i=0;i<scales.length;i++){resolutions.push(OpenLayers.Util.getResolutionFromScale(scales[i],this.olMap.units));};return resolutions;};fbsKaMap.prototype.onInit=function(fn){this.initFunction=fn;};fbsKaMap.prototype.parseQueryString=function(){var s=window.location.search;if(s!='')
{s=s.substring(1);var p=s.split('&');for(var i=0;i<p.length;i++)
{var q=p[i].split('=');this.queryParams[q[0]]=q[1];}}};fbsKaMap.prototype.setOptions=function(o){this.options=o;this.featureLayerOpacity=(o.overlayOpacity!=null)?this.overlayOpacity=o.overlayOpacity:100;this.bScalebar=(o.scalebar!=null)?o.scalebar=='true':false;this.scalebarOptions=(o.scalebarOptions!=null)?o.scalebarOptions:{};this.bZoom=(o.zoom!=null)?o.zoom=='true':false;this.zoomOptions=(o.zoomOptions!=null)?o.zoomOptions:{imgUrl:"http://localhost/fbs-img/",zoomEndHeight:34,zoomEndWidth:26,zoomStopHeight:10,zoomStopWidth:26,panImgDim:26,panSouthImg:"button_pan_s.png",panNorthImg:"button_pan_n.png",panWestImg:"button_pan_w.png",panEastImg:"button_pan_e.png",zoomInImg:"slider_zoom_in.png",zoomOutImg:"slider_zoom_out.png",zoombarImg:"slide_c.png",sliderImg:"button_zoom_slide.png"};this.zoomEffect=o.zoomEffect;this.bRubberZoom=(o.rubberzoom!=null)?o.rubberzoom=='true':false;this.bRuler=(o.ruler!=null)?o.ruler=='true':false;this.oRulerStyle=(o.rulerStyle!=null)?o.rulerStyle:null;this.sb_className=(o.signBoardClass!=null)?o.signBoardClass:'';this.bQuery=(o.query!=null)?o.query=='true':false;this.queryCB=o.queryCallback;this.dynamicServer=(o.dynamicServer)?o.dynamicServer:'http://mapserv1.flexmls.com:9000/cgi-bin/mapserv?';this.dynamicMap=(o.dynamicMap)?o.dynamicMap:'/flexmaps/dynamic/map/dynamic.map';if(o.extents!=undefined){this.aInitialExtents=o.extents;}
if(o.center!=undefined){this.aCenter=o.center;}
if(o.markers!=undefined){this.items=o.markers;}
if(o.features!=undefined){this.features=o.features;}
if(o.resolutions!=undefined){this.aBaseResolutions=o.resolutions;}else if(o.scales!=undefined){this.aBaseScales=o.scales;}else{}
if(o.masterScales){this.masterScales=o.masterScales;};if(o.tileServers!=undefined){this.aTileServers=o.tileServers;}else{}
if(o.tileFormat!=undefined){this.tileFormat=o.tileFormat.substr(0,3).toLowerCase();}
if(o.commercialBaseLayer!=undefined){this.commercialBaseLayer=o.commercialBaseLayer;}
if(o.googleLayerType!=undefined){this.googleLayerType=o.googleLayerType;}
if(o.bingLayerType!=undefined){this.bingLayerType=o.bingLayerType;}
this.sphericalMercator=(o.projection!=undefined&&o.projection=='mercator')?true:false;if(o.commercialZoomRange){this.zoomRange=o.commercialZoomRange;};this.baseLayerName=o.baseLayer||"__base__";if(o.maxExtent!=undefined){this.aMaxExtent=o.maxExtent;}
this.myMapsSaveScript=o.myMapsSaveScript;this.myMapsLoadScript=o.myMapsLoadScript;this.myMapsSaveCallback=o.myMapsSaveCB||'fbsMyMapsSaveCB';this.myMapsLoadCallback=o.myMapsLoadCB||'fbsMyMapsLoadCB';this.userInfo=(o.userInfo instanceof Array)?o.userInfo:[];o=null;};fbsKaMap.prototype.initialized=function(){if(this.items.length){this.initialMarkerLayer=this.addMarkerCanvas('markers',3);for(var i=0;i<this.items.length;i++){var item=this.items[i];if(item.iconOptions){item.iconOptions.fbsid=item.fbsid;}
this.addObjectGeo(item.point,item.contentHTML,item.iconOptions);};}
this.staticFeatureCanvasLayer=this.addFeatureCanvas('vector-static',2);this.staticFeatureCanvasLayer.preFeatureInsert=OpenLayers.Function.bind(this._preFeatureInsert,this);this.initialFeatureCanvasLayer=this.addFeatureCanvas('vector',5);this.initialFeatureCanvasLayer.preFeatureInsert=OpenLayers.Function.bind(this._preFeatureInsert,this);for(var i=0;i<this.features.length;i++){var feature=this.features[i];var uid=this.features[i]['uid'];var targetCanvas=feature.isStatic?this.staticFeatureCanvasLayer:this.initialFeatureCanvasLayer;switch(feature.type){case'line':feature=this.addLine(feature['coords'],feature['style'],{canvas:targetCanvas,className:feature['measureClass']});break;case'polygon':feature=this.addPolygon(feature['coords'],feature['style'],{canvas:targetCanvas,className:feature['measureClass']});break;case'multipolygon':feature=this.addMultiPolygon(feature['coords'],feature['style'],{canvas:targetCanvas,className:feature['measureClass']});break;case'radius':feature=this.addRadius(feature['coords'],feature['radius'],feature['style'],{canvas:targetCanvas,className:feature['measureClass']});break;case'rectangle':feature=this.addRect(feature['coords'],feature['style'],{canvas:targetCanvas,className:feature['measureClass']});break;default:}
feature.uid=uid;this.features[i]=feature;};if(this.initFunction){this.initFunction();}};fbsKaMap.prototype.getMap=function(){return this.olMap;};fbsKaMap.prototype._preFeatureInsert=function(feature){if(feature.attributes){var style=OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default']);feature.style=OpenLayers.Util.extend(style,feature.attributes);}
var map=feature.layer.map;var mapController=map.mapController;var uproj=new OpenLayers.Projection("EPSG:4326");var mproj=new OpenLayers.Projection("EPSG:900913");var drawMeasure=function(){if(feature.attributes.signBoardClass){var className=feature.attributes.signBoardClass;var unitType=mapController.sb_unitType;var minSegLen=feature.attributes.minSegLen||mapController.sb_minSegLen;var minSegAngle=mapController.sb_minSegAngle||20;var signBoardCoords=feature.geometry.clone();var coords=signBoardCoords.components[0].components;var signBoardGroup=new OpenLayers.SignBoardGroup(map);var point1,point2,point3=null;var segLength=0;var szUnitAbbr='';var lastBrng=null;var nGroupSegLength=0;var nGroupPixSegLength=0;var dGroupAngle=0;var aoGroupSegs=[];var dCurrentDeltaAngle=0;coords.push(coords.shift());if(coords.length<2){return};for(var i=0;i<coords.length;i++){var midLon=null;var midLat=null;point1={lon:coords[i].x,lat:coords[i].y};point2={lon:coords[(i+1)%(coords.length)].x,lat:coords[(i+1)%(coords.length)].y};point3={lon:coords[(i+2)%(coords.length)].x,lat:coords[(i+2)%(coords.length)].y};var currentBearing=mapController.getBearing(point1,point2);var nextBearing=mapController.getBearing(point2,point3);dCurrentDeltaAngle=lastBrng?Math.abs(currentBearing-nextBearing):360;var p1=new OpenLayers.LonLat(point1.lon,point1.lat);var p2=new OpenLayers.LonLat(point2.lon,point2.lat);if(map.units=='m'){mapController.transformMapToUser(p1);mapController.transformMapToUser(p2);};segLength=OpenLayers.Util.distVincenty(p1,p2)*1000;if(segLength<=1){segLength=0;}
var myUnits=new OpenLayers.Units();segLength=myUnits.ConvertUnits(myUnits.METERS,myUnits.GetUnitsIndex(map.units),segLength);lastBrng=currentBearing;var segPixels1=map.getViewPortPxFromLonLat(new OpenLayers.LonLat(point1.lon,point1.lat));var segPixels2=map.getViewPortPxFromLonLat(new OpenLayers.LonLat(point2.lon,point2.lat));var pixSegLength=Math.pow(Math.pow(segPixels1.x-segPixels2.x,2)+
Math.pow(segPixels1.y-segPixels2.y,2),0.5);if(nGroupPixSegLength>0){if((dGroupAngle+dCurrentDeltaAngle)>=minSegAngle){pixSegLength+=nGroupPixSegLength;segLength+=nGroupSegLength;aoGroupSegs.push({x1:point1.lon,y1:point1.lat,x2:point2.lon,y2:point2.lat});var l=aoGroupSegs.length-1;midLon=Math.abs(aoGroupSegs[0].x1-aoGroupSegs[l].x1)/2+Math.min(aoGroupSegs[0].x1,aoGroupSegs[l].x1);midLat=Math.abs(aoGroupSegs[0].y1-aoGroupSegs[l].y1)/2+Math.min(aoGroupSegs[0].y1,aoGroupSegs[l].y1);nGroupSegLength=0;nGroupPixSegLength=0;dGroupAngle=0;aoGroupSegs=[];}else{nGroupSegLength+=segLength;nGroupPixSegLength+=pixSegLength;dGroupAngle+=dCurrentDeltaAngle;aoGroupSegs.push({x1:point1.lon,y1:point1.lat,x2:point2.lon,y2:point2.lat});continue;};}else{if(dCurrentDeltaAngle<minSegAngle){nGroupSegLength+=segLength;nGroupPixSegLength+=pixSegLength;dGroupAngle+=dCurrentDeltaAngle;aoGroupSegs.push({x1:point1.lon,y1:point1.lat,x2:point2.lon,y2:point2.lat});continue;};};if(pixSegLength<=minSegLen){nGroupSegLength+=segLength;nGroupPixSegLength+=pixSegLength;dGroupAngle+=dCurrentDeltaAngle;aoGroupSegs.push({x1:point1.lon,y1:point1.lat,x2:point2.lon,y2:point2.lat});continue;};segLength=mapController._convertLengthUnits(segLength,unitType,map.units);if(!midLon||!midLat){midLon=(point2.lon-point1.lon)/2+point1.lon;midLat=(point2.lat-point1.lat)/2+point1.lat;}
signBoardGroup.addSignBoard(new OpenLayers.LonLat(midLon,midLat),'<div class="'+className+'">'+
Math.round(segLength.dimension*100)/100+' '+segLength.units+'</div>',-20,-8,2000);feature.sbg=signBoardGroup;signBoardGroup.draw();};};};switch(feature.attributes.type){case'radius':var label='';if(feature.geometry.components&&feature.geometry.components.length==2){var origin=feature.geometry.components[0];var arcPoint=feature.geometry.components[1];var radius=(Math.sqrt(Math.pow(arcPoint.x-origin.x,2)+
Math.pow(arcPoint.y-origin.y,2)));feature.attributes.displayRadius=radius;feature.attributes.resolution=map.getResolution();feature.geometry.removePoint(feature.geometry.components[1]);label=radius;if(feature.layer.map.units='m'){var centerLocation=new OpenLayers.LonLat(origin.x,origin.y);var arcLocation=new OpenLayers.LonLat(arcPoint.x,arcPoint.y);centerLocation.transform(mproj,uproj);arcLocation.transform(mproj,uproj);label=OpenLayers.Util.distVincenty(centerLocation,arcLocation)*1000;}}else{radius=feature.attributes.displayRadius;label=feature.attributes.label||radius;};var radiusPx=radius/map.getResolution();feature.style.pointRadius=radiusPx;feature.geometry.toString=function(){var origin=new OpenLayers.LonLat(feature.geometry.components[0].x,feature.geometry.components[0].y);radius=feature.attributes.displayRadius;var majorR=radius;var minorR=radius;if(feature.layer.map.units='m'){var minorPoint=new OpenLayers.LonLat(origin.lon,origin.lat+radius);var majorPoint=new OpenLayers.LonLat(origin.lon+radius,origin.lat);origin.transform(mproj,uproj);minorPoint.transform(mproj,uproj);majorPoint.transform(mproj,uproj);majorR=Math.abs(majorPoint.lon-origin.lon);minorR=Math.abs(minorPoint.lat-origin.lat);};return'RADIUS(('+origin.lon+' '+origin.lat+'),('+majorR+','+minorR+'))';};feature.layer.map.events.register('zoomend',null,feature.zoomCallback=function(){var radiusPx=feature.attributes.displayRadius/map.getResolution();feature.style.pointRadius=radiusPx;feature.layer.redraw();});if(feature.attributes.signBoardClass){var className=feature.attributes.signBoardClass;var unitType=mapController.sb_unitType;var units=mapController.units;var minSegLen=mapController.sb_minSegLen;var pixSegLength=radiusPx;if(pixSegLength>minSegLen)
{var Area=0;var rad=mapController._convertLengthUnits(label,unitType,map.units);Area=Math.PI*Math.pow(rad.value,2);var signBoardGroup=new OpenLayers.SignBoardGroup(map);signBoardGroup.addSignBoard(new OpenLayers.LonLat(feature.geometry.components[0].x+parseFloat(radius),feature.geometry.components[0].y),'<div class="'+className+'">'+
Math.round(rad.dimension*100)/100+' '+rad.units,-20,-8,2000);feature.sbg=signBoardGroup;signBoardGroup.draw();};};break;case'rectangle':feature.geometry.toString=function(){var b=feature.geometry.getBounds().clone();if(feature.layer.map.units='m'){b.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));};return'RECTANGLE(('+b.left+' '+b.top+'),('+b.right+' '+b.bottom+'))';};drawMeasure();break;case'polygon':if(feature.layer.map.units='m'){feature.geometry.toString=function(){var geom=feature.geometry.clone().components[0];var result='POLYGON((';var sep='';for(var i=0;i<geom.components.length-1;i++){var g=geom.components[i];g.transform(mproj,uproj);result+=sep+g.x+' '+g.y;sep=',';};return result+'))';};};drawMeasure();break;case'multipolygon':for(var i=0;i<feature.geometry.components.length;i++){var polygon={geometry:feature.geometry.components[i]};polygon.attributes={'type':'polygon','signBoardClass':feature.attributes.signBoardClass};polygon.layer=feature.layer;this._preFeatureInsert(polygon);};break;case'line':if(feature.layer.map.units='m'){feature.geometry.toString=function(){var geom=feature.geometry.clone();var result='LINESTRING((';var sep='';for(var i=0;i<geom.components.length;i++){var g=geom.components[i];g.transform(mproj,uproj);result+=sep+g.x+' '+g.y;sep=',';};return result+'))';};};break;case'point':if(feature.layer.map.units='m'){feature.geometry.toString=function(){var g=feature.geometry.clone();g.transform(mproj,uproj);return'POINT(('+g.x+' '+g.y+'))';};};break;default:break;};};fbsKaMap.prototype._convertLengthUnits=function(length,unitType,mapUnits){var units=new OpenLayers.Units();var newLength;if(unitType.toLowerCase()=='imperial')
{newLength=units.ConvertUnits(units.GetUnitsIndex(mapUnits),units.MILES,length);var szUnitAbbr=units.UnitAbbr[units.MILES];if(newLength<0.5){newLength=Math.round(units.ConvertUnits(units.GetUnitsIndex(mapUnits),units.FEET,length));szUnitAbbr=units.UnitAbbr[units.FEET];}}else{newLength=units.ConvertUnits(units.GetUnitsIndex(mapUnits),units.KILOMETERS,length);var szUnitAbbr=units.UnitAbbr[units.KILOMETERS];if(newLength<0.5){newLength=Math.round(units.ConvertUnits(units.GetUnitsIndex(mapUnits),units.METERS,length));szUnitAbbr=units.UnitAbbr[units.METERS];};}
return{'dimension':newLength,'units':szUnitAbbr};};fbsKaMap.prototype.scaleChanged=function(eventid){};fbsKaMap.prototype.extentsChanged=function(){this.extentsHistory.splice(this.currentExtentsIndex,this.extentsHistory.length,this.getCenterZoomLevel());this.currentExtentsIndex++;};fbsKaMap.prototype.previousExtents=function(){if(this.currentExtentsIndex>0){if(this.currentExtentsIndex==this.extentsHistory.length){this.currentExtentsIndex--;}
this.currentExtentsIndex--;var extents=this.extentsHistory[this.currentExtentsIndex];if(extents){this.olMap.events.unregister('moveend',this,this.processMoveEnd);this.olMap.setCenter(extents.center,extents.zoom,false,false);this.olMap.events.register('moveend',this,this.processMoveEnd);}}};fbsKaMap.prototype.nextExtents=function(){if(this.currentExtentsIndex<this.extentsHistory.length){this.currentExtentsIndex++;var extents=this.extentsHistory[this.currentExtentsIndex];if(extents){this.olMap.events.unregister('moveend',this,this.processMoveEnd);this.olMap.setCenter(extents.center,extents.zoom,false,false);this.olMap.events.register('moveend',this,this.processMoveEnd);}}};fbsKaMap.prototype.getExtents=function(){var oExtent=this.olMap.getExtent();return[oExtent.left,oExtent.bottom,oExtent.right,oExtent.top];};fbsKaMap.prototype.getCenterZoomLevel=function(){return{zoom:this.olMap.getZoom(),center:this.olMap.getCenter()};};fbsKaMap.prototype.zoomTo=function(point,scale){var res=OpenLayers.Util.getResolutionFromScale(scale,this.olMap.baseLayer.units);var zoomIndex=this.olMap.getZoom();if(res){zoomIndex=this.olMap.getZoomForResolution(res,true);}
var location=new OpenLayers.LonLat(point[0],point[1]);if(this.sphericalMercator){this.transformUserToMap(location);}
this.olMap.setCenter(location,zoomIndex,false,false);if(this.currentExtentsIndex!=this.extentsHistory.length-1){this.extentsHistory.splice(this.currentExtentsIndex,this.extentsHistory.length-this.currentExtentsIndex);}};fbsKaMap.prototype.zoomToExtents=function(bbox,margin){if(margin){bbox.minx-=parseFloat(margin);bbox.maxx+=parseFloat(margin);bbox.miny-=parseFloat(margin);bbox.maxy+=parseFloat(margin);};var extents=new OpenLayers.Bounds(bbox.minx,bbox.miny,bbox.maxx,bbox.maxy);if(this.olMap.units=='m'){this.transformUserToMap(extents);};this.olMap.zoomToExtent(extents);};fbsKaMap.prototype.getLayers=function(){return this.olMap.layers;};fbsKaMap.prototype.getLayer=function(layer){for(var i=0;i<this.olMap.layers.length;i++){if(this.olMap.layers[i].name==layer){return this.olMap.layers[i];}};return null;};fbsKaMap.prototype.toggleVisibility=function(layer){layer.setVisibility(!layer.getVisibility());};fbsKaMap.prototype.getLegend=function(){var legend={mapLayers:[]};var aLayerSources=[];aLayerSources.push(this.getLayers());aLayerSources.push(this.aFeatureCanvases);for(var j=0;j<aLayerSources.length;j++){var layers=aLayerSources[j];for(var i=0;i<layers.length;i++){legend.mapLayers.push({name:layers[i][name],visibility:layers[i].visible,opacity:layers[i].opacity});}}
return legend;};fbsKaMap.prototype.addMarkerCanvas=function(name,idx){var canvas=new OpenLayers.Layer.Markers(name);this.olMap.addLayer(canvas);if(idx){this.olMap.setLayerZIndex(canvas,idx);}
this.olMap.resetLayersZIndex();return canvas;};fbsKaMap.prototype.removeMarkerCanvas=function(o){this.olMap.removeLayer(o);};fbsKaMap.prototype.removeMarker=function(uid){var marker=null;for(var i=0;i<this.items.length;i++){if(this.items[i].uid==uid){marker=this.items[i].marker;this.items.splice(i,1);if(marker){marker.destroy();}
return true;}};return false;};fbsKaMap.prototype.addObjectGeo=function(point,contentHTML,iconOptions,canvasId){if(this.initialMarkerLayer==null&&canvasId==null){this.initialMarkerLayer=this.addMarkerCanvas('initial_markers',2);}
var layer=this.olMap.getLayer(canvasId)||this.initialMarkerLayer;var size=iconOptions?new OpenLayers.Size(iconOptions.width,iconOptions.height):new OpenLayers.Size(34,34);var offset=iconOptions?new OpenLayers.Pixel(iconOptions.offsetX,iconOptions.offsetY):new OpenLayers.Pixel(-3,-30);var imgURL=iconOptions?iconOptions.imgUrl+iconOptions.imgSrc:'images/marker.png';var imgPath=iconOptions?iconOptions.imgUrl:'images';var location=new OpenLayers.LonLat(point.x,point.y);if(this.sphericalMercator){this.transformUserToMap(location);}
var icon=new OpenLayers.Icon(imgURL,size,offset);var feature=new OpenLayers.FeatureFBS(layer,location,{icon:icon,popupContentHTML:contentHTML,server:imgPath});var marker=feature.createMarker();if(contentHTML&&contentHTML!='')
{feature.popupClass=OpenLayers.PopupFBS.AnchoredBubble;var f=this._clickMarker.bind(this,feature);marker.events.register('click',null,f.bindAsEventListener(this));}
feature.fbsid=iconOptions&&iconOptions.fbsid;layer.addMarker(marker);this.featureList.push(feature);return feature.id;};fbsKaMap.prototype._clickMarker=function(feature,e)
{this.drawMarkerPopup(feature.id);OpenLayers.Event.stop(e);};fbsKaMap.prototype.addPopupListener=function(f)
{this.popupListeners.push(f);};fbsKaMap.prototype.drawMarkerPopup=function(nId)
{var feature=this.getObject(nId);if(feature&&feature.popupClass)
{if(this.goPopup!==null)
{this.olMap.removePopup(this.goPopup);this.goPopup.destroy();this.goPopup=null;}
this.goPopup=feature.createPopup(true);this.olMap.addPopup(this.goPopup);for(var i=0;i<this.popupListeners.length;i++)
{this.popupListeners[i](nId);}}};fbsKaMap.prototype.getObject=function(nId){for(var i=0;i<this.featureList.length;i++)
{if(this.featureList[i].id==nId)
{return this.featureList[i];}}
return null;};fbsKaMap.prototype.removeObject=function(nId){var newList=[];for(var i=0;i<this.featureList.length;i++)
{if(this.featureList[i].id!==nId)
{newList.push(this.featureList[i]);}
else
{if(this.goPopup!==null)
{if(this.goPopup.id==nId+'_popup'){this.goPopup=null;}}
this.featureList[i].layer.removeMarker(this.featureList[i].marker);this.featureList[i].destroy();}}
this.featureList=newList;};fbsKaMap.prototype.addFeatureCanvas=function(name,idx){var canvas=new OpenLayers.Layer.Vector(name);this.olMap.addLayer(canvas);if(idx){this.olMap.setLayerZIndex(canvas,idx);}
canvas.preFeatureInsert=OpenLayers.Function.bind(this._preFeatureInsert,this);this.aFeatureCanvases.push(canvas);return canvas;};fbsKaMap.prototype.removeFeatureCanvas=function(o){for(var i=0;i<this.aFeatureCanvases.length;i++){if(this.aFeatureCanvases[i]==o){this.olMap.removeLayer(o);this.aFeatureCanvases.splice(i,1);return;}}};fbsKaMap.prototype.clearFeatureCanvas=function(o){o.clear();return;};fbsKaMap.prototype.activateFeatureEditing=function(canvas){if(!this.toolset.edit){var setTool=function(o){var setMode=function(tool,feature,mode){tool.deactivate();tool.mode=mode;tool.activate();};if(o.feature.sbg){o.feature.sbg.destroy();o.feature.sbg=null;};canvas.events.un({"beforefeaturemodified":setTool,"featuremodified":revertZIndex,"featureunselected":reMeasure,"featureselected":revertZIndex,scope:this});switch(o.feature.attributes.type){case'point':setMode(this.toolset.edit,o.feature,OpenLayers.Control.ModifyFeature.DRAG);break;case'radius':setMode(this.toolset.edit,o.feature,OpenLayers.Control.ModifyFeature.RESIZE|OpenLayers.Control.ModifyFeature.DRAG);break;case'rectangle':case'multipolygon':case'polygon':setMode(this.toolset.edit,o.feature,OpenLayers.Control.ModifyFeature.RESHAPE|OpenLayers.Control.ModifyFeature.DRAG);break;case'line':default:setMode(this.toolset.edit,o.feature,OpenLayers.Control.ModifyFeature.RESHAPE);break;};canvas.events.on({"beforefeaturemodified":setTool,"featuremodified":revertZIndex,"featureunselected":reMeasure,"featureselected":revertZIndex,scope:this});};var reMeasure=function(o){o.feature.layer.map.mapController._callEditListeners(o.feature);if(o.feature.attributes.signBoardClass){if(o.feature.sbg){o.feature.sbg.destroy();o.feature.sbg=null;}
o.feature.layer.map.mapController._preFeatureInsert(o.feature);}};var revertZIndex=function(o){};this.toolset.edit=new OpenLayers.Control.ModifyFeatureFBS(canvas);canvas.events.on({"beforefeaturemodified":setTool,"featuremodified":reMeasure,"featureunselected":revertZIndex,"featureselected":revertZIndex,scope:this});this.olMap.addControl(this.toolset.edit);};this.toolset.edit.activate();};fbsKaMap.prototype.addEditListener=function(f){this.editListeners.push(f);}
fbsKaMap.prototype._callEditListeners=function(feature){for(var i=0;i<this.editListeners.length;i++){this.editListeners[i](feature);};};fbsKaMap.prototype.addRect=function(coords,style,options){var pointList=[];pointList.push(coords[0]);pointList.push([coords[1][0],coords[0][1]]);pointList.push(coords[1]);pointList.push([coords[0][0],coords[1][1]]);style.type='rectangle';var feature=this.addPolygon(pointList,style,options);return feature;};fbsKaMap.prototype.addPolygon=function(coords,style,options){if(typeof coords[0][0]=='object'){coords=coords[0];}
var canvas=null;if(!options||(options&&!options.canvas)){canvas=this.initialFeatureCanvasLayer;}else{canvas=options.canvas;}
var pointList=[];for(var i=0;i<coords.length;i++){if(this.olMap.units=='m'){}
var newPoint=new OpenLayers.Geometry.Point(coords[i][0],coords[i][1]);if(this.olMap.units=='m'){this.transformUserToMap(newPoint);}
pointList.push(newPoint);}
pointList.push(pointList[0]);var linearRing=new OpenLayers.Geometry.LinearRing(pointList);var feature=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([linearRing]),null,style);var measureClass=options&&options.className;var minSegLen=options&&options.minSegLen;feature.attributes=OpenLayers.Util.extend({'type':'polygon','signBoardClass':measureClass,'minSegLen':minSegLen},style);this.features.push(feature);canvas.addFeatures([feature]);return feature;};fbsKaMap.prototype.addMultiPolygon=function(components,style,options){var canvas=null;if(!options||(options&&!options.canvas)){canvas=this.initialFeatureCanvasLayer;}else{canvas=options.canvas;}
var measureClass=options&&options.className;var minSegLen=options&&options.minSegLen;var polygons=[]
for(var i=0;i<components.length;i++){var coords=components[i];if(typeof coords[0][0]=='object'){coords=coords[0];}
var pointList=[];for(var k=0;k<coords.length;k++){if(this.olMap.units=='m'){}
var newPoint=new OpenLayers.Geometry.Point(coords[k][0],coords[k][1]);if(this.olMap.units=='m'){this.transformUserToMap(newPoint);}
pointList.push(newPoint);}
pointList.push(pointList[0]);polygons.push(new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(pointList)]));};var feature=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPolygon(polygons),null,style);feature.attributes=OpenLayers.Util.extend({'type':'multipolygon','signBoardClass':measureClass,'minSegLen':minSegLen},style);this.features.push(feature);canvas.addFeatures([feature]);return feature;};fbsKaMap.prototype.addLine=function(coords,style,options){var canvas=null;if(!options||(options&&!options.canvas)){canvas=this.initialFeatureCanvasLayer;}else{canvas=options.canvas;}
if(options&&options.className){var unitType=this.sb_unitType;var minSegLen=this.sb_minSegLen;var className=options.className;if(options.unitType)
{unitType=options.unitType;}
if(options.minSegLen)
{minSegLen=options.minSegLen;}
var signBoardGroup=new OpenLayers.SignBoardGroup(this.olMap);var point1=null;var point2=null;var segLength=0;var szUnitAbbr='';for(var i=0;i<coords.length-1;i++)
{point1={lon:coords[i][0],lat:coords[i][1]};point2={lon:coords[i+1][0],lat:coords[i+1][1]};segLength=OpenLayers.Util.distVincenty(point1,point2)*1000;var myUnits=new OpenLayers.Units();segLength=myUnits.ConvertUnits(myUnits.METERS,myUnits.GetUnitsIndex(this.olMap.units),segLength);var segPixels1=this.olMap.getViewPortPxFromLonLat(new OpenLayers.LonLat(point1.lon,point1.lat));var segPixels2=this.olMap.getViewPortPxFromLonLat(new OpenLayers.LonLat(point2.lon,point2.lat));var pixSegLength=Math.pow(Math.pow(segPixels1.x-segPixels2.x,2)+Math.pow(segPixels1.y-segPixels2.y,2),0.5);if(pixSegLength<=minSegLen)
{continue;}
if(unitType.toLowerCase()=='imperial')
{segLength=this.units.ConvertUnits(this.units.GetUnitsIndex(this.olMap.units),this.units.MILES,segLength);szUnitAbbr=this.units.UnitAbbr[this.units.MILES];if(segLength<0.5)
{segLength=this.units.ConvertUnits(this.units.GetUnitsIndex(this.olMap.units),this.units.FEET,segLength);szUnitAbbr=this.units.UnitAbbr[this.units.FEET];}}
else
{segLength=this.units.ConvertUnits(this.units.GetUnitsIndex(this.olMap.units),this.units.KILOMETERS,segLength);szUnitAbbr=this.units.UnitAbbr[this.units.KILOMETERS];if(segLength<0.5)
{segLength=this.units.ConvertUnits(this.units.GetUnitsIndex(this.olMap.units),this.units.METERS,segLength);szUnitAbbr=this.units.UnitAbbr[this.units.METERS];}}
var midLon=(point2.lon-point1.lon)/2+point1.lon;var midLat=(point2.lat-point1.lat)/2+point1.lat;signBoardGroup.addSignBoard(new OpenLayers.LonLat(midLon,midLat),'<div class="'+className+'">'+Math.round(segLength*100)/100+' '+szUnitAbbr+'</div>',-20,-8,2000);signBoardGroup.draw();}}
var pointList=[];for(var i=0;i<coords.length;i++){var newPoint=new OpenLayers.Geometry.Point(coords[i][0],coords[i][1]);pointList.push(newPoint);}
var line=new OpenLayers.Geometry.LineString(pointList);var feature=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Line([line]),null,style);if(signBoardGroup){feature.sbg=signBoardGroup;}
canvas.addFeatures([feature]);this.features.push(feature);return feature;};fbsKaMap.prototype.addRadius=function(center,radius,radiusStyle,options){var canvas=null;if(!options||(options&&!options.canvas)){canvas=this.initialFeatureCanvasLayer;}else{canvas=options.canvas;}
var gPoint=new OpenLayers.LonLat(center[0],center[1]);if(this.olMap.units=='m'){var rPoint=new OpenLayers.LonLat(gPoint.lon+parseFloat(radius),gPoint.lat);radius=OpenLayers.Util.distVincenty(gPoint,rPoint)*1000;this.transformUserToMap(gPoint);this.transformUserToMap(rPoint);var featureRadius=(Math.sqrt(Math.pow(rPoint.lon-gPoint.lon,2)+
Math.pow(rPoint.lat-gPoint.lat,2)));}
var pointGeometry=new OpenLayers.Geometry.Point(gPoint.lon,gPoint.lat);var geometry=new OpenLayers.Geometry.MultiPoint(pointGeometry);var style=radiusStyle||OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default']);var measureClass=options&&options.className;var feature=new OpenLayers.Feature.Vector(geometry,null,style);feature.attributes=OpenLayers.Util.extend({'type':'radius','label':radius,'displayRadius':featureRadius,'signBoardClass':measureClass},style);this.features.push(feature);canvas.addFeatures([feature]);return feature;};fbsKaMap.prototype.findFeature=function(uid){for(var i=0;i<this.features.length;i++){if(this.features[i].id==uid||this.features[i].uid==uid){return this.features[i];}};};fbsKaMap.prototype.clearFeature=function(feature){if(feature&&feature.layer){var fc=feature.layer;if(feature.uid||feature.id){for(var i=0;i<this.features.length;i++){if(this.features[i].uid==feature.uid||this.features[i].id==feature.id){this.features=OpenLayers.Util.removeItem(this.features,feature);}}}
if(feature.sbg){feature.sbg.destroy();feature.sbg=null;}
if(feature.zoomCallback){feature.layer.map.events.unregister('zoomend',null,feature.zoomCallback);}
fc.removeFeatures([feature]);}};fbsKaMap.prototype.clearFeatures=function(){if(arguments.length){var canvas=arguments[0];canvas.destroyFeatures();}else{for(var i=0;i<this.aFeatureCanvases.length;i++){this.aFeatureCanvases[i].destroyFeatures();};}
this.aFeatureCanvases=[];this.features=[];};fbsKaMap.prototype.addDynamicLayer=function(data,symbol,theme){var arVersion=navigator.appVersion.split("MSIE");var version=parseFloat(arVersion[1]);var useAlpha=version&&version<7;this.dynamicLayer=new OpenLayers.Layer.MapServer("Search Results",this.dynamicServer,{map:this.dynamicMap,map_imagetype:'aggpng24',subst:data,layers:symbol,theme:theme,sphericalMercator:this.sphericalMercator,transparent:true},{singleTile:true,alpha:useAlpha});this.olMap.addLayer(this.dynamicLayer);};fbsKaMap.prototype.removeDynamicLayer=function(){if(this.dynamicLayer){if(this.mapTipTool){this.disableDynamicLayerMapTip();}
this.dynamicLayer.destroy();}
this.dynamicLayer=null;};fbsKaMap.prototype.hideDynamicLayer=function(){if(this.dynamicLayer){this.dynamicLayer.setVisibility(false);return true;}
return false;};fbsKaMap.prototype.showDynamicLayer=function(){if(this.dynamicLayer){this.dynamicLayer.setVisibility(true);return true;}
return false;};fbsKaMap.prototype.setDynamicLayerData=function(data){if(this.dynamicLayer){this.dynamicLayer.mergeNewParams({subst:data});if(this.mapTipTool){this.mapTipTool.serverInfo.layer=data;}
return true;}
return false;};fbsKaMap.prototype.setDynamicLayerTheme=function(theme){if(this.dynamicLayer){this.dynamicLayer.mergeNewParams({theme:theme});if(this.mapTipTool){this.mapTipTool.serverInfo.theme=theme;}
return true;}
return false;};fbsKaMap.prototype.enableDynamicLayerMapTip=function(div,delay,scales){if(this.dynamicLayer){this.mapTipDiv=div;this.delay=delay?parseInt(delay):250;if(!this.mapTipTool){this.mapTipTool=new OpenLayers.Control.MapTip({domObj:this.mapTipDiv,delay:this.delay,validScales:scales,hover:false,serverInfo:{url:this.dynamicServer,map:this.dynamicMap,layer:this.dynamicLayer.params.subst,symbol:this.dynamicLayer.params.layers,theme:this.dynamicLayer.params.theme}});};this.olMap.addControl(this.mapTipTool);this.mapTipTool.activate();return true;}
return false;};fbsKaMap.prototype.disableDynamicLayerMapTip=function(){if(this.mapTipTool){this.mapTipTool.hide();this.mapTipTool.deactivate();this.mapTipTool.destroy();this.mapTipTool=null;}};fbsKaMap.prototype.hideMapTip=function(){this.mapTipTool.hide();};fbsKaMap.prototype.addCacheLayer=function(layer,opacity,isBase,scales){var newLayer=this.olMap.getLayer(layer.id);var arVersion=navigator.appVersion.split("MSIE");var version=parseFloat(arVersion[1]);var useAlpha=(!isBase&&(version<7));if(!newLayer){var imageFormat=(arguments.length>4)?arguments[4].substr(0,3).toLowerCase():'png';var resolutions=null;if(!scales||!(scales.length)){resolutions=this.olMap.baseLayer.resolutions;}
var layerVisibility=resolutions?resolutions:this.aResolutions;var fOpacity=opacity||1.0;var newLayer=new OpenLayers.Layer.KaMapFBS(layer,this.aTileServers,{map:this.sMap,group:layer,i:imageFormat,tileSize:{w:256,h:256},metaSize:{w:24,h:24},a:isBase},{isBaseLayer:isBase,buffer:1,scales:scales,resolutions:resolutions,alpha:useAlpha});this.olMap.addLayer(newLayer);}
var baseZindex=this.olMap.baseLayer.div.style.zIndex;if(isBase){this.olMap.setBaseLayer(newLayer);if(baseZindex){newLayer.setZIndex(parseInt(baseZindex));}}else{if(baseZindex){newLayer.setZIndex(parseInt(baseZindex)+this.olMap.getNumLayers());}}
return newLayer;};fbsKaMap.prototype.removeCacheLayer=function(layer){var oldLayer=this.olMap.getLayer(layer.id);if(oldLayer){oldLayer.destroy();}};fbsKaMap.prototype.setLayerVisibility=function(layer,visible){var oLayer=this.olMap.getLayer(layer);if(oLayer){oLayer.setVisibility(visible);return true;}
return false;};fbsKaMap.prototype.setLayerOpacity=function(layer,opacity){var oLayer=this.olMap.getLayer(layer);if(oLayer){oLayer.setOpacity(opacity);return true;}
return false;};fbsKaMap.prototype.processMoveStart=function(o){};fbsKaMap.prototype.processMoveEnd=function(o){var dScaleCheck=this.olMap.getScale();if(dScaleCheck!=this.dCurrentScale){this.scaleChanged(o);this.dCurrentScale=dScaleCheck;}
this.extentsChanged(o);};fbsKaMap.prototype.activateTool=function(tool){if(arguments.length>1&&arguments[1]==true){this.deactivateAllTools();}
if(this.toolset['tool']){this.toolset['tool'].activate();}};fbsKaMap.prototype.activateRuler=function(){if(arguments.length>0&&arguments[0]==true){this.deactivateAllTools();}
this.toolset.ruler.activate();};fbsKaMap.prototype.goQuery=function(){};fbsKaMap.prototype.activateQuery=function(){this.deactivateAllTools();this.toolset.query.activate();};fbsKaMap.prototype.deactivateAllTools=function(){for(var key in this.toolset){this.toolset[key].deactivate();}};fbsKaMap.prototype.saveFeaturesSuccessCB=function(){};fbsKaMap.prototype.saveFeaturesFailureCB=function(){};fbsKaMap.prototype.saveFeaturesLocal=function(){if(!this.myMapsSaveScript){return;};gmlwriter=new OpenLayers.Format.GML();var complete=this.saveFeaturesSuccessCB.bind(this);var failure=this.saveFeaturesFailureCB.bind(this);var layer=this.features[0].layer;var userFeatures=[];for(i=0;i<layer.features.length;i++)
{var feature=layer.features[i];if(feature.attributes.isUserFeature){OpenLayers.Util.extend(feature.attributes,feature.style);feature.attributes.resolution=this.olMap.getResolution();userFeatures.push(feature);}}
var gml_features=gmlwriter.write(userFeatures);new OpenLayers.Ajax.Request(this.myMapsSaveScript,{method:'post',postBody:value_post=gml_features,parameters:value_post=gml_features,onComplete:complete,onFailure:failure});};fbsKaMap.prototype.saveFeatures=function(){if(!this.myMapsSaveScript){return;};gmlwriter=new OpenLayers.Format.GML();var complete=this.saveFeaturesSuccessCB.bind(this);var failure=this.saveFeaturesFailureCB.bind(this);var layer=this.features[0].layer;var userFeatures=[];for(i=0;i<layer.features.length;i++)
{var feature=layer.features[i];if(feature.attributes.isUserFeature){OpenLayers.Util.extend(feature.attributes,feature.style);feature.attributes.resolution=this.olMap.getResolution();userFeatures.push(feature);}}
var gml_features=gmlwriter.write(userFeatures);this._saveString(gml_features);};fbsKaMap.prototype._saveString=function(s){var maxLen=this.MYMAPS_GET_SIZE||1000;var chunks=Math.ceil(s.length/maxLen);this.myMapsSaveData=[];for(var i=0;i<chunks;i++){this.myMapsSaveData.push(s.slice(maxLen*i,maxLen*i+maxLen));}
this.saveChunk();};fbsKaMap.prototype.saveChunk=function(id){var szCallback='&callback='+this.myMapsSaveCallback;var url=this.myMapsSaveScript+'?chunk='+encodeURIComponent(this.myMapsSaveData.shift())+
szCallback;if(this.myMapsScriptTag){document.getElementsByTagName('head')[0].removeChild(this.myMapsScriptTag);}
this.myMapsScriptTag=document.createElement('script');document.getElementsByTagName('head')[0].appendChild(this.myMapsScriptTag);if(this.myMapsSaveData.length==0){url+="&final=1";};if(id){url+="&id="+id;}
this.myMapsScriptTag.src=url;};fbsKaMap.prototype.getBearing=function(point1,point2){var toRad=function(f){return f*Math.PI/180;};var p1=new OpenLayers.LonLat(point1.lon,point1.lat);var p2=new OpenLayers.LonLat(point2.lon,point2.lat);;if(this.olMap.units=='m'){this.transformMapToUser(p1);this.transformMapToUser(p2);};var lat1=toRad(p1.lat);var lat2=toRad(p2.lat);var dLon=toRad(p2.lon-p1.lon);var y=Math.sin(dLon)*Math.cos(lat2);var x=Math.cos(lat1)*Math.sin(lat2)-
Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);return(Math.atan2(y,x)*180/Math.PI+360)%360;};fbsKaMap.prototype.gmlonLoadEnd=function(doc){var gml=new OpenLayers.Format.GML();var features=gml.read(doc);for(var i=0;i<features.length;i++){var feature=features[i];var style=OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default']);feature.style=OpenLayers.Util.extend(style,feature.attributes);this.features.push(feature);this.initialFeatureCanvasLayer.addFeatures([feature]);this._callFeatureListeners(feature);};};fbsKaMap.prototype.loadFeatures=function(){if(!this.myMapsLoadScript){return;};if(this.myMapsScriptTag){document.getElementsByTagName('head')[0].removeChild(this.myMapsScriptTag);}
this.myMapsScriptTag=document.createElement('script');document.getElementsByTagName('head')[0].appendChild(this.myMapsScriptTag);this.myMapsScriptTag.src=this.myMapsLoadScript+'?callback='+this.myMapsLoadCallback;};fbsKaMap.prototype.addFeatureListener=function(f){this.featureListeners.push(f);};fbsKaMap.prototype._callFeatureListeners=function(feature){for(var i=0;i<this.featureListeners.length;i++){this.featureListeners[i](feature);};};fbsKaMap.prototype.setPopupContent=function(content){if(!this.goPopup){return;}
var target=this.goPopup;target.refreshWithContent(content);target.feature.data.popupContentHTML=content;return target;};fbsKaMap.prototype.requestFailure=function(){alert('There was a problem communicating with the server. Contact support');};fbsKaMap.prototype.Position=function(point){if(this.olMap.units=='m'){point=OpenLayers.Layer.SphericalMercator.inverseMercator(point.x,point.y);}
return new OpenLayers.LonLat(point.x,point.y);};OpenLayers.Renderer.SVG.prototype.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)&&feature.attributes.type!='radius'){style={display:"none"};}
return this.drawGeometry(feature.geometry,style,feature.id);}}};OpenLayers.Renderer.VML.prototype.drawFeature=OpenLayers.Renderer.SVG.prototype.drawFeature;OpenLayers.Renderer.Canvas.prototype.drawFeature=OpenLayers.Renderer.SVG.prototype.drawFeature;