﻿// JScript File

var currentOpenPanelId;
function OpenPanel(srcElem){
    //get the parent container of the title that was clicked
    var AccordPanel = srcElem.parentElement ? srcElem.parentElement : srcElem.parentNode;
    if (!AccordPanel){return;}
    
    //get the accordion contaner
    var parentDiv = AccordPanel.parentElement ? AccordPanel.parentElement:AccordPanel.parentNode;
    if (!parentDiv){return;}
    
    //close all panels in the container
    var allPanels = parentDiv.getElementsByTagName('div');
    for (var index = 0; index < allPanels.length; index++){
        if ((allPanels[index].className == 'AccordionContent') || (allPanels[index].className == 'AccordionContentWide')){
            allPanels[index].style.display = 'none';
        }
        if (allPanels[index].className == "AccordionTitle OpenPanel"){
            allPanels[index].className = "AccordionTitle ClosedPanel";
        }
    }
    
    //open the panel that was clicked or requested
   
    var pnl = AccordPanel.getElementsByTagName('div')[1];
    var title = AccordPanel.getElementsByTagName('div')[0];
    
    if (pnl){
        if (pnl.style.display == 'block'){
            pnl.style.display = 'none';
            if (title){title.className = "AccordionTitle ClosedPanel";}
        }
        if ((pnl.style.display == 'none') && (AccordPanel.id != currentOpenPanelId)){
            pnl.style.display = 'block';
            if (title){title.className = "AccordionTitle OpenPanel";}
        }
    }
    
    //store the currently opened panel id
    if (currentOpenPanelId == AccordPanel.id){
        currentOpenPanelId = '';}
    else{
        currentOpenPanelId = AccordPanel.id;}
}
function OpenSpecified(ID){
    var pnl = document.getElementById('AccordionPanel' + ID);
    if (pnl) {
        var titlePanel = pnl.getElementsByTagName('div')[0];
        OpenPanel(titlePanel);
    }
}

function underline(elem, state){
    if (state == 1){elem.style.textDecoration='underline';elem.style.cursor='pointer';elem.style.color='#2660b1';}
    else {elem.style.textDecoration='none';elem.style.cursor='default';}
}
