function cSphere(a,b){return((typeof(b)=="object"?b:document).getElementById(a))}function cSphereStyle(a){a=cSphere(a);if(a){return(a.style)}}function abPos(b){var b=(typeof(b)=="object"?b:cSphere(b)),a={X:0,Y:0};while(b!=null){a.X+=b.offsetLeft;a.Y+=b.offsetTop;b=b.offsetParent}return(a)}function agent(a){return(Math.max(navigator.userAgent.toLowerCase().indexOf(a),0))}function isset(a){return((typeof(a)=="undefined"||a.length==0)?false:true)}function toggle(d,b,e){var a=cSphereStyle(d);a.display=b?b:(a.display=="none"?"block":"none");if(e){a.left=e[0];a.top=e[1]}}function XY(b,a){var d=agent("msie")?{X:b.clientX+document.body.scrollLeft,Y:b.clientY+document.body.scrollTop}:{X:b.pageX,Y:b.pageY};return(a?d[a]:d)}function zero(a){return(!isNaN(a=parseFloat(a))?a:0)}function zindex(a){a.style.zIndex=zINDEX++}Picker={};Picker.stop=1;Picker.R="FF";Picker.G="FF";Picker.B="FF";Picker.C="1";Picker.M="1";Picker.Y="1";Picker.K="1";Picker.core=function(a,j,t,p,f){function q(o,d,u){r=XY(u);g([r.X+o,r.Y+d])}function n(e,d,o){return(Math.max(!isNaN(o)?o:0,!isNaN(d)?Math.min(d,e):e))}function g(D){if(f){f(D)}if(a=="mCur"){var d=parseInt(cSphereStyle("mSpec").width),w=d/2,u=w/2;var C=D[0]-w;var B=d-D[1]-w;var e=Math.sqrt(Math.pow(C,2)+Math.pow(B,2));var o=Math.atan2(C,B)/(Math.PI*2);hsv={H:o>0?(o*360):((o*360)+360),S:e<u?(e/u)*100:100,V:e>=u?Math.max(0,1-((e-u)/(w-u)))*100:100};hex=color.HSV_HEX(hsv);cSphere("hex-val-field").value=hex;var z=HexToCMYK(hex);cSphere("c-val-field").value=percentile(z[0]);Picker.C=percentile(z[0]);cSphere("m-val-field").value=percentile(z[1]);Picker.M=percentile(z[1]);cSphere("y-val-field").value=percentile(z[2]);Picker.Y=percentile(z[2]);cSphere("k-val-field").value=percentile(z[3]);Picker.K=percentile(z[3]);cSphereStyle("exampleColor").background="#"+hex;color.cords(d)}else{if(a=="mSize"){var A=Math.max(Math.max(D[0],D[1])+b,75);color.cords(A);cSphereStyle("mini").height=(A)+"px";cSphereStyle("mini").width=(A)+"px";cSphereStyle("mSpec").height=A+"px";cSphereStyle("mSpec").width=A+"px"}else{}}}if(Picker.stop){Picker.stop="";var l=cSphereStyle(a),r=XY(j);if(!p){zindex(cSphere(a))}if(a=="mCur"){var s=abPos(cSphere(a).parentNode);q(-(s.X),-(s.Y),j)}if(a=="mSize"){var b=parseInt(cSphereStyle("mSpec").height),i=-XY(j).X,h=-XY(j).Y}else{var i=zero(l.left)-r.X,h=zero(l.top)-r.Y}$("#usecolor-field").attr("checked",true);document.onmousemove=function(d){if(!Picker.stop){q(i,h,d)}};document.onmouseup=function(){Picker.stop=1;document.onmousemove="";document.onmouseup=""}}};Picker.hsv={H:0,S:0,V:100};zINDEX=2;color={};color.cords=function(b){var d=b/2,a=(hsv.H/360)*(Math.PI*2),e=(hsv.S+(100-hsv.V))/100*(d/2);cSphereStyle("mCur").left=Math.round(Math.abs(Math.round(Math.sin(a)*e)+d)-3)+"px";cSphereStyle("mCur").top=Math.round(Math.abs(Math.round(Math.cos(a)*e)-d)-3)+"px"};color.HEX=function(a){a=Math.round(Math.min(Math.max(0,a),255));return("0123456789ABCDEF".charAt((a-a%16)/16)+"0123456789ABCDEF".charAt(a%16))};color.RGB_HEX=function(b){var a=color.HEX;return(a(b.R)+a(b.G)+a(b.B))};color.HSV_RGB=function(d){var h,j,e,b,a,g=d.S/100,f=d.V/100,i=d.H/360;if(g>0){if(i>=1){i=0}i=6*i;F=i-Math.floor(i);e=Math.round(255*f*(1-g));b=Math.round(255*f*(1-(g*F)));a=Math.round(255*f*(1-(g*(1-F))));f=Math.round(255*f);switch(Math.floor(i)){case 0:h=f;j=a;b=e;break;case 1:h=b;j=f;b=e;break;case 2:h=e;j=f;b=a;break;case 3:h=e;j=b;b=f;break;case 4:h=a;j=e;b=f;break;case 5:h=f;j=e;b=b;break}return({R:h?h:0,G:j?j:0,B:b?b:0,A:1})}else{return({R:(f=Math.round(f*255)),G:f,B:f,A:1})}};color.HSV_HEX=function(a){return(color.RGB_HEX(color.HSV_RGB(a)))};$(document).ready(function(){var b=new RegExp("#{0,1}[0-9A-Fa-f]{0,6}");var a=new RegExp("[#0-9A-Fa-f]");$("#hex-val-field").keypress(function(g){var f=g.charCode;var d=String.fromCharCode(f);if(d.match(a)==null&&f!=0){return false}});$("#hex-val-field").keyup(function(l){$("#usecolor-field").attr("checked",true);var h=l.charCode;var g=String.fromCharCode(h);var f=$("#hex-val-field").val();if(f.match(b)==null){$("#hex-val-field").val("#FFFFFF");$("c-val-field").val(0);$("m-val-field").val(0);$("y-val-field").val(0);$("k-val-field").val(0);$("#mCur").css({left:"48px",top:"48px"});return false}f=f.replace("#","");if(f.length==6){$("#exampleColor").css({backgroundColor:"#"+f});var n=HexToCMYK(f);$("#c-val-field").val(percentile(n[0]));$("#m-val-field").val(percentile(n[1]));$("#y-val-field").val(percentile(n[2]));$("#k-val-field").val(percentile(n[3]));var d=fromHEX({R:f.substr(0,2),G:f.substr(2,2),B:f.substr(4,2)});decR=d[0];decG=d[1];decB=d[2];var j={};j.r=decR;j.g=decG;j.b=decB;var i={h:"",s:"",v:""};newHSV=RGB2HSV(j,{h:"",s:"",v:""});rePosCursor("mSpec",{h:newHSV[0],s:newHSV[1],v:newHSV[2]})}});$("#c-val-field,#m-val-field,#y-val-field,#k-val-field").keypress(function(h){var g=new RegExp("[0-9]{0,3}");var f=h.charCode;var d=String.fromCharCode(f);if(d.match(g)==null&&f!=0){return false}});$("#c-val-field,#m-val-field,#y-val-field,#k-val-field").keyup(function(){$("#usecolor-field").attr("checked",true);var e=parseInt($(this).val());if(e>100){return false}c=$("#c-val-field").val();m=$("#m-val-field").val();y=$("#y-val-field").val();k=$("#k-val-field").val();aRGB=CMYK_To_HEX(c,m,y,k);$("#hex-val-field").val("#"+aRGB[0]+aRGB[1]+aRGB[2]);$("#exampleColor").css({backgroundColor:"#"+aRGB[0]+aRGB[1]+aRGB[2]});var d=fromHEX({R:aRGB[0],G:aRGB[1],B:aRGB[2]});decR=d[0];decG=d[1];decB=d[2];var g={};g.r=decR;g.g=decG;g.b=decB;var f={h:"",s:"",v:""};newHSV=RGB2HSV(g,{h:"",s:"",v:""});rePosCursor("mSpec",{h:newHSV[0],s:newHSV[1],v:newHSV[2]})})});function rePosCursor(d,h){var i=parseInt($("#"+d).width());var g=i/2,f=(h.h/360)*(Math.PI*2),b=(h.s+(100-h.v))/100*(g/2);var e=Math.round(Math.abs(Math.round(Math.sin(f)*b)+g)-3)+"px";var a=Math.round(Math.abs(Math.round(Math.cos(f)*b)-g)-3)+"px";$("#mCur").css({left:e,top:a})}function percentile(a){return Math.round(a*100)};
