// JavaScript Document
function validacja()
{
isOK=0;

cena=document.getElementById("cena").value;
miejscowosc=document.getElementById("miejscowosc").value;
imie=document.getElementById("imie").value;
telefon=document.getElementById("telefon").value;

testTelefon = /^\d{1,3} \d{3} \d{2,3} \d{2,3}$/;
testCena = /^\d{1,7}$/;
testImie = /^[a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬ ]{2,20}$/;

if (!(document.getElementById("rodzaj_t").selectedIndex > 0 && document.getElementById("rodzaj_t").selectedIndex <= 6))
	{

		isOK=1;
		if(isOK==1){
		alert("Proszê wybraæ rodzaj transakcji");
		return false;}
	}

if (!(document.getElementById("rodzaj_n").selectedIndex > 0 && document.getElementById("rodzaj_n").selectedIndex <= 8))
	{
		isOK=1;
		if(isOK==1){
		alert("Proszê wybraæ rodzaj nieruchomo¶ci");
		return false;}
	}
	
if(!testCena.test(cena))
	{
		isOK=1;
		if(isOK==1){
		alert("Proszê wprowadziæ cenê");
		return false;}
	}
	
if(!testImie.test(miejscowosc))
	{
		isOK=1;
		if(isOK==1){
		alert("Proszê wpisaæ miejscowo¶æ");
		return false;}
	}

if(!testImie.test(imie))
	{
		isOK=1;
		if(isOK==1){
		alert("Proszê wpisaæ imiê");
		return false;}
	}
	
if(!testTelefon.test(telefon))
	{
		isOK=1;
		if(isOK==1){
		alert("Brak nr. telefonu lub niepoprawny format: \npoprawnie np. 017 865 11 11 lub 0 600 600 600");
		return false;}
	}
	
if(!document.getElementById("zgoda").checked)
	{
		isOK=1;
		if(isOK==1){
		alert("Proszê wyraziæ zgodê na przetwarzanie danych osobowych");
		return false;}
		
	}

	if(isOK==1)
	return false;
	else return true;
}

function validacja_zamowienia_katalogu()
{
isOK=0;
imie=document.getElementById("imie").value;
tel=document.getElementById("tel").value;
kodMiejscowosc=document.getElementById("adres2").value;
ulicaNumer=document.getElementById("adres1").value;
daneOsobowe=document.getElementById("daneOsobowe").checked;
komunikat="Proszê o poprawne (uzupe³nienie) nastêpuj±cych danych:\n";
obrazek=document.getElementById("STI_imgString").value;

FormName  = "zamowienie"  //Name of the form
CheckName = "check" //Name of the checkboxes (without 1,2,3...10,11,12...)
TextName  = "text"  //Name of the textfields (without 1,2,3...10,11,12...)

testTelefon=/^[0-9\/\+\(\)\- ]{9,}$/;
testKodMiejscowosc = /^\d{2}-\d{3}[a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬.,'\- ]{2,50}$/;
testUlicaNumer = /^[0-9a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬,.\-_ ]{2,}\d{1,}[0-9a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬\/ ]*$/;
testObrazek = /^[a-zA-Z0-9]{5}$/;
testImie = /^[0-9a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬.\-_ ]{3,}$/;

if(!testImie.test(imie))
	{
		komunikat= komunikat+" \n* imie i nazwisko";
		document.getElementById("imie").style.background="#FFFFCC";
		isOK=1;
	}	
	else
		{
			document.getElementById("imie").style.background="#FFFFFF";
		}
if(!testUlicaNumer.test(ulicaNumer))
	{
		komunikat= komunikat+" \n* ulica, nr domu/mieszkania";
		document.getElementById("adres1").style.background="#FFFFCC";
		isOK=1;
	}	
	else
		{
			document.getElementById("adres1").style.background="#FFFFFF";
		}
	
if(!testKodMiejscowosc.test(kodMiejscowosc))
	{
		komunikat= komunikat+" \n* kod pocztowy, miejscowo¶æ";
		document.getElementById("adres2").style.background="#FFFFCC";
		isOK=1;
	}
	else
		{
			document.getElementById("adres2").style.background="#FFFFFF";
		}
	
if(!testTelefon.test(tel))
	{
		komunikat= komunikat+" \n* telefon";
		document.getElementById("tel").style.background="#FFFFCC";
		isOK=1;
	}
	else
		{
			document.getElementById("tel").style.background="#FFFFFF";
		}
		
if(!daneOsobowe)
	{
		komunikat= komunikat+" \n* zgoda na przetwarzanie danych";
		document.getElementById("daneOsobowe").style.background="#FFFFCC";
		document.getElementById("daneOsobowe").style.border="1px solid #DD0000";
		isOK=1;
	}
if(!testObrazek.test(obrazek))
	{
		komunikat= komunikat+" \n* tekst z obrazka";
		document.getElementById("STI_imgString").style.background="#FFFFCC";
		isOK=1;
	}
	
isCHECK=0;	
for(w=1; w<=17; w++){
	if(w==5 || w==9 || w==13 || w==14) continue;
	if(eval("document.zamowienie.check"+w+".checked==true")){
	isCHECK++;
	}
}
if(isCHECK==0){
	komunikat= komunikat+" \n* prosze wybraæ (zaznaczyæ) katalog";
	isOK=1;
	}
	
if(isOK==1)
	{
		alert (komunikat);
		return false;
	}
else return true;
}

function validacjaWyslij()
{
isOK=0;

imie=document.getElementById("imie").value;
mail=document.getElementById("mail").value;
komunikat = "Proszê o poprawne uzupe³nienie nastêpuj±cych danych:\n";

testImie = /^[a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬ ]{2,30}$/;
testMail = /^[a-zA-Z0-9\.\_-]{1,30}@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/;

if(!testImie.test(imie))
	{
		komunikat= komunikat+" \n* imiê i nazwisko";
		document.getElementById("imie").style.background="#FFFFCC";
		isOK=1;
	}
	else
		{
			document.getElementById("imie").style.background="#FFFFFF";
		}
	
	
if(!testMail.test(mail))
	{
		komunikat= komunikat+" \n* e-mail odbiorcy";
		document.getElementById("mail").style.background="#FFFFCC";
		isOK=1;
	}	
	else
		{
			document.getElementById("mail").style.background="#FFFFFF";
		}
	
if(isOK==1)
	{
		alert (komunikat);
		return false;
	}
else return true;
}
function validacja_zamowienia_projekt()
{
isOK=0;

imie=document.getElementById("imie").value;
tel=document.getElementById("tel").value;
kodMiejscowosc=document.getElementById("adres2").value;
ulicaNumer=document.getElementById("adres1").value;
daneOsobowe=document.getElementById("daneOsobowe").checked;
komunikat="Proszê o poprawne uzupe³nienie nastêpuj±cych danych:\n";
obrazek=document.getElementById("STI_imgString").value;

testTelefon=/^[0-9\/\+\(\)\- ]{9,}$/;
testImie = /^[a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬ ]{2,30}$/;
testKodMiejscowosc = /^\d{2}-\d{3}[a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬'\- ]{2,50}$/;
testUlicaNumer = /^[0-9a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬.:\-_ ]{2,}\d{1,}[0-9a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬\/ ]*$/;
testObrazek = /^[a-zA-Z0-9]{5}$/;

if(!testImie.test(imie))
	{
		komunikat= komunikat+" \n* imiê i nazwisko";
		document.getElementById("imie").style.background="#FFFFCC";
		isOK=1;
	}
	else
		{
			document.getElementById("imie").style.background="#FFFFFF";
		}
	
	
if(!testUlicaNumer.test(ulicaNumer))
	{
		komunikat= komunikat+" \n* ulica, nr domu/mieszkania";
		document.getElementById("adres1").style.background="#FFFFCC";
		isOK=1;
	}	
	else
		{
			document.getElementById("adres1").style.background="#FFFFFF";
		}
	
if(!testKodMiejscowosc.test(kodMiejscowosc))
	{
		komunikat= komunikat+" \n* kod pocztowy, miejscowo¶æ";
		document.getElementById("adres2").style.background="#FFFFCC";
		isOK=1;
	}
	else
		{
			document.getElementById("adres2").style.background="#FFFFFF";
		}
	
if(!testTelefon.test(tel))
	{
		komunikat= komunikat+" \n* telefon";
		document.getElementById("tel").style.background="#FFFFCC";
		isOK=1;
	}
	else
		{
			document.getElementById("tel").style.background="#FFFFFF";
		}
		
if(!daneOsobowe)
	{
		komunikat= komunikat+" \n* zgoda na przetwarzanie danych";
		document.getElementById("daneOsobowe").style.background="#FFFFCC";
		document.getElementById("daneOsobowe").style.border="1px solid #DD0000";
		isOK=1;
	}
if(!testObrazek.test(obrazek))
	{
		komunikat= komunikat+" \n* tekst z obrazka";
		document.getElementById("STI_imgString").style.background="#FFFFCC";
		isOK=1;
	}

	
if(isOK==1)
	{
		alert (komunikat);
		return false;
	}
else return true;
}
function validacja_zamowienia_projekt_en()
{
isOK=0;

imie=document.getElementById("imie").value;
tel=document.getElementById("tel").value;
kodMiejscowosc=document.getElementById("adres2").value;
ulicaNumer=document.getElementById("adres1").value;
daneOsobowe=document.getElementById("daneOsobowe").checked;
komunikat="Check your form:\n";
obrazek=document.getElementById("STI_imgString").value;

testTelefon=/^[0-9\/\+\(\)\- ]{9,}$/;
testImie = /^[a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬ ]{2,30}$/;
testKodMiejscowosc = /^\d{2}-\d{3}[a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬'\- ]{2,50}$/;
testUlicaNumer = /^[0-9a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬.\-_ ]{2,}\d{1,}[0-9a-zA-ZZ±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬\/ ]*$/;
testObrazek = /^[a-zA-Z0-9]{5}$/;

if(!testImie.test(imie))
	{
		komunikat= komunikat+" \n* imiê i nazwisko";
		document.getElementById("imie").style.background="#FFFFCC";
		isOK=1;
	}
	else
		{
			document.getElementById("imie").style.background="#FFFFFF";
		}
	
	
if(!daneOsobowe)
	{
		komunikat= komunikat+" \n* zgoda na przetwarzanie danych";
		document.getElementById("daneOsobowe").style.background="#FFFFCC";
		document.getElementById("daneOsobowe").style.border="1px solid #DD0000";
		isOK=1;
	}
if(!testObrazek.test(obrazek))
	{
		komunikat= komunikat+" \n* tekst z obrazka";
		document.getElementById("STI_imgString").style.background="#FFFFCC";
		isOK=1;
	}

	
if(isOK==1)
	{
		alert (komunikat);
		return false;
	}
else return true;
}
