
/*
 * NOTE:
 * a very specialized version of Scroller(); hacked for a specific implementation,
 * and should not be used as the official version.  
 * buzz spasquali@blastradius.com for proper Scroller() object;
 *
 */

var $SCROLL_PATH = new Array();

function Scroller()
  {
    this.targX = 0;
    this.curX = 0;
    this.marX = 0; // left margin
    this.factor = .002;
    this.easing = 'start'; // 'start' || 'end';
//-------------------------------------------------- SetFactor
    this.SetFactor = function(fct)
      {
        this.factor = fct || this.factor;
        return;
      }
//-------------------------------------------------- SetEasing
    this.SetEasing = function(ea)
      {
        this.easing
          = (ea == 'start') ? 'start'
          : (ea == 'end') ? 'end'
          : 'none';
        return;
      }
//-------------------------------------------------- MoveTo
    this.MoveTo = function(targX)
      {
        $SCROLL_PATH = new Array();
        this.targX = targX 
        var ST = 1;
        while(this.curX != this.targX)
          {
            ST= Math.ceil(((this.targX > this.curX) ? this.targX - this.curX : this.curX - this.targX)*this.factor)
            this.curX = (this.targX > this.curX) ? Math.min(this.curX + ST,this.targX) : Math.max(this.curX - ST,this.targX); 
            $SCROLL_PATH[$SCROLL_PATH.length] = this.curX;
          }
        runPath(0);
        return;
      }
    return;
  }

function runPath(stp)
  {
    clearTimeout(parent.$SCROLL_TIMER);
    if($SCROLL_PATH[stp])
      {
        if(document.all) { window.scrollTo($SCROLL_PATH[stp]); }
        else { document.SCRLAYER.left = -$SCROLL_PATH[stp]; }
        setTimeout("runPath(" + (++stp) + ")",parent.$SCROLL_SPEED);
      }
    else { parent.signalEndScroll(); }
    return;
  }
