//constructor
function createAccrual()
{
	var j;

	this.mNumberOfRates = 0;
	this.mRate = new Array();
	this.mBend = new Array();

	for (j=0; j<=20; j++)
	{
		this.mRate[j] = 0;
	this.mBend[j] = 0;
	}
	this.AddRate = AddRate;
	this.Calc = Calc;

	return true;
}

function AddRate(Rate, Bend)
{
	this.mNumberOfRates = this.mNumberOfRates + 1;
	this.mRate[this.mNumberOfRates] = Rate;
	this.mBend[this.mNumberOfRates] = Bend;
}

function Calc(Value)
{
	var j;
	var Result;

	Result = 0;
	this.mBend[this.mNumberOfRates] = Value;
	for (j = 1; j <= this.mNumberOfRates; j++)
		Result = Result + this.mRate[j] * Math.max(0,Math.min(Value,this.mBend[j]) - this.mBend[j-1])
	return Result
}