$(document).ready(function(){
	// son dakika
	if ($(".lastnews div ul li").length) { $('.lastnews div ul li').css('display','block'); $(".lastnews > div").jCarouselLite({vertical:true,visible:1,auto:2000,speed:500,hoverPause:true}); }
	//manşet
	if ($(".manset-img").length) { $(".manset-img:first-child").css('display','block'); $('.manset-list ul li a').fL({ou:'.manset-img',ti:'.manset-none',si:0,poh:true,tin:5000}); }
	// yazar modül
	$('.authors-list ul li a').hover(function(){ $('.authors-list').parent().find('div').not('.authors-list').not('.clear').css('display','none'); $('.authors-list').parent().find('.'+$(this).attr('class')).css('display','block'); }, function(){});
	// sag manset
	$('.right-manset-spot > h3').eq(0).css('display','block');
	
	$(".rm-images").jCarouselLite({ visible: 1, start:0, scroll:1, auto:5000, btnGo: [".sag-manset-button-1", ".sag-manset-button-2", ".sag-manset-button-3", ".sag-manset-button-4", ".sag-manset-button-5",".sag-manset-button-6", ".sag-manset-button-7", ".sag-manset-button-8", ".sag-manset-button-9", ".sag-manset-button-10"], afterEnd: function(a) { $xi = $(a[0]).index(); if ($xi == $('.right-manset-spot > h3').length) {$xi = 0;} $('.right-manset-spot > h3').css('display','none'); $('.right-manset-spot > h3').eq($xi).css('display','block'); } });
	// cok okunan haberler
	$('.modul-tabs li a').click(function(){ $('.modul-tabs li').removeClass('current'); $(this).parent().addClass('current'); $('.news-today').css('display','none'); $('.news-week').css('display','none'); $('.news-month').css('display','none'); $this = $(this).parent().attr('class').split(' '); $('.news-'+$this[0]).css('display','block'); });
	// editorun sectikleri
	if ($(".modul-es-holder").length){$(".modul-es-holder").jCarouselLite({ btnNext: ".modul-es-next", btnPrev: ".modul-es-prev", visible: 4, speed: 1000, auto:2000, hoverPause:true}); }
	// kategori manşet
	$('.category-manset-list li a').fL({ou:'.category-manset-img li',ti:'.category-manset-spot h2',si:0,poh:true,tin:5000});
	
	
	$(".author-slider").jCarouselLite({
	btnNext: ".author-prev",
	btnPrev: ".author-next",
	visible: 5,
	vertical:true,
	start:0,
	scroll:1
	});
	$(".author-slider-spor").jCarouselLite({
	btnNext: ".author-prev-spor",
	btnPrev: ".author-next-spor",
	visible: 5,
	vertical:true,
	start:0,
	scroll:1
	});
	
	// anasayfa video
	/*if ($('.modul-video-list ul li').length)
	{
		$('.modul-video-list ul li a').hover(function(){
			$('.modul-video-image').find('a').attr('href', $(this).attr('href'));
			$('.modul-video-image').find('img').attr('src', $(this).find('img').attr('src').replace('_2','_1'));
			$('.modul-video-spot').find('a').attr('href', $(this).attr('href'));
			$('.modul-video-spot').find('a').html($(this).attr('title'));
		},function(){});
	}*/
	// anasayfa foto-video tab
	$('.mg-tab').find('a').click(function(){
		$('.mg-tab > li').removeClass('current');
		$(this).parent().parent().addClass('current');
		$('.modul-gallery-content').css('display', 'none');
		$('#'+$(this).attr('class')).css('display','block');
		Cufon('.cufon-light',{hover:{color:'#333'}});
	});
	
	$('.right-manset .right-manset-list li a').hover(function(){
		$i = $(this).parent().index();
		$('.right-manset .right-manset-list li').eq($i-1).find('a').click();
	},function(){});
});


	$(".weather-change-button").click(function(){
		$(".weather-city-list").css('display','block');
	});
	
	$(".weather-city-cancel-button").click(function(){
		$(".weather-city-list").css('display','none');
	});

	$('.weather-city-change-button').click(function(){
		
		$(".weather-loading").css('display','block');
		$(".weather ul li").find('img').not('.weather-loading').remove();
		$(".weather-result ul li").html('');
		  
		$(".selected-city").html($(".weather-city option:selected").text());
		$(".weather-city-list").css('display','none');
		$(".weather .title").css('display', 'block');
		
		var d = new Date();
		var day = d.getDate();
		var month = d.getMonth()+1;
	
		if (day < 10)
		day = '0'+day;
	
		if (month < 10)
		month = '0'+month;
	
		$.getJSON("/cron/use.weather.php?jsoncallback=?",
				  {
			data: "json",
			date: d.getFullYear()+''+month +''+day,
			city: $(".weather-city option:selected").val()
				  },
				  function(data) {
					  
					  $('.weather-icon').attr('src','/cron/icon/'+data.items[0].icon+'.png');
					  $('.weather-icon').attr('alt',data.items[0].type);
					  $('.weather-icon').attr('title',data.items[0].type);
					  
					  for (var k=0; k<3; k++)
					  {
						  $(".weather-loading").css('display','none');
						  
						  $li = $(".weather-result ul li:eq("+k+")");
						  
						  $('<h4>').html(data.items[k].tarih.split(' ')[2]).appendTo($li);
						  
						  if (data.items[k].minDeg.substring(0, 1) == '-')
							  $('<span>').addClass('weather-low').html(': '+data.items[k].minDeg+'&deg;').appendTo($li);
						  else
							  $('<span>').addClass('weather-low').html(': &nbsp;'+data.items[k].minDeg+'&deg;').appendTo($li);
						  
						  $('<span>').addClass('weather-high').html(data.items[k].maxDeg+'&deg;').appendTo($li);
						  
					  }				  
				  });
	});


var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}



// functions
function setHomepage(){if (document.all){document.body.style.behavior='url(#default#homepage)';document.body.setHomePage('http://'+location.hostname);}else if(window.sidebar){if(window.netscape){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}catch(e){alert("İşlem, internet tarayıcınız tarafından güvenlik gerekçesi ile iptal edildi!\r\n\r\nİşleme devam edebilmek için tarayıcı ayarlarından \r\n\"signed.applets.codebase_principal_support\" değerini \"true\" yapınız ve işlemi tekrar çalıştırınız.\r\nTarayıcı ayarlarını açmak için adres satırına \"about:config\" yazınız.\r\n\r\nDikkat! Bu işlem tarayıcınızı saldırılara açık hale getirebilir!");}}var prefs=Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);prefs.setCharPref('browser.startup.homepage','http://'+location.hostname);}}function addBookmark(){var uv='http://'+location.hostname;var tv=location.hostname;if (window.sidebar){window.sidebar.addPanel(tv, uv,"");}else if(window.external){window.external.AddFavorite(uv,tv);}else if(window.opera && window.print){return true;}}
function changeFontSize(t,c){$b = parseInt($(t).css('font-size').replace('px','')); if (c == "u" && ($b+1) < 21) $(t).css('font-size', ($b+1)+"px"); else if (c == "d" && ($b-1) > 11) $(t).css('font-size', ($b-1)+"px");}
function setFontSize(t,c){$(t).css('font-size',c+'px');}
function doSearch(keyword, place, category, searchURL) { if (typeof String.prototype.trim !== 'function') { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); } } keyword = keyword.trim(); if (searchURL.length == 0) { $searchURL = "/haber/arama/"; } else { $searchURL = searchURL; } if (keyword.length < 3) { alert('En az 3 karakterlik kelime aramalısınız'); return false; } $searchURL += keyword; if (place != '') { $searchURL += "/"+place; } if (category != '') { $searchURL += "/"+category; } location.href=$searchURL+".html"; return false; }
function addBookmark(){var uv='http://'+location.hostname;var tv=location.hostname;if (window.sidebar){window.sidebar.addPanel(tv, uv,"");}else if(window.external){window.external.AddFavorite(uv,tv);}else if(window.opera && window.print){return true;}}
function addComment(tablo, kayitID, kullaniciID, form) { formFields = form.serialize(); form.find('input, textarea').attr('disabled','disabled'); $.ajax({ type: 'POST', url: '/includes/js.functions.php', data: 'do=post-comment&tablo='+tablo+'&kayitID='+kayitID+'&kullaniciID='+kullaniciID+'&'+formFields, dataType: 'json', success: function(json){ form.find('input, textarea').val(''); form.find('input[type="submit"]').val('Gönder'); form.find('input, textarea').removeAttr('disabled'); if (json.result == 'success') { alert('Yorumunuz başarıyla eklendi.\r\n\r\nEditör onayından sonra yayınlanacaktır.'); } else { alert('Yorumunuz eklenemedi. Lütfen tüm alanları doldurduğunuzdan emin olun.'); } }}); return false; }

// library

(function($){$.fn.jCarouselLite = function(o) {o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,hoverPause:false,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var div=$(this),ul=$("ul",div),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v+1).clone()).append(tLi.slice(0,o.scroll).clone());o.start+=v-1;}var li=$("li",ul),itemLength=li.size(),curr=o.start;div.css("visibility","visible");li.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});div.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var liSize=o.vertical?height(li):width(li);var ulSize=liSize*itemLength;var divSize=liSize*v;li.css({width:li.width(),height:li.height()});ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));div.css(sizeCss,divSize+"px");if(o.btnPrev){$(o.btnPrev).click(function(){return go(curr-o.scroll);});if(o.hoverPause){$(o.btnPrev).hover(function(){stopAuto();},function(){startAuto();});}}if(o.btnNext){$(o.btnNext).click(function(){return go(curr+o.scroll);});if(o.hoverPause){$(o.btnNext).hover(function(){stopAuto();},function(){startAuto();});}}if(o.btnGo)$.each(o.btnGo,function(i,val){$(val).click(function(){return go(o.circular?o.visible+i:i);});});if(o.mouseWheel && div.mousewheel)div.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll);});var autoInterval;function startAuto(){stopAuto();autoInterval=setInterval(function(){go(curr+o.scroll);},o.auto+o.speed);};function stopAuto(){clearInterval(autoInterval);};if(o.auto){if(o.hoverPause){div.hover(function(){stopAuto();},function(){startAuto();});}startAuto();};function vis(){return li.slice(curr).slice(0,v);};function go(to){if(!running){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(to<0){ul.css(animCss,-((curr+tl)*liSize)+"px");curr=to+tl;}else if(to>itemLength-v){ul.css(animCss,-((curr-tl)*liSize)+"px");curr=to-tl;}else curr=to;}else{if(to<0||to>itemLength-v)return;else curr=to;}running=true;ul.animate(animCss=="left"?{left:-(curr*liSize)}:{top:-(curr*liSize)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this, vis());running = false;});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0 && o.btnPrev)||(curr+o.scroll > itemLength-v && o.btnNext)||[]).addClass("disabled");}}return false;};});};function css(el,prop){return parseInt($.css(el[0],prop))||0;};function width(el){return  el[0].offsetWidth+css(el,'marginLeft')+css(el,'marginRight');};function height(el){return el[0].offsetHeight+css(el,'marginTop')+css(el,'marginBottom');};})(jQuery);
(function($){$.fn.fL=function(op){var t=$(this);var ou=$(op.ou);var ti=$(op.ti);new jQuery.fL(t,ou,ti,op);return this;};$.fL = function(t, ou, ti, op) {function sl(nr){if (typeof nr=="undefined"){nr=vi+1;nr=nr>=tim?0:nr;}nr=nr<0?tim-1:nr;ou.stop(true,true).filter(":visible").css('display','none');ou.filter(":eq("+nr+")").css('display','block');ti.filter(":visible").css('display','none');ti.filter(":eq("+nr+")").css('display','block');t.parent().filter(".current").removeClass('current');t.parent().not('.prev').not('.next').filter(":eq("+nr+")").addClass('current');vi=nr;}var op=op||{};var tim=t.not('.prev').not('.next').length;var vi=op.si||0;op.poh=op.poh||true;op.tin=op.tin||5000;ou.hide().eq(vi).show();t.hover(function(){if($(this).get(0).className=='prev'){sl(vi);}else if($(this).get(0).className=='next'){sl();}else{sl(t.index(this));}});if(op.tin>0){var tmr=setInterval(function (){sl();},op.tin);if (op.poh){t.mouseenter(function(){clearInterval(tmr);}).mouseleave(function(){clearInterval(tmr);tmr=setInterval(function(){sl();},op.tin);});}}};})(jQuery);
