// Infation Erosion Index Calculator 
/*
	This function will be return Expected Cost after the time period
	@return FltExpectedCost
*/
function getExpectedCost(frmInflationCalc)
{
	var fieldCurrentPrice = frmInflationCalc.CurrentPrice;
	var fieldInflationRate = frmInflationCalc.InflationRate;
	var fieldTimePeriod = frmInflationCalc.TimePeriod;
	var FltExpectedCost = 0.0;
	
	//Current Price
	CurrentPrice = fieldCurrentPrice.value; 
	//Expected Inflation Index
	InflationRate = fieldInflationRate.value;
	//The time period after which the cost is to be calculated
	TimePeriod = fieldTimePeriod.value;
	
	var vResult = document.getElementById('result');	
	
	if(CurrentPrice == "")
	{
		alert("Please enter Current Price");
		fieldCurrentPrice.focus();
		return false;
		//CurrentPrice = 0.0;
	}
	if(InflationRate == "")
	{
		alert("Please enter the Expected Inflation Index");
		fieldInflationRate.focus();
		return false;
		//InflationRate = 0;
	}
	if(TimePeriod == "")
	{
		alert("Please enter the time period");
		fieldTimePeriod.focus();
		return false;
		//TimePeriod = 0;
	}	
	
	InflationRate = InflationRate/100;	
	//calulates the rate after period of time
	var vInflationRate = 1 + InflationRate;	
	vInflationRate = Math.pow(vInflationRate,TimePeriod)
	//Calcuates the expected cost after period of time
	FltExpectedCost = CurrentPrice * vInflationRate	;
	
	var strFltExpectedCost = new String(FltExpectedCost);
	//Takes only three numbers from decimal point
	for(var i=0; i<strFltExpectedCost.length;i++)
	{
		if(strFltExpectedCost.charAt(i) == ".")
		{
			strFltExpectedCost = strFltExpectedCost.substr(0,i+4);
		}
	}
		
	vResult.innerHTML  = Math.round(strFltExpectedCost,0);	
}//end of getExpectedCost() method

//Deletes the content enterd by the user
function del()
{
         document.getElementById("a").value='';
         document.getElementById("b").value='';
         document.getElementById("c").value='';
         document.getElementById("result").innerHTML='';
}

//Takes number from 0 to 9
function onlyNums()
{	
  if((event.keyCode >= 48 && event.keyCode <= 57))
	{
		return true;
	}
	return false;
}

//Takes number from 0 to 9 and also dot
function onlyNumsDot()
{
	if((event.keyCode >= 48&& event.keyCode <= 57 || event.keyCode == 46))
	{
		return true;
	}
	return false;
}

function numeric(field)
{
	var vFieldValue = field.value;
	var vFieldLength = field.value.length;
	var vStringValue = new String();
	var j=0;
	var k=0;
	for(var i=0; i<vFieldLength; i++)
	{
		if(vFieldValue.charAt(i)=='.')
		{
			j=j+1;
			if(j>=2)
			{
				continue;
			}
		}
		if(vFieldValue.charAt(i)<=9 || vFieldValue.charAt(i) >=0 || vFieldValue.charAt(i)=='.')
		{
			k=k+1;
			vStringValue = vStringValue + vFieldValue.charAt(i);
		}
	}
	if(k==0)
	{
		field.value="";
		return;
	}
	field.value=parseFloat(vStringValue);
	return;
}