
// Counter
var nTop = 0;

// Start and Stop
var bRun;
var ContentHeight = 350;
function start()
{
  var nHeight = window.document.getElementById("scrollContentDiv").clientHeight;
	if (document.getElementById("inhalt")){
		document.getElementById("inhalt").style.overflow = 'hidden';
		if (ContentHeight < (parseInt(nHeight)))
			document.getElementById("scrollbar").style.visibility = 'visible';
	}
}
// Scroll up
function goUp()
{
  // If nTop < 0 scroll
  if(nTop < 0)
  {
    var objDiv =document.getElementById("scrollContentDiv"); 
    nTop=nTop+10;
    objDiv.style.top=nTop+'px';
		
		// Dont stop scrolling, if the mouse is over the scrollbutton
    if (bRun) 
		  setTimeout("goUp();", 17);
   }
}

// Scroll down
function goDown()
{
  // Height of div
  var nHeight = '-'+window.document.getElementById("scrollContentDiv").clientHeight;
//  alert (nTop);
//  alert (parseInt(nHeight));
	// If nTop >= height scroll
	if(nTop >= parseInt(nHeight)+ContentHeight)
  {
    var objDiv =document.getElementById("scrollContentDiv");
	  nTop=nTop-10;
    objDiv.style.top=nTop+'px';
    
		// Dont stop scrolling, if the mouse is over the scrollbutton
		if (bRun)
		 setTimeout("goDown();", 17);
  }
}

// Scroll to top
function goTop()
{
  // Jump to top
  document.getElementById("scrollContentDiv").style.top = '0px';
 
  // Set counter to 0 (begin)
	nTop = 0;
}

/** This is high-level function.
 * It must react to delta being more/less than zero.
 */
function handle(delta) {
        if (delta < 0)
			goDown();
        else
			goUp();
}

/** Event handler for mouse wheel event.
 */
function wheel(event){
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.
                 */
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
        if (delta)
                handle(delta);
        /** Prevent default actions caused by mouse wheel.
         * That might be ugly, but we handle scrolls somehow
         * anyway, so don't bother here..
         */
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}

/** Initialization code. 
 * If you use your own event management code, change it as required.
 */
if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
        window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel;