
function InitializeScroller()
{
    my_scroll_control = document.all? document.all.divScrollControl : document.getElementById("divScrollControl")
    my_scroll_control.style.top = "0px"
    // View the first page before starting to scroll
    setTimeout("GetScrollControlHeight()", view_time*1000)
}

function GetScrollControlHeight()
{
    // How long is our page?
    my_scroll_control_height = my_scroll_control.offsetHeight/2
    if (my_scroll_control_height == 0)
        setTimeout("GetScrollControlHeight()",10)    // Page not loaded yet. Try again in 10ms
    else
        StartScrolling()
}

function ScrollDiv()
{
    // Scroll the specified amount
    my_scroll_control.style.top = parseInt(my_scroll_control.style.top) - scroll_amount_px
    if (parseInt(my_scroll_control.style.top) < (-my_scroll_control_height))
    {
        my_scroll_control.style.top =0
        // Refresh the data from Database every time scroll is back to top
        //clearInterval(scrollingID)  // Bug in FireFox meant it didn't have time to reload the page before scrolling began
        //window.location.reload();
    }
}

function StartScrolling()
{
    // Start scrolling
    scrollingID = setInterval("ScrollDiv()", scroll_speed)
    // Set when to stop again
    if (view_time > 0)
        setTimeout("StopScrolling()", scroll_time)
}

function StopScrolling()
{
    // Stop scrolling
    clearInterval(scrollingID)
    // Set when to start again
    setTimeout("StartScrolling()", view_time*1000)
}

if (window.addEventListener)
    window.addEventListener("load", InitializeScroller, false)
else    
    if (window.attachEvent)
        window.attachEvent("onload", InitializeScroller)
    else
        window.onload = InitializeScroller
