File size: 3,342 Bytes
f59e1ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Main JavaScript functionality

document.addEventListener('DOMContentLoaded', function() {
    // Initialize tooltips
    const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
    
    if (tooltipTriggerList.length > 0) {
        tooltipTriggerList.map(function (tooltipTriggerEl) {
            return new bootstrap.Tooltip(tooltipTriggerEl);
        });
    }

    // Smooth scroll for anchor links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            document.querySelector(this.getAttribute('href')).scrollIntoView({
                behavior: 'smooth'
            });
        });
    });

    // Age calculator for demonstration purposes
    const currentYear = new Date().getFullYear();
    const targetYear = 2025;
    const cutoffAge = 42;
    
    const ageCalcForm = document.getElementById('age-calculator');
    if (ageCalcForm) {
        ageCalcForm.addEventListener('submit', function(e) {
            e.preventDefault();
            const birthYear = parseInt(document.getElementById('birth-year').value);
            const ageIn2025 = targetYear - birthYear;
            
            const resultElement = document.getElementById('age-result');
            resultElement.innerHTML = `
                <div class="mt-4 p-4 rounded-lg ${ageIn2025 > cutoffAge ? 'bg-red-100 text-red-800' : 'bg-green-100 text-green-800'}">
                    <p>In 2025, you will be <strong>${ageIn2025} years old</strong>.</p>
                    <p class="mt-2">${ageIn2025 > cutoffAge ? 
                        'This exceeds the standard cutoff age, but waiver options may be available.' : 
                        'You meet the standard age requirements!'}</p>
                </div>
            `;
        });
    }
});

// Back to top button functionality
window.addEventListener('scroll', function() {
    const backToTopButton = document.getElementById('back-to-top');
    if (backToTopButton) {
        if (window.pageYOffset > 300) {
            backToTopButton.classList.remove('opacity-0', 'invisible');
            backToTopButton.classList.add('opacity-100', 'visible');
        } else {
            backToTopButton.classList.remove('opacity-100', 'visible');
            backToTopButton.classList.add('opacity-0', 'invisible');
        }
    }
});

// Initialize any modals or popups
function initModal(modalId) {
    const modal = document.getElementById(modalId);
    if (modal) {
        const openButtons = document.querySelectorAll(`[data-modal-target="${modalId}"]`);
        const closeButton = modal.querySelector('.modal-close');
        
        openButtons.forEach(btn => {
            btn.addEventListener('click', () => {
                modal.classList.remove('hidden');
                document.body.style.overflow = 'hidden';
            });
        });
        
        closeButton.addEventListener('click', () => {
            modal.classList.add('hidden');
            document.body.style.overflow = 'auto';
        });
        
        window.addEventListener('click', (e) => {
            if (e.target === modal) {
                modal.classList.add('hidden');
                document.body.style.overflow = 'auto';
            }
        });
    }
}