n = (document.layers) ? 1:0;
canscroll=false;
scrolltimer=0;
scroll_up=scroll_left=1;
scroll_down=scroll_right=0;
divArray = new Array;

function ScrollDiv(binnen, bottomhash, resthoogte){
  if (!resthoogte) resthoogte=200;
  dummy = new MakeScrollDiv(binnen, bottomhash, resthoogte);
}

function ShowDiv(divnaam){
  dummy = new MakeShowDiv(divnaam);
}

function MakeShowDiv(divnaam){
   var thisnr = divArray.length;
   nestedarray = divnaam.split(",");
   binnen=nestedarray[nestedarray.length -1];
   eval('div'+binnen+'='+thisnr);
   if (n) {
      buiten='document.';
      for(i=0; i<=nestedarray.length -2; i++){
         buiten = buiten + 'layers.'+nestedarray[i]+'.document.';
      }
      this.showme=buiten+'layers.'+binnen+'.visibility';
    }else{
      this.showme=binnen+'.style.visibility';
   }
   divArray[thisnr] = this;
}

function MakeScrollDiv(divnaam, bottomhash, resthoogte){
   nestedarray = divnaam.split(",");
   var thisnr = divArray.length;
   binnen=nestedarray[nestedarray.length -1];
   eval('div'+binnen+'='+thisnr);
   if (n) {
      buiten='document.';
      for(i=0; i<=nestedarray.length -2; i++){
         buiten = buiten + 'layers.'+nestedarray[i]+'.document.';
      }
      this.divpad=buiten+'layers.'+binnen;
      this.showme=this.divpad+'.visibility';
      hulp = this.divpad+'.document.anchors["'+bottomhash+'"].y'
      this.scrolllimit=eval(hulp);
    }else{
      this.divpad=binnen;
      this.showme=this.divpad+'.style.visibility';
// 	 alert("bottomhash :" +bottomhash)
      this.scrolllimit=eval(bottomhash+'.offsetTop');
 //	 alert("bottomhash :" +document.all.bottomhashz.offsetTop)
 	// alert("bottomhash :" +bottomhashz.offsetTop)
  }
   this.top = 0;
   this.scrolllimit = this.scrolllimit - resthoogte;
   divArray[thisnr] = this;
}

function ScrollMe(updown,speed,constant, divnaam){
   if(scrolltimer) clearTimeout(scrolltimer);
   if (!canscroll) {
      return;
   }  
   if (!divnaam) {
      divnaam = 'div'+currentselect;
  }
   if (!constant) constant=1;
   var divnr = eval('div'+divnaam);
   var thistop = divArray[divnr].top;
   var thislimit = divArray[divnr].scrolllimit;
   if(updown && thistop < thislimit - speed) {
 //   	alert("canscroll :"+canscroll);
    divArray[divnr].top = thistop + speed;
   } else if(!updown && thistop > speed) {
      divArray[divnr].top = thistop - speed;
   } else if(speed >= 2){
      speed = speed/2;
   }
   if (divArray[divnr].top < 1){
      divArray[divnr].top = 0;
      canscroll =false;
  }
   if (n) {
      eval(divArray[divnr].divpad+'.moveTo(0,-'+divArray[divnr].top+')');
   } else {
      eval(divnaam+'.style.top=-'+divArray[divnr].top);
   }
   if(canscroll) {
      hulp = 'ScrollMe('+updown+','+constant*speed+','+constant+',"'+divnaam+'")';
	//alert("hulp: "+hulp);
      scrolltimer=setTimeout(hulp,60);
   }
}  

function SpringNaar(richting, divnaam){
   if(scrolltimer) clearTimeout(scrolltimer);
   if (!divnaam) {
      divnaam = 'div'+currentselect;
   }
   var divnr = eval('div'+divnaam);
   newtop = (richting == 'beneden')?-divArray[divnr].scrolllimit:0;
   divArray[divnr].top = newtop;
   if (n) {
      eval(divArray[divnr].divpad+'.moveTo(0,'+newtop+')');
   } else {
      eval(divnaam+'.style.top='+newtop);
   }
}  

function hide_textdiv(divnaam){
   show_hide('="hidden"',divnaam)
}
function show_textdiv(divnaam){
   show_hide('="visible"',divnaam)
}

function show_hide(showhide, divnaam, titel){
   if (!divnaam) divnaam='div'+currentselect;
   if (titel) divnaam += '_titel';
   hulp = eval('div'+divnaam);
   eval(divArray[hulp].showme+showhide);
}


