function GSAbstractMenu(a){this.options={menuItemWidth:150,menuItemHeight:16,menuItemPadding:"3px 10px",fontFamily:"Helvetica, Arial, Sans-serif",fontSize:"11px",color:"#000",activeColor:"#ffd400",highlightColor:"#fff",highlightBackgroundColor:"#336fcb",disabledColor:"#8c8c8c",useRollover:true,hideOnAction:false,highlightBackgroundImage:false};GSUtil.merge(a,this.options);this.menuItems=[];this.selectedIndex=-1;this.eventListeners={};this.showing=false}GSUtil.include(GSAbstractMenu,new GSEventBroadcasterMixin());GSAbstractMenu.prototype.getItems=function(){return this.menuItems};GSAbstractMenu.prototype.addItem=function(a){this.menuItems.push(a);a.addToMenu(this)};GSAbstractMenu.prototype.addItemAt=function(b,a){b.parent=this;this.menuItems.splice(a,0,b);b.addToMenu(this,a)};GSAbstractMenu.prototype.removeItem=function(c){for(var b=0,a=this.menuItems.length;b<a;b++){if(this.menuItems[b]===c){this.menuItems.splice(b,1)[0].remove();return}}};GSAbstractMenu.prototype.removeItemAt=function(a){this.menuItems.splice(a,1)[0].remove()};GSAbstractMenu.prototype.subscribeToKeyEvents=function(){this.keydownListener=GSEventManager.addEventListener(document,"keydown",GSUtil.bindAsEventListener(this.keyHandler,this))};GSAbstractMenu.prototype.unsubscribeForKeyEvents=function(){GSEventManager.removeEventListener(this.keydownListener)};GSAbstractMenu.prototype.keyHandler=function(a){switch(a.keyCode){case GSKeyEvents.KEY_ESC:this.hide();return;case GSKeyEvents.KEY_RETURN:this.dispatchClickEvent(this.menuItems[this.selectedIndex]);return;case GSKeyEvents.KEY_UP:this.selectPrevious();return;case GSKeyEvents.KEY_DOWN:this.selectNext();return}};GSAbstractMenu.prototype.selectNext=function(){if(this.selectedIndex<this.menuItems.length-1){var a=this.selectedIndex;do{a+=1}while(!this.menuItems[a].isFocusTraversable()&&a<this.menuItems.length-1);if(this.menuItems[a].isFocusTraversable()){this.selectedIndex=a}this.updateItemsSelection()}};GSAbstractMenu.prototype.selectPrevious=function(){if(this.selectedIndex>0){var a=this.selectedIndex;do{a-=1}while(!this.menuItems[a].isFocusTraversable()&&a>0);if(this.menuItems[a].isFocusTraversable()){this.selectedIndex=a}this.updateItemsSelection()}};GSAbstractMenu.prototype.selectItem=function(c){for(var b=0,a=this.menuItems.length;b<a;b++){if(this.menuItems[b]===c){this.selectedIndex=b;this.updateItemsSelection();return}}};GSAbstractMenu.prototype.dispatchClickEvent=function(a){var b=document.createEvent("MouseEvents");b.initEvent("click",true,true);a.element.dispatchEvent(b)};GSAbstractMenu.prototype.updateItemsSelection=function(){for(var b=0,a=this.menuItems.length;b<a;b++){if(b==this.selectedIndex){this.menuItems[b].select()}else{this.menuItems[b].deselect()}}};GSAbstractMenu.prototype.initialize=function(){if(this.options.highlightBackgroundImage){new Image().src=this.options.highlightBackgroundImage}};GSAbstractMenu.prototype.show=function(){this.showing=true;this.subscribeToKeyEvents();this.broadcastMessage("menuShown",this,arguments.length?arguments[0]:null)};GSAbstractMenu.prototype.hide=function(){this.showing=false;this.selectedIndex=-1;this.updateItemsSelection();this.unsubscribeForKeyEvents();this.broadcastMessage("menuHidden",this)};function GSMenuItem(b,a){this.options={enabled:true,type:"default",checked:false,mnemonicIndex:-1,iconWidth:16,iconHeight:16};GSUtil.merge(a,this.options);this.label=b;this.labelElement;this.menu;this.checkbox;this.initialized=false;this.element=GSUtil.createElement("div",{styles:{clear:"left",position:"relative"},events:{mouseover:GSUtil.bindAsEventListener(this.mouseoverHandler,this),contextmenu:GSUtil.cancelEvent,dblclick:GSUtil.cancelEvent},unselectable:true});this.graphicsEl=this.element}GSUtil.include(GSMenuItem,new GSDOMEventsMixin());GSMenuItem.prototype.initialize=function(){if(this.options.type=="separator"){this.element.style.width=(this.getWidth())+"px";this.element.style.borderTop="1px solid #ccc";this.element.style.padding=this.getPadding();this.element.style.paddingTop=0;this.element.style.paddingBottom=0;this.element.appendChild(document.createElement("div"));this.element.className="GSMenuItem GSMenuItemSeparator"}else{this.element.style.width=this.getWidth()+"px";this.element.style.height=this.getHeight()+"px";this.element.style.lineHeight=this.getHeight()+"px";this.element.style.padding=this.getPadding();this.element.className="GSMenuItem";if(this.options.type=="check"){this.boundOnCheckboxClicked=GSUtil.bindAsEventListener(this.onCheckboxClicked,this);this.checkbox=new GSCheckbox(this.element,{onClick:this.boundOnCheckboxClicked,checked:this.options.checked});this.checkbox.setStyles({marginRight:"8px",position:"relative",top:"2px"});this.labelElement=GSUtil.createElement("span",{html:this.label});this.element.appendChild(this.labelElement);if(this.options.icon){this.element.appendChild(GSUtil.createElement("img",{styles:{position:"absolute",right:"10px",marginLeft:"8px",width:this.options.iconWidth+"px",height:this.options.iconHeight+"px"},src:this.options.icon}))}if(this.options.action){this.boundOnLabelClicked=GSUtil.bindAsEventListener(this.onLabelClicked,this);GSEventManager.addEventListener(this.element,"click",this.boundOnLabelClicked)}}else{if(this.options.icon){this.element.appendChild(GSUtil.createElement("img",{styles:{cssFloat:"left",styleFloat:"left",marginRight:"8px",width:this.options.iconWidth+"px",height:this.options.iconHeight+"px"},src:this.options.icon}))}this.labelElement=GSUtil.createElement("span",{html:this.label});this.element.appendChild(this.labelElement);if(this.options.action){this.boundPerformAction=GSUtil.bindAsEventListener(this.performAction,this);GSEventManager.addEventListener(this.element,"click",this.boundPerformAction)}}}if(!this.options.enabled){this.applyDisabledStyle()}else{this.applyEnabledStyle()}this.initialized=true};GSMenuItem.prototype.setLabel=function(a){this.label=a;this.labelElement.innerHTML=a};GSMenuItem.prototype.getWidth=function(){return this.options.width||this.menu.options.menuItemWidth};GSMenuItem.prototype.getHeight=function(){return this.options.height||this.menu.options.menuItemHeight};GSMenuItem.prototype.getPadding=function(){return this.options.padding||this.menu.options.menuItemPadding};GSMenuItem.prototype.onCheckboxClicked=function(a){if(this.checkbox.options.checked){this.element.style.color=this.menu.options.activeColor}else{this.element.style.color=this.menu.options.color}this.performAction(a)};GSMenuItem.prototype.onLabelClicked=function(a){if(this.checkbox.options.checked){this.element.style.color=this.menu.options.color;this.checkbox.uncheck()}else{this.element.style.color=this.menu.options.activeColor;this.checkbox.check()}this.performAction(a)};GSMenuItem.prototype.setStyles=function(b){for(var a in b){this.element.style[a]=b[a]}};GSMenuItem.prototype.addToMenu=function(b,a){this.menu=b;if(!this.initialized){this.initialize()}this.position(a)};GSMenuItem.prototype.position=function(c){var b=this.menu.element;if(c!==undefined){var e=null;for(var d=0,a=b.childNodes.length;d<a;d++){if(d==c){e=b.childNodes[d];break}}b.insertBefore(this.element,e)}else{b.appendChild(this.element)}};GSMenuItem.prototype.remove=function(){this.removeEventListeners();this.element.parentNode.removeChild(this.element)};GSMenuItem.prototype.addEventHandler=function(a,b){return this.addEventListener(a,b,this)};GSMenuItem.prototype.removeEventHandler=function(a){GSEventManager.release(a)};GSMenuItem.prototype.isFocusTraversable=function(){return this.options.enabled&&this.options.type!="separator"};GSMenuItem.prototype.setEnabled=function(a){this.options.enabled=a;if(this.options.enabled){this.applyEnabledStyle()}else{this.applyDisabledStyle()}};GSMenuItem.prototype.performAction=function(a){if(this.options.enabled){if(this.options.action){this.options.action(this)}if(this.menu.options.hideOnAction){this.menu.hide()}if(a){GSUtil.eventStopPropagation(a)}}};GSMenuItem.prototype.select=function(){if(!this.menu.options.useRollover){return}this.element.style.color=this.menu.options.highlightColor;if(this.menu.options.highlightBackgroundImage){this.element.style.background="url("+this.menu.options.highlightBackgroundImage+") repeat-x"}else{this.element.style.backgroundColor=this.menu.options.highlightBackgroundColor}};GSMenuItem.prototype.deselect=function(){if(!this.menu.options.useRollover){return}if(this.options.enabled){this.applyEnabledStyle()}else{this.applyDisabledStyle()}this.element.style.background="none"};GSMenuItem.prototype.applyEnabledStyle=function(){this.element.style.color=(this.options.type=="check"&&this.checkbox.options.checked)?this.menu.options.activeColor:this.menu.options.color;this.element.style.cursor=this.options.action?"pointer":"default"};GSMenuItem.prototype.applyDisabledStyle=function(){this.element.style.color=this.menu.options.disabledColor;this.element.style.cursor="default"};GSMenuItem.prototype.mouseoverHandler=function(a){if(this.isFocusTraversable()){this.menu.selectItem(this)}};GSUtil.extend(GSContextMenu,GSAbstractMenu);function GSContextMenu(a){this.options={hideOnAction:true};GSUtil.merge(a,this.options);GSContextMenu.baseConstructor.call(this,this.options);this.edgeOffset=5;this.element;this.map;this.onmap=false;this.initialize()}GSContextMenu.prototype.addToMap=function(a){this.map=a;a.container.appendChild(this.element);this.onmap=true};GSContextMenu.prototype.hide=function(){GSContextMenu.superClass.hide.call(this);this.element.style.visibility="hidden";GSContextMenuManager.contextMenuHidden(this)};GSContextMenu.prototype.show=function(a,e){if(GSContextMenuManager.activeMenu&&GSContextMenuManager.activeMenu.showing){GSContextMenuManager.activeMenu.hide()}GSContextMenuManager.contextMenuOpened(this);if(a){this.position=a;var d=[this.element.offsetWidth,this.element.offsetHeight];var c=this.position.y+d[1]+this.edgeOffset>this.map.pxHeight?"bottom":"top";var b=this.position.x+d[0]+this.edgeOffset>this.map.pxWidth?"right":"left";if(c=="top"){this.element.style.top=this.position.y+"px";this.element.style.bottom="auto"}else{this.element.style.top="auto";this.element.style.bottom=(this.map.pxHeight-this.position.y)+"px"}if(b=="left"){this.element.style.left=this.position.x+"px";this.element.style.right="auto"}else{this.element.style.left="auto";this.element.style.right=(this.map.pxWidth-this.position.x)+"px"}}this.element.style.visibility="visible";GSContextMenu.superClass.show.call(this,e)};GSContextMenu.prototype.initialize=function(){GSContextMenu.superClass.initialize.call(this);this.element=GSUtil.createElement("div",{styles:{visibility:"hidden",position:"absolute",zIndex:1000,color:"#000",backgroundColor:"#f0f0f0",borderColor:"#ccc rgb(103, 103, 103) rgb(103, 103, 103) #ccc",borderStyle:"solid",borderWidth:"1px",fontFamily:this.options.fontFamily,fontSize:this.options.fontSize},events:{contextmneu:GSUtil.cancelEvent},"class":"GSContextMenu"})};GSContextMenu.prototype.remove=function(){if(this.map){this.map.container.removeChild(this.element)}this.onmap=false};function GSContextMenuMixin(){}GSContextMenuMixin.prototype.getContextMenu=function(){return this.contextMenu};GSContextMenuMixin.prototype.setContextMenu=function(b){this.contextMenu=b;this.enableContextMenu();if(this.didSetContextMenu){this.didSetContextMenu(b)}var a=this.container||this.graphicsEl||this.element;GSEventManager.addEventListener(a,"contextmenu",this.handleContextMenuEvent,this)};GSContextMenuMixin.prototype.removeContextMenu=function(){var a=this.contextMenu;if(a){this.disableContextMenu();a.remove();this.contextMenu=undefined}return a};GSContextMenuMixin.prototype.addContextMenuItem=function(a){if(!this.contextMenu){throw new Error("Must set a context menu before adding a context menu item")}if(!this.contextMenuItems){this.contextMenuItems=[]}this.contextMenuItems.push({item:a,pos:0})};GSContextMenuMixin.prototype.addContextMenuItemAt=function(a,b){if(!this.contextMenu){throw new Error("Must set a context menu before adding a context menu item")}if(!this.contextMenuItems){this.contextMenuItems=[]}this.contextMenuItems.push({item:a,pos:b})};GSContextMenuMixin.prototype.removeContextMenuItem=function(b){if(!this.contextMenuItems){return false}for(var a=0,c=null;c=this.contextMenuItems[a];a++){if(b==c.item){this.contextMenuItems.splice(a,1);return true}}return false};GSContextMenuMixin.prototype.enableContextMenu=function(){this.contextMenuEnabled=true;return this.contextMenu};GSContextMenuMixin.prototype.disableContextMenu=function(){this.contextMenuEnabled=false};GSContextMenuMixin.prototype.displayContextMenu=function(d){if(GSContextMenuManager.activeMenu&&GSContextMenuManager.activeMenu.showing){GSContextMenuManager.activeMenu.hide()}this.contextMenu.addListener(this);if(this.contextMenuItems){for(var b=0,a=this.contextMenuItems.length;b<a;b++){var c=this.contextMenuItems[b];c.item.comp=this;this.contextMenu.addItemAt(c.item,c.pos)}}var f=GSUtil.getMousePixelCoordinate(d,this.contextMenu.map.container);this.contextMenu.show(f,this);if(this.tip){this.tip.hide()}};GSContextMenuMixin.prototype.menuHidden=function(d){if(this.contextMenuItems){for(var b=0,a=this.contextMenuItems.length;b<a;b++){var c=this.contextMenuItems[b];d.removeItem(c.item)}}d.removeListener(this)};GSContextMenuMixin.prototype.handleContextMenuEvent=function(a){GSUtil.cancelEvent(a);if(this.contextMenuEnabled){this.displayContextMenu(a)}if(this.didHandleContextMenuEvent){this.didHandleContextMenuEvent(a)}};GSUtil.include(GSMap,new GSContextMenuMixin());GSUtil.include(GSMapFeature,new GSContextMenuMixin());function GSContextMenuManager(){}GSContextMenuManager.defaultOptions={fontFamily:"Helvetica, Arial, Sans-serif",fontSize:"12px"};GSContextMenuManager.menus={};GSContextMenuManager.activeMenu=null;GSContextMenuManager.getContextMenu=function(a){if(GSContextMenuManager.menus["default"]){return GSContextMenuManager.menus["default"]}else{var a=GSUtil.merge(GSContextMenuManager.defaultOptions,a);var b=new GSContextMenu(a);GSContextMenuManager.menus["default"]=b;return b}};GSContextMenuManager.getContextMenuByName=function(a){var b=null;if(GSContextMenuManager.menus[a]){b=GSContextMenuManager.menus[a]}return b};GSContextMenuManager.addContextMenu=function(a,b){GSContextMenuManager.menus[a]=b};GSContextMenuManager.contextMenuOpened=function(a){GSContextMenuManager.activeMenu=a};GSContextMenuManager.contextMenuHidden=function(a){GSContextMenuManager.activeMenu=null};GSEventManager.addEventListener(document,"click",function(a){var b=a.which?a.which==3:(a.button?a.button==2:false);if(b){return}if(GSContextMenuManager.activeMenu&&GSContextMenuManager.activeMenu.showing){GSContextMenuManager.activeMenu.hide()}});function GSCheckbox(b,a){this.options={checked:false,styles:{width:"12px",height:"12px",cursor:"pointer"}};GSUtil.merge(a,this.options);this.parent=(typeof b)=="string"?document.getElementById(b):b;this.element;this.initialize();this.addEventListeners()}GSCheckbox.UNCHECKED=0;GSCheckbox.PARTIALLY_CHECKED=1;GSCheckbox.CHECKED=2;GSCheckbox.prototype.initialize=function(){this.element=GSUtil.createElement("img",{styles:this.options.styles,"class":"GSCheckbox"});if(this.options.checked){this.check()}else{this.uncheck()}this.parent.appendChild(this.element)};GSCheckbox.prototype.addEventListeners=function(){GSEventManager.addEventListener(this.element,"click",this.toggleChecked,this)};GSCheckbox.prototype.toggleChecked=function(a){if(a){GSUtil.cancelEvent(a)}if(this.options.checked==GSCheckbox.CHECKED){this.uncheck()}else{this.check()}if(this.options.onClick){this.options.onClick(a)}};GSCheckbox.prototype.check=function(){this.options.checked=GSCheckbox.CHECKED;this.element.src=_globals.resourceURL+"legend-check-on.gif"};GSCheckbox.prototype.uncheck=function(){this.options.checked=GSCheckbox.UNCHECKED;this.element.src=_globals.resourceURL+"legend-check-off.gif"};GSCheckbox.prototype.partialCheck=function(){this.options.checked=GSCheckbox.PARTIALLY_CHECKED;this.element.src=_globals.resourceURL+"legend-check-mixed.gif"};GSCheckbox.prototype.setStyles=function(b){for(var a in b){this.element.style[a]=b[a]}};function GSSlider(b,a){this.options={mode:"horizontal",value:0,min:0,max:100,stepInterval:1,showDataTip:true};GSUtil.merge(a,this.options);this.steps=this.calcSteps();this.parent=(typeof b)=="string"?document.getElementById(b):b;this.initialize()}GSSlider.SLIDER_THUMB_WIDTH=15;GSSlider.SLIDER_HMIN=0;GSSlider.SLIDER_HMAX=146;GSSlider.prototype.initialize=function(){this.element=GSUtil.createElement("div",{styles:GSUtil.merge(this.options.styles,{width:"160px",height:"15px",backgroundImage:"url("+(_browser.pngAlpha?_globals.resourceURL+"slider/slider-bar.gif":_globals.resourceURL+"slider/slider-bar.png")+")"}),events:{click:GSUtil.bind(this.sliderBarClickHandler,this)},"class":"GSSlider"});this.sliderThumb=GSUtil.createElement("div",{styles:{height:"15px",width:"15px",position:"relative",left:"0px",cursor:"default",zoom:1},events:{mouseover:this.thumbMouseoverHandler,mouseout:this.thumbMouseoutHandler}});GSUtil.setElementBackgroundImage(this.sliderThumb,_globals.resourceURL+"slider/slider-knob.png");GSDrag.init(this.sliderThumb,null,GSSlider.SLIDER_HMIN,GSSlider.SLIDER_HMAX,0,0);this.sliderThumb.onDrag=GSUtil.bind(this.thumbDragHandler,this);if(this.options.showDataTip){this.sliderThumb.onDragStart=GSUtil.bind(this.thumbDragStartHandler,this);this.sliderThumb.onDragEnd=GSUtil.bind(this.thumbDragEndHandler,this)}this.element.appendChild(this.sliderThumb);this.parent.appendChild(this.element);if(this.options.showDataTip){this.dataTip=GSUtil.createElement("div",{styles:{visibility:"hidden",position:"absolute",color:"#000",backgroundColor:"#f0f0f0",fontFamily:"Arial, Helvetica, Sans-serif",fontSize:"11px",borderColor:"rgb(130, 130, 130)",borderStyle:"solid",borderWidth:"1px",padding:"2px 4px",WebkitBoxShadow:"0px 2px 4px #666",MozBoxShadow:"0px 2px 4px #666"},parent:this.element});this.updateDataTipText()}if(this.options.value){this.setValue(this.options.value)}};GSSlider.prototype.getElement=function(){return this.element};GSSlider.prototype.calcSteps=function(){return((this.options.max-this.options.min)/this.options.stepInterval)+1};GSSlider.prototype.getValue=function(){return this.options.value};GSSlider.prototype.setValue=function(c,b){this.options.value=c;this.updateDataTipText();var a=Math.round(GSSlider.SLIDER_HMAX*((c-this.options.min)/(this.steps-1)));if(b){this.animateSlider(a)}else{this.sliderThumb.style.left=a+"px"}};GSSlider.prototype.animateSlider=function(a){var b=new GSAnimator(new GSPoint(parseInt(this.sliderThumb.style.left,0)),new GSPoint(a,0),16,150,GSUtil.bind(function(d,c){this.sliderThumb.style.left=c.x+"px"},this));b.animate()};GSSlider.prototype.sliderBarClickHandler=function(b){GSUtil.cancelEvent(b);var d=GSUtil.getMousePos(b);var a=d.x-GSUtil.getElementPosition(this.element).x;this.sliderThumb.style.left=(a-Math.round(GSSlider.SLIDER_THUMB_WIDTH/2))+"px";a=Math.max(a,GSSlider.SLIDER_HMIN);a=Math.min(a,GSSlider.SLIDER_HMAX);var c=this.fit(a);this.options.value=c;if(this.options.onChange){this.options.onChange(c)}};GSSlider.prototype.thumbDragStartHandler=function(a,c,b){GSUtil.cancelEvent(b);this.positionDataTip();this.dataTip.style.visibility="visible"};GSSlider.prototype.thumbDragHandler=function(a,d,b){GSUtil.cancelEvent(b);var c=this.fit(a);if(this.options.showDataTip){this.updateDataTipText();this.positionDataTip()}if(c==this.options.value){return}if(this.options.onChange){this.options.value=c;this.options.onChange(c)}};GSSlider.prototype.thumbDragEndHandler=function(a,b){this.positionDataTip();this.dataTip.style.visibility="hidden"};GSSlider.prototype.thumbMouseoverHandler=function(a){GSUtil.cancelEvent(a);GSUtil.setElementBackgroundImage(this,_globals.resourceURL+"slider/slider-knob-glow.png")};GSSlider.prototype.thumbMouseoutHandler=function(a){GSUtil.cancelEvent(a);GSUtil.setElementBackgroundImage(this,_globals.resourceURL+"slider/slider-knob.png")};GSSlider.prototype.fit=function(a){return Math.round((a/GSSlider.SLIDER_HMAX-GSSlider.SLIDER_HMIN)*(this.steps-1))+this.options.min};GSSlider.prototype.updateDataTipText=function(){this.dataTip.innerHTML=this.options.value};GSSlider.prototype.positionDataTip=function(){var b=(this.dataTip.offsetWidth-GSSlider.SLIDER_THUMB_WIDTH)*-1/2;var c=-24;var a=this.sliderThumb.offsetLeft;var d=this.sliderThumb.offsetTop;GSUtil.setStyles(this.dataTip,{left:(a+b)+"px",top:(d+c)+"px"})};function GSColorPicker(c,b){this.parent=(typeof c)=="string"?document.getElementById(c):c;this.options={x:0,y:0,color:"#ffffff",backgroundColor:"#f7f7f7",border:"1px solid #999",visible:true};GSUtil.merge(b,this.options);this.hex=/^\#?[0-9A-F]{6}$/i;this.color=this.hex2Rgb(this.options.color);var a=this.rgb2Hsv(this.color);this.hue=this.hsv2Rgb({h:a.h,s:1,v:1});this.visible=this.options.visible;this.eventListeners={};this.initialize()}GSColorPicker.COLOR_BOX_WIDTH=80;GSColorPicker.COLOR_BOX_HEIGHT=80;GSColorPicker.COLOR_BOX_CURSOR_SIZE=12;GSColorPicker.SLIDER_HEIGHT=80;GSColorPicker.prototype.initialize=function(){this.element=GSUtil.createElement("div",{styles:{position:"absolute",left:this.options.x+"px",top:this.options.y+"px",width:"106px",height:"90px",backgroundColor:this.options.backgroundColor,border:this.options.border,zIndex:1000},events:{mousedown:GSUtil.cancelEvent,click:GSUtil.cancelEvent},"class":"GSColorPicker",parent:this.parent});this.colorBox=GSUtil.createElement("div",{styles:{position:"absolute",left:"4px",top:"4px",width:"80px",height:"80px",border:"1px solid #999",backgroundColor:this.rgb2Hex(this.hue),overflow:"hidden"},parent:this.element});var c=GSUtil.createElement("img",{src:_globals.resourceURL+"colorpicker/woverlay.png",styles:{width:"80px",height:"80px",position:"absolute"},parent:this.colorBox});var b=GSUtil.createElement("img",{src:_globals.resourceURL+"colorpicker/boverlay.png",styles:{width:"80px",height:"80px",position:"absolute"},events:{mousedown:GSUtil.bind(this.colorBoxMousedownHandler,this)},parent:this.colorBox});this.colorBoxCursor=GSUtil.createElement("img",{styles:{position:"absolute",zIndex:2},src:_globals.resourceURL+"colorpicker/cursor.gif",parent:this.colorBox});this.updateColorBoxCursorPosition();GSDrag.init(this.colorBoxCursor,null,(GSColorPicker.COLOR_BOX_CURSOR_SIZE/2)*-1,72,(GSColorPicker.COLOR_BOX_CURSOR_SIZE/2)*-1,72);var a=GSUtil.bind(this.colorBoxCursorDragHandler,this);this.colorBoxCursor.onDragStart=a;this.colorBoxCursor.onDrag=a;this.colorSlider=GSUtil.createElement("img",{src:_globals.resourceURL+"colorpicker/slider.png",styles:{position:"absolute",left:"90px",top:"4px",width:"10px",height:"80px",border:"1px solid #999"},events:{mousedown:GSUtil.bindAsEventListener(this.sliderMousedownHandler,this)},parent:this.element});this.setVisible(this.visible)};GSColorPicker.prototype.show=function(){this.setVisible(true)};GSColorPicker.prototype.hide=function(){this.setVisible(false)};GSColorPicker.prototype.setVisible=function(a){this.visible=a;if(this.visible){this.eventListeners.parentClick=GSEventManager.addEventListener(this.parent,"click",this.hide,this)}else{GSEventManager.release(this.eventListeners.parentClick)}this.element.style.visibility=a?"visible":"hidden"};GSColorPicker.prototype.setColor=function(a){this.color=this.hex2Rgb(a);var b=this.rgb2Hsv(this.color);this.hue=this.hsv2Rgb({h:b.h,s:1,v:1});this.colorBox.style.backgroundColor=this.rgb2Hex(this.hue);this.updateColorBoxCursorPosition()};GSColorPicker.prototype.getSliderColor=function(m){var e=GSColorPicker.SLIDER_HEIGHT;var f=e/6,h=e/f,d=m,k=d%f;var a=Math.round(d<f?255:d<f*2?255-k*h:d<f*4?0:d<f*5?k*h:255);var i=Math.round(d<f*2?0:d<f*3?k*h:d<f*5?255:255-k*h);var l=Math.round(d<f?k*h:d<f*3?255:d<f*4?255-k*h:0);return{r:a,g:i,b:l}};GSColorPicker.prototype.getColorBoxColor=function(d,e){d.x=Math.round((d.x/GSColorPicker.COLOR_BOX_WIDTH)*255);d.y=Math.round((d.y/GSColorPicker.COLOR_BOX_HEIGHT)*255);var c=d.x<0?0:d.x>255?255:d.x;var i=d.y<0?0:d.y>255?255:d.y;var h=Math.round((1-(1-(e.r/255))*(c/255))*(255-i));var f=Math.round((1-(1-(e.g/255))*(c/255))*(255-i));var a=Math.round((1-(1-(e.b/255))*(c/255))*(255-i));return{r:h,g:f,b:a}};GSColorPicker.prototype.calcColorBoxCursorPosition=function(){var b=this.rgb2Hsv(this.color);var c=(b.v/255)*GSColorPicker.COLOR_BOX_HEIGHT;var a=(1-b.s)*GSColorPicker.COLOR_BOX_WIDTH;return new GSPoint(parseInt(a),parseInt(c))};GSColorPicker.prototype.updateColorBoxFromSlider=function(c){this.hue=this.getSliderColor(c.y);this.colorBox.style.backgroundColor=this.rgb2Hex(this.hue);var b=this.rgb2Hsv(this.color);var a=this.rgb2Hsv(this.hue);this.color=this.hsv2Rgb({h:a.h,s:b.s,v:b.v/255});if(this.options.onChange){this.options.onChange(this.rgb2Hex(this.color))}};GSColorPicker.prototype.updateColorBoxCursorPosition=function(){var c=this.calcColorBoxCursorPosition();var a=GSColorPicker.COLOR_BOX_WIDTH-c.x-(GSColorPicker.COLOR_BOX_CURSOR_SIZE/2);var b=GSColorPicker.COLOR_BOX_HEIGHT-c.y-(GSColorPicker.COLOR_BOX_CURSOR_SIZE/2);this.colorBoxCursor.style.left=a+"px";this.colorBoxCursor.style.top=b+"px"};GSColorPicker.prototype.colorBoxMousedownHandler=function(b){GSUtil.cancelEvent(b);var c=this.getMousePosition(b);this.color=this.getColorBoxColor(c,this.hue);this.updateColorBoxCursorPosition();var a;if(document.createEvent){a=document.createEvent("MouseEvents");a.initMouseEvent("mousedown",true,true,window,0,b.screenX,b.screenY,b.clientX,b.clientY,false,false,false,false,0,null);this.colorBoxCursor.dispatchEvent(a)}else{a=document.createEventObject(b);this.colorBoxCursor.fireEvent("onmousedown",a)}if(this.options.onChange){this.options.onChange(this.rgb2Hex(this.color))}};GSColorPicker.prototype.colorBoxCursorDragHandler=function(a,b){this.color=this.getColorBoxColor(new GSPoint(a,b),this.hue);if(this.options.onChange){this.options.onChange(this.rgb2Hex(this.color))}};GSColorPicker.prototype.sliderMousedownHandler=function(a){GSUtil.cancelEvent(a);this.eventListeners.sliderMousedown=GSEventManager.addEventListener(this.colorSlider,"mousemove",this.sliderMousemoveHandler,this);this.eventListeners.sliderMouseup=GSEventManager.addEventListener(document,"mouseup",this.sliderMouseupHandler,this);var b=this.getMousePosition(a);this.updateColorBoxFromSlider(b)};GSColorPicker.prototype.sliderMousemoveHandler=function(a){GSUtil.cancelEvent(a);var b=this.getMousePosition(a);this.updateColorBoxFromSlider(b)};GSColorPicker.prototype.sliderMouseupHandler=function(a){GSUtil.cancelEvent(a);GSEventManager.release(this.eventListeners.sliderMousedown);GSEventManager.release(this.eventListeners.sliderMouseup)};GSColorPicker.prototype.getMousePosition=function(d){var b=GSUtil.getMousePos(d);var c=GSUtil.getElementPosition(d.target||d.srcElement);var a=b.x-c.x;var f=b.y-c.y;return new GSPoint(a,f)};GSColorPicker.prototype.hex2Rgb=function(hex){if(this.hex.test(hex)){return{r:eval("0x"+hex.substr(hex.length==6?0:1,2)),g:eval("0x"+hex.substr(hex.length==6?2:3,2)),b:eval("0x"+hex.substr(hex.length==6?4:5,2))}}};GSColorPicker.prototype.rgb2Hex=function(a){var b="#";for(var e in a){if(a.hasOwnProperty(e)){var d=parseInt(a[e]).toString(16);b+=(d.length<2?"0"+d:d)}}return b};GSColorPicker.prototype.rgb2Hsv=function(f){var a=f.r;var e=f.g;var i=f.b;var j=Math.max(Math.max(a,e),i);var c=Math.min(Math.min(a,e),i);var l=j;var k=(j-c);var m=0;if(j!==0){m=k/j}var d=0;if(c!=j){if(a==j){d=(e-i)/k}else{if(e==j){d=2+((i-a)/k)}else{d=4+((a-e)/k)}}d=d*60;if(d<0){d+=360}}return{h:d,s:m,v:l}};GSColorPicker.prototype.hsv2Rgb=function(l){var k=l.h;var x=l.s;var u=l.v;var a=u;var m=u;var o=u;if(u===0||x===0){return{r:a,g:m,b:o}}var e=(k/60);var j=Math.floor(e);var n=e-j;var d=u*(1-x);var c=u*(1-x*n);var w=u*(1-x*(1-n));switch(j){case 0:a=u;m=w;o=d;break;case 1:a=c;m=u;o=d;break;case 2:a=d;m=u;o=w;break;case 3:a=d;m=c;o=u;break;case 4:a=w;m=d;o=u;break;default:a=u;m=d;o=c;break}return{r:Math.round(a*255),g:Math.round(m*255),b:Math.round(o*255)}};if(window.GSModule&&GSModule.moduleLoaded){GSModule.moduleLoaded("additional-ui")};