OpenLayers.Util.getImagesLocation=function(){return"/javascripts/openlayers_2_6/img/";};Object.extend(OpenLayers.Feature.Vector.style["default"],{fillColor:'#8A95C6',fillOpacity:0.4,strokeColor:"#8A95C6",strokeWidth:3,strokeOpacity:1});OpenLayers.Popup.CsPopup=OpenLayers.Class.create();OpenLayers.Popup.CsPopup.prototype=OpenLayers.Class.inherit(OpenLayers.Popup,{initialize:function(id,lonlat,size,content){if(id==null){id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");}
this.id=id;this.lonlat=lonlat;this.size=(size!=null)?size:new OpenLayers.Size(OpenLayers.Popup.WIDTH,OpenLayers.Popup.HEIGHT);if(content!=null){this.contentHTML=content;}
this.div=new Element('div',{id:this.id,className:'csPopup'});var divs=['top','right','bottom','left','top_left','top_right','bottom_left','bottom_right','anchor'];divs.each(function(d){var div=new Element('div',{className:d});this.div.appendChild(div);this[d+'_div']=div;}.bind(this));this.contentDiv=new Element('div',{id:this.id+'_contentDiv',className:'popup_contents'});this.div.appendChild(this.contentDiv);this.registerEvents();},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";}
if(this.contentDiv!=null){this.contentDiv.style.width=this.size.w+"px";this.contentDiv.style.height=this.size.h+"px";}
this.left_div.style.height=this.size.h+"px";this.right_div.style.height=this.size.h+"px";this.top_div.style.width=this.size.w+"px";this.bottom_div.style.width=this.size.w+"px";},fit_contents:function()
{this.setSize(new OpenLayers.Size(this.size.w,this.contentDiv.down().getHeight()));},moveTo:function(px){var newPx=this.calculateNewPx(px);var newArguments=new Array(newPx);OpenLayers.Popup.prototype.moveTo.apply(this,newArguments);},calculateNewPx:function(px){px.x-=this.size.w-100;px.y-=this.size.h+109;return px;},setBackgroundColor:function(color){},setOpacity:function(opacity){},setBorder:function(border){},CLASS_NAME:"OpenLayers.Popup.CsPopup"});OpenLayers.Popup.DomPopup=OpenLayers.Class.create();OpenLayers.Popup.DomPopup.prototype=OpenLayers.Class.inherit(OpenLayers.Popup.CsPopup,{url:null,initialize:function(id,lonlat,size,content,className){OpenLayers.Popup.CsPopup.prototype.initialize.apply(this,[id,lonlat,size,content]);if(className)
{$(this.div).addClassName(className);}},setContentHTML:function(contentHTML){if(contentHTML!=null){this.contentHTML=contentHTML;}
if(this.contentDiv!=null){this.contentDiv.appendChild(this.contentHTML);}},CLASS_NAME:"OpenLayers.Popup.DomPopup"});var ArticleFeature=Class.create();ArticleFeature.prototype={feature:null,popup:null,description:'',title:'',selected:false,initialize:function(controls,feature,dom_node)
{this.controls=controls;this.feature=feature;this.info_pane=dom_node;if(!this.feature&&this.info_pane)
{this.build_from_html();}
else
{this.build_from_feature();}},build_from_feature:function()
{this.feature.state=OpenLayers.State.INSERT;this.build_info_pane();this.observe_info_pane();},build_from_html:function()
{this.title_field=this.info_pane.down("input.title");this.description_field=this.info_pane.down("input.description");this.title=this.title_field.value;this.description=this.description_field.value;this.type=this.info_pane.down("input.geometry_type").value;var geometry=this.info_pane.getElementsBySelector("input.geometry")[0].value;geometry=geometry.replace(/SRID=-?\d+;/,'');var wkt=new OpenLayers.Format.WKT();this.feature=wkt.read(geometry);if(this.feature)
{Utils.mercator_transform(this.feature.geometry,OpenLayers.Layer.SphericalMercator.forwardMercator)
this.controls.layer.addFeatures([this.feature]);}
this.observe_info_pane();},display_popup:function()
{if(this.popup)
{this.update_popup();}
else
{this.build_popup();}},hide_popup:function()
{this.popup.hide();},select:function(called_by_selector)
{if(this.selected)
{return;}
this.selected=true;this.set_center();this.display_popup();this.controls.deselect_other_features(this);},deselect:function(called_by_selector)
{if(!this.selected)
{return;}
this.selected=false;this.hide_popup();},to_wkt:function()
{var new_geom=this.feature.geometry.clone();Utils.mercator_transform(new_geom,OpenLayers.Layer.SphericalMercator.inverseMercator)
return new_geom.toString();},build_popup:function()
{this.feature.geometry.calculateBounds();var lonlat=this.feature.geometry.bounds.getCenterLonLat();this.popup=new OpenLayers.Popup.DomPopup(null,lonlat,new OpenLayers.Size(250,140),this.popup_contents(),'edit_feature_popup',false);this.controls.map.addPopup(this.popup);},update_popup:function(feature)
{this.description_popup_field.value=this.description;this.title_popup_field.value=this.title;this.popup.show();this.popup.updatePosition();},popup_contents:function()
{var title_popup_field=new Element('input',{type:'text',name:'title',value:this.title||'title'});ClearInput.attach(title_popup_field);var title_row=new Element('DIV',{className:'form_row'});title_row.appendChild(title_popup_field);var desc_field=new Element('textarea',{name:'description'});desc_field.innerHTML=this.description;var desc_label=new Element('label').appendText('Details');var desc_row=new Element('DIV',{className:'form_row'});desc_row.appendChild(desc_label);desc_row.appendChild(desc_field);var submit_button=Utils.button('save');var remove_link=new Element('A',{href:'#',className:'action'}).appendText('remove');var cancel_link=new Element('A',{href:'#',className:'action'}).appendText('close');var submit_row=new Element('DIV',{className:'actions form_row'});submit_row.appendChild(submit_button);submit_row.appendText(' ');submit_row.appendChild(cancel_link);submit_row.appendText(' ');submit_row.appendChild(remove_link);var container=new Element('form');container.appendChild(title_row);container.appendChild(desc_row);container.appendChild(submit_row);Event.observe(container,'submit',this.form_submitted.bindAsEventListener(this));Event.observe(submit_button,'click',this.form_submitted.bindAsEventListener(this));Event.observe(remove_link,'click',this.remove_clicked.bindAsEventListener(this));Event.observe(cancel_link,'click',this.cancel_edit_clicked.bindAsEventListener(this));this.title_popup_field=title_popup_field;this.description_popup_field=desc_field;return container;},form_submitted:function(e)
{Event.stop(e);this.updated();},remove_clicked:function(e)
{Event.stop(e);this.destroy();},cancel_edit_clicked:function(e)
{Event.stop(e);this.deselect();},destroy:function()
{this.deselect();this.popup.destroy();this.feature.destroy();new Effect.Fade(this.info_pane,{afterFinish:function(){this.info_pane.remove();}.bind(this)});},updated:function()
{this.deselect();this.description=$F(this.description_popup_field);this.title=$F(this.title_popup_field);this.update_info_panel();},build_info_pane:function()
{this.info_pane=new Element('li',{className:'feature '+this.type()});var title=new Element('h4').appendText(this.title_text());var description=new Element('p').appendText(this.description_text());this.info_pane.appendChild(title);this.info_pane.appendChild(description);var uid=Utils.uid();this.title_field=new Element('input',{type:'hidden',value:this.title,name:'features['+uid+'][title]'});this.description_field=new Element('input',{type:'hidden',value:this.description,name:'features['+uid+'][description]'});this.geometry_field=new Element('input',{type:'hidden',value:this.to_wkt(),name:'features['+uid+'][wkt_geometry]'});var type_field=new Element('input',{type:'hidden',value:this.type(),name:'features['+uid+'][geometry_type]'});this.info_pane.appendChild(this.title_field);this.info_pane.appendChild(this.description_field);this.info_pane.appendChild(this.geometry_field);this.info_pane.appendChild(type_field);$('article_map_features').appendChild(this.info_pane);},observe_info_pane:function()
{Event.observe(this.info_pane,'click',this.info_clicked.bindAsEventListener(this));},info_clicked:function()
{this.select();},set_center:function()
{this.feature.geometry.calculateBounds();this.controls.map.setCenter(this.feature.geometry.bounds.getCenterLonLat());},update_info_panel:function()
{this.info_pane.getElementsBySelector('h4')[0].innerHTML=this.title_text();this.info_pane.getElementsBySelector('p')[0].innerHTML=this.description_text();this.title_field.value=this.title;this.description_field.value=this.description;},title_text:function()
{return(this.title.strip()=='')?'no title':this.title;},description_text:function()
{return(this.description.strip()=='')?'no description':this.description;},type:function()
{var type;switch(this.feature.geometry.CLASS_NAME)
{case"OpenLayers.Geometry.Polygon":type='polygon';break;case"OpenLayers.Geometry.LineString":type='line';break;}
return type;}};var ArticleAreaSelection=Class.create();Object.extend(ArticleAreaSelection.prototype,ArticleFeature.prototype);Object.extend(ArticleAreaSelection.prototype,{feature:null,popup:null,description:'',title:'',selected:false,initialize:function(controls,feature,dom_node)
{this.controls=controls;this.feature=feature;this.info_pane=dom_node;if(!this.feature&&this.info_pane)
{this.build_from_html();}
else
{this.build_from_feature();}},build_from_html:function()
{this.type=this.info_pane.down("input.geometry_type").value;var geometry=this.info_pane.getElementsBySelector("input.geometry")[0].value;var wkt=new OpenLayers.Format.WKT();this.feature=wkt.read(geometry);if(this.feature)
{Utils.mercator_transform(this.feature.geometry,OpenLayers.Layer.SphericalMercator.forwardMercator)
this.controls.layer.addFeatures([this.feature]);}
this.observe_info_pane();},build_popup:function()
{this.feature.geometry.calculateBounds();var lonlat=this.feature.geometry.bounds.getCenterLonLat();this.popup=new OpenLayers.Popup.DomPopup(null,lonlat,new OpenLayers.Size(100,50),this.popup_contents(),'edit_feature_popup',false);this.controls.map.addPopup(this.popup);},update_popup:function(feature)
{this.popup.show();this.popup.updatePosition();},popup_contents:function()
{var remove_link=new Element('A',{href:'#',className:'action'}).appendText('remove');var cancel_link=new Element('A',{href:'#',className:'action'}).appendText('close');var submit_row=new Element('DIV',{className:'actions form_row'});submit_row.appendChild(cancel_link);submit_row.appendText(' ');submit_row.appendChild(remove_link);var container=new Element('form');container.appendChild(submit_row);Event.observe(remove_link,'click',this.remove_clicked.bindAsEventListener(this));Event.observe(cancel_link,'click',this.cancel_edit_clicked.bindAsEventListener(this));return container;},build_info_pane:function()
{this.info_pane=new Element('li',{className:'feature '+this.type()});var uid=Utils.uid();this.geometry_field=new Element('input',{type:'hidden',value:this.to_wkt(),name:'area_selections['+uid+'][wkt_geometry]'});var type_field=new Element('input',{type:'hidden',value:this.type(),name:'area_selections['+uid+'][geometry_type]'});this.info_pane.appendChild(this.geometry_field);this.info_pane.appendChild(type_field);$('article_area_selections').appendChild(this.info_pane);},update_info_panel:function()
{}});OpenLayers.Control.BeaconToolbar=OpenLayers.Class.create();OpenLayers.Control.BeaconToolbar.prototype=OpenLayers.Class.inherit(OpenLayers.Control.Panel,{article_features:[],initialize:function(layer,options){OpenLayers.Control.Panel.prototype.initialize.apply(this,[options]);this.layer=layer;this.navigation=new OpenLayers.Control.Navigation();this.path_drawer=new OpenLayers.Control.DrawFeature(layer,OpenLayers.Handler.Path,{'displayClass':'olControlDrawFeaturePath'});this.poly_drawer=new OpenLayers.Control.DrawFeature(layer,OpenLayers.Handler.Polygon,{'displayClass':'olControlDrawFeaturePolygon'});this.selector=new OpenLayers.Control.CsSelectFeature(layer);this.path_drawer.featureAdded=this.feature_added.bind(this);this.poly_drawer.featureAdded=this.feature_added.bind(this);this.selector.onclick=this.feature_clicked.bind(this);this.addControls([this.navigation,this.path_drawer,this.poly_drawer]);},find_features:function()
{$$('#article_map_features .feature').each(function(feature_info){this.add_article_feature(new ArticleFeature(this,false,feature_info));}.bind(this));},article_feature_from_feature:function(feature)
{return this.article_features.find(function(f){return f.feature==feature;});},deselect_other_features:function(article_feature)
{this.article_features.findAll(function(x){return(x!=article_feature&&x.selected);}).invoke('deselect');},feature_clicked:function(f)
{if(this.selected)
{this.feature_deselected(f);this.selected=f;}
else
{this.feature_selected(f);this.selected=false;}},feature_added:function(feature)
{setTimeout(this.activateControl.bind(this,this.navigation),10);article_feature=new ArticleFeature(this,feature);this.add_article_feature(article_feature);article_feature.select();},add_article_feature:function(article_feature)
{this.article_features[this.article_features.length]=article_feature;},feature_selected:function(feature)
{this.article_feature_from_feature(feature).select(true);},feature_deselected:function(feature)
{this.article_feature_from_feature(feature).deselect(true);},draw:function(){var div=OpenLayers.Control.Panel.prototype.draw.apply(this,arguments);this.activateControl(this.navigation);return div;},CLASS_NAME:"OpenLayers.Control.BeaconToolbar"});OpenLayers.Control.AreaToolbar=OpenLayers.Class.create();OpenLayers.Control.AreaToolbar.prototype=OpenLayers.Class.inherit(OpenLayers.Control.Panel,{article_areas:[],initialize:function(layer,options){OpenLayers.Control.Panel.prototype.initialize.apply(this,[options]);this.layer=layer;this.navigation=new OpenLayers.Control.Navigation();this.poly_drawer=new OpenLayers.Control.DrawFeature(layer,OpenLayers.Handler.Polygon,{'displayClass':'olControlDrawFeaturePolygon'});this.selector=new OpenLayers.Control.CsSelectFeature(layer);this.poly_drawer.featureAdded=this.feature_added.bind(this);this.selector.onclick=this.feature_clicked.bind(this);this.addControls([this.navigation,this.poly_drawer]);},find_features:function()
{$$('#article_area_selections .feature').each(function(area_info){this.add_article_feature(new ArticleAreaSelection(this,false,area_info));}.bind(this));},article_area_from_feature:function(feature)
{return this.article_areas.find(function(f){return f.feature==feature;});},deselect_other_features:function(article_area)
{this.article_areas.findAll(function(x){return(x!=article_area&&x.selected);}).invoke('deselect');},feature_clicked:function(f)
{if(this.selected)
{this.feature_deselected(f);this.selected=f;}
else
{this.feature_selected(f);this.selected=false;}},feature_added:function(feature)
{setTimeout(this.activateControl.bind(this,this.navigation),10);article_area=new ArticleAreaSelection(this,feature);this.add_article_feature(article_area);},add_article_feature:function(article_area)
{this.article_areas[this.article_areas.length]=article_area;},feature_selected:function(feature)
{this.article_area_from_feature(feature).select(true);},feature_deselected:function(feature)
{this.article_area_from_feature(feature).deselect(true);},draw:function(){var div=OpenLayers.Control.Panel.prototype.draw.apply(this,arguments);this.activateControl(this.navigation);return div;},CLASS_NAME:"OpenLayers.Control.AreaToolbar"});OpenLayers.Handler.CSRulerHandler=OpenLayers.Class(OpenLayers.Handler.Path,{FLAG_IMG_SRC:"/images/markers/marker-blue.png",markers:null,size:null,offset:null,lines:null,markersInCurrentLineCount:0,initialize:function(control,callbacks,options){OpenLayers.Handler.Path.prototype.initialize.apply(this,arguments);this.lines=new Array();this.size=new OpenLayers.Size(20,20);this.offset=new OpenLayers.Pixel(-10,-35);this.style={fillColor:"#ee9900",fillOpacity:0.4,hoverFillColor:"white",hoverFillOpacity:0.8,strokeColor:"red",strokeOpacity:0.8,strokeWidth:2,strokeLinecap:"round",hoverStrokeColor:"red",hoverStrokeOpacity:1,hoverStrokeWidth:0.2,pointRadius:3,hoverPointRadius:1,hoverPointUnit:"%",pointerEvents:"visiblePainted",cursor:""}},activate:function(){if(this.control.layer==null)this.control.layer=new OpenLayers.Layer.Vector("Ruler Path");this.control.layer.style=this.style;this.map.addLayer(this.control.layer);this.markers=new OpenLayers.Layer.Markers("Ruler Markers");this.map.addLayer(this.markers);return OpenLayers.Handler.Path.prototype.activate.apply(this,arguments);},deactivate:function(){this.control.layer.destroyFeatures();this.map.removeLayer(this.control.layer);this.map.removeLayer(this.markers);return OpenLayers.Handler.Path.prototype.deactivate.apply(this,arguments);},addPoint:function(){var bbox=new OpenLayers.LonLat(this.point.geometry.x,this.point.geometry.y);var distance=this.calculateDistanceVincenty(bbox);var icon=new OpenLayers.CSIcon(this.FLAG_IMG_SRC,this.size,this.offset,null,distance+this.getUnits());var marker=new OpenLayers.Marker(bbox,icon);marker.distance=distance;marker.initialLonLat=bbox;this.markers.addMarker(marker);this.markersInCurrentLineCount++;this.line.geometry.addComponent(this.point.geometry.clone(),this.line.geometry.components.length);this.callback("point",[this.point.geometry]);},calculateDistanceVincenty:function(newBbox){if(this.markersInCurrentLineCount<=1)return 0;var prevMarker=this.markers.markers[this.markers.markers.length-1];var oldBbox=prevMarker.initialLonLat;var distance=CSRulerUtils.prototype.calculateDistanceFromMercator(oldBbox,newBbox);var distV=parseFloat(prevMarker.distance)+distance;return distV.toFixed(3);},getUnits:function(){return"&nbsp;km";},dblclick:function(evt){this.markersInCurrentLineCount=0;return OpenLayers.Handler.Path.prototype.dblclick.apply(this,arguments);},modifyFeature:function(){var bbox=new OpenLayers.LonLat(this.point.geometry.x,this.point.geometry.y);var distance=this.calculateDistanceVincenty(bbox);this.markers.markers[this.markers.markers.length-1].lonlat=bbox;this.markers.drawMarker(this.markers.markers[this.markers.markers.length-1]);this.markers.markers[this.markers.markers.length-1].icon.setIconText(distance+this.getUnits());OpenLayers.Handler.Path.prototype.modifyFeature.apply(this,arguments);},markerClick:function(evt){alert("It doesn't work in FF....");},CLASS_NAME:"OpenLayers.Handler.CSRulerHandler"})
OpenLayers.Handler.CSCircleHandler=OpenLayers.Class(OpenLayers.Handler.RegularPolygon,{FLAG_IMG_SRC:"/images/markers/marker-blue.png",sides:30,size:null,offset:null,center:null,marker:null,initialize:function(control,callbacks,options){OpenLayers.Handler.RegularPolygon.prototype.initialize.apply(this,[control,callbacks,options]);this.size=new OpenLayers.Size(20,20);this.offset=new OpenLayers.Pixel(-10,-35);this.style={fillColor:"blue",fillOpacity:0.1,hoverFillColor:"white",hoverFillOpacity:0.9,strokeColor:"red",strokeOpacity:0.6,strokeWidth:2,strokeLinecap:"round",hoverStrokeColor:"red",hoverStrokeOpacity:1,hoverStrokeWidth:0.2,pointRadius:3,hoverPointRadius:1,hoverPointUnit:"%",pointerEvents:"visiblePainted",cursor:""}},down:function(evt){var maploc=this.map.getLonLatFromPixel(evt.xy);var point=new OpenLayers.Geometry.Point(maploc.lon,maploc.lat);var bbox=new OpenLayers.LonLat(point.x,point.y);this.center=bbox;var icon=new OpenLayers.CSIcon(this.FLAG_IMG_SRC,this.size,this.offset,null,0+this.getUnits());this.marker=new OpenLayers.Marker(bbox,icon);this.markers.addMarker(this.marker);OpenLayers.Handler.RegularPolygon.prototype.down.apply(this,arguments);},getUnits:function(){return"&nbsp;km";},move:function(evt){var maploc=this.map.getLonLatFromPixel(evt.xy);var point=new OpenLayers.Geometry.Point(maploc.lon,maploc.lat);var newBbox=new OpenLayers.LonLat(point.x,point.y);var oldBbox=this.center;var distance=CSRulerUtils.prototype.calculateDistanceFromMercator(oldBbox,newBbox);this.marker.icon.setIconText(distance+this.getUnits());OpenLayers.Handler.RegularPolygon.prototype.move.apply(this,arguments);},activate:function(){if(this.control.layer==null)this.control.layer=new OpenLayers.Layer.Vector("Ruler Circle");this.control.layer.style=this.style;this.map.addLayer(this.control.layer);this.markers=new OpenLayers.Layer.Markers("Ruler Markers");this.map.addLayer(this.markers);return OpenLayers.Handler.RegularPolygon.prototype.activate.apply(this,arguments);},deactivate:function(){this.control.layer.destroyFeatures();this.map.removeLayer(this.control.layer);this.map.removeLayer(this.markers);return OpenLayers.Handler.RegularPolygon.prototype.deactivate.apply(this,arguments);},CLASS_NAME:"OpenLayers.Handler.CSCircleHandler"});if(!window.CSRulerUtils)var CSRulerUtils=new Object();CSRulerUtils.prototype={calculateDistanceFromMercator:function(oldBbox,newBbox){var wgs84OldPoint=OpenLayers.Layer.SphericalMercator.inverseMercator(oldBbox.lon,oldBbox.lat);var wgs84NewPoint=OpenLayers.Layer.SphericalMercator.inverseMercator(newBbox.lon,newBbox.lat);var distance=OpenLayers.Util.distVincenty(wgs84OldPoint,wgs84NewPoint);distance=Math.round(distance*1000)/1000;return distance;}}
OpenLayers.CSIcon=OpenLayers.Class(OpenLayers.Icon,{textDiv:null,text:null,initialize:function(url,size,offset,calculateOffset,text){var options=[url,size,offset,calculateOffset];this.text=text;this.textDiv=OpenLayers.Util.createDiv(null,null,null,null,null,null,null,null);this.textDiv.innerHTML="<span>"+this.text+"</span>";this.textDiv.style.backgroundColor="#FFFF99";this.textDiv.style.border="1px solid #C5DCFA";this.textDiv.style.width="100%";this.textDiv.noWrap=true;this.url=url;this.size=(size)?size:new OpenLayers.Size(20,20);this.offset=offset?offset:new OpenLayers.Pixel(-(this.size.w/2),-(this.size.h/2));this.calculateOffset=calculateOffset;var id=OpenLayers.Util.createUniqueID("OL_Icon_");this.imageDiv=document.createElement("div");this.imageDiv.style.position="absolute";var img=document.createElement("img");img.style.position="relative";img.src=url;img.style.width=size.w;img.style.height=size.h;img.style.float="left";this.textDiv.style.position="relative";this.textDiv.style.float="right";this.imageDiv.appendChild(this.textDiv);this.imageDiv.appendChild(img);this.imageDiv.noWrap=true;},setIconText:function(text){this.text=text;this.textDiv.innerHTML="<span>"+text+"</span>";},draw:function(px){this.moveTo(px);return this.imageDiv;},moveTo:function(px){if(px!=null){this.px=px;}
if(this.imageDiv!=null){if(this.px==null){this.display(false);}else{if(this.calculateOffset){this.offset=this.calculateOffset(this.size);}
var offsetPx=this.px.offset(this.offset);OpenLayers.Util.modifyDOMElement(this.imageDiv,null,offsetPx,null,null,null,null,null);}}},display:function(display){this.imageDiv.style.display=(display)?"block":"none";this.container.style.display=(display)?"":"none";this.textDiv.style.display=(display)?"":"none";},CLASS_NAME:"OpenLayers.CSIcon"})
OpenLayers.Handler.CSCircleCustomHandler=OpenLayers.Class(OpenLayers.Handler.RegularPolygon,{FLAG_IMG_SRC:"/images/markers/marker-blue.png",sides:30,size:null,offset:null,center:null,marker:null,radio_buttons_count:6,initial_value:100,step:200,initialize:function(control,callbacks,options){OpenLayers.Handler.RegularPolygon.prototype.initialize.apply(this,[control,callbacks,options]);this.size=new OpenLayers.Size(20,20);this.style={fillColor:"blue",fillOpacity:0.1,hoverFillColor:"white",hoverFillOpacity:0.9,strokeColor:"red",strokeOpacity:0.6,strokeWidth:2,strokeLinecap:"round",hoverStrokeColor:"red",hoverStrokeOpacity:1,hoverStrokeWidth:0.2,pointRadius:3,hoverPointRadius:1,hoverPointUnit:"%",pointerEvents:"visiblePainted",cursor:""}
this.offset=new OpenLayers.Pixel(-10,-35);this.radius_size_chooser=document.createElement('div');this.radius_size_chooser.id="radius_size_chooser";var radio_buttons_container=document.createElement('div');var bodyText=document.createElement('span');bodyText.innerHTML="Radius (m)";radio_buttons_container.appendChild(bodyText);radio_buttons_container.id="radio_buttons_container";radio_buttons_container.setAttribute('class','x-dlg-bd');for(var i=0;i<this.radio_buttons_count;i++){var r_button=document.createElement("input");r_button.name="circle_cize";r_button.type="radio";r_button.value=this.initial_value+this.step*i;var span=document.createElement('span');span.appendChild(r_button);var label=document.createElement('label');label.textContent=this.initial_value+this.step*i+" m";span.appendChild(label);radio_buttons_container.appendChild(span);}
radio_buttons_container.getElementsByTagName("input")[0].checked=true;this.radius_size_chooser.appendChild(radio_buttons_container);document.body.appendChild(this.radius_size_chooser);this.window=new Ext.BasicDialog('radius_size_chooser',{collapsible:false,width:500,height:100,shadow:true,modal:true,resizable:false,title:"Add cordon"});this.ok_button=this.window.addButton('Ok',this.doPressOkButton.bind(this),this.window);},up:function(evt){return true;},down:function(evt){var maploc=this.map.getLonLatFromPixel(evt.xy);var point=new OpenLayers.Geometry.Point(maploc.lon,maploc.lat);var bbox=new OpenLayers.LonLat(point.x,point.y);this.center=bbox;var icon=new OpenLayers.CSIcon(this.FLAG_IMG_SRC,this.size,this.offset,null,0+this.getUnits());this.marker=new OpenLayers.Marker(bbox,icon);this.markers.addMarker(this.marker);this.window.show();OpenLayers.Handler.RegularPolygon.prototype.down.apply(this,arguments);},doPressOkButton:function(){var inputs=$(this.window.body.dom).getElementsBySelector('input');for(var i=0;i<inputs.length;i++){if(inputs[i].checked){this.radius=parseFloat(inputs[i].value);this.marker.icon.setIconText(parseFloat(inputs[i].value)+this.getUnits());this.origin=new OpenLayers.Geometry.Point(this.center.lon,this.center.lat);this.modifyGeometry();this.layer.drawFeature(this.feature,this.style);}}
this.control.layer.style=this.style;this.window.hide();},getUnits:function(){return"&nbsp;m";},activate:function(){if(this.control.layer==null)this.control.layer=new OpenLayers.Layer.Vector("Ruler Custom Circle");this.control.layer.style=this.style;this.map.addLayer(this.control.layer);this.markers=new OpenLayers.Layer.Markers("Ruler Markers");this.map.addLayer(this.markers);return OpenLayers.Handler.RegularPolygon.prototype.activate.apply(this,arguments);},deactivate:function(){this.control.layer.destroyFeatures();this.map.removeLayer(this.control.layer);this.map.removeLayer(this.markers);return OpenLayers.Handler.RegularPolygon.prototype.deactivate.apply(this,arguments);},CLASS_NAME:"OpenLayers.Handler.CSCircleCustomHandler"});OpenLayers.Control.BoundingBoxControlPanel=OpenLayers.Class.create();OpenLayers.Control.BoundingBoxControlPanel.prototype=OpenLayers.Class.inherit(OpenLayers.Control.Panel,{initialize:function(layer,options){OpenLayers.Control.Panel.prototype.initialize.apply(this,[options]);this.layer=layer;this.navigation=new OpenLayers.Control.Navigation();this.poly_drawer=new OpenLayers.Control.DrawFeature(layer,OpenLayers.Handler.Polygon,{'displayClass':'olControlDrawFeaturePolygon'});this.poly_drawer.featureAdded=this.bbox_added.bind(this);this.addControls([this.navigation,this.poly_drawer]);},bbox_added:function(feature)
{if(this.feature)this.feature.destroy();this.feature=feature;this.onsetbbox(feature.geometry)},set_bbox_from_wkt:function(wkt)
{wkt=wkt.replace(/SRID=-?\d+;/,'');var parser=new OpenLayers.Format.WKT();var feature=parser.read(wkt);if(feature)
{this.feature=feature;this.layer.addFeatures(feature);}},onsetbbox:function(geo)
{},CLASS_NAME:"OpenLayers.Control.BoundingBoxControlPanel"});OpenLayers.Control.CsSelectFeature=OpenLayers.Class.create();OpenLayers.Control.CsSelectFeature.prototype={initialize:function(layer)
{this.layer=layer;Event.observe(this.layer.div,'mousemove',this.mouseover.bindAsEventListener(this));Event.observe(this.layer.div,'click',this.clicked.bindAsEventListener(this));},mouseover:function(e)
{var f=this.feature(e);if(!f)
{if(this.selected)
{this.onmouseout(this.selected,e);this.selected=false;}}
else
{if(this.selected&&this.selected!=f)
{this.onmouseout(this.selected,e);this.selected=false;}
if(!this.selected)
{this.selected=f;this.onmouseover(f,e);}}},clicked:function(e)
{var f=this.feature(e);if(f)
{this.onclick(f,e);Event.stop(e);}},onclick:function(f,e){},onmouseover:function(f,e){},onmouseout:function(f,e){},feature:function(e)
{return this.layer.getFeatureFromEvent(e);}};