

var actx = 0;          // actual x-position of slider - must be globally available
var speed = 100 ;       // steps in 100 milliseconds. Adjust for faster/slower movement
var pend ;              // there's a move pending

function slide_to(target) {
  // this function will be called "onmouseover" the target destination.
  // it will compute the vertical distance between the target destination
  // and the location, where the slider actually is.
  // if there is a difference, it will move the slider halfway towards the target
  // and call itself again after a time interval.

  window.clearTimeout(pend) ;     // just in case we change our mind and point to
                                  // another target before the slider has reached
                                  // its destination
  target_pos = document.getElementById(target).offsetLeft ;  // find the destination
  if(actx != target_pos) {                                   // if we aren't there
    var diff = target_pos - actx ;                           // calculate the difference
    actx += Math.ceil(diff/2) ;                              // move by half way
    document.getElementById("slider").style.left = actx + "px" ;
    pend = window.setTimeout("slide_to('" + target + "')",speed) ;
  }
}
