var conter=1;
var timerCount;
var maxHeaderlineCount = 10;
var max = 13;
var bugunYaziIndex = 0;
var FontBuyuklugu=parseInt('3');
maxHeaderlineCount = maxHeaderlineCount+1;

function saveComment(){
	$('.commentResult').slideDown('slow'); 
	$(".commentResult").html('Yorumunuz ekleniyor...'); 
	$.ajax({ 
		type:'POST', 
		url:'/ekle.php', 
		data:$('#comment-form').serialize(), 
		success:function(cevap){  
			$(".commentResult").html(cevap);
			$("#comment-form #yorum").val("Bir yorum yazın...");
		}
	});
}

function bugunYaziSlayt(index,toplam) {
	toplam = (toplam/3);
	bugunYaziIndex = bugunYaziIndex + index;
    if(bugunYaziIndex > toplam) bugunYaziIndex = 0;
    if(bugunYaziIndex < 0) bugunYaziIndex = toplam;
    tmp = (bugunYaziIndex * 102);
    $('div.bugunYazilarIc').animate({ top: -tmp + 'px' }, 400 ); 
}

function mansetAc(selectedItemIndex) {
	stopTimer();
	for(i=1;i<maxHeaderlineCount;i++) {
		if(i!=selectedItemIndex) {
			document.getElementById('bigPic'+i).style.display = 'none';
			if(document.getElementById('OtherArticles_'+i)) {
				document.getElementById('OtherArticles_'+i).style.display = 'none';
			}
			if( i== 9) {
				document.getElementById('HeaderOK_'+i).className = 'small';
			} else if(i== 10) {
				document.getElementById('HeaderOK_'+i).className = 'small last';
			} else {
				document.getElementById('HeaderOK_'+i).className = '';
			}
		} else {
			document.getElementById('bigPic'+i).style.display = 'inline-block';
			if(document.getElementById('OtherArticles_'+i)) {
				document.getElementById('OtherArticles_'+i).style.display = 'inline-block';
			}
			if(i == 9) {
				document.getElementById('HeaderOK_'+i).className = 'small current';
			} else if(i == 10) {
				document.getElementById('HeaderOK_'+i).className = 'small last current';
			} else {
				document.getElementById('HeaderOK_'+i).className = 'current';
			}
		}
	}
}

function mansetAcSmall(selectedItemIndex) {
	for(i=1;i<max;i++) {
		if(i!=selectedItemIndex) {
			document.getElementById('smallPic'+i).style.display = 'none';
		} else {
			document.getElementById('smallPic'+i).style.display = 'inline-block';
		}
	}
}

function mansetAcCok(selectedItemIndex) {
	for(i=1;i<max;i++) {
		if(i!=selectedItemIndex) {
			document.getElementById('cokManset'+i).style.display = 'none';
		} else {
			document.getElementById('cokManset'+i).style.display = 'inline-block';
		}
	}
}

function zamanBasla(conterNum) {
	if(conterNum!=-1) conter = conterNum;
	if(conter==maxHeaderlineCount) conter=1;
	for(i=1;i<maxHeaderlineCount;i++) {
		if(i!=conter) {
			document.getElementById('bigPic'+i).style.display = 'none';
			if(document.getElementById('OtherArticles_'+i)) {
				document.getElementById('OtherArticles_'+i).style.display = 'none';
			}
			if( i== 9) {
				document.getElementById('HeaderOK_'+i).className = 'small';
			} else if(i== 10) {
				document.getElementById('HeaderOK_'+i).className = 'small last';
			} else {
				document.getElementById('HeaderOK_'+i).className = '';
			}
		} else {
			document.getElementById('bigPic'+i).style.display = 'inline-block';
			if(document.getElementById('OtherArticles_'+i)) {
				document.getElementById('OtherArticles_'+i).style.display = 'inline-block';
			}
			if(i == 9) {
				document.getElementById('HeaderOK_'+i).className = 'small current';
			} else if(i == 10) {
				document.getElementById('HeaderOK_'+i).className = 'small last current';
			} else {
				document.getElementById('HeaderOK_'+i).className = 'current';
			}
		}
	}
	conter=conter+1;
	timerCount=setTimeout("timerStart(-1)",5000);
}

function stopTimer() {
	clearTimeout(timerCount);
}
zamanBasla(-1);
document.getElementById('bigPic1').style.display = 'inline-block';
if(document.getElementById('OtherArticles_'+i)) {
	document.getElementById('OtherArticles_1').style.display = 'inline-block';
}
document.getElementById('HeaderOK_1').className = 'current';

$(document).ready(function(){

	// Textarea alanı için
	$('#yorum').kalanKarakter({
		limit: 100,
		mesaj: '#1 karakter kald&#305;',
		kapsa: '<span class="kalanKarakter"></span>',
	});
});

function FontSizeDegistir (ck,islem){
    var govde = $('.haberMetin');
    switch (islem) {
        case 'arttir':
            if (FontBuyuklugu+1 < 6) {
                govde.removeClass('fontsize'+FontBuyuklugu);
                FontBuyuklugu++;
                govde.addClass('fontsize'+FontBuyuklugu);
            }
        break;
        case 'dusur':
            if (FontBuyuklugu-1 > 0) {
                govde.removeClass('fontsize'+FontBuyuklugu);
                FontBuyuklugu--;
                govde.addClass('fontsize'+FontBuyuklugu);
            }
        break;
        default:
            govde.removeClass('fontsize'+FontBuyuklugu);
            FontBuyuklugu = islem;
            govde.addClass('fontsize'+FontBuyuklugu);
    }
}

function puanDurumuAc(){
	$(".kPt").css('display','in-block');
}

function PiPap(adres, title, w, h, scroll) 
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
	win = window.open(adres, title, winprops)
}

function HavaDurumuAl(SehirID) {
	var Hedef = "TR" + SehirID + "01";
	$.get("/Eklentiler/Hava-Durumu-Gelismis/index.php?sehir=" + Hedef, function(_Data){ $('#HavaDurumu').html(_Data); });
}
