window.addEventListener("load", function () {
  var overlay = document.getElementById("modal-overlay");
  var container = document.getElementById("modal-container");

  // Get the close button in the view event modal
  var closeButton = container.querySelector(".cv_modal-close");

  // Add click event listener to the close button in the view event modal
  closeButton.addEventListener("click", function () {
    container.style.display = "none";
    overlay.style.display = "none";
    window.location.reload();
  });

  // When the user clicks anywhere outside of the modal, close it
  overlay.addEventListener("click", function (event) {
    if (event.target == overlay) {
      container.style.display = "none";
      overlay.style.display = "none";
      window.location.reload();
    }
  });
});
