<!-- Loan Calc start --> 

<!--
function round(number,X) 
{
	// rounds number to X decimal places, defaults to 2
	X = (!X ? 2 : X);
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function showpay() 
{
	 if ((document.calc.loan.value == null || document.calc.loan.value.length == 0) || (document.calc.months.value == null || document.calc.months.value.length == 0) || (document.calc.rate.value == null || document.calc.rate.value.length == 0))
	 { 
		//document.calc.pay.value = "Incomplete data";
	 }
	 else
	 {
		 var princ = document.calc.loan.value;
		 princ=princ * (1 + (parseFloat("0" + document.calc.txtGST.value) + parseFloat("0" + document.calc.txtPST.value) + parseFloat("0" + document.calc.txtHST.value))/100);
		 princ=princ - (parseFloat("0" + document.calc.txtDownPayment.value)+parseFloat("0" + document.calc.txtTrade.value)+parseFloat("0" + document.calc.txtRebate.value));
		 var term  = document.calc.months.value;
		 var intr   = document.calc.rate.value / 1200;
		 document.calc.pay.value = round(princ * intr / (1 - (Math.pow(1/(1 + intr), term))),2);
		 document.calc.txtBiWeekly.value=round(document.calc.pay.value * 24/52,2);
	 }

// payment = principle * monthly interest/(1 - (1/(1+MonthlyInterest)*Months))

}

// --> 


//Makes sure that the entered value is a number
// use via onKeyPress="checkNum()" on the textbox
function checkNum()
{
	var carCode = event.keyCode;
	//alert(carCode);
	if ((carCode!=46 && carCode < 48) || (carCode > 57))
	{
		alert('Please enter only numbers.');	
		event.cancelBubble = true;	
		event.returnValue = false;	
	}
}


