function ScrollPane(name, xwin, ywin, wwin, hwin, xscroll, yscroll)
{
  this.layer = new Layer(name);
  this.xwin = xwin;
  this.ywin = ywin;
  this.wwin = wwin;
  this.hwin = hwin;
  this.xscroll = xscroll ? xscroll : 0;
  this.yscroll = yscroll ? yscroll : 0;
  
  this.scroll = ScrollPaneScroll;
  this.move = ScrollPaneMove;
  
  this.xmax = this.layer.width - wwin;
  if(this.xmax < 0) this.xmax = 0;
  this.ymax = this.layer.height - hwin;
  if(this.ymax < 0) this.ymax = 0;
  
  var xdest = this.xscroll;
  var ydest = this.yscroll;
  this.xscroll = -1;
  this.yscroll = -1;
  this.scroll(xdest, ydest);
  
  if(ie || ns4) this.images = this.layer.layer.document.images;
  else if(dom) this.images = document.images;
}

function ScrollPaneScroll(xdest, ydest)
{
  if(xdest < 0) xdest = 0;
  else if(xdest > this.xmax) xdest = this.xmax;
  if(ydest < 0) ydest = 0;
  else if(ydest > this.ymax) ydest = this.ymax;
  if(xdest == this.xscroll && ydest == this.yscroll) return;
  
  this.xscroll = xdest;
  this.yscroll = ydest;
  
  this.layer.move(this.xwin - this.xscroll, this.ywin - this.yscroll);
  this.layer.setClip(this.xscroll, this.yscroll, this.wwin, this.hwin);
}

function ScrollPaneMove(x, y)
{
  this.xwin = x;
  this.ywin = y;
  this.layer.move(this.xwin - this.xscroll, this.ywin - this.yscroll);
}

