/**
 * HVAC Attendee Profile JavaScript
 * Handles timeline animations and interactions
 */

jQuery(document).ready(function($) {
    'use strict';

    // Animate timeline items on scroll
    function animateTimeline() {
        $('.hvac-timeline-item').each(function() {
            var $this = $(this);
            var elementTop = $this.offset().top;
            var elementBottom = elementTop + $this.outerHeight();
            var viewportTop = $(window).scrollTop();
            var viewportBottom = viewportTop + $(window).height();

            if (elementBottom > viewportTop && elementTop < viewportBottom) {
                $this.addClass('hvac-timeline-visible');
            }
        });
    }

    // Initial animation check
    animateTimeline();

    // Animate on scroll
    $(window).on('scroll', animateTimeline);

    // Print functionality
    $('.hvac-button[onclick*="print"]').on('click', function(e) {
        e.preventDefault();
        window.print();
    });

    // Smooth scroll for timeline
    $('.hvac-timeline-item').on('click', '.hvac-event-link', function(e) {
        // Allow default link behavior but add tracking if needed
        console.log('Event link clicked:', $(this).attr('href'));
    });

    // Add hover effects to timeline items
    $('.hvac-timeline-item').hover(
        function() {
            $(this).find('.hvac-timeline-content').addClass('hvac-timeline-hover');
        },
        function() {
            $(this).find('.hvac-timeline-content').removeClass('hvac-timeline-hover');
        }
    );
});