﻿var act_news, i;

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 scroll()
{
 document.getElementById("top-news-" + act_news).style.display = "none";
 act_news++;
 if(!document.getElementById("top-news-" + act_news))
 {
  act_news = 1;
 }
 document.getElementById("top-news-" + act_news).style.display = "block";
 window.setTimeout("scroll()", 5000);
}

function start()
{
 if(document.getElementById("top-news-1") && readCookie('top-closed')==null)
 {
  document.getElementById("body").style.padding = "25px 0 0 0";
  document.getElementById("top-news").style.display = "block";
  act_news = 1;
  document.getElementById("top-news-1").style.display = "block";
  window.setTimeout("scroll()", 5000);
 }
 
 i = 1;
 while(document.getElementById("category-"+i))
 {
  document.getElementById("category-"+i).style.display = "none";
  i++;
 }
 
 document.getElementById("top-news-close").onclick = function()
    {
        document.getElementById("body").style.padding = "0";
		document.getElementById("top-news").style.display = "none";
		document.cookie = 'top-closed=1;expires=';
		alert('Pasek górny nie będzie się już pojawiał do zakończenia bieżącej sesji');
		return false;
    }
 document.getElementById("slideshow").onclick = function()
    {
        window.open("slideshow/index.html","Slideshow","menubar=no,width=740,height=500,toolbar=no");
    }
 document.getElementById("active-footer").onclick = function()
    {
        actual = document.getElementById('aboutParagraph').style.display;
		if(actual == 'block') actual = 'none';
		else actual = 'block';
		document.getElementById('aboutParagraph').style.display = actual;
    }
 fade_start();
}

function toogle(category)
{
 if(document.getElementById("category-"+category).style.display == "none")
 {
  document.getElementById("category-"+category).style.display = "block";
  document.getElementById("toogle-"+category).innerHTML = "zwiń";
 }
 else
 {
  document.getElementById("category-"+category).style.display = "none";
  document.getElementById("toogle-"+category).innerHTML = "rozwiń";
 }
}

window.onload = start;