document.addEventListener("DOMContentLoaded", function () { // MODAL JS const openModalButtons = document.querySelectorAll(".open-modal"); const closeModalButtons = document.querySelectorAll(".close-modal"); const modals = document.querySelectorAll(".modal"); openModalButtons.forEach(button => { button.addEventListener("click", (e) => { e.preventDefault(); // Prevent default anchor behavior const modalId = button.getAttribute("data-modal"); const modal = document.querySelector(modalId); modal.style.display = "block"; }); }); closeModalButtons.forEach(button => { button.addEventListener("click", () => { const modal = button.closest(".modal"); modal.style.display = "none"; }); }); window.addEventListener("click", (e) => { if (e.target.classList.contains("modal")) { e.target.style.display = "none"; } }); // PAGINATION JS let currentSlide = 0; const slides = document.querySelectorAll(".slide"); const dots = document.querySelectorAll(".dot"); function showSlide(index) { slides.forEach((slide, i) => { slide.classList.toggle("active", i === index); dots[i].classList.toggle("active", i === index); }); currentSlide = index; } setInterval(() => { let nextSlide = (currentSlide + 1) % slides.length; showSlide(nextSlide); }, 5000); // CONTACT US BUTTON - ALERT const contactForm = document.getElementById("contact-form"); if (contactForm) { contactForm.removeEventListener("submit", handleFormSubmit); contactForm.addEventListener("submit", handleFormSubmit); } }); function handleFormSubmit(event) { event.preventDefault(); alert(beanheavenStrings.contactSuccess); document.getElementById("contact-form").reset(); } document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); // Prevent default anchor behavior const targetId = this.getAttribute('href'); // Get the target section ID const targetSection = document.querySelector(targetId); // Find the target section if (targetSection) { // Scroll to the target section smoothly targetSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); });