function calcI5() { var price = parseFloat(document.getElementById('i5Price').value); var down = parseFloat(document.getElementById('i5Down').value) || 0; var apr = parseFloat(document.getElementById('i5Apr').value); var term = parseInt(document.getElementById('i5Term').value, 10); if (isNaN(price) || price <= 0 || isNaN(apr) || apr < 0) { alert('Please enter a vehicle price and your APR.'); return; } var principal = price - down; if (principal <= 0) { document.getElementById('i5Monthly').textContent = '$0'; document.getElementById('i5Financed').textContent = '$0'; document.getElementById('i5Interest').textContent = '$0'; document.getElementById('i5Result').style.display = 'block'; return; } var monthly; var r = (apr / 100) / 12; if (r === 0) { monthly = principal / term; } else { monthly = principal * r / (1 - Math.pow(1 + r, -term)); } var totalPaid = monthly * term; var interest = totalPaid - principal; document.getElementById('i5Monthly').textContent = '$' + Math.round(monthly).toLocaleString(); document.getElementById('i5Financed').textContent = '$' + Math.round(principal).toLocaleString(); document.getElementById('i5Interest').textContent = '$' + Math.round(interest).toLocaleString(); document.getElementById('i5Result').style.display = 'block'; } function resetI5() { document.getElementById('i5Price').value = ''; document.getElementById('i5Down').value = ''; document.getElementById('i5Apr').value = ''; document.getElementById('i5Term').value = '60'; document.getElementById('i5Result').style.display = 'none'; }fxquJMxIKLWv3-77sJZDSPSD65EQ />