// JavaScript Document

$('document').ready(function(){
	allowChange=true;
    $('#top_news').hover(function(){ allowChange=false; }, function(){ allowChange=true; });
	
	changeTopNews(1);	
	
	$('#menu a').blend(450);
});
 
function changeTopNews(active)
{
	if (allowChange)
	{
		top_news(active)	
		active=active+1; if( active>5 ) active=1;
	}
	
	setTimeout("changeTopNews("+active+")",10000);
}

function top_news(active)
{	
	for (i=1; i<=5; i++)
	{
		if (i != active)
		{
			$('#chevron_numbers'+i).removeClass("selected");
			$('#top_news_image'+i+':visible').hide();
			$('#top_news_title'+i+':visible').hide();
			$('#top_news_text'+i+':visible').hide();
		}
	}
	
	$('#chevron_numbers'+active).addClass("selected");
	$('#top_news_image'+active+':hidden').show();
	$('#top_news_title'+active+':hidden').fadeIn(250);
	$('#top_news_text'+active+':hidden').fadeIn(250);
}

function sure()
{
	var answer=confirm("Na pewno usunąć?");
	if (answer) { 
		return true; 
	}
	else { 
		return false; 
	}
}

function zliczaj(_licznik, pole, maxlen)
{
        var tekst = document.getElementById(pole).value; // cały text z pola textarea
        var dl_tresc = document.getElementById(pole).value.length; // długoś tekstu z textarea
        var prawdziwa = 0; // licznik znaków
        var entery = 0;

        for (i=0; i<dl_tresc; i++) {
            if (tekst.charAt(i) == "\n") {

                prawdziwa++;
                entery++;

                if (navigator.appName != "Netscape")
                    i++;
            }
            prawdziwa++;
        } // koniec for i

        document.getElementById(_licznik).value = maxlen - prawdziwa; // obcinaj znaki jak za duzo znakow
        document.getElementById('licznik1').innerHTML="pozostało znaków: " + (maxlen - prawdziwa);
		if (prawdziwa>maxlen) {
            if (navigator.appName != "Netscape")
                document.getElementById(pole).value = document.getElementById(pole).value.substring(0, maxlen);
            else
                document.getElementById(pole).value = document.getElementById(pole).value.substring(0, maxlen-entery);

        document.getElementById(_licznik).value = 0;
        //alert("Maksymalna długo¶ć to " + maxlen +".");
        }
}

function showCommentPage(page)
{
	document.getElementById('komentarze'+page).style.display = ''; 
	document.getElementById('komentarze-btn'+page).className = 'pageActive';
	
	for (i=1; i<=50; i++)
	{
		if (i!=page)
		{
		document.getElementById('komentarze'+i).style.display = 'none';
		document.getElementById('komentarze-btn'+i).className = 'pageHidden';
		}
	}
}
