function CalculateValues()
{
	var arArray;
	var nMonths;
	var nAmount;
	var nAPR;
	var nMonthlyRate;
	var nMonthlyRepayment;
	var nTotalAmountPayable;
	var bValidValues;
	
	
	bValidValues = true;
	
	arArray = document.loans.ddlAmount.value.split('|');
	if (isNaN(parseInt(arArray[0]))) bValidValues = false;
	if (isNaN(parseInt(arArray[1]))) bValidValues = false;
	if (isNaN(parseInt(document.loans.ddlPeriod.value))) bValidValues = false;
	if (bValidValues)
	{
		nAmount = parseInt(arArray[0]);
		nMonths = parseInt(document.loans.ddlPeriod.value);
		nAPR = parseFloat(arArray[1]);
		document.loans.txtMonthlyPayments.value = GetMonthlyRepaymentAmount(nAmount, nAPR, nMonths);
	}
	else
	{
		document.loans.txtMonthlyPayments.value = "";
	}
}

function GetMonthlyRepaymentAmount(curLoanValue, fltAPR, nPaymentMonths)
{
	var fltMonthlyRate;
	var fltMonthlyRepayment;
	var fltTotalAmountPayable;
	var fltResult;
	
	fltMonthlyRate = 100 * (Math.pow(((fltAPR * 0.01) + 1), (1 / 12)) - 1);
	fltMonthlyRepayment = ((curLoanValue * (fltMonthlyRate * 0.01) * (Math.pow((1 + (fltMonthlyRate * 0.01)), nPaymentMonths))) / (Math.pow((1 + (fltMonthlyRate * 0.01)), nPaymentMonths) -1)) ;
	fltTotalAmountPayable = fltMonthlyRepayment * nPaymentMonths;
	fltResult = (Math.round(fltMonthlyRepayment * 100)) / 100;
	
	return fltResult ;
}
