const messages = document.querySelectorAll('.banner-message'); const prevButton = document.querySelector('.prev-button'); const nextButton = document.querySelector('.next-button'); let currentIndex = 0; let intervalId; function showMessage(index) { messages.forEach(msg => msg.classList.remove('active')); messages[index].classList.add('active'); } function nextMessage() { currentIndex = (currentIndex + 1) % messages.length; showMessage(currentIndex); } function prevMessage() { currentIndex = (currentIndex - 1 + messages.length) % messages.length; showMessage(currentIndex); } // Auto-rotate every 5 seconds function startAutoRotate() { intervalId = setInterval(nextMessage, 5000); } function resetAutoRotate() { clearInterval(intervalId); startAutoRotate(); } nextButton.addEventListener('click', () => { nextMessage(); resetAutoRotate(); }); prevButton.addEventListener('click', () => { prevMessage(); resetAutoRotate(); }); startAutoRotate(); const menuButton = document.querySelector('.menu-button'); const navMenu = document.querySelector('.nav-menu'); menuButton.addEventListener('click', () => { navMenu.style.display = navMenu.style.display === 'flex' ? 'none' : 'flex'; }); document.querySelector('.search-input').addEventListener('keypress', function(e) { if (e.key === 'Enter') { e.preventDefault(); this.closest('form').submit(); } });