document.addEventListener("DOMContentLoaded", function() {
  $("ul.catFilter li.available").on("click", function(e){
    
    e.preventDefault();

    var catFilter = document.getElementsByClassName("catFilter")[0];
    var catElement = catFilter.querySelector('.active');
    catElement.classList.remove('active');
    this.classList.add('active');


    var requestLetter = $(this).find('a:first').text().trim();
    var lists = document.getElementsByClassName("bestandliste");
    for (let list of lists) {
      var listLetter = list.id;
      if (listLetter != requestLetter && requestLetter != "Alle") {
        list.style.display = "none";
      } else {
        list.style.display = "block";
      };
    }

  });
});
