function Slider(sliderObject) {
   var i = 0;
   var a;
   
   this.sliderTimeout = 15;
   this.sliderStep = 10;
   
   this.sliderObject = sliderObject.parentNode;
   this.sliderSize = parseInt(sliderObject.offsetHeight);
   this.sliderButton = 0;
   this.sliders = Array();
   
   a = this.sliderObject.getElementsByTagName('DIV');
   for (i=0;i<a.length;i++) {
      if (a[i].getAttribute('sliderButton')!= null) {
         this.sliders[this.sliders.length] = a[i];
      }
   } 
   
   if (this.sliders.length <= 1) {
      return;
   }

   this.sliderButton = (this.sliderObject.offsetHeight - this.sliderSize)/(this.sliders.length-1);  

   // ** These functions are application-dependent, and must be changed 
   this.sliderMark = function (obj, mark) {
      var img = obj.getElementsByTagName('IMG')[0];
 
      if (obj.getAttribute("basename") == null) {
         calculateBasename(obj);
      }
   
      img.src = obj.getAttribute("basedir") + (mark ? "butSliderOpen" : "butSliderClosed") + "." + obj.getAttribute("baseext");
   }

   this.getMark = function (obj) {
      var img = obj.getElementsByTagName('IMG')[0];
 
      calculateBasename(obj);
      return (obj.getAttribute("basename")=="butSliderOpen");
   }


   this.slide = function (obj) {
      var i=0;
      var found = false; 
   
      /* Calculates target positions */   
      while (i<this.sliders.length) {
         if (found) {
            this.sliders[i].setAttribute('sliderTargetPos', this.sliderSize + ((i-1) * this.sliderButton));
         } else {
            this.sliders[i].setAttribute('sliderTargetPos', i * this.sliderButton);
         }
          
         if ((!found) && (this.sliders[i] == obj)) {
            found = true;
            
            /* if this is clicked and not the first, revert to previous */
            if ((this.getMark(document.getElementById(this.sliders[i].getAttribute('sliderButton')))) && (i!=0)) {
               i--;   
            }      
                  
            this.sliderMark(document.getElementById(this.sliders[i].getAttribute('sliderButton')), true);                        
         } else {
            this.sliderMark(document.getElementById(this.sliders[i].getAttribute('sliderButton')), false);
         }
         i++;
      }

      if (this.sliders.length > 1) {
         this.move();
      } 
   }
   
   this.move = function () {
      var finished = true;
      var pos, targetPos;
   
      for (i=0;i<this.sliders.length;i++) {
         pos = parseInt(this.sliders[i].style.top);
         targetPos = parseInt(this.sliders[i].getAttribute('sliderTargetPos'));
         
         if (pos < targetPos) {
            pos = pos + this.sliderStep;
            if (pos > targetPos) {
               pos = targetPos;
            }
         } 
         
         if (pos > targetPos) {
            pos = pos - this.sliderStep;
            if (pos < targetPos) {
               pos = targetPos;
            }
         }
      
         if (pos != targetPos) {
            finished = false;
         }   
         
         this.sliders[i].style.top = Number(pos).toString() + 'px';
      }
      
      if (!finished) {
         window.setTimeout("sliderMove('" + this.sliderObject.id + "');", this.sliderTimeout);
      } 
   }
}

function sliderMove(id) {
   var sliderObject = new Slider(document.getElementById(id).getElementsByTagName('DIV')[0]);
   
   sliderObject.move();
}

function slide(obj) {
   var sliderObject;
   
   // Finds the parent
   while ((obj != document) && (obj.getAttribute('sliderButton') == null)) {
      obj = obj.parentNode;
   }
   
   if (obj == document) {
      return false;
   }
   
   sliderObject = new Slider(obj);
   sliderObject.slide(obj);
   
   return false;
}
