/**
 *
 * http://www.balicbilisim.com/
 * Copyright (c) Baliç Bilişim Hizmetleri
 * index.php - www.kozmikinsaat.com.tr
 * Ibrahim BALIÇ 
 * 2010
 *
 */

 var headline_count;
 var headline_interval;
 var old_headline = 0;
 var current_headline = 0;

 function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
 return (isIE) ? window[movieName] : document[movieName];
 }

 function getProje(Id) {
 $.ajax({
   type: "POST",
   url: "function.php",
   data: "Function=Proje&Id="+Id,
   success: function(msg){
   document.getElementById('Insaat_Icerik').innerHTML =  msg;
   $('#Insaat_Icerik').css('display', 'none');
   $('#Insaat_Icerik').fadeIn('slow', function() {
      });
   }
 });
  }

 function KrediHesapla(secim) {
  switch(secim) {
    case "1":
	link = "http://heryersubem.vakifbank.com.tr/SubesizBankacilik/KrediHesaplama.aspx";
    break;
    case "2":
	link = "https://sube.garanti.com.tr/isube/basvurular/bireyselkredi/odemeplani";
    break;
    case "3":
	link = "http://www.isbank.com.tr/content/TR/Hesaplama_Araclari/BireyselKrediHesaplama.aspx";
    break;
    case "4":
	link = "http://www.teb.com.tr/TebPiyasa/HesapMakinalari/KrediFls.aspx";
    break;
    case "5":
	link = "http://www.yapikredi.com.tr/tr-TR/hesaplama_araclari/AjaxBireyselKredi.aspx";
    break;
   }

  window.open(link,'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=0,scrollbars=yes');
 }

 function KozmikIslem(Istek) { 

 Sayfa = Istek;

 $.ajax({
   type: "POST",
   url: "function.php",
   data: "Function=Sayfa&Sayfa="+Sayfa,
   success: function(msg){
   document.getElementById('Insaat_Icerik').innerHTML =  msg;
   $('#Insaat_Icerik').css('display', 'none');
   $('#Insaat_Icerik').fadeIn('slow', function() {
      });
   }
 });
  getFlashMovie("video").BinaVer();
 }
 $(document).ready(function(){
  $("div.kzmproje:eq(0)")
 .animate({top: -175},"slow", function() {
   $(this).css('top', '170px');
 });
  $("div.kzmproje:eq(0)")
 .animate({top: 5},"slow");
  old_headline = current_headline;
  headline_count = $("div.kzmproje").size();
  $("div.headline:eq("+current_headline+")").css('top', '5px');
  headline_interval = setInterval(headline_rotate,5000);
  $('#scrollup').hover(function() {
 clearInterval(headline_interval);
  }, function() {
 headline_interval = setInterval(headline_rotate,5000);
 headline_rotate();
  });
 });
 function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count;
  $("div.kzmproje:eq(" + old_headline + ")")
 .animate({top: -175},"slow", function() {
   $(this).css('top', '170px');
 });
  $("div.kzmproje:eq(" + current_headline + ")")
 .animate({top: 5},"slow");
  old_headline = current_headline;
 }


var currency = '';

function calculatePayment(form) {
	L = 1 * form.amount.value;
	r = 1 * form.interest.value;
	n = 1 * form.months.value;
	var str = '';
			P = doCompoundCalculation(L, r, n);
				str = formatMoney(P);
	
	document.getElementById('aylik_odeme').innerHTML = str;
	
}

function doCompoundCalculation(L, r, n) {
	P = L * r * Math.pow(1+r/100,n) / (100 * (Math.pow(1+r/100,n) - 1));
	return P;
}


function doFlatRateCalculation(L, r, n) {
	P = L * r * 1.20 * Math.pow((1+(r/100)*1.20),n) / (100 * (Math.pow((1+(r/100)*1.20),n) - 1));
	return P;
}

function doSerkanCalculation(L, r, n) {
	P = L * r * 1.05 * Math.pow((1+(r/100)*1.05),n) / (100 * (Math.pow((1+(r/100)*1.05),n) - 1));
	return P;
}
function setNumericOnly(object) {
	value = object.value;
	object.value = value.replace(/[^\d\.]/g, "");
}
function formatMoney(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	dec = num%100;
	num = Math.floor(num/100).toString();
	if(dec<10) dec = "0" + dec;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {
		num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));
	}
	return '' + (((sign)?'':'-') + num + 'TL');
}

