function diScroller(instance_name, obj, visible_width, real_width, distance)
{
  this.obj = _ge(obj);
  this.obj.style.position = 'relative';
  this.obj.style.left = '0px';
  this.obj.style.top = '0px';
  this.obj.style.width = real_width+'px';

  this.instance_name = instance_name;
  this.visible_width = visible_width;

  this.default_step = 3;
  this.step = this.default_step;
  this.timeout = 4;
  this.timer_up = null;
  this.timer_down = null;

  this.timer_auto = null;

  this.busy = false;

  this.auto_busy = false;
  this.auto_mode_on = false;
  this.auto_timeout = 15 * 1000;

  if (typeof distance == 'undefined')
    var distance = 0;
  this.distance = distance;
  this.next_left_for_move_left = false;
  this.next_left_for_move_right = false;

  this.top = function()
  {
    this.obj.scrollTop = 0;
  }

  this.bottom = function()
  {
    this.obj.scrollTop = this.obj.scrollHeight;
  }

  this.left = function()
  {
    this.obj.scrollLeft = 0;
  }

  this.right = function()
  {
    this.obj.scrollLeft = this.obj.scrollWidth;
  }

  this.move_up = function()
  {
    this.obj.scrollTop -= this.step;
    this.timer_up = setTimeout(this.instance_name+'.move_up()', this.timeout);
  }

  this.move_down = function()
  {
    this.obj.scrollTop += this.step;
    this.timer_down = setTimeout(this.instance_name+'.move_down()', this.timeout);
  }

  this.move_left = function(distance, auto)
  {
    //if (this.busy) return false;

    if (typeof distance == 'undefined')
      var distance = false;
    else
      distance *= 1;

    if (typeof auto == 'undefined')
      var auto = false;

    if (!auto)
      this.stop_auto();

    if (this.next_left_for_move_left)
    {
      this.obj.style.left = this.next_left_for_move_left+'px';
      this.next_left_for_move_left = false;
    }

    var l = parseInt(this.obj.style.left);

    if (l >= 0)
    {
      if (this.distance)
        this.next_left_for_move_left = - this.distance * 2;

      this.busy = false;
      return false;
    }

    if (distance !== false)
    {
      if (distance <= 0)
      {
        clearTimeout(this.timer_left);
        this.busy = false;
        return false;
      }

      distance -= this.step;
    }

    this.obj.style.left = (l + this.step)+'px';
    this.busy = true;
    this.timer_left = setTimeout(this.instance_name+'.move_left('+distance+','+auto+')', this.timeout);
  }

  this.move_right = function(distance, auto)
  {
    //if (this.busy) return false;

    if (typeof distance == 'undefined')
      var distance = false;
    else
      distance *= 1;

    if (typeof auto == 'undefined')
      var auto = false;

    if (!auto)
      this.stop_auto();

    if (this.next_left_for_move_right)
    {
      this.obj.style.left = this.next_left_for_move_right+'px';
      this.next_left_for_move_right = false;
    }

    var l = parseInt(this.obj.style.left);

    if (l <= this.visible_width - this.obj.offsetWidth)
    {
      if (this.distance)
        this.next_left_for_move_right = this.distance;

      this.busy = false;
      return false;
    }

    if (distance !== false)
    {
      if (distance <= 0)
      {
        clearTimeout(this.timer_right);
        this.busy = false;
        return false;
      }

      distance -= this.step;
    }

    this.obj.style.left = (l - this.step)+'px';
    this.busy = true;
    this.timer_right = setTimeout(this.instance_name+'.move_right('+distance+','+auto+')', this.timeout);
  }

  this.point = function(x, y)
  {
    this.obj.scrollLeft = x;
    this.obj.scrollTop = y;
  }

  this.stop = function()
  {
    clearTimeout(this.timer_up);
    clearTimeout(this.timer_down);
    clearTimeout(this.timer_left);
    clearTimeout(this.timer_right);
  }

  this.start_auto = function(distance)
  {
    if (typeof distance == 'undefined' || !distance)
      return false;

    this.timer_auto = setInterval(this.instance_name+'.move_right('+distance+',1)', this.auto_timeout);
    this.auto_mode_on = true;
  }

  this.stop_auto = function()
  {
    clearInterval(this.timer_auto);
    this.auto_mode_on = false;
  }
}
