window.GSVectorGraphicsConstants={resourceURL:(document.location.protocol.indexOf("http")==-1?"http:":document.location.protocol)+"//api.geosmart.co.nz/images/svg-v1-rc3/"};GSUtil.extend(GSVectorGraphics,GSMapFeature);function GSVectorGraphics(a){this.options={style:{fill:"#3886d9","fill-opacity":0.3,stroke:"#3886d9","stroke-width":"1px","stroke-opacity":0.9,"stroke-linejoin":"round","stroke-linecap":"round"},textStyle:{"font-family":"Helvetica, Arial, Sans-serif","font-size":"12px","font-weight":"normal","font-style":"normal",color:"black"}};GSUtil.merge(a,this.options);GSVectorGraphics.baseConstructor.call(this,this.options);this.textEl=undefined;if(_browser.svg){this.textEl=document.createElementNS(_globals.svgns,"text");this.textEl.setAttributeNS(null,"pointer-events","none")}else{if(_browser.isIE6up){this.textEl=document.createElement(_globals.vmlnsPrefix,":textbox")}}this.resizeToLayer=false;this.isShowingInfo=false;this.setText(this.options.text,this.options["text-position"],this.options["text-style"])}GSVectorGraphics.prototype.setText=function(e,b,c){if(!this.textEl){return}this.text=e;this.textPosition=b||new GSPoint(0,0);if(this.text){while(this.textEl.firstChild){this.textEl.removeChild(this.textEl.firstChild)}var a=document.createTextNode(this.text);this.textEl.appendChild(a)}for(var d in c){this.options.textStyle[d]=c[d]}if(_browser.svg){this.textEl.setAttributeNS(null,"font-family",this.options.textStyle["font-family"]);this.textEl.setAttributeNS(null,"font-size",this.options.textStyle["font-size"]);this.textEl.setAttributeNS(null,"font-weight",this.options.textStyle["font-weight"]);this.textEl.setAttributeNS(null,"font-style",this.options.textStyle["font-style"]);this.textEl.setAttributeNS(null,"fill",this.options.textStyle.color)}else{if(_browser.isIE6up){this.textEl.style.fontFamily=this.options.textStyle["font-family"];this.textEl.style.fontSize=this.options.textStyle["font-size"];this.textEl.style.fontWeight=this.options.textStyle["font-weight"];this.textEl.style.fontStyle=this.options.textStyle["font-style"];this.textEl.style.color=this.options.textStyle.color}}if(this.onmap&&this.text){this.renderText()}};GSVectorGraphics.prototype.renderText=function(){if(!this.textEl){return}var a=this.getBounds();var j=this.map.translateToMapCoordinate(new GSPoint(a.minX,a.maxY));var h=this.map.translateToMapCoordinate(new GSPoint(a.maxX,a.maxY));var b=this.map.translateToMapCoordinate(new GSPoint(a.minX,a.minY));if(_browser.svg){if(this.options.textStyle["display-threshold"]<this.map.scaleIdx){this.textEl.setAttributeNS(null,"visibility","hidden");return}else{this.textEl.setAttributeNS(null,"visibility","inherit")}if(this.options.textStyle["text-align"]){var e=0;switch(this.options.textStyle["text-align"]){case"left":break;case"center":var g=this.textEl.getComputedTextLength();var f=h.x-j.x;e=(f-g)/2;break;case"right":this.textEl.setAttributeNS(null,"text-anchor","end");e=h.x-j.x;break}this.textEl.setAttributeNS(null,"x",j.x+e)}else{this.textEl.setAttributeNS(null,"x",j.x+this.textPosition.x)}if(this.options.textStyle["vertical-align"]){switch(this.options.textStyle["vertical-align"]){case"top":this.textEl.setAttributeNS(null,"y",j.y+this.textEl.getBBox().height);break;case"middle":var i=this.textEl.getBBox().height;var c=b.y-j.y;var d=(c-i)/2;this.textEl.setAttributeNS(null,"y",j.y+this.textEl.getBBox().height+d);break;case"bottom":this.textEl.setAttributeNS(null,"y",b.y);break}}else{this.textEl.setAttributeNS(null,"y",j.y+this.textEl.getBBox().height+this.textPosition.y)}}else{if(_browser.isIE6up){if(this.options.textStyle["display-threshold"]<this.map.scaleIdx){this.textEl.style.visibility="hidden";return}else{this.textEl.style.visibility="visible"}this.textEl.style.position="relative";this.textEl.style.left=0;this.textEl.style.top=0;var f=Math.round(h.x)-Math.round(j.x);var c=Math.round(b.y)-Math.round(j.y);this.textEl.style.height=c+"px";if(this.options.textStyle["text-align"]){this.graphicsEl.style.textAlign=this.options.textStyle["text-align"]}else{this.textEl.style.paddingLeft=this.textPosition.x+"px"}if(this.options.textStyle["vertical-align"]){var i=parseInt(this.options.textStyle["font-size"]);switch(this.options.textStyle["vertical-align"]){case"top":this.textEl.style.top=0;break;case"middle":this.textEl.style.top=((c-i)/2)>=0?((c-i)/2):0;break;case"bottom":this.textEl.style.top=(c-i);break}}else{this.textEl.style.top=this.textPosition.y}}}};GSVectorGraphics.prototype.getBounds=function(){};GSVectorGraphics.prototype.getStyle=function(){return this.options.style};GSVectorGraphics.prototype.setStyle=function(a){for(var c in a){var b=a[c];switch(c){case"stroke":this.setStroke(b);break;case"stroke-width":this.setStrokeWidth(b);break;case"stroke-opacity":this.setStrokeOpacity(b);break;case"stroke-linecap":this.setStrokeLinecap(b);break;case"stroke-linejoin":this.setStrokeLinejoin(b);break;case"stroke-style":this.setStrokeStyle(b);break;case"fill":this.setFill(b);break;case"fill-opacity":this.setFillOpacity(b);break;case"opacity":this.setOpacity(b);break;default:this.graphicsEl.style[c]=b;break}}};GSVectorGraphics.prototype.getStroke=function(){return this.options.style.stroke};GSVectorGraphics.prototype.setStroke=function(a){this.options.style.stroke=a;return this._setStroke(a)};GSVectorGraphics.prototype._setStroke=function(a){if(_browser.svg){this.setStyleProperty("stroke",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");if(b=="none"){this.setStyleProperty("on",false,b)}else{this.setStyleProperty("color",a,b)}}}return this};GSVectorGraphics.prototype.getStrokeWidth=function(){return parseInt(this.options.style["stroke-width"])};GSVectorGraphics.prototype.setStrokeWidth=function(a){this.options.style["stroke-width"]=a;return this._setStrokeWidth(a)};GSVectorGraphics.prototype._setStrokeWidth=function(a){if(_browser.svg){this.setStyleProperty("stroke-width",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");var c=""+a;if(isNaN(parseInt(c.charAt(c.length-1),10))==false){a+="px"}this.setStyleProperty("weight",a,b)}}return this};GSVectorGraphics.prototype.getStrokeOpacity=function(){return parseFloat(this.options.style["stroke-opacity"])};GSVectorGraphics.prototype.setStrokeOpacity=function(a){this.options.style["stroke-opacity"]=a;return this._setStrokeOpacity(a)};GSVectorGraphics.prototype._setStrokeOpacity=function(a){if(_browser.svg){this.setStyleProperty("stroke-opacity",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");this.setStyleProperty("opacity",a,b)}}return this};GSVectorGraphics.prototype.getStrokeLinecap=function(){return this.options.style["stroke-linecap"]};GSVectorGraphics.prototype.setStrokeLinecap=function(a){this.options.style["stroke-linecap"]=a;return this._setStrokeLinecap(a)};GSVectorGraphics.prototype._setStrokeLinecap=function(a){if(_browser.svg){this.setStyleProperty("stroke-linecap",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");this.setStyleProperty("endcap",a,b)}}return this};GSVectorGraphics.prototype.getStrokeLinejoin=function(){return this.options.style["stroke-linejoin"]};GSVectorGraphics.prototype.setStrokeLinejoin=function(a){this.options.style["stroke-linejoin"]=a;return this._setStrokeLinejoin(a)};GSVectorGraphics.prototype._setStrokeLinejoin=function(a){if(_browser.svg){this.setStyleProperty("stroke-linejoin",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");this.setStyleProperty("joinstyle",a,b)}}return this};GSVectorGraphics.prototype.getStrokeStyle=function(){return this.options.style["stroke-style"]};GSVectorGraphics.prototype.setStrokeStyle=function(a){this.options.style["stroke-style"]=a;return this._setStrokeStyle(a)};GSVectorGraphics.prototype._setStrokeStyle=function(a){if(_browser.svg){if(a=="solid"){this.setStyleProperty("stroke-dasharray","none")}else{this.setStyleProperty("stroke-dasharray",this.options.style["stroke-width"])}}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");if(a=="solid"){this.setStyleProperty("stroke-dasharray","1",b)}else{this.setStyleProperty("dashstyle","1 1",b)}}}return this};GSVectorGraphics.prototype.getFill=function(){return this.options.style.fill};GSVectorGraphics.prototype.setFill=function(a){this.options.style.fill=a;return this._setFill(a)};GSVectorGraphics.prototype._setFill=function(a){if(_browser.svg){this.setStyleProperty("fill",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"fill");if(a=="none"){this.setStyleProperty("on",false,b)}else{this.setStyleProperty("color",a,b)}}}return this};GSVectorGraphics.prototype.getFillOpacity=function(){return parseFloat(this.options.style["fill-opacity"])};GSVectorGraphics.prototype.setFillOpacity=function(a){this.options.style["fill-opacity"]=a;return this._setFillOpacity(a)};GSVectorGraphics.prototype._setFillOpacity=function(a){if(_browser.svg){this.setStyleProperty("fill-opacity",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"fill");this.setStyleProperty("opacity",a,b)}}return this};GSVectorGraphics.prototype.getOpacity=function(){return parseFloat(this.options.style.opacity)};GSVectorGraphics.prototype.setOpacity=function(a){this.options.style.opacity=a;return this._setOpacity(a)};GSVectorGraphics.prototype._setOpacity=function(c){if(_browser.svg){this.setStyleProperty("opacity",c)}else{if(_browser.isIE6up){var a=GSUtil.roundNumber(c*this.options.style["fill-opacity"],2);this._setFillOpacity(a);var b=GSUtil.roundNumber(c*this.options.style["stroke-opacity"],2);this._setStrokeOpacity(b)}}return this};GSVectorGraphics.prototype.setStyleProperty=function(b,d,c){if(!c){c=this.graphicsEl}var a="";if(_browser.svg){a=c.getAttributeNS(null,b);c.setAttributeNS(null,b,d)}else{if(_browser.isIE6up){a=c.getAttribute(b);c[b]=d}}if(this.onmap){this.map.container.scrollLeft=this.map.container.scrollLeft}this.broadcastMessage("shapeStyleChanged",this,b,a,d)};GSVectorGraphics.prototype.getPreparedCanvasContext=function(){var a=this.graphicsEl.getContext("2d");a.clearRect(0,0,a.canvas.width,a.canvas.height);this.applyStylesToCanvasContext(a);return a};GSVectorGraphics.prototype.applyStylesToCanvasContext=function(a){for(var c in this.options.style){if(this.options.style.hasOwnProperty(c)){var b=this.options.style[c];switch(c){case"stroke":if(this.options.style["stroke-opacity"]){a.strokeStyle=(new GSColor(b,this.options.style["stroke-opacity"])).toRGBA()}else{a.strokeStyle=b}break;case"stroke-width":a.lineWidth=parseFloat(b);break;case"stroke-opacity":if(this.options.style.stroke){a.strokeStyle=(new GSColor(this.options.style.stroke,b)).toRGBA()}else{a.strokeStyle="rgba(0, 0, 0, "+b+")"}break;case"stroke-linecap":a.lineCap=b;break;case"stroke-linejoin":a.lineJoin=b;break;case"stroke-style":break;case"fill":if(this.options.style["fill-opacity"]){a.fillStyle=(new GSColor(b,this.options.style["fill-opacity"])).toRGBA()}else{a.fillStyle=b}break;case"fill-opacity":if(this.options.style.fill){a.fillStyle=(new GSColor(this.options.style.fill,b)).toRGBA()}else{a.fillStyle="rgba(0, 0, 0, "+b+")"}break;case"opacity":a.globalAlpha=b;break}}}};GSVectorGraphics.prototype.getChildElement=function(c,a){var b=null;if(_browser.svg){b=c.getElementsByTagNameNS(_globals.svgns,a)[0]}else{if(_browser.isIE6up){b=c.getElementsByTagName(a)[0]}else{if(_browser.canvas){return null}}}if(!b){if(_browser.svg){b=document.createElementNS(_globals.svgns,a)}else{if(_browser.isIE6up){b=document.createElement(_globals.vmlnsPrefix+":"+a)}}c.appendChild(b)}return b};GSVectorGraphics.prototype.setVisible=function(a){this.visible=a;if(this.graphicsEl){if(_browser.svg){this.graphicsEl.setAttributeNS(null,"visibility",(a===true?"inherit":"hidden"))}else{if(_browser.isIE6up){this.graphicsEl.style.visibility=(a===true?"inherit":"hidden")}else{if(_browser.canvas){this.graphicsEl.style.visibility=(a===true?"inherit":"hidden")}}}}if(this.onmap&&this.visible){this.render()}};GSVectorGraphics.prototype.addToLayer=function(a){if(!a.vectorContainer){a.vectorContainer=a.createVectorContainer()}if(_browser.svg){GSUtil.makeUnselectable(this.graphicsEl);GSUtil.makeUnselectable(this.textEl);a.vectorContainer.appendChild(this.graphicsEl);a.vectorContainer.appendChild(this.textEl)}else{if(_browser.isIE6up){if(this.resizeToLayer){this.graphicsEl.style.width=a.map.pxWidth;this.graphicsEl.style.height=a.map.pxHeight;this.graphicsEl.coordsize=a.map.pxWidth+" "+a.map.pxHeight}this.graphicsEl.setAttribute("unselectable","on");this.textEl.setAttribute("unselectable","on");a.vectorContainer.appendChild(this.graphicsEl);this.graphicsEl.appendChild(this.textEl)}else{if(_browser.canvas){this.graphicsEl.width=a.map.pxWidth;this.graphicsEl.height=a.map.pxHeight;GSUtil.positionElement(this.graphicsEl,0,0);a.vectorContainer.appendChild(this.graphicsEl)}}}GSVectorGraphics.superClass.addToLayer.call(this,a)};GSVectorGraphics.prototype.render=function(){if(this.text){this.renderText()}};GSVectorGraphics.prototype.pixelIsTransparent=function(a){var b=this.graphicsEl.getContext("2d");var c=b.getImageData(a.x,a.y,1,1);return(c.data[3]==0)};GSVectorGraphics.prototype.touchstartHandler=function(b){var a=GSUtil.getTouchPixelCoordinate(b.touches[0],this.graphicsEl);if(!this.pixelIsTransparent(a)){GSVectorGraphics.superClass.touchstartHandler.call(this,b)}};GSVectorGraphics.prototype.clickHandler=function(b){if(!_browser.svg&&!_browser.isIE6up&&_browser.canvas){var a;if(_browser.isMobileWebkit){a=GSUtil.getTouchPixelCoordinate(b.changedTouches[0],this.graphicsEl)}else{a=GSUtil.getMousePixelCoordinate(b,this.graphicsEl)}if(!this.pixelIsTransparent(a)){GSVectorGraphics.superClass.clickHandler.call(this,b)}}else{GSVectorGraphics.superClass.clickHandler.call(this,b)}};GSVectorGraphics.prototype.mapResized=function(a){if(!_browser.svg&&_browser.isIE6up){if(this.resizeToLayer){this.graphicsEl.style.width=a.pxWidth;this.graphicsEl.style.height=a.pxHeight;this.graphicsEl.coordsize=a.pxWidth+" "+a.pxHeight}}else{if(_browser.canvas){this.graphicsEl.width=a.pxWidth;this.graphicsEl.height=a.pxHeight}}this.render()};GSVectorGraphics.prototype.getInfoWindowOptions=function(){return{title:this.type}};GSVectorGraphics.prototype.remove=function(){if(this.snappable){this.layer.map.removeSnappable(this)}try{if(_browser.svg){this.layer.vectorContainer.removeChild(this.graphicsEl);this.layer.vectorContainer.removeChild(this.textEl)}else{if(_browser.isIE6up){this.graphicsEl.removeChild(this.textEl);this.layer.vectorContainer.removeChild(this.graphicsEl)}else{if(_browser.canvas){this.layer.vectorContainer.removeChild(this.graphicsEl)}}}}catch(a){}GSVectorGraphics.superClass.remove.call(this)};GSVectorGraphics.canvasDashedLine=function(j,h,e,a,f,l){if(!l){l=[10,5]}j.save();var m=(a-h),k=(f-e);var c=Math.sqrt(m*m+k*k);var b=Math.atan2(k,m);j.translate(h,e);j.moveTo(0,0);j.rotate(b);var i=l.length;var d=0,g=true;h=0;while(c>h){h+=l[d++%i];if(h>c){h=c}g?j.lineTo(h,0):j.moveTo(h,0);g=!g}j.restore()};if(!_browser.svg&&_browser.isIE6up){var ss=document.createStyleSheet();ss.cssText="v\\:group, v\\:oval, v\\:line, v\\:shape, v\\:rect, v\\:roundrect, v\\:textbox, v\\:stroke, v\\:fill { behavior: url(#default#VML);";(function(){var b=false;for(var a=0;a<document.namespaces.length;a++){if(document.namespaces[a].name=="v"){b=true;break}}if(!b){document.namespaces.add("v","urn:schemas-microsoft-com:vml")}})()}GSUtil.extend(GSPolyline,GSVectorGraphics);function GSPolyline(b,a){this.options={snapHandles:false,snappable:false,clickToEdit:false,editable:false,style:{fill:"none",stroke:"blue","stroke-opacity":0.6,"stroke-width":"7px"}};GSUtil.merge(a,this.options);GSPolyline.baseConstructor.call(this,this.options);this.type="GSPolyline";this.resizeToLayer=true;this.graphicsEl=undefined;if(_browser.svg){this.graphicsEl=document.createElementNS(_globals.svgns,"polyline")}else{if(_browser.isIE6up){this.graphicsEl=document.createElement(_globals.vmlnsPrefix+":shape")}else{if(_browser.canvas){this.graphicsEl=document.createElement("canvas")}}}this.setStyle(this.options.style);if(this.options.editable){this.handles=[];this.handles.indexOf=function(d){for(var e=0,c=this.length;e<c;e++){if(this[e]==d){return e}}return -1};this.createHandles(b);this.insertHandles=[];this.insertHandles.indexOf=function(d){for(var e=0,c=this.length;e<c;e++){if(this[e]==d){return e}}return -1};this.createInsertHandles()}else{this.points=b;this.points.indexOf=function(d){for(var e=0,c=this.length;e<c;e++){if(this[e]==d){return e}}return -1}}this.editing=false;this.selectable=true}GSPolyline.prototype.clickHandler=function(a){if(!this.options.isDrawFeature){GSPolyline.superClass.clickHandler.call(this,a)}};GSPolyline.prototype.initializeContextMenu=function(){if(this.options.editable){if(!GSModule.isLoaded("additional-ui")){throw new Error("Cannot create GSMenuItem. Has the additional-ui module been loaded?")}var a;if(!this.options.clickToEdit){a=new GSMenuItem("Change shape",{action:GSUtil.bind(this.startEditing,this)});this.options.contextMenuItems.push(a)}a=new GSMenuItem("Delete shape",{action:GSUtil.bind(this.remove,this)});this.options.contextMenuItems.push(a)}GSPolyline.superClass.initializeContextMenu.call(this)};GSPolyline.prototype.setPoints=function(a){if(this.options.editable){this.removeHandles();this.createHandles(a)}else{this.points=a}this.render()};GSPolyline.prototype.getPoints=function(){if(this.options.editable){var c=[];for(var b=0,a=this.handles.length;b<a;b++){c.push(this.handles[b].point)}return c}else{return this.points}};GSPolyline.prototype.getHandles=function(){return this.handles};GSPolyline.prototype.shouldSnapHandles=function(){return this.options.snapHandles};GSPolyline.prototype.isSnappable=function(){return this.options.snappable};GSPolyline.prototype.createHandles=function(c){if(c){for(var b=0,a=c.length;b<a;b++){var d=this.createHandle(c[b]);this.handles.push(d)}}};GSPolyline.prototype.removeHandles=function(){for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].remove()}this.handles.length=0};GSPolyline.prototype.createInsertHandles=function(){for(var d=0,a=this.handles.length-1;d<a;d++){var c=this.handles[d];var b=this.handles[d+1];var f=this.getIntermediatePoint(c.point,b.point);var e=this.createInsertHandle(f,c,b);this.insertHandles.push(e)}};GSPolyline.prototype.updateInsertHandles=function(){for(var c=0,a=this.handles.length-1;c<a;c++){var b=this.insertHandles[c];var f=this.handles[c].point;var e=this.handles[c+1].point;var d=this.getIntermediatePoint(f,e);b.point=d;b.render()}};GSPolyline.prototype.removeInsertHandles=function(){for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].remove()}this.insertHandles.length=0};GSPolyline.prototype.recreateInsertHandles=function(){this.removeInsertHandles();this.createInsertHandles();this.addHandles(this.layer,this.insertHandles);for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(this.editing)}};GSPolyline.prototype.isCreating=function(){return this.creating};GSPolyline.prototype.startCreating=function(){if(this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(true)}for(b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(true)}this.editing=true};GSPolyline.prototype.stopEditing=function(){if(!this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(false)}for(b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(false)}this.editing=false};GSPolyline.prototype.isEditing=function(){return this.editing};GSPolyline.prototype.startEditing=function(){if(this.editing){return}if(!this.options.editable){throw new Exception("Cannot start editing a non-editable GSPolyline. Set editable option to true when instantiating.")}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(true)}for(b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(true)}this.editing=true};GSPolyline.prototype.stopEditing=function(){if(!this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(false)}for(b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(false)}this.editing=false};GSPolyline.prototype.showHandles=function(){this.startEditing()};GSPolyline.prototype.addHandles=function(d,c){for(var b=0,a=c.length;b<a;b++){c[b].addToLayer(d)}};GSPolyline.prototype.addPoint=function(a){if(this.options.editable){var b=this.createHandle(a);this.addHandle(b)}else{this.points.push(a);if(this.onmap){this.render()}}};GSPolyline.prototype.addPointAt=function(b,a){if(this.options.editable){var c=this.createHandle(b);this.addHandleAt(c,a)}else{this.points.splice(a,0,b);if(this.onmap){this.render()}}};GSPolyline.prototype.replacePoint=function(c,f){var a;if(this.options.editable){a=0;for(var d=0,b=this.handles.length;d<b;d++){if(handles[d].point.equals(f)){a=d;break}}var e=this.createHandle(c);this.addHandleAt(e,a)}else{a=this.points.indexOf(f);this.points.splice(a,1,c);if(this.onmap){this.render()}}};GSPolyline.prototype.createHandle=function(a){var b=new GSHandle(this,new GSPoint(a.x,a.y));b.addListener(this);return b};GSPolyline.prototype.createInsertHandle=function(a,c,b){var d=new GSHandle(this,a,{isInsertHandle:true,beforeHandle:c,afterHandle:b});d.addListener(this);return d};GSPolyline.prototype.addHandle=function(a){this.handles.push(a);this._addHandle(a)};GSPolyline.prototype.addHandleAt=function(b,a){this.handles.splice(a,0,b);this._addHandle(b)};GSPolyline.prototype.replaceHandle=function(c,b){var a=this.handles.indexOf(b);this.handles.splice(a,1,c);this._addHandle(c)};GSPolyline.prototype.removeHandle=function(c){for(var b=0,a=this.handles.length;b<a;b++){if(c.point.equals(this.handles[b].point)){this.handles.splice(b,1);c.remove();this.recreateInsertHandles();if(this.onmap){this.render()}return true}}return false};GSPolyline.prototype._addHandle=function(a){this.recreateInsertHandles();if(this.onmap){a.addToLayer(this.layer);this.render()}};GSPolyline.prototype.hideHandles=function(){this.stopEditing()};GSPolyline.prototype.removePoint=function(a){var c,b;if(this.options.editable){for(c=0,b=this.handles.length;c<b;c++){if(a.equals(this.handles[c].point)){return this.removeHandle(this.handles[c])}}}else{for(c=0,b=this.points.length;c<b;c++){if(a.equals(this.points[c])){this.points.splice(c,1);if(this.onmap){this.render()}return true}}}return false};GSPolyline.prototype.removePointAt=function(a){if(this.options.editable){var b=this.handles.splice(a,1)[0];b.remove();this.recreateInsertHandles()}else{this.points.splice(a,1)}if(this.onmap){this.render()}return true};GSPolyline.prototype.addToLayer=function(a){if(this.options.editable){this.addHandles(a,this.handles);this.addHandles(a,this.insertHandles)}GSPolyline.superClass.addToLayer.call(this,a)};GSPolyline.prototype.render=function(){if(this.isVisible()){GSPolyline.superClass.render.call(this);var a=(this.options.editable?this.handles:this.points);if(a){var g=this.translateToMapPoints();if(_browser.svg){this.graphicsEl.setAttributeNS(null,"points",g);this.layer.map.container.scrollLeft=this.layer.map.container.scrollLeft}else{if(_browser.isIE6up){var f=g[0];var d=g[1];g.splice(0,2);var h="m "+f+","+d+" l "+g.join(",")+" e";this.graphicsEl.style.display="none";this.graphicsEl.path=h;this.graphicsEl.style.display=""}else{if(_browser.canvas){var c=this.getPreparedCanvasContext();c.beginPath();for(var e=0,b=g.length;e<b;e+=2){c.lineTo(g[e],g[e+1])}c.stroke()}}}}}};GSPolyline.prototype.getIntermediatePoint=function(i,h){var d=Math.min(i.x,h.x);var c=Math.min(i.y,h.y);var b=Math.max(i.x,h.x);var a=Math.max(i.y,h.y);var f=d+((b-d)/2);var e=c+((a-c)/2);var g=new GSPoint(f,e);return g};GSPolyline.prototype.translateToMapPoints=function(){var c,b,d=[];if(this.options.editable){for(c=0,b=this.handles.length;c<b;c++){var a=this.handles[c].point;var e=this.map.translateToMapCoordinate(a);d.push(Math.round(e.x));d.push(Math.round(e.y))}}else{for(c=0,b=this.points.length;c<b;c++){var a=this.points[c];var e=this.map.translateToMapCoordinate(a);d.push(Math.round(e.x));d.push(Math.round(e.y))}}return d};GSPolyline.prototype.closestPoint=function(g,f){var b=null;var j=this.getPoints();for(var e=(j.length-1),h=null;h=j[e];e--){var a=this.map.translateToMapCoordinate(h);var d=Math.abs(a.x-g.x);var c=Math.abs(a.y-g.y);if(d<f&&c<f){if(!b||Math.min(d,c)<b.delta){b={point:h,delta:Math.min(d,c)}}}}return b};GSPolyline.prototype.getBounds=function(){var b=this.getPoints();var a=GSUtil.getMinimum(GSUtil.getPropertyArray(b,"x"));var e=GSUtil.getMinimum(GSUtil.getPropertyArray(b,"y"));var d=GSUtil.getMaximum(GSUtil.getPropertyArray(b,"x"));var c=GSUtil.getMaximum(GSUtil.getPropertyArray(b,"y"));return new GSBounds(a,e,d,c)};GSPolyline.prototype.getInfoWindowPosition=function(){var a=this.getPoints();return a[Math.round(a.length/2)-1]};GSPolyline.prototype.remove=function(){if(this.options.editable){for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].remove()}for(b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].remove()}}GSPolyline.superClass.remove.call(this)};GSPolyline.prototype.select=function(){GSPolyline.superClass.select.call(this);if(this.onmap&&this.options.clickToEdit&&!this.editing){this.startEditing()}};GSPolyline.prototype.deselect=function(){GSPolyline.superClass.deselect.call(this);if(this.onmap&&this.editing){this.stopEditing()}};GSPolyline.prototype.toJson=function(){var a={type:this.type,style:GSUtil.toCC(this.options.style),points:this.getPoints(),visible:this.visible};if(this.options.text){a.text=this.options.text;a.textPosition=this.options.textPosition;a.textStyle=GSUtil.toCC(this.options.textStyle)}return GSUtil.objToJson(a)};GSPolyline.prototype.toWKT=function(){var e=[];var d=this.getPoints();for(var c=0,b=d.length;c<b;c++){var a=d[c];e.push(a.x+" "+a.y)}return"LINESTRING("+e.join(",")+")"};GSPolyline.prototype.toGML=function(){var e=[];var d=this.getPoints();for(var c=0,b=d.length;c<b;c++){var a=d[c];e.push(a.x+", "+a.y)}var f=[];f.push('<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:27200">');f.push("<gml:coordinates>"+e.join(" ")+"</gml:coordinates>");f.push("</gml:LineString>");return f.join("")};GSPolyline.prototype.clone=function(){var a=new GSPolyline({points:GSUtil.clone(this.getPoints()),style:GSUtil.clone(this.options.style)});return a};GSPolyline.prototype.projectPoint=function(b){var f=null;var a=null;var e=this.getPoints();if(e.length<2){throw new Exception("Polyline must contain at least two points to project a point onto it.")}for(var d=0,c=e.length-1;d<c;d++){var g=this._projectPointOnLineSegment(b,e[d],e[d+1]);if(f===null||g.distance<f){f=g.distance;a=g;a.start=e[d];a.end=e[d+1];if(f<=1){break}}}return a};GSPolyline.prototype._projectPointOnLineSegment=function(g,f,d){var b=f.distanceFrom(d);if(b<1){return{distance:g.distanceFrom(f),coordinate:f}}var e=((g.x-f.x)*(d.x-f.x)+(g.y-f.y)*(d.y-f.y))/Math.pow(b,2);if(e<1e-7){return{distance:g.distanceFrom(f),coordinate:f}}if(e>0.9999999){return{distance:g.distanceFrom(d),coordinate:d}}var c=new GSPoint(f.x+e*(d.x-f.x),f.y+e*(d.y-f.y));return{distance:g.distanceFrom(c),coordinate:c}};GSPolyline.prototype.handleDrag=function(a){this.render();if(!a.isInsertHandle()){this.updateInsertHandles()}};GSPolyline.prototype.handleDragEnd=function(b){if(b.isInsertHandle()){var c=this.createHandle(b.point);c.setVisible(true);var a=this.insertHandles.indexOf(b);this.addHandleAt(c,a+1)}else{this.render();this.updateInsertHandles()}this.broadcastMessage("shapeGeometryChanged",this)};GSPolyline.prototype.handleMoved=function(a){this.render();this.updateInsertHandles()};GSPolyline.prototype.pointDeleted=function(a){this.removePoint(a);this.broadcastMessage("shapeGeometryChanged",this)};GSUtil.extend(GSPolylineDrawingHandler,GSDrawingHandler);GSPolyline.drawingHandler=GSPolylineDrawingHandler;function GSPolylineDrawingHandler(c,b){var a={drawStyle:{fill:"none","fill-opacity":0,stroke:"black","stroke-width":"1px","stroke-opacity":1},viewStyle:{fill:"none","fill-opacity":0,stroke:"blue","stroke-opacity":0.6,"stroke-width":"7px"}};GSUtil.merge(b,a);GSPolylineDrawingHandler.baseConstructor.call(this,c,a)}GSPolylineDrawingHandler.prototype.createDrawFeature=function(){this.drawFeature=new GSPolyline([],{style:this.options.drawStyle,isDrawFeature:true});this.layer.addFeature(this.drawFeature);this.map.customCursor="crosshair";this.map.setCursor("")};GSPolylineDrawingHandler.prototype.mapClicked=function(b,c,a){if(this.drawing){this.addPoint(this.snapPoint(c))}};GSPolylineDrawingHandler.prototype.addPoint=function(b){if(this.drawing){var a=this;this.updatingLine=false;this.drawFeature.addPoint(b);if(this.drawFeature.getPoints().length==1){this.drawFeature.addPoint(b)}if(!this.mouseMoveListener){this.mouseMoveListener=GSEventManager.addEventListener(document,"mousemove",GSUtil.bindAsEventListener(this.updateLine,this))}}};GSPolylineDrawingHandler.prototype.updateLine=function(c){GSUtil.cancelEvent(c);var a=this.map.getMouseCoordinate(c);this.map.panPointIntoView(a,25);if(!this.updatingLine){this.updatingLine=true}else{var b=this.drawFeature.getPoints();this.drawFeature.removePointAt(b.length-1);this.drawFeature.addPoint(a)}};GSPolylineDrawingHandler.prototype.removeDrawFeature=function(){if(this.drawing){GSEventManager.removeEventListener(this.mouseMoveListener);delete this.mouseMoveListener;this.drawFeature.removePointAt(this.drawFeature.getPoints().length-1);var a=this.drawFeature.getPoints();this.layer.removeFeature(this.drawFeature);this.drawFeature=null;this.layer.removeFeature(this.closeFeature);this.closeFeature=null;this.map.customCursor=null;this.map.setCursor();return a}else{throw new Error("GSPolylineDrawingHandler.closePolyline called while not drawing.")}};GSPolylineDrawingHandler.prototype.createViewFeature=function(b){var a=new GSPolyline(b,this.options.featureOptions);this.layer.addFeature(a);return a};GSPolylineDrawingHandler.prototype.keyHandler=function(a){if(a.keyCode==GSKeyEvents.KEY_RETURN){this.stopDrawing()}GSPolylineDrawingHandler.superClass.keyHandler.call(this,a)};GSUtil.extend(GSPolygon,GSVectorGraphics);function GSPolygon(b,a){this.options={snapHandles:false,snappable:false,clickToEdit:false,editable:false};GSUtil.merge(a,this.options);GSPolygon.baseConstructor.call(this,this.options);this.type="GSPolygon";this.resizeToLayer=true;this.graphicsEl=undefined;if(_browser.svg){this.graphicsEl=document.createElementNS(_globals.svgns,"polygon")}else{if(_browser.isIE6up){this.graphicsEl=document.createElement(_globals.vmlnsPrefix+":shape")}else{if(_browser.canvas){this.graphicsEl=document.createElement("canvas")}}}this.setStyle(this.options.style);this.handles=[];this.handles.indexOf=function(d){for(var e=0,c=this.length;e<c;e++){if(this[e]==d){return e}}return -1};this.createHandles(b);this.insertHandles=[];this.insertHandles.indexOf=function(d){for(var e=0,c=this.length;e<c;e++){if(this[e]==d){return e}}return -1};this.createInsertHandles();this.editing=false;this.selectable=true}GSPolygon.prototype.initializeContextMenu=function(){if(this.options.editable){if(!GSModule.isLoaded("additional-ui")){throw new Error("Cannot create GSMenuItem. Has the additional-ui module been loaded?")}var a;if(!this.options.clickToEdit){a=new GSMenuItem("Change shape",{action:GSUtil.bind(this.startEditing,this)});this.options.contextMenuItems.push(a)}if(window.GSStyleInspector){a=new GSMenuItem("Change style...",{action:GSUtil.bind(this.showStyleInspector,this)});this.options.contextMenuItems.push(a)}a=new GSMenuItem("Delete shape",{action:GSUtil.bind(this.remove,this)});this.options.contextMenuItems.push(a)}GSPolygon.superClass.initializeContextMenu.call(this)};GSPolygon.prototype.getPoints=function(){var c=[];for(var b=0,a=this.handles.length;b<a;b++){c.push(this.handles[b].point)}return c};GSPolygon.prototype.getHandles=function(){return this.handles};GSPolygon.prototype.shouldSnapHandles=function(){return this.options.snapHandles};GSPolygon.prototype.isSnappable=function(){return this.options.snappable};GSPolygon.prototype.createHandles=function(c){if(c){for(var b=0,a=c.length;b<a;b++){var d=this.createHandle(c[b]);this.handles.push(d)}}};GSPolygon.prototype.removeHandles=function(){for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].remove()}this.handles.length=0};GSPolygon.prototype.createInsertHandles=function(){for(var d=0,a=this.handles.length;d<a;d++){var c=this.handles[d];var b=this.handles[(d+1)%a];var f=this.getIntermediatePoint(c.point,b.point);var e=this.createInsertHandle(f,c,b);this.insertHandles.push(e)}};GSPolygon.prototype.updateInsertHandles=function(){for(var c=0,a=this.handles.length;c<a;c++){var b=this.insertHandles[c];var f=this.handles[c].point;var e=this.handles[(c+1)%a].point;var d=this.getIntermediatePoint(f,e);b.point=d;b.render()}};GSPolygon.prototype.removeInsertHandles=function(){for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].remove()}this.insertHandles.length=0};GSPolygon.prototype.recreateInsertHandles=function(){this.removeInsertHandles();this.createInsertHandles();this.addHandles(this.layer,this.insertHandles);for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(true)}};GSPolygon.prototype.isCreating=function(){return this.creating};GSPolygon.prototype.startCreating=function(){if(this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(true)}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(true)}this.editing=true};GSPolygon.prototype.stopEditing=function(){if(!this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(false)}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(false)}this.editing=false};GSPolygon.prototype.isEditing=function(){return this.editing};GSPolygon.prototype.startEditing=function(){if(this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(true)}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(true)}this.editing=true};GSPolygon.prototype.stopEditing=function(){if(!this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(false)}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(false)}this.editing=false};GSPolygon.prototype.showHandles=function(){this.startEditing()};GSPolygon.prototype.addHandles=function(d,c){for(var b=0,a=c.length;b<a;b++){c[b].addToLayer(d)}};GSPolygon.prototype.addPoint=function(a){var b=this.createHandle(a);this.addHandle(b)};GSPolygon.prototype.addPointAt=function(b,a){var c=this.createHandle(b);this.addHandleAt(c,a)};GSPolygon.prototype.replacePoint=function(c,f){var a=0;for(var d=0,b=this.handles.length;d<b;d++){if(handles[d].point.equals(f)){a=d;break}}var e=this.createHandle(c);this.addHandleAt(e,a)};GSPolygon.prototype.createHandle=function(a){var b=new GSHandle(this,a);b.addListener(this);return b};GSPolygon.prototype.createInsertHandle=function(a,c,b){var d=new GSHandle(this,a,{isInsertHandle:true,beforeHandle:c,afterHandle:b});d.addListener(this);return d};GSPolygon.prototype.addHandle=function(a){this.handles.push(a);this._addHandle(a)};GSPolygon.prototype.addHandleAt=function(b,a){this.handles.splice(a,0,b);this._addHandle(b)};GSPolygon.prototype.replaceHandle=function(c,b){var a=this.handles.indexOf(b);this.handles.splice(a,1,c);this._addHandle(c)};GSPolygon.prototype.removeHandle=function(c){for(var b=0,a=this.handles.length;b<a;b++){if(c.point.equals(this.handles[b].point)){this.handles.splice(b,1);c.remove();this.recreateInsertHandles();if(this.onmap){this.render()}return true}}return false};GSPolygon.prototype._addHandle=function(a){this.recreateInsertHandles();if(this.onmap){a.addToLayer(this.layer);this.render()}};GSPolygon.prototype.hideHandles=function(){this.stopEditing()};GSPolygon.prototype.removePoint=function(a){for(var c=0,b=this.handles.length;c<b;c++){if(a.equals(this.handles[c].point)){return this.removeHandle(this.handles[c])}}return false};GSPolygon.prototype.removePointAt=function(a){var b=this.handles.splice(a,1)[0];b.remove();this.recreateInsertHandles();if(this.onmap){this.render()}return true};GSPolygon.prototype.setPoints=function(a){this.removeHandles();this.createHandles(a);this.render()};GSPolygon.prototype.addToLayer=function(a){this.addHandles(a,this.handles);this.addHandles(a,this.insertHandles);GSPolygon.superClass.addToLayer.call(this,a)};GSPolygon.prototype.render=function(){if(this.isVisible()){GSPolygon.superClass.render.call(this);if(this.handles){var f=this.translateToMapPoints();if(_browser.svg){this.graphicsEl.setAttributeNS(null,"points",f);this.layer.map.container.scrollLeft=this.layer.map.container.scrollLeft}else{if(_browser.isIE6up){var e=f[0];var c=f[1];f.splice(0,2);var g="m "+e+","+c+" l "+f.join(",")+" x e";this.graphicsEl.style.display="none";this.graphicsEl.path=g;this.graphicsEl.style.display=""}else{if(_browser.canvas){var b=this.getPreparedCanvasContext();b.beginPath();for(var d=0,a=f.length;d<a;d+=2){b.lineTo(f[d],f[d+1])}b.closePath();b.fill();b.stroke()}}}}}};GSPolygon.prototype.getIntermediatePoint=function(i,h){var d=Math.min(i.x,h.x);var c=Math.min(i.y,h.y);var b=Math.max(i.x,h.x);var a=Math.max(i.y,h.y);var f=d+((b-d)/2);var e=c+((a-c)/2);var g=new GSPoint(f,e);return g};GSPolygon.prototype.translateToMapPoints=function(){var d=[];for(var c=0,b=this.handles.length;c<b;c++){var a=this.handles[c].point;var e=this.map.translateToMapCoordinate(a);d.push(Math.round(e.x));d.push(Math.round(e.y))}return d};GSPolygon.prototype.closestPoint=function(g,f){var b=null;var j=this.getPoints();for(var e=(j.length-1),h=null;h=j[e];e--){var a=this.map.translateToMapCoordinate(h);var d=Math.abs(a.x-g.x);var c=Math.abs(a.y-g.y);if(d<f&&c<f){if(!b||Math.min(d,c)<b.delta){b={point:h,delta:Math.min(d,c)}}}}return b};GSPolygon.prototype.getBounds=function(){var d=[];for(var c=0,b=this.handles.length;c<b;c++){d.push(this.handles[c].point)}var a=GSUtil.getMinimum(GSUtil.getPropertyArray(d,"x"));var g=GSUtil.getMinimum(GSUtil.getPropertyArray(d,"y"));var f=GSUtil.getMaximum(GSUtil.getPropertyArray(d,"x"));var e=GSUtil.getMaximum(GSUtil.getPropertyArray(d,"y"));return new GSBounds(a,g,f,e)};GSPolygon.prototype.getInfoWindowPosition=function(){var d=this.getBounds();var b=d.maxX-d.minX;var c=d.maxY-d.minY;var a=new GSPoint(d.minX+(b/2),d.minY+(c/2));return a};GSPolygon.prototype.remove=function(){for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].remove()}for(b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].remove()}GSPolygon.superClass.remove.call(this)};GSPolygon.prototype.select=function(){GSPolygon.superClass.select.call(this);if(this.onmap&&this.options.clickToEdit&&!this.editing){this.startEditing()}};GSPolygon.prototype.deselect=function(){GSPolygon.superClass.deselect.call(this);if(this.onmap&&this.editing){this.stopEditing()}};GSPolygon.prototype.toJson=function(){var a={type:this.type,style:GSUtil.toCC(this.options.style),points:this.getPoints(),visible:this.visible};if(this.options.text){a.text=this.options.text;a.textPosition=this.options.textPosition;a.textStyle=GSUtil.toCC(this.options.textStyle)}return GSUtil.objToJson(a)};GSPolygon.prototype.toGML=function(){var e=[];var d=this.getPoints();for(var c=0,b=d.length;c<b;c++){var a=d[c];e.push(a.x+", "+a.y)}var f=[];f.push('<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:27200">');f.push("<gml:outerBoundaryIs>");f.push("<gml:LinearRing>");f.push("<gml:coordinates>"+e.join(" ")+"</gml:coordinates>");f.push("</gml:LinearRing>");f.push("</gml:outerBoundaryIs>");f.push("</gml:Polygon>");return f.join("")};GSPolygon.prototype.toWKT=function(){var e=[];var d=this.getPoints();for(var c=0,b=d.length;c<b;c++){var a=d[c];e.push(a.x+" "+a.y)}return"POLYGON(("+e.join(",")+"))"};GSPolygon.prototype.handleDrag=function(a){this.render();if(!a.isInsertHandle()){this.updateInsertHandles()}};GSPolygon.prototype.handleDragEnd=function(b){if(b.isInsertHandle()){var c=this.createHandle(b.point);c.setVisible(true);var a=this.insertHandles.indexOf(b);this.addHandleAt(c,a+1)}else{this.render();this.updateInsertHandles()}this.broadcastMessage("shapeGeometryChanged",this)};GSPolygon.prototype.handleMoved=function(a){this.render();this.updateInsertHandles()};GSPolygon.prototype.pointDeleted=function(a){this.removePoint(a);this.broadcastMessage("shapeGeometryChanged",this)};GSPolygon.prototype.showStyleInspector=function(){var a=GSStyleInspector.getInstance();a.show()};GSUtil.extend(GSPolygonDrawingHandler,GSDrawingHandler);GSPolygon.drawingHandler=GSPolygonDrawingHandler;function GSPolygonDrawingHandler(b,a){GSPolygonDrawingHandler.baseConstructor.call(this,b,a)}GSPolygonDrawingHandler.prototype.createDrawFeature=function(){this.drawFeature=new GSPolyline([],{style:this.options.drawStyle,isDrawFeature:true});this.layer.addFeature(this.drawFeature);this.map.customCursor="crosshair";this.map.setCursor("")};GSPolygonDrawingHandler.prototype.mapClicked=function(b,c,a){if(this.drawing){this.addPoint(this.snapPoint(c))}};GSPolygonDrawingHandler.prototype.addPoint=function(d){if(this.drawing){var a=this;this.updatingLine=false;this.drawFeature.addPoint(d);if(this.drawFeature.getPoints().length==1){this.drawFeature.addPoint(d);var b=new GSIcon();b.imageSrc=GSVectorGraphicsConstants.resourceURL+"close.png";b.imageSize=new GSDimension(15,15);b.iconOffset=new GSPoint(-8,-8);var c={coordinate:d,icon:b};this.closeFeature=new GSPointFeature(c);this.closeFeature.setTip("Click here to close the polygon",{showDelay:0,hideDelay:0});this.closeFeature.addEventHandler("click",GSUtil.bindAsEventListener(function(f){this.stopDrawing();GSUtil.cancelEvent(f)},this));this.layer.addFeature(this.closeFeature)}if(!this.mouseMoveListener){this.mouseMoveListener=GSEventManager.addEventListener(document,"mousemove",GSUtil.bindAsEventListener(this.updateLine,this))}}};GSPolygonDrawingHandler.prototype.updateLine=function(c){GSUtil.cancelEvent(c);var a=this.map.getMouseCoordinate(c);this.map.panPointIntoView(a,25);if(!this.updatingLine){this.updatingLine=true}else{var b=this.drawFeature.getPoints();this.drawFeature.removePointAt(b.length-1);this.drawFeature.addPoint(a)}};GSPolygonDrawingHandler.prototype.removeDrawFeature=function(){if(this.drawing){GSEventManager.removeEventListener(this.mouseMoveListener);delete this.mouseMoveListener;this.drawFeature.removePointAt(this.drawFeature.getPoints().length-1);var a=this.drawFeature.getPoints();this.layer.removeFeature(this.drawFeature);this.drawFeature=null;this.layer.removeFeature(this.closeFeature);this.closeFeature=null;this.map.customCursor=null;this.map.setCursor();return a}else{throw new Error("GSPolygonDrawingHandler.closePolygon called while not drawing.")}};GSPolygonDrawingHandler.prototype.createViewFeature=function(b){var a=new GSPolygon(b,this.options.featureOptions);this.layer.addFeature(a);return a};GSUtil.extend(GSCircle,GSVectorGraphics);function GSCircle(b,a,c){this.options={};GSUtil.merge(c,this.options);GSCircle.baseConstructor.call(this,this.options);this.type="GSCircle";this.graphicsEl=undefined;if(_browser.svg){this.graphicsEl=document.createElementNS(_globals.svgns,"circle")}else{if(_browser.isIE6up){this.graphicsEl=document.createElement(_globals.vmlnsPrefix+":oval")}else{if(_browser.canvas){this.graphicsEl=document.createElement("canvas")}}}this.setStyle(this.options.style);this.center=b;this.radius=a}GSCircle.prototype.setCenter=function(a){this.center=a;this.render()};GSCircle.prototype.setRadius=function(a){this.radius=a;this.render()};GSCircle.prototype.render=function(){if(this.isVisible()){GSCircle.superClass.render.call(this);var b=this.map.translateToMapCoordinate(this.center);var d=this.radius/this.map.mpx;if(_browser.svg){this.graphicsEl.setAttributeNS(null,"cx",b.x);this.graphicsEl.setAttributeNS(null,"cy",b.y);this.graphicsEl.setAttributeNS(null,"r",d)}else{if(_browser.isIE6up){this.graphicsEl.style.left=b.x-d;this.graphicsEl.style.top=b.y-d;this.graphicsEl.style.width=d*2;this.graphicsEl.style.height=d*2}else{if(_browser.canvas){var a=this.getPreparedCanvasContext();a.beginPath();var c=Math.PI*2;a.arc(b.x,b.y,d,c,false);a.fill();a.stroke()}}}}};GSCircle.prototype.getBounds=function(){var a=this.center.x-this.radius;var d=this.center.y-this.radius;var c=this.center.x+this.radius;var b=this.center.y+this.radius;return new GSBounds(a,d,c,b)};GSCircle.prototype.getInfoWindowPosition=function(){return this.center};GSCircle.prototype.toJson=function(){var a={type:this.type,style:GSUtil.toCC(this.options.style),center:this.center,radius:this.radius,visible:this.visible};if(this.options.text){a.text=this.options.text;a.textPosition=this.options.textPosition;a.textStyle=GSUtil.toCC(this.options.textStyle)}return GSUtil.objToJson(a)};GSCircle.prototype.toGML=function(){throw new Error("GML output not supported for this shape type")};GSCircle.prototype.toWKT=function(){throw new Error("WKT output not supported for this shape type")};GSUtil.extend(GSHandle,GSMapFeature);function GSHandle(d,a,b){this.options={isInsertHandle:false,visible:false,draggable:true,style:{width:8,height:8,fill:"white",opacity:0.9,stroke:"black","stroke-width":"1px",cursor:"pointer",fontSize:"1px"},dragStyle:{stroke:"aqua",fill:"white",opacity:0.9,cursor:"crosshair"},insertStyle:{stroke:"black",fill:"white",opacity:0.5,cursor:"pointer"},snapStyle:{fill:"aqua","fill-opacity":0.9,stroke:"aqua","stroke-opacity":1}};GSUtil.merge(b,this.options);GSHandle.baseConstructor.call(this,this.options);this.type="GSHandle";this.graphicsEl=GSUtil.createElement("div");this.graphicsEl.style.position="absolute";this.setStyle(this.options.style);this.parent=d;this.point=a;this.beforeHandle=this.options.beforeHandle;this.afterHandle=this.options.afterHandle;if(this.options.isInsertHandle){this._setStyle(this.options.insertStyle);this.createDragBoundary();if(GSModule.isLoaded("additional-ui")){this.disableContextMenu()}}else{this.setTip(GSHandle.TOOL_TIP_TEXT,{showDelay:0,hideDelay:0,offset:new GSPoint(20,-10)});if(GSModule.isLoaded("additional-ui")){var e=GSContextMenuManager.getContextMenu();this.setContextMenu(e);var c=new GSMenuItem("Delete point");c.addEventListener("click",this.pointDeletedHandler,this);this.addContextMenuItemAt(c,0);if(e.getItems().length){this.addContextMenuItemAt(new GSMenuItem("",{isSeparator:true}),1)}}}this.setVisible(this.options.visible);if(this.options.draggable){GSEventManager.bind(this.graphicsEl,"mousedown",this,this.dragStart)}this.dragging=false;this.dragStartPoint=null;this.mapPanBuffer=25}GSHandle.TOOL_TIP_TEXT="Drag to move point";GSHandle.prototype.createDragBoundary=function(){if(_browser.svg){this.dragBoundary=document.createElementNS(_globals.svgns,"polyline");this.dragBoundary.style.display="none";this.dragBoundary.setAttributeNS(null,"stroke",this.parent.options.style.stroke);this.dragBoundary.setAttributeNS(null,"stroke-width","2px");this.dragBoundary.setAttributeNS(null,"stroke-dasharray","2px,4px");this.dragBoundary.setAttributeNS(null,"fill","none");GSUtil.makeUnselectable(this.dragBoundary)}else{if(_browser.isIE6up){this.dragBoundary=document.createElement(_globals.vmlnsPrefix+":shape");this.dragBoundary.style.display="none";this.dragBoundary.setAttribute("unselectable","on");var b=document.createElement(_globals.vmlnsPrefix+":stroke");b.setAttribute("on","true");b.setAttribute("color",this.parent.options.style.stroke);b.setAttribute("weight","3px");b.setAttribute("dashstyle","dot");this.dragBoundary.appendChild(b);var a=document.createElement(_globals.vmlnsPrefix+":fill");a.setAttribute("on","false");this.dragBoundary.appendChild(a)}else{if(_browser.canvas){this.dragBoundary=document.createElement("canvas");this.dragBoundary.style.display="none"}}}};GSHandle.prototype.dragStart=function(a){var b=a.which?a.which==3:(a.button?a.button==2:false);if(b){return}this.dragStartPoint=this.map.getMouseCoordinate(a);this._setStyle(this.options.dragStyle);if(this.options.isInsertHandle){this.dragBoundary.style.display=""}this.mousemoveListener=GSEventManager.addEventListener(document,"mousemove",this.onDrag,this);this.mouseupListener=GSEventManager.addEventListener(document,"mouseup",this.stopDrag,this);this.dragging=true;this.broadcastMessage("handleDragStart",this);GSUtil.cancelEvent(a)};GSHandle.prototype.onDrag=function(f){this.point=this.map.getMouseCoordinate(f);this.closest=undefined;if(this.parent.shouldSnapHandles()){var h=this.map.getSnappables();for(var c=0,b=h.length;c<b;c++){var d=h[c];if(d!==this.parent&&d.isVisible()){var g=this.map.translateToMapCoordinate(this.point);var a=d.closestPoint(g,15);if(a){if(!this.closest||a.delta<this.closest.delta){this.closest=a}}}}}if(this.closest){this._setStyle(this.options.snapStyle)}else{this._setStyle(this.options.dragStyle)}if(!this.options.isInsertHandle){this.tip.setText(this.point.x+", "+this.point.y)}this.render();this.broadcastMessage("handleDrag",this,[f]);GSUtil.cancelEvent(f)};GSHandle.prototype.stopDrag=function(a){GSUtil.cancelEvent(a);GSEventManager.release(this.mousemoveListener);delete this.mousemoveListener;GSEventManager.release(this.mouseupListener);delete this.mouseupListener;if(this.options.isInsertHandle){this._setStyle(this.options.insertStyle);this.dragBoundary.style.display="none"}else{this._setStyle(this.options.style);this.tip.setText(GSHandle.TOOL_TIP_TEXT)}if(!this.dragStartPoint.equals(this.map.getMouseCoordinate(a))){if(this.closest){this.point=this.closest.point;this.closest=undefined;this.render()}}this.broadcastMessage("handleDragEnd",this,[a]);this.dragging=false};GSHandle.prototype.addToLayer=function(a){a.map.handleContainer.appendChild(this.graphicsEl);if(this.options.isInsertHandle){if(!a.vectorContainer){a.vectorContainer=a.createVectorContainer()}if(_browser.isIE6up){this.dragBoundary.style.width=a.map.pxWidth;this.dragBoundary.style.height=a.map.pxHeight;this.dragBoundary.coordsize=a.map.pxWidth+" "+a.map.pxHeight}else{if(_browser.canvas){this.dragBoundary.width=a.map.pxWidth;this.dragBoundary.height=a.map.pxHeight}}a.vectorContainer.appendChild(this.dragBoundary)}GSHandle.superClass.addToLayer.call(this,a)};GSHandle.prototype.isInsertHandle=function(){return this.options.isInsertHandle};GSHandle.prototype.render=function(){if(this.isVisible()){var h=this.map.translateToMapCoordinate(this.point);var a=h.x-this.options.style.width/2;var g=h.y-this.options.style.height/2;this.graphicsEl.style.left=a+"px";this.graphicsEl.style.top=g+"px";this.graphicsEl.style.width=this.options.style.width+"px";this.graphicsEl.style.height=this.options.style.height+"px";this.graphicsEl.style.zIndex=100;if(this.options.isInsertHandle&&this.dragging){var e=this.map.translateToMapCoordinate(this.beforeHandle.point);var c=this.map.translateToMapCoordinate(this.afterHandle.point);if(_browser.svg){var d=[e.x,e.y,h.x,h.y,c.x,c.y];this.dragBoundary.setAttributeNS(null,"points",d)}else{if(_browser.isIE6up){var f="m "+Math.round(e.x)+","+Math.round(e.y)+" l "+Math.round(h.x)+", "+Math.round(h.y)+", "+Math.round(c.x)+", "+Math.round(c.y)+" e";this.dragBoundary.style.display="none";this.dragBoundary.path=f;this.dragBoundary.style.display=""}else{if(_browser.canvas){var b=this.dragBoundary.getContext("2d");b.clearRect(0,0,b.canvas.width,b.canvas.height);b.strokeStyle=this.parent.options.style.stroke;b.lineWidth=2;b.beginPath();GSVectorGraphics.canvasDashedLine(b,e.x,e.y,h.x,h.y,[2,4]);GSVectorGraphics.canvasDashedLine(b,h.x,h.y,c.x,c.y,[2,4]);b.stroke()}}}}}};GSHandle.prototype.setStyle=function(a){for(var c in a){var b=a[c];switch(c){case"stroke":this.setStroke(b);break;case"stroke-width":this.setStrokeWidth(b);break;case"fill":this.setFill(b);break;case"opacity":this.setOpacity(b);break;default:this.graphicsEl.style[c]=b;break}}};GSHandle.prototype._setStyle=function(a){for(var c in a){var b=a[c];switch(c){case"stroke":this._setStroke(b);break;case"stroke-width":this._setStrokeWidth(b);break;case"fill":this._setFill(b);break;case"opacity":this._setOpacity(b);break;default:this.graphicsEl.style[c]=b;break}}};GSHandle.prototype.setStroke=function(a){this.options.style.stroke=a;return this._setStroke(a)};GSHandle.prototype.setStrokeWidth=function(a){this.options.style["stroke-width"]=a;return this._setStrokeWidth(a)};GSHandle.prototype.setFill=function(a){this.options.style.fill=a;return this._setFill(a)};GSHandle.prototype.setOpacity=function(a){this.options.style.opacity=a;return this._setOpacity(a)};GSHandle.prototype._setStroke=function(a){if(a==="none"){this.graphicsEl.style.borderStyle="none"}else{this.graphicsEl.style.borderStyle="solid";this.graphicsEl.style.borderColor=a}};GSHandle.prototype._setStrokeWidth=function(a){this.graphicsEl.style.borderWidth=a};GSHandle.prototype._setStrokeOpacity=function(a){};GSHandle.prototype._setFill=function(a){if(a==="none"){this.graphicsEl.style.backgroundColor="transparent"}else{this.graphicsEl.style.backgroundColor=a}};GSHandle.prototype._setFillOpacity=function(a){};GSHandle.prototype._setOpacity=function(a){GSUtil.setOpacity(this.graphicsEl,a*100)};GSHandle.prototype.remove=function(){this.map.handleContainer.removeChild(this.graphicsEl);if(this.options.isInsertHandle){this.layer.vectorContainer.removeChild(this.dragBoundary)}GSHandle.superClass.remove.call(this)};GSHandle.prototype.setVisible=function(a){this.options.visible=a;if(this.graphicsEl){this.graphicsEl.style.visibility=(a===true?"visible":"hidden")}if(this.onmap&&this.options.visible){this.render()}};GSHandle.prototype.pointDeletedHandler=function(a){if(GSModule.isLoaded("additional-ui")){this.contextMenu.hide()}this.broadcastMessage("pointDeleted",this.point);GSUtil.cancelEvent(a)};GSHandle.prototype.toString=function(){return"GSHandle: x=["+this.point.x+"], y=["+this.point.y+"]"};GSHandle.prototype.clickHandler=function(a){GSUtil.cancelEvent(a);return};function GSDrawingHandler(b,a){this.layer=b;this.map=b.map;this.eventListeners={};this.options={drawStyle:{fill:"white","fill-opacity":0.4,stroke:"black","stroke-width":"1px","stroke-opacity":1},onShapeCreated:function(){},onDrawingCancelled:function(){}};GSUtil.merge(a,this.options);this.drawing=false;this.map.addListener(this)}GSDrawingHandler.prototype.startDrawing=function(){if(!this.drawing){this.drawing=true;this.createDrawFeature();if(!this.eventListeners.keydownListener){this.eventListeners.keydownListener=GSEventManager.addEventListener(document,"keydown",this.keyHandler,this)}}};GSDrawingHandler.prototype.stopDrawing=function(){if(this.drawing){var a=this.removeDrawFeature();this.drawing=false;this.viewFeature=this.createViewFeature(a);if(this.viewFeature!==null){this.options.onShapeCreated(this.viewFeature)}GSEventManager.removeEventListener(this.eventListeners.keydownListener);this.eventListeners.keydownListener=null}};GSDrawingHandler.prototype.createDrawFeature=function(){};GSDrawingHandler.prototype.removeDrawFeature=function(){};GSDrawingHandler.prototype.createViewFeature=function(){};GSDrawingHandler.prototype.snapPoint=function(b){var d=this.map.translateToMapCoordinate(b);var f=this.map.getSnappables();var e=null;for(var c=0;c<f.length;c++){if(f[c].isVisible()){var a=f[c].closestPoint(d,15);if(a){if(!e||a.delta<e.delta){e=a}}}}if(e){return e.point}return b};GSDrawingHandler.prototype.keyHandler=function(a){if(a.keyCode==GSKeyEvents.KEY_ESC){this.cancelDrawing()}};GSDrawingHandler.prototype.cancelDrawing=function(){if(this.drawing){this.removeDrawFeature();this.drawing=false;if(this.options.onDrawingCancelled){this.options.onDrawingCancelled()}}};function GSMultiLevelPolyline(b,a){if(!a){a={}}this.type="GSMultiLevelPolyline";this.levelPoints=b;this.levelPolylines=[];this.style=a.style?a.style:{};this.layer=null;this.map=null;this.currentVisiblePolyline=null;this.createLevelPolylines()}GSMultiLevelPolyline.getLevelPoints=function(f,h){var e=[];var d,c,b,a;var g=4;for(d=0,a=g;d<a;d++){e[d]=[]}for(d=0,a=f.length;d<a;d++){for(c=0,b=h[d];c<=b;c++){e[c].push(f[d])}}return e};GSMultiLevelPolyline.prototype.createLevelPolylines=function(){if(this.levelPoints.length){this.removePolylines();for(var b=0,a=this.levelPoints.length;b<a;b++){this.levelPolylines[b]=new GSPolyline(this.levelPoints[b],{style:this.style});this.levelPolylines[b].setVisible(false)}}};GSMultiLevelPolyline.prototype.addPolylinesToLayer=function(a){this.layer=a;this.map=this.layer.map;this.map.addListener(this);this.updateVisiblePolyline()};GSMultiLevelPolyline.prototype.updateVisiblePolyline=function(){if(this.map!==null){var a=Math.floor((15-this.map.getZoomLevel())/3);if(a<0){a=0}else{if(a>3){a=3}}if(a!=this.currentVisiblePolyline){if(this.currentVisiblePolyline!==null){if(this.levelPolylines[this.currentVisiblePolyline].graphicsEl){this.levelPolylines[this.currentVisiblePolyline].setVisible(false)}else{this.removePolylines();return}}this.currentVisiblePolyline=a;if(!this.levelPolylines[this.currentVisiblePolyline]){console.log("No polyline for level "+this.currentVisiblePolyline)}if(this.levelPolylines[this.currentVisiblePolyline].graphicsEl){if(!this.levelPolylines[this.currentVisiblePolyline].layer){this.layer.addFeature(this.levelPolylines[this.currentVisiblePolyline])}else{this.levelPolylines[this.currentVisiblePolyline].setVisible(true)}}else{this.removePolylines();return}}}};GSMultiLevelPolyline.prototype.mapBoundsChanged=function(c,a,b){this.updateVisiblePolyline()};GSMultiLevelPolyline.prototype.mapZoomed=function(c,b,a){this.updateVisiblePolyline()};GSMultiLevelPolyline.prototype.removePolylines=function(){if(this.levelPolylines.length){for(var b=0,a=this.levelPolylines.length;b<a;b++){if(this.levelPolylines[b].graphicsEl){this.layer.removeFeature(this.levelPolylines[b])}}}this.levelPolylines=[];if(this.map){this.map.removeListener(this);this.map=null;this.layer=null}};GSMultiLevelPolyline.prototype.projectPoint=function(a){if(this.levelPolylines[this.currentVisiblePolyline]){return this.levelPolylines[this.currentVisiblePolyline].projectPoint(a)}return null};GSMultiLevelPolyline.prototype.addEventHandler=function(c,d){for(var b=0,a=this.levelPolylines.length;b<a;b++){this.levelPolylines[b].addEventHandler(c,d)}};GSMultiLevelPolyline.prototype.clone=function(){var a=new GSMultiLevelPolyline(this.levelPoints,{style:GSUtil.clone(this.style)});return a};GSUtil.extend(GSLine,GSVectorGraphics);function GSLine(c,b,a){this.options={style:{fill:"none",stroke:"blue","stroke-opacity":0.6,"stroke-width":"7px"}};GSUtil.merge(a,this.options);GSLine.baseConstructor.call(this,this.options);this.type="GSLine";this.resizeToLayer=true;this.graphicsEl=undefined;if(_browser.svg){this.graphicsEl=document.createElementNS(_globals.svgns,"line")}else{if(_browser.isIE6up){this.graphicsEl=document.createElement(_globals.vmlnsPrefix+":shape")}else{if(_browser.canvas){this.graphicsEl=document.createElement("canvas")}}}this.setStyle(this.options.style);this.from=c;this.to=b}GSLine.prototype.setFrom=function(a){this.from=a;this.render()};GSLine.prototype.setTo=function(a){this.to=a;this.render()};GSLine.prototype.render=function(){if(this.isVisible()){GSLine.superClass.render.call(this);var b=this.map.translateToMapCoordinate(this.from);var c=this.map.translateToMapCoordinate(this.to);if(_browser.svg){this.graphicsEl.setAttributeNS(null,"x1",b.x);this.graphicsEl.setAttributeNS(null,"y1",b.y);this.graphicsEl.setAttributeNS(null,"x2",c.x);this.graphicsEl.setAttributeNS(null,"y2",c.y)}else{if(_browser.isIE6up){var d="M "+Math.round(b.x)+" "+Math.round(b.y)+" L "+Math.round(c.x)+" "+Math.round(c.y);this.graphicsEl.style.display="none";this.graphicsEl.path=d;this.graphicsEl.style.display=""}else{if(_browser.canvas){var a=this.getPreparedCanvasContext();a.beginPath();a.moveTo(b.x,b.y);a.lineTo(c.x,c.y);a.stroke()}}}}};GSLine.prototype.getBounds=function(){var a=Math.min(this.from.x,this.to.x);var d=Math.min(this.from.y,this.to.y);var c=Math.max(this.from.x,this.to.x);var b=Math.max(this.from.y,this.to.y);return new GSBounds(a,d,c,b)};GSLine.prototype.getInfoWindowPosition=function(){var a=Math.min(this.from.x,this.to.x)+Math.abs((this.from.x-this.to.x)/2);var b=Math.min(this.from.y,this.to.y)+Math.abs((this.from.y-this.to.y)/2);return new GSPoint(a,b)};GSLine.prototype.toJson=function(){var a={type:this.type,style:GSUtil.toCC(this.options.style),from:this.from,to:this.to,visible:this.visible};if(this.options.text){a.text=this.options.text;a.textPosition=this.options.textPosition;a.textStyle=GSUtil.toCC(this.options.textStyle)}return GSUtil.objToJson(a)};GSLine.prototype.toGML=function(){var a=[];a.push('<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:27200">');a.push("<gml:coordinates>"+this.from.x+","+this.from.y+" "+this.to.x+","+this.to.y+"</gml:coordinates>");a.push("</gml:LineString>");return a.join("")};GSLine.prototype.toWKT=function(){return"LINESTRING("+this.from.x+" "+this.from.y+","+this.to.x+" "+this.to.y+")"};function GSLineClipping(a){this.bounds=a}GSLineClipping.prototype.clipLine=function(c){var b=[];for(var d=0,a=c.length;d<a-1;d++){var f=c[d];var e=c[d+1];var g=this.clip(f,e);if(g){if(b.length){if((g[0].x==f.x&&g[0].y==f.y)&&(g[1].x==e.x&&g[1].y==e.y)){b[b.length-1].push(g[1]);continue}}b.push([g[0],g[1]])}}return b};GSLineClipping.prototype.clip=function(m,l){var o,n,c,b,a;var g=0;var f=1;o=l.x-m.x;n=l.y-m.y;var k=[-1*o,o,-1*n,n];var j=[m.x-this.bounds.minX,this.bounds.maxX-m.x,m.y-this.bounds.minY,this.bounds.maxY-m.y];var d=true;for(var e=0;e<4;e++){c=k[e];b=j[e];if(c==0&&b<0){d=false;break}a=b/c;if(c<0){g=Math.max(g,a)}if(c>0){f=Math.min(f,a)}if(g>f){d=false;break}}if(d){var h=[m,l,false];if(f<1){h[1]=new GSPoint(parseInt(m.x+f*o),parseInt(m.y+f*n))}if(g>0){h[0]=new GSPoint(parseInt(m.x+g*o),parseInt(m.y+g*n))}return h}return false};function GSColor(f,d){this.ok=false;if(f.charAt(0)=="#"){f=f.substr(1,6)}f=f.replace(/ /g,"");f=f.toLowerCase();var b={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var g in b){if(f==g){f=b[g]}}var e=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(i){return[parseInt(i[1]),parseInt(i[2]),parseInt(i[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(i){return[parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(i){return[parseInt(i[1]+i[1],16),parseInt(i[2]+i[2],16),parseInt(i[3]+i[3],16)]}}];for(var c=0;c<e.length;c++){var j=e[c].re;var a=e[c].process;var h=j.exec(f);if(h){channels=a(h);this.r=channels[0];this.g=channels[1];this.b=channels[2];this.ok=true}}this.r=(this.r<0||isNaN(this.r))?0:((this.r>255)?255:this.r);this.g=(this.g<0||isNaN(this.g))?0:((this.g>255)?255:this.g);this.b=(this.b<0||isNaN(this.b))?0:((this.b>255)?255:this.b);this.a=(typeof d=="undefined"?1:d);this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.a+")"};this.toHex=function(){var l=this.r.toString(16);var k=this.g.toString(16);var i=this.b.toString(16);if(l.length==1){l="0"+l}if(k.length==1){k="0"+k}if(i.length==1){i="0"+i}return"#"+l+k+i};this.getHelpXML=function(){var m=new Array();for(var o=0;o<e.length;o++){var l=e[o].example;for(var n=0;n<l.length;n++){m[m.length]=l[n]}}for(var t in b){m[m.length]=t}var p=document.createElement("ul");p.setAttribute("id","rgbcolor-examples");for(var o=0;o<m.length;o++){try{var q=document.createElement("li");var s=new RGBColor(m[o]);var u=document.createElement("div");u.style.cssText="margin: 3px; border: 1px solid black; background:"+s.toHex()+"; color:"+s.toHex();u.appendChild(document.createTextNode("test"));var k=document.createTextNode(" "+m[o]+" -> "+s.toRGB()+" -> "+s.toHex());q.appendChild(u);q.appendChild(k);p.appendChild(q)}catch(r){}}return p}}if(window.GSModule&&GSModule.moduleLoaded){GSModule.moduleLoaded("svg")};