document.addEventListener('DOMContentLoaded', function() { // Initialize AOS animation library AOS.init({ duration: 800, offset: 100, once: true }); // Mobile menu toggle const mobileMenuBtn = document.querySelector('.mobile-menu'); const navLinks = document.querySelector('.nav-links'); mobileMenuBtn.addEventListener('click', () => { navLinks.style.display = navLinks.style.display === 'flex' ? 'none' : 'flex'; }); // Update navigation links to point to new pages document.querySelectorAll('.nav-links a').forEach(link => { const href = link.getAttribute('href'); if (href === '#servicos') { link.setAttribute('href', 'servicos.html'); } else if (href === '#sobre') { link.setAttribute('href', 'sobre.html'); } }); // Smooth scroll for navigation links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); target.scrollIntoView({ behavior: 'smooth' }); // Close mobile menu after clicking a link if (window.innerWidth <= 768) { navLinks.style.display = 'none'; } }); }); // However, we need to update this part to prevent the default behavior of links that now point to external pages document.querySelectorAll('.nav-links a').forEach(link => { link.addEventListener('click', function (e) { const href = link.getAttribute('href'); if (href === 'servicos.html' || href === 'sobre.html') { // Do nothing and let the link behave normally } else { e.preventDefault(); const target = document.querySelector(href); target.scrollIntoView({ behavior: 'smooth' }); // Close mobile menu after clicking a link if (window.innerWidth <= 768) { navLinks.style.display = 'none'; } } }); }); // Contact form handling const contactForm = document.getElementById('contact-form'); contactForm.addEventListener('submit', function(e) { e.preventDefault(); // Here you would typically send the form data to a server // For now, we'll just show an alert alert('Obrigado pelo seu contacto! Responderemos em breve.'); contactForm.reset(); }); // Add scroll event listener for header const header = document.querySelector('header'); let lastScroll = 0; window.addEventListener('scroll', () => { const currentScroll = window.pageYOffset; if (currentScroll > lastScroll) { header.style.transform = 'translateY(-100%)'; } else { header.style.transform = 'translateY(0)'; } lastScroll = currentScroll; }); });