/* the newsticker will automatically adjusts to the
   height setting in the style of #newstickerFrame. */
var newstickerFrame;
var newsticker;
var pauseTime = 4000; // in milliseconds.
var isPaused = 0;
var index = 0;

function newstickerInit() {
    if (news.length > 0) {
        newstickerFrame = document.getElementById('newstickerFrame');
        newsticker = document.getElementById('newsticker');
        setInterval('scrollNewsticker()', 60);
    }
}

function scrollNewsticker() {
    if (isPaused) return;
    if (!newsticker.innerHTML | parseInt(newsticker.offsetHeight) == -parseInt(newsticker.style.top)) {
        newsticker.innerHTML = news[index];
        index = news[index + 1] ? index + 1 : 0;
        newsticker.style.top = parseInt(newstickerFrame.style.height);
    }
    newsticker.style.top = parseInt(newsticker.style.top) - 1 + 'px';
    if (parseInt(newsticker.style.top) % parseInt(newstickerFrame.style.height) == 0) {
        newstickerPause();
        setTimeout('newstickerResume()', pauseTime);
    }
}

function newstickerPause() { isPaused = 1; }
function newstickerResume() { isPaused = 0; }