function getDivElmtsByClass(srchClass, cls) {
    // cls normally 'div' but can search for buttons too
    if (cls == null)
        cls = 'div';
    var elmts = document.getElementsByTagName(cls);
    // special code to only return the 2nd button on page
    if (cls == 'input')
        return elmts;

    // look for matching DIV tags with class name
    var clsElmts = new Array();
    var dlen = elmts.length;
    for (i = 0, j = 0; i < dlen; i++) {
        cn = elmts[i].className;
        if (cn && cn == srchClass) {
            clsElmts[j] = elmts[i];
            j++;
        }
    }
    return clsElmts;
}

function togall(cls) {
    var elmts = getDivElmtsByClass(cls);
    var dlen = elmts.length;

    // special code to toggle the toggle button text
    var btns = getDivElmtsByClass(cls, 'input');
    ebtn = btns[1];
    pbtn = btns[2];
    if (ebtn.value == "Hide Minor Errata")
	ebtn.value = "Show Minor Errata";
    else
	ebtn.value = "Hide Minor Errata";
    if (cls == 'print')
	pbtn.value = "Formatting page to print...";

    // toggle all of the minor errata
    for (i = 0; i < dlen; i++) {
        os = elmts[i].style;
        if (os.display)
            os.display = "";
        else
            os.display = "none";
    }
}

