//otwórz stronę
function loaddoc(link) {
var link;
window.location.href=link;
}

//otwarcie zdjęcia lub strony w nowym oknie
var newWindow = null
function new_img(link, width, height) 
{
	var link;
	var width;
	var height;
	if (!newWindow || newWindow.closed)
	{
		window.open('window.php?bimage='+link+'', 'foto' ,'left=5,top=5, width='+width+' , height='+height+', menubar=0, resizable=1, scrollbars=1');
	}
	else //jeżeli otwarte to pokaż
	{
		newWindow.focus();
		newWindow.location.href=link;
	}
}

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");

		if (pos1>0 || pos2>0 || pos3) //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;
	}
}

//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();
}

//w zależnosci od wybranej wartosci pola select 1 pokaz odpowiedni select 2
function subsel(sel1)
{
	if (subtab)
	{
		main_op = document.getElementById(sel1).value; //glowny select
		for (i=0; i<subtab.length; i++) //w petli sprawdz wszystkie divy z selectami - pokaz jeden wlasciwy
		{
			sub = "sub"+subtab[i];
			p = document.getElementById(sub);

			if (main_op == subtab[i])
			{
				p.style.display="block"; //właściwy pokaż
				p.focus();
			}
			else
			p.style.display="none"; //pozostałe ukryj
		}
	}
}

//schowaj banner na stronie głównej
function zamknij(id)
{
	var p = document.getElementById(id);
	p.style.display="none"
}

//schowaj/pokaż wybrany element
function flip(rid)
{
	document.getElementById(rid).style.display = document.getElementById(rid).style.display == 'none' ? 'block' : 'none'
}

//dodaj do ulubionych
function dodaj_ulubione(adres,tytul)
{
    	//FireFox
	if (window.sidebar)
	{
		window.sidebar.addPanel(tytul, adres, "");
	}
	else if (window.external) //IE
	{
		window.external.AddFavorite(adres, tytul);
	}
	else if (window.opera && window.print)     //Opera
	{
		var a = document.createElement('a');
		a.setAttribute('href', adres); a.setAttribute('title', tytul);
		a.setAttribute('rel','sidebar'); a.click();
	}
}

//pokaż cennik w zależnosci od wybranego typu obiektu
function cennik(typ)
{
	//wszystkie schowaj
	document.getElementById('A_cn').style.display="none"
	document.getElementById('B_cn').style.display="none"
	document.getElementById('C_cn').style.display="none"
	document.getElementById('D_cn').style.display="none"	
	document.getElementById('E_cn').style.display="none"

	g = document.getElementById(typ+'_cn') //id kliknietego
	g.style.display="block"; //pokaz

}

function mshow(id) 	
{
	var e = document.getElementById(id);
	e.style.visibility="visible";
}

function mhide(id)
{
	var e = document.getElementById(id);
	e.style.visibility="hidden";
}

