// AFS Yayıncılık JavaScript v1.2 - Carbon Teknoloji ~ Hazar Karabay

$(document).ready(function() {
	if ($("#logo").length > 0) { 
		$("#logo").click(function(event) { window.location = "index.php"; }).addClass('hand');
	}
	if ($(".basadon").length > 0) $(".basadon").click(function(event) { 
															   if ($.browser.opera) $('html').animate({scrollTop:0}, 200);
															   else $('html, body').animate({scrollTop:0}, 200); 
															}).addClass('hand');
	
	/*$(window).resize(function() { ortala(true); yukseklikAyarla(); });
	ortala(false);
	yukseklikAyarla();
	*/
	
	$("#topnav img").hover(function() {
		$(this).attr("src", $(this).attr("src").replace("navi","navi/over"));
	}, function() {
		$(this).attr("src", $(this).attr("src").replace("navi/over","navi"));
	});
	
	
	if ($("a.fancy").length > 0) {
		$("a.fancy").fancybox({
			'overlayShow'			: false,
			'zoomSpeedIn'			: 600,
			'zoomSpeedOut'			: 500,
			'centerOnScroll'		: true
		});
	}
	
	if ($(".kitabimibul_large").length > 0) {
		var sinif = Number($(".kitabimibul_large .sinif").text());
		$(".kitabimibul_large .yukari").click(function(){ 													   
													   if (sinif < 9) sinif++;
													   $(".kitabimibul_large .sinif").text(sinif);
													   }).addClass('hand');
		
		$(".kitabimibul_large .asagi").click(function(){
													  if (sinif > 3) sinif--;
													  $(".kitabimibul_large .sinif").text(sinif);
													  }).addClass('hand');
		
		$(".kitabimibul_large .bul").click(function(){ 
													window.location = "search.php?sinif="+sinif;
													}).addClass('hand');
	}
	
	
	if ($(".kitabimibul_large_en").length > 0) {
		var sinif = Number($(".kitabimibul_large_en .sinif").text());
		$(".kitabimibul_large_en .yukari").click(function(){ 													   
													   if (sinif < 9) sinif++;
													   $(".kitabimibul_large_en .sinif").text(sinif);
													   }).addClass('hand');
		
		$(".kitabimibul_large_en .asagi").click(function(){
													  if (sinif > 3) sinif--;
													  $(".kitabimibul_large_en .sinif").text(sinif);
													  }).addClass('hand');
		
		$(".kitabimibul_large_en .bul").click(function(){ 
													window.location = "search.php?sinif="+sinif;
													}).addClass('hand');
	}
	
	
	if ($(".kitabimibul_small").length > 0) {
		var sinif = Number($(".kitabimibul_small .sinif").text());
		$(".kitabimibul_small .yukari").click(function(){ 													   
													   if (sinif < 9) sinif++;
													   $(".kitabimibul_small .sinif").text(sinif);
													   }).addClass('hand');
		
		$(".kitabimibul_small .asagi").click(function(){
													  if (sinif > 3) sinif--;
													  $(".kitabimibul_small .sinif").text(sinif);
													  }).addClass('hand');
		
		$(".kitabimibul_small .bul").click(function(){ 
													window.location = "search.php?sinif="+sinif;
													}).addClass('hand');
	}
	
	
	if ($(".kitabimibul_small_en").length > 0) {
		var sinif = Number($(".kitabimibul_small_en .sinif").text());
		$(".kitabimibul_small_en .yukari").click(function(){ 													   
													   if (sinif < 9) sinif++;
													   $(".kitabimibul_small_en .sinif").text(sinif);
													   }).addClass('hand');
		
		$(".kitabimibul_small_en .asagi").click(function(){
													  if (sinif > 3) sinif--;
													  $(".kitabimibul_small_en .sinif").text(sinif);
													  }).addClass('hand');
		
		$(".kitabimibul_small_en .bul").click(function(){ 
													window.location = "search.php?sinif="+sinif;
													}).addClass('hand');
	}
	
});

/*

	***	Anchor Slider by Cedric Dugas   ***
	*** http://www.position-absolute.com ***
	*** Hazar Karabay tarafından modifiye edildi ***
	
*/

function yukseklikAyarla() {
	var fark = 0;
	if ($("#anaicerik").height() > getSolDivHeight()) fark = ($("#anaicerik").height() - getSolDivHeight()); // Fark var..
	if ($("#darsol").length > 0 && $("#darsol").height() < getSolDivHeight()+fark) $("#darsol").css({"height" : getSolDivHeight()+fark + "px"});
	}
	
function ortala(oynatarak) {
	if ($("#main-container").length > 0) {
		var divYukseklik = $("#main-container").height();		
		
		// jQuery sevilmez mi yahu..
		if (oynatarak) $("#main-container").animate({ marginTop: parseInt((getViewportHeight() - divYukseklik) / 2) + "px" }, 250);
		else $("#main-container").css({"margin-top" : parseInt((getViewportHeight() - divYukseklik) / 2) + "px"});		
		
		// Arka imaj patlamasına karşı fix. CSS'de hallettik, gerek kalmadı.
		//if ($("#background-img").height() < getViewportHeight()) $("#background-img").css({"height":"100%"})
	}
}
	
	
function getSolDivHeight() {
	var sabit
	sabit = 270
	return (getViewportHeight() - sabit <= 0) ? 0 : getViewportHeight() - sabit;
	}

function numVld(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;	
	else return true;
}

function priceVld(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode == 44) return true;
	else {
		if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
		else return true;
	}
}

function getViewportHeight() {
	var viewportwidth;
	var viewportheight;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	
	if (typeof window.innerWidth != 'undefined')
	{
	  viewportwidth = window.innerWidth,
	  viewportheight = window.innerHeight
	}
	
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	else if (typeof document.documentElement != 'undefined'
	 && typeof document.documentElement.clientWidth !=
	 'undefined' && document.documentElement.clientWidth != 0)
	{
	   viewportwidth = document.documentElement.clientWidth,
	   viewportheight = document.documentElement.clientHeight
	}
	
	// older versions of IE
	
	else
	{
	   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	return viewportheight;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=820,height=670,left = 430,top = 195');");
}
