// AquaSculpt Supplement Website - JavaScript document.addEventListener('DOMContentLoaded', function() { // FAQ Toggle Functionality const faqItems = document.querySelectorAll('.as-faq-item'); faqItems.forEach(item => { const question = item.querySelector('.as-faq-question'); if (question) { question.addEventListener('click', function() { item.classList.toggle('as-active'); }); } }); // Mobile Menu Toggle const hamburger = document.querySelector('.as-hamburger'); const nav = document.querySelector('.as-nav'); if (hamburger && nav) { hamburger.addEventListener('click', function() { nav.classList.toggle('as-mobile-active'); }); } // Smooth Scroll for Anchor Links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { const href = this.getAttribute('href'); if (href !== '#') { e.preventDefault(); const target = document.querySelector(href); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } } }); }); // Sticky Order Button Scroll Visibility const stickyOrder = document.querySelector('.as-sticky-order'); if (stickyOrder) { window.addEventListener('scroll', function() { const heroSection = document.querySelector('.as-hero'); if (heroSection) { const heroBottom = heroSection.offsetTop + heroSection.offsetHeight; if (window.scrollY > heroBottom) { stickyOrder.style.display = 'block'; } else { stickyOrder.style.display = 'none'; } } }); // Initial check window.dispatchEvent(new Event('scroll')); } // Close mobile menu when link is clicked const navLinks = document.querySelectorAll('.as-nav a'); navLinks.forEach(link => { link.addEventListener('click', function() { if (nav) { nav.classList.remove('as-mobile-active'); } }); }); // Add current page styling to nav links const currentLocation = location.pathname; const navItems = document.querySelectorAll('.as-nav a'); navItems.forEach(link => { const href = link.getAttribute('href'); if (href && (currentLocation.includes(href) || (currentLocation === '/' && href === 'index.html') || (currentLocation === '/index.html' && href === 'index.html'))) { link.parentElement.classList.add('as-active'); } }); // Ensure no horizontal overflow on mobile function checkOverflow() { const body = document.body; if (body.scrollHeight > window.innerHeight) { // Page has content, CSS handles overflow-x } } window.addEventListener('resize', checkOverflow); checkOverflow(); }); // Tracking for CTA clicks function trackCTA(source) { console.log('CTA Clicked from: ' + source); // Can be used for analytics integration }