<!--

// functions to control scrolling of thumbnails

function scrollerObj(viewPortId, filmStripId, sliderObj, callback)
{
  scrollerObjs[viewPortId] = this;

  this.id         = viewPortId;
  this.scrollFunc = "scrollerObjs." + this.id;
  this.active     = false;
  this.stopped    = true;
  this.x          = 0;
  this.dir        = 1;
  this.endX       = 0;
  this.maxX       = 0;
  this.dx         = 0;
  this.totx       = 0;

  this.scrollTimerId = null;

  this.viewPortDiv  = null;
  this.filmStripDiv = null;
  this.mouseStart   = 0;

  this.callback  = callback;
  this.sliderObj = sliderObj;
  this.load(viewPortId, filmStripId);
};

scrollerObj.prototype.load = function(viewPortId, filmStripId)
{
  if (!document.getElementById)
    return;

  this.filmStripDiv = document.getElementById(filmStripId);
  this.viewPortDiv  = document.getElementById(viewPortId);

  this.filmStripDiv.style.left = this.x = 0;

  if (this.filmStripDiv.offsetWidth > this.viewPortDiv.offsetWidth)
    this.maxX = this.filmStripDiv.offsetWidth - this.viewPortDiv.offsetWidth;
  else
    this.maxX = 0;

  this.sizX = this.viewPortDiv.offsetWidth;
  this.offX = parseInt(this.viewPortDiv.style.left);

  this.ready = true;
}

scrollerObj.prototype.manualScroll = function(delta)
{
  var x = this.x + delta;
  
  if (x > 0) x = 0;

  if ( (delta < 0 && x > -this.maxX) || (delta >= 0 && x <= 0) )
  {
    this.x = x;
  }
  else
  {
    this.x = this.endX;
  }
  this.sliderObj.setValue(this.x * -1);
}

scrollerObj.prototype.manualScrollTo = function(x)
{
  this.x = x;
  
  this.filmStripDiv.style.left = (this.x)+"px";
}

scrollerObj.prototype.scrollByDx = function()
{
  var incr = (3 * this.dir);

  if (this.dir == -1)
  {
    if ((this.totx+incr) < this.dx) incr = this.dx - this.totx;
    this.scrollTimerId = null;
  }
  else
  {
    if ((this.totx+incr) > this.dx) incr = this.dx - this.totx;
  }

  var x = this.x + incr;

  if ( (this.dir == -1 && x > -this.maxX) || (this.dir == 1 && x < 0) )
  {
    this.x = x;
  }
  else
  {
    this.x = this.endX;
  }
  
  this.sliderObj.setValue(this.x * -1);
  
  this.totx += incr;

  if (this.dir == -1)
  {
    if (this.totx <= this.dx)
    {
    	if (this.scrollTimerId != null) clearTimeout(this.scrollTimerId);
    	this.scrollTimerId = null;
    	this.callback();
    	return;
    }
  }
  else
  {
    if (this.scrollTimerId != null) clearTimeout(this.scrollTimerId);
    this.scrollTimerId = null;
    if (this.totx >= this.dx) 
    {
    	this.callback();
    	return;
    }
  }

  this.scrollTimerId = window.setTimeout("scrollerObjs['"+this.id+"'].scrollByDx()", 5);
}

scrollerObj.prototype.endScroll = function()
{
  if (!this.ready)
    return;

  if (this.timerId)
    window.clearInterval(this.timerId);

  this.timerId = 0;
}
// -->
