function _focus(nazwa,zawartosc)
{
var textbox= document.getElementById(nazwa);

if (textbox.value == zawartosc)
{
textbox.value = "";
}
textbox.focus();
}

function _blur(nazwa,zawartosc)
{
var textbox= document.getElementById(nazwa);
if (textbox.value == "")
{

textbox.value = zawartosc;
}
}

function _focus2(nazwa,zawartosc)
{
var textbox= document.getElementById(nazwa);
if (nazwa=='haslo')
{

	textbox.style.background="#FFFFFF";  
}
if (textbox.value == zawartosc)
{
textbox.value = "";
}
textbox.focus();
}

function _blur2(nazwa,zawartosc)
{
var textbox= document.getElementById(nazwa);
if (textbox.value == "")
{


	textbox.style.background="url('img/haslo.gif') top left no-repeat";

textbox.value = "";
}
}




function zapis_uzytkownika(nazwa_uzytkownika,haslo1,haslo2,e_mail, imie , nazwisko , zam_adres1 , zam_miasto,zam_kod)
{
	if (document.getElementById(nazwa_uzytkownika).value=="")
	{alert('brak podanej nazwy użytkownika');
	document.getElementById(nazwa_uzytkownika).focus();
	document.getElementById(nazwa_uzytkownika).select();

	return false	
	}
	reg = /^[a-zA-Z0-9]{3,}$/
    wyn = document.getElementById(nazwa_uzytkownika).value.match(reg);
    if (wyn == null) {
        alert("nazwa użytkownika musi zawierać od 3 znaków, Dopuszczalne znaki to duże, małe litery oraz cyfry bez polskich znaków.");
        return false;
    }

//	obsluga haseł
	
	if (document.getElementById(haslo1).value=="")
	{alert('brak podanego hasła');
	document.getElementById(haslo1).focus();
	return false	
	}
	reg = /^[a-zA-Z0-9]{4,15}$/
    wyn = document.getElementById(haslo1).value.match(reg);
    if (wyn == null) {
        alert("Hasło musi zawierać od 4 do 15 znaków, Dopuszczalne znaki to duże, małe litery oraz cyfry bez polskich znaków.");
        return false;
    }

	if (document.getElementById(haslo2).value=="")
	{alert('brak podanego hasła');
	document.getElementById(haslo2).focus();
	return false	
	}

	if (document.getElementById(haslo1).value!=document.getElementById(haslo2).value)
	{
	alert('Hasła nie są zgodne. Proszę podać takie same hasła.');
	document.getElementById(haslo1).focus();
	return false
	}

	
	// obsługa adresu email
	if (document.getElementById(e_mail).value=="")
	{alert('brak podanego adresu e-mail');
	document.getElementById(e_mail).focus();
	return false	
	}
	
	reg = /^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/
    wyn = document.getElementById(e_mail).value.match(reg);
    if (wyn == null) {
        alert("Proszę podać poprawny adres email. " +
              "Poprawny adres musi zawierać małpę " +
              "oraz co najmniej dwa człony nazwy serwera, " +
              "np. a@b.c lub ala@ma.kota.czarnego.com.");
        return false;
    }

	//imie
	if (document.getElementById(imie).value=="")
	{alert('brak podanego imienia');
	document.getElementById(imie).focus();
	return false	
	}
	reg = /^[a-zA-ZąćęłńóśżźĄĆĘŁŃÓŚŻŹ]{2,50}$/;
	wyn = document.getElementById(imie).value.match(reg);
    if (wyn == null) {
        alert("Proszę podać poprawne imię");
        return false;
    }
//nazwisko
	if (document.getElementById(nazwisko).value=="")
	{alert('brak podanego nazwiska');
	document.getElementById(nazwisko).focus();
	return false	
	}

	reg = /^[a-zA-ZąćęłńóśżźĄĆĘŁŃÓŚŻŹ]{2,50}$/;
	wyn = document.getElementById(nazwisko).value.match(reg);
    if (wyn == null) {
        alert("Proszę podać poprawne nazwisko");
        return false;
    }

	if (document.getElementById(zam_adres1).value=="")
	{alert('brak podanego adresu');
	document.getElementById(zam_adres1).focus();
	return false	
	}
	if (document.getElementById(zam_miasto).value=="")
	{alert('brak podanej nazwy miejscowości');
	document.getElementById(zam_miasto).focus();
	return false	
	}
//kod miejscowosci
	if (document.getElementById(zam_kod).value=="")
	{alert('brak podanego kodu pocztowego');
	document.getElementById(zam_kod).focus();
	return false	
	}
	reg =/^\d{2}\-\d{3}$/
    wyn = document.getElementById(zam_kod).value.match(reg);
    if (wyn == null) {
        alert("Proszę podać właściwy kod pocztowy np. 06-600");
        return false;
    }


	if (document.getElementById(zam_wojewodztwo).value=="brak")
	{alert('brak wskazania województwa');
	document.getElementById(zam_wojewodztwo).focus();
	return false	
	}


	return true;

 }
 function zapis_uzytkownika2(imie , nazwisko , telefon,  wys_adres1 , wys_miasto, wys_kod)
{
	

	//imie
	if (document.getElementById(imie).value=="")
	{alert('brak podanego imienia');
	document.getElementById(imie).focus();
	return false	
	}
	reg = /^[a-zA-ZąćęłńóśżźĄĆĘŁŃÓŚŻŹ]{2,50}$/;
	wyn = document.getElementById(imie).value.match(reg);
    if (wyn == null) {
        alert("Proszę podać poprawne imię");
        return false;
    }
//nazwisko
	if (document.getElementById(nazwisko).value=="")
	{alert('brak podanego nazwiska');
	document.getElementById(nazwisko).focus();
	return false	
	}

	reg = /^[a-zA-ZąćęłńóśżźĄĆĘŁŃÓŚŻŹ]{2,50}$/;
	wyn = document.getElementById(nazwisko).value.match(reg);
    if (wyn == null) {
        alert("Proszę podać poprawne nazwisko");
        return false;
    }
//telefon
	if (document.getElementById(telefon).value=="")
	{alert('brak podanego numeru telefonu');
	document.getElementById(telefon).focus();
	return false	
	}

	if (document.getElementById(wys_adres1).value=="")
	{alert('brak podanego adresu');
	document.getElementById(wys_adres1).focus();
	return false	
	}

	if (document.getElementById(wys_miasto).value=="")
	{alert('brak podanej nazwy miejscowości');
	document.getElementById(wys_miasto).focus();
	return false	
	}
//kod miejscowosci
	if (document.getElementById(wys_kod).value=="")
	{alert('brak podanego kodu pocztowego');
	document.getElementById(wys_kod).focus();
	return false	
	}
	reg =/^\d{2}\-\d{3}$/
    wyn = document.getElementById(wys_kod).value.match(reg);
    if (wyn == null) {
        alert("Proszę podać właściwy kod pocztowy np. 06-600");
        return false;
    }
	if (document.getElementById(wys_wojewodztwo).value=="brak")
	{alert('brak wskazania województwa');
	document.getElementById(wys_wojewodztwo).focus();
	return false	
	}

	

	return true;

 }

function dodaj(nazwapola)
{
	w=parseInt(document.getElementById(nazwapola).value);	
	document.getElementById(nazwapola).value= w+1;
}

function odejmij(nazwapola)
{
	w=parseInt(document.getElementById(nazwapola).value);	
	document.getElementById(nazwapola).value= w-1;
	if(document.getElementById(nazwapola).value<0) {document.getElementById(nazwapola).value=0};
}




      function isArray(obj) {

      if (obj == null) return false;

      return obj.constructor == Array;

      }
function sprawdz()
{
if  (document.dostawa.dost.length==null)
{
	if (document.dostawa.dost.checked)
			{
				return true
			}
}
else
{
w=document.dostawa.dost.length;

	for (i=0; i <w; i++) {
		if (document.dostawa.dost[i].checked)
		{
			return true
		}
	}
}
return false;

}


function sprawdz2()
{
if  (document.platnosc.plat.length==null)
{

	if (document.platnosc.plat.checked)
		{
			return true
		}
}
else
{
w=document.platnosc.plat.length;

	for (i=0; i <w; i++) {
		
		if (document.platnosc.plat[i].checked)
		{
			return true
		}
	}
}
return false;

}
