
function setLayer(layerId, show) {
    if (show) {
        showLayer(layerId);
    } else {
        hideLayer(layerId);
    }
}

function toggleLayer(layerId) {
    var currentStyle = getLayerStyle(layerId);
    if (currentStyle.display == 'none') {
        currentStyle.display = '';
    } else {
        currentStyle.display = 'none';
    }
}
function toggleSpan(layerId) {
    var currentStyle = getLayerStyle(layerId);
    currentStyle.display = currentStyle.display ? "" : "block";
}


function showLayer(layerId) {
    changeLayer(layerId, 'inline');
}
function hideLayer(layerId) {
    changeLayer(layerId, 'none');
}

function showSpan(layerId) {
    changeLayer(layerId, 'inline');
}
function hideSpan(layerId) {
    changeLayer(layerId, '');
}

function getLayerStyle(layerId) {
    if (document.getElementById) {
        // this is the way the standards work
        return (document.getElementById(layerId)!=null) ? document.getElementById(layerId).style : null;

    } else if (document.all) {
        // this is the way old msie versions work
        return (document.all[layerId]!=null) ? document.all[layerId].style : null;

    } else if (document.layers) {
        // this is the way nn4 works
        return (document.layers[layerId].style!=null) ? document.layers[layerId].style : null;
    }
}
function changeLayer(layerId, newStyle) {
    var currentStyle = getLayerStyle(layerId);
    if (currentStyle!=null) {
        currentStyle.display = newStyle;
    }
}