/**
* Scrolling Script 1.0
* --------------------
* Copyright: Adrian Suter - Netpilots, Switzerland
* Last Modification: February 2004
* Needs: dhtml.js
* Divs: scrollUp, scrollDown, inhalt
*/

var direction  = 0;
var speed      = 4;
var looping    = null;
var doc_width  = null;
var doc_height = null;
var checkEOL   = null;

function scrollUp() {
	if ( direction == 0 )
    {
	    direction = 1;
	    scrollStart();
    }
}

function scrollDown() {
	if ( direction == 0 )
    {
	    direction = -1;
	    scrollStart();
    }
}

function scrollStart() {
    looping = window.setInterval("moveInhalt()", 1);
}

function scrollStop() {
    direction = 0;
    window.clearInterval(looping);
}

function moveInhalt() {
    var inhalt = getElem("id", "inhalt", null);
    var newPos = parseInt(inhalt.style.top) + speed * direction;
    if ( newPos > 0 ) newPos = 0;

    /* Avoid scrolling too much (only DOM and IE) */
    if ( checkEOL == "yes" && (DOM || IE) ) {
        if ( parseInt(inhalt.offsetHeight)-doc_height+20 < -newPos ) {
            scrollStop();
            return true;
        }
    }

    inhalt.style.top = newPos + "px";
}

function setArrows(leftPadding, topPadding, visibility, ceol, s) {
    var inhalt = getElem("id", "inhalt", null);
    checkEOL   = ceol;
    speed      = s;
    doc_width  = getWindowInnerWidth();
    doc_height = getWindowInnerHeight();

    /* Handle resizes of the browser window */
//    window.onresize = setArrows;

    if ( visibility == "no" )
    	return true;
    if ( visibility == "auto" && (DOM || IE) ) {
        if ( parseInt(inhalt.offsetHeight) < doc_height )
            return true;
    }

    var obj0 = getElem("id", "arrowUp", null);
    obj0.style.top = topPadding + "px";
    obj0.style.left = (doc_width-leftPadding) + "px";
    obj0.style.visibility = "visible";

    var obj1 = getElem("id", "arrowDown", null);
    obj1.style.top = (doc_height-20) + "px";
    obj1.style.left = (doc_width-leftPadding) + "px";
    obj1.style.visibility = "visible";
}
