function getPageSize  (){
	var dimensions = {width: 0, height: 0};

	var de = document.documentElement;
	dimensions.width = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	dimensions.height = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;

	return dimensions;
}

$(document).ready(function(){

	$('#logoClicker').css('cursor', 'pointer').click(function(){
		window.location = $("#logoClicker a").attr('href');
		return false;
	});

	$.preloadImages('/gfx/menuBG2.jpg');

	//drop down menu
	$("ul.nav").superfish({
		speed		: "slow",
		animation : { opacity:"show", height:"show" }
	});

	/* ladne paski */
	$('#textColumn').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
	$('#newsBox').jScrollPane();

	if($.browser.msie ) {
		if($.browser.version < 7) {
			$("#comp1").css("display", "none");
			$("#comp2").css("display", "none");
			$('img[@src$=.png]').ifixpng();
		}
		if ($.browser.version == 7) {
			$(".jScrollPaneContainer").css('width', '393px')

		}
	}

	$(".mainSiteTopBox").corner("round");


	$(".mainSiteTopBox").each(function() {
		var href = $(this).children("a").attr('href');
		var content  = $(this).children("a").html();
		$(this).children("a").replaceWith("<p>"+content+"</p>");
		$(this).children("p").attr("href", href);
	});



	$(".mainSiteTopBox").bind("click", function(){
		window.location = $(this).children("p").attr('href');
		return false;
	});

	$("input:text, input:password").focus(function(){
		$(this).attr('value', '');
	});

	pasek();
	pulsate();
});

$(window).resize(function(){
	pasek();
});


var x = -1;
function pulsate() {
	x = x + 1;
	if(x>3) {
		x = 0;
	}

	$(".mainSiteTopBox:eq("+x+")").animate({backgroundColor: '#f7a305', color: '#2e4252'}, 2200, mnT(x));
}
function mnT(x) {
	$("#boxDescr p#descr"+x).fadeIn(2200);
	setTimeout("pulseBack("+x+")", 3000);

}
function pulseBack(x) {
	$("#boxDescr p#descr"+x).fadeOut(2200);
	$(".mainSiteTopBox:eq("+x+")").animate({backgroundColor: '#2e4252', color: '#f7a305'}, 2200, pulsate);
}

function pasek() {
	var winHeight = getPageSize().height;
	var docHeight = $('#mainContainer').height(); //wez to uladnij

	var diff = winHeight - docHeight;
	if(diff > 0) {
		$('#bgFade').height(350+diff);
	} else {
		$('#bgFade').height(277);
	}
}

