function displayWindows(url, width, height) {
var Win = window.open(url,name,'width=' + width + ',height=' + height +',resizable=0,scrollbars=no,menubar=no');}


var no_text_selected = 'Zaznacz najpierw tekst';
var selectedText = quoteAuthor = '';

function quoteSelection()
{
	theSelection = false;
	if (selectedText) theSelection = selectedText;
	else if (document.selection && document.selection.createRange) theSelection = document.selection.createRange().text;

	if (theSelection)
	{
		emoticon( (document.post.message.value ? '' : '') + '[quote' + (quoteAuthor ? '="' + quoteAuthor + '"' : '') + ']' + theSelection + '[/quote]');
		document.post.message.focus();
		selectedText = quoteAuthor = theSelection = '';
		return;
	}
	else
	{
		alert(no_text_selected);
	}
}

function emoticon(text)
{
	if (document.post.message.createTextRange && document.post.message.caretPos)
	{
		var caretPos = document.post.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		document.post.message.focus();
	}
	else if (document.post.message.selectionStart != undefined)
	{
		document.post.message.value = document.post.message.value.substring(0, document.post.message.selectionStart) + text + document.post.message.value.substring(document.post.message.selectionStart);
		document.post.message.focus();
	}
	else
	{
		document.post.message.value += text;
		document.post.message.focus();
	}
}

function qu(username)
{
	if (window.getSelection && window.getSelection() || document.selection && document.selection.createRange && document.selection.createRange().text)
	{
		return true;
	}
	else
	{
		return false;
	}
}	

function niezalogowany()
{
	alert("Musisz byæ zalogowany(a)!!!");
}	

function czas_do_meczu (rok,miesiac,dzien,godzina, minuta) {
var msPerDay = 24 * 60 * 60 * 1000 ;

var data_meczu = new Date(rok,miesiac,dzien,godzina,minuta,00);
var now = new Date();
var timeLeft = data_meczu.getTime() - now.getTime();

e_daysLeft = timeLeft / msPerDay;
daysLeft = Math.floor(e_daysLeft);
e_hrsLeft = (e_daysLeft - daysLeft)*24;
hrsLeft = Math.floor(e_hrsLeft);
e_minsLeft = (e_hrsLeft - hrsLeft)*60;
minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
secLeft = Math.floor((e_minsLeft - minsLeft)*60);

if (daysLeft < 1 ) {daysLeft = 0;}

document.getElementById("pole_1").innerHTML = daysLeft;
document.getElementById("pole_2").innerHTML = hrsLeft;
document.getElementById("pole_3").innerHTML = minsLeft;
document.getElementById("pole_4").innerHTML = secLeft;

id = setTimeout( "czas_do_meczu ("+rok+","+miesiac+","+dzien+","+godzina+","+minuta+",00)", 1000);

}

function poll_send() {
	
	advAJAX.submit(document.getElementById("poll"), {
		disableForm: true,
		parameters: {"ajax": "true"},
		timeout : 3000,
		//onTimeout : function() { alert("Connection timed out."); },
		retry: 2,
		retryDelay: 2000,
		onRetry : function() { alert("Retry connection..."); },
		onRetryDelay : function() { alert("Awaiting retry..."); },
		onSuccess : function(obj) { document.getElementById('poll-container').innerHTML = obj.responseText; },
		onError : function(obj) { alert("Error: " + obj.status); }
 	});
}
