
   var number = 100000;
   var pr = 0.3;
   var pos = 4;

function Vubor()
{   
   if (pos == 1) {Calculate1();}
   if (pos == 2) {Calculate2();}
   if (pos == 3) {Calculate3();} 
   if (pos == 4) {Calculate4();}
}
function Setup1()
{
  pos = 1;
  document.fc.num.value = "=";
}
function Setup2()
{
  pos = 2;
  document.fc.s1.value = "=";
}
function Setup3()
{
  pos = 3;
  document.fc.tax.value = "=";
}
function Setup4()
{
  pos = 4;
  document.fc.t1.value = "=";
}
 
function myRound(n)
{
   n = n * 100;
   return Math.round(n)/100;
}
function myRoundPr(n)
{
   n = n * 100000;
   return Math.round(n)/1000;
}
function Calculate1()
{
	pr = document.fc.s1.value;
	pr = pr.replace("%", "");
   	pr = pr / 100;
	sum = document.fc.t1.value;
	years = Math.floor(document.fc.tax.value);
	document.fc.tax.value = years;

	issum = sum / Math.pow((100 + pr*100)/100,years);	
	document.fc.num.value = myRound(issum);
}
function Calculate2()
{
	issum = document.fc.num.value;
	sum = document.fc.t1.value;
	years = Math.floor(document.fc.tax.value);
	document.fc.tax.value = years;	
	
	pr =  Math.pow (sum/issum, 1/years) - 1;	
	document.fc.s1.value = myRoundPr(pr)+"%";
}
function Calculate3()
{
	issum = document.fc.num.value;
	sum = document.fc.t1.value;
	pr = document.fc.s1.value;
	pr = pr.replace("%", "");
   	pr = pr / 100;
	
	years =  Math.log (sum/issum)/Math.log ((100 + pr*100)/100);	
	document.fc.tax.value = myRound(years);
}
function Calculate4()
{
	pr = document.fc.s1.value;
	pr = pr.replace("%", "");
   	pr = pr / 100;
	issum = document.fc.num.value;
	years = Math.floor(document.fc.tax.value);
	document.fc.tax.value = years;
	
	sum = issum * Math.pow((100 + pr*100)/100,years);	
	document.fc.t1.value = myRound(sum);     
}     
