		/*
		*************************************************
		********* JavaScript Implementation *************
		*************************************************

		Loan Calculator by Sidney Forcier
		sf01@sidneyforcier.com
		
		The formula for calculating loan payments is:
			Pi / (q * (1 - (1 + (i / q))^(-nq)

		Where the variables are as follows:

		 P - The amount of the loan (after down payment)
		 i - The interest expressed as a decimal (e.g. 8% is .08)
		 n - The number of term units (e.g. number of years)
		 q - The number of payments per term unit (e.g. 12 months)

		You can enhance the formulas below by allowing the user to change the number 
		of payments per year if you wish. I have hard-coded the payments to monthly.
		*/
		
		function getsalestax()
		{
			var ntrst = document.auto_loan_calc.sales_tax.value / 100;
			var slstx = ntrst * document.auto_loan_calc.sales_price.value;
			slstx = Math.floor(slstx * 100) / 100;
			if (isNaN(slstx))
				document.auto_loan_calc.sales_tax_money.value = 'Could not compute';
			else
				document.auto_loan_calc.sales_tax_money.value = slstx;
			
		}
		function getothercosts()
		{
			var salesprice = document.auto_loan_calc.sales_price.value;
			var othercosts = salesprice * .015;
			othercosts = Math.floor(othercosts * 100) / 100;
			if (isNaN(othercosts))
				document.auto_loan_calc.sales_tax_money.value = '0';
			else
				document.auto_loan_calc.other_costs.value = othercosts;
			
		}
		
		function CalculatePayments(principal, interest, years)
		{
			var x = ((principal) * interest / (12 * (1 - Math.pow(1 + (interest / 12), (-years * 12)))));
			return Math.floor(x * 100) / 100
		}
		
		function ShowPayments()
		{
			var prin = (parseFloat(document.auto_loan_calc.sales_price.value) + parseFloat(document.auto_loan_calc.sales_tax_money.value) + parseFloat(document.auto_loan_calc.other_costs.value)) - (parseFloat(document.auto_loan_calc.down_payment.value) + parseFloat(document.auto_loan_calc.trade_in_value.value));
			var x = CalculatePayments(prin, document.auto_loan_calc.interest_rate.value / 100, document.auto_loan_calc.years.value);
			if (isNaN(x))
				document.auto_loan_calc.monthly_payment.value = 'Could not compute';
			else
				document.auto_loan_calc.monthly_payment.value = x;
		}