// assets/js/scripts.js
var filterOptionsVisible = false;

function toggleFilterOptions() {
    var filterOptions = document.getElementById('filter-options');
    var filterButtons = document.getElementById('filter-buttons');

    if (!filterOptionsVisible) {
        filterOptions.style.display = 'block';
        filterButtons.classList.add('show');
        filterOptionsVisible = true;
    } else {
        filterOptions.style.display = 'none';
        filterButtons.classList.remove('show');
        hideCheckboxes();
        filterOptionsVisible = false;
    }
}

function toggleCheckboxes(filterType) {
    var checkboxes = document.getElementById(filterType + '-checkboxes');
    if (checkboxes.style.display === 'none' || checkboxes.style.display === '') {
        checkboxes.style.display = 'block';
    } else {
        checkboxes.style.display = 'none';
    }
}

function hideCheckboxes() {
    var checkboxes = document.querySelectorAll('.filter-checkboxes');
    checkboxes.forEach(function(checkbox) {
        checkbox.classList.remove('show');
    });
}

function toggleSortButtons() {
    var sortButtons = document.getElementById('sort-buttons');
    if (sortButtons.style.display === 'none' || sortButtons.style.display === '') {
        sortButtons.style.display = 'block';
    } else {
        sortButtons.style.display = 'none';
    }
}

function sortAlbums(column, order) {
    var url = "<?= site_url('chansons/index'); ?>";
    url += "?sort=" + column + "&order=" + order;
    window.location.href = url;
}

function toggleCheckboxesPlaylist(filterType) {
    var checkboxes = document.getElementById(filterType + '-checkboxes-playlist');
    if (checkboxes.style.display === 'none' || checkboxes.style.display === '') {
        checkboxes.style.display = 'block';
    } else {
        checkboxes.style.display = 'none';
    }
}