function $_(a,b){return((typeof(b)=="object"?b:document).getElementById(a))}function $S(a){a=$_(a);if(a){return(a.style)}}function abPos(b){var b=(typeof(b)=="object"?b:$_(b)),a={X:0,Y:0};while(b!=null){a.X+=b.offsetLeft;a.Y+=b.offsetTop;b=b.offsetParent}return(a)}function agent(a){return(Math.max(navigator.userAgent.toLowerCase().indexOf(a),0))}function toggle(a){if(!$S(a)){return}$S(a).display=($S(a).display=="none"?"block":"none")}function within(c,b,d){return((c>=b&&c<=d)?true:false)}function XY(b,a){var c=agent("msie")?{X:event.clientX+document.documentElement.scrollLeft,Y:event.clientY+document.documentElement.scrollTop}:{X:b.pageX,Y:b.pageY};return(a?c[a]:c)}function zero(a){a=parseInt(a);return(!isNaN(a)?a:0)}ColorPicker={};ColorPicker.maxValue={H:360,S:100,V:100};ColorPicker.HSV={H:360,S:100,V:100};ColorPicker.slideHSV={H:360,S:100,V:100};ColorPicker.zINDEX=15;ColorPicker.stop=1;ColorPicker.callback=null;ColorPicker.mkHSV=function(e,d,f){return(Math.min(e,Math.max(0,Math.ceil((parseInt(f)/d)*e))))};ColorPicker.HSVslide=function(l,b,k){function m(d){n=XY(d).Y-q.Y;p=XY(d).X-q.X}function h(e,d){if(within(e,0,d)){return(e)}else{if(e>d){return(d)}else{if(e<0){return("-"+i)}}}}function f(t){if(!ColorPicker.stop){if(l!="drag"){m(t)}if(l=="SVslide"){c.left=h(p-i,162)+"px";c.top=h(n-i,162)+"px";ColorPicker.slideHSV.S=ColorPicker.mkHSV(100,162,c.left);ColorPicker.slideHSV.V=100-ColorPicker.mkHSV(100,162,c.top);ColorPicker.HSVupdate(null,true)}else{if(l=="Hslide"){var d=h(n-i,163),s=["H","S","V"],u={};c.top=(d-12)+"px";ColorPicker.slideHSV.H=ColorPicker.mkHSV(360,163,d);for(var o in s){o=s[o];u[o]=(o=="H")?ColorPicker.maxValue[o]-ColorPicker.mkHSV(ColorPicker.maxValue[o],163,d):ColorPicker.HSV[o]}ColorPicker.HSVupdate(u,true);$S("SV").backgroundColor="#"+color.HSV_HEX({H:ColorPicker.HSV.H,S:100,V:100})}else{if(l=="drag"){c.left=XY(t).X+j-a+"px";c.top=XY(t).Y+g-r+"px"}}}}}if(ColorPicker.stop){ColorPicker.stop="";var c=$S(l!="drag"?l:b);if(l=="drag"){var j=parseInt(c.left),g=parseInt(c.top),a=XY(k).X,r=XY(k).Y;$S(b).zIndex=ColorPicker.zINDEX++}else{var q=abPos($_(b)),p,n,i=(l=="Hslide")?2:4;q.X+=10;q.Y+=22;if(l=="SVslide"){ColorPicker.slideHSV.H=ColorPicker.HSV.H}}document.onmousemove=f;document.onmouseup=function(){ColorPicker.stop=1;document.onmousemove="";document.onmouseup=""};f(k)}};ColorPicker.HSVupdate=function(a,b){a=color.HSV_HEX(ColorPicker.HSV=a?a:ColorPicker.slideHSV);$_("hexinput").value=a;$S("plugCUR").background="#"+a;if(b&&ColorPicker.callback){ColorPicker.callback(a)}return(a)};ColorPicker.handleKey=function(a){if(!a){a=window.event}if(a){if(a.keyCode==13){var b=$_("hexinput").value;if(color.isValidHEX(b)){ColorPicker.setColor(b);if(ColorPicker.callback){ColorPicker.callback(b)}}}}};ColorPicker.setColor=function(e){if(!e){return}if(e.indexOf("#")==0){e=e.substring(1)}var c=color.HEX_HSV(e);var b=ColorPicker.mkHSV(163,360,360-c.H)-12;$S("Hslide").top=b+"px";var a=ColorPicker.mkHSV(162,100,c.S)-4;$S("SVslide").left=a+"px";var d=ColorPicker.mkHSV(162,100,100-c.V)-4;$S("SVslide").top=d+"px";$S("SV").backgroundColor="#"+color.HSV_HEX({H:c.H,S:100,V:100});$S("plugCUR").background="#"+e;ColorPicker.HSVupdate(c);$_("hexinput").value=e};ColorPicker.draw=function(a,c){if(!a){a=0}if(!c){c=0}var b=document.createElement("div");b.innerHTML='<div id="ColorPicker" style="top:'+c+"px;left:"+a+'px;display:block">	 <div id="plugCLOSE" onmousedown="ColorPicker.hide()"></div><br>	 <div id="SV" onmousedown="ColorPicker.HSVslide(\'SVslide\',\'ColorPicker\',event)" title="Saturation + Value">	  <div id="SVslide" style="TOP: -4px; LEFT: -4px;"><br /></div>	 </div>	 <form id="H" onmousedown="ColorPicker.HSVslide(\'Hslide\',\'ColorPicker\',event)" title="Hue">	  <div id="Hmodel"></div>	  <div id="Hslide" style="TOP: -14px; LEFT: -14px;"><br /></div>	 </form>	 <div id="plugHEX" onmousedown="ColorPicker.stop=0; setTimeout(\'ColorPicker.stop=1\',100);">	 	<div id="hexlabel">Hex # </div>	 		 		<input id="hexinput" type="text" value="FFFFFF" onkeypress="ColorPicker.handleKey(event)"/>	 		 </div>	 <div id="plugCUR"></div>	</div>';document.body.appendChild(b)};ColorPicker.show=function(c,b,f){var d=XY(b);var e=abPos(c);e.X+=c.offsetWidth;var a=$_("ColorPicker");if(a){a.style.display="block";a.style.left=e.X+"px";a.style.top=e.Y+"px"}else{ColorPicker.draw(e.X,e.Y)}if(f){ColorPicker.callback=f}};ColorPicker.hide=function(){ColorPicker.callback=null;if($_("ColorPicker")){$S("ColorPicker").display="none"}};color={};color.HEX=function(a){a=Math.round(Math.min(Math.max(0,a),255));return("0123456789ABCDEF".charAt((a-a%16)/16)+"0123456789ABCDEF".charAt(a%16))};color.HEX_RGB=function(a){return({R:parseInt(a.substr(0,2),16),G:parseInt(a.substr(2,2),16),B:parseInt(a.substr(4,2),16),A:1})};color.HEX_HSV=function(a){return(color.RGB_HSV(color.HEX_RGB(a)))};color.RGB_HEX=function(b){var a=color.HEX;return(a(b.R)+a(b.G)+a(b.B))};color.RGB_HSV=function(d){var f=Math.max(d.R,d.G,d.B),e=f-Math.min(d.R,d.G,d.B),c,b,a;if(f!=0){b=Math.round(e/f*100);if(d.R==f){c=(d.G-d.B)/e}else{if(d.G==f){c=2+(d.B-d.R)/e}else{if(d.B==f){c=4+(d.R-d.G)/e}}}var c=Math.min(Math.round(c*60),360);if(c<0){c+=360}}return({H:c?c:0,S:b?b:0,V:Math.round((f/255)*100)})};color.HSV_RGB=function(c){var g,i,d,b,a,j,f=c.S/100,e=c.V/100,h=c.H/360;if(f>0){if(h>=1){h=0}h=6*h;j=h-Math.floor(h);d=Math.round(255*e*(1-f));b=Math.round(255*e*(1-(f*j)));a=Math.round(255*e*(1-(f*(1-j))));e=Math.round(255*e);switch(Math.floor(h)){case 0:g=e;i=a;b=d;break;case 1:g=b;i=e;b=d;break;case 2:g=d;i=e;b=a;break;case 3:g=d;i=b;b=e;break;case 4:g=a;i=d;b=e;break;case 5:g=e;i=d;b=b;break}return({R:g?g:0,G:i?i:0,B:b?b:0,A:1})}else{return({R:(e=Math.round(e*255)),G:e,B:e,A:1})}};color.HSV_HEX=function(a){return(color.RGB_HEX(color.HSV_RGB(a)))};color.isValidHEX=function(a){if(a==null||a==""){return false}return a.match(/^#?[0-9A-Fa-f]{6}$/)};