function initArea(area, bar, handle) {
  initArea(area, bar, handle, 'no')
}

function initArea(area, bar, handle, areaname) {
  display = getLayer(area);
  if (handle !='no')  display.scrollhandle = getLayer(handle);
	else {
		display.scrollhandle=new Object();
		display.scrollhandle.getHeight=_getZero;
		display.scrollhandle.getWidth=_getZero;
		display.scrollhandle.ypos=0;
		display.scrollhandle.ymin=0;
		display.scrollhandle.ymax=500;
	}
  if (bar !='no')  display.scrollbar = getLayer(bar); 
	else display.scrollbar=new Object();

  display.globalname=areaname;
  display.hoehe=100; //höhe anzeigebereich
  display.breite=100; //breite anzeigebereich
  display.scrollIncrementY = 10; 
  display.scrollSteps=5; //scrollschritte pro displayhöhe
  display.scrollableHeight=0; //scrollbare höhe (contenthöhe - anzeigehöhe)

  display.scrollTo= _scrollTo;
  display.initScrolling= _initScrolling;
  display.scroll= _scroll;
  display.scrollUp= _scrollUp;
  display.scrollDown= _scrollDown;
  display.adjustContent= _adjustContent;
  display.initObjects= _initObjects;

  return display;
}

function _initObjects() {
  this.ymin = this.getTop();
  this.scrollTo(0);
  this.xmin = this.getLeft();
  this.initScrolling()
  //initDrag();
}

function _initScrolling() {
  this.visibility = HIDE;
  this.clipTo(0, 0, this.breite, this.hoehe);
  if (this.getHeight() <= this.hoehe) {
	this.scrollbar.visibility=HIDE;
	this.scrollhandle.visibility=HIDE;
	this.scrollIncrementY=10;
  }
  else {
	this.scrollableHeight=this.getHeight()-this.hoehe;
	this.scrollbar.visibility=SHOW;
	this.scrollhandle.visibility=SHOW;
	dh_part=this.scrollableHeight/this.hoehe*this.scrollSteps;
	this.scrollIncrementY=(this.scrollhandle.ymax-this.scrollhandle.ymin)/dh_part;
  }
  this.visibility = SHOW;
}



function _scroll(dy) {
  this.scrollhandle.ypos += dy;
  if (this.scrollhandle.ypos < this.scrollhandle.ymin) {
	this.scrollhandle.ypos = this.scrollhandle.ymin;
  }
  if (this.scrollhandle.ypos > this.scrollhandle.ymax) {
	this.scrollhandle.ypos = this.scrollhandle.ymax;
  }
  if (NS) this.scrollhandle.pageY = this.scrollhandle.ypos;
  if (IE) this.scrollhandle.top = this.scrollhandle.ypos;
  this.adjustContent();
  return false;
}


function _scrollUp() {
if (this.globalname !='no') for(i=0;i<25;i++) setTimeout(this.globalname+'.scroll(-'+this.scrollIncrementY/25+')',30*i);
else this.scroll(-this.scrollIncrementY);
}

function _scrollDown() {
if (this.globalname !='no') for(i=0;i<25;i++) setTimeout(this.globalname+'.scroll('+this.scrollIncrementY/25+')',30*i);
else this.scroll(this.scrollIncrementY);
}

function _scrollTo(val) {
  if (this.getHeight()< this.hoehe) return;
	this.scrollhandle.ypos = val;
	this.scroll(0);
}

function _adjustContent() {
  if (this.getHeight()< this.hoehe) return;
  var dy = this.scrollableHeight * (this.scrollhandle.ypos - this.scrollhandle.ymin)/(this.scrollhandle.ymax - this.scrollhandle.ymin);
  this.moveTo(this.getLeft(),this.ymin-dy);
  this.clipTo(0, dy, this.breite, this.hoehe);
}




function _getZero() {return 0;}


