// Page load animations window.addEventListener('load', () => { setTimeout(() => { document.getElementById('loader').style.display = 'none'; }, 1500); // Animate counters const counters = document.querySelectorAll('.counter'); const speed = 200; counters.forEach(counter => { const animate = () => { const value = +counter.getAttribute('data-target'); const data = +counter.innerText; const time = value / speed; if (data < value) { counter.innerText = Math.ceil(data + time); setTimeout(animate, 10); } else { counter.innerText = value.toLocaleString(); } } animate(); }); }); // Smooth scroll to section function scrollToSection(sectionId) { const section = document.getElementById(sectionId); if (section) { section.scrollIntoView({ behavior: 'smooth' }); } } // Investment plan selection let selectedPlanData = {}; let userInvestments = []; function selectPlan(plan, daily, withdrawal, fixedAmount) { selectedPlanData = { plan, daily, withdrawal, amount: fixedAmount }; document.getElementById('modalPlan').value = `${plan} Plan - ${daily} daily - Fixed ${fixedAmount}`; document.getElementById('modalAmount').value = fixedAmount; document.getElementById('modalAmount').readOnly = true; document.getElementById('investModal').classList.remove('hidden'); document.getElementById('investModal').classList.add('flex'); document.body.style.overflow = 'hidden'; } // Smooth scrolling for anchor links document.addEventListener('DOMContentLoaded', function() { const links = document.querySelectorAll('a[href^="#"]'); links.forEach(link => { link.addEventListener('click', function(e) { const href = this.getAttribute('href'); if (href !== '#') { e.preventDefault(); const target = document.querySelector(href); if (target) { const offsetTop = target.offsetTop - 80; // Account for fixed navbar window.scrollTo({ top: offsetTop, behavior: 'smooth' }); } } }); }); }); function closeInvestModal() { document.getElementById('investModal').classList.add('hidden'); document.getElementById('investModal').classList.remove('flex'); document.body.style.overflow = 'auto'; } function confirmInvestment() { const amount = document.getElementById('modalAmount').value; const wallet = document.getElementById('modalWallet').value; if (!amount || !wallet) { showNotification('Please fill in all fields', 'error'); return; } // Check if amount matches the fixed amount for the plan const fixedAmounts = { 'Starter': 10, 'Professional': 100, 'VIP': 1000 }; if (parseFloat(amount) !== fixedAmounts[selectedPlanData.plan]) { showNotification(`For ${selectedPlanData.plan} plan, the investment amount must be exactly ${fixedAmounts[selectedPlanData.plan]}`, 'error'); return; } // Add investment to user's portfolio const investment = { plan: selectedPlanData.plan, amount: parseFloat(amount), daily: selectedPlanData.daily, withdrawal: selectedPlanData.withdrawal, wallet: wallet, startDate: new Date().toISOString(), id: Date.now() }; userInvestments.push(investment); localStorage.setItem('userInvestments', JSON.stringify(userInvestments)); showNotification(`Investment of ${amount} confirmed for ${selectedPlanData.plan} plan! You can purchase additional plans if desired.`, 'success'); closeInvestModal(); // Reset form document.getElementById('modalAmount').value = ''; document.getElementById('modalWallet').value = ''; document.getElementById('modalAmount').readOnly = false; } // Load user investments on page load window.addEventListener('load', () => { const saved = localStorage.getItem('userInvestments'); if (saved) { userInvestments = JSON.parse(saved); } }); // Calculator functionality function calculateReturns() { const amount = parseFloat(document.getElementById('calcAmount').value) || 0; const daily = 1; // Fixed at 1% const days = parseInt(document.getElementById('calcDays').value) || 0; const compound = document.getElementById('calcCompound').value; if (!amount || !days) { showNotification('Please enter investment amount and period', 'error'); return; } let totalReturn; if (compound === 'daily') { totalReturn = amount * Math.pow(1 + (daily / 100), days); } else { totalReturn = amount + (amount * (daily / 100) * days); } const netProfit = totalReturn - amount; document.getElementById('totalReturn').textContent = totalReturn.toFixed(2).toLocaleString(); document.getElementById('netProfit').textContent = netProfit.toFixed(2).toLocaleString(); document.getElementById('calcResults').classList.remove('hidden'); } // FAQ toggle function toggleFAQ(id) { const content = document.getElementById(`faq-${id}`); const icon = document.getElementById(`faq-icon-${id}`); if (content.classList.contains('hidden')) { content.classList.remove('hidden'); icon.style.transform = 'rotate(180deg)'; } else { content.classList.add('hidden'); icon.style.transform = 'rotate(0deg)'; } } // Registration modal function showRegistration() { document.getElementById('regModal').classList.remove('hidden'); document.getElementById('regModal').classList.add('flex'); document.body.style.overflow = 'hidden'; } function closeRegModal() { document.getElementById('regModal').classList.add('hidden'); document.getElementById('regModal').classList.remove('flex'); document.body.style.overflow = 'auto'; } function handleRegistration(event) { event.preventDefault(); const formData = new FormData(event.target); showNotification('Account created successfully! Check your email for verification.', 'success'); closeRegModal(); event.target.reset(); } // Login modal function showLogin() { const loginModal = document.querySelector('login-modal'); if (loginModal) { const overlay = loginModal.shadowRoot.getElementById('loginModal'); if (overlay) { overlay.style.display = 'flex'; document.body.style.overflow = 'hidden'; } } } function closeLoginModal() { const loginModal = document.querySelector('login-modal'); if (loginModal) { const overlay = loginModal.shadowRoot.getElementById('loginModal'); if (overlay) { overlay.style.display = 'none'; document.body.style.overflow = 'auto'; } } } function handleLogin(event) { event.preventDefault(); showNotification('Login successful! Welcome back.', 'success'); closeLoginModal(); event.target.reset(); } // Notification system function showNotification(message, type = 'info') { const notification = document.createElement('div'); notification.className = `fixed top-4 right-4 z-50 px-6 py-4 rounded-lg shadow-lg transform transition-all duration-500 ${ type === 'success' ? 'bg-green-500' : type === 'error' ? 'bg-red-500' : type === 'warning' ? 'bg-yellow-500' : 'bg-blue-500' } text-white`; notification.innerHTML = `
${message}
`; document.body.appendChild(notification); feather.replace(); setTimeout(() => { notification.style.transform = 'translateX(400px)'; setTimeout(() => notification.remove(), 500); }, 3000); } // Live ticker simulation function updateLiveTicker() { const tickers = document.querySelectorAll('.live-ticker'); tickers.forEach(ticker => { const currentValue = parseFloat(ticker.textContent.replace(/[^0-9.-]/g, '')); const change = (Math.random() - 0.5) * 2; const newValue = currentValue + change; ticker.textContent = newValue.toFixed(2) + '%'; ticker.className = `live-ticker ${change > 0 ? 'text-green-500' : 'text-red-500'}`; }); } // Simulate live data updates setInterval(() => { // Update random stats const statElements = document.querySelectorAll('.live-stat'); if (statElements.length > 0) { const randomStat = statElements[Math.floor(Math.random() * statElements.length)]; const current = parseInt(randomStat.textContent.replace(/[^0-9]/g, '')); randomStat.textContent = (current + Math.floor(Math.random() * 10)).toLocaleString(); } }, 5000); // Add parallax effect on scroll window.addEventListener('scroll', () => { const scrolled = window.pageYOffset; const parallaxElements = document.querySelectorAll('.parallax'); parallaxElements.forEach(element => { const speed = element.dataset.speed || 0.5; element.style.transform = `translateY(${scrolled * speed}px)`; }); }); // Form validation enhancements document.querySelectorAll('input[type="number"]').forEach(input => { input.addEventListener('input', function() { if (this.value < 0) this.value = 0; if (this.value > 9999999) this.value = 9999999; }); }); // Add ripple effect to buttons document.querySelectorAll('button').forEach(button => { button.addEventListener('click', function(e) { const ripple = document.createElement('span'); ripple.className = 'absolute bg-white opacity-30 rounded-full animate-ping'; ripple.style.width = ripple.style.height = '20px'; ripple.style.left = e.offsetX - 10 + 'px'; ripple.style.top = e.offsetY - 10 + 'px'; this.style.position = 'relative'; this.style.overflow = 'hidden'; this.appendChild(ripple); setTimeout(() => ripple.remove(), 600); }); });