// JavaScript Document

var wiadomosci_aktywna = null;

var body_load_height = null;

var scroll_up = false;

var scroll_down = false;



function createCookie(name,value,days) {

	if (days) {

		var date = new Date();

		date.setTime(date.getTime()+(days*24*60*60*1000));

		var expires = "; expires="+date.toGMTString();

	}

	else var expires = "";

	document.cookie = name+"="+value+expires+"; path=/";

}



function readCookie(name) {

	var nameEQ = name + "=";

	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) {

		var c = ca[i];

		while (c.charAt(0)==' ') c = c.substring(1,c.length);

		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

	}

	return null;

}





function animuj()

{

	if (scroll_down)

	{

		$("#column .wrapper").scrollTop($("#column .wrapper").scrollTop()+1);

	}

	else if (scroll_up)

	{

		$("#column .wrapper").scrollTop($("#column .wrapper").scrollTop()-1);

	}

}

setInterval(animuj, 10);



function zmienRozmiar(rozmiar, linia)

{

	$(".txt, .txt ul, .txt li, .txt p, .txt td, .txt th").css("font-size", rozmiar).css("line-height", linia);

	$("#newsList").css("font-size", rozmiar).css("line-height", linia);

	createCookie('czcionkaRozmiar',rozmiar,1);

	$(".fontsize11px").css("font-weight", "normal");
	$(".fontsize13px").css("font-weight", "normal");
	$(".fontsize15px").css("font-weight", "normal");
	$(".fontsize" + rozmiar).css("font-weight", "bold");
}



$(document).ready(function () {

	$("#pagesListWiadomosci .cell a, #column .list a").click(function(){

		wiadomosci_aktywna = $(this).attr('rel');

		

		if (body_load_height == null)

			body_load_height = $('#body').outerHeight();



		$('.fullDesc').fadeOut('fast');



		$('#body').height('auto');



		var body_h = $('#body').outerHeight();

		var desc_h = $('.descId' + wiadomosci_aktywna).outerHeight();



		if (desc_h < body_h - 60)

		{

			$('.descId' + wiadomosci_aktywna).height(body_h - 60);

		}

		else

		{

			$('#body').animate({

				height:(desc_h + 60)+'px'

			}, ((desc_h + 60)-body_load_height)/600*1000 )

		}



		$('.descId' + wiadomosci_aktywna).fadeIn('slow');



		return false;

	});

	

	$(".fullDesc .close a").click(function(){

		$('.fullDesc').fadeOut('fast');

		$('.fullDesc').height('auto');



		$('#body').animate({

			height:body_load_height+'px'

		}, (($('#body').outerHeight() - 65)-body_load_height)/600*1000 )

		return false;

	});

	

	$("#dropdown_pages").change(function() {

		document.location.href = $(this).attr('value');

	});

	

	$(".scrollBut .down").mouseover(function(){

		scroll_down = true;

	});

	

	$(".scrollBut .up").mouseover(function(){

		scroll_up = true;

	});

	

	$(".scrollBut .down").mouseout(function(){

		scroll_down = false;

	});

	

	$(".scrollBut .up").mouseout(function(){

		scroll_up = false;

	});

	

	$(".rozmiarCzcionki").click(function(){

		zmienRozmiar($(this).css('font-size'), '1.5em');

	});

	

	$(".rozmiarCzcionki").css('display', 'inline');

	

	zmienRozmiar(readCookie('czcionkaRozmiar'), '1.5em');

});
