﻿/*
    REQUIRES "misc.djn.js" FOR COOKIEs, etc
*/

// updateSectionCookie - each time a section is opened or closed, the cookie is updated...
// sectionIdx is the integer count of the section (currSection in the following code)
// isOpen is a boolean True / False

function updateSectionCookie(sectionIdx, isOpen) {
    cookieContent = cookieContent.slice(0, sectionIdx - 1) + (isOpen ? "1" : "0") + cookieContent.slice(sectionIdx);
    // expires after one day - there's no reason to store this long term and an extra section would reset the cookie anyway
    setCookie(cookieName, cookieContent, 1);
}

function toggleDiv(idx) {
    var divName = "section"+idx;
    var dispStat;
    var elem = getElement(divName);
    if (elem) {
        dispStat = elem.style.display == "none" ? "" : "none";
        elem.style.display = dispStat;
    }
    divName = "arrow" + idx;

    // change the arrow, depending on dispStat ("" = down, "none" = across)!
    elem = getElement(divName);
    if (elem) {
        elem.style.background = dispStat == "" ? "url(images/dbl_arrow_down.gif) no-repeat right" : 
            "url(images/dbl_arrow_across.gif) no-repeat right";
    }
    updateSectionCookie(idx, dispStat == "");
}
