 var CROSSHAIRS_LOCATION="http://st.facilisimo.com/images/color/crosshairs.png";var HUE_SLIDER_LOCATION="http://st.facilisimo.com/images/color/h.png";var HUE_SLIDER_ARROWS_LOCATION="http://st.facilisimo.com/images/color/position.png";var SAT_VAL_SQUARE_LOCATION="http://st.facilisimo.com/images/color/sv.png";function hexToRgb(_1,_2){if(_2==undefined){_2=null;} if(_1.substr(0,1)=="#"){_1=_1.substr(1);} var r;var g;var b;if(_1.length==3){r=_1.substr(0,1);r+=r;g=_1.substr(1,1);g+=g;b=_1.substr(2,1);b+=b;}else{if(_1.length==6){r=_1.substr(0,2);g=_1.substr(2,2);b=_1.substr(4,2);}else{return _2;}} r=parseInt(r,16);g=parseInt(g,16);b=parseInt(b,16);if(isNaN(r)||isNaN(g)||isNaN(b)){return _2;}else{return{r:r/255,g:g/255,b:b/255};}} function rgbToHex(r,g,b,_9){r=Math.round(r*255);g=Math.round(g*255);b=Math.round(b*255);if(_9==undefined){_9=true;} r=r.toString(16);if(r.length==1){r="0"+r;} g=g.toString(16);if(g.length==1){g="0"+g;} b=b.toString(16);if(b.length==1){b="0"+b;} return((_9?"#":"")+r+g+b).toUpperCase();} var arVersion=navigator.appVersion.split("MSIE");var version=parseFloat(arVersion[1]);function fixPNG(_a){if((version>=5.5)&&(version<7)&&(document.body.filters)){var _b=document.createElement("span");_b.id=_a.id;_b.className=_a.className;_b.title=_a.title;_b.style.cssText=_a.style.cssText;_b.style.setAttribute("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src='"+_a.src+"', sizingMethod='scale')");_b.style.fontSize="0";_b.style.width=_a.width.toString()+"px";_b.style.height=_a.height.toString()+"px";return _b;}else{return _a.cloneNode(false);}} function trackDrag(_c,_d){function fixCoords(x,y){var _10=pageCoords(_c);x=(x-_10.x)+document.documentElement.scrollLeft;y=(y-_10.y)+document.documentElement.scrollTop;if(x<0){x=0;} if(y<0){y=0;} if(x>_c.offsetWidth-1){x=_c.offsetWidth-1;} if(y>_c.offsetHeight-1){y=_c.offsetHeight-1;} return{x:x,y:y};} function mouseDown(ev){var _12=fixCoords(ev.clientX,ev.clientY);var _13=_12.x;var _14=_12.y;_d(_12.x,_12.y);function moveHandler(ev){var _16=fixCoords(ev.clientX,ev.clientY);if(_16.x!=_13||_16.y!=_14){_13=_16.x;_14=_16.y;_d(_16.x,_16.y);}} function upHandler(ev){myRemoveEventListener(document,"mouseup",upHandler);myRemoveEventListener(document,"mousemove",moveHandler);myAddEventListener(_c,"mousedown",mouseDown);} myAddEventListener(document,"mouseup",upHandler);myAddEventListener(document,"mousemove",moveHandler);myRemoveEventListener(_c,"mousedown",mouseDown);if(ev.preventDefault){ev.preventDefault();}} myAddEventListener(_c,"mousedown",mouseDown);_c.onmousedown=function(e){return false;};_c.onselectstart=function(e){return false;};_c.ondragstart=function(e){return false;};} var eventListeners=[];function findEventListener(_1b,_1c,_1d){var i;for(i in eventListeners){if(eventListeners[i].node==_1b&&eventListeners[i].event==_1c&&eventListeners[i].handler==_1d){return i;}} return null;} function myAddEventListener(_1f,_20,_21){if(findEventListener(_1f,_20,_21)!=null){return;} if(!_1f.addEventListener){_1f.attachEvent("on"+_20,_21);}else{_1f.addEventListener(_20,_21,false);} eventListeners.push({node:_1f,event:_20,handler:_21});} function removeEventListenerIndex(_22){var _23=eventListeners[_22];delete eventListeners[_22];if(!_23.node.removeEventListener){_23.node.detachEvent("on"+_23.event,_23.handler);}else{_23.node.removeEventListener(_23.event,_23.handler,false);}} function myRemoveEventListener(_24,_25,_26){removeEventListenerIndex(findEventListener(_24,_25,_26));} function cleanupEventListeners(){var i;for(i=eventListeners.length;i>0;i--){if(eventListeners[i]!=undefined){removeEventListenerIndex(i);}}} myAddEventListener(window,"unload",cleanupEventListeners);function hsvToRgb(hue,_29,_2a){var red;var _2c;var _2d;if(_2a==0){red=0;_2c=0;_2d=0;}else{var i=Math.floor(hue*6);var f=(hue*6)-i;var p=_2a*(1-_29);var q=_2a*(1-(_29*f));var t=_2a*(1-(_29*(1-f)));switch(i){case 1:red=q;_2c=_2a;_2d=p;break;case 2:red=p;_2c=_2a;_2d=t;break;case 3:red=p;_2c=q;_2d=_2a;break;case 4:red=t;_2c=p;_2d=_2a;break;case 5:red=_2a;_2c=p;_2d=q;break;case 6:case 0:red=_2a;_2c=t;_2d=p;break;}} return{r:red,g:_2c,b:_2d};} function rgbToHsv(red,_34,_35){var max=Math.max(Math.max(red,_34),_35);var min=Math.min(Math.min(red,_34),_35);var hue;var _39;var _3a=max;if(min==max){hue=0;_39=0;}else{var _3b=(max-min);_39=_3b/max;if(red==max){hue=(_34-_35)/_3b;}else{if(_34==max){hue=2+((_35-red)/_3b);}else{hue=4+((red-_34)/_3b);}} hue/=6;if(hue<0){hue+=1;} if(hue>1){hue-=1;}} return{h:hue,s:_39,v:_3a};} function pageCoords(_3c){var x=_3c.offsetLeft;var y=_3c.offsetTop;var _3f=_3c.offsetParent;while(_3f!=null){x+=_3f.offsetLeft;y+=_3f.offsetTop;_3f=_3f.offsetParent;} return{x:x,y:y};} var huePositionImg=document.createElement("img");huePositionImg.galleryImg=false;huePositionImg.width=35;huePositionImg.height=11;huePositionImg.style.left="0px";huePositionImg.src=HUE_SLIDER_ARROWS_LOCATION;huePositionImg.style.position="absolute";var hueSelectorImg=document.createElement("img");hueSelectorImg.galleryImg=false;hueSelectorImg.width=35;hueSelectorImg.height=200;hueSelectorImg.src=HUE_SLIDER_LOCATION;hueSelectorImg.style.display="block";var satValImg=document.createElement("img");satValImg.galleryImg=false;satValImg.width=200;satValImg.height=200;satValImg.src=SAT_VAL_SQUARE_LOCATION;satValImg.style.display="block";var crossHairsImg=document.createElement("img");crossHairsImg.galleryImg=false;crossHairsImg.width=21;crossHairsImg.height=21;crossHairsImg.src=CROSSHAIRS_LOCATION;crossHairsImg.style.position="absolute";function makeColorSelector(_40){var rgb,hsv;function colorChanged(){var hex=rgbToHex(rgb.r,rgb.g,rgb.b);var _44=hsvToRgb(hsv.h,1,1);var _45=rgbToHex(_44.r,_44.g,_44.b);_46.style.background=hex;_40.value=hex;_47.style.background=_45;_48.style.left=((hsv.v*199)-10).toString()+"px";_48.style.top=(((1-hsv.s)*199)-10).toString()+"px";_49.style.top=((hsv.h*199)-5).toString()+"px";} function rgbChanged(){hsv=rgbToHsv(rgb.r,rgb.g,rgb.b);colorChanged();} function hsvChanged(){rgb=hsvToRgb(hsv.h,hsv.s,hsv.v);colorChanged();} var _4a=document.createElement("div");_4a.style.padding="15px";_4a.style.marginRight="55px";_4a.style.position="relative";_4a.style.height="200px";_4a.style.width="200px";var _47=document.createElement("div");_47.style.position="relative";_47.style.width="200px";_47.style.height="200px";var _4b=fixPNG(satValImg);_47.appendChild(_4b);var _48=crossHairsImg.cloneNode(false);_47.appendChild(_48);function satValDragged(x,y){hsv.s=1-(y/199);hsv.v=(x/199);hsvChanged();} trackDrag(_47,satValDragged);_4a.appendChild(_47);var _4e=document.createElement("div");_4e.style.position="absolute";_4e.style.left="230px";_4e.style.top="15px";_4e.style.width="35px";_4e.style.height="200px";var _49=fixPNG(huePositionImg);_4e.appendChild(hueSelectorImg.cloneNode(false));_4e.appendChild(_49);function hueDragged(x,y){hsv.h=y/199;hsvChanged();} trackDrag(_4e,hueDragged);_4a.appendChild(_4e);var _46=document.getElementById("color_base");function inputBoxChanged(){rgb=hexToRgb(_40.value,{r:0,g:0,b:0});rgbChanged();} myAddEventListener(_40,"change",inputBoxChanged);_40.size=8;_40.style.position="absolute";_40.style.right="15px";_40.style.top=(225+(25-(_40.offsetHeight/2))).toString()+"px";_4a.appendChild(_40);inputBoxChanged();return _4a;} function makeColorSelectors(ev){var _52=document.getElementsByTagName("input");var i;for(i=0;i<_52.length;i++){var _54=_52[i];if(_54.className!="color"){continue;} var _55=_54.parentNode;var _56=_54.previousSibling;var _57=makeColorSelector(_54);_55.insertBefore(_57,(_56?_56.nextSibling:null));}}

