var delay=5000 // a delay of 5 seconds...

var theDiv

function initNewsTicker() {

    theDiv = document.getElementById( 'news_ticker_id' )

    if ( getNumberOfP()==0 ) {
        return
    }

    // Show the first P
    for ( var i = 0; i < theDiv.childNodes.length; i++ ) {
        if ( theDiv.childNodes[i].tagName=='P' ) {
            var theP = theDiv.childNodes[i]
            theP.className='show'
            break
        }
    }

    setTimeout("changeNewsTicker()",delay)
}

function changeNewsTicker() {
    var currentP

    // Find the P we have currently showing
    for ( var i = 0; i < theDiv.childNodes.length; i++ ) {
        if ( theDiv.childNodes[i].tagName=='P' && theDiv.childNodes[i].className=='show' )  {
            theDiv.childNodes[i].className=''
            currentP = i
            break
        }
    }

    // Activate the next p
    var i = currentP
    while ( true ) {
        i = (i + 1) % theDiv.childNodes.length // loop round to the beginning of the Ps if we are at the last P
        if ( theDiv.childNodes[i].tagName=='P' ) {
            var theP = theDiv.childNodes[i]
            theP.className='show'
            break
        }

    }

    setTimeout("changeNewsTicker()",delay)
}

function getNumberOfP() {
    var count = 0

    for( var i = 0; i < theDiv.childNodes.length; i++ ) {
        if ( theDiv.childNodes[i].tagName=='P' ) {
            count++
        }
    }

    return count
}

window.onload = initNewsTicker