var nav = document.getElementsByClassName('nav-item');
var tab = document.getElementsByClassName('tab-pane');


if (history.pushState) {
    hashchanged();
}
$(window).bind("hashchange", function() {
    hashchanged();
});

function hashchanged() {
    oldHref = document.location.href;
    var location_list = oldHref.toString().split("#");
    if (location_list[1] == "content_tab_1") {
        resetpage();
        nav[0].children[0].classList.add('show');
        nav[0].children[0].classList.add('active');
        tab[0].classList.add('show');
        tab[0].classList.add('active');
    } else if (location_list[1] == "content_tab_2") {
        resetpage();
        nav[1].children[0].classList.add('show');
        nav[1].children[0].classList.add('active');
        tab[1].classList.add('show');
        tab[1].classList.add('active');
    } else if (location_list[1] == "content_tab_3") {
        resetpage();
        nav[2].children[0].classList.add('show');
        nav[2].children[0].classList.add('active');
        tab[2].classList.add('show');
        tab[2].classList.add('active');
    } else if (location_list[1] == "content_tab_4") {
        resetpage();
        nav[3].children[0].classList.add('show');
        nav[3].children[0].classList.add('active');
        tab[3].classList.add('show');
        tab[3].classList.add('active');
    } else {
        resetpage();
        nav[0].children[0].classList.add('show');
        nav[0].children[0].classList.add('active');
        tab[0].classList.add('show');
        tab[0].classList.add('active');
    }
}


function resetpage() {
    for (var i = 0; i < nav.length; i++) {

        try {
            nav[i].children[0].classList.remove('show');
            nav[i].children[0].classList.remove('active');
            tab[i].classList.remove('show');
            tab[i].classList.remove('active');
        } catch (error) {

        }
    }
}