//*******************************************
//DO NOT REMOVE THIS COPYWRITE INFO!
//Simple Loan Calculator
//1998 Daniel C. Peterson ALL RIGHTS RESERVED
//Created: 08/21/1998
//Last Modified: 07/30/2002
//This script may not be copied, edited, distributed or reproduced
//without express written permission from
//Daniel C. Peterson of Web Winder Website Services
//For commercial use rates, contact:
//Dan Peterson:
//Web Winder Website Services
//P.O. Box 11
//Bemidji, MN  56619
//dan@webwinder.com
//Commercial User Licence #:1498-410-66-399
//Commercial Licence Date:2004-07-28
//*******************************************


function calculate(){


	var PV = Number(document.getElementById('PV').value); 
	var N = Number(document.getElementById('N').value); 
	var i = Number(document.getElementById('i').value); 
	//var PV = Number(document.forms[1].PV.value);
	//var N = Number(document.forms[1].N.value);
	//var i = Number(document.forms[1].i.value);
	
	var time = Number(document.getElementById('time').selectedIndex); 
	//var time = Number(document.forms[1].time.selectedIndex);

	var mPMT = 0;
	var tPMT = 0;
	var tINT = 0;

    if (i >= 1.0) { i = i / 100;}
	i = i / 12;
	
	if ( time == 1 ){ N = N;}
	if ( time == 0 ){ N = N * 12;}


	var x = 1 + i;

   mPMT = ( PV * Math.pow(x,N) ) / ( ( ( Math.pow(x,N) - 1 ) / i ) );
   tPMT = mPMT * N;
   tINT = tPMT - PV;
   
   document.getElementById('mPMT').value = Math.round( 100 * mPMT)/ 100;
   document.getElementById('tPMT').value = Math.round( 100 * tPMT)/ 100;
   document.getElementById('tINT').value = Math.round( 100 * tINT)/ 100;
   //document.forms[1].mPMT.value = Math.round( 100 * mPMT)/ 100;
   //document.forms[1].tPMT.value = Math.round( 100 * tPMT)/ 100;
   //document.forms[1].tINT.value = Math.round( 100 * tINT)/ 100;

}


