//This function calculates the Net Present Value.
//The inflation rate and the discount rate passed into this function must be passed as a percentage and not a fraction.
//For example, 5% must be passed as 5 and not as .05 and 5.5% must be passed as 5.5 and not .055.
function calculateNPV(annualCost, parmInflationRate, parmDiscountRate, numberOfYears)
{
	var calcAnnualCost = parseFloat(annualCost);
	var calcInflationRate = parseFloat(parseFloat(parmInflationRate) / 100);
	var calcDiscountRate = parseFloat(parseFloat(parmDiscountRate) / 100);

	var futureValue = 0;
	var presentValue = 0;
	var netPresentValue = 0;
	
	for (i=1;i<=numberOfYears;i++)
	{
		futureValue = calcAnnualCost * (Math.pow((1 + calcInflationRate),(i-1)));
		presentValue = futureValue / (Math.pow((1 + calcDiscountRate),(i-1)));
		netPresentValue += presentValue;
	}

	return (Math.round(netPresentValue));
}
