
document.getById = function(strId) {
    if (document.getElementById)
        return document.getElementById(strId);
    else if (document.all)
        return document.all[strId];
    else if (document[strId])
        return document[strId];
    else if (document.layers && document.layers[strId])
        return document.layers[strId];
}

if (String && String.prototype) {
    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g, "");
    }
}

function swapImage(imgObj, strImg) {
    imgObj.old = imgObj.src;
    imgObj.src = strImg;
}

function restoreImage(imgObj) {
    imgObj.src = imgObj.old;
}

function setCurrentPage() {
    var strUrl = location.href.toLowerCase();
    var strStart = "/index.php/";
    var startInd = strUrl.indexOf(strStart);

    if (startInd != -1) {
        strUrl = strUrl.substring(startInd + strStart.length);
        if (strUrl.indexOf('/') != -1)
            strUrl = strUrl.substring(0, strUrl.indexOf('/'));
        if (strUrl.indexOf('?') != -1)
            strUrl = strUrl.substring(0, strUrl.indexOf('?'));
    }
    else {
        strUrl = '';
    }

    var obSetPage = null;
    var obSetImage = null;

    switch (strUrl) {
        case '':
        case 'default':
            obSetPage = "but01";
            obSetImage = "but01on";
            break;
        case 'trustees':
            obSetPage = "but02";
            obSetImage = "but02on";
            break;
        case 'contactus':
            obSetPage = "but03";
            obSetImage = "but03on";
            break;
        case 'documents':
            obSetPage = "but04";
            obSetImage = "but04on";
            break;
        case 'links':
            obSetPage = "but05";
            obSetImage = "but05on";
            break;
        case 'news':
            obSetPage = "but06";
            obSetImage = "but06on";
            break;
    }

    if (obSetPage && obSetPage.length != 0 && obSetImage && obSetImage.length != 0) {
        obSetPage = document.getById(obSetPage);
        obSetImage = document.getById(obSetImage);
        if (obSetPage && obSetImage) {
            obSetPage.src = obSetImage.src;
            obSetPage.onmouseover = null;
            obSetPage.onmouseout = null;
        }
    }
}

