
function vbsInit() {
  if (this.initOk) return true;
  this.boxContainer=this.getObj(this.name+'Container');
  this.boxContent=this.getObj(this.name+'Content');
  this.vpos=0;
  this.speed=0;
  this.hlimit=this.boxContainer.offsetHeight-this.boxContent.offsetHeight;
  this.enabled=(this.hlimit<0);
  this.initOk=true;
  this.timer=null;
}

function vbsGetElementById(anid) {
  return document.getElementById(anid);
}

function vbsScrollDo() {
  if (this.speed==0 || !this.enabled) return;
  if (this.vpos>0 || this.vpos<this.hlimit) return this.stop();
  this.vpos+=this.speed;
  this.boxContent.style.top=this.vpos+'px';
  /*var o=document.getElementById('scrollDebug');
  if (o) o.innerHTML=this.scrollTimout;*/
  this.timer=setTimeout(this.objName+".scroll()",this.scrollTimout);
}

function vbsScrollStart() {
  this.scroll();
}

function vbsScrollStop() {
  this.speed=0;
  if (this.vpos>0) this.vpos=0;
  if (this.vpos<this.hlimit) this.vpos=this.hlimit;
  clearTimeout(this.timer)
  this.timer=null;
}

function vbsScrollDown() {
  if (!this.initOk) this.init();
  this.speed=-this.scrollSpeed;
  this.start();
}

function vbsScrollUp() {
  if (!this.initOk) this.init();
  this.speed=this.scrollSpeed;
  this.start();
}

function verticalBlocScroller(aname,anObjName) {
  this.name=aname;
  this.objName=anObjName;
  this.init=vbsInit;
  this.getObj=vbsGetElementById;
  this.down=vbsScrollDown;
  this.up=vbsScrollUp;
  this.scroll=vbsScrollDo;
  this.start=vbsScrollStart;
  this.stop=vbsScrollStop;
  this.scrollSpeed=2;
  this.scrollTimout=20;
}


