var jscolor={dir:"",bindClass:"colorpicker",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 n=jscolor.detectDir();jscolor.dir=n!==!1?n:"jscolor/"}return jscolor.dir},detectDir:function(){for(var r=location.href,t=document.getElementsByTagName("base"),u,i,n=0;n<t.length;n+=1)t[n].href&&(r=t[n].href);for(t=document.getElementsByTagName("script"),n=0;n<t.length;n+=1)if(t[n].src&&/(^|\/)jscolor\.js([?#].*)?$/i.test(t[n].src))return u=new jscolor.URI(t[n].src),i=u.toAbsolute(r),i.path=i.path.replace(/[^\/]+$/,""),i.query=null,i.fragment=null,i.toString();return!1},bind:function(){for(var u=new RegExp("(^|\\s)("+jscolor.bindClass+")\\s*(\\{[^}]*\\})?","i"),t=document.getElementsByTagName("input"),i,r,n=0;n<t.length;n+=1)if(!t[n].color&&t[n].className&&(i=t[n].className.match(u))){if(r={},i[3])try{r=new Function("return ("+i[3]+")")()}catch(f){}t[n].color=new jscolor.color(t[n],r)}},preload:function(){for(var n in jscolor.imgRequire)jscolor.imgRequire.hasOwnProperty(n)&&jscolor.loadImage(n)},images:{pad:[181,101],sld:[16,101],cross:[15,15],arrow:[7,11]},imgRequire:{},imgLoaded:{},requireImage:function(n){jscolor.imgRequire[n]=!0},loadImage:function(n){jscolor.imgLoaded[n]||(jscolor.imgLoaded[n]=new Image,jscolor.imgLoaded[n].src=jscolor.getDir()+n)},fetchElement:function(n){return typeof n=="string"?document.getElementById(n):n},addEvent:function(n,t,i){n.addEventListener?n.addEventListener(t,i,!1):n.attachEvent&&n.attachEvent("on"+t,i)},fireEvent:function(n,t){var i;n&&(document.createEvent?(i=document.createEvent("HTMLEvents"),i.initEvent(t,!0,!0),n.dispatchEvent(i)):document.createEventObject?(i=document.createEventObject(),n.fireEvent("on"+t,i)):n["on"+t]&&n["on"+t]())},getElementPos:function(n){var t=n,i=n,r=0,u=0;if(t.offsetParent)do r+=t.offsetLeft,u+=t.offsetTop;while(t=t.offsetParent);while((i=i.parentNode)&&i.nodeName.toUpperCase()!=="BODY")r-=i.scrollLeft,u-=i.scrollTop;return[r,u]},getElementSize:function(n){return[n.offsetWidth,n.offsetHeight]},getRelMousePos:function(n){var t=0,i=0;return n||(n=window.event),typeof n.offsetX=="number"?(t=n.offsetX,i=n.offsetY):typeof n.layerX=="number"&&(t=n.layerX,i=n.layerY),{x:t,y:i}},getViewPos:function(){return typeof window.pageYOffset=="number"?[window.pageXOffset,window.pageYOffset]:document.body&&(document.body.scrollLeft||document.body.scrollTop)?[document.body.scrollLeft,document.body.scrollTop]:document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)?[document.documentElement.scrollLeft,document.documentElement.scrollTop]:[0,0]},getViewSize:function(){return typeof window.innerWidth=="number"?[window.innerWidth,window.innerHeight]:document.body&&(document.body.clientWidth||document.body.clientHeight)?[document.body.clientWidth,document.body.clientHeight]:document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)?[document.documentElement.clientWidth,document.documentElement.clientHeight]:[0,0]},URI:function(n){function t(n){for(var t="",i;n;)n.substr(0,3)==="../"||n.substr(0,2)==="./"?n=n.replace(/^\.+/,"").substr(1):n.substr(0,3)==="/./"||n==="/."?n="/"+n.substr(3):n.substr(0,4)==="/../"||n==="/.."?(n="/"+n.substr(4),t=t.replace(/\/?[^\/]*$/,"")):n==="."||n===".."?n="":(i=n.match(/^\/?[^\/]*/)[0],n=n.substr(i.length),t=t+i);return t}this.scheme=null,this.authority=null,this.path="",this.query=null,this.fragment=null,this.parse=function(n){var t=n.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);return this.scheme=t[3]?t[2]:null,this.authority=t[5]?t[6]:null,this.path=t[7],this.query=t[9]?t[10]:null,this.fragment=t[12]?t[13]:null,this},this.toString=function(){var n="";return this.scheme!==null&&(n=n+this.scheme+":"),this.authority!==null&&(n=n+"//"+this.authority),this.path!==null&&(n=n+this.path),this.query!==null&&(n=n+"?"+this.query),this.fragment!==null&&(n=n+"#"+this.fragment),n},this.toAbsolute=function(n){var n=new jscolor.URI(n),i=this,r=new jscolor.URI;return n.scheme===null?!1:(i.scheme!==null&&i.scheme.toLowerCase()===n.scheme.toLowerCase()&&(i.scheme=null),i.scheme!==null?(r.scheme=i.scheme,r.authority=i.authority,r.path=t(i.path),r.query=i.query):(i.authority!==null?(r.authority=i.authority,r.path=t(i.path),r.query=i.query):(i.path===""?(r.path=n.path,r.query=i.query!==null?i.query:n.query):(i.path.substr(0,1)==="/"?r.path=t(i.path):(r.path=n.authority!==null&&n.path===""?"/"+i.path:n.path.replace(/[^\/]+$/,"")+i.path,r.path=t(r.path)),r.query=i.query),r.authority=n.authority),r.scheme=n.scheme),r.fragment=i.fragment,r)},n&&this.parse(n)},color:function(n,t){function ot(n,t,i){var f=Math.min(Math.min(n,t),i),u=Math.max(Math.max(n,t),i),r=u-f,e;return r===0?[null,0,u]:(e=n===f?3+(i-t)/r:t===f?5+(n-i)/r:1+(t-n)/r,[e===6?0:e,r/u,u])}function k(n,t,i){if(n===null)return[i,i,i];var f=Math.floor(n),e=f%2?n-f:1-(n-f),r=i*(1-t),u=i*(1-t*e);switch(f){case 6:case 0:return[i,u,r];case 1:return[u,i,r];case 2:return[r,i,u];case 3:return[r,u,i];case 4:return[u,r,i];case 5:return[i,r,u]}}function et(){delete jscolor.picker.owner,document.getElementsByTagName("body")[0].removeChild(jscolor.picker.boxB)}function ft(t,r){function d(){var n=i.pickerInsetColor.split(/\s+/),t=n.length<2?n[0]:n[1]+" "+n[0]+" "+n[0]+" "+n[1];h.btn.style.borderColor=t}var v,y,a,h,p,k;if(!jscolor.picker){for(jscolor.picker={box:document.createElement("div"),boxB:document.createElement("div"),pad:document.createElement("div"),padB:document.createElement("div"),padM:document.createElement("div"),sld:document.createElement("div"),sldB:document.createElement("div"),sldM:document.createElement("div"),btn:document.createElement("div"),btnS:document.createElement("span"),btnT:document.createTextNode(i.pickerCloseText)},v=0,y=4;v<jscolor.images.sld[1];v+=y)a=document.createElement("div"),a.style.height=y+"px",a.style.fontSize="1px",a.style.lineHeight="0",jscolor.picker.sld.appendChild(a);jscolor.picker.sldB.appendChild(jscolor.picker.sld),jscolor.picker.box.appendChild(jscolor.picker.sldB),jscolor.picker.box.appendChild(jscolor.picker.sldM),jscolor.picker.padB.appendChild(jscolor.picker.pad),jscolor.picker.box.appendChild(jscolor.picker.padB),jscolor.picker.box.appendChild(jscolor.picker.padM),jscolor.picker.btnS.appendChild(jscolor.picker.btnT),jscolor.picker.btn.appendChild(jscolor.picker.btnS),jscolor.picker.box.appendChild(jscolor.picker.btn),jscolor.picker.boxB.appendChild(jscolor.picker.box)}h=jscolor.picker,h.box.onmouseup=h.box.onmouseout=function(){n.focus()},h.box.onmousedown=function(){c=!0},h.box.onmousemove=function(n){(o||e)&&(o&&b(n),e&&w(n),document.selection?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges(),l())},"ontouchstart"in window&&h.box.addEventListener("touchmove",function(n){var t={offsetX:n.touches[0].pageX-f.X,offsetY:n.touches[0].pageY-f.Y};(o||e)&&(o&&b(t),e&&w(t),l()),n.stopPropagation(),n.preventDefault()},!1),h.padM.onmouseup=h.padM.onmouseout=function(){o&&(o=!1,jscolor.fireEvent(u,"change"))},h.padM.onmousedown=function(n){switch(s){case 0:i.hsv[2]===0&&i.fromHSV(null,null,1);break;case 1:i.hsv[1]===0&&i.fromHSV(null,1,null)}e=!1,o=!0,b(n),l()},"ontouchstart"in window&&h.padM.addEventListener("touchstart",function(n){f={X:n.target.offsetParent.offsetLeft,Y:n.target.offsetParent.offsetTop};this.onmousedown({offsetX:n.touches[0].pageX-f.X,offsetY:n.touches[0].pageY-f.Y})}),h.sldM.onmouseup=h.sldM.onmouseout=function(){e&&(e=!1,jscolor.fireEvent(u,"change"))},h.sldM.onmousedown=function(n){o=!1,e=!0,w(n),l()},"ontouchstart"in window&&h.sldM.addEventListener("touchstart",function(n){f={X:n.target.offsetParent.offsetLeft,Y:n.target.offsetParent.offsetTop};this.onmousedown({offsetX:n.touches[0].pageX-f.X,offsetY:n.touches[0].pageY-f.Y})}),p=it(i),h.box.style.width=p[0]+"px",h.box.style.height=p[1]+"px",h.boxB.style.position="absolute",h.boxB.style.clear="both",h.boxB.style.left=t+"px",h.boxB.style.top=r+"px",h.boxB.style.zIndex=i.pickerZIndex,h.boxB.style.border=i.pickerBorder+"px solid",h.boxB.style.borderColor=i.pickerBorderColor,h.boxB.style.background=i.pickerFaceColor,h.pad.style.width=jscolor.images.pad[0]+"px",h.pad.style.height=jscolor.images.pad[1]+"px",h.padB.style.position="absolute",h.padB.style.left=i.pickerFace+"px",h.padB.style.top=i.pickerFace+"px",h.padB.style.border=i.pickerInset+"px solid",h.padB.style.borderColor=i.pickerInsetColor,h.padM.style.position="absolute",h.padM.style.left="0",h.padM.style.top="0",h.padM.style.width=i.pickerFace+2*i.pickerInset+jscolor.images.pad[0]+jscolor.images.arrow[0]+"px",h.padM.style.height=h.box.style.height,h.padM.style.cursor="crosshair",h.sld.style.overflow="hidden",h.sld.style.width=jscolor.images.sld[0]+"px",h.sld.style.height=jscolor.images.sld[1]+"px",h.sldB.style.display=i.slider?"block":"none",h.sldB.style.position="absolute",h.sldB.style.right=i.pickerFace+"px",h.sldB.style.top=i.pickerFace+"px",h.sldB.style.border=i.pickerInset+"px solid",h.sldB.style.borderColor=i.pickerInsetColor,h.sldM.style.display=i.slider?"block":"none",h.sldM.style.position="absolute",h.sldM.style.right="0",h.sldM.style.top="0",h.sldM.style.width=jscolor.images.sld[0]+jscolor.images.arrow[0]+i.pickerFace+2*i.pickerInset+"px",h.sldM.style.height=h.box.style.height;try{h.sldM.style.cursor="pointer"}catch(g){h.sldM.style.cursor="hand"}h.btn.style.display=i.pickerClosable?"block":"none",h.btn.style.position="absolute",h.btn.style.left=i.pickerFace+"px",h.btn.style.bottom=i.pickerFace+"px",h.btn.style.padding="0 15px",h.btn.style.height="18px",h.btn.style.border=i.pickerInset+"px solid",d(),h.btn.style.color=i.pickerButtonColor,h.btn.style.font="12px sans-serif",h.btn.style.textAlign="center";try{h.btn.style.cursor="pointer"}catch(g){h.btn.style.cursor="hand"}h.btn.onmousedown=function(){i.hidePicker()},h.btnS.style.lineHeight=h.btn.style.height;switch(s){case 0:k="hs.png";break;case 1:k="hv.png"}h.padM.style.backgroundImage="url('"+jscolor.getDir()+"cross.gif')",h.padM.style.backgroundRepeat="no-repeat",h.sldM.style.backgroundImage="url('"+jscolor.getDir()+"arrow.gif')",h.sldM.style.backgroundRepeat="no-repeat",h.pad.style.backgroundImage="url('"+jscolor.getDir()+k+"')",h.pad.style.backgroundRepeat="no-repeat",h.pad.style.backgroundPosition="0 0",tt(),nt(),jscolor.picker.owner=i,document.getElementsByTagName("body")[0].appendChild(h.boxB)}function it(n){return[2*n.pickerInset+2*n.pickerFace+jscolor.images.pad[0]+(n.slider?2*n.pickerInset+2*jscolor.images.arrow[0]+jscolor.images.sld[0]:0),n.pickerClosable?4*n.pickerInset+3*n.pickerFace+jscolor.images.pad[1]+n.pickerButtonHeight:2*n.pickerInset+2*n.pickerFace+jscolor.images.pad[1]]}function tt(){var f,o,h,r,t,n;switch(s){case 0:f=1;break;case 1:f=2}o=Math.round(i.hsv[0]/6*(jscolor.images.pad[0]-1)),h=Math.round((1-i.hsv[f])*(jscolor.images.pad[1]-1)),jscolor.picker.padM.style.backgroundPosition=i.pickerFace+i.pickerInset+o-Math.floor(jscolor.images.cross[0]/2)+"px "+(i.pickerFace+i.pickerInset+h-Math.floor(jscolor.images.cross[1]/2))+"px",r=jscolor.picker.sld.childNodes;switch(s){case 0:for(t=k(i.hsv[0],i.hsv[1],1),n=0;n<r.length;n+=1)r[n].style.backgroundColor="rgb("+t[0]*(1-n/r.length)*100+"%,"+t[1]*(1-n/r.length)*100+"%,"+t[2]*(1-n/r.length)*100+"%)";break;case 1:var t,e,u=[i.hsv[2],0,0],n=Math.floor(i.hsv[0]),c=n%2?i.hsv[0]-n:1-(i.hsv[0]-n);switch(n){case 6:case 0:t=[0,1,2];break;case 1:t=[1,0,2];break;case 2:t=[2,0,1];break;case 3:t=[2,1,0];break;case 4:t=[1,2,0];break;case 5:t=[0,2,1]}for(n=0;n<r.length;n+=1)e=1-1/(r.length-1)*n,u[1]=u[0]*(1-e*c),u[2]=u[0]*(1-e),r[n].style.backgroundColor="rgb("+u[t[0]]*100+"%,"+u[t[1]]*100+"%,"+u[t[2]]*100+"%)"}}function nt(){var n,t;switch(s){case 0:n=2;break;case 1:n=1}t=Math.round((1-i.hsv[n])*(jscolor.images.sld[1]-1)),jscolor.picker.sldM.style.backgroundPosition="0 "+(i.pickerFace+i.pickerInset+t-Math.floor(jscolor.images.arrow[1]/2))+"px"}function v(){return jscolor.picker&&jscolor.picker.owner===i}function ut(){u===n&&i.importColor(),i.pickerOnfocus&&i.hidePicker()}function rt(){u!==n&&i.importColor()}function b(n){var t=jscolor.getRelMousePos(n),r=t.x-i.pickerFace-i.pickerInset,u=t.y-i.pickerFace-i.pickerInset;switch(s){case 0:i.fromHSV(r*(6/(jscolor.images.pad[0]-1)),1-u/(jscolor.images.pad[1]-1),null,d);break;case 1:i.fromHSV(r*(6/(jscolor.images.pad[0]-1)),null,1-u/(jscolor.images.pad[1]-1),d)}}function w(n){var r=jscolor.getRelMousePos(n),t=r.y-i.pickerFace-i.pickerInset;switch(s){case 0:i.fromHSV(null,null,1-t/(jscolor.images.sld[1]-1),y);break;case 1:i.fromHSV(null,1-t/(jscolor.images.sld[1]-1),null,y)}}function l(){if(i.onImmediateChange){var n;n=typeof i.onImmediateChange=="string"?new Function(i.onImmediateChange):i.onImmediateChange,n.call(i)}}var a,g;this.required=!0,this.adjust=!1,this.hash=!0,this.caps=!0,this.slider=!0,this.valueElement=n,this.styleElement=n,this.onImmediateChange=null,this.hsv=[0,0,1],this.rgb=[1,1,1],this.minH=0,this.maxH=6,this.minS=0,this.maxS=1,this.minV=0,this.maxV=1,this.pickerOnfocus=!0,this.pickerMode="HSV",this.pickerPosition="bottom",this.pickerSmartPosition=!0,this.pickerButtonHeight=20,this.pickerClosable=!1,this.pickerCloseText="Close",this.pickerButtonColor="ButtonText",this.pickerFace=10,this.pickerFaceColor="ThreeDFace",this.pickerBorder=1,this.pickerBorderColor="ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight",this.pickerInset=1,this.pickerInsetColor="ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow",this.pickerZIndex=1e4;for(a in t)t.hasOwnProperty(a)&&(this[a]=t[a]);this.hidePicker=function(){v()&&et()},this.showPicker=function(){var r,c;if(!v()){var u=jscolor.getElementPos(n),f=jscolor.getElementSize(n),s=jscolor.getViewPos(),h=jscolor.getViewSize(),o=it(this),i,t,e;switch(this.pickerPosition.toLowerCase()){case"left":i=1,t=0,e=-1;break;case"right":i=1,t=0,e=1;break;case"top":i=0,t=1,e=-1;break;default:i=0,t=1,e=1}r=(f[t]+o[t])/2,c=this.pickerSmartPosition?[-s[i]+u[i]+o[i]>h[i]?-s[i]+u[i]+f[i]/2>h[i]/2&&u[i]+f[i]-o[i]>=0?u[i]+f[i]-o[i]:u[i]:u[i],-s[t]+u[t]+f[t]+o[t]-r+r*e>h[t]?-s[t]+u[t]+f[t]/2>h[t]/2&&u[t]+f[t]-r-r*e>=0?u[t]+f[t]-r-r*e:u[t]+f[t]-r+r*e:u[t]+f[t]-r+r*e>=0?u[t]+f[t]-r+r*e:u[t]+f[t]-r-r*e]:[u[i],u[t]+f[t]-r+r*e],ft(c[i],c[t])}},this.importColor=function(){u?this.adjust?!this.required&&/^\s*$/.test(u.value)?(u.value="",r.style.backgroundImage=r.jscStyle.backgroundImage,r.style.backgroundColor=r.jscStyle.backgroundColor,r.style.color=r.jscStyle.color,this.exportColor(h|p)):this.fromString(u.value)||this.exportColor():this.fromString(u.value,h)||(r.style.backgroundImage=r.jscStyle.backgroundImage,r.style.backgroundColor=r.jscStyle.backgroundColor,r.style.color=r.jscStyle.color,this.exportColor(h|p)):this.exportColor()},this.exportColor=function(n){if(!(n&h)&&u){var t=this.toString();this.caps&&(t=t.toUpperCase()),this.hash&&(t="#"+t),u.value=t}n&p||!r||(r.style.backgroundImage="none",r.style.backgroundColor="#"+this.toString(),r.style.color=.213*this.rgb[0]+.715*this.rgb[1]+.072*this.rgb[2]<.5?"#FFF":"#000"),n&y||!v()||tt(),n&d||!v()||nt()},this.fromHSV=function(n,t,i,r){n!==null&&(n=Math.max(0,this.minH,Math.min(6,this.maxH,n))),t!==null&&(t=Math.max(0,this.minS,Math.min(1,this.maxS,t))),i!==null&&(i=Math.max(0,this.minV,Math.min(1,this.maxV,i))),this.rgb=k(n===null?this.hsv[0]:this.hsv[0]=n,t===null?this.hsv[1]:this.hsv[1]=t,i===null?this.hsv[2]:this.hsv[2]=i),this.exportColor(r)},this.fromRGB=function(n,t,i,r){var u,f;n!==null&&(n=Math.max(0,Math.min(1,n))),t!==null&&(t=Math.max(0,Math.min(1,t))),i!==null&&(i=Math.max(0,Math.min(1,i))),u=ot(n===null?this.rgb[0]:n,t===null?this.rgb[1]:t,i===null?this.rgb[2]:i),u[0]!==null&&(this.hsv[0]=Math.max(0,this.minH,Math.min(6,this.maxH,u[0]))),u[2]!==0&&(this.hsv[1]=u[1]===null?null:Math.max(0,this.minS,Math.min(1,this.maxS,u[1]))),this.hsv[2]=u[2]===null?null:Math.max(0,this.minV,Math.min(1,this.maxV,u[2])),f=k(this.hsv[0],this.hsv[1],this.hsv[2]),this.rgb[0]=f[0],this.rgb[1]=f[1],this.rgb[2]=f[2],this.exportColor(r)},this.fromString=function(n,t){var i=n.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);return i?(i[1].length===6?this.fromRGB(parseInt(i[1].substr(0,2),16)/255,parseInt(i[1].substr(2,2),16)/255,parseInt(i[1].substr(4,2),16)/255,t):this.fromRGB(parseInt(i[1].charAt(0)+i[1].charAt(0),16)/255,parseInt(i[1].charAt(1)+i[1].charAt(1),16)/255,parseInt(i[1].charAt(2)+i[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 i=this,s=this.pickerMode.toLowerCase()==="hvs"?1:0,c=!1,u=jscolor.fetchElement(this.valueElement),r=jscolor.fetchElement(this.styleElement),o=!1,e=!1,f={},h=1,p=2,y=4,d=8;jscolor.addEvent(n,"focus",function(){i.pickerOnfocus&&i.showPicker()}),jscolor.addEvent(n,"blur",function(){c?c=!1:window.setTimeout(function(){c||ut(),c=!1},0)}),u&&(g=function(){i.fromString(u.value,h),l()},jscolor.addEvent(u,"keyup",g),jscolor.addEvent(u,"input",g),jscolor.addEvent(u,"blur",rt),u.setAttribute("autocomplete","off")),r&&(r.jscStyle={backgroundImage:r.style.backgroundImage,backgroundColor:r.style.backgroundColor,color:r.style.color});switch(s){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()