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