YAHOO.util.Color=function(){var A="0123456789ABCDEF",B=YAHOO.lang;return{real2dec:function(C){return Math.min(255,Math.round(C*256))},hsv2rgb:function(G,N,L){if(B.isArray(G)){return this.hsv2rgb.call(this,G[0],G[1],G[2])}var C,H,K,F,I,E,D,M;F=Math.floor((G/60)%6);I=(G/60)-F;E=L*(1-N);D=L*(1-I*N);M=L*(1-(1-I)*N);switch(F){case 0:C=L;H=M;K=E;break;case 1:C=D;H=L;K=E;break;case 2:C=E;H=L;K=M;break;case 3:C=E;H=D;K=L;break;case 4:C=M;H=E;K=L;break;case 5:C=L;H=E;K=D;break}var J=this.real2dec;return[J(C),J(H),J(K)]},rgb2hsv:function(C,G,H){if(B.isArray(C)){return this.rgb2hsv.call(this,C[0],C[1],C[2])}C=C/255;G=G/255;H=H/255;var D,I,K,F,L,J;D=Math.min(Math.min(C,G),H);I=Math.max(Math.max(C,G),H);K=I-D;switch(I){case D:F=0;break;case C:F=60*(G-H)/K;if(G<H){F+=360}break;case G:F=(60*(H-C)/K)+120;break;case H:F=(60*(C-G)/K)+240;break}L=(I===0)?0:1-(D/I);var E=[Math.round(F),L,I];return E},rgb2hex:function(E,D,C){if(B.isArray(E)){return this.rgb2hex.call(this,E[0],E[1],E[2])}var F=this.dec2hex;return F(E)+F(D)+F(C)},dec2hex:function(C){C=parseInt(C,10);C=(B.isNumber(C))?C:0;C=(C>255||C<0)?0:C;return A.charAt((C-C%16)/16)+A.charAt(C%16)},hex2dec:function(E){var D=function(F){return A.indexOf(F.toUpperCase())};var C=E.split("");return((D(C[0])*16)+D(C[1]))},hex2rgb:function(C){var D=this.hex2dec;return[D(C.substr(0,2)),D(C.substr(2,2)),D(C.substr(4,2))]},websafe:function(E,D,C){if(B.isArray(E)){return this.websafe.call(this,E[0],E[1],E[2])}var F=function(G){if(B.isNumber(G)){G=Math.min(Math.max(0,G),255);var H,I;for(H=0;H<256;H=H+51){I=H+51;if(G>=H&&G<=I){return(G-H>25)?I:H}}}return G};return[F(E),F(D),F(C)]}}}();(function(){var F=0;YAHOO.widget.ColorPicker=function(f,b){F=F+1;b=b||{};if(arguments.length===1&&!YAHOO.lang.isString(f)&&!f.nodeName){b=f;f=b.element||null}if(!f&&!b.element){f=Q.call(this,b)}YAHOO.widget.ColorPicker.superclass.constructor.call(this,f,b)};YAHOO.extend(YAHOO.widget.ColorPicker,YAHOO.util.Element);var P=YAHOO.widget.ColorPicker.prototype,O=YAHOO.widget.Slider,c=YAHOO.util.Color,C=YAHOO.util.Dom,d=YAHOO.util.Event,e=YAHOO.lang,I=e.substitute;var Z="yui-picker";P.ID={R:Z+"-r",R_HEX:Z+"-rhex",G:Z+"-g",G_HEX:Z+"-ghex",B:Z+"-b",B_HEX:Z+"-bhex",H:Z+"-h",S:Z+"-s",V:Z+"-v",PICKER_BG:Z+"-bg",PICKER_THUMB:Z+"-thumb",HUE_BG:Z+"-hue-bg",HUE_THUMB:Z+"-hue-thumb",HEX:Z+"-hex",SWATCH:Z+"-swatch",WEBSAFE_SWATCH:Z+"-websafe-swatch",CONTROLS:Z+"-controls",RGB_CONTROLS:Z+"-rgb-controls",HSV_CONTROLS:Z+"-hsv-controls",HEX_CONTROLS:Z+"-hex-controls",HEX_SUMMARY:Z+"-hex-summary",CONTROLS_LABEL:Z+"-controls-label"};P.TXT={ILLEGAL_HEX:"Illegal hex value entered",SHOW_CONTROLS:"Show color details",HIDE_CONTROLS:"Hide color details",CURRENT_COLOR:"Currently selected color: {rgb}",CLOSEST_WEBSAFE:"Closest websafe color: {rgb}. Click to select.",R:"R",G:"G",B:"B",H:"H",S:"S",V:"V",HEX:"#",DEG:"\u00B0",PERCENT:"%"};P.IMAGE={PICKER_THUMB:"../../build/colorpicker/assets/picker_thumb.png",HUE_THUMB:"../../build/colorpicker/assets/hue_thumb.png"};P.DEFAULT={PICKER_SIZE:180};P.OPT={HUE:"hue",SATURATION:"saturation",VALUE:"value",RED:"red",GREEN:"green",BLUE:"blue",HSV:"hsv",RGB:"rgb",WEBSAFE:"websafe",HEX:"hex",PICKER_SIZE:"pickersize",SHOW_CONTROLS:"showcontrols",SHOW_RGB_CONTROLS:"showrgbcontrols",SHOW_HSV_CONTROLS:"showhsvcontrols",SHOW_HEX_CONTROLS:"showhexcontrols",SHOW_HEX_SUMMARY:"showhexsummary",SHOW_WEBSAFE:"showwebsafe",CONTAINER:"container",IDS:"ids",ELEMENTS:"elements",TXT:"txt",IMAGES:"images",ANIMATE:"animate"};P.setValue=function(f,b){b=(b)||false;this.set(this.OPT.RGB,f,b);S.call(this)};P.hueSlider=null;P.pickerSlider=null;var W=function(){var b=this.get(this.OPT.PICKER_SIZE),f=(b-this.hueSlider.getValue())/b;f=Math.round(f*360);return(f===360)?0:f};var N=function(){return this.pickerSlider.getXValue()/this.get(this.OPT.PICKER_SIZE)};var M=function(){var b=this.get(this.OPT.PICKER_SIZE);return(b-this.pickerSlider.getYValue())/b};var L=function(){var g=this.get(this.OPT.RGB),i=this.get(this.OPT.WEBSAFE),h=this.getElement(this.ID.SWATCH),f=g.join(","),b=this.get(this.OPT.TXT);C.setStyle(h,"background-color","rgb("+f+")");h.title=e.substitute(b.CURRENT_COLOR,{rgb:"#"+this.get(this.OPT.HEX)});h=this.getElement(this.ID.WEBSAFE_SWATCH);f=i.join(",");C.setStyle(h,"background-color","rgb("+f+")");h.title=e.substitute(b.CLOSEST_WEBSAFE,{rgb:"#"+c.rgb2hex(i)})};var Y=function(){var g=W.call(this),f=N.call(this),b=M.call(this);rgb=c.hsv2rgb(g,f,b);var j=c.websafe(rgb);var i=c.rgb2hex(rgb[0],rgb[1],rgb[2]);this.set(this.OPT.RGB,rgb)};var B=function(){this.getElement(this.ID.H).value=this.get(this.OPT.HUE);this.getElement(this.ID.S).value=this.get(this.OPT.SATURATION);this.getElement(this.ID.V).value=this.get(this.OPT.VALUE);this.getElement(this.ID.R).value=this.get(this.OPT.RED);this.getElement(this.ID.R_HEX).innerHTML=c.dec2hex(this.get(this.OPT.RED));this.getElement(this.ID.G).value=this.get(this.OPT.GREEN);this.getElement(this.ID.G_HEX).innerHTML=c.dec2hex(this.get(this.OPT.GREEN));this.getElement(this.ID.B).value=this.get(this.OPT.BLUE);this.getElement(this.ID.B_HEX).innerHTML=c.dec2hex(this.get(this.OPT.BLUE));this.getElement(this.ID.HEX).value=this.get(this.OPT.HEX)};var X=function(i){var f=W.call(this);this.set(this.OPT.HUE,f,true);var b=c.hsv2rgb(f,1,1);var g="rgb("+b.join(",")+")";C.setStyle(this.getElement(this.ID.PICKER_BG),"background-color",g);if(this.hueSlider.valueChangeSource===this.hueSlider.SOURCE_UI_EVENT){Y.call(this)}B.call(this);L.call(this)};var G=function(g){var f=N.call(this),b=M.call(this);this.set(this.OPT.SATURATION,Math.round(f*100),true);this.set(this.OPT.VALUE,Math.round(b*100),true);if(this.pickerSlider.valueChangeSource===this.pickerSlider.SOURCE_UI_EVENT){Y.call(this)}B.call(this);L.call(this)};var V=function(b){var f=d.getCharCode(b);if(f===38){return 3}else{if(f===13){return 6}else{if(f===40){return 4}else{if(f>=48&&f<=57){return 1}else{if(f>=97&&f<=102){return 2}else{if(f>=65&&f<=70){return 2}else{if("8, 9, 13, 27, 37, 39".indexOf(f)>-1){return 5}else{return 0}}}}}}}};var E=function(g,b,i){var h=V(g);var f=(g.shiftKey)?10:1;switch(h){case 6:H.apply(this,arguments);break;case 3:this.set(i,Math.min(this.get(i)+f,255));B.call(this);break;case 4:this.set(i,Math.max(this.get(i)-f,0));B.call(this);break;default:}};var A=function(f,b,h){var g=V(f);if(g===6){H.apply(this,arguments)}};var H=function(f,b,h){var g=b.value;if(h!==this.OPT.HEX){g=parseInt(g,10)}if(g!==this.get(h)){this.set(h,g)}};var K=function(b){return J(b,true)};var J=function(f,b){var g=V(f);switch(g){case 6:case 5:case 1:break;case 2:if(b!==true){break}default:d.stopEvent(f);return false}};P.getElement=function(b){return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[b]]};_createElements=function(){var h,g,l,j,k,b=this.get(this.OPT.IDS),m=this.get(this.OPT.TXT),o=this.get(this.OPT.IMAGES),n=function(i,p){var r=document.createElement(i);if(p){e.augmentObject(r,p,true)}return r},q=function(i,p){var r=e.merge({autocomplete:"off",value:"0",size:3,maxlength:3},p);r.name=r.id;return new n(i,r)};var f=this.get("element");h=new n("div",{id:b[this.ID.PICKER_BG],className:"yui-picker-bg",tabIndex:-1,hideFocus:true});g=new n("div",{id:b[this.ID.PICKER_THUMB],className:"yui-picker-thumb"});l=new n("img",{src:o.PICKER_THUMB});g.appendChild(l);h.appendChild(g);f.appendChild(h);h=new n("div",{id:b[this.ID.HUE_BG],className:"yui-picker-hue-bg",tabIndex:-1,hideFocus:true});g=new n("div",{id:b[this.ID.HUE_THUMB],className:"yui-picker-hue-thumb"});l=new n("img",{src:o.HUE_THUMB});g.appendChild(l);h.appendChild(g);f.appendChild(h);h=new n("div",{id:b[this.ID.CONTROLS],className:"yui-picker-controls"});f.appendChild(h);f=h;h=new n("div",{className:"hd"});g=new n("a",{id:b[this.ID.CONTROLS_LABEL],href:"#"});h.appendChild(g);f.appendChild(h);h=new n("div",{className:"bd"});f.appendChild(h);f=h;h=new n("ul",{id:b[this.ID.RGB_CONTROLS],className:"yui-picker-rgb-controls"});g=new n("li");g.appendChild(document.createTextNode(m.R+" "));j=new q("input",{id:b[this.ID.R],className:"yui-picker-r"});g.appendChild(j);h.appendChild(g);g=new n("li");g.appendChild(document.createTextNode(m.G+" "));j=new q("input",{id:b[this.ID.G],className:"yui-picker-g"});g.appendChild(j);h.appendChild(g);g=new n("li");g.appendChild(document.createTextNode(m.B+" "));j=new q("input",{id:b[this.ID.B],className:"yui-picker-b"});g.appendChild(j);h.appendChild(g);f.appendChild(h);h=new n("ul",{id:b[this.ID.HSV_CONTROLS],className:"yui-picker-hsv-controls"});g=new n("li");g.appendChild(document.createTextNode(m.H+" "));j=new q("input",{id:b[this.ID.H],className:"yui-picker-h"});g.appendChild(j);g.appendChild(document.createTextNode(" "+m.DEG));h.appendChild(g);g=new n("li");g.appendChild(document.createTextNode(m.S+" "));j=new q("input",{id:b[this.ID.S],className:"yui-picker-s"});g.appendChild(j);g.appendChild(document.createTextNode(" "+m.PERCENT));h.appendChild(g);g=new n("li");g.appendChild(document.createTextNode(m.V+" "));j=new q("input",{id:b[this.ID.V],className:"yui-picker-v"});g.appendChild(j);g.appendChild(document.createTextNode(" "+m.PERCENT));h.appendChild(g);f.appendChild(h);h=new n("ul",{id:b[this.ID.HEX_SUMMARY],className:"yui-picker-hex_summary"});g=new n("li",{id:b[this.ID.R_HEX]});h.appendChild(g);g=new n("li",{id:b[this.ID.G_HEX]});h.appendChild(g);g=new n("li",{id:b[this.ID.B_HEX]});h.appendChild(g);f.appendChild(h);h=new n("div",{id:b[this.ID.HEX_CONTROLS],className:"yui-picker-hex-controls"});h.appendChild(document.createTextNode(m.HEX+" "));g=new q("input",{id:b[this.ID.HEX],className:"yui-picker-hex",size:6,maxlength:6});h.appendChild(g);f.appendChild(h);f=this.get("element");h=new n("div",{id:b[this.ID.SWATCH],className:"yui-picker-swatch"});f.appendChild(h);h=new n("div",{id:b[this.ID.WEBSAFE_SWATCH],className:"yui-picker-websafe-swatch"});f.appendChild(h)};P.initPicker=function(){var k=this.OPT,j=this.get(k.IDS),f=this.get(k.ELEMENTS),b,h,l;for(b in this.ID){if(e.hasOwnProperty(this.ID,b)){j[this.ID[b]]=j[b]}}h=C.get(j[this.ID.PICKER_BG]);if(!h){_createElements.call(this)}else{}for(b in j){if(e.hasOwnProperty(j,b)){h=C.get(j[b]);l=C.generateId(h);j[b]=l;j[j[b]]=l;f[l]=h}}f=[k.SHOW_CONTROLS,k.SHOW_RGB_CONTROLS,k.SHOW_HSV_CONTROLS,k.SHOW_HEX_CONTROLS,k.SHOW_HEX_SUMMARY,k.SHOW_WEBSAFE];for(b=0;b<f.length;b=b+1){this.set(f[b],this.get(f[b]))}var g=this.get(k.PICKER_SIZE);this.hueSlider=O.getVertSlider(this.getElement(this.ID.HUE_BG),this.getElement(this.ID.HUE_THUMB),0,g);this.hueSlider.subscribe("change",X,this,true);this.pickerSlider=O.getSliderRegion(this.getElement(this.ID.PICKER_BG),this.getElement(this.ID.PICKER_THUMB),0,g,0,g);this.pickerSlider.subscribe("change",G,this,true);d.on(this.getElement(this.ID.WEBSAFE_SWATCH),"click",function(i){this.setValue(this.get(k.WEBSAFE))},this,true);d.on(this.getElement(this.ID.CONTROLS_LABEL),"click",function(i){this.set(k.SHOW_CONTROLS,!this.get(k.SHOW_CONTROLS));d.preventDefault(i)},this,true);_attachRGBHSV.call(this,this.ID.R,this.OPT.RED);_attachRGBHSV.call(this,this.ID.G,this.OPT.GREEN);_attachRGBHSV.call(this,this.ID.B,this.OPT.BLUE);_attachRGBHSV.call(this,this.ID.H,this.OPT.HUE);_attachRGBHSV.call(this,this.ID.S,this.OPT.SATURATION);_attachRGBHSV.call(this,this.ID.V,this.OPT.VALUE);d.on(this.getElement(this.ID.HEX),"keydown",function(m,i){A.call(i,m,this,i.OPT.HEX)},this);d.on(this.getElement(this.ID.HEX),"keypress",J,this);d.on(this.getElement(this.ID.HEX),"blur",function(m,i){H.call(i,m,this,i.OPT.HEX)},this)};_attachRGBHSV=function(f,b){d.on(this.getElement(f),"keydown",function(h,g){E.call(g,h,this,b)},this);d.on(this.getElement(f),"keypress",K,this);d.on(this.getElement(f),"blur",function(h,g){H.call(g,h,this,b)},this)};P.initAttributes=function(b){b=b||{};YAHOO.widget.ColorPicker.superclass.initAttributes.call(this,b);this.setAttributeConfig(this.OPT.PICKER_SIZE,{value:b.size||this.DEFAULT.PICKER_SIZE});this.setAttributeConfig(this.OPT.HUE,{value:b.hue||0,validator:e.isNumber});this.setAttributeConfig(this.OPT.SATURATION,{value:b.saturation||0,validator:e.isNumber});this.setAttributeConfig(this.OPT.VALUE,{value:b.value||100,validator:e.isNumber});this.setAttributeConfig(this.OPT.RED,{value:b.red||255,validator:e.isNumber});this.setAttributeConfig(this.OPT.GREEN,{value:b.red||255,validator:e.isNumber});this.setAttributeConfig(this.OPT.BLUE,{value:b.blue||255,validator:e.isNumber});this.setAttributeConfig(this.OPT.HEX,{value:b.hex||"FFFFFF",validator:e.isString});this.setAttributeConfig(this.OPT.RGB,{value:b.rgb||[255,255,255],method:function(h){this.set(this.OPT.RED,h[0],true);this.set(this.OPT.GREEN,h[1],true);this.set(this.OPT.BLUE,h[2],true);var j=c.websafe(h);this.set(this.OPT.WEBSAFE,j,true);var i=c.rgb2hex(h);this.set(this.OPT.HEX,i,true);var g=c.rgb2hsv(h);this.set(this.OPT.HUE,g[0],true);this.set(this.OPT.SATURATION,Math.round(g[1]*100),true);this.set(this.OPT.VALUE,Math.round(g[2]*100),true)},readonly:true});this.setAttributeConfig(this.OPT.CONTAINER,{value:null,method:function(g){if(g){g.showEvent.subscribe(function(){this.pickerSlider.focus()},this,true)}}});this.setAttributeConfig(this.OPT.WEBSAFE,{value:b.websafe||[255,255,255]});ids=b.ids||e.merge({},this.ID);if(!b.ids&&F>1){for(var f in ids){if(e.hasOwnProperty(ids,f)){ids[f]=ids[f]+F}}}this.setAttributeConfig(this.OPT.IDS,{value:ids,writeonce:true});this.setAttributeConfig(this.OPT.TXT,{value:b.txt||this.TXT,writeonce:true});this.setAttributeConfig(this.OPT.IMAGES,{value:b.images||this.IMAGE,writeonce:true});this.setAttributeConfig(this.OPT.ELEMENTS,{value:{},readonly:true});_hideShowEl=function(i,g){var h=(e.isString(i)?this.getElement(i):i);C.setStyle(h,"display",(g)?"":"none")};this.setAttributeConfig(this.OPT.SHOW_CONTROLS,{value:(b.showcontrols)||true,method:function(g){var h=C.getElementsByClassName("bd","div",this.getElement(this.ID.CONTROLS))[0];_hideShowEl.call(this,h,g);this.getElement(this.ID.CONTROLS_LABEL).innerHTML=(g)?this.get(this.OPT.TXT).HIDE_CONTROLS:this.get(this.OPT.TXT).SHOW_CONTROLS}});this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS,{value:(b.showrgbcontrols)||true,method:function(g){_hideShowEl.call(this,this.ID.RGB_CONTROLS,g)}});this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS,{value:(b.showhsvcontrols)||false,method:function(g){_hideShowEl.call(this,this.ID.HSV_CONTROLS,g);if(g&&this.get(this.OPT.SHOW_HEX_SUMMARY)){this.set(this.OPT.SHOW_HEX_SUMMARY,false)}}});this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS,{value:(b.showhexcontrols)||false,method:function(g){_hideShowEl.call(this,this.ID.HEX_CONTROLS,g)}});this.setAttributeConfig(this.OPT.SHOW_WEBSAFE,{value:(b.showwebsafe)||true,method:function(g){_hideShowEl.call(this,this.ID.WEBSAFE_SWATCH,g)}});this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY,{value:(b.showhexsummary)||true,method:function(g){_hideShowEl.call(this,this.ID.HEX_SUMMARY,g);if(g&&this.get(this.OPT.SHOW_HSV_CONTROLS)){this.set(this.OPT.SHOW_HSV_CONTROLS,false)}}});this.setAttributeConfig(this.OPT.ANIMATE,{value:(b.animate)||true,method:function(g){this.pickerSlider.animate=g;this.hueSlider.animate=g}});this.on(this.OPT.HUE+"Change",T,this,true);this.on(this.OPT.SATURATION+"Change",T,this,true);this.on(this.OPT.VALUE+"Change",a,this,true);this.on(this.OPT.RED+"Change",D,this,true);this.on(this.OPT.GREEN+"Change",D,this,true);this.on(this.OPT.BLUE+"Change",D,this,true);this.on(this.OPT.HEX+"Change",U,this,true);this.initPicker()};var D=function(){var b=[this.get(this.OPT.RED),this.get(this.OPT.GREEN),this.get(this.OPT.BLUE)];this.set(this.OPT.RGB,b);S.call(this)};var T=function(){var f=[this.get(this.OPT.HUE),this.get(this.OPT.SATURATION)/100,this.get(this.OPT.VALUE)/100];var b=c.hsv2rgb(f);this.set(this.OPT.RGB,b);S.call(this)};var U=function(){var h=this.get(this.OPT.HEX),b=h.length;if(b===3){var j=h.split(""),g;for(g=0;g<b;g=g+1){j[g]=j[g]+j[g]}h=j.join("")}if(h.length!==6){return false}var f=c.hex2rgb(h);this.setValue(f)};var S=function(){R.call(this);a.call(this)};var R=function(){var b=this.get(this.OPT.PICKER_SIZE),f=this.get(this.OPT.HUE);f=b-Math.round(f/360*b);if(f===b){f=0}this.hueSlider.setValue(f)};var a=function(){var f=this.get(this.OPT.PICKER_SIZE),g=this.get(this.OPT.SATURATION),b=this.get(this.OPT.VALUE);g=Math.round(g*f/100);b=Math.round(f-(b*f/100));this.pickerSlider.setRegionValue(g,b)};var Q=function(){var b=document.createElement("div");if(this.CSS.BASE){b.className=this.CSS.BASE}return b}})();YAHOO.register("colorpicker",YAHOO.widget.ColorPicker,{version:"2.3.0",build:"442"});