$(document).ready(function() 
{
		$('#nick,#pass').click(function() { $(this).val(''); });
		$('#Kaynak a').each(function() { if($(this).text() == '') $(this).parent().hide(); })
		$('.rateComment .alkis,.rateComment .kina').click(			
			function() {
				var pars = 'act=YorumOnay&yorumID=' + $(this).attr('yorumID') + '&onay=' + $(this).attr('onay');
				var obj = this;
				$.ajax({
				  url: 'include/lib-ajax.php?' + pars,
				  success: function(data) 
						   {
								switch(data)
								{
									case 'nouser':
										alert('Lütfen kullanıcı girişi yapın.');
									break;
									case 'voted':
										alert('Yorumları bir defa onaylama hakkınız bulunmaktadır.');
									break;
									case 'OK':
										//alert('Yorum oyunuz kaydedildi. Teşekkür ederiz.');
										var cs = ($(obj).attr('onay') == '1' ? '.evet':'.hayir');
										$(obj).parent().slideUp('fast',function() { $(obj).parent().find(cs).html((parseInt($(obj).parent().find(cs).html()) + 1)); });										
										$(obj).parent().slideDown('fast');	
									break;
								}
						   }
				});	
			}
	);
	$('.imgCaptchaRefresh').click(function() { $(this).parent().find('.imgCaptcha').attr({'src':'include/create_captcha.php?' + Math.random()}) });
	$('.digeryazilar').change(function() { if($(this).val()) window.location.href=$(this).val(); });
	csZoom();
});

function csZoom()
{
	$('a[cszoomWidth]').each(function()
	{
		var imgSrc = $(this).find('img').attr('src');
		var imgArray = imgSrc.split('&width=');
		imgSrc = imgArray[0]+'&width='+$(this).attr('cszoomWidth');
		var cszoom = '<div class="cszoom"><img src="'+imgSrc+'"><div class="cszoomInfo">'+$(this).attr('cszoomInfo')+'</div></div>';
		$(this).hover(function() { $(cszoom).prependTo($(this));  $('.cszoomInfo').css('maxWidth',($(this).attr('cszoomWidth') - 10)+'px'); },function() { $('.cszoom').remove();  });
	});	
}

function FavorilereEkle(url,title) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,"");	
	} 
	else if( window.external ) 
	{ 
		window.external.AddFavorite( url, title); 
	}	
	else if(window.opera && window.print) 
	{ 
		return true; 
	} 
} 

function SiteneHaberEkleCode(tip,css,sayi,en,boy)
{
	if (tip == '') {
		alert('Lütfen Gösterim Tipi bölümünü seçin');
		return;
	}
	$('#gf_htmlkod').val('<iframe src="'+AbsolutePath+'haberler.php?tip='+tip+'&habersayisi='+sayi+'&css='+css+'" width="'+en+'" height="'+boy+'" frameborder="0" scrolling="No"></iframe>');
}

function yazdir(type,id)
{
	window.open(AbsolutePath + 'yazdir.php?t='+type+'&ID='+id,'_blank','width=640,height=600,scrollbars=1');	
}

function ajaxSayfa(queryID,temp,title,perPage,curPage) 
{
	$('#'+queryID).find('.pager').html('<div>&nbsp;<img src="images/zoomloader.gif">&nbsp;</div>');
	var pars = 'queryID='+queryID+'&temp='+temp+'&title='+title;
	$.ajax({
	  url: 'include/ajaxLib.php?act=ajaxPager_Object&page='+curPage,
	  type: 'POST',
	  data: pars,
	  success: function(data) 
			   {
					$('#'+queryID).html(data);
					x = $('#'+queryID).offset().top;
					$('html,body').animate({scrollTop: x}, 500);
					csZoom();
			   }
	});	
}

function scrollGo() {
   var x = $(this).offset().top - 100;
   $('html,body').animate({scrollTop: x}, 500);
}

function checkCaptcha(formID) 
{
	var pars = 'txtCaptcha='+$('.' + formID + '_txtCaptcha').val();
	$.ajax({
	  url: 'include/ajaxLib.php?act=captcha',
	  type: 'POST',
	  data: pars,
	  success: function(data) 
			   {
					if(data != 'true') alert('Güvenlik kodu hatalı.');
					else {
						$('#'+formID).submit();
					}
			   }
	});	
}

