var totalDivs=0;
var firstTimeIn = true;

function expandableDiv() {
    this.id = 'div' + totalDivs++;
    this.begin = getTopOfDiv;
    this.end = getBottomOfDiv;
    this.flip = flipDiv;
}

function getTopOfDiv() {
    if (firstTimeIn) {
        firstTimeIn = false;      
        text = "<div id='" + this.id +  "' style='cursor:auto;'>";
    } else {
        text = "<div id='" + this.id +  "' style='display:none;cursor:auto;'>";
    }
    document.write(text);
}

function getBottomOfDiv() {
    document.write("</div>");
}


function flipDiv() {
    closeAllDivs();
    var divToFlip;
    if (document.getElementById) {
    divToFlip = document.getElementById(this.id);
    } else if (document.all) {
        divToFlip = eval ("document.all." + this.id);
    }
    window.focus()

    if (divToFlip.style.display=="none")  {
        divToFlip.style.display="";
    } else {
        divToFlip.style.display="none";
    }
}

function openAllDivs() {
    setAllDivs(true);
}
function closeAllDivs() {
    setAllDivs(false);
}


function setAllDivs(visible) {
    var divToFlip;
    for (i=0; i < totalDivs; i++) {
        if (document.getElementById) {
            divToFlip = eval("document.getElementById('div" + i + "')");
        } else if (document.all) {
            divToFlip = eval ("document.all.div" + i);
        }

        window.focus()
    
        if (visible)  {
            divToFlip.style.display="";
        } else {
            divToFlip.style.display="none";
        }
    }
}