// -------------------------------------------------------
// Page-Handling Javascript
//
// $Id: Page.js,v 1.1.1.1 2010/02/26 08:30:22 steve Exp $
//
// -------------------------------------------------------

var Page = function() {

    this.goToHomePage = function() {

       replacePage('index.php')
    }

    this.replacePage = function(page, args) {

        url = SITEROOT + '/' + page
        if (args) {
            url = url + '&' + args
        }
        location.replace(url)
    }

    this.submitPage = function(url) {

        $('#replacePage').attr('action', url)
        $('#replacePage').submit() ;
    }

    this.reLoadPage = function() {

        submitPage(location.href)
    }
}

function toggleExpand(elem, expandText, collapseText) {

    var id     = $(elem).attr('id')
    var textId = id + 'Text'
    var divId  = id.replace(/_Expander$/, '')

    var src    = $(elem).attr('src')
    
    
    console.log(divId)
    if (src.match(/expand/)) {
        src = src.replace(/expand/, 'collapse')
        if (collapseText) {
            $('span#' + textId).html(collapseText)
        }
        $('div#' + divId).show()
    } else {
        src = src.replace(/collapse/, 'expand')
        if (expandText) {
            $('span#' + textId).html(expandText)
        }
        $('div#' + divId).hide()
    }
    $(elem).attr('src', src)
}


