const defaultTab = "ocbinfo";

function openTab(event, tabName) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(tabName).style.display = "block";
    event.currentTarget.className += " active";

    
    localStorage.setItem("activeTab", tabName);
}

function refreshPage() {
    window.location.reload();
}

window.onload = function() {
    var activeTab = localStorage.getItem("activeTab");
    if (activeTab) {
        
        var tablinks = document.getElementsByClassName("tablinks");
        for (var i = 0; i < tablinks.length; i++) {
            if (tablinks[i].getAttribute("data-tab") === activeTab) {
                tablinks[i].click();
                break;
            }
        }
    } else {
        
        var defaultTabLink = document.querySelector(`.tablinks[data-tab="${defaultTab}"]`);
        if (defaultTabLink) {
            defaultTabLink.click();
        }
    }
};
