﻿function CloseBox(boxID) {
    ToggleBox(boxID, -1);
}

function OpenBox(boxID) {
    ToggleBox(boxID, 1);
}

function ToggleBox(boxID, motion) {
    if (!document.getElementById) return;

    var box = document.getElementById(boxID);
    if (!box) return;

    var boxElements = box.getElementsByTagName("*");
    for (var i = 0; i < boxElements.length; i++) {
        var className = boxElements[i].className;
        if (className == "boxitembody" || className == "boxitemfooter") {
            // Toggle visibility of body and footer.
            boxElements[i].style.display = (motion == 1) ? "block" : "none";
        }
        if (className == "boxitemtitletext") {
            // Display listitemtitletext's bottom border when the window is opening.
            boxElements[i].style.borderBottom = (motion == 1) ? "none" : "solid 1px #446D8D";
        }
        if (className == "switchclose-on" && motion == 1) {
            boxElements[i].className = "switchclose-off";
        }
        if (className == "switchclose-off" && motion == -1) {
            boxElements[i].className = "switchclose-on";
        }
        if (className == "switchopen-off" && motion == 1) {
            boxElements[i].className = "switchopen-on";
        }
        if (className == "switchopen-on" && motion == -1) {
            boxElements[i].className = "switchopen-off";
        }
    }
}

