// Find a CSS rule based on a selector
function cssRuleForSelector(s)
{
    s = s.toLowerCase();
    var sh = document.styleSheets[0];
    var r = sh.cssRules ? sh.cssRules : sh.rules;
    for (i=1; i<r.length; i++) {
        if ((r[i].selectorText) && (r[i].selectorText.toLowerCase() == s)) {
            return r[i];
        }
    }
}

// Toggle visibility of a class
function toggle(c)
{
    document.body.style.cursor = 'wait';
    // Give it some time to actually change the cursor
    setTimeout("do_toggle('"+c+"')", 100);
}

// Toggle visibility of a class
function do_toggle(c)
{
    var css = cssRuleForSelector('.'+c);
    var linkCss = cssRuleForSelector('.'+c+'Link');
    var display = css.style.display;
    if (display == 'none') {
        linkCss.style.fontWeight = 'bold';
        css.style.display = '';
    } else {
        linkCss.style.fontWeight = 'normal';
        css.style.display = 'none';
    }
    document.body.style.cursor = 'default';
}

