//DIV-Scroller for modern DOM-capable Browser: Sebstian Bechtold
//sebastian_bechtold@web.de (siehe www.traum-projekt.com/forum)
//ACHTUNG: var=id und "scrollframe" sind Bezeichnungen von DIV-Container
//         und dürfen nur "gezielt" verändert werden (wenn Änderung, dann
//         in den JS-Function und CSS zugleich)!
//=============================================================
// horizontales scrollen
var scrollers = new Array();
function ScrollableLayer(id)
{ this.contentLayer = document.getElementById(id);
  this.scrollframe = document.getElementById('scrollframe' + id);
  if (this.contentLayer.offsetWidth==0) //firefox kann 0 sein, dann clientWidth
     this.scrollWidth = this.contentLayer.clientWidth - this.scrollframe.offsetWidth;
  else
    this.scrollWidth = this.contentLayer.offsetWidth - this.scrollframe.offsetWidth;
  this.contentLayer.style.position = 'relative';
  this.scrollframe.style.position = 'relative';
}
function start_scroll(id, speed)
{ scrollers[id] = new ScrollableLayer(id);
  new_id = id;
  new_speed = speed;
  scrollers[id].timer = window.setInterval("scroll(new_id, new_speed);",20);
}
function stop_scroll(id)
{ window.clearInterval(scrollers[id].timer);
}
function scroll(id, speed)
{ y_new = scrollers[id].contentLayer.offsetLeft + speed;
  if (y_new <= 0 && y_new >= -scrollers[id].scrollWidth)
  { scrollers[id].contentLayer.style.left = y_new+"px";
  }
  else
  { width = 0;
    if (y_new < -scrollers[id].scrollWidth)
    { width = scrollers[id].scrollWidth;
    }
    stop_scroll(id);
    start_scroll(id, width + y_new);
  }
}
//=============================================================
// vertikales Scrollen
var Vscrollers = new Array();

function VScrollableLayer(id)
{ this.contentLayer = document.getElementById(id);
  this.scrollframe = document.getElementById('scrollframe' + id);
  this.scrollHeight = this.contentLayer.offsetHeight - this.scrollframe.offsetHeight;
// alert(id+" div TXT:"+this.contentLayer.clientHeight+this.contentLayer.offsetHeight+"  div scrollframeTXT:"+this.scrollframe.offsetHeight+this.scrollframe.clientHeight);
  this.contentLayer.style.position = 'relative';
  this.scrollframe.style.position = 'relative';
}
function Vtext_anfang(id, speed)
{ Vscrollers[id] = new VScrollableLayer(id);
  new_id = id;
  new_speed = speed;
  Vscrollers[id].timer = window.setInterval("Vscroll(new_id, new_speed);",20);
  Vstop_scroll(id);
}
function Vstart_scroll(id, speed)
{ Vscrollers[id] = new VScrollableLayer(id);
  new_id = id;
  new_speed = speed;
  Vscrollers[id].timer = window.setInterval("Vscroll(new_id, new_speed);",20);
}
function Vstop_scroll(id)
{ window.clearInterval(Vscrollers[id].timer);
}
function Vscroll(id, speed)
{ y_new = Vscrollers[id].contentLayer.offsetTop + speed;
  if (y_new <= 0 && y_new >= -Vscrollers[id].scrollHeight)
  { Vscrollers[id].contentLayer.style.top = y_new+"px";
  }
  else
  { height = 0;
    if (y_new < -Vscrollers[id].scrollHeight)
    { height = Vscrollers[id].scrollHeight;

    }
    Vstop_scroll(id);
    Vstart_scroll(id, height + y_new);
  }
}