///javascript class info http://www.litotes.demon.co.uk/js_info/private_static.html
// banner.js

function showMessage(n, show) {
    var whichElStyle = YAHOO.util.Dom.get("message" + n).style;
    whichElStyle.visibility = show ? "visible" : "hidden";
}

function nextMessage() {
    var fromInd = current;
    current = (fromInd == ar.length - 1) ? 0 : fromInd + 1;

    scrollBanner(fromInd, current);
}

function moveUp() {
    fromElStyle.top = parseInt(fromElStyle.top.substring(0,fromElStyle.top.length -2)) - increment + "px";
    if (parseInt(toElStyle.top.substring(0,toElStyle.top.length -2)) - increment <= toElTarget) {
        toElStyle.top = toElTarget + "px";
        clearInterval(intervalID);
        fromElStyle.visibility = "hidden";
        timeoutID = setTimeout("nextMessage()", pause);
    }
    else
    {
        toElStyle.top = parseInt(toElStyle.top.substring(0,toElStyle.top.length -2)) - increment + "px";
    }
}

function scrollBanner(from, to) {
    try
    {            
        fromElStyle = YAHOO.util.Dom.get("message" + from).style;
        toElStyle = YAHOO.util.Dom.get("message" + to).style;
            
        toElStyle.top = parseInt(fromElStyle.top.substring(0,fromElStyle.top.length -2)) + bannerHeight + "px";
        toElTarget = parseInt(fromElStyle.top.substring(0,fromElStyle.top.length -2));
        showMessage(to, true); // show the upcoming message
        intervalID = setInterval("moveUp()", interval);
    }
    catch(ex)
    {
        setTimeout("scrollBanner(" + from + ", " + to + ")",1000);
    }
}

function makeIE() {
    var banner = YAHOO.util.Dom.get('holdspace');

    for (var i = ar.length - 1; i >= 0; i--)
    {
        var messageElement = document.createElement('div');
        messageElement.id = "message" + i;
        
        with(messageElement.style)
        {
            position = "absolute";
            visibility = "hidden";
            left = leftPadding + "px";
            top = topPadding + "px";
            width = bannerWidth - leftPadding + "px";
        }
        banner.appendChild(messageElement);
    }
}

function fillBanner() {
    var whichEl;
    for (var i = 0; i < ar.length; i++) {
        whichEl = YAHOO.util.Dom.get("message" + i);
        whichEl.innerHTML = ar[i];
    }
}

function startBanner() {
    makeIE();
    fillBanner();
    BannerInitialize();
}

function BannerInitialize()
{
    ///wordt alleen eerste keer uitgevoerd dat dit script wordt geladen
    if (typeof Structura.banner == "undefined") {
        Structura.banner = "myBanner";
        
        showMessage(0, true);
        current = 0;
        timeoutID = setTimeout("nextMessage()", pause);
    }
}