/*
ASCII2MathML-SVGButtonsSilders.js v3.41, May 13th 2009
=====================================================================
Copyright Dr.ir. S.A. Miedema, www.Fullxml.org

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
(at http://www.gnu.org/licences/lgpl.html) for more details.
*/

//Start of Buttons
function createButton(p,q,id,rx,ry,label,buttontype,activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor) {
  var bl, tr, rt, rs, delta;
  var buttonpressed=false, buttonnode;
  if (activecolor!=null) {activecolor = activecolor.replace(/\*/g,"");} else {activecolor="#8DB6CD";}
  if (inactivecolor!=null) {inactivecolor = inactivecolor.replace(/\*/g,"");} else {inactivecolor="lightblue";}
  if (lightcolor!=null) {lightcolor = lightcolor.replace(/\*/g,"");} else {lightcolor="#CCCCCC";}
  if (shadowcolor!=null) {shadowcolor = shadowcolor.replace(/\*/g,"");} else {shadowcolor="#555555";}
  if (labelcolor!=null) {labelcolor = labelcolor.replace(/\*/g,"");} else {labelcolor="black";}
  bl = [p[0]*xunitlength+origin[0],p[1]*yunitlength+origin[1]];
  tr = [q[0]*xunitlength+origin[0],q[1]*yunitlength+origin[1]];
  rt = rx*xunitlength;
  rs =ry*yunitlength;
  delta=1;
  strokewidth=2;
  stroke=shadowcolor;
  mrect([bl[0]-delta,bl[1]-delta],[tr[0]+delta,tr[1]+delta],id+"_bottomright",rt,rs)
  stroke=lightcolor;
  mrect([bl[0]-delta,bl[1]+delta],[tr[0]-delta,tr[1]+delta],id+"_topleft",rt,rs)
  stroke=activecolor;
  strokewidth=1;
  fill=activecolor;
  mrect(bl,tr,id,rt,rs);
  buttonnode = doc.getElementById(id);
  buttonnode.setAttribute("onclick","try {button_click(evt,"+(p[0]+q[0])/2+","+(p[1]+q[1])/2+")} catch(e) {}");
  buttonnode.setAttribute("type",buttontype);
  fontfill=labelcolor;
  text([(p[0]+q[0])/2,(p[1]+q[1])/2],label,"middlemiddle",id+"_label");
  buttonnode.setAttribute("pressed",false);
  buttonnode.setAttribute("active",true);
  buttonnode.setAttribute("activecolor",activecolor);
  buttonnode.setAttribute("inactivecolor",inactivecolor);
  buttonnode.setAttribute("lightcolor",lightcolor);
  buttonnode.setAttribute("shadowcolor",shadowcolor);
  buttonnode.setAttribute("labelcolor",labelcolor);
  
  labelnode = doc.getElementById(id+"_label");
  labelnode.setAttribute("onclick","try {button_click(evt,"+(p[0]+q[0])/2+","+(p[1]+q[1])/2+")} catch(e) {}");
  labelnode.setAttribute("onmousemove","try {slider_moveV(evt);slider_moveH(evt);} catch(e) {}");
}

function updateButton(nodeid) {
  var buttonnode, labelnode, tlnode, brnode;
  var buttonpressed=false;
  var i = nodeid.indexOf("_");
  if (i>0) nodeid = nodeid.substring(0,i);
  buttonnode = doc.getElementById(nodeid);
  labelnode = doc.getElementById(nodeid+"_label");
  tlnode = doc.getElementById(nodeid+"_topleft");
  brnode = doc.getElementById(nodeid+"_bottomright");
  buttonpressed = buttonnode.getAttribute("pressed"); 
  if (buttonpressed=="false") {buttonpressed=false;} else {buttonpressed=true;} 
  var lightcolor = buttonnode.getAttribute("lightcolor");
  var shadowcolor = buttonnode.getAttribute("shadowcolor");
  if (buttonpressed) {tlnode.setAttribute("stroke",lightcolor);} else {tlnode.setAttribute("stroke",shadowcolor);}
  if (buttonpressed) {brnode.setAttribute("stroke",shadowcolor);} else {brnode.setAttribute("stroke",lightcolor);}
  var x = labelnode.getAttribute("x");
  var y = labelnode.getAttribute("y");
  if (buttonpressed) {
    labelnode.setAttribute("x",(x*1+2));
    labelnode.setAttribute("y",(y*1+2));
  } else {
    labelnode.setAttribute("x",(x*1-2));
    labelnode.setAttribute("y",(y*1-2));
  }
  if (buttonpressed) {buttonpressed=false;} else {buttonpressed=true;}
  buttonnode.setAttribute("pressed",buttonpressed);
}

function refreshButton(pictureid,nodeid) {
  switchTo(pictureid);
  var i = nodeid.indexOf("_");
  if (i>0) nodeid = nodeid.substring(0,i);
  var buttonnode = doc.getElementById(nodeid);
  var t = buttonnode.getAttribute("type");
  var active = buttonnode.getAttribute("active");
  if (active=="false") {active=false;} else {active=true;}
  if (active) {
    updateButton(nodeid);
    if (t=="click") setTimeout("updateButton('"+nodeid+"');",200);
  }
}

function activateButton(pictureid,nodeid) {
  switchTo(pictureid);
  var buttonnode = doc.getElementById(nodeid);
  buttonnode.setAttribute("active",true);
  var activecolor = buttonnode.getAttribute("activecolor");
  buttonnode.setAttribute("fill",activecolor);
}

function deactivateButton(pictureid,nodeid) {
  switchTo(pictureid);
  var buttonnode = doc.getElementById(nodeid);
  buttonnode.setAttribute("active",false);
  var inactivecolor = buttonnode.getAttribute("inactivecolor");
  buttonnode.setAttribute("fill",inactivecolor);
}
//End of Buttons

//Start of Sliders
function createSliderV(p,q,id,rx,ry,label,sliderxmargin,sliderymargin,sliderwidth,sliderheight,min,max,activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor,valuecolor) {
  var x, y, ymin, ymax, yinc, minvalue,maxvalue;
  if (min!=null) {minvalue=min;} else {minvalue=0;}
  if (max!=null) {maxvalue=max;} else {maxvalue=100;}
  if (activecolor!=null) {activecolor = activecolor.replace(/\*/g,"");} else {activecolor="#8DB6CD";}
  if (inactivecolor!=null) {inactivecolor = inactivecolor.replace(/\*/g,"");} else {inactivecolor="lightblue";}
  if (lightcolor!=null) {lightcolor = lightcolor.replace(/\*/g,"");} else {lightcolor="#CCCCCC";}
  if (shadowcolor!=null) {shadowcolor = shadowcolor.replace(/\*/g,"");} else {shadowcolor="#555555";}
  if (labelcolor!=null) {labelcolor = labelcolor.replace(/\*/g,"");} else {labelcolor="black";}
  if (valuecolor!=null) {valuecolor = valuecolor.replace(/\*/g,"");} else {valuecolor="red";}
  createButton(p,q,id+"_SliderBody",rx,ry,"","click",activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor);
  slidernode = doc.getElementById(id+"_SliderBody");
  slidernode.setAttribute("onmousemove","try {slider_moveV(evt)} catch(e) {}");
  ymin = p[1]+sliderymargin;
  ymax = q[1]-sliderymargin;
  yinc = (q[1]-p[1]-2*sliderymargin)/10;
  x = (p[0]+q[0])/2;
  fontfill=labelcolor;
  text([x,ymax+sliderymargin],label,"middlebelow");
  stroke="black";
  strokewidth=3;
  line([x,ymin],[x,ymax]);
  strokewidth=1;
  for (y = ymin; y<=ymax+0.001; y = y+yinc) {
    line([x-sliderxmargin,y],[x+sliderxmargin,y]);
    if (y+yinc/2<=ymax) line([x-sliderxmargin/2,y+yinc/2],[x+sliderxmargin/2,y+yinc/2]);
  }  
  stroke=valuecolor;
  strokewidth=3;
  line([x-sliderxmargin,ymin],[x+sliderxmargin,ymin],id+"_Ruler");
  var slx1 = x-sliderwidth/2;
  var slx2 = x+sliderwidth/2;
  var sly1 = sliderymargin-sliderheight/2;
  var sly2 = sliderymargin+sliderheight/2;
  sly1 = p[1]+sly1;
  sly2 = p[1]+sly2;
  strokewidth=1;
  createButton([slx1,sly1],[slx2,sly2],id+"_Slider",rx,ry,"","click",activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor);
  text([x,ymin-sliderheight/2],minvalue.toFixed(1),"middlebelow",id+"_ValueMin");
  text([x,ymax+sliderheight/2],maxvalue.toFixed(1),"middleabove",id+"_ValueMax");
  fontfill=valuecolor;
  text([x,ymin-sliderymargin],minvalue.toFixed(1),"middleabove",id+"_Value");
  fontfill=labelcolor;
  slidernode = doc.getElementById(id+"_Slider");
  slidernode.setAttribute("onmousemove","try {slider_moveV(evt)} catch(e) {}");
  slidernode.setAttribute("xmed",x);
  slidernode.setAttribute("ymin",ymin);
  slidernode.setAttribute("ymax",ymax);
  slidernode.setAttribute("sliderwidth",sliderwidth);
  slidernode.setAttribute("sliderheight",sliderheight);
  slidernode.setAttribute("sliderxmargin",sliderxmargin);
  slidernode.setAttribute("sliderymargin",sliderymargin);
  slidernode.setAttribute("radiusx",rx);
  slidernode.setAttribute("radiusy",ry);
  slidernode.setAttribute("value",min);
  slidernode.setAttribute("minvalue",minvalue);
  slidernode.setAttribute("maxvalue",maxvalue);
  slidernode.setAttribute("direction","vertical");
  slidernode.setAttribute("activecolor",activecolor);
  slidernode.setAttribute("inactivecolor",inactivecolor);
  slidernode.setAttribute("lightcolor",lightcolor);
  slidernode.setAttribute("shadowcolor",shadowcolor);
  slidernode.setAttribute("labelcolor",labelcolor);
  slidernode.setAttribute("valuecolor",valuecolor);
}

function refreshSliderV(pictureid,nodeid,XCoord,YCoord) {
  var slidernode, rulernode,x,y, ymin, ymax, sliderwidth, sliderheight, rx, ry, sliderxmargin,sliderymargin, value, minvalue, maxvalue, direction;
  var activecolor, inactivecolor, lightcolor, shadowcolor, labelcolor, valuecolor;
  switchTo(pictureid);
  slidernode = doc.getElementById(nodeid+"_Slider");
  x = slidernode.getAttribute("xmed")*1;
  ymin = slidernode.getAttribute("ymin")*1;
  ymax = slidernode.getAttribute("ymax")*1;
  sliderwidth = slidernode.getAttribute("sliderwidth")*1;
  sliderheight = slidernode.getAttribute("sliderheight")*1;
  sliderxmargin = slidernode.getAttribute("sliderxmargin")*1;
  sliderymargin = slidernode.getAttribute("sliderymargin")*1;
  rx = slidernode.getAttribute("radiusx");
  ry = slidernode.getAttribute("radiusy");
  value = slidernode.getAttribute("value");
  minvalue = slidernode.getAttribute("minvalue")*1;
  maxvalue = slidernode.getAttribute("maxvalue")*1;
  activecolor = slidernode.getAttribute("activecolor");
  inactivecolor = slidernode.getAttribute("inactivecolor");
  lightcolor = slidernode.getAttribute("lightcolor");
  shadowcolor = slidernode.getAttribute("shadowcolor");
  labelcolor = slidernode.getAttribute("labelcolor");
  valuecolor = slidernode.getAttribute("valuecolor");
  direction = slidernode.getAttribute("direction");
  if (direction=="vertical") {
    var slx1 = x-sliderwidth/2;
    var slx2 = x+sliderwidth/2;
    var sly1 = YCoord-sliderheight/2;
    var sly2 = YCoord+sliderheight/2;
    if (YCoord>=ymin && YCoord<=ymax )
    createButton([slx1,sly1],[slx2,sly2],nodeid+"_Slider",rx,ry,"","click",activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor);
    stroke=valuecolor;
    strokewidth=3;
    if (YCoord>=ymin && YCoord<=ymax)
    line([x-sliderxmargin,YCoord],[x+sliderxmargin,YCoord],nodeid+"_Ruler");
    y = ymin-sliderymargin;
    if (YCoord>=ymin && YCoord<=ymax) {
      value = (YCoord-ymin)/(ymax-ymin)*100;
      if (value<0.3) value=0;
      if (value>99.7) value=100;
      value = minvalue+value/100*(maxvalue-minvalue);
      value = value.toFixed(1);
      slidernode.setAttribute("value",value);
      fontfill=valuecolor;
      text([x,y],value,"middleabove",nodeid+"_Value");
      fontfill=labelcolor;
    }
    return value;
  }
}

function setSliderV(pictureid,nodeid,setvalue) {
  var slidernode, rulernode,x,y, ymin, ymax, sliderwidth, sliderheight, rx, ry, sliderxmargin,sliderymargin, value, minvalue, maxvalue, direction;
  var activecolor, inactivecolor, lightcolor, shadowcolor, labelcolor, valuecolor;
  var XCoord, YCoord;
  switchTo(pictureid);
  slidernode = doc.getElementById(nodeid+"_Slider");
  x = slidernode.getAttribute("xmed")*1;
  ymin = slidernode.getAttribute("ymin")*1;
  ymax = slidernode.getAttribute("ymax")*1;
  sliderwidth = slidernode.getAttribute("sliderwidth")*1;
  sliderheight = slidernode.getAttribute("sliderheight")*1;
  sliderxmargin = slidernode.getAttribute("sliderxmargin")*1;
  sliderymargin = slidernode.getAttribute("sliderymargin")*1;
  rx = slidernode.getAttribute("radiusx");
  ry = slidernode.getAttribute("radiusy");
  value = slidernode.getAttribute("value");
  minvalue = slidernode.getAttribute("minvalue")*1;
  maxvalue = slidernode.getAttribute("maxvalue")*1;
  activecolor = slidernode.getAttribute("activecolor");
  inactivecolor = slidernode.getAttribute("inactivecolor");
  lightcolor = slidernode.getAttribute("lightcolor");
  shadowcolor = slidernode.getAttribute("shadowcolor");
  labelcolor = slidernode.getAttribute("labelcolor");
  valuecolor = slidernode.getAttribute("valuecolor");
  direction = slidernode.getAttribute("direction");
  if (direction=="vertical") {
    YCoord = (setvalue-minvalue)/(maxvalue-minvalue)*(ymax-ymin)+ymin
    var slx1 = x-sliderwidth/2;
    var slx2 = x+sliderwidth/2;
    var sly1 = YCoord-sliderheight/2;
    var sly2 = YCoord+sliderheight/2;
    if (YCoord>=ymin && YCoord<=ymax )
    createButton([slx1,sly1],[slx2,sly2],nodeid+"_Slider",rx,ry,"","click",activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor);
    stroke=valuecolor;
    strokewidth=3;
    if (YCoord>=ymin && YCoord<=ymax)
    line([x-sliderxmargin,YCoord],[x+sliderxmargin,YCoord],nodeid+"_Ruler");
    y = ymin-sliderymargin;
    if (YCoord>=ymin && YCoord<=ymax) {
      value = (YCoord-ymin)/(ymax-ymin)*100;
      if (value<0.3) value=0;
      if (value>99.7) value=100;
      value = minvalue+value/100*(maxvalue-minvalue);
      value = value.toFixed(1);
      slidernode.setAttribute("value",value);
      fontfill=valuecolor;
      text([x,y],value,"middleabove",nodeid+"_Value");
      fontfill=labelcolor;
    }
    return value;
  }
}

function createSliderH(p,q,id,rx,ry,label,sliderxmargin,sliderymargin,sliderwidth,sliderheight,min,max,activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor,valuecolor) {
  var x, xmin, xmax, xinc, xmed, y, ymin, ymax, yinc, ymed, minvalue,maxvalue;
  if (min!=null) {minvalue=min;} else {minvalue=0;}
  if (max!=null) {maxvalue=max;} else {maxvalue=100;}
  if (activecolor!=null) {activecolor = activecolor.replace(/\*/g,"");} else {activecolor="#8DB6CD";}
  if (inactivecolor!=null) {inactivecolor = inactivecolor.replace(/\*/g,"");} else {inactivecolor="lightblue";}
  if (lightcolor!=null) {lightcolor = lightcolor.replace(/\*/g,"");} else {lightcolor="#CCCCCC";}
  if (shadowcolor!=null) {shadowcolor = shadowcolor.replace(/\*/g,"");} else {shadowcolor="#555555";}
  if (labelcolor!=null) {labelcolor = labelcolor.replace(/\*/g,"");} else {labelcolor="black";}
  if (valuecolor!=null) {valuecolor = valuecolor.replace(/\*/g,"");} else {valuecolor="red";}
  createButton(p,q,id+"_SliderBody",rx,ry,"","click",activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor);
  slidernode = doc.getElementById(id+"_SliderBody");
  slidernode.setAttribute("onmousemove","try {slider_moveH(evt)} catch(e) {}");
  xmin = p[0]+sliderxmargin;
  xmax = q[0]-sliderxmargin;
  xinc = (q[0]-p[0]-2*sliderxmargin)/10;
  xmed = (p[0]+q[0])/2;

  ymin = (p[1]+q[1])/2-sliderymargin;
  ymax = (p[1]+q[1])/2+sliderymargin;
  yinc = (q[1]-p[1]-2*sliderymargin)/10;
  ymed = (p[1]+q[1])/2;

  fontfill=labelcolor;
  text([xmed,ymax],label,"middleabove");
  stroke="black";
  strokewidth=3;
  line([xmin,ymed],[xmax,ymed]);
  strokewidth=1;
  for (x = xmin; x<=xmax*1.001; x = x+xinc) {
    line([x,ymed-sliderymargin],[x,ymed+sliderymargin]);
    if (x+xinc/2<=xmax) line([x+xinc/2,ymed-sliderymargin/2],[x+xinc/2,ymed+sliderymargin/2]);
  }  
  stroke=valuecolor;
  strokewidth=3;
  line([xmin,ymed-sliderymargin],[xmin,ymed+sliderymargin],id+"_Ruler");
  var slx1 = xmin-sliderwidth/2;
  var slx2 = xmin+sliderwidth/2;
  var sly1 = ymed-sliderheight/2;
  var sly2 = ymed+sliderheight/2;
  strokewidth=1;
  createButton([slx1,sly1],[slx2,sly2],id+"_Slider",rx,ry,"","click",activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor);
  text([xmin,ymin],minvalue.toFixed(1),"middlebelow",id+"_ValueMin");
  text([xmax,ymin],maxvalue.toFixed(1),"middlebelow",id+"_ValueMax");
  fontfill=valuecolor;
  text([xmed,ymin],minvalue.toFixed(1),"middlebelow",id+"_Value");
  fontfill=labelcolor;

  slidernode = doc.getElementById(id+"_Slider");
  slidernode.setAttribute("onmousemove","try {slider_moveH(evt)} catch(e) {}");
  slidernode.setAttribute("xmed",xmed);
  slidernode.setAttribute("xmin",xmin);
  slidernode.setAttribute("xmax",xmax);
  slidernode.setAttribute("ymed",ymed);
  slidernode.setAttribute("ymin",ymin);
  slidernode.setAttribute("ymax",ymax);
  slidernode.setAttribute("sliderwidth",sliderwidth);
  slidernode.setAttribute("sliderheight",sliderheight);
  slidernode.setAttribute("sliderxmargin",sliderxmargin);
  slidernode.setAttribute("sliderymargin",sliderymargin);
  slidernode.setAttribute("radiusx",rx);
  slidernode.setAttribute("radiusy",ry);
  slidernode.setAttribute("value",min);
  slidernode.setAttribute("minvalue",minvalue);
  slidernode.setAttribute("maxvalue",maxvalue);
  slidernode.setAttribute("direction","horizontal");
  slidernode.setAttribute("activecolor",activecolor);
  slidernode.setAttribute("inactivecolor",inactivecolor);
  slidernode.setAttribute("lightcolor",lightcolor);
  slidernode.setAttribute("shadowcolor",shadowcolor);
  slidernode.setAttribute("labelcolor",labelcolor);
  slidernode.setAttribute("valuecolor",valuecolor);
}

