/* Script by: www.jtricks.com
 * Version: 20060105
 * Latest version:
 * www.jtricks.com/javascript/navigation/toc.html
 */

function toggle(obname)
{
    ob = document.getElementById(obname);
    if (ob.style.display == '')
        ob.style.display='none';
    else
        ob.style.display='';
}

function toc_parent(obsearch, ob)
{
    var obp = obsearch;
    while (obp != null && obp != ob)
    {
        obp = obp.parentNode;
    }

    return obp == ob;
}

function toc_switch(obnameto, obnamefrom)
{
    var obto = document.getElementById(obnameto);
    var obfrom = document.getElementById(obnamefrom);

    var obtry = obfrom;

    // Find commn parent
    while (!toc_parent(obto, obtry))
    {
        obtry = obtry.parentNode;
    }
    var obcommon = obtry;

    // Show the DIV/SPAN we switch to
    // (up to the common parent)
    obtry = obto;
    while (obtry != obcommon)
    {
        if (obtry.nodeName == 'DIV' ||
            obtry.nodeName == 'SPAN')
        {
            obtry.style.display = '';
        }

        obtry = obtry.parentNode;
    }

    // Hide the DIV/SPAN we switch from
    // (up to the common parent)
    obtry = obfrom;
    while (obtry != obcommon)
    {
        if (obtry.nodeName == 'DIV' ||
            obtry.nodeName == 'SPAN')
        {
            obtry.style.display = 'none';
        }

        obtry = obtry.parentNode;
    }
}

