
 function otworz_okno(url, szer, wys)
 {
 	var nowe_okno = null;
 	nowe_okno = window.open("", "", "toolbar=no, width="+szer+", height="+wys+", directories=no, status=no, scrollbars=no, resize=no, menubar=no, location=no");
 	nowe_okno.location.href = url;
 }

 function otworz_okno_scroll(url, szer, wys)
 {
 	var nowe_okno = null;
 	nowe_okno = window.open("", "", "toolbar=no, width="+szer+", height="+wys+", directories=no, status=no, scrollbars=yes, resize=no, menubar=no, location=no");
 	nowe_okno.location.href = url;
 }

 function otworz_okno_popup(url, szer, wys)
 {
 	var nowe_okno = null;
 	nowe_okno = window.open("", "", "toolbar=no, width="+szer+", height="+wys+", directories=no, status=no, scrollbars=yes, resize=no, menubar=no, location=no");
 	nowe_okno.location.href = url;
 }


function usun(u)
{
	fno=confirm(u);

	if(fno) {
		return true
	}
	else {
		return false
	}
}

function ukrywaj(nazwa_id)
{
	if(document.getElementById(nazwa_id).style.display == 'none') {
		document.getElementById(nazwa_id).style.display = 'block';
	}
	else {
		document.getElementById(nazwa_id).style.display = 'none';
	}
}

function ukrywajOdkryj(nazwa_id, akcja)
{
	if (akcja == 'odkryj') {
		document.getElementById(nazwa_id).style.display = 'block';
	}
	else if (akcja == 'ukryj') {
		document.getElementById(nazwa_id).style.display = 'none';
	}
}

function formularz_forum (nowy)
{
    if (window.document.dodaj_post.temat_postu.value == "" && nowy == "tak") {
        alert( "Musisz wpisać temat..." );
        window.document.dodaj_post.temat_postu.focus();
        return false ;
    }
    else if (window.document.dodaj_post.autor_postu.value == "") {
        alert( "Musisz się podpisać..." );
        window.document.dodaj_post.autor_postu.focus();
        return false ;
    }
    else if (window.document.dodaj_post.tresc_postu.value == "") {
        alert( "Zapomniałeś o treści postu..." );
        window.document.dodaj_post.tresc_postu.focus();
        return false ;
    }
	return true ;
}

function textareaRozmiar(nazwaTextarea, minimumWierszy) 
{
	var kolumny = document.getElementById(nazwaTextarea).getAttribute('cols');
	var wiersze = document.getElementById(nazwaTextarea).getAttribute('rows');
	var text = document.getElementById(nazwaTextarea).value;
	var dlugoscTextu = text.length;
	var widacZnakow = kolumny * wiersze;
	var tyleWierszy = Math.round(dlugoscTextu / kolumny + 3);

	if (tyleWierszy > minimumWierszy) {
		document.getElementById(nazwaTextarea).rows = tyleWierszy;
	}
}
  
function menuBackg(divId, kier) {
	var divEl = document.getElementById(divId);
		
	if (kier == 'top') {
		divEl.style.backgroundPosition = "top";
		return;
	}
	else if  (kier == 'bot') {
		divEl.style.backgroundPosition = "bottom";
		return;
	}
}


/**
 * Zapis ciastka
 */
function setCookie(c_name, value, expiredays) {
	var exdate = new Date();
	
	exdate.setDate(exdate.getDate() + expiredays);
	
	document.cookie = c_name + "=" + escape(value) + ((expiredays == null)? "" : ";expires=" + exdate.toUTCString());
	
	return;
}


/**
 * Odczyt ciastka
 */
function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			
			if (c_end == -1) {
				c_end = document.cookie.length;
			}
			
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}

	return "";
}


/**
 * Wyświetla okienko poup
 */
function showPopup(img, id, maxIloscW) {
	//Kontrola ilości wyświetleń
	if (id != '') {
		var maxIloscW = Number(maxIloscW);
		var popupCookie = Number(getCookie('popup_' + id));
		
		if (popupCookie >= maxIloscW) {
			return;
		}
		else if (id != '') {
			setCookie('popup_' + id, popupCookie + 1);
			
			$.get('ajax_content.php?ajaxC=cmsTime', function(TS) {
				setCookie('popup_' + id + '_TS', TS);
			})
		}
	}
	
	var img = img.replace(/\|/g, '"');

	$.fancybox(img,{
       	'autoDimensions'	: true,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	return;
}
  
