/*
	***************************************************
	*********** @Thomas Nelson [Developer] ************
	***********     12th January,2011      ************
	***************************************************
*/
function browserOK(){

		var b_ok	= true;

		b_ok		= b_ok && (navigator.appName.indexOf("Microsoft")!= -1);

		b_ok		= b_ok && parseInt(navigator.appVersion.substring(0,1))>=4;

		return (b_ok);

	}



	function trunc(formElement){

		var sValue = formElement.value;

		formElement.value =
Math.round(sValue*100)/100;

	}



	function getMonths(){

		var time_type 	= 	document.f1.period.selectedIndex;

		var	months	=	document.f1.term.value;

		months			=	(time_type ==1 ) ? months*12 : months;

		return months;

	}



	function update(){

		calculate();

		return false;

	}



	function calculate(){

		var loan = new  Number(document.f1.loan.value);

		var months = getMonths();

		var int_rate = new  Number(document.f1.interest_rate.value);

		// Monthly Payment

		var factor_a = new Number(int_rate/1200);

		var factor_b = new Number(Math.pow((1 + (int_rate/1200)), months));

		var factor_c = new Number(factor_b -1);

		var monthly_payment = new Number(((factor_a * factor_b)/factor_c)* loan);

		// TotalChargeForCredit

		var total_charge_credit = new Number((monthly_payment * months) - loan);

		// TotalRepayment

		var total_repayment = new Number(monthly_payment * months);

		if(total_repayment > 0  ){

			document.f1.monthly_payment.value =  monthly_payment
;

			document.f1.total_charge.value = total_charge_credit;

			document.f1.total_repayment.value = total_repayment;

			trunc(document.f1.monthly_payment);

			trunc(document.f1.total_charge);

			trunc(document.f1.total_repayment);

		}

	}

