var oScrollInterval;
var iAmount = 1
var iInterval = 15

function scrollDivUp() {
    //    scrolls the content div
    var oDiv;
    if (document.getElementById) {
        oDiv = document.getElementById("content");
        if (oDiv.style) {
            if ((typeof oDiv.style.top == "string")
            && (typeof oDiv.offsetTop == "number")) {
                oScrollInterval = window.setInterval(
                "moveDownBy()",iInterval);
            }
        }
    }
}

function scrollDivDown() {
    //    scrolls the content div
    var oDiv;
    if (document.getElementById) {
        oDiv = document.getElementById("content");
        if (oDiv.style) {
            if ((typeof oDiv.style.top == "string")
            && (typeof oDiv.offsetTop == "number")
            && (typeof oDiv.offsetHeight == "number")) {
                oScrollInterval = window.setInterval(
                "moveUpBy()",iInterval);
            }
        }
    }
}

function moveUpBy() {
    var oDiv = document.getElementById("content");
    if (oDiv.offsetTop > ((oDiv.offsetHeight*(-1))+242)) 
        oDiv.style.top = oDiv.offsetTop - iAmount;
}

function moveDownBy() {
    var oDiv = document.getElementById("content");
    if (oDiv.offsetTop < 0)
        oDiv.style.top = oDiv.offsetTop + iAmount;
}

function stopScrollDiv() {
    clearInterval(oScrollInterval);
}

function initiate() {
    enableScroll();
    centerContainer();
}

function enableScroll(){
    //    enables scrolling if necessary.
    //    (necessary if content div is larger than contentview)
    
    if (document.getElementById) {
        oDiv = document.getElementById("content");
        oContainerDiv = document.getElementById("containercontent");
        oUp = document.getElementById("up");
        oDown = document.getElementById("down");
        if (typeof oDiv.offsetHeight == "number"
            && oDiv.style
            && typeof oDiv.style.visibility == "string") {
            if (oDiv.offsetHeight >= oContainerDiv.offsetHeight) {
                oUp.style.visibility = "visible"
                oDown.style.visibility = "visible"
            }
        }
    }
}

function centerContainer() {
    //    calculates the inner width and height of the browser window,
    //    and places the container div with id="container" in the centre.

    var oDiv;
    var iWidth;
    var iHeight;
    
    if(document.getElementById) {
        oDiv = document.getElementById("container");
    
        if ((typeof document.body.clientWidth) == "number")
            iWidth = document.body.clientWidth;    
        else if ((typeof window.innerWidth) == "number")
            iWidth = window.innerWidth;

        if ((typeof document.body.clientHeight) == "number")
            iHeight = document.body.clientHeight;    
        else if ((typeof window.innerHeight) == "number")
            iHeight = window.innerHeight;
        
        if (oDiv.style) {
            if (((typeof oDiv.style.left) == "string")
            && ((typeof oDiv.style.top) == "string")
            && ((typeof iWidth) == "number")
            && ((typeof iHeight) == "number")) {
                oDiv.style.left = (Math.max(34,(iWidth - 712)/2)) + "px";
                oDiv.style.top = (Math.max(17,(iHeight - 390)/2)) + "px";
                oDiv.style.visibility = "visible";
            }
        }
    }
}

window.onload=initiate;
window.onresize=initiate;