//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=20,top=20, width='+width+' , height='+height+', menubar=0, resizable=1, scrollbars=1');
}

//otwarcie strony 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('log').value;
	new_win('window.php?page=check_login&login='+p_log,'550','120');
}

//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();
}

//oblicza wartosc udzialu w konf.
function calc()
{
	total = 0
	warsz = 0
	t_warsz = 0
	gala = 0
	var no;
	
	//bez udzialu w konferencji - tylko warsztaty
	no = false;
	if (document.getElementById('only_w'))
	no = document.getElementById('only_w').checked;
	
	if (no == true)
	{
		var c1 = cena_p2;
		var c2 = cena_t2;
		wpl = 0;
	}
	else
	{
		var c1 = cena_p1;
		var c2 = cena_t1;
		wpl = document.formularz.elements['wplata'].value;
	}

	for (i=1; i<=5; i++)
	{
		if (t = document.getElementById('t'+i))
		t.innerHTML = c1;
		if (p = document.getElementById('p'+i))
		p.innerHTML = c2;
	}

	//wpłata
	wpl = parseFloat(wpl);

	//warsztaty
	for (i=1; i<=8; i++)
	{
		if (document.getElementById(i))
		{
			w = document.getElementById(i);

			if (w.checked==true)
			{
				if (no==true) //udział tylko w warsztatach
				warsz = tablica_no[i];
				else
				warsz = tablica[i];
				t_warsz += warsz;
			}
		}
	}
	//gala party - ile biletów
	bil = document.getElementById('biletow').value;
	
	//cena biletu z pola hidden
	cena_bil = document.getElementById('c_bil').value;
	gala = cena_bil * bil;

	//suma
	total = wpl + t_warsz + gala;
	s = document.getElementById('suma');
	if (total>0)
	total = total.toFixed(2);
	s.value = total;

	//hotel
	pok1 = document.getElementById('pokoj1');
	pok2 = document.getElementById('pokoj2');
	doby = document.getElementById('dob').value;
	doby = parseInt(doby);
	if (doby>0)
	{
		if (pok1.checked==true) sh = pok1.value * doby;
		else sh = pok2.value * doby;
		document.formularz.elements['suma_hotel'].value = sh;
	}
}


//schowaj reklamę
function zamknij()
{
	var p = document.getElementById('fl');
	p.style.display="none"
}

//czysci zaznaczone radio
function clean()
{

	for (i=1; i<=9; i++)
	{
		e = document.getElementById(i);
		if (e) e.checked=false;
	}
	calc()
}
