﻿function HideAllContents() {
    var contentBlocks = document.getElementsByTagName("div");
    for (var i = 0; i < contentBlocks.length; i++) {
        var name = contentBlocks[i].getAttribute("name");
        if (name != null && name.indexOf("RadioButtonContent") != -1) {
            contentBlocks[i].style.display = "none";
            contentBlocks[i].style.visibility = "hidden";
            ShowHideContentInput(contentBlocks[i], false);
        }
    }
}

function ShowHideContentInput(contentBlock, show) {
    for (var i = 0; i < contentBlock.childNodes.length; i++) {
        child = contentBlock.childNodes[i];
        if (child.nodeName.toLowerCase() == "input" &&
                child.type == "hidden") {
            child.value = show ? "INVALID" : "";
        }
        else if (child.id && child.nodeName.toLowerCase() == "span" &&
                child.id.toLowerCase().indexOf("validator") != -1) {
            if (show) {
                child.setAttribute("isvalid", false);
            }
            else
                ValidatorEnable(child, show);
        }
        if (child.childNodes.length > 0)
            ShowHideContentInput(child, show);
    }
}

function ShowContents(radioButtonId) {
    HideAllContents();
    var radioButton = document.getElementById(radioButtonId);
    var parentNode = radioButton.parentNode;
    var radioButtonName = parentNode.getAttribute("name");
    var content;
    if (radioButton != null) {
        var contentBlocks = document.getElementsByTagName("div");
        for (var i = 0; i < contentBlocks.length; i++) {
            content = contentBlocks[i];
            var name = content.getAttribute("name");
            if (name != null && name == radioButtonName + "Content") {
                break;
            }
        }
        if (content != null) {
            content.style.display = "";
            content.style.visibility = "visible";
            ShowHideContentInput(content, true);
        }
    }
}