var scrollPE;
var theSlider;

function stopScroll()
{
    if (scrollPE) {
        scrollPE.stop();
        scrollPE = null;
    }
}

function scrollUpExecuter()
{
    theSlider.setValue(theSlider.value - 40);
}

function scrollDownExecuter()
{
    theSlider.setValue(theSlider.value + 40);
}

function scrollDown()
{
    stopScroll();

    scrollPE = new PeriodicalExecuter(scrollDownExecuter, 0.1);
}

function scrollUp()
{
    stopScroll();

    scrollPE = new PeriodicalExecuter(scrollUpExecuter, 0.1);
}

function initScrollbar()
{
    var availHeight = $('scrollContainer').getHeight();
    var contentHeight = $('produkttabelleFrame').getHeight();
    
    //window.alert("availHeight: "+availHeight);
    //window.alert("contentHeight: "+contentHeight);

    if (contentHeight > availHeight) {
        var sliderHeight = Math.floor((availHeight / contentHeight) * 362);

        if (sliderHeight < 20) {
            sliderHeight = 20;
        }

        $('sliderHandle').style.height = sliderHeight + 'px';

        theSlider = new Control.Slider('sliderHandle','sliderTrack', {
            maximum: 362,
            disabled: false,
            handleDisabled: false,
            range: $R(0, contentHeight - availHeight),
            axis: 'vertical',
            onChange: function(value) {
                $('produkttabelleFrame').style.marginTop = -value + 'px';
            },
            onSlide: function(value) {
                $('produkttabelleFrame').style.marginTop = -value + 'px';
            }
        });
    } else {
        $('scrollBar').style.display = 'none';
    }
}