var co = new Object;
function recalc_onclick(ctl) 
{{
if (document.formc.pA1B.value<=0){
	alert("Initial Investment Amount must be a number greater than zero");
	document.formc.pA4B.value="";
	document.formc.pA5B.value="";
	document.formc.pA6B.value="";
	document.formc.pA7B.value="";
	document.formc.pA8B.value="";
	document.formc.pA9B.value="";
return;
}

x = document.formc.pA2B.value;
x = x.replace(/[^0-9.-]/g, '');
if (x<=0){
	alert("Annual Interest Rate (%) must be a number greater than zero")
	document.formc.pA4B.value="";
	document.formc.pA5B.value="";
	document.formc.pA6B.value="";
	document.formc.pA7B.value="";
	document.formc.pA8B.value="";
	document.formc.pA9B.value="";
return;
}

if (document.formc.pA3B.value<=0){
	alert("Term Length (Years) must be a number greater than zero");
	document.formc.pA4B.value="";
	document.formc.pA5B.value="";
	document.formc.pA6B.value="";
	document.formc.pA7B.value="";
	document.formc.pA8B.value="";
	document.formc.pA9B.value="";
return;
}

co.pA1B=ooparseFloatTh(document.formc.pA1B.value);
co.pA2B=ooparsePercent(document.formc.pA2B.value);
co.pA3B=ooparseFloat(document.formc.pA3B.value);
calc(co);
document.formc.pA4B.value="$" + oodisplayFloatNDTh(co.pA4B,2);
document.formc.pA5B.value=oodisplayPercentND(co.pA5B,2);

document.formc.pA6B.value="Based on the terms you entered it appears that"
document.formc.pA7B.value="you will accumulate $"  + oodisplayFloatNDTh(co.pA4B,2) + " before taxes"
document.formc.pA8B.value="over the next " + ooparseFloat(document.formc.pA3B.value) + " years with a Return on"
document.formc.pA9B.value="your Initial Investment Amount of " + oodisplayPercentND(co.pA5B,2)

};
};
var ooisus=1;
var ootrue="TRUE";
var oofalse="FALSE";
var oodec=".";
var ooth=",";
var oodecreg=new RegExp("[.]","g");
var oothreg=new RegExp(",","g");
function calc(data){
var cA1B=data.pA1B;
var cA2B=data.pA2B;
var cA3B=data.pA3B;
var cA4B=(((Math.pow((((1)+(cA2B))),(cA3B)))*(cA1B)));
var cA5B=(((((1)-(((cA4B)/(cA1B)))))*(-1)));
data.pA4B=cA4B;
data.pA5B=cA5B;

};
function myIsNaN(x)
{
return(isNaN(x)||(typeof x=='number'&&!isFinite(x)));
};
function round(n,nd)
{
if(isFinite(n)&&isFinite(nd))
{
var sign_n=(n<0)?-1:1;
var abs_n=Math.abs(n);
var factor=Math.pow(10,nd);
return sign_n*Math.round(abs_n*factor)/factor;
}
else
{
return NaN;
}
};
function ooparseFloat(str)
{
str=String(str).replace(oodecreg,".");
var res=parseFloat(str);
if(isNaN(res))
{
return 0;
}
else
{
return res;
}
};
function ooparsePercent(str)
{
var parts=String(str).split('%');
var tmp=String(parts[0]).replace(oodecreg,".");
var res=parseFloat(tmp)/100;
if(isNaN(res))
{
return 0;
}
else
{
return res;
}
};
function oodisplayFloat(x)
{
if(myIsNaN(x))
{
return Number.NaN;
}
else
{
return String(x).replace(/\./g,oodec);
}
};
function oodisplayFloatND(x,nd)
{
if(myIsNaN(x))
{
return Number.NaN;
}
else
{
var res=round(x,nd);
if(nd>0)
{
var str=String(res);
if(str.indexOf('e')!=-1)return str;
if(str.indexOf('E')!=-1)return str;
var parts=str.split('.');
if(parts.length<2)
{
var decimals=('00000000000000').substring(0,nd);
return(parts[0]).toString()+oodec+decimals;
}
else
{
var decimals=((parts[1]).toString()+'00000000000000').substring(0,nd);
return(parts[0]).toString()+oodec+decimals;
}
}
else
{
return res;
}
}
};
function oodisplayPercentND(x,nd)
{
if(myIsNaN(x))
{
return Number.NaN;
}
else
{
return oodisplayFloatND(x*100,nd)+'%';
}
}
function ooparseFloatTh(str)
{
str=String(str).replace(oothreg,"");
str=String(str).replace(oodecreg,".");
var res=parseFloat(str);
if(isNaN(res))
{
return 0;
}
else
{
return res;
}
};
function oodisplayFloatNDTh(x,nd)
{if(myIsNaN(x))
{
return Number.NaN;
}
else
{
var res=round(x,nd);
if(nd>0)
{
var str=String(res);
if(str.indexOf('e')!=-1)return str;
if(str.indexOf('E')!=-1)return str;
var parts=str.split('.');
var res2=ooinsertThousand(parts[0].toString());
if(parts.length<2)
{
var decimals=('00000000000000').substring(0,nd);
return(res2+oodec+decimals);
}
else
{
var decimals=((parts[1]).toString()+'00000000000000').substring(0,nd);
return(res2+oodec+decimals);
}
}
else
{
return(ooinsertThousand(res.toString()));
}
}
};
function ooinsertThousand(whole)
{
if(whole==""||whole.indexOf("e")>=0)
{
return whole;
}
else
{
var minus_sign="";
if(whole.charAt(0)=="-")
{
minus_sign="-";whole=whole.substring(1);
};
var res="";
var str_length=whole.length-1;
for(var ii=0;ii<=str_length;ii++)
{
if(ii>0&&ii%3==0)
{
res=ooth+res;
};
res=whole.charAt(str_length-ii)+res;
};
return minus_sign+res;
}
};

