function calculate() {

	var amount = document.mortcalc.amount.value * 1 ;
	var annualrate = document.mortcalc.annualrate.value * 1 ;
	var years = document.mortcalc.years.value * 1 ;

	annualrate = annualrate / 100 ;
	var rate = annualrate / 12 ;
	var months = years * 12 ;
	var payment = (amount * Math.pow((1 + rate), months) * rate) / (Math.pow((1 + rate), months) - 1) ;
	
	payment = payment + "" ;
	var decpos = payment.indexOf(".") ;
	var monthlypayment = payment.substring(0,decpos + 3) ;
	document.mortcalc.finished.value = monthlypayment ;

}