function SliderWindow(sliderObject) {
   var i = 0;
   
   this.sliderContainer = sliderObject.parentNode.parentNode;
   this.sliderTimeout = 30;
   this.sliderStep = 10;
   this.sliderDelay = 2000;
   
   this.sliderObject = sliderObject;
   this.sliderSize = sliderObject.offsetHeight;
   this.sliderStartPos = (this.sliderContainer.offsetHeight / 2) - this.sliderSize; 
   
   this.slide = function () {
      var thread;
      var startpos;
      
      // resets
      this.sliderObject.style.top = Number(this.sliderStartPos).toString() + 'px';
      this.sliderObject.setAttribute('sliderTargetPos', this.sliderStartPos + this.sliderSize);
      this.sliderContainer.style.visibility = 'visible';

      thread = this.sliderObject.getAttribute('slidingThread');
      if (thread != null) {
         thread = parseInt(thread) + 1;
      } else {
         thread = 0;
      }
      this.sliderObject.setAttribute('slidingThread', thread);
      this.move(thread);
   }
   
   this.move = function (thread) {
      var pos, targetPos, currthread;

      currthread = parseInt(this.sliderObject.getAttribute('slidingThread'));
       
      if (thread != currthread) {
         return;
      }
      
      pos = parseInt(this.sliderObject.style.top);
      targetPos = parseInt(this.sliderObject.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) {
         window.setTimeout("sliderWindowMove('" + this.sliderObject.id + "', " + currthread + ");", this.sliderTimeout);
     } else {
         if (pos != this.sliderStartPos) {
            this.sliderObject.setAttribute('sliderTargetPos', this.sliderStartPos);
            window.setTimeout("sliderWindowMove('" + this.sliderObject.id + "', " + currthread + ");", this.sliderDelay);
         }  else {
            this.sliderContainer.style.visibility = 'hidden';
         }        
     }
     
     this.sliderObject.style.top = Number(pos).toString() + 'px';
   }
}

function sliderWindowMove(id, thread) {
   var sliderObject = new SliderWindow(document.getElementById(id));
   sliderObject.move(thread);
}

function slideWindow(id) {
   var sliderObject;
   
   sliderObject = new SliderWindow(document.getElementById(id));
   sliderObject.slide();
   
   return false;
}
