// Redefine resizeParentIframe to be a no-op function 
function resizeParentIframe() {
    // This function intentionally left blank
}

// Toggle container panel containing sub questions of a header type item
// 1. only show/hide the panel (does not clear elements)
// 2. set cookie to remember state
// 3. set title attribute of button and span
// 4. set active class on button
// 5. if element is not passed, take the first previous span
function toggleHeaderChildQuestions(element, buttonId, containerId, userId) {
    const $button = $(`#${buttonId}`);
    const $container = $(`#${containerId}`);
    
    if (!element) {
        // If element is not passed, take the first previous span.
        element = $button.prev("span")[0];
    }
    
    if ($container.is(":visible")) {
        setCookie(`HeaderHidden_${containerId}_${userId}`, "1");
        $container.slideUp(function () {
            $(element).attr("title", "Show Sub-Questions");
            $button.attr("title", "Show Sub-Questions");
            $button.removeClass("active");
        });
    } else {
        setCookie(`HeaderHidden_${containerId}_${userId}`, "0");
        $container.slideDown(function () {
            $(element).attr("title", "Hide Sub-Questions");
            $button.attr("title", "Hide Sub-Questions");
            $button.addClass("active");
        });
    }
}

function toggleReadOnlyText(element) {
    const $element = $(element);
    
    const $secondLabel = $element.parent().find(".secondLabel");
    
    if (!$element.hasClass("active")) {
        $element.text("Hide");
        $element.addClass("active");

        $secondLabel
            .attr("style", "")
            .removeClass("text-truncate");
    } else {
        $element.text("Read More");
        $element.removeClass("active");

        $secondLabel
            .attr("style", "display: block; width: 100%; max-height: 100px;")
            .addClass("text-truncate");
    }
}