(function($,version)
{var Slider=function(bar,options)
{var $this=this,arrow=$('img',bar),barMouseDown=function(e)
{setValuesFromMousePosition(e);$(document).bind('mousemove',docMouseMove).bind('mouseup',docMouseUp);e.stopPropagation();e.preventDefault();return false;},docMouseMove=function(e)
{setValuesFromMousePosition(e);e.stopPropagation();e.preventDefault();return false;},docMouseUp=function(e)
{$(document).unbind('mouseup',docMouseUp).unbind('mousemove',docMouseMove);e.stopPropagation();e.preventDefault();return false;},setValuesFromMousePosition=function(e)
{var offset=bar.offset(),x=e.pageX-offset.left-parseInt(bar.css('border-left-width')),y=e.pageY-offset.top-parseInt(bar.css('border-top-width')),barW=bar.w,barH=bar.h,newX,newY;if(x<0)x=0;else if(x>barW)x=barW;if(y<0)y=0;else if(y>barH)y=barH;newX=Math.floor(x/barW*$this.mxX);newY=Math.floor(y/barH*$this.mxY);$this.x=newX;$this.y=newY;if($this.mxX==$this.mnX)x=0;if($this.mxY==$this.mnY)y=0;$this.setArrowPosition(x,y);$.isFunction($this.valuesChanged)&&$this.valuesChanged($this);};$.extend(true,$this,{settings:options,x:0,y:0,mnX:0,mxX:0,mnY:100,mxY:100,valuesChanged:$.isFunction(arguments[2])&&arguments[2]||null,setPositioningVariables:function(e)
{var map=$this.settings.map;bar.w=map&&map.width||bar.width();bar.h=map&&map.height||bar.height();$this.MinX=0;$this.MinY=0;$this.MaxX=bar.w;$this.MaxY=bar.h;},setArrowPositionFromValues:function(e)
{$this.setPositioningVariables();var arrowOffsetX=0,arrowOffsetY=0,mnX=$this.mnX,mxX=$this.mxX,mnY=$this.mnY,mxY=$this.mxY,x=$this.x,y=$this.y;if(mnX!=mxX)
{if(x==mnX)arrowOffsetX=0;else if(x==mxX)arrowOffsetX=bar.w;else
{if(mnX<1)mxX+=Math.abs(mnX)+1;if(x<1)x+=1;arrowOffsetX=x/mxX*bar.w;if(parseInt(arrowOffsetX)==(mxX-1))arrowOffsetX=mxX;else arrowOffsetX=parseInt(arrowOffsetX);if(mnX<1)arrowOffsetX-=Math.abs(mnX)-1;}}
if(mnY!=mxY)
{if(y==mnY)arrowOffsetY=0;else if(y==mxY)arrowOffsetY=bar.h;else
{if(mnY<1)mxY+=Math.abs(mnY)+1;if(y<1)y+=1;arrowOffsetY=y/mxY*bar.h;if(parseInt(arrowOffsetY)==(mxY-1))arrowOffsetY=mxY;else arrowOffsetY=parseInt(arrowOffsetY);if(mnY<1)arrowOffsetY-=Math.abs(mnY)-1;}}
$this.setArrowPosition(arrowOffsetX,arrowOffsetY);},setArrowPosition:function(offsetX,offsetY)
{var barW=bar.w,barH=bar.h,arrowW=arrow.w,arrowH=arrow.h;if(offsetX<0)offsetX=0;else if(offsetX>barW)offsetX=barW;if(offsetY<0)offsetY=0;else if(offsetY>barH)offsetY=barH;if(arrowW>barW)offsetX=(barW>>1)-(arrowW>>1);else offsetX-=arrowW>>1;if(arrowH>barH)offsetY=(barH>>1)-(arrowH>>1);else offsetY-=arrowH>>1;arrow.css({left:offsetX+'px',top:offsetY+'px'});},destroy:function()
{$(document).unbind('mouseup',docMouseUp).unbind('mousemove',docMouseMove);bar.unbind('mousedown',barMouseDown);bar=null;arrow=null;$this.valuesChanged=null;}});arrow.src=$this.settings.arrow&&$this.settings.arrow.image;arrow.w=$this.settings.arrow&&$this.settings.arrow.width||arrow.width();arrow.h=$this.settings.arrow&&$this.settings.arrow.height||arrow.height();$this.setPositioningVariables();bar.bind('mousedown',barMouseDown);$this.setArrowPositionFromValues();$.isFunction($this.valuesChanged)&&$this.valuesChanged($this);},ColorValuePicker=function(picker)
{var $this=this,hsvKeyUp=function(e)
{if(e.target.value=='')return;validateHsv(e);$this.setValuesFromHsv();$.isFunction($this.valuesChanged)&&$this.valuesChanged($this);},rgbKeyUp=function(e)
{if(e.target.value=='')return;validateRgb(e);$this.setValuesFromRgb();$.isFunction($this.valuesChanged)&&$this.valuesChanged($this);},alphaKeyUp=function(e)
{if(e.target.value=='')return;validateAlpha(e);color.a=e.target.value;$.isFunction($this.valuesChanged)&&$this.valuesChanged($this);},hsvBlur=function(e)
{if(e.target.value=='')$this.setValuesFromRgb();},rgbBlur=function(e)
{if(e.target.value=='')$this.setValuesFromHsv();},alphaBlur=function(e)
{if(e.target.value=='')fields.alpha.val(100);},hexKeyUp=function(e)
{if(e.target.value=='')return;validateHex(e);$this.setValuesFromHex();$.isFunction($this.valuesChanged)&&$this.valuesChanged($this);},hexBlur=function(e)
{if(e.target.value=='')$this.setValuesFromHsv();},validateRgb=function(e)
{if(!validateKey(e))return e;fields.red.val(setValueInRange(fields.red.val(),0,255));fields.green.val(setValueInRange(fields.green.val(),0,255));fields.blue.val(setValueInRange(fields.blue.val(),0,255));},validateAlpha=function(e)
{if(!validateKey(e))return e;fields.alpha.val(setValueInRange(fields.alpha.val(),0,100));},validateHsv=function(e)
{if(!validateKey(e))return e;fields.hue.val(setValueInRange(fields.hue.val(),0,360));fields.saturation.val(setValueInRange(fields.saturation.val(),0,100));fields.value.val(setValueInRange(fields.value.val(),0,100));},validateHex=function(e)
{if(!validateKey(e))return e;fields.hex.val(fields.hex.val().replace(/[^a-fA-F0-9]/g,'0').toLowerCase().substring(0,6));},validateKey=function(e)
{switch(e.keyCode)
{case 9:case 16:case 29:case 37:case 38:case 40:return false;case'c'.charCodeAt():case'v'.charCodeAt():if(e.ctrlKey)return false;}
return true;},setValueInRange=function(value,min,max)
{if(value==''||isNaN(value))return min;value=parseInt(value);if(value>max)return max;if(value<min)return min;return value;};$.extend(true,$this,{color:new Color(),fields:{hue:$('.jPicker_HueText',picker),saturation:$('.jPicker_SaturationText',picker),value:$('.jPicker_BrightnessText',picker),red:$('.jPicker_RedText',picker),green:$('.jPicker_GreenText',picker),blue:$('.jPicker_BlueText',picker),hex:$('.jPicker_HexText',picker),alpha:$('.jPicker_AlphaText',picker)},valuesChanged:$.isFunction(arguments[1])&&arguments[1]||null,bindedHexKeyUp:function(e)
{hexKeyUp(e);},setValuesFromRgb:function()
{color.fromRgb(fields.red.val(),fields.green.val(),fields.blue.val());fields.hex.val(color.hex);fields.hue.val(color.h);fields.saturation.val(color.s);fields.value.val(color.v);},setValuesFromHsv:function()
{color.fromHsv(fields.hue.val(),fields.saturation.val(),fields.value.val());fields.hex.val(color.hex);fields.red.val(color.r);fields.green.val(color.g);fields.blue.val(color.b);},setValuesFromHex:function()
{color.fromHex(fields.hex.val());fields.red.val(color.r);fields.green.val(color.g);fields.blue.val(color.b);fields.hue.val(color.h);fields.saturation.val(color.s);fields.value.val(color.v);},setAlphaFromValue:function()
{color.a=fields.alpha.val();},destroy:function()
{fields.hue.add(fields.saturation).add(fields.value).unbind('keyup',events.hsvKeyUp).unbind('blur',hsvBlur);fields.red.add(fields.green).add(fields.blue).unbind('keyup',events.rgbKeyUp).unbind('blur',rgbBlur);fields.alpha.unbind('keyup',alphaKeyUp).unbind('blur',alphaBlur);fields.hex.unbind('keyup',hexKeyUp);fields=null;color=null;$this.valuesChanged=null;}});var fields=$this.fields,color=$this.color;fields.hue.add(fields.saturation).add(fields.value).bind('keyup',hsvKeyUp).bind('blur',hsvBlur);fields.red.add(fields.green).add(fields.blue).bind('keyup',rgbKeyUp).bind('blur',rgbBlur);fields.alpha.bind('keyup',alphaKeyUp).bind('blur',alphaBlur);fields.hex.bind('keyup',hexKeyUp).bind('blur',hexBlur);if(fields.hex.val()!='')
{color.fromHex(fields.hex.val());$this.setValuesFromHex();}};$.jPicker={List:[],Color:function(init)
{var $this=this;$.extend(true,$this,{r:0,g:0,b:0,h:0,s:0,v:0,a:100,hex:'',cmyk:{C:0,M:0,Y:0,K:0},fromRgb:function(r,g,b)
{var $this=this;$this.r=r;$this.g=g;$this.b=b;var newHsv=ColorMethods.rgbToHsv($this);$this.h=newHsv.h;$this.s=newHsv.s;$this.v=newHsv.v;$this.hex=ColorMethods.rgbToHex($this);$this.cmyk=ColorMethods.hexToCmyk($this.hex);},fromHsv:function(h,s,v)
{var $this=this;$this.h=h;$this.s=s;$this.v=v;var newRgb=ColorMethods.hsvToRgb($this);$this.r=newRgb.r;$this.g=newRgb.g;$this.b=newRgb.b;$this.hex=ColorMethods.rgbToHex(newRgb);$this.cmyk=ColorMethods.hexToCmyk($this.hex);},fromHex:function(hex)
{var $this=this;$this.hex=hex;var newRgb=ColorMethods.hexToRgb(hex);$this.r=newRgb.r;$this.g=newRgb.g;$this.b=newRgb.b;var newHsv=ColorMethods.rgbToHsv(newRgb);$this.h=newHsv.h;$this.s=newHsv.s;$this.v=newHsv.v;$this.hex=ColorMethods.rgbToHex(newRgb);$this.cmyk=ColorMethods.hexToCmyk($this.hex);}});if(init)
{if(init.hex)$this.fromHex(init.hex);else if(!isNaN(init.r))$this.fromRgb(init.r,init.g,init.b);else if(!isNaN(init.h))$this.fromHsv(init.h,init.s,init.v);if(!isNaN(init.a))$this.a=init.a;}},ColorMethods:{hexToRgb:function(hex)
{hex=this.validateHex(hex);var r='00',g='00',b='00';if(hex.length==6)
{r=hex.substring(0,2);g=hex.substring(2,4);b=hex.substring(4,6);}
else
{if(hex.length>4)
{r=hex.substring(4,hex.length);hex=hex.substring(0,4);}
if(hex.length>2)
{g=hex.substring(2,hex.length);hex=hex.substring(0,2);}
if(hex.length>0)b=hex.substring(0,hex.length);}
return{r:this.hexToInt(r),g:this.hexToInt(g),b:this.hexToInt(b)};},validateHex:function(hex)
{hex=hex.toLowerCase().replace(/[^a-f0-9]/g,'0');if(hex.length>6)hex=hex.substring(0,6);return hex;},rgbToHex:function(rgb)
{return this.intToHex(rgb.r)+this.intToHex(rgb.g)+this.intToHex(rgb.b);},intToHex:function(dec)
{var result=parseInt(dec).toString(16);if(result.length==1)result=('0'+result);return result.toLowerCase();},hexToInt:function(hex)
{return parseInt(hex,16);},rgbToHsv:function(rgb)
{var r=rgb.r/255,g=rgb.g/255,b=rgb.b/255,hsv={h:0,s:0,v:0},min=0,max=0,delta;if(r>=g&&r>=b)
{max=r;min=g>b?b:g;}
else if(g>=b&&g>=r)
{max=g;min=r>b?b:r;}
else
{max=b;min=g>r?r:g;}
hsv.v=max;hsv.s=max?(max-min)/max:0;if(!hsv.s)hsv.h=0;else
{delta=max-min;if(r==max)hsv.h=(g-b)/delta;else if(g==max)hsv.h=2+(b-r)/delta;else hsv.h=4+(r-g)/delta;hsv.h=parseInt(hsv.h*60);if(hsv.h<0)hsv.h+=360;}
hsv.s=parseInt(hsv.s*100);hsv.v=parseInt(hsv.v*100);return hsv;},hsvToRgb:function(hsv)
{var rgb={r:0,g:0,b:0},h=hsv.h,s=hsv.s,v=hsv.v;if(s==0)
{if(v==0)rgb.r=rgb.g=rgb.b=0;else rgb.r=rgb.g=rgb.b=parseInt(v*255/100);}
else
{if(h==360)h=0;h/=60;s=s/100;v=v/100;var i=parseInt(h),f=h-i,p=v*(1-s),q=v*(1-(s*f)),t=v*(1-(s*(1-f)));switch(i)
{case 0:rgb.r=v;rgb.g=t;rgb.b=p;break;case 1:rgb.r=q;rgb.g=v;rgb.b=p;break;case 2:rgb.r=p;rgb.g=v;rgb.b=t;break;case 3:rgb.r=p;rgb.g=q;rgb.b=v;break;case 4:rgb.r=t;rgb.g=p;rgb.b=v;break;case 5:rgb.r=v;rgb.g=p;rgb.b=q;break;}
rgb.r=parseInt(rgb.r*255);rgb.g=parseInt(rgb.g*255);rgb.b=parseInt(rgb.b*255);}
return rgb;},hexToCmyk:function(hex)
{var cmyk={C:0.0000,M:0.0000,Y:0.0000,K:0.0000};hex=this.validateHex(hex);if(!hex){return cmyk;}
var r=parseInt(hex.substring(0,2),16);var g=parseInt(hex.substring(2,4),16);var b=parseInt(hex.substring(4,6),16);if(r==0&&g==0&&b==0){cmyk.K=1;cmyk.K=cmyk.K.toFixed(4);return cmyk;}
cmyk.C=1-(r/255);cmyk.M=1-(g/255);cmyk.Y=1-(b/255);var minCMY=Math.min(cmyk.C,Math.min(cmyk.M,cmyk.Y));cmyk.C=((cmyk.C-minCMY)/(1-minCMY)).toFixed(4);cmyk.M=((cmyk.M-minCMY)/(1-minCMY)).toFixed(4);cmyk.Y=((cmyk.Y-minCMY)/(1-minCMY)).toFixed(4);cmyk.K=minCMY.toFixed(4);return cmyk;}}};var Color=$.jPicker.Color,List=$.jPicker.List,ColorMethods=$.jPicker.ColorMethods;$.fn.jPicker=function(options)
{var $arguments=arguments;return this.each(function()
{var $this=$(this),$settings=$.extend(true,{},$.fn.jPicker.defaults,options);if($this.get(0).nodeName.toLowerCase()=='input')
{$.extend(true,$settings,{window:{bindToInput:true,expandable:true,input:$this}});if(ColorMethods.validateHex($this.val()))
{$settings.color.active=new Color({hex:$this.val(),a:$settings.color.active.a});$settings.color.current=new Color({hex:$this.val(),a:$settings.color.active.a});}}
if($settings.window.expandable)
$this.after('<span class="jPicker_Picker"><span id="'+$settings.window.pickerId+'" class="jPicker_Color">&nbsp;</span><span class="jPicker_Icon" title="Click To Open Color Picker">&nbsp;</span><span class="jPicker_Container">&nbsp;</span></span>');else $settings.window.liveUpdate=false;var isLessThanIE7=parseFloat(navigator.appVersion.split('MSIE')[1])<7&&document.body.filters,colorMapL1=null,colorMapL2=null,colorMapL3=null,colorBarL1=null,colorBarL2=null,colorBarL3=null,colorBarL4=null,colorBarL5=null,enableAlpha=null,alphaCheckbox=null,alphaBarDiv=null,alphaBarL1=null,alphaBarL2=null,container=null,hue=null,saturation=null,value=null,red=null,green=null,blue=null,colorMap=null,colorBar=null,alphaBar=null,colorPicker=null,elementStartX=null,elementStartY=null,pageStartX=null,pageStartY=null,activeColor=null,currentColor=null,currentActiveBG=null,okButton=null,cancelButton=null,grid=null,colorBox=null,colorIcon=null,moveBar=null,setColorMode=function(colorMode)
{color.active=colorPicker.color;var active=color.active,clientPath=images.clientPath,resetImage=function(img)
{setAlpha(img,100);img.css({backgroundColor:'',backgroundPosition:'0px 0px',filter:''});};resetImage(colorMapL1);resetImage(colorMapL2);resetImage(colorBarL1);resetImage(colorBarL2);resetImage(colorBarL3);resetImage(colorBarL4);hue.add(saturation).add(value).add(red).add(green).add(blue).removeAttr('checked');switch(colorMode)
{case'h':hue.attr('checked',true);colorMapL1.css({backgroundColor:'#'+active.hex});colorMapL2.css({backgroundColor:'transparent'});setImgLoc(colorMapL2,-256);setAlpha(colorMapL2,100);setImgLoc(colorBarL4,-256);colorMap.mxX=100;colorMap.mxY=100;colorBar.mxY=360;break;case's':saturation.attr('checked',true);setImgLoc(colorMapL1,-512);setImgLoc(colorMapL2,-768);setAlpha(colorMapL2,0);setBG(colorBarL3,active.hex);setImgLoc(colorBarL4,-512);colorMap.mxX=360;colorMap.mxY=100;colorBar.mxY=100;break;case'v':value.attr('checked',true);setBG(colorMapL1,'000');setImgLoc(colorMapL2,-1024);colorBarL3.css({backgroundColor:'#'+active.hex});setImgLoc(colorBarL4,-768);colorMap.mxX=360;colorMap.mxY=100;colorBar.mxY=100;break;case'r':red.attr('checked',true);setImgLoc(colorMapL2,-1536);setImgLoc(colorMapL1,-1280);setImgLoc(colorBarL4,-1024);setImgLoc(colorBarL3,-1280);setImgLoc(colorBarL2,-1536);setImgLoc(colorBarL1,-1792);break;case'g':green.attr('checked',true);setImgLoc(colorMapL2,-2048);setImgLoc(colorMapL1,-1792);setImgLoc(colorBarL4,-2048);setImgLoc(colorBarL3,-2304);setImgLoc(colorBarL2,-2560);setImgLoc(colorBarL1,-2816);break;case'b':blue.attr('checked',true);setImgLoc(colorMapL2,-2560);setImgLoc(colorMapL1,-2304);setImgLoc(colorBarL4,-3072);setImgLoc(colorBarL3,-3328);setImgLoc(colorBarL2,-3584);setImgLoc(colorBarL1,-3840);break;default:throw('Invalid Mode');break;}
switch(colorMode)
{case'h':case's':case'v':colorMap.mnX=1;colorMap.mnY=1;colorBar.mnY=1;break;case'r':case'g':case'b':colorMap.mnX=0;colorMap.mnY=0;colorBar.mnY=0;colorMap.mxX=255;colorMap.mxY=255;colorBar.mxY=255;break;}
color.mode=colorMode;positionMapAndBarArrows();updateMapVisuals();updateBarVisuals();if(window.expandable&&window.liveUpdate)
{colorBox.css({backgroundColor:'#'+active.hex});if(window.bindToInput)
window.input.val(active.hex).css({backgroundColor:'#'+active.hex,color:active.v>75?'#000000':'#ffffff'});}
$.isFunction($this.liveCallback)&&$this.liveCallback(active);},textValuesChanged=function()
{positionMapAndBarArrows();updateVisuals();color.active=colorPicker.color;var active=color.active;if(window.expandable&&window.liveUpdate)
{colorBox.css({backgroundColor:'#'+active.hex});if(window.bindToInput)
window.input.val(colorPicker.fields.hex.val()).css({backgroundColor:'#'+active.hex,color:active.v>75?'#000000':'#ffffff'});}
$.isFunction($this.liveCallback)&&$this.liveCallback(active);},mapValueChanged=function()
{if(!colorPicker||!colorMap||!colorBar||!alphaBar)return;color.active=colorPicker.color;var fields=colorPicker.fields,active=color.active;switch(color.mode)
{case'h':fields.saturation.val(colorMap.x);fields.value.val(100-colorMap.y);break;case's':fields.hue.val(colorMap.x);fields.value.val(100-colorMap.y);break;case'v':fields.hue.val(colorMap.x);fields.saturation.val(100-colorMap.y);break;case'r':fields.blue.val(colorMap.x);fields.green.val(255-colorMap.y);break;case'g':fields.blue.val(colorMap.x);fields.red.val(255-colorMap.y);break;case'b':fields.red.val(colorMap.x);fields.green.val(255-colorMap.y);break;}
switch(color.mode)
{case'h':case's':case'v':colorPicker.setValuesFromHsv();break;case'r':case'g':case'b':colorPicker.setValuesFromRgb();break;}
updateVisuals();if(window.expandable&&window.liveUpdate)
{colorBox.css({backgroundColor:'#'+active.hex});if(window.bindToInput)
window.input.val(active.hex).css({backgroundColor:'#'+active.hex,color:active.v>75?'#000000':'#ffffff'});}
$.isFunction($this.liveCallback)&&$this.liveCallback(active);},colorBarValueChanged=function()
{if(!colorPicker||!colorMap||!colorBar||!alphaBar)return;color.active=colorPicker.color;var fields=colorPicker.fields,active=color.active;switch(color.mode)
{case'h':fields.hue.val(360-colorBar.y);break;case's':fields.saturation.val(100-colorBar.y);break;case'v':fields.value.val(100-colorBar.y);break;case'r':fields.red.val(255-colorBar.y);break;case'g':fields.green.val(255-colorBar.y);break;case'b':fields.blue.val(255-colorBar.y);break;}
switch(color.mode)
{case'h':case's':case'v':colorPicker.setValuesFromHsv();break;case'r':case'g':case'b':colorPicker.setValuesFromRgb();break;}
updateVisuals();if(window.expandable&&window.liveUpdate)
{colorBox.css({backgroundColor:'#'+active.hex});if(window.bindToInput)
window.input.val(active.hex).css({backgroundColor:'#'+active.hex,color:active.v>75?'#000000':'#ffffff'});}
$.isFunction($this.liveCallback)&&$this.liveCallback(active);},alphaBarValueChanged=function()
{if(!colorPicker||!colorMap||!colorBar||!alphaBar)return;color.active=colorPicker.color;var fields=colorPicker.fields,active=color.active;fields.alpha.val(alphaBar.x);colorPicker.setAlphaFromValue();updateVisuals();$.isFunction($this.liveCallback)&&$this.liveCallback(color.active);},positionMapAndBarArrows=function()
{color.active=colorPicker.color;var sliderValue=0,active=color.active;switch($this.settings.color.mode)
{case'h':sliderValue=360-active.h;break;case's':sliderValue=100-active.s;break;case'v':sliderValue=100-active.v;break;case'r':sliderValue=255-active.r;break;case'g':sliderValue=255-active.g;break;case'b':sliderValue=255-active.b;break;}
colorBar.y=sliderValue;alphaBar.x=active.a;colorBar.setArrowPositionFromValues();alphaBar.setArrowPositionFromValues();var mapX=0,mapY=0;switch($this.settings.color.mode)
{case'h':mapX=active.s;mapY=100-active.v;break;case's':mapX=active.h;mapY=100-active.v;break;case'v':mapX=active.h;mapY=100-active.s;break;case'r':mapX=active.b;mapY=256-active.g;break;case'g':mapX=active.b;mapY=256-active.r;break;case'b':mapX=active.r;mapY=256-active.g;break;}
colorMap.x=mapX;colorMap.y=mapY;colorMap.setArrowPositionFromValues();},updateVisuals=function()
{updatePreview();updateMapVisuals();updateBarVisuals();updateAlphaVisuals();},updatePreview=function()
{try
{activeColor.css({backgroundColor:'#'+colorPicker.color.hex});setAlpha(activeColor,colorPicker.color.a);}
catch(e){}},updateMapVisuals=function()
{if(!color||!colorPicker)return;color.active=colorPicker.color;var active=color.active;switch(color.mode)
{case'h':setBG(colorMapL1,new Color({h:active.h,s:100,v:100}).hex);break;case's':setAlpha(colorMapL2,100-active.s);break;case'v':setAlpha(colorMapL2,active.v);break;case'r':setAlpha(colorMapL2,active.r/256*100);break;case'g':setAlpha(colorMapL2,active.g/256*100);break;case'b':setAlpha(colorMapL2,active.b/256*100);break;}
setAlpha(colorMapL3,100-active.a);},updateBarVisuals=function()
{if(!color||!colorPicker)return;color.active=colorPicker.color;var active=color.active,mode=color.mode,fields=colorPicker.fields;switch(mode)
{case'h':break;case's':var saturatedColor=new Color({h:active.h,s:100,v:active.v});setBG(colorBarL3,saturatedColor.hex);break;case'v':var valueColor=new Color({h:active.h,s:active.s,v:100});setBG(colorBarL3,valueColor.hex);break;case'r':case'g':case'b':var hValue=0,vValue=0;if(mode=='r')
{hValue=fields.blue.val();vValue=fields.green.val();}
else if(mode=='g')
{hValue=fields.blue.val();vValue=fields.red.val();}
else if(mode=='b')
{hValue=fields.red.val();vValue=fields.green.val();}
var horzPer=hValue/256*100,vertPer=vValue/256*100,horzPerRev=(256-hValue)/256*100,vertPerRev=(256-vValue)/256*100;setAlpha(colorBarL4,vertPer>horzPerRev?horzPerRev:vertPer);setAlpha(colorBarL3,vertPer>horzPer?horzPer:vertPer);setAlpha(colorBarL2,vertPerRev>horzPer?horzPer:vertPerRev);setAlpha(colorBarL1,vertPerRev>horzPerRev?horzPerRev:vertPerRev);break;}
setAlpha(colorBarL5,100-active.a);},updateAlphaVisuals=function()
{setBG(alphaBarL1,colorPicker.color.hex);},setBG=function(el,c)
{try
{el.css({backgroundColor:'#'+c});}
catch(e){}},setImg=function(img,src)
{if(src.indexOf('png')&&this.isLessThanIE7)
{img.attr('pngSrc',src);img.css({backgroundImage:'none',filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+src+'\')'});}
else img.css({backgroundImage:'url('+src+')'});},setImgLoc=function(img,y)
{img.css({backgroundPosition:'0px '+y+'px'});},setAlpha=function(obj,alpha)
{if(alpha<100)
{if(this.isLessThanIE7)
{var src=obj.attr('pngSrc');if(src!=null&&src.indexOf('map-hue')==-1)
obj.css({filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+src+'\') progid:DXImageTransform.Microsoft.Alpha(opacity='+alpha+')'});}
else obj.css({opacity:alpha/100});}
else if(alpha==100)
{if(this.isLessThanIE7)
{var src=obj.attr('pngSrc');if(src!=null&&src.indexOf('map-hue')==-1)obj.css({filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+src+'\')'});}
else obj.css({opacity:''});}},revertColor=function()
{colorPicker.fields.hex.val(color.current.hex);colorPicker.fields.alpha.val(color.current.a);colorPicker.setValuesFromHex();colorPicker.setAlphaFromValue();$.isFunction(colorPicker.valuesChanged)&&colorPicker.valuesChanged(colorPicker);},radioClicked=function(e)
{setColorMode(e.target.value);},currentClicked=function()
{revertColor();},cancelClicked=function()
{revertColor();window.expandable&&$this.hide();$.isFunction($this.cancelCallback)&&$this.cancelCallback();},commitColor=function()
{var active=color.active;color.current=new Color({hex:active.hex});color.current.a=active.a;currentColor.css({backgroundColor:'#'+active.hex});setAlpha(currentColor,colorPicker.color.a);if(window.expandable)
{colorBox.css({backgroundColor:'#'+active.hex});if(window.bindToInput)
window.input.val(active.hex).css({backgroundColor:'#'+active.hex,color:active.v>75?'#000000':'#ffffff'});}
$.isFunction($this.commitCallback)&&$this.commitCallback(active);},okClicked=function()
{commitColor();window.expandable&&$this.hide();},colorIconClicked=function()
{$this.show();},moveBarMouseDown=function(e)
{var element=window.element,page=window.page;elementStartX=parseInt(container.css('left'));elementStartY=parseInt(container.css('top'));pageStartX=e.pageX;pageStartY=e.pageY;$(document).bind('mousemove',documentMouseMove).bind('mouseup',documentMouseUp);e.stopPropagation();e.preventDefault();return false;},documentMouseMove=function(e)
{container.css({left:elementStartX-(pageStartX-e.pageX)+'px',top:elementStartY-(pageStartY-e.pageY)+'px'});e.stopPropagation();e.preventDefault();return false;},documentMouseUp=function(e)
{$(document).unbind('mousemove',documentMouseMove).unbind('mouseup',documentMouseUp);e.stopPropagation();e.preventDefault();return false;},bindedHexKeyUp=function(e)
{colorPicker.fields.hex.val($this.settings.window.input.val());colorPicker.bindedHexKeyUp(e);},quickPickClicked=function(e)
{colorPicker.fields.hex.val(color.quickList[e.data.i].hex);colorPicker.fields.alpha.val(color.quickList[e.data.i].a);colorPicker.setValuesFromHex();colorPicker.setAlphaFromValue();$.isFunction(colorPicker.valuesChanged)&&colorPicker.valuesChanged(colorPicker);};$.extend(true,$this,{id:$this.attr('id'),settings:$settings,color:null,icon:null,commitCallback:$.isFunction($arguments[1])&&$arguments[1]||null,liveCallback:$.isFunction($arguments[2])&&$arguments[2]||null,cancelCallback:$.isFunction($arguments[3])&&$arguments[3]||null,show:function()
{if(document.all)
{var foundthis=false;for(i=0;i<List.length;i++)
{if(foundthis)List[i].color.add(List[i].icon).css({display:'none'});if(List[i].id==$this.id)foundthis=true;}}
color.current=new Color({hex:color.active.hex,a:color.active.a});currentColor.css({backgroundColor:'#'+color.active.hex});setAlpha(currentColor,color.active.a);container.css({display:'block'});colorMap.setPositioningVariables();colorBar.setPositioningVariables();positionMapAndBarArrows();},hide:function()
{if(document.all)
{var foundthis=false;for(i=0;i<List.length;i++)
{if(foundthis)List[i].color.add(List[i].icon).css({display:'block'});if(List[i].id==$this.id)foundthis=true;}}
container.css({display:'none'});},destroy:function()
{if(window.expandable)colorIcon=$('.jPicker_Icon',container).unbind('click',colorIconClicked);if(window.bindToInput)window.input.unbind('keyup',bindedHexKeyUp).unbind('change',bindedHexKeyUp);hue.add(saturation).add(value).add(red).add(green).add(blue).unbind('click',radioClicked);currentColor.unbind('click',currentClicked);cancelButton.unbind('click',cancelClicked);okButton.unbind('click',okClicked);if(window.expandable)moveBar.unbind('mousedown',moveBarMouseDown);$('.jPicker_QuickColor',container).unbind('click',quickPickClicked);hue=null;saturation=null;value=null;red=null;green=null;blue=null;colorMapL1=null;colorMapL2=null;colorMapL3=null;colorBarL1=null;colorBarL2=null;colorBarL3=null;colorBarL4=null;colorBarL5=null;enableAlpha=null;alphaCheckbox=null;alphaBarDiv=null;alphaBarL1=null;alphaBarL2=null;currentActiveBG=null;activeColor=null;currentColor=null;okButton=null;cancelButton=null;grid=null;$this.color=null;$this.icon=null;colorMap.destroy();colorMap=null;colorBar.destroy();colorBar=null;alphaBar.destroy();alphaBar=null;colorPicker.destroy();colorPicker=null;$this.commitCallback=null;$this.cancelCallback=null;$this.liveCallback=null;container.html('');for(i=0;i<List.length;i++)if(List[i].id==$this.id)List.splice(i,1);}});var images=$this.settings.images,window=$this.settings.window,color=$this.settings.color;container=window.expandable?$('.jPicker_Container',$this.next()):$this;if(window.expandable)
container.css({left:window.position.x=='left'?'-526px':window.position.x=='center'?'-259px':window.position.x=='right'?'0px':window.position.x=='screenCenter'?(($(document).width()>>1)-259)-$this.next().offset().left+'px':window.position.x,position:'absolute',top:window.position.y=='top'?'-350px':window.position.y=='center'?'-158px':window.position.y=='bottom'?'25px':window.position.y});if((typeof(color.active)).toString().toLowerCase()=='string')color.active=new Color({hex:color.active.substring(1)});if(!color.alphaSupport)color.active.a=100;container.html('<table class="jPicker_table"><tbody>'+(window.expandable?'<tr><td class="jPicker_MoveBar" colspan="6">&nbsp;</td></tr>':'')+'<tr><td class="jPicker_MapCol" rowspan="7"><h2 class="jPicker_Title">'+(window.title||'Drag Markers To Pick A Color')+'</h2><div class="jPicker_ColorMap"><span class="jPicker_ColorMap_l1">&nbsp;</span><span class="jPicker_ColorMap_l2">&nbsp;</span><span class="jPicker_ColorMap_l3">&nbsp;</span><img src="'+images.clientPath+images.colorMap.arrow.file+'" class="jPicker_ColorMap_Arrow"/></div></td><td rowspan="7"><div class="jPicker_ColorBar"><span class="jPicker_ColorBar_l1">&nbsp;</span><span class="jPicker_ColorBar_l2">&nbsp;</span><span class="jPicker_ColorBar_l3">&nbsp;</span><span class="jPicker_ColorBar_l4">&nbsp;</span><span class="jPicker_ColorBar_l5">&nbsp;</span><img src="'+images.clientPath+images.colorBar.arrow.file+'" class="jPicker_ColorBar_Arrow"/></div></td><td colspan="3" class="jPicker_Preview">new<div class="jPicker_NewCurrent"><span class="jPicker_Active" title="New Color - Press &ldquo;OK&rdquo; To Commit">&nbsp;</span><span class="jPicker_Current" title="Click To Revert To Original Color">&nbsp;</span></div>current</td><td rowspan="8" class="jPicker_OkCancel"><input type="button" class="jPicker_Ok" value="OK" title="Commit To This Color Selection"/><input type="button" class="jPicker_Cancel" value="Cancel" title="Cancel And Revert To Original Color"/><hr/><div class="jPicker_Grid">&nbsp;</div></td></tr><tr><td><input type="radio" class="jPicker_HueRadio" id="jPicker_Hue_'+List.length+'" name="jPicker_Mode_'+List.length+'" value="h" title="Set To &ldquo;Hue&rdquo; Color Mode"/></td><td><label for="jPicker_Hue_'+List.length+'" title="Set To &ldquo;Hue&rdquo; Color Mode">H:</label></td><td><input type="text" class="jPicker_HueText" value="'+color.active.h+'" title="Enter A &ldquo;Hue&rdquo; Value (0-360&deg;)"/> &deg;</td></tr><tr><td><input type="radio" class="jPicker_SaturationRadio" id="jPicker_Saturation_'+List.length+'" name="jPicker_Mode_'+List.length+'" value="s" title="Set To &ldquo;Saturation&rdquo; Color Mode"/></td><td><label for="jPicker_Saturation_'+List.length+'" title="Set To &ldquo;Saturation&rdquo; Color Mode">S:</label></td><td><input type="text" class="jPicker_SaturationText" value="'+color.active.s+'" title="Enter A &ldquo;Saturation&rdquo; Value (0-100%)"/> %</td></tr><tr><td><input type="radio" class="jPicker_BrightnessRadio" id="jPicker_Brightness_'+List.length+'" name="jPicker_Mode_'+List.length+'" value="v" title="Set To &ldquo;Brightness&rdquo; Color Mode"/><br/><br/></td><td><label for="jPicker_Brightness_'+List.length+'" title="Set To &ldquo;Brightness&rdquo; Color Mode">B:</label></td><td><input type="text" class="jPicker_BrightnessText" value="'+color.active.v+'" title="Enter A &ldquo;Brightness&rdquo; Value (0-100%)"/> %</td></tr><tr><td><input type="radio" class="jPicker_RedRadio" id="jPicker_Red_'+List.length+'" name="jPicker_Mode_'+List.length+'" value="r" title="Set To &ldquo;Red&rdquo; Color Mode"/></td><td><label for="jPicker_Red_'+List.length+'" title="Set To &ldquo;Red&rdquo; Color Mode">R:</label></td><td><input type="text" class="jPicker_RedText" value="'+color.active.r+'" title="Enter A &ldquo;Red&rdquo; Value (0-255)"/></td></tr><tr><td><input type="radio" class="jPicker_GreenRadio" id="jPicker_Green_'+List.length+'" name="jPicker_Mode_'+List.length+'" value="g" title="Set To &ldquo;Green&rdquo; Color Mode"/></td><td><label for="jPicker_Green_'+List.length+'" title="Set To &ldquo;Green&rdquo; Color Mode">G:</label></td><td><input type="text" class="jPicker_GreenText" value="'+color.active.g+'" title="Enter A &ldquo;Green&rdquo; Value (0-255)"/></td></tr><tr><td><input type="radio" class="jPicker_BlueRadio" id="jPicker_Blue_'+List.length+'" name="jPicker_Mode_'+List.length+'" value="b" title="Set To &ldquo;Blue&rdquo; Color Mode"/></td><td><label for="jPicker_Blue_'+List.length+'" title="Set To &ldquo;Blue&rdquo; Color Mode">B:</label></td><td><input type="text" class="jPicker_BlueText" value="'+color.active.b+'" title="Enter A &ldquo;Blue&rdquo; Value (0-255)"/></td></tr><tr><td class="jPicker_OpacityBar"><div class="jPicker_AlphaBar"><span class="jPicker_AlphaBar_l1">&nbsp;</span><span class="jPicker_AlphaBar_l2">&nbsp;</span><img src="'+images.clientPath+images.alphaBar.arrow.file+'" class="jPicker_AlphaBar_Arrow"/></div></td><td colspan="2" class="jPicker_OpacityCol"><label for="jPicker_Alpha_'+List.length+'" title="Enter An &ldquo;Alpha&rdquo; Value (0-100%)">A:</label><input type="text" class="jPicker_AlphaText" id="jPicker_Alpha_'+List.length+'" value="'+color.active.a+'" title="Enter An &ldquo;Alpha&rdquo; Value (0-100%)"/><span>%</span></td><td class="jPicker_HexCol"><label for="jPicker_Hex_'+List.length+'" title="Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)">#:</label></td><td class="jPicker_EnterHex"><input type="text" class="jPicker_HexText" id="jPicker_Hex_'+List.length+'" value="'+color.active.hex+'" title="Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)"/></td></tr></tbody></table>');hue=$('.jPicker_HueRadio',container);saturation=$('.jPicker_SaturationRadio',container);value=$('.jPicker_BrightnessRadio',container);red=$('.jPicker_RedRadio',container);green=$('.jPicker_GreenRadio',container);blue=$('.jPicker_BlueRadio',container);colorMapL1=$('.jPicker_ColorMap_l1',container);colorMapL2=$('.jPicker_ColorMap_l2',container);colorMapL3=$('.jPicker_ColorMap_l3',container);colorBarL1=$('.jPicker_ColorBar_l1',container);colorBarL2=$('.jPicker_ColorBar_l2',container);colorBarL3=$('.jPicker_ColorBar_l3',container);colorBarL4=$('.jPicker_ColorBar_l4',container);colorBarL5=$('.jPicker_ColorBar_l5',container);alphaBarL1=$('.jPicker_AlphaBar_l1',container);alphaBarL2=$('.jPicker_AlphaBar_l2',container);enableAlpha=$('.jPicker_EnableAlpha',container);alphaCheckbox=$('.jPicker_AlphaCheckbox',container);alphaBarDiv=$('.jPicker_AlphaBar',container);currentActiveBG=$('.jPicker_NewCurrent',container);activeColor=$('.jPicker_Active',container).css({backgroundColor:'#'+color.active.hex});currentColor=$('.jPicker_Current',container).css({backgroundColor:'#'+color.active.hex});okButton=$('.jPicker_Ok',container);cancelButton=$('.jPicker_Cancel',container);grid=$('.jPicker_Grid',container);$this.color=$('.Picker_Color');$this.icon=$('.jPicker_Icon');colorPicker=new ColorValuePicker(container,textValuesChanged);colorMap=new Slider($('.jPicker_ColorMap',container),{map:{width:images.colorMap.width,height:images.colorMap.height},arrow:{image:images.clientPath+images.colorMap.arrow.file,width:images.colorMap.arrow.width,height:images.colorMap.arrow.height}},mapValueChanged);colorBar=new Slider($('.jPicker_ColorBar',container),{map:{width:images.colorBar.width,height:images.colorBar.height},arrow:{image:images.clientPath+images.colorBar.arrow.file,width:images.colorBar.arrow.width,height:images.colorBar.arrow.height}},colorBarValueChanged);alphaBar=new Slider($('.jPicker_AlphaBar',container),{map:{width:images.alphaBar.width,height:images.alphaBar.height},arrow:{image:images.clientPath+images.alphaBar.arrow.file,width:images.alphaBar.arrow.width,height:images.alphaBar.arrow.height}},alphaBarValueChanged);alphaBar.mnX=0;alphaBar.mxX=100;setImg(colorMapL1,images.clientPath+'Maps.png');setImg(colorMapL2,images.clientPath+'Maps.png');setImg(colorMapL3,images.clientPath+'map-opacity.png');setImg(colorBarL1,images.clientPath+'Bars.png');setImg(colorBarL2,images.clientPath+'Bars.png');setImg(colorBarL3,images.clientPath+'Bars.png');setImg(colorBarL4,images.clientPath+'Bars.png');setImg(colorBarL5,images.clientPath+'bar-opacity.png');setImg(alphaBarL2,images.clientPath+'Maps.png');setImgLoc(alphaBarL2,-2816);setImg(currentActiveBG,images.clientPath+'preview-opacity.png');currentActiveBG.css({backgroundPosition:'1px 1px'});if(color.alphaSupport)
{enableAlpha.hide();alphaBarDiv.show();$('td.jPicker_OpacityCol *',container).show();}
else
alphaCheckbox.bind('click',function()
{enableAlpha.hide();alphaBarDiv.show();$('td.jPicker_OpacityCol *',container).show();});if(window.expandable)
{colorBox=$('.jPicker_Color',$this.next()).css({backgroundColor:'#'+color.active.hex});colorIcon=$('.jPicker_Icon',$this.next()).css({backgroundImage:'url('+images.clientPath+images.picker.file+')'}).bind('click',colorIconClicked);if(window.bindToInput)window.input.bind('keyup',bindedHexKeyUp).bind('change',bindedHexKeyUp);}
hue.add(saturation).add(value).add(red).add(green).add(blue).bind('click',radioClicked);currentColor.bind('click',currentClicked);cancelButton.bind('click',cancelClicked);okButton.bind('click',okClicked);if(window.expandable)moveBar=$('.jPicker_MoveBar',container).bind('mousedown',moveBarMouseDown);if(color.quickList&&color.quickList.length>0)
{grid.html('');for(i=0;i<color.quickList.length;i++)
{if((typeof(color.quickList[i])).toString().toLowerCase()=='string')color.quickList[i]=new Color({hex:color.quickList[i].substring(1)});grid.append('<span class="jPicker_QuickColor" title="#'+color.quickList[i].hex+'">&nbsp;</span>');$('.jPicker_QuickColor',container).eq(i).css({backgroundColor:'#'+color.quickList[i].hex}).bind('click',{i:i},quickPickClicked);}}
setColorMode(color.mode);colorPicker.fields.hex.val(colorBar.hex);colorPicker.setValuesFromHex();colorPicker.setAlphaFromValue();positionMapAndBarArrows();updateVisuals();if(!window.expandable)$this.show();List.push($this);});};$.fn.jPicker.defaults={window:{title:null,position:{x:'screenCenter',y:'top'},expandable:false,liveUpdate:true},color:{mode:'h',active:new Color({hex:'ffc000'}),alphaSupport:false,quickList:[new Color({h:360,s:33,v:100}),new Color({h:360,s:66,v:100}),new Color({h:360,s:100,v:100}),new Color({h:360,s:100,v:75}),new Color({h:360,s:100,v:50}),new Color({h:180,s:0,v:100}),new Color({h:30,s:33,v:100}),new Color({h:30,s:66,v:100}),new Color({h:30,s:100,v:100}),new Color({h:30,s:100,v:75}),new Color({h:30,s:100,v:50}),new Color({h:180,s:0,v:90}),new Color({h:60,s:33,v:100}),new Color({h:60,s:66,v:100}),new Color({h:60,s:100,v:100}),new Color({h:60,s:100,v:75}),new Color({h:60,s:100,v:50}),new Color({h:180,s:0,v:80}),new Color({h:90,s:33,v:100}),new Color({h:90,s:66,v:100}),new Color({h:90,s:100,v:100}),new Color({h:90,s:100,v:75}),new Color({h:90,s:100,v:50}),new Color({h:180,s:0,v:70}),new Color({h:120,s:33,v:100}),new Color({h:120,s:66,v:100}),new Color({h:120,s:100,v:100}),new Color({h:120,s:100,v:75}),new Color({h:120,s:100,v:50}),new Color({h:180,s:0,v:60}),new Color({h:150,s:33,v:100}),new Color({h:150,s:66,v:100}),new Color({h:150,s:100,v:100}),new Color({h:150,s:100,v:75}),new Color({h:150,s:100,v:50}),new Color({h:180,s:0,v:50}),new Color({h:180,s:33,v:100}),new Color({h:180,s:66,v:100}),new Color({h:180,s:100,v:100}),new Color({h:180,s:100,v:75}),new Color({h:180,s:100,v:50}),new Color({h:180,s:0,v:40}),new Color({h:210,s:33,v:100}),new Color({h:210,s:66,v:100}),new Color({h:210,s:100,v:100}),new Color({h:210,s:100,v:75}),new Color({h:210,s:100,v:50}),new Color({h:180,s:0,v:30}),new Color({h:240,s:33,v:100}),new Color({h:240,s:66,v:100}),new Color({h:240,s:100,v:100}),new Color({h:240,s:100,v:75}),new Color({h:240,s:100,v:50}),new Color({h:180,s:0,v:20}),new Color({h:270,s:33,v:100}),new Color({h:270,s:66,v:100}),new Color({h:270,s:100,v:100}),new Color({h:270,s:100,v:75}),new Color({h:270,s:100,v:50}),new Color({h:180,s:0,v:10}),new Color({h:300,s:33,v:100}),new Color({h:300,s:66,v:100}),new Color({h:300,s:100,v:100}),new Color({h:300,s:100,v:75}),new Color({h:300,s:100,v:50}),new Color({h:180,s:0,v:0}),new Color({h:330,s:33,v:100}),new Color({h:330,s:66,v:100}),new Color({h:330,s:100,v:100}),new Color({h:330,s:100,v:75}),new Color({h:330,s:100,v:50})]},images:{clientPath:'/jPicker/images/',colorMap:{width:256,height:256,arrow:{file:'mappoint.gif',width:15,height:15}},colorBar:{width:20,height:256,arrow:{file:'rangearrows.gif',width:40,height:9}},alphaBar:{width:256,height:20,arrow:{file:'rangearrows2.gif',width:9,height:40}},picker:{file:'picker.gif',width:25,height:24}}};})(jQuery,'1.0.10');
