

function czysc(co)
{
if (co=='wk') {
kalkulator.WK.value=''; 
kalkulator.WK.focus();
} else if (co=='R') {
kalkulator.R.value=''; 
kalkulator.R.focus();
} else if (co=='T') {
kalkulator.T.value=''; 
kalkulator.T.focus();
}
}
function wylicz_kredyt (WK,R,T) // by Łukasz Przybył
{
var regexp=','
                     
kalkulator.WK.value=WK.replace(regexp,".");
kalkulator.R.value=R.replace(regexp,".");
kalkulator.T.value=T.replace(regexp,".");

document.kalkulator.WR.value='';
R = R * T;
R=R/100;
	
a=(1/(R/12));
kalkulator.a02.value='a: '+a;

b=(1+(R/12));
kalkulator.a01.value='b: '+b;	

//c=POW();
var c = Math.pow(b,(T)); // T*12 jesli T to lata

kalkulator.a04.value='c: '+ c;

if ((T!=0) && (WK!=0) && (R!=0)) document.kalkulator.WR.value=WK/(a*(1-1/c));

}

function wylicz_rate(WK, R, M) {
  var kwota = WK * (parseFloat(M * parseFloat(R)) / 100);
  kwota = WK + kwota;
  if (parseInt(R) == 1) {
    kwota += 20;
    if (M == 24) {
      kwota += 20;
    }
  }
  rata = Math.round(kwota / M);

  if (kwota != 'undefined' && kwota != 0) {
    return rata;
  } else {
    return '';
  }
  
}