_input=null;hue=60;adeg=60;sat=1;val=1;squarecolor="#ffff00";pickindex=0;threec=new Array("#666666","#555555","#545657");prevc=threec[2];initary=new Array("#444444","#777777","#aaaaaa","#bbbbbb","#cccccc","#dddddd","#eeeeee");function aff_couleur(a){the_left=ds_getleft(a)+2;document.getElementById("wheel").style.left=the_left+"px";the_top=ds_gettop(a)+25;document.getElementById("wheel").style.top=the_top+"px";document.getElementById("wheel").style.display="block";_input=a}function BrowserDetectXLite(){var a=navigator.userAgent.toLowerCase();this.ua=a;this.isIE=((a.indexOf("msie")!=-1)&&(a.indexOf("opera")==-1)&&(a.indexOf("webtv")==-1));this.isSafari=(a.indexOf("safari")!=-1);this.versionMinor=parseFloat(navigator.appVersion);if(this.isIE&&this.versionMinor>=4){this.versionMinor=parseFloat(a.substring(a.indexOf("msie ")+5))}this.versionMajor=parseInt(this.versionMinor);this.isWin=(a.indexOf("win")!=-1);this.isWin32=(this.isWin&&(a.indexOf("95")!=-1||a.indexOf("98")!=-1||a.indexOf("nt")!=-1||a.indexOf("win32")!=-1||a.indexOf("32bit")!=-1));this.isMac=(a.indexOf("mac")!=-1);this.isIE4x=(this.isIE&&this.versionMajor==4);this.isIE4up=(this.isIE&&this.versionMajor>=4);this.isIE5x=(this.isIE&&this.versionMajor==5);this.isIE55=(this.isIE&&this.versionMinor==5.5);this.isIE5up=(this.isIE&&this.versionMajor>=5);this.isIE6x=(this.isIE&&this.versionMajor==6);this.isIE6up=(this.isIE&&this.versionMajor>=6);this.isIE4xMac=(this.isIE4x&&this.isMac)}var browser=new BrowserDetectXLite();function deMoronize(){if(!((browser.isIE55||browser.isIE6up)&&browser.isWin32)){thesmartversion="<a href='javascript://' onclick='javascript:pickColor(); return false;'><img src='images/hsvwheel.png' alt='color wheel' width='255' height='257' border='0'></a>";document.getElementById("wheel").innerHTML=thesmartversion}if(browser.isSafari){document.onkeypress=rotate}else{document.onkeydown=rotate}capture()}function hsv2rgb(d,b,a){H=d/360;if(b==0){R=a*255;G=a*255;B=a*255}else{var_h=H*6;var_i=Math.floor(var_h);var_1=a*(1-b);var_2=a*(1-b*(var_h-var_i));var_3=a*(1-b*(1-(var_h-var_i)));if(var_i==0){var_r=a;var_g=var_3;var_b=var_1}else{if(var_i==1){var_r=var_2;var_g=a;var_b=var_1}else{if(var_i==2){var_r=var_1;var_g=a;var_b=var_3}else{if(var_i==3){var_r=var_1;var_g=var_2;var_b=a}else{if(var_i==4){var_r=var_3;var_g=var_1;var_b=a}else{var_r=a;var_g=var_1;var_b=var_2}}}}}R=Math.round(var_r*255);G=Math.round(var_g*255);B=Math.round(var_b*255)}return new Array(R,G,B)}function rgb2hex(a){cary=new Array;cary[3]="#";for(i=0;i<3;i++){cary[i]=parseInt(a[i]).toString(16);if(cary[i].length<2){cary[i]="0"+cary[i]}cary[3]=cary[3]+cary[i];cary[i+4]=a[i]}return cary}function webRounder(b,a){thec="";for(i=0;i<3;i++){num=Math.round(b[i+4]/a)*a;numc=num.toString(16);if(String(numc).length<2){numc="0"+numc}thec+=numc}return thec}function hexColorArray(a){threec[2]=a[3];threec[1]=webRounder(a,17);threec[0]=webRounder(a,51);return false}function capture(){initColor();if(document.layers){layobj=document.layers.wheel;layobj.document.captureEvents(Event.MOUSEMOVE);layobj.document.onmousemove=mouseMoved}else{if(document.all){layobj=document.all.wheel;layobj.onmousemove=mouseMoved}else{if(document.getElementById){window.document.getElementById("wheel").onmousemove=mouseMoved}}}}function greyMoved(a,b){adeg=hue;xside=(a<=553)?a-296:256;yside=(b<=256)?b:256;sat=xside/256;val=1-(yside/256);c=rgb2hex(hsv2rgb(hue,sat,val));hexColorArray(c);return false}function mouseMoved(a){if(document.layers){x=a.layerX;y=a.layerY}else{if(document.all){x=event.offsetX;y=event.offsetY}else{if(document.getElementById){x=(a.pageX-document.getElementById("wheel").offsetLeft);y=(a.pageY-document.getElementById("wheel").offsetTop)}}}if(x>=296){greyMoved(x,y);return false}if(y>256){return false}cartx=x-128;carty=128-y;cartx2=cartx*cartx;carty2=carty*carty;cartxs=(cartx<0)?-1:1;cartys=(carty<0)?-1:1;cartxn=cartx/128;rraw=Math.sqrt(cartx2+carty2);rnorm=rraw/128;if(rraw==0){sat=0;val=0;rgb=new Array(0,0,0)}else{arad=Math.acos(cartx/rraw);aradc=(carty>=0)?arad:2*Math.PI-arad;adeg=360*aradc/(2*Math.PI);if(rnorm>1){rgb=new Array(255,255,255);sat=1;val=1}else{if(rnorm>=0.5){sat=1-((rnorm-0.5)*2);val=1;rgb=hsv2rgb(adeg,sat,val)}else{sat=1;val=rnorm*2;rgb=hsv2rgb(adeg,sat,val)}}}c=rgb2hex(rgb);hexColorArray(c);return false}function setSquare(a){hue=a;adeg=a;c=rgb2hex(hsv2rgb(hue,1,1));squarecolor=c[3];if(document.layers){document.layers.wheel.bgColor=squarecolor}else{if(document.all){document.all.wheel.style.backgroundColor=squarecolor}else{if(document.getElementById){document.getElementById("wheel").style.backgroundColor=squarecolor}}}}function initColor(){for(i=0;i<7;i++){thecontents="<tt class='wtxt'>"+initary[i]+"</tt><br><tt class='btxt'>"+initary[i]+"</tt>"}}function theToggle(e,a){var d=document.getElementsByTagName("div");for(var b=0;b<d.length;b++){if(d.item(b).id==e){d.item(b).style.display=a}}}function rotate(b){if(!b){b=window.event}var a=(typeof b.which=="number")?b.which:b.keyCode;handleKP(a)}function handleKP(a){switch(a){case 13:reHue(hue);pickColor();break;case 112:reHue(hue);pickColor();break;case 114:reHue(0);break;case 121:reHue(60);break;case 103:reHue(120);break;case 99:reHue(180);break;case 98:reHue(240);break;case 109:reHue(300);break;case 106:reHue(hue+1);break;case 104:reHue(hue+1);break;case 107:reHue(hue+355);break;case 116:reHue(hue+355);break;case 108:reHue(hue+359);break;case 110:reHue(hue+359);break;case 80:reHue(hue);pickColor();break;case 82:reHue(0);break;case 89:reHue(60);break;case 71:reHue(120);break;case 67:reHue(180);break;case 66:reHue(240);break;case 77:reHue(300);break;case 74:reHue(hue+1);break;case 72:reHue(hue+1);break;case 75:reHue(hue+355);break;case 84:reHue(hue+355);break;case 76:reHue(hue+359);break;case 78:reHue(hue+359);break}return false}function reHue(a){a=a%360;setSquare(a);rgb=hsv2rgb(a,sat,val);c=rgb2hex(rgb);hexColorArray(c);hoverColor();return false}function pickColor(){if(threec[2]==prevc){return false}prevc=threec[2];thecontents=threec[1];_input.value=thecontents;document.getElementById("wheel").style.display="none"};
