function PictureSlider() {
  this.speed=1; 
  this.steps=1;
  this.timeoutHandler=0;
  this.sliderPaneId;
  this.innerSliderId;
  this.speedFaktor = 5;
  this.noScrollWidth = 60;


  this.scrollLeft = function(sp) {
    if(sp)
      this.speed = sp;
    var newpos=parseFloat(document.getElementById(this.innerSliderId).style.left);
    var m = eval(newpos + this.steps);

    if(newpos < 0) {
      document.getElementById(this.innerSliderId).style.left= m + "px";
      this.timeoutHandler=setTimeout("ps.scrollLeft()",this.speed);
    }
  }

  this.scrollRight = function(sp) {
    if(sp)
      this.speed = sp;
    var pw = document.getElementById(this.innerSliderId).offsetWidth;
    var ow = document.getElementById(this.sliderPaneId).offsetWidth;
    var newpos = parseFloat(document.getElementById(this.innerSliderId).style.left);
    if(eval(newpos + pw) > ow) {  
      newpos-=this.steps;
      document.getElementById(this.innerSliderId).style.left=newpos + "px";
      this.timeoutHandler=setTimeout("ps.scrollRight()",this.speed);
    }
  }

  this.totalLeft = function() {
    this.stop();
    document.getElementById(this.innerSliderId).style.left = "0px";
  }

  
  this.totalRight = function() {
    this.stop();
    var pw = document.getElementById(this.innerSliderId).offsetWidth;
    var ow = document.getElementById(this.sliderPaneId).offsetWidth;
    var newpos = ow - pw;
    document.getElementById(this.innerSliderId).style.left = newpos + "px";
  }

  this.scrollpan = function(evt) {
    evt = window.event || evt;
    pos = this.getCursorPosition(evt);
    len = document.getElementById(this.sliderPaneId).offsetWidth;
    if(pos < (len/2 - this.noScrollWidth)) {
      this.scrollLeft();
    } else if(pos > (len/2 + this.noScrollWidth)) {
      this.scrollRight();
    } 
  }

  this.getSpeed = function(evt) {
    evt = window.event || evt;
    pos = this.getCursorPosition(evt);
    len = document.getElementById(this.sliderPaneId).offsetWidth;
    if(pos < (len/2 - this.noScrollWidth)) {
      this.speed = (pos/this.speedFaktor).toFixed(0);
      if(this.speed < 1)
        this.speed = 1;
    } else if(pos > (len/2 + this.noScrollWidth)) {
      this.speed = ((pos - len)/this.speedFaktor * -1).toFixed(0);
      if(this.speed < 1)
        this.speed = 1;
    }
  }

  this.getCursorPosition = function(evt) {
    return evt.clientX - parseFloat(document.getElementById(this.sliderPaneId).offsetLeft);
  }
  
  this.stop = function() {
    clearTimeout(this.timeoutHandler); 
  }
}


