// -------------------------------------------------------
// News
//
// $Id: news.js,v 1.1 2009/01/24 11:53:32 steve Exp $
//
// -------------------------------------------------------

function init_news() {

    $('img.newsItemToggle').click( toggleNewsItem )
    
    $('div.newsItemHeader').mouseover( function() { $(this).addClass('newsItemHeader_Over') })
    $('div.newsItemHeader').mouseout( function() { $(this).removeClass('newsItemHeader_Over') })
}

function toggleNewsItem() {

    var elem   = $(this)
    var thisId = $(this).attr('id').split('_')
    thisId     = thisId[1]

    $('img.newsItemToggle').each(
        function() {
            var src = $(this).attr('src')
            var id  = $(this).attr('id').split('_')
            id      = id[1]
            if (thisId == id) {
                if (src.match(/expand.gif/)) {
                    src = src.replace(/expand.gif/, 'collapse.gif')
                    $('div#newsItemText_' + id).slideDown()
                 } else {
                    src = src.replace(/collapse.gif/, 'expand.gif')
                    $('div#newsItemText_' + id).slideUp()
                 }
                 $(this).attr('src', src)
            } else {
                if (src.match(/collapse.gif/)) {
                    $(this).attr('src', src.replace(/collapse.gif/, 'expand.gif'))
                }
                    $('div#newsItemText_' + id).slideUp()
            }
        })
}

