function wnd(src, nazwa, w, h)
{
	if (w>640)
		w=640;

	if (h>480)
		h=480;

  if(window.screen){
    aw=screen.availWidth;
    ah=screen.availHeight;
  }else{
    aw=640;
    ah=450;
  }
  //if(noweOkienko==null || noweOkienko.closed){
    ustawienia=
     "left=" + (aw-w)/2 + ","
    +"top=" + (ah-h)/2 + ","
    +"screenX=" + (aw-w)/2 + ","
    +"screenY=" + (ah-h)/2 + ","

	+"width=" + w + ","
    +"height=" + h + ","
	
	+"innerWidth=" + w + ","
    +"innerHeight=" + h + ","
    +"toolbar=no,"
    +"location=no,"
    +"directories=no,"
    +"status=no,"
    +"menubar=no,"
    +"scrollbars=yes,"
    +"resizable=yes,"
	+"status=no"
    noweOkienko = window.open(src,nazwa,ustawienia);
  //}
  noweOkienko.focus();
}


function pomoc(src, nazwa, w, h)
{

  if(window.screen){
    aw=screen.availWidth;
    ah=screen.availHeight;
  }else{
    aw=640;
    ah=450;
  }
  //if(noweOkienko==null || noweOkienko.closed){
    ustawienia=
     "left=" + (aw-w-10) + ","
    +"top=100, "// + (ah-h) + ","
    +"screenX=" + (aw-w) + ","
    +"screenY=" + (ah-h) + ","

	+"width=" + w + ","
    +"height=" + h + ","
	
	+"innerWidth=" + w + ","
    +"innerHeight=" + h + ","
    +"toolbar=no,"
    +"location=no,"
    +"directories=no,"
    +"menubar=no,"
    +"scrollbars=yes,"
    +"resizable=yes,"
	+"status=no"
    noweOkienko = window.open(src, nazwa, ustawienia);
  //}
  noweOkienko.focus();
}


function doit(nazwa,check)
{
	switch (check)
	{
	case 1: if (document.all[nazwa].style.display == "none") // Zawsze pokaz
				document.all[nazwa].style.display = '';
			 break;
	case 2: if (document.all[nazwa].style.display != "none") // Zawsze ukryj
				document.all[nazwa].style.display = 'none';
			break;

	default:	// Zamiennie ukryj/pokaż
			if (document.all[nazwa].style.display == "none")
				document.all[nazwa].style.display = '';
			else
				document.all[nazwa].style.display = 'none';
			break;

	}
}

///////////////////////////////////
//////////////////// MENU ROZWIJANE
///////////////////////////////////
var head="display:''"

var ns6=document.getElementById&&!document.all||window.opera
var ie4=document.all
//var ns6=document.getElementById&&!document.all
//var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

function checkcontained(e){
var iscontained=0
cur=ns6? e.target : event.srcElement
i=0
if (cur.id=="foldheader")
iscontained=1
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 1 : 0
break
}
cur=ns6? cur.parentNode : cur.parentElement
}

if (iscontained){
var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
if (foldercontent.style.display=="none"){
foldercontent.style.display=""
}
else{
foldercontent.style.display="none"
}
}
}

if (ie4||ns6)
document.onclick=checkcontained



function zamow()
{

	if (!document.zamowienie.nazwa.value)
	{
		alert("Podaj imię i nazwisko lub nazwę firmy!");
		document.zamowienie.nazwa.focus();
	}

	else if ((!document.zamowienie.telefon.value) && (!CheckEMail(document.zamowienie.email.value)))
	{
		alert("Podaj telefon kontaktowy lub adres e-mail!");
		document.zamowienie.telefon.focus();
	}

	else if (document.zamowienie.email.value && !CheckEMail(document.zamowienie.email.value))
	{
		alert('Podany adres e-mail jest błędny!');
		document.zamowienie.email.focus();
	}

	else if (!document.zamowienie.adres.value)
	{
		alert("Podaj właściwy adres!");
		document.zamowienie.adres.focus();
	}

	else if (!document.zamowienie.kod.value)
	{
		alert("Podaj poprawny kod pocztowy!");
		document.zamowienie.kod.focus();
	}

	else if (!document.zamowienie.miasto.value)
	{
		alert("Podaj miasto!");
		document.zamowienie.miasto.focus();
	}

	else
	{
		document.zamowienie.submit();
	}
}



function nowy()
{

	if (!document.dodanie.idklienta.value)
	{
		alert("Podaj osobisty identyfikator!");
		document.dodanie.idklienta.focus();
	}

	else if ((!document.dodanie.idklienta.value) || (document.dodanie.idklienta.value.length<4))
	{
		alert("Wprowadziłeś zbyt krótką nazwę użytkownika !");
		document.dodanie.idklienta.focus();
	}

	else if ((!document.dodanie.haslo1.value) || (document.dodanie.haslo1.value.length<4))
	{
		alert("Wprowadziłeś zbyt krótkie hasło!");
		document.dodanie.haslo1.focus();
	}
	else if (!document.dodanie.haslo2.value)
	{
		alert("Wpisz ponownie hasło!");
		document.dodanie.haslo2.focus();
	}
	else if (document.dodanie.haslo1.value!=document.dodanie.haslo2.value)
	{
		alert("Podany hasła nie są zgodne!");
		document.dodanie.haslo1.value='';
		document.dodanie.haslo2.value='';
		document.dodanie.haslo1.focus();
	}
	else
	{
		document.dodanie.submit();
	}
}


function CheckEMail(email)
	{
		if (email.indexOf('@') == -1)
			return false;
		if (email.length < 4)
			return false;
		if (email.indexOf('@') != email.lastIndexOf('@'))
			return false;
		if (email.indexOf(' ') != -1)
			return false;
		return true;
	} 

function Check_Kontakt(form)
{
	if (!form.temat.value)
	{
		alert("Nie podałeś tematu wiadomości!");
		form.temat.focus();
		return false;
	}

	if (!form.wiadomosc.value)
	{
		alert("Nie wpisałeś treści!");
		form.wiadomosc.focus();
		return false;
	}

	if (!form.podpis.value)
	{
		alert("Nie podpisałeś siŕ!");
		form.podpis.focus();
		return false;
	}

	if (form.email.value && !CheckEMail(form.email.value))
	{
		alert('Podany adres jest b-ŕdny!');
		form.email.focus();
		return false;
	}
return true;
}


function Check_Ciekawastrona(form)
{
	if (!form.nazwa.value)
	{
		alert("Nie podałeś tytułu strony!");
		form.nazwa.focus();
		return false;
	}

	if (!form.http.value)
	{
		alert("Nie podałeś adresu strony!");
		form.http.focus();
		return false;
	}

	if (!form.opis.value)
	{
		alert("Nie wpisałeś opisu strony!");
		form.opis.focus();
		return false;
	}

	if (!form.email.value)
	{
		alert("Nie podałeś swojego adresu e-mail!");
		form.email.focus();
		return false;
	}

	if (form.email.value && !CheckEMail(form.email.value))
	{
		alert('Podany adres jest błędny!');
		form.email.focus();
		return false;
	}
return true;
}


function SprawdzForm(form)
{
	if (!CheckEMail(form.adres.value))
		{
			alert('Podany adres jest błędny.');
			form.adres.focus();
			return (false);
		}

return true;
}
