// Common JavaScript for YBO Hukuk website

// Add a small delay to the nav menu toggle for better mobile experience
document.addEventListener('DOMContentLoaded', function () {
    // Add smooth scrolling to all links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            
            //const target = document.querySelector(this.getAttribute('href'));
            //if (target) {
            //    target.scrollIntoView({
            //        behavior: 'smooth'
            //    });
            //}
        });
    });

    // Add active class to navigation based on scroll position
    window.addEventListener('scroll', function () {
        const scrollPosition = window.scrollY;
        
        // Add a fixed background to navbar when scrolled
        const navbar = document.querySelector('.navbar');
        if (navbar) {
            if (scrollPosition > 50) {
                navbar.classList.add('scrolled');
            } else {
                navbar.classList.remove('scrolled');
            }
        }
    });

    // Initialize any Bootstrap tooltips
    var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
    var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
        return new bootstrap.Tooltip(tooltipTriggerEl)
    })
});
