/* remove error messages IE 7 or greater */
function blockError(){return true;}window.onerror = blockError;

/* onload functions*/
$(function(){
	/* navigation */
	$("div#nav a").eq(navSelect).addClass("selected");
	/* urunler */
	var hrefFirst=$("div.urunAltTab").eq(0).find("a").attr("href");
	if($("div.urunAltTab").css("display")=="block" && hrefFirst!=="#"){
	
	}
});


function popup(id2){
	$("div#popupBg,div#popup").show();
	$("#imageSlider").hide();
	$("div#popContent").addClass("popupLoader");
	$.ajax({
		type:"POST",
		url:"index/urunkatalog",
		data:"id="+id2,
		success:function(page){
			$("div#popContent").removeClass("popupLoader").html(page);
		}
	});	
	$("div#popup div.close a").live("click",function(){
		$("div#popupBg,div#popup").hide();
		$("div#popContent").empty();
		$("#imageSlider").show();
		return false
	});
}




$("a.popKatalog").live("click",function(){
	$(window).scrollTo("div#logo",600,function(){
		popup('ekatalog','def');
	});
	return false
});


/* languages */
$("a#langSelect").live("click",function(){
	var langDiv=$("div#lang div");
	if(langDiv.css("display")=="block"){
		$("div#lang div").fadeOut();
	}else{
		$("div#lang div").fadeIn();
	}
	return false
});

/* content tab buttons */
$("ul.contentTabs a").live("click",function(){
	$("ul.contentTabs a").removeClass("selected");
	$(this).addClass("selected");
	$("div.contentPages").hide();
	$("div.contentPages").eq($(this).parents("ul").find("a").index(this)).fadeIn();
	return false
});

/* urunler */
/*
$("div.urunAltDetay div.gallery ul li a").live("click",function(){
	var resim=$(this).attr("href");
	$(this).parents("div.gallery").find("li a").removeClass("selected");
	$(this).addClass("selected");
	$(this).parents("div.gallery").find("a.urunBig img").hide().attr("src","img/urunler/"+resim+"b.jpg").fadeIn().parent().attr("href","img/urunler/"+resim+"bb.jpg");
	return false
});*/


$("div.urunAltDetay div.gallery ul li a").live("click",function(){
	var resimOrta=$(this).attr("orta");
	var resimBig=$(this).attr("href");

	
	$(this).parents("div.gallery").find("li a").removeClass("selected");
	$(this).addClass("selected");
	$(this).parents("div.gallery").find("a.urunBig img").hide().attr("src",resimOrta).fadeIn().parent().attr("href",resimBig);
	return false
});

$(".kullanimYelpaze").live("click",function(){
	var resim=$(this).attr("href"),
		chrome=navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	$("div#galleryPrewBg").css("height",$(window).height()+"px").show();
	$("div#galleryPrew").show().find("div").css("margin-top",(($(window).height()-600)/2)+"px");
	if(chrome==true){
		$("div#galleryPrew img").attr("src",resim).fadeIn();
	}else{
		$("div#galleryPrew div").html('<img src="'+resim+'" >').find("img").load(function(){
			$(this).fadeIn();
		});
	}
	return false
});
$("div.gallery a.urunBig").live("click",function(){
	var resim=$(this).attr("href"),
		chrome=navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	$("div#galleryPrewBg").css("height",$(window).height()+"px").show();
	$("div#galleryPrew").show().find("div").css("margin-top",(($(window).height()-600)/2)+"px");
	$("#imageSlider").hide();
	if(chrome==true){
		$("div#galleryPrew img").attr("src",resim).fadeIn();
	}else{
		$("div#galleryPrew div").html('<span id="galleryPrewBgClose"></span><img src="'+resim+'" >').find("img").load(function(){
			$(this).fadeIn();
		});
	}
	return false
}).live("mouseover",function(){
	$(this).find("span").show();
}).live("mouseout",function(){
	$(this).find("span").hide();
});
$(window).resize(function(){
	$("div#galleryPrewBg").css({height: $(window).height()+"px"});
	$("div#galleryPrew div").css({marginTop: (($(window).height()-600)/2)+"px"});
});
$("div#galleryPrew div,div#galleryPrew img,span#galleryPrewBgClose").live("click",function(){
	if(chrome=navigator.userAgent.toLowerCase().indexOf('chrome') > -1==true){
		$("div#galleryPrew img").attr("src","img/spacer.gif").hide();
	}else{
		$("div#galleryPrew div").empty();
	}
	$("div#galleryPrew,div#galleryPrewBg").hide();
	$("#imageSlider").show();
});

$(".yukPlatformBtn:not('.selected')").live("click",function(){
	$(".yukPlatformList").slideUp();
	$(".yukPlatformBtn").removeClass("selected");
	$(".yukPlatformList" , $(this).parent().next("li")).slideDown();
	$(this).addClass("selected");
	return false
});

$("#urunlerList .selected").live("click",function(){
	$(".yukPlatformList").slideUp();
	$(".yukPlatformBtn").removeClass("selected");
	return false
});
