function setupModal() {
    // Get the modal
    const modalDownload = document.getElementById("documentDownloadModal");

    // Get all links that should open in the modal
    const download_links = document.querySelectorAll(".edocmancollectdownloadbtn");

    // Get the iframe inside the modal
    const modalIframe = document.getElementById("modalDownloadIframe");

    // Get the close button
    const closeBtn = document.querySelector(".close-btn-download");

    // Loop through each link and add a click event listener
    download_links.forEach(link => {
        link.addEventListener("click", function(event) {
            event.preventDefault(); // Prevent default link behavior
            var url = this.href; // Get the link URL
            modalIframe.src = url; // Load the URL inside the iframe
            modalDownload.style.display = "flex"; // Show the modal
        });
    });

    // Close the modal when clicking the close button
    closeBtn.onclick = function() {
        modalDownload.style.display = "none";
        modalIframe.src = ""; // Reset iframe to stop loading content
    };
}

document.addEventListener("DOMContentLoaded", function() {
	setupModal();
});
