// Landing Page JavaScript // DOM Content Loaded document.addEventListener('DOMContentLoaded', function() { initializeAnimations(); initializeNavigation(); initializeROICalculator(); initializeChatDemo(); initializeContactForm(); initializeScrollAnimations(); }); // Navigation functionality function initializeNavigation() { const navbar = document.querySelector('.navbar'); const hamburger = document.getElementById('hamburger'); const navMenu = document.getElementById('navMenu'); // Scroll effect for navbar window.addEventListener('scroll', function() { if (window.scrollY > 50) { navbar.classList.add('scrolled'); } else { navbar.classList.remove('scrolled'); } }); // Mobile menu toggle hamburger.addEventListener('click', function() { navMenu.classList.toggle('active'); hamburger.classList.toggle('active'); }); // Smooth scrolling for nav links document.querySelectorAll('.nav-link').forEach(link => { link.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); const targetSection = document.querySelector(targetId); if (targetSection) { targetSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); } // Close mobile menu if open navMenu.classList.remove('active'); hamburger.classList.remove('active'); }); }); } // Scroll animations function initializeScrollAnimations() { const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver(function(entries) { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('aos-animate'); } }); }, observerOptions); // Observe all elements with data-aos attribute document.querySelectorAll('[data-aos]').forEach(el => { observer.observe(el); }); } // ROI Calculator function initializeROICalculator() { const studentCountInput = document.getElementById('studentCount'); const staffCountInput = document.getElementById('staffCount'); const staffSalaryInput = document.getElementById('staffSalary'); const annualSavingsElement = document.getElementById('annualSavings'); const paybackPeriodElement = document.getElementById('paybackPeriod'); const threeYearROIElement = document.getElementById('threeYearROI'); function calculateROI() { const studentCount = parseInt(studentCountInput.value) || 0; const staffCount = parseInt(staffCountInput.value) || 0; const staffSalary = parseInt(staffSalaryInput.value) || 0; // Calculate based on 70% efficiency improvement const currentAnnualCost = staffCount * staffSalary; const staffReduction = Math.floor(staffCount * 0.7); const annualSavings = staffReduction * staffSalary; // Estimate edi.chat cost based on student count let monthlyCost = 2500; // Base cost if (studentCount > 2500) monthlyCost = 5500; if (studentCount > 15000) monthlyCost = 12000; const annualCost = monthlyCost * 12; const netSavings = annualSavings - annualCost; // Payback period in months const paybackMonths = annualCost / (annualSavings / 12); // 3-year ROI const threeYearSavings = netSavings * 3; const threeYearROI = (threeYearSavings / annualCost) * 100; // Update display annualSavingsElement.textContent = `$${netSavings.toLocaleString()}`; paybackPeriodElement.textContent = `${paybackMonths.toFixed(1)} months`; threeYearROIElement.textContent = `${Math.max(0, threeYearROI).toFixed(0)}%`; } // Add event listeners [studentCountInput, staffCountInput, staffSalaryInput].forEach(input => { input.addEventListener('input', calculateROI); }); // Initial calculation calculateROI(); } // Chat Demo Animation function initializeChatDemo() { const messagesContainer = document.getElementById('chatMessages'); if (!messagesContainer) return; // Simulate typing animation function simulateTyping() { const messages = messagesContainer.querySelectorAll('.message'); // Hide all messages initially messages.forEach((message, index) => { message.style.opacity = '0'; message.style.transform = 'translateY(20px)'; }); // Show messages with delay messages.forEach((message, index) => { setTimeout(() => { message.style.transition = 'opacity 0.5s ease, transform 0.5s ease'; message.style.opacity = '1'; message.style.transform = 'translateY(0)'; }, index * 1500); }); } // Start simulation when chat demo is visible const chatDemo = document.querySelector('.chat-demo'); const observerOptions = { threshold: 0.5, rootMargin: '0px' }; const observer = new IntersectionObserver(function(entries) { entries.forEach(entry => { if (entry.isIntersecting) { setTimeout(simulateTyping, 1000); observer.unobserve(entry.target); } }); }, observerOptions); if (chatDemo) { observer.observe(chatDemo); } } // Contact Form function initializeContactForm() { const contactForm = document.getElementById('contactForm'); if (!contactForm) return; contactForm.addEventListener('submit', async function(e) { e.preventDefault(); const submitButton = contactForm.querySelector('.submit-button'); const buttonText = submitButton.querySelector('.button-text'); const buttonLoading = submitButton.querySelector('.button-loading'); // Show loading state buttonText.style.display = 'none'; buttonLoading.style.display = 'flex'; submitButton.disabled = true; // Collect form data const formData = new FormData(contactForm); const data = Object.fromEntries(formData.entries()); try { // Simulate form submission await new Promise(resolve => setTimeout(resolve, 2000)); // Show success message showNotification('Thank you! We\'ll contact you within 24 hours to schedule your demo.', 'success'); contactForm.reset(); } catch (error) { showNotification('There was an error submitting your request. Please try again.', 'error'); } // Reset button state buttonText.style.display = 'inline'; buttonLoading.style.display = 'none'; submitButton.disabled = false; }); } // Demo Modal function openDemo() { const modal = document.getElementById('demoModal'); modal.classList.add('show'); document.body.style.overflow = 'hidden'; } function closeDemo() { const modal = document.getElementById('demoModal'); modal.classList.remove('show'); document.body.style.overflow = 'auto'; } // Close modal when clicking outside document.getElementById('demoModal').addEventListener('click', function(e) { if (e.target === this) { closeDemo(); } }); // Scroll to contact section function scrollToContact() { document.getElementById('contact').scrollIntoView({ behavior: 'smooth', block: 'start' }); } // Notification system function showNotification(message, type = 'info') { // Remove existing notifications const existingNotifications = document.querySelectorAll('.notification'); existingNotifications.forEach(notification => notification.remove()); // Create notification element const notification = document.createElement('div'); notification.className = `notification notification-${type}`; notification.innerHTML = `