<!--
	//checks that data is valid 
	function checkNumber(input, min, max, msg) {

		msg = msg + " field not correct !: " + input.value;


		//validate number
		var str = input.value;
		for (var i = 0; i < str.length; i++) {
			var ch = str.substring( i, i + 1)
			if ((ch < "0" || "9" < ch) && ch != '.') {
				alert(msg);
				return false;
			}
		}

		//validate min and max values
		var num = 0 + str
		if (num < min || max < num) {
			alert(msg + " not in range [" + min + ".." + max + "]");
			return false;
		}
		input.value = str;
		return true;
	}

	function computeField(input) {
		if (input.value != null && input.value.length != 0)
		{
			input.value = "" + eval(input.value);
		}
		computeForm(input.form);
	}

	function computeForm(form) {
		var loan=form.loan.value;
		var term=form.term.value;
		var interest=form.interest.value;

		//making sure that an entry has been made in each field.
		if ((loan == null || loan.length == 0) ||
			(interest == null || interest.length == 0)) 
		{
			alert('not all fields filled in');
			return;
		}

		// validate data entry
		if (!checkNumber(form.loan, 1, 999999, "loanmount") ||
			!checkNumber(form.interest, .001, 1000, "Interest interestate") ||
			!checkNumber(form.term, 0, 40, "Period")) 
		{
			form.repayment.value = "Invalid";
			return;
		}

		// calculations
	
		interest = interest / 100;
		//other_eg = 0.08 //8%
		var P = ((loan*interest)/12) * (1/(1-(Math.pow(1/(1+interest),term))));
		//var _with_dec = poundsPence( P );		
		//form.repayment.value
		form.repayment.value = poundsPence( P );
		
		//P = ((loan*other_eg)/12) * (1 / (1-(Math.pow(1/(1+other_eg),term))));
		//form.CCm.value = poundsPence( P );
		
		
		 
		//P = (loan*other_eg)/12;
		//form.CCI.value = poundsPence( P );
		
		P = (loan*interest)/12;
		//var cost_with_dec = poundsPence( P );		
		//Final number sent back to FORM - sets number of dec places
		//form.int_only.value = cost_with_dec.toFixed(2)
		form.int_only.value = poundsPence( P );
	}

	function poundsPence( N ) {
		
		//For Microsoft Browsers
		if ((navigator.appName.indexOf('Microsoft')>-1)
			&& (navigator.appVersion.indexOf('3.0')>-1) )
		{
			//return N;
			
			var res = N.toFixed(2)
			return res;
			
		}
		//For other Browsers (FF)
		S = new String( N );
		var i = S.indexOf('.');
		if (i != -1) {
			S = S.substr( 0, i+3 );
			if (S.length-i < 3)
				S = S + '0';
		}
		return S;
	}

	//clear the form
	//function clearForm(form) {
		//form.loan.value = "";
		//form.term.value = "";
		//form.interest.value = "";
	//}

//-->
