﻿// not animated collapse/expand
function togglePannelStatus(content)
{
    var expand = (content.style.display=="none");
    content.style.display = (expand ? "block" : "none");
    toggleChevronIcon(content);
}

// current animated collapsible panel content
var currentContent = null;

function togglePannelAnimatedStatus(content, interval, step)
{
    // wait for another animated expand/collapse action to end

   

    
    
    if (currentContent==null) {

       
        var xx1 = document.getElementById("c1")

        var xx2 = document.getElementById("c2")
        var xx3 = document.getElementById("c3")
        var xx4 = document.getElementById("c4")
        var xx5 = document.getElementById("c5")
        var xx6 = document.getElementById("c6")
        var xx7 = document.getElementById("c7")
       
        if (content.id == "c1") { } else { if (xx1.style.display != "none") {toggleChevronIcon(xx1)} xx1.style.display = "none"; }
        if (content.id == "c2") { } else { if (xx2.style.display != "none") {toggleChevronIcon(xx2)} xx2.style.display = "none"; }
        if (content.id == "c3") { } else { if (xx3.style.display != "none") {toggleChevronIcon(xx3)} xx3.style.display = "none"; }
        if (content.id == "c4") { } else { if (xx4.style.display != "none") {toggleChevronIcon(xx4)} xx4.style.display = "none"; }
        if (content.id == "c5") { } else { if (xx5.style.display != "none") {toggleChevronIcon(xx5)} xx5.style.display = "none"; }
        if (content.id == "c6") { } else { if (xx6.style.display != "none") {toggleChevronIcon(xx6)} xx6.style.display = "none"; }
         if (content.id == "c7") { } else { if (xx7.style.display != "none") {toggleChevronIcon(xx7)} xx7.style.display = "none"; }
        
        
        
        
        currentContent = content;
        var expand = (content.style.display=="none");
        if (expand)
            content.style.display = "block";
        var max_height = content.offsetHeight;

        var step_height = step + (expand ? 0 : -max_height);
        toggleChevronIcon(content);
                
        // schedule first animated collapse/expand event
        content.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus(" + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
}

function togglePannelAnimatingStatus(interval, step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    // schedule next animated collapse/expand event
    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        currentContent.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus(" + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
    // animated expand/collapse done
    else
    {
        if (step_height_abs<step)
            currentContent.style.display = "none";
        currentContent.style.height = "";
        currentContent = null;
    }
}

// change chevron icon into either collapse or expand
function toggleChevronIcon(content)
{
    // var chevron = content.parentNode.firstChild.childNodes[1].childNodes[0];
    // var expand = (chevron.src.indexOf("expand.gif")>0);
    // chevron.src = chevron.src
       // .split(expand ? "expand.gif" : "collapse.gif")
       // .join(expand ? "collapse.gif" : "expand.gif");
}

