function modify_buttons_for_help(status) {
    K.visible("#linkshow", status);
    K.visible("#textshow", status);
    K.visible("#searchtools", status);
    K.get("#help").textContent = status == "show" ? "Help" : "Back";
}

function show_help() {
    let header = K.get("#text h1");
    if (header && header.textContent === "Navigation features") {
        textshow();
	modify_buttons_for_help("show");
        frame_resize();
    } else {
        save_position();
        K.get("#text").replaceWith(K.get("#help_page").cloneNode(true));
        K.attr("#help_page", "id", "text");
        K.visible("#toc", "hide");
        K.visible("#resizer", "hide");
        set_buttons("hide");
        resize_text_width();
	modify_buttons_for_help("hide");
        frame_resize();
    }
}

window.addEventListener("load", function (event) {
    K.get("#help").addEventListener("click", function (e) {
        event.preventDefault();
        show_help();
    });
    define_keypress("H", "#help");
});
