//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('http://www.infoarchitekta.pl/window.php?bimage='+link+'', 'foto' ,'left=20,top=20, width='+width+' , height='+height+', menubar=0, resizable=1, scrollbars=1');
}

//otwarcie dok w nowym oknie
function new_win(link, width, height) {
var link;
var width;
var height;
window.open(link, 'noweokno' ,'left=20,top=20, width='+width+' , height='+height+', menubar=0, resizable=1, scrollbars=1');
}

//sprawdzenie czy login istnieje
function check_login()
{
	var p_log = document.getElementById('login').value;
	new_win('window.php?page=register&run=check&login='+p_log,'550','120');
}

//zakladki w wyszukiwarce
function sea(e)
{
	var e = parseInt(e);
	for (i=1; i<=4; i++)
	{
		k = document.getElementById("z_"+i); //zakładka
		t = document.getElementById("t_"+i); //tabelka
		//wszystkie ustaw na nieaktywne
		k.setAttribute("class", "nact");
		k.setAttribute("className", "nact");
		t.style.display = "none";

		if (i==e) //kliknięty aktywny
		{
			k.setAttribute("class", "act");
			k.setAttribute("className", "act");
			t.style.display = "block";
		}
	}
}

//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 
		znikaj = "true";
		znikaj_p = document.getElementById('znikajPK');
		
		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="inline";
         znikaj = "false";
      }
			else  {
			   p.style.display="none";
			}
		}
		if (znikaj == "true")
		 znikaj_p.style.display="none";
		else
		 znikaj_p.style.display="inline";
	}
}

//pokaż odpowiednie pola - wgrywanie plików CAD/PDF
function show()
{
	dc1 = document.getElementById('dec1');
	dc2 = document.getElementById('dec2');
	dp1 = document.getElementById('d1');
	dp2 = document.getElementById('d2');
	dp1.style.display = "none";
	dp2.style.display = "none";
	if (dc1.checked == true) dp1.style.display = "block";
	if (dc2.checked == true) dp2.style.display = "block";
}

//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();
	}
}

//ustaw jako stronę startowa
function homepage(adres)
{
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(adres);
	}
	else
	{
		alert('Ta opcja działa tylko w Internet Explorer');
	}
}

//wpisane słowo przenies do google
function gotogoogle()
{
	w = document.getElementById('word').value;
	loaddoc('http://www.google.pl/search?hl=pl&btnG=Szukaj&q='+w);
}

//schowaj województwo
function hide()
{
	k = document.getElementById('kraj');
	w = document.getElementById('wo');
	if (k.value!='PL')
	w.style.display = "none";
	else
	w.style.display = "block";
}

//sprawdza zaznaczenie pol do utworzenia zipa
function send_zip()
{
	cad = document.formularz.elements['all_cad'].checked;
	pdf = document.formularz.elements['all_pdf'].checked;
	pho = document.formularz.elements['photo'].checked;
	if (cad!=true && pdf!=true && pho!=true)
	alert("Zaznacz, które rodzaje plików chcesz pobrać!");
	else
	document.formularz.submit();
}

