//<--

function calculateNewDeposit(templ,mytxt,mytempl)
{
var myinterest='';
var myammount='';
var mysuf='_'+mytempl;

var mywithdr='';
if (document.getElementById('newwithdrawal'+mysuf)!=undefined){
	mywithdr=document.getElementById('newwithdrawal'+mysuf).value;
	}

var destarr={};
if (mywithdr){
	if (calcobj[mytempl][mywithdr]!=undefined) destarr=calcobj[mytempl][mywithdr];
	else {
		alert(mytxt);
		return 0;
		}
	}
else {
	if (calcobj[mytempl]["yes"]!=undefined) destarr=calcobj[mytempl]["yes"];
	else if (calcobj[mytempl]["no"]!=undefined) destarr=calcobj[mytempl]["no"];
	else {
		alert(mytxt);
		return 0;
		}
	}

var mymonths;
if (document.getElementById('newterm'+mysuf)) mymonths=document.getElementById('newterm'+mysuf).value;
else {
	alert(mytxt);
	return 0;
	}

var mycurr;
if (document.getElementById('newcurrency'+mysuf)) mycurr=document.getElementById('newcurrency'+mysuf).value;
else {
	alert(mytxt);
	return 0;
	}

if (destarr[mymonths]!=undefined && destarr[mymonths][mycurr]){
	myinterest=destarr[mymonths][mycurr];
	document.getElementById('newinterest'+mysuf).value=myinterest+'%';
	}
if (!myinterest){
	alert(mytxt);
	return 0;
	}

var firstam=0;
if (document.getElementById('newfirstammount'+mysuf)){
	firstam=document.getElementById('newfirstammount'+mysuf).value;
	if (parseInt(firstam)) firstam=parseInt(firstam);
	else firstam=0;
	}
if (!firstam){
	alert(mytxt);
	return 0;
	}

if (templ=='termcalc'){
	//myammount=firstam*myinterest*mymonths/1200;
	myammount=firstam*myinterest/36500*(mymonths*30);
	}
else {
	var montham=0;
	if (document.getElementById('newmonthlyammount'+mysuf)){
		montham=document.getElementById('newmonthlyammount'+mysuf).value;
		if (parseInt(montham)) montham=parseInt(montham);
		else montham=0;
		}
	if (!montham){
		alert(mytxt);
		return 0;
		}
	mymonths=parseFloat(mymonths);
	var myinterest2=parseFloat(myinterest)/1200;
	montham=parseFloat(montham);
	firstam=parseFloat(firstam);
	mymonths=parseFloat(mymonths);
	myammount=parseFloat(fv(myinterest2, mymonths-1, -montham, 0, 1))+parseFloat(((firstam*myinterest*mymonths)/1200)+firstam);
	}

myammount=Math.round(parseFloat(myammount)*100)/100;
document.getElementById('newtotal'+mysuf).value=myammount;
}


//future value FV Excel function

function fv(rate, nper, pmt, pv, type) {

    // Validate parameters
    if (type != 0 && type != 1) {
        return false;
    }

    // Calculate
    if (rate != 0.0) {
        return -pv * Math.pow(1 + rate, nper) - pmt * (1 + rate * type) * (Math.pow(1 + rate, nper) - 1) / rate;
    } else {
        return -pv - pmt * per;
    }
}   //  function FV()

//-->
