// JavaScript Document
var birinciTarih, ikinciTarih, ikinciAy, tmp;
birinciTarih = new Date();
tmp = birinciTarih.getMonth() + 1;

ikinciAy = tmp % 12;



if (ikinciAy == 0){

ikinciTarih = new Date(birinciTarih.getFullYear()+1,ikinciAy,15);

	}else{
		
ikinciTarih = new Date(birinciTarih.getFullYear(),ikinciAy,15);


		}



var one_day=1000*60*60*24;

/////// ARTIK GUN ///////
var artikGun = Math.ceil((ikinciTarih.getTime() - birinciTarih.getTime())/(one_day));
//alert(artikGun);
var presel, opt1, opt2, lastsel, combobox, ay, globalFaiz;
function testim(lbl, faiz){
globalFaiz = faiz;
opt2 = "";
opt1 = "";
	presel = "<select  id=borcVadesi  name=borcVadesi style=font-size:10px; ><option value=0>Seçiniz</option>";
	lastsel = "</select>";
if (lbl == "brctip3"){	
ay = 60;
}
else{
ay = 36
}
	for(i=6;i<=ay;i++){

		opt1 = "<option value="+i+">"+i+" AY</option>";
		opt2 = opt2 + opt1;

					  }


combobox = presel + opt2 + lastsel;
document.getElementById("faizOrani").innerHTML = faiz;
document.getElementById("knt").innerHTML = combobox;
}


function hesapla(){
var t, n, B, pay, payda, A, artikFaiz ;
t = ( document.getElementById("borcTipi").value * 0.01);
if (document.getElementById("borcVadesi").value == 0){
alert("Lütfen Borç Vadesini Seçiniz")
}
n = document.getElementById("borcVadesi").value;
B = document.getElementById("txtTalepEdilenTutar").value;
deger = t + 1;
deger= Math.pow(deger,n);
pay = deger * t;
payda = deger -1;

A = B * pay/payda;
kusurat = (Math.round((A * 100)% 100))* 0.01;
tamsayi = parseInt(A);
A = tamsayi + kusurat;

if (isNaN(A)== false){
document.getElementById("txtTaksitTutari").value = A;
}else{
alert("Lütfen Tutarı Doğru Giriniz!")
document.getElementById("txtTaksitTutari").value = "0.00"}

ode = A * n;
okusurat = (Math.round((ode * 100)% 100))* 0.01;
otamsayi = parseInt(ode);
artikFaiz = (((B * globalFaiz)/100)/30)*artikGun;
artikkusurat = (Math.round((artikFaiz * 100)% 100))* 0.01;
artiksayi = parseInt(artikFaiz);
paramNew = otamsayi + okusurat + artiksayi + artikkusurat ;
if (isNaN(paramNew) == false){
document.getElementById("txtGeriOdenecekTutar").value = otamsayi + okusurat + artiksayi + artikkusurat ;
}else{document.getElementById("txtGeriOdenecekTutar").value = "0.00";}

}
