      /**
       * A javascript slider by Michael Morris
       * Requires Prototype.js & Scriptaculous.js (Effects)
       */
                           
      var Slider = Class.create({
  
        offsetLeft: 0,
        lWidth: 0,
        rWidth: 0,
        moving: false,
        lens: null,
        reel: null,
        
        initialize: function(lens, reel) {
          this.lens = $(lens);
          this.reel = $(reel);
          
          this.lWidth = this.lens.getWidth();
          this.rWidth = this.reel.getWidth();
        },
        
        move: function() {
          if (!this.moving) {
            if ((this.rWidth + this.offsetLeft) <= this.lWidth) {
              new Effect.Move('reel', { x: 0, y: 0, mode: 'absolute', beforeStart: this.moveStart.bind(this), afterFinish: this.moveEnd.bind(this) });
            } else {
              new Effect.Move('reel', { x: -200, y: 0, mode: 'relative', duration: 1, beforeStart: this.moveStart.bind(this), afterFinish: this.moveEnd.bind(this) });
            }
          }
        },
        
        moveBack: function() {
          if (!this.moving)
            if (this.offsetLeft != 0)
              new Effect.Move('reel', { x: 200, y: 0, mode: 'relative', beforeStart: this.moveStart.bind(this), afterFinish: this.moveEnd.bind(this) });
        },
        
        moveStart: function() {
          this.moving = true;
        },
        
        moveEnd: function() {
          this.moving = false;
          this.offsetLeft = this.reel.positionedOffset().left;
          this.rWidth = this.reel.getWidth();
          this.lWidth = this.lens.getWidth();
        }
        
      });

