var mouse_x;var mouse_y;var color_selects=new Array(0);var scrolling=true;function set_scrolling(){scrolling=true;window.status="(scrolling!)";}function XBrowserAddHandler(_1,_2,_3){if(_1.addEventListener){_1.addEventListener(_2,function(e){_1[_3](e);},false);}else{if(_1.attachEvent){_1.attachEvent("on"+_2,function(e){_1[_3](e);});}else{var _6=_1["on"+_2];if(_6){_1["on"+_2]=function(e){_6(e);_1[_3](e);};}else{_1["on"+_2]=_1[_3];}}}}function generic_h_select_box_mousedown(){var id=this.id.match(/(.+?)_/);id=RegExp.$1;var _9=id+".h_select_box_mousedown();";eval(_9);}function generic_h_select_box_mouseup(){var id="";if(this.id){id=this.id;}var id=this.id.match(/(.+?)_/);id=RegExp.$1;var _c=id+".h_select_box_mouseup();";eval(_c);}function generic_sv_select_box_mousedown(){var id=this.id.match(/(.+?)_/);id=RegExp.$1;var _e=id+".sv_select_box_mousedown();";eval(_e);}function generic_sv_select_box_mouseup(){var id=this.id.match(/(.+?)_/);id=RegExp.$1;var _10=id+".sv_select_box_mouseup();";eval(_10);}function generic_ok_button_click(){var id=this.id.match(/(.+?)_/);id=RegExp.$1;var _12=id+".hide();";eval(_12);}function color_select(i,_14){this.id=i;this.sv_image="";this.x=0;this.y=0;this.hexcolor="";this.color_select_box=document.createElement("div");this.color_select_box.id=this.id+"_color_select_box";this.color_select_box.className="color_select_box";this.color_select_box.style.display="none";document.getElementsByTagName("body").item(0).appendChild(this.color_select_box);this.sv_crosshair_horiz_cursor=document.createElement("div");this.sv_crosshair_horiz_cursor.id=this.id+"_sv_crosshair_horiz_cursor";this.sv_crosshair_horiz_cursor.className="sv_crosshair_horiz_cursor";this.sv_crosshair_horiz_cursor.style.visibility="hidden";this.color_select_box.appendChild(this.sv_crosshair_horiz_cursor);this.sv_crosshair_vert_cursor=document.createElement("div");this.sv_crosshair_vert_cursor.id=this.id+"_sv_crosshair_vert_cursor";this.sv_crosshair_vert_cursor.className="sv_crosshair_vert_cursor";this.sv_crosshair_vert_cursor.style.visibility="hidden";this.color_select_box.appendChild(this.sv_crosshair_vert_cursor);this.sv_crosshair_center_cursor=document.createElement("div");this.sv_crosshair_center_cursor.id=this.id+"_sv_crosshair_center_cursor";this.sv_crosshair_center_cursor.className="sv_crosshair_center_cursor";this.sv_crosshair_center_cursor.style.visibility="hidden";this.color_select_box.appendChild(this.sv_crosshair_center_cursor);this.sv_select_box_bg=document.createElement("div");this.sv_select_box_bg.id=this.id+"_sv_select_box_bg";this.sv_select_box_bg.className="sv_select_box_bg";this.color_select_box.appendChild(this.sv_select_box_bg);this.sv_select_box_bg.style.height="256px";this.sv_select_box_bg.style.width="256px";this.sv_select_box=document.createElement("div");this.sv_select_box.id=this.id+"_sv_select_box";this.sv_select_box.className="sv_select_box";this.sv_select_box_bg.appendChild(this.sv_select_box);this.sv_select_box.style.height="256px";this.sv_select_box.style.width="256px";this.sv_select_box.mousedownHandler=generic_sv_select_box_mousedown;this.sv_select_box.mouseupHandler=generic_sv_select_box_mouseup;XBrowserAddHandler(this.sv_select_box,"mousedown","mousedownHandler");XBrowserAddHandler(this.sv_select_box,"mouseup","mouseupHandler");this.h_select_box=document.createElement("div");this.h_select_box.id=this.id+"_h_select_box";this.h_select_box.className="h_select_box";this.h_select_box.mousedownHandler=generic_h_select_box_mousedown;this.h_select_box.mouseupHandler=generic_h_select_box_mouseup;XBrowserAddHandler(this.h_select_box,"mousedown","mousedownHandler");XBrowserAddHandler(this.h_select_box,"mouseup","mouseupHandler");this.color_select_box.appendChild(this.h_select_box);this.color_box=document.createElement("div");this.color_box.id=this.id+"_color_box";this.color_box.className="color_box";this.color_select_box.appendChild(this.color_box);this.color_value_box=document.createElement("div");this.color_value_box.id=this.id+"_color_value_box";this.color_value_box.className="color_value_box";this.color_box.appendChild(this.color_value_box);this.ok_button=document.createElement("div");this.ok_button.id=this.id+"_ok_button";this.ok_button.className="ok_button";this.color_select_box.appendChild(this.ok_button);this.ok_button.innerHTML="ok";this.ok_button.mouseupHandler=generic_ok_button_click;XBrowserAddHandler(this.ok_button,"mouseup","mouseupHandler");this.hue_cursor=document.createElement("div");this.hue_cursor.id=this.id+"_hue_cursor";this.hue_cursor.className="hue_cursor";this.h_select_box.appendChild(this.hue_cursor);this.hue_offset=0;this.sat_offset=0;this.val_offset=0;this.color_select_bounding_box=new Array(4);this.initialized=false;this.active=false;this.h_select_box_focus=false;this.sv_select_box_focus=false;this.change_update_function=this.id+"_change_update";this.hide_update_function=this.id+"_hide_update";this.attach_to_element=function(e){this.x=docjslib_getRealLeft(e);this.y=docjslib_getRealTop(e)+22;};this.h_select_box_mousedown=function(){this.h_select_box_focus=true;window.status="(h_select_box_mousedown) ("+mouse_x+","+mouse_y+") "+this.id+" "+this.h_select_box_focus;this.hue_cursor_to_color();this.sv_update();color_select_update();};this.h_select_box_mouseup=function(){this.h_select_box_focus=false;};this.sv_select_box_mousedown=function(){this.sv_select_box_focus=true;window.status="(sv_select_box_mousedown) ("+mouse_x+","+mouse_y+") "+this.id+" "+this.sv_select_box_focus;this.sv_update();color_select_update();};this.sv_select_box_mouseup=function(){this.sv_select_box_focus=false;};this.show=function(){this.color_select_bounding_box=new Array;if(!document.all&&this.sv_image){this.sv_select_box.style.backgroundImage="url('"+this.sv_image+"')";}this.color_select_box.style.visibility="visible";this.color_select_box.style.display="block";this.color_select_box.style.position="absolute";this.color_select_box.style.left=this.x-docjslib_getRealLeft(this.color_select_box.offsetParent)+"px";this.color_select_box.style.top=this.y-docjslib_getRealTop(this.color_select_box.offsetParent)+"px";this.sat_offset=docjslib_getRealTop(this.sv_select_box);this.val_offset=docjslib_getRealLeft(this.sv_select_box);this.hue_offset=docjslib_getRealTop(this.h_select_box);this.color_select_bounding_box[0]=this.x;this.color_select_bounding_box[1]=this.y;this.color_select_bounding_box[2]=300;this.color_select_bounding_box[3]=300;this.sv_cursor_draw();this.hue_cursor.style.left=docjslib_getRealLeft(this.h_select_box)-docjslib_getRealLeft(this.color_select_box)-1;this.hue_cursor_draw();this.initialized=true;this.active=true;if(!this.color_select_box.style){alert("color select box style not found!");}this.update_color_box();};this.hide=function(){if(this.color_select_box){this.color_select_box.style.display="none";}this.active=false;this.unfocus();try{if(self[this.hide_update_function]){setTimeout(this.hide_update_function+"(\""+this.hexcolor+"\")",100);}}catch(e){}};this.toggle_color_select=function(){if(this.active){this.hide();}else{this.show();}};this.select_disable=function(){if(this.h_select_box_focus||this.sv_select_box_focus){return true;}else{return false;}};this.hue_cursor_to_color=function(){if(!this.h_select_box_focus){return;}var _16=mouse_y-this.hue_offset;if(_16>255){_16=255;}if(_16<0){_16=0;}this.hue_cursor_pos=_16;this.hue_value=360-_16/255*360;this.hue_cursor_draw();this.cursor_to_color();};this.sv_update=function(){if(!this.sv_select_box_focus){return;}var _17=mouse_y-this.sat_offset;var _18=mouse_x-this.val_offset;if(_17>255){_17=255;}if(_17<0){_17=0;}if(_18>255){_18=255;}if(_18<0){_18=0;}this.sat_cursor_pos=_17;this.val_cursor_pos=_18;this.sv_cursor_draw();this.cursor_to_color();return;};this.hue_cursor_draw=function(){if(!this.hue_cursor.style){return;}if(!this.sv_select_box_bg.style){return;}this.hue_cursor.style.top=this.hue_cursor_pos+1+"px";this.hue_cursor.style.visibility="visible";var _19=new Array(this.hue_value,1,255);var _1a=hsv2rgb(_19);var _1b="rgb("+_1a[0]+", "+_1a[1]+", "+_1a[2]+")";this.sv_select_box_bg.style.background=_1b;};this.sv_cursor_draw=function(){if(!this.sv_crosshair_horiz_cursor.style){return;}if(!this.sv_crosshair_vert_cursor.style){return;}var _1c=this.val_cursor_pos;if(_1c==0){_1c=0.001;}_1c=Math.round(255/(_1c/30));if(_1c>255){_1c=255;}if(_1c<0){_1c=0;}this.sv_crosshair_vert_cursor.style.backgroundColor="rgb("+_1c+","+_1c+","+_1c+")";this.sv_crosshair_horiz_cursor.style.borderColor="rgb("+_1c+","+_1c+","+_1c+")";this.sv_crosshair_horiz_cursor.style.top=this.sat_cursor_pos+3+"px";this.sv_crosshair_horiz_cursor.style.left=2+"px";this.sv_crosshair_horiz_cursor.style.visibility="visible";this.sv_crosshair_vert_cursor.style.left=this.val_cursor_pos+3+"px";this.sv_crosshair_vert_cursor.style.visibility="visible";window.status=(this.sat_cursor_pos+3)+", "+(this.val_cursor_pos+3);};this.cursor_to_color=function(){this.hue_value=((255-this.hue_cursor_pos)/255*360);this.sat_value=(255-this.sat_cursor_pos)/255;this.val_value=this.val_cursor_pos;this.update_color_box();};this.unfocus=function(){this.sv_select_box_focus=false;};this.setrgb=function(c){if(!c.match(/#([0-9]|[A-F]){6}/i)){return false;}var rgb=hex2rgb(c.substring(1,7));hsv=rgb2hsv(rgb);this.sethsv(hsv[0],hsv[1],hsv[2]);return true;};this.sethsv=function(h,s,v){var _22;this.hue_value=h;this.sat_value=s;this.val_value=v;this.hue_cursor_pos=(360-this.hue_value)/360*255;this.sat_cursor_pos=Math.round(255-255*this.sat_value);this.val_cursor_pos=this.val_value;this.update_color_box();};this.update_color_box=function(){var _23=new Array(this.hue_value,this.sat_value,this.val_value);var _24=hsv2rgb(_23);var _25="rgb("+_24[0]+","+_24[1]+","+_24[2]+")";this.hexcolor="#"+baseconverter(_24[0],10,16,2)+baseconverter(_24[1],10,16,2)+baseconverter(_24[2],10,16,2);try{if(self[this.change_update_function]){setTimeout(this.change_update_function+"(\""+this.hexcolor+"\")",100);}}catch(e){}if(this.color_value_box){this.color_value_box.innerHTML=this.hexcolor;}if(this.color_value_box.style){this.color_box.style.background=_25;}};if(_14){this.setrgb(_14);}else{this.setrgb("#ffffff");}color_selects[color_selects.length]=this;}function color_select_mousedown(_26){var _27=false;for(var l1=0;l1<color_selects.length;l1++){var ob=color_selects[l1];if(!ob.active){continue;}_27=true;if(mouse_x<ob.color_select_bounding_box[0]||mouse_y<ob.color_select_bounding_box[1]||mouse_x>(ob.color_select_bounding_box[0]+ob.color_select_bounding_box[2])||mouse_y>(ob.color_select_bounding_box[1]+ob.color_select_bounding_box[3])){scrolling=false;setTimeout("color_select_hide("+l1+")",200);}}if(_27&&_26){if(_26.cancelBubble){_26.cancelBubble=true;}else{if(_26.stopPropagation){_26.stopPropagation();}if(_26.preventDefault){_26.preventDefault();}}}}function color_select_hide(num){if(!scrolling){color_selects[num].hide();}else{scrolling=false;}}function color_select_hideall(){for(var l1=0;l1<color_selects.length;l1++){color_selects[l1].hide();}}function color_select_mouseup(){for(var l1=0;l1<color_selects.length;l1++){ob=color_selects[l1];ob.unfocus();scrolling=false;}}function get_mouse_coords(e){if(window.getSelection){mouse_x=e.pageX;mouse_y=e.pageY;}else{if(document.selection&&document.selection.createRange){if(document.documentElement.scrollTop){mouse_x=window.event.clientX+document.documentElement.scrollLeft-4;mouse_y=window.event.clientY+document.documentElement.scrollTop-4;}else{if(document.body){mouse_x=window.event.clientX+document.body.scrollLeft-4;mouse_y=window.event.clientY+document.body.scrollTop-4;}}}else{var str="";window.status="Sorry, event capture is not possible with your browser.";return;}}}function get_mouse_coords_old(e){if(window.event){mouse_x=window.event.clientX+document.body.scrollLeft;mouse_y=window.event.clientY+document.body.scrollTop;}else{mouse_x=e.pageX;mouse_y=e.pageY;}}function color_select_update(_30){var _31=false;for(var l1=0;l1<color_selects.length;l1++){ob=color_selects[l1];if(ob.active){_31=true;}ob.sv_update();ob.hue_cursor_to_color();}if(_30&&_31){if(_30.cancelBubble){_30.cancelBubble=true;}else{if(_30.stopPropagation){_30.stopPropagation();}if(_30.preventDefault){_30.preventDefault();}}}}function findowner(evt){if(evt.target){return evt.target;}else{if(evt.srcElement){return evt.srcElement;}else{return null;}}}function baseconverter(_34,ob,nb,_37){_34+="";_34=_34.toUpperCase();var _38="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";var dec=0;for(var i=0;i<=_34.length;i++){dec+=(_38.indexOf(_34.charAt(i)))*(Math.pow(ob,(_34.length-i-1)));}_34="";var _3b=Math.floor((Math.log(dec))/(Math.log(nb)));for(var i=_3b;i>=0;i--){var _3d=Math.floor(dec/Math.pow(nb,i));_34=_34+_38.charAt(_3d);dec-=_3d*(Math.pow(nb,i));}var _3e=_34.length;if(_3e<_37){for(var i=0;i<_37-_3e;i++){_34="0"+_34;}}return _34;}function docjslib_getRealTop(_40){yPos=_40.offsetTop;tempEl=_40.offsetParent;while(tempEl!=null){yPos+=tempEl.offsetTop;tempEl=tempEl.offsetParent;}return yPos;}function docjslib_getRealLeft(_41){xPos=_41.offsetLeft;tempEl=_41.offsetParent;while(tempEl!=null){xPos+=tempEl.offsetLeft;tempEl=tempEl.offsetParent;}return xPos;}function rgb2hsv(rgb){var r=rgb[0];var g=rgb[1];var b=rgb[2];var h;var s;var v=Math.max(Math.max(r,g),b);var min=Math.min(Math.min(r,g),b);var _4a=v-min;if(v==0){s=0;}else{s=_4a/v;}if(s==0){h=0;}else{if(r==v){h=60*(g-b)/_4a;}else{if(g==v){h=120+60*(b-r)/_4a;}else{if(b==v){h=240+60*(r-g)/_4a;}}}}if(h<0){h+=360;}return new Array(h,s,v);}function hsv2rgb(hsv){var h=hsv[0];var s=hsv[1];var v=hsv[2];var r;var g;var b;if(s==0){return new Array(v,v,v);}var _52;if(h==360){_52=0;}else{_52=h;}_52=_52/60;var i=Math.floor(_52);var f=_52-i;var p=v*(1-s);var q=v*(1-(s*f));var t=v*(1-(s*(1-f)));if(i==0){r=v;g=t;b=p;}if(i==1){r=q;g=v;b=p;}if(i==2){r=p;g=v;b=t;}if(i==3){r=p;g=q;b=v;}if(i==4){r=t;g=p;b=v;}if(i==5){r=v;g=p;b=q;}r=Math.round(r);g=Math.round(g);b=Math.round(b);return new Array(r,g,b);}function hex2rgb(h){h=h.replace(/#/,"");var r=Math.round(parseInt(h.substring(0,2),16));var g=Math.round(parseInt(h.substring(2,4),16));var b=Math.round(parseInt(h.substring(4,6),16));var _5c=new Array(r,g,b);return _5c;}function move_test(){alert("move test");}function color_select_unfocus(){for(var l1=0;l1<color_selects.length;l1++){ob=color_selects[l1];ob.unfocus();}}function cs_select_disable(){for(var l1=0;l1<color_selects.length;l1++){ob=color_selects[l1];if(ob.select_disable()){return false;}}}if(document.attachEvent){document.attachEvent("onmousedown",color_select_mousedown);document.attachEvent("onmouseup",color_select_mouseup);document.attachEvent("onmouseup",color_select_unfocus);document.attachEvent("onmousemove",get_mouse_coords);document.attachEvent("onmousemove",color_select_update);document.attachEvent("onselectstart",cs_select_disable);document.attachEvent("onscroll",set_scrolling);}else{document.addEventListener("scroll",set_scrolling,false);document.addEventListener("resize",color_select_mousedown,false);document.addEventListener("mousedown",color_select_mousedown,false);document.addEventListener("mouseup",color_select_mouseup,false);document.addEventListener("mousemove",get_mouse_coords,false);document.addEventListener("mousemove",color_select_update,false);document.addEventListener("resize",color_select_hideall,false);}