// Gerenciador de Abas function openTab(tabName) { // Esconder todas as seções const contents = document.querySelectorAll('.tab-content'); contents.forEach(content => content.classList.remove('active')); // Remover estado ativo dos links const links = document.querySelectorAll('.tab-link'); links.forEach(link => link.classList.remove('active')); // Ativar a seção e o link clicado document.getElementById(tabName).classList.add('active'); document.getElementById('link-' + tabName).classList.add('active'); window.scrollTo({ top: 0, behavior: 'smooth' }); } // Lógica da Calculadora de Juros Compostos function calculateInterest() { const initial = parseFloat(document.getElementById('initial').value) || 0; const monthly = parseFloat(document.getElementById('monthly').value) || 0; const rateAnnual = parseFloat(document.getElementById('rate').value) || 0; const years = parseFloat(document.getElementById('years').value) || 0; const months = years * 12; const rateMonthly = (rateAnnual / 100) / 12; // Fórmula: A = P(1+r)^n + PMT [ ((1+r)^n - 1) / r ] let total = initial * Math.pow(1 + rateMonthly, months); if (rateMonthly > 0) { total += monthly * ((Math.pow(1 + rateMonthly, months) - 1) / rateMonthly); } else { total += monthly * months; } const formatter = new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }); document.getElementById('result-value').innerText = formatter.format(total); document.getElementById('result-details').innerText = `Projeção baseada em ${months} meses de aportes.`; document.getElementById('calc-result').style.display = 'block'; }