File size: 2,503 Bytes
0305ba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Shared JavaScript across all pages
document.addEventListener('DOMContentLoaded', function() {
    // Donation amount selection
    const amountButtons = document.querySelectorAll('.amount-btn');
    const otherAmountContainer = document.getElementById('other-amount');
    const customAmountInput = document.getElementById('custom-amount');
    
    amountButtons.forEach(button => {
        button.addEventListener('click', function() {
            // Remove active class from all buttons
            amountButtons.forEach(btn => btn.classList.remove('active'));
            
            // Add active class to clicked button
            this.classList.add('active');
            
            // Show/hide custom amount input
            if (this.textContent === 'Other') {
                otherAmountContainer.classList.remove('hidden');
                customAmountInput.focus();
            } else {
                otherAmountContainer.classList.add('hidden');
            }
        });
    });
    
    // Donation form submission
    const donationForm = document.getElementById('donation-form');
    if (donationForm) {
        donationForm.addEventListener('submit', function(e) {
            e.preventDefault();
            
            // Get selected amount
            let amount = '';
            const activeButton = document.querySelector('.amount-btn.active');
            if (activeButton) {
                if (activeButton.textContent === 'Other') {
                    amount = customAmountInput.value || '0';
                } else {
                    amount = activeButton.textContent.replace('$', '');
                }
            }
            
            // In a real application, you would process the payment here
            alert(`Thank you for your donation of $${amount}! Your contribution makes a difference.`);
            donationForm.reset();
            document.querySelector('.amount-btn:first-child').classList.add('active');
            otherAmountContainer.classList.add('hidden');
        });
    }
    
    // Newsletter form submission
    const newsletterForm = document.getElementById('newsletter-form');
    if (newsletterForm) {
        newsletterForm.addEventListener('submit', function(e) {
            e.preventDefault();
            const email = this.querySelector('input[type="email"]').value;
            alert(`Thank you for subscribing with ${email}! You'll receive our next update soon.`);
            this.reset();
        });
    }
});