//otwórz stronę
function loaddoc(link) {
var link;
window.location.href=link;
}

//otwarcie zdjęcia w nowym oknie
function new_img(link, width, height) {
var link;
var width;
var height;
window.open('window.php?bimage='+link+'', 'foto' ,'left=5,top=5, width='+width+' , height='+height+', menubar=0, resizable=1, scrollbars=1');
}

var newWindow = null
function new_win(link, width, height) 
{
	var link;
	var width;
	var height;
	if (!newWindow || newWindow.closed)
	{
		pos1 = link.indexOf("page=galeria");
		pos2 = link.indexOf("page=realizacje");
		pos3 = link.indexOf("page=reportaze");
		pos4 = link.indexOf("window");
		if (pos4<0) link = "window.php"+link; //nie ma slowa window w linku - dodaj

		if (pos1>0 || pos2>0 || pos3>0) //zdjecia - bez menubar i tolbar
		newWindow = window.open(''+link+'', 'window' ,'left=0, top=0, width='+width+' , height='+height+', menubar=no, resizable=yes, toolbar=no, status=no, scrollbars=yes');
		else
		newWindow = window.open(''+link+'', 'window' ,'left=20, top=0, width='+width+' , height='+height+', menubar=yes, resizable=yes, toolbar=yes, scrollbars=yes');
	}
	else
	{
		newWindow.focus();
		newWindow.location.href=link;
	}
}

//do newslettera
function wstaw()
{
	t = document.formularz.mail_podpis.value;
	info = document.formularz.newsletter_info.value;
	document.formularz.mail_podpis.value = info+'\n\n'+t;
	
}

//schowaj reklame na glownej stronie
function zamknij()
{
	var p = document.getElementById('fl');
	p.style.display="none"
}

//pokazuje ile liter zostało (znaki_id) w polu textarea (pole_id)
function litery(pole_id,znaki_id)
{
	maxlen = 160;
	var u = document.getElementById(pole_id).value;
	var l = u.length;
	var z = document.getElementById(znaki_id);
	var p = maxlen-l;
	if (p<0) p=0;
	z.innerHTML = "Pozostało znaków: " +p;

	if (p==0) //obcinaj jak za duzo
	document.getElementById(pole_id).value = u.substring(0,maxlen);
}

//zwraca kliknięta wartosc w oknie do pola formularza w oknie parent
function open_back(name,link)
{
	opener.document.formularz.elements[name].value = link;
	window.close();
}


