if($.cookie("animationsDisabled")==1){
	var animations = false;
}
else{
	var animations = true;
}
$(document).ready(function(){
	if(animations){
		$("#animations").text("Wyłącz animacje");
	}
	else{
		$("#animations").text("Włącz animacje");
	}
	$("#animations").click(function(){
		if(animations){
			pageTracker._trackPageview("/disabeleAnimations");
			animations = false;
			$.cookie("animationsDisabled", 1, { expires: 365 });
			$(this).text("Włącz animacje");
		}
		else{
			pageTracker._trackPageview("/enableAnimations" );
			animations = true;
			$.cookie("animationsDisabled", 0, { expires: 365 });
			$(this).text("Wyłącz animacje");
		}
		return false;
	});
	$("#submenu li a").each(function(i, e){
		$(e).click(function(){
			$("#submenu li").removeClass("selected");
			$("#submovies").slideUp("fast").load("/categories/"+$(this).text()+"/subcat", function(){
				$(this).slideDown("fast");
				console.log($(e).parent());
				$(e).parent().addClass("selected").attr("style", "");
			});
			return false;
		});
	});
	if($.browser.msie){
		$("#submovies .frame>a").each(function(i, e){
			$(e).mouseover(function(){
				$(e).siblings(".overlay").css('border', '1px solid #0187c5');
			});
			$(e).mouseout(function(){
				$(e).siblings(".overlay").css('border', '1px solid #999');
			});
		});
	}
	else{
		$("#submovies .overlay").each(function(i, e){
			$(e).mouseover(function(){
				$(e).css('backgroundImage','url(/img/antyrama-o.png)'); 
			});
			$(e).mouseout(function(){
				$(e).css('backgroundImage','url(/img/antyrama.png)'); 
			});
		});
	}
// 	$("#searchbox").focus(function(){
// 		offset = $(this).offset();
// 		if(animations){
// 			$("#spotlight").css("top", offset.top+$(this).height() + 5).css("left", offset.left - 200).fadeIn("fast");
// 		}
// 		else{
// 			$("#spotlight").css("top", offset.top+$(this).height() + 5).css("left", offset.left - 200).show();
// 		}
// 	}).blur(function(){
// 		if(animations){
// 			$("#spotlight").fadeOut("slow");
// 		}
// 		else{
// 			$("#spotlight").hide();
// 		}
// 	});
	$("#othermedia li a").mouseover(function(){
		imgsrc = $(this).children("img").attr("src");
		imgsrc = imgsrc.substring(0, imgsrc.length - 7)+".png";
		$(this).children("img").attr("src", imgsrc);
	});
	$("#othermedia li a").mouseout(function(){
		imgsrc = $(this).children("img").attr("src");
		imgsrc = imgsrc.substring(0, imgsrc.length - 4)+"-gs.png";
		$(this).children("img").attr("src", imgsrc);
	});
	$("#submenu li").not(".selected").mouseover(function(){
		$(this).css({
			backgroundImage:"url(\"/img/tab-left-new-sel.png\")"
		});
	});
	$("#submenu li").not(".selected").mouseout(function(){
		$(this).css({
			backgroundImage:"url(\"/img/tab.png\")"
		});
	});
	$("#a107jajo img").click(function(){
		$("#a107jajo .a107jajoimg").hide().eq(0).appendTo("#jajahidden");
		if(animations){
			$("#a107jajo .a107jajoimg").eq(0).prependTo("#a107jajo").fadeIn(350);
		}
		else{
			$("#a107jajo .a107jajoimg").eq(0).prependTo("#a107jajo").show();
		}
	})
});
$(window).load(function(){
	if(animations){
		var newsbarnbr = $("#newsbarnbr").attr("value");
		if(($.cookie("newsbarHighlight") != newsbarnbr) || ($.cookie("dbg") == "1")){
			// delay hack: animating to the same color for 2000ms
			$("#newsbar").animate({color:"#EEEEEE"}, 5000, function(){
				$(this).css("background-color", "#60B8FE").animate(
				{
					backgroundColor:"#344A6E"
				}, 4000);
			});
			$.cookie("newsbarHighlight", newsbarnbr, {expires: 31});
		}
	}
});
