/*
 * toggleView( className )
 * will look for tr elements of class "className" and display
 * them; all other tr elements will be hidden (except
 * for header and th elements).
 * If you call this again with identical parameters,
 * it returns everything back to normal (i.e. everything visible)
 *
 * This only affects tr elements inside tables of class "library"
 *
 * Written by Stephen Becker, 2008, 2009, 2010
 * */
var oldClass = "1900";
function toggleView(theClass){

    var rows = new Array();
    var browser=navigator.appName;
    // July 2010: restrict to just tables of class "library"
    var allTables=document.getElementsByTagName("table");
    var rows=new Array();
    // (Note: we allow tables to be of several class types)
    for (i=0; i<allTables.length; i++) {
        if (allTables[i].className.indexOf("library") != -1 ) {
            var trs = allTables[i].getElementsByTagName("tr");
            for ( j=0; j < trs.length; j++ ) {
                rows.push(trs[j]);
            }
        }
    }

    //alert(browser)
    // Note: safari identifies as "Netscape"
    if ( (browser=="Netscape") || (browser=="Opera") ){ 
        DISP = "table-row";
    } else {
        DISP = "block";
    }
    makeVisible = 0;

    for (i=0; i<rows.length; i++) {
        // decide if we are making everything visible or invisible
        if (rows[i].style.display == 'none' ) {
            makeVisible = 1;
            break;
        }
    }
    if (theClass != oldClass) {
        makeVisible = 0;
    }
    oldClass = theClass;
    if (makeVisible == 1 ){
        for (i=0; i<rows.length; i++) {
            rows[i].style.display = DISP;
        }
    } else {

        for (i=0; i<rows.length; i++) {

            // June 2010, adding this so that it can handle the
            // case where class has more than one tag:
            if (rows[i].className.indexOf(theClass) != -1 ) {
                rows[i].style.display = DISP;
            } else if (rows[i].className=="header" ) {
                // also keep the table headers visible
            } else if (rows[i].getElementsByTagName("th").length > 0 ){
                // another way to specify table headers
            } else if (rows[i].className=="titleTR" ) {
                rows[i].style.display = DISP;
            } else {
                // but everything else should not be displayed
                rows[i].style.display = "none";
            }

        }
    }
}

