function PolygonControl(D){var A=this;A.type="polygon";A.name=A.type+"Control";A.zuper=null;A.digitizerShape=null;A.editLineHandler=null;A.endLineHandler=null;A.infoWindowHtml="";A.infoWindowTabs=[];A.styles={standard:{}};A.storage=[];A.Options={button_opts:{img_up_url:"http://www.google.com/intl/en_us/mapfiles/ms/t/Bpu.png",img_down_url:"http://www.google.com/intl/en_us/mapfiles/ms/t/Bpd.png",name:"polygon",tooltip:"Draw a shape"},position:{controlPosition:[245,3]},tooltip:{anchor:[-30,-8],cursor_on:"",cursor_off:"",titles:{start:"Click to start drawing a shape",middle:"Click to continue drawing a shape",end:"Click a vertex once, or double click on the map to end this shape"},callback:null},newGeometryOptions:{strokeColor:"#000000",strokeWeight:3,strokeOpacity:0.25,fillColor:"#0000FF",fillOpacity:0.45,opts:{clickable:true}},geometryListenerOpts:{mouseoverEditingEnabled:true,infoWindowHtmlEnabled:true,mouseoverHighlightingEnabled:true,infoWindowTabsEnabled:false,assembleInfoWindowTabs:function(){A.infoWindowTabs.push(new GInfoWindowTab("Geometry Controls",A.infoWindowHtml));A.infoWindowTabs.push(new GInfoWindowTab("Example Tab",A.zuper.infoWindowHtmlTemplates["infoWindowTabContent1"]))}},multiEdit:false,htmlTemplateParams:{},cssId:"emmc-polygon",optionalGeometryListeners:null,autoSave:false};if(typeof (D)!="undefined"){for(var C in D){if(typeof (D[C])==="object"){for(var B in D[C]){A.Options[C][B]=D[C][B]}}else{A.Options[C]=D[C]}}}else{}}PolygonControl.prototype=new GControl();PolygonControl.prototype.getDefaultPosition=function(){var A=this;return A.zuper.getDefaultPosition(A.Options.position)};PolygonControl.prototype.initialize=function(C){var B=this;B.container=document.createElement("div");B.container.id="mymaps-control-"+B.Options.button_opts.name;var A=B.zuper.createButton({controlName:B.name,button_opts:B.Options.button_opts,startDigitizing:function(){B.startDigitizing()},stopDigitizing:function(D){B.stopDigitizing(D)}});B.container.appendChild(A.img);C.getContainer().appendChild(B.container);B.runInitFunctions();return B.container};PolygonControl.prototype.runInitFunctions=function(){var A=this;A.tooltip();A.assembleInfoWindowHtml(A.Options.htmlTemplateParams);A.extendGPolygon()};PolygonControl.prototype.startDigitizing=function(){var B=this,D=B.zuper,C=D.map,A=B.Options;B.tooltip.on(A.tooltip.titles["start"]);B.digitizerShape=B.newGPolygon([],A.newGeometryOptions);C.addOverlay(B.digitizerShape);B.digitizerShape.enableDrawing({});B.editLineHandler=GEvent.addListener(B.digitizerShape,"lineupdated",function(){switch(B.digitizerShape.getVertexCount()){case 2:B.tooltip.tooltipContainer.innerHTML=A.tooltip.titles["middle"];break;case 3:B.tooltip.tooltipContainer.innerHTML=A.tooltip.titles["end"];break}});GEvent.addListener(B.digitizerShape,"cancelline",function(){B.stopDigitizing()});B.endLineHandler=GEvent.addListener(B.digitizerShape,"endline",function(H){var G=[];for(var F=0;F-1){var G=A.replace("stroke","").toLowerCase();I[G]=C=K[A]}if(A.indexOf("fill")>-1){var G=A.replace("fill","").toLowerCase();J[G]=D=K[A]}}if(C){H.setStrokeStyle(I)}if(D){H.setFillStyle(J)}for(var B in K){H.unsavedStyle[B]=K[B]}}};PolygonControl.prototype.hoverTooltip=function(){};PolygonControl.prototype.loadPolygons=function(A){var C=this;var B=C.createPolygon(A.coordinates,C.infoWindowHtml,false,A.style);C.storage[B.index].title=[A.title,A.title];C.storage[B.index].description=[A.description,A.description];C.zuper.map.addOverlay(B);return B};PolygonControl.prototype.newGPolygon=function(B,A){return new GPolygon(B,A.strokeColor,A.strokeWeight,A.strokeOpacity,A.fillColor,A.fillOpacity,A.opts)};PolygonControl.prototype.extendGPolygon=function(){GPolygon.unsavedStyle={};GPolygon.savedStyle={};GPolygon.prototype.getStrokeWeight=function(){return(this.unsavedStyle.strokeWeight||this.savedStyle.strokeWeight)};GPolygon.prototype.setStrokeWeight=function(A){if(!isNaN(A)){this.unsavedStyle.strokeWeight=(A>20)?20:(A<1)?1:A}else{this.unsavedStyle.strokeWeight=this.savedStyle.strokeWeight}return this.unsavedStyle.strokeWeight||this.savedStyle.strokeWeight};GPolygon.prototype.getStrokeOpacity=function(){return(this.unsavedStyle.strokeOpacity||this.savedStyle.strokeOpacity)*100};GPolygon.prototype.setStrokeOpacity=function(B){if(!isNaN(B)){var A=(B>100)?100:(B<0)?0:B;this.unsavedStyle.strokeOpacity=A/100}else{this.unsavedStyle.strokeOpacity=this.savedStyle.strokeOpacity}return this.unsavedStyle.strokeOpacity||this.savedStyle.strokeOpacity};GPolygon.prototype.getFillOpacity=function(){return(this.unsavedStyle.fillOpacity||this.savedStyle.fillOpacity)*100};GPolygon.prototype.setFillOpacity=function(B){if(!isNaN(B)){var A=(B>100)?100:(B<0)?0:B;this.unsavedStyle.fillOpacity=A/100}else{this.unsavedStyle.fillOpacity=this.savedStyle.fillOpacity}return this.unsavedStyle.fillOpacity||this.savedStyle.fillOpacity}}