//Global current image number
var iThumb = 1;

//Timer function for changing pictures
function timerDoBanner() {
    opacityChangeBanner("topBanner" + iThumb, 100, 0, 500);
    imageTimer = setTimeout("timerDoBanner()", 6500);
}

//Add images to the desired div
function addContentBanner() {
    imageTimer = setTimeout("timerDoBanner()", 6500);
}

function opacityChangeBanner(iID, iOpacStart, iOpacEnd, iMilliSec) {
    //Speed for each frame
    var iSpeed = Math.round(iMilliSec / 100);
    var iTimer = 0;

    //Determine the direction for the blending, if start and end are the same nothing happens
    if (iOpacStart > iOpacEnd) {
        for(iCounter = iOpacStart; iCounter >= iOpacEnd; iCounter--) {
            setTimeout("changeOpacBanner(" + iCounter + ",'" + iID + "', 'down')", (iTimer * iSpeed));
            iTimer++;
        }
    } else if (iOpacStart < iOpacEnd) {
        if (iOpacStart == 0) {
            document.getElementById(iID).style.display = 'block';
        }
        for(iCounter = iOpacStart; iCounter <= iOpacEnd; iCounter++)
            {
            setTimeout("changeOpacBanner(" + iCounter + ",'" + iID + "', 'up')", (iTimer * iSpeed));
            iTimer++;
        }
    }
}

//Change the opacity for different browsers
function changeOpacBanner(iOpacity, iID, iStatus) {
    var object = document.getElementById(iID).style;
    object.opacity = (iOpacity / 100);
    object.MozOpacity = (iOpacity / 100);
    object.KhtmlOpacity = (iOpacity / 100);
    object.filter = "alpha(opacity=" + iOpacity + ")";

    //Check if picture needs to be changed, and do if necessary
    if ((iStatus == "down") && (iOpacity == 0))
    {
        object.display = 'none';
        if (iThumb < 10) {
            iThumb++;
        } else {
            iThumb = 1;
        }
        opacityChangeBanner("topBanner" + iThumb, 0, 100, 500);
    }
}