function getParentLeft(obj){if(obj==document.body)return obj.offsetLeft;else return obj.offsetLeft+getParentLeft(obj.parentNode)}function pbMove(e,obj,that){var objLeft=getParentLeft(obj);var objWidth=obj.clientWidth;if(objWidth==0)objWidth="-1";var x=e.clientX;var pos=x-objLeft;if(pos<0)pos=0;if(pos>objWidth)pos=objWidth;var p=pos/objWidth;that.p=p;that.value=that.p_min*1+Math.round((that.p_max-that.p_min)*p);that.onChangeFN(that.value);that.drawSlider();return false}function setSlider(obj,p){}
var drawSlider=function drawSlider(){this.c2D=this.canvas.getContext("2d");this.c2D.fillStyle=""+this.p_bgcolor;this.c2D.fillRect(0,0,this.width,this.height);this.c2D.fillStyle=""+this.p_color;var d=Math.abs(this.p-this.p_draw);var smooth=0.5;if(this.p_draw<this.p)this.p_draw+=d*smooth;if(this.p_draw>this.p)this.p_draw-=d*smooth;this.c2D.fillRect(0,0,this.width*this.p_draw,this.height);this.c2D.fillStyle="rgba(220,0,0,1)";this.c2D.fillRect(this.width*this.p_draw-1,0,1,this.height);this.desc.textContent=
""+Math.round(this.p_min*1+this.p_draw*(this.p_max-this.p_min))+this.p_jed};var refreshSlider=function refreshSlider(){this.height=this.obj.clientHeight;if(this.width<1)this.width=1;this.width=this.obj.clientWidth;if(this.width<10)this.width=10;this.canvas.width=this.width;this.canvas.height=this.height;this.desc.textContent="r"+this.p+this.p_jed;this.p=(this.value*1-this.p_min*1)/(this.p_max*1-this.p_min*1);this.p_draw=this.p};
function makeSlider(domID,onChangeFN){this.obj=document.getElementById(domID);this.pbMove=pbMove;this.refreshSlider=refreshSlider;this.drawSlider=drawSlider;this.onChangeFN=onChangeFN;this.canvas=document.createElement("canvas");this.c2D=this.canvas.getContext("2d");this.c2D.font="15pt Calibri";this.canvas.style.width="100%";this.canvas.style.height="100%";this.desc=document.createElement("span");this.desc.className="pbd";this.desc.textContent="init";this.desc.style.width="100%";this.desc.style.height=
"100%";this.obj.appendChild(this.desc);this.obj.appendChild(this.canvas);this.p_min=this.obj.getAttribute("min");this.p_max=this.obj.getAttribute("max");this.p_value=this.obj.getAttribute("value");this.p_jed=this.obj.getAttribute("jed");this.p_bgcolor=this.obj.getAttribute("bgcolor");this.p_fcolor=this.obj.getAttribute("fcolor");this.p_color=this.obj.getAttribute("color");this.p_width=this.obj.getAttribute("width");this.p_height=this.obj.getAttribute("height");this.value=this.p_value;this.p=(this.p_value*
1-this.p_min*1)/(this.p_max*1-this.p_min*1);this.refreshSlider();this.drawSlider();var that=this;attachEvent(this.obj,"pop",function(e,obj){that.pbMove(e,obj,that)});attachEvent(this.obj,"hover",function(e,obj){that.pbMove(e,obj,that)});attachEvent(this.obj,"tap",function(e,obj){that.pbMove(e,obj,that)});return this};
