var jscolor={dir:"",bindClass:"color",binding:!0,preloading:!0,install:function(){jscolor.addEvent(window,"load",jscolor.init)},init:function(){jscolor.binding&&jscolor.bind(),jscolor.preloading&&jscolor.preload()},getDir:function(){if(!jscolor.dir){var e=jscolor.detectDir();jscolor.dir=e!==!1?e:"jscolor/"}return jscolor.dir},detectDir:function(){for(var e=location.href,t=document.getElementsByTagName("base"),o=0;oh[t]?-c[t]+s[t]+l[t]/2>h[t]/2&&s[t]+l[t]-u[t]>=0?s[t]+l[t]-u[t]:s[t]:s[t],-c[o]+s[o]+l[o]+u[o]-d+d*r>h[o]?-c[o]+s[o]+l[o]/2>h[o]/2&&s[o]+l[o]-d-d*r>=0?s[o]+l[o]-d-d*r:s[o]+l[o]-d+d*r:s[o]+l[o]-d+d*r>=0?s[o]+l[o]-d+d*r:s[o]+l[o]-d-d*r];else var p=[s[t],s[o]+l[o]-d+d*r];n(p[t],p[o])}},this.importColor=function(){k?this.adjust?!this.required&&/^\s*$/.test(k.value)?(k.value="",v.style.backgroundImage=v.jscStyle.backgroundImage,v.style.backgroundColor=v.jscStyle.backgroundColor,v.style.color=v.jscStyle.color,this.exportColor(M|C)):this.fromString(k.value)||this.exportColor():this.fromString(k.value,M)||(v.style.backgroundImage=v.jscStyle.backgroundImage,v.style.backgroundColor=v.jscStyle.backgroundColor,v.style.color=v.jscStyle.color,this.exportColor(M|C)):this.exportColor()},this.exportColor=function(e){if(!(e&M)&&k){var t=this.toString();this.caps&&(t=t.toUpperCase()),this.hash&&(t="#"+t),k.value=t}e&C||!v||(v.style.backgroundImage="none",v.style.backgroundColor="#"+this.toString(),v.style.color=.213*this.rgb[0]+.715*this.rgb[1]+.072*this.rgb[2]<.5?"#FFF":"#000"),e&E||!a()||l(),e&I||!a()||c()},this.fromHSV=function(e,t,o,s){null!==e&&(e=Math.max(0,this.minH,Math.min(6,this.maxH,e))),null!==t&&(t=Math.max(0,this.minS,Math.min(1,this.maxS,t))),null!==o&&(o=Math.max(0,this.minV,Math.min(1,this.maxV,o))),this.rgb=r(null===e?this.hsv[0]:this.hsv[0]=e,null===t?this.hsv[1]:this.hsv[1]=t,null===o?this.hsv[2]:this.hsv[2]=o),this.exportColor(s)},this.fromRGB=function(e,t,s,n){null!==e&&(e=Math.max(0,Math.min(1,e))),null!==t&&(t=Math.max(0,Math.min(1,t))),null!==s&&(s=Math.max(0,Math.min(1,s)));var i=o(null===e?this.rgb[0]:e,null===t?this.rgb[1]:t,null===s?this.rgb[2]:s);null!==i[0]&&(this.hsv[0]=Math.max(0,this.minH,Math.min(6,this.maxH,i[0]))),0!==i[2]&&(this.hsv[1]=null===i[1]?null:Math.max(0,this.minS,Math.min(1,this.maxS,i[1]))),this.hsv[2]=null===i[2]?null:Math.max(0,this.minV,Math.min(1,this.maxV,i[2]));var l=r(this.hsv[0],this.hsv[1],this.hsv[2]);this.rgb[0]=l[0],this.rgb[1]=l[1],this.rgb[2]=l[2],this.exportColor(n)},this.fromString=function(e,t){var o=e.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);return o?(6===o[1].length?this.fromRGB(parseInt(o[1].substr(0,2),16)/255,parseInt(o[1].substr(2,2),16)/255,parseInt(o[1].substr(4,2),16)/255,t):this.fromRGB(parseInt(o[1].charAt(0)+o[1].charAt(0),16)/255,parseInt(o[1].charAt(1)+o[1].charAt(1),16)/255,parseInt(o[1].charAt(2)+o[1].charAt(2),16)/255,t),!0):!1},this.toString=function(){return(256|Math.round(255*this.rgb[0])).toString(16).substr(1)+(256|Math.round(255*this.rgb[1])).toString(16).substr(1)+(256|Math.round(255*this.rgb[2])).toString(16).substr(1)};var f=this,b="hvs"===this.pickerMode.toLowerCase()?1:0,y=!1,k=jscolor.fetchElement(this.valueElement),v=jscolor.fetchElement(this.styleElement),j=!1,x=!1,w={},M=1,C=2,E=4,I=8;if(jscolor.addEvent(e,"focus",function(){f.pickerOnfocus&&f.showPicker()}),jscolor.addEvent(e,"blur",function(){y?y=!1:window.setTimeout(function(){y||h(),y=!1},0)}),k){var S=function(){f.fromString(k.value,M),m()};jscolor.addEvent(k,"keyup",S),jscolor.addEvent(k,"input",S),jscolor.addEvent(k,"blur",u),k.setAttribute("autocomplete","off")}switch(v&&(v.jscStyle={backgroundImage:v.style.backgroundImage,backgroundColor:v.style.backgroundColor,color:v.style.color}),b){case 0:jscolor.requireImage("hs.png");break;case 1:jscolor.requireImage("hv.png")}jscolor.requireImage("cross.gif"),jscolor.requireImage("arrow.gif"),this.importColor()}};jscolor.install();