$(window).load(function() {
	$(".secondaryScreen").css("opacity","0.3");
	$(".secondaryScreen").css("display","block");
	if($(".contentTxt").height() > $(".contentTxt").parent().height()){
		$(".scrollUp").fadeIn("slow");
		$(".scrollDown").fadeIn("slow");
	}
});	
$(function(){
	jQuery.each(jQuery.browser, function(i) {
	  if($.browser.msie && jQuery.browser.version.substr(0,3) < "7"){
		$.ifixpng('design_img/blank.gif');
		$('#navigation ul li a img, #logotypeImg, #subNavSlider img').ifixpng();
	  }
	});	   
	//NEWSLETTER	
	var emailText = "wpisz e-mail"
	$("#nEmail").blur(function(){
		if($(this).val() == ""){
			$(this).val(emailText);
		}
	});
	$("#nEmail").focus(function(){
		if($(this).val() == emailText){
			$(this).val("")
		}
	});
	//oferta	   
	$(".ballimg").click(function(){
		var d = $(this).parent(); 
		for (var i = 1; i<=10; i++) {
			if ($('#ball'+i)) {
				$('#ball'+i).children(".ballTxt").fadeOut("fast");
				$('#ball'+i).children("h3").css('color','#848282');
				$('#ball'+i).removeClass("active");
			}
		}	  
		if (d) {
			d.children(".ballTxt").fadeIn("fast");
			d.children("h3").css('color','#3fdce5');
			d.addClass("active");
			}
	});
	$(".showTxt").click(function(){			
		var id = $(this).attr("id").substr(2,$(this).attr("id").length);
		var d = $("#t-" + id);
		$(".contentTxt").each(function(){
				$(".contentTxt").fadeOut("fast");
		});
		$(".ballTxt a").each(function(){
				$(".ballTxt a").css("color","#fff");
		});
		if(d){
			d.fadeIn("fast");
			$("h1").text(d.attr("title"));
			$(this).css("color","#3fdce5");
		}
		return false;
	});
	//Porftfolio	   	
	$(".secondaryScreen").mouseover(function(){$(this).animate({opacity: 0.7},200);});	
	$(".secondaryScreen").mouseout(function(){$(this).animate({opacity: 0.3},200);});
	$(".scrollUp").click(function(){return false;});
	$(".scrollDown").click(function(){return false;});

	$(".secondaryScreen a").click(function(){	
		var src = $(this).children("img").attr('src');
		var href = $(this).attr('href');
		var mainSrc = $(".mainScreen a").children("img").attr('src');
		var mainHref = $(".mainScreen a").attr('href');
		$(this).children("img").attr('src', mainSrc);
		$(this).attr('href', mainHref);
		$(".mainScreen a").children("img").attr('src', src);
		$(".mainScreen a").attr('href', href);
		return false;
	});
	$(".mainScreen a").lightBox();
	//=========================================	   
	$("#subNavSlider").animate({top: 49},1000);
	$("#subNav").animate({top: 50, opacity: 1},1000);
	//menu
	//$("#navigation ul li a").mouseover(function(){$(this).children(".glow").animate({opacity: 1},300)});
	//$("#navigation ul li a").mouseout(function(){$(this).children(".glow").animate({opacity: 0},300)});
	//$("#navigation ul li a").mouseover(function(){$(this).children(".glow").fadeIn('medium');});
	//$("#navigation ul li a").mouseout(function(){$(this).children(".glow").fadeOut('medium');});	
	
	$(".scrollDown").mousedown(
		function()
		{
			$(this).animate({opacity: .5},100);
			$(".contentTxt").animate({top: (-($(".contentTxt").height()) + ($(".contentTxt").parent().height()))},2000, "linear");
			return false;
	});
	//var top = $(".contentTxt").css("top").substr(0, $(".contentTxt").css("top").length - 2);
	//var actualPos;
	/*$(".contentTxt").mousewheel(
		function(event, delta)
		{
			if(delta < 0)	
				$(".contentTxt").animate({top: (-($(".contentTxt").height()) + ($(".contentTxt").parent().height()))},2000, "linear");
			else if(delta > 0)	
				$(".contentTxt").animate({top: 0},2000, "linear");
			event.stopPropagation();
						event.preventDefault();	
			
	});*/
	
	/*$('.contentTxt').mousewheel(function(event, delta) {
			if (delta > 0){
				top = top + 10;
				if(top > 0){
					$(this).css("top",top);
				}
				//alert(top);
				return false;
			}
			else{
				top = top - 10;
				if(top > -($(this).height()) + ($(this).parent().height())){
					$(this).css("top",top);
				}
				return false;
				}
	});*/
	$(".scrollDown").mouseup(
		function()
		{
			$(this).animate({opacity: 1},100);
			$(".contentTxt").stop();
			return false;
	});
	$(".scrollUp").mousedown(
		function()
		{
			$(this).animate({opacity: .5},100);
			$(".contentTxt").animate({top: 0},2000, "linear");
			return false;
	});
	$(".scrollUp").mouseup(
		function()
		{
			$(this).animate({opacity: 1},100);
			$(".contentTxt").stop();
			return false;
	});
	if($('#subNav').length > 0){
	$('#subNav').Accordion({
		active: '.selected',
		header: 'span',
		alwaysOpen: false,
		animated: true,
		showSpeed: 400,
		hideSpeed: 800
	});
	}
});	