function refreshSliderH(pictureid,nodeid,XCoord,YCoord) {
  var slidernode, rulernode, xmin, xmax, xmed, ymed, ymin, ymax, sliderwidth, sliderheight, rx, ry, sliderxmargin,sliderymargin, value, minvalue, maxvalue;
  var activecolor, inactivecolor, lightcolor, shadowcolor, labelcolor, valuecolor;
  switchTo(pictureid);
  slidernode = doc.getElementById(nodeid+"_Slider");
  xmed = slidernode.getAttribute("xmed")*1;
  xmin = slidernode.getAttribute("xmin")*1;
  xmax = slidernode.getAttribute("xmax")*1;
  ymed = slidernode.getAttribute("ymed")*1;
  ymin = slidernode.getAttribute("ymin")*1;
  ymax = slidernode.getAttribute("ymax")*1;
  sliderwidth = slidernode.getAttribute("sliderwidth")*1;
  sliderheight = slidernode.getAttribute("sliderheight")*1;
  sliderxmargin = slidernode.getAttribute("sliderxmargin")*1;
  sliderymargin = slidernode.getAttribute("sliderymargin")*1;
  rx = slidernode.getAttribute("radiusx");
  ry = slidernode.getAttribute("radiusy");
  value = slidernode.getAttribute("value");
  minvalue = slidernode.getAttribute("minvalue")*1;
  maxvalue = slidernode.getAttribute("maxvalue")*1;
  activecolor = slidernode.getAttribute("activecolor");
  inactivecolor = slidernode.getAttribute("inactivecolor");
  lightcolor = slidernode.getAttribute("lightcolor");
  shadowcolor = slidernode.getAttribute("shadowcolor");
  labelcolor = slidernode.getAttribute("labelcolor");
  valuecolor = slidernode.getAttribute("valuecolor");
  direction = slidernode.getAttribute("direction");
  if (direction=="horizontal") {
    var slx1 = XCoord-sliderwidth/2;
    var slx2 = XCoord+sliderwidth/2;
    var sly1 = ymed-sliderheight/2;
    var sly2 = ymed+sliderheight/2;
    if (XCoord>=xmin && XCoord<=xmax )
    createButton([slx1,sly1],[slx2,sly2],nodeid+"_Slider",rx,ry,"","click",activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor);
    stroke=valuecolor;
    strokewidth=3;
    if (XCoord>=xmin && XCoord<=xmax)
    line([XCoord,ymed-sliderymargin],[XCoord,ymed+sliderymargin],nodeid+"_Ruler");
    x = (xmin+xmax)/2;
    if (XCoord>=xmin && XCoord<=xmax) {
      value = (XCoord-xmin)/(xmax-xmin)*100;
      if (value<0.3) value=0;
      if (value>99.7) value=100;
      value = minvalue+value/100*(maxvalue-minvalue);
      value = value.toFixed(1);
      slidernode.setAttribute("value",value);
      fontfill=valuecolor;
      text([x,ymin],value,"middlebelow",nodeid+"_Value");
      fontfill=labelcolor;
    }
    return value;
  }
}

function setSliderH(pictureid,nodeid,setvalue) {
  var slidernode, rulernode, xmin, xmax, xmed, ymed, ymin, ymax, sliderwidth, sliderheight, rx, ry, sliderxmargin,sliderymargin, value, minvalue, maxvalue;
  var activecolor, inactivecolor, lightcolor, shadowcolor, labelcolor, valuecolor;
  var XCoord, YCoord;
  switchTo(pictureid);
  slidernode = doc.getElementById(nodeid+"_Slider");
  xmed = slidernode.getAttribute("xmed")*1;
  xmin = slidernode.getAttribute("xmin")*1;
  xmax = slidernode.getAttribute("xmax")*1;
  ymed = slidernode.getAttribute("ymed")*1;
  ymin = slidernode.getAttribute("ymin")*1;
  ymax = slidernode.getAttribute("ymax")*1;
  sliderwidth = slidernode.getAttribute("sliderwidth")*1;
  sliderheight = slidernode.getAttribute("sliderheight")*1;
  sliderxmargin = slidernode.getAttribute("sliderxmargin")*1;
  sliderymargin = slidernode.getAttribute("sliderymargin")*1;
  rx = slidernode.getAttribute("radiusx");
  ry = slidernode.getAttribute("radiusy");
  value = slidernode.getAttribute("value");
  minvalue = slidernode.getAttribute("minvalue")*1;
  maxvalue = slidernode.getAttribute("maxvalue")*1;
  activecolor = slidernode.getAttribute("activecolor");
  inactivecolor = slidernode.getAttribute("inactivecolor");
  lightcolor = slidernode.getAttribute("lightcolor");
  shadowcolor = slidernode.getAttribute("shadowcolor");
  labelcolor = slidernode.getAttribute("labelcolor");
  valuecolor = slidernode.getAttribute("valuecolor");
  direction = slidernode.getAttribute("direction");
  if (direction=="horizontal") {
    XCoord = (setvalue-minvalue)/(maxvalue-minvalue)*(xmax-xmin)+xmin
    var slx1 = XCoord-sliderwidth/2;
    var slx2 = XCoord+sliderwidth/2;
    var sly1 = ymed-sliderheight/2;
    var sly2 = ymed+sliderheight/2;
    if (XCoord>=xmin && XCoord<=xmax )
    createButton([slx1,sly1],[slx2,sly2],nodeid+"_Slider",rx,ry,"","click",activecolor,inactivecolor,lightcolor,shadowcolor,labelcolor);
    stroke=valuecolor;
    strokewidth=3;
    if (XCoord>=xmin && XCoord<=xmax)
    line([XCoord,ymed-sliderymargin],[XCoord,ymed+sliderymargin],nodeid+"_Ruler");
    x = (xmin+xmax)/2;
    if (XCoord>=xmin && XCoord<=xmax) {
      value = (XCoord-xmin)/(xmax-xmin)*100;
      if (value<0.3) value=0;
      if (value>99.7) value=100;
      value = minvalue+value/100*(maxvalue-minvalue);
      value = value.toFixed(1);
      slidernode.setAttribute("value",value);
      fontfill=valuecolor;
      text([x,ymin],value,"middlebelow",nodeid+"_Value");
      fontfill=labelcolor;
    }
    return value;
  }
}
//End of Sliders