/////////////////////////////////////////////
//                                         //
//  script powered by: mpps (www.mpps.pl)  //
//                                         //
/////////////////////////////////////////////

function Entry(lancuch){
	if(lancuch=='')
		return lancuch;
	while(lancuch.charAt(0) == " ") 
		lancuch = lancuch.substring(1,lancuch.length);
	while(lancuch.charAt(lancuch.length-1) == " ") 
		lancuch = lancuch.substring(0,lancuch.length-2);
		return lancuch;
}

function CheckAnkieta(){
	if(document.ankieta.rt.checked==false && document.ankieta.ut.checked==false && document.ankieta.pt.checked==false && document.ankieta.mt.checked==false && document.ankieta.vt.checked==false && document.ankieta.serwis.checked==false){
		alert('Proszę zaznaczyć co najmniej jeden z rodzajów usług.');
		document.ankieta.rt.focus();
		return false;
	}
	if(document.ankieta.o1.checked==false && document.ankieta.o2.checked==false && document.ankieta.o3.checked==false && document.ankieta.o4.checked==false && document.ankieta.o5.checked==false){
		alert('Proszę ocenić jakość usług(i).');
		document.ankieta.o1.focus();
		return false;
	}
	return true;
}

function CheckReferencje(){
	if(Entry(document.referencje.klient.value)==''){
		alert('Proszę wpisać nazwę klienta.');
		document.referencje.klient.focus();
		return false;
	}
	if(Entry(document.referencje.miasto.value)==''){
		alert('Proszę wpisać nazwę miasta,\nw którym usługa została wykonana.');
		document.referencje.miasto.focus();
		return false;
	}
	if(Entry(document.referencje.zakres.value)==''){
		alert('Proszę wpisać zakres wykonanych prac.');
		document.referencje.zakres.focus();
		return false;
	}
	if(Entry(document.referencje.date.value)==''){
		alert('Proszę wpisać datę dodania\nw formacie RRRR-MM-DD.');
		document.referencje.date.focus();
		return false;
	}
	return true;
}

function CheckReferencje_edit(){
	if(Entry(document.referencje.klient.value)==''){
		alert('Proszę wpisać nazwę klienta.');
		document.referencje.klient.focus();
		return false;
	}
	if(Entry(document.referencje.miasto.value)==''){
		alert('Proszę wpisać nazwę miasta,\nw którym usługa została wykonana.');
		document.referencje.miasto.focus();
		return false;
	}
	if(Entry(document.referencje.zakres.value)==''){
		alert('Proszę wpisać zakres wykonanych prac.');
		document.referencje.zakres.focus();
		return false;
	}
	if(Entry(document.referencje.date.value)==''){
		alert('Proszę wpisać datę dodania\nw formacie RRRR-MM-DD.');
		document.referencje.date.focus();
		return false;
	}
	return true;
}

function CheckLinki(){
	if(Entry(document.linki.firma.value)==''){
		alert('Proszę wpisać nazwę firmy.');
		document.linki.firma.focus();
		return false;
	}
	if(Entry(document.linki.link.value)==''){
		alert('Proszę wpisać adres strony WWW.');
		document.linki.link.focus();
		return false;
	}
	return true;
}

function CheckBaner(){
	if(Entry(document.baner.naglowek.value)==''){
		alert('Proszę wpisać nagłówek.');
		document.baner.naglowek.focus();
		return false;
	}
	if(Entry(document.baner.naglowek_en.value)==''){
		alert('Proszę wpisać nagłówek angielski.');
		document.baner.naglowek_en.focus();
		return false;
	}
	if(Entry(document.baner.naglowek_de.value)==''){
		alert('Proszę wpisać nagłówek niemiecki.');
		document.baner.naglowek_de.focus();
		return false;
	}
	if(Entry(document.baner.txt_1.value)==''){
		alert('Proszę wpisać pierwszy tekst.');
		document.baner.txt_1.focus();
		return false;
	}
	if(Entry(document.baner.txt_1_eng.value)==''){
		alert('Proszę wpisać pierwszy tekst angielski.');
		document.baner.txt_1_eng.focus();
		return false;
	}
	if(Entry(document.baner.txt_1_deu.value)==''){
		alert('Proszę wpisać pierwszy tekst niemiecki.');
		document.baner.txt_1_deu.focus();
		return false;
	}
	if(Entry(document.baner.txt_2.value)==''){
		alert('Proszę wpisać drugi tekst.');
		document.baner.txt_2.focus();
		return false;
	}
	if(Entry(document.baner.txt_2_eng.value)==''){
		alert('Proszę wpisać drugi tekst angielski.');
		document.baner.txt_2_eng.focus();
		return false;
	}
	if(Entry(document.baner.txt_2_deu.value)==''){
		alert('Proszę wpisać drugi tekst niemiecki.');
		document.baner.txt_2_deu.focus();
		return false;
	}
	if(Entry(document.baner.img_full.value)=='' && document.baner.without_foto.checked==false){
		alert('Proszę podać ścieżkę do pliku - zdjęcia z certyfikatem\nlub badaniem lub zaznaczyć pole \"bez zdjęcia\"\n(zostanie przypisane zdjęcie domyślne).');
		document.baner.img_full.focus();
		return false;
	}
	if(Entry(document.baner.cmd.value)=='alert' && document.baner.without_foto.checked==false){
		alert('Proszę wybrać akcję dla zdjęcia:\n   --> link do certyfikatów\n   --> link do zdjęć badań');
		document.baner.txt_2_deu.focus();
		return false;
	}
	return true;
}

function CheckBaner_edit(){
	if(Entry(document.baner.naglowek.value)==''){
		alert('Proszę wpisać nagłówek.');
		document.baner.naglowek.focus();
		return false;
	}
	if(Entry(document.baner.naglowek_en.value)==''){
		alert('Proszę wpisać nagłówek angielski.');
		document.baner.naglowek_en.focus();
		return false;
	}
	if(Entry(document.baner.naglowek_de.value)==''){
		alert('Proszę wpisać nagłówek niemiecki.');
		document.baner.naglowek_de.focus();
		return false;
	}
	if(Entry(document.baner.txt_1.value)==''){
		alert('Proszę wpisać pierwszy tekst.');
		document.baner.txt_1.focus();
		return false;
	}
	if(Entry(document.baner.txt_1_eng.value)==''){
		alert('Proszę wpisać pierwszy tekst angielski.');
		document.baner.txt_1_eng.focus();
		return false;
	}
	if(Entry(document.baner.txt_1_deu.value)==''){
		alert('Proszę wpisać pierwszy tekst niemiecki.');
		document.baner.txt_1_deu.focus();
		return false;
	}
	if(Entry(document.baner.txt_2.value)==''){
		alert('Proszę wpisać drugi tekst.');
		document.baner.txt_2.focus();
		return false;
	}
	if(Entry(document.baner.txt_2_eng.value)==''){
		alert('Proszę wpisać drugi tekst angielski.');
		document.baner.txt_2_eng.focus();
		return false;
	}
	if(Entry(document.baner.txt_2_deu.value)==''){
		alert('Proszę wpisać drugi tekst niemiecki.');
		document.baner.txt_2_deu.focus();
		return false;
	}
	if(Entry(document.baner.img_old.value)=='' && Entry(document.baner.img_full.value)=='' && document.baner.without_foto.checked==false){
		alert('Proszę podać ścieżkę do pliku - zdjęcia z certyfikatem\nlub badaniem lub zaznaczyć pole \"bez zdjęcia\"\n(zostanie przypisane zdjęcie domyślne).');
		document.baner.img_full.focus();
		return false;
	}
	if(Entry(document.baner.img_full.value)=='' && document.baner.del_img_old.checked==true && document.baner.without_foto.checked==false){
		alert('Proszę podać ścieżkę do pliku - zdjęcia z certyfikatem lub badaniem\nlub odznaczyć pole \"usuń zdjęcie\" lub zaznaczyć pole \"bez zdjęcia\"\n(zostanie przypisane zdjęcie domyślne).');
		document.baner.img_full.focus();
		return false;
	}
	if(Entry(document.baner.cmd.value)=='alert' && document.baner.without_foto.checked==false){
		alert('Proszę wybrać akcję dla zdjęcia lub zaznaczyć pole \"bez zdjęcia\"\n(zostanie przypisana domyślna akcja -> link do certyfikatów).');
		document.baner.txt_2_deu.focus();
		return false;
	}
	return true;
}

function CheckFrm_Bad(){
	if(Entry(document.frm_bad.img_full.value)==''){
		alert('Proszę podać ścieżkę do pliku (zdjęcia) z badaniem.');
		document.frm_bad.img_full.focus();
		return false;
	}
	return true;
}

function CheckFrm_Bad_edit(){
	if(Entry(document.frm_bad.img_full_old.value)=='' && Entry(document.frm_bad.img_full.value)==''){
		alert('Proszę podać ścieżkę do pliku (zdjęcia) z badaniem.');
		document.frm_bad.img_full.focus();
		return false;
	}
	if(Entry(document.frm_bad.img_full.value)=='' && document.frm_bad.del_img_full_old.checked==true){
		alert('Proszę podać ścieżkę do pliku (zdjęcia) z badaniem\nlub odznaczyć pole \"usuń zdjęcie\".');
		document.frm_bad.img_full.focus();
		return false;
	}
	return true;
}

function CheckFrm_Cpl(){
	if(Entry(document.frm_cpl.img_full.value)==''){
		alert('Proszę podać ścieżkę do pliku\n(zdjęcia) z certyfikatem w polu \"foto\".');
		document.frm_cpl.img_full.focus();
		return false;
	}
	if(Entry(document.frm_cpl.rt.value)==''){
		alert('Proszę wpisać uprawnienia do badań RT.');
		document.frm_cpl.rt.focus();
		return false;
	}
	if(Entry(document.frm_cpl.rt.value)!='' && Entry(document.frm_cpl.rtlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla RT.');
		document.frm_cpl.rtlevel.focus();
		return false;
	}
	if(Entry(document.frm_cpl.mt.value)==''){
		alert('Proszę wpisać uprawnienia do badań MT.');
		document.frm_cpl.mt.focus();
		return false;
	}
	if(Entry(document.frm_cpl.mt.value)!='' && Entry(document.frm_cpl.mtlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla MT.');
		document.frm_cpl.mtlevel.focus();
		return false;
	}
	if(Entry(document.frm_cpl.vt.value)==''){
		alert('Proszę wpisać uprawnienia do badań VT.');
		document.frm_cpl.vt.focus();
		return false;
	}
	if(Entry(document.frm_cpl.vt.value)!='' && Entry(document.frm_cpl.vtlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla VT.');
		document.frm_cpl.vtlevel.focus();
		return false;
	}
	if(Entry(document.frm_cpl.ut.value)==''){
		alert('Proszę wpisać uprawnienia do badań UT.');
		document.frm_cpl.ut.focus();
		return false;
	}
	if(Entry(document.frm_cpl.ut.value)!='' && Entry(document.frm_cpl.utlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla UT.');
		document.frm_cpl.utlevel.focus();
		return false;
	}
	if(Entry(document.frm_cpl.pt.value)==''){
		alert('Proszę wpisać uprawnienia do badań PT.');
		document.frm_cpl.pt.focus();
		return false;
	}
	if(Entry(document.frm_cpl.pt.value)!='' && Entry(document.frm_cpl.ptlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla PT.');
		document.frm_cpl.ptlevel.focus();
		return false;
	}
	return true;
}

function CheckFrm_Cpl_edit(){
	if(Entry(document.frm_cpl.img_old.value)==''){
		alert('Proszę podać ścieżkę do pliku\n(zdjęcia) z certyfikatem w polu \"foto\".');
		document.frm_cpl.img_full.focus();
		return false;
	}
	if(document.frm_cpl.del_img_old.checked==true && Entry(document.frm_cpl.img_full.value)==''){
		alert('Proszę podać ścieżkę do pliku (zdjęcia) z certyfikatem\nw polu \"foto\" lub odznaczyć pole \"usuń zdjęcie\".');
		document.frm_cpl.img_full.focus();
		return false;
	}
	if(Entry(document.frm_cpl.rt.value)==''){
		alert('Proszę wpisać uprawnienia do badań RT.');
		document.frm_cpl.rt.focus();
		return false;
	}
	if(Entry(document.frm_cpl.rt.value)!='' && Entry(document.frm_cpl.rtlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla RT.');
		document.frm_cpl.rtlevel.focus();
		return false;
	}
	if(Entry(document.frm_cpl.mt.value)==''){
		alert('Proszę wpisać uprawnienia do badań MT.');
		document.frm_cpl.mt.focus();
		return false;
	}
	if(Entry(document.frm_cpl.mt.value)!='' && Entry(document.frm_cpl.mtlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla MT.');
		document.frm_cpl.mtlevel.focus();
		return false;
	}
	if(Entry(document.frm_cpl.vt.value)==''){
		alert('Proszę wpisać uprawnienia do badań VT.');
		document.frm_cpl.vt.focus();
		return false;
	}
	if(Entry(document.frm_cpl.vt.value)!='' && Entry(document.frm_cpl.vtlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla VT.');
		document.frm_cpl.vtlevel.focus();
		return false;
	}
	if(Entry(document.frm_cpl.ut.value)==''){
		alert('Proszę wpisać uprawnienia do badań UT.');
		document.frm_cpl.ut.focus();
		return false;
	}
	if(Entry(document.frm_cpl.ut.value)!='' && Entry(document.frm_cpl.utlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla UT.');
		document.frm_cpl.utlevel.focus();
		return false;
	}
	if(Entry(document.frm_cpl.pt.value)==''){
		alert('Proszę wpisać uprawnienia do badań PT.');
		document.frm_cpl.pt.focus();
		return false;
	}
	if(Entry(document.frm_cpl.pt.value)!='' && Entry(document.frm_cpl.ptlevel.value)==''){
		alert('Proszę podać poziom wyszkolenia dla PT.');
		document.frm_cpl.ptlevel.focus();
		return false;
	}
	return true;
}

function CheckFrm_Cfm(){
	if(Entry(document.frm_cfm.img_full.value)==''){
		alert('Proszę podać ścieżkę do pliku\n(zdjęcia) z certyfikatem.');
		document.frm_cfm.img_full.focus();
		return false;
	}
	if(Entry(document.frm_cfm.opis.value)==''){
		alert('Proszę opisać certyfikat (język polski).');
		document.frm_cfm.opis.focus();
		return false;
	}
	if(Entry(document.frm_cfm.opis_eng.value)==''){
		alert('Proszę opisać certyfikat (język angielski).');
		document.frm_cfm.opis_eng.focus();
		return false;
	}
	if(Entry(document.frm_cfm.opis_deu.value)==''){
		alert('Proszę opisać certyfikat (język niemiecki).');
		document.frm_cfm.opis_deu.focus();
		return false;
	}
	return true;
}

function CheckFrm_Cfm_edit(){
	if(Entry(document.frm_cfm.img_full_old.value)==''){
		alert('Proszę podać ścieżkę do pliku (zdjęcia)\nz certyfikatem w polu \"foto\".');
		document.frm_cfm.img_full.focus();
		return false;
	}
	if(document.frm_cfm.del_img_full_old.checked==true && Entry(document.frm_cfm.img_full.value)==''){
		alert('Proszę podać ścieżkę do pliku (zdjęcia) z certyfikatem\nw polu \"foto\" lub odznaczyć pole \"usuń zdjęcie\".');
		document.frm_cfm.img_full.focus();
		return false;
	}
	if(Entry(document.frm_cfm.opis.value)==''){
		alert('Proszę opisać certyfikat (język polski).');
		document.frm_cfm.opis.focus();
		return false;
	}
	if(Entry(document.frm_cfm.opis_eng.value)==''){
		alert('Proszę opisać certyfikat (język angielski).');
		document.frm_cfm.opis_eng.focus();
		return false;
	}
	if(Entry(document.frm_cfm.opis_deu.value)==''){
		alert('Proszę opisać certyfikat (język niemiecki).');
		document.frm_cfm.opis_deu.focus();
		return false;
	}
	return true;
}

function CheckContactPol(){
	if(document.contact.checkemail.checked==false && document.contact.checktelefon.checked==false){
		alert('Proszę zaznaczyć sposób kontaktu.');
				document.contact.checkemail.focus();
		return false;
	}
	else{
		if(Entry(document.contact.osoba.value)==''){
			alert('Proszę podać imię.');
			document.contact.osoba.focus();
			return false;
		}
		if(document.contact.checkemail.checked==true){		//mail checked?
			if(Entry(document.contact.email.value)==''){
				alert('Proszę podać adres e-mail.');
				document.contact.email.focus();
				return false;
			}
		}
		if(document.contact.checktelefon.checked==true){		//phone checked?
			if(Entry(document.contact.telefon.value)==''){
				alert('Proszę podać numer telefonu.');
				document.contact.telefon.focus();
				return false;
			}
		}
		if(Entry(document.contact.wpis.value)==''){
			if(confirm("Czy chcesz wysłać wiadomość bez treści?")){
				return true;
			}
			else{
				document.contact.wpis.focus();
				return false;
			}
		}
	}
	return true;
}

function CheckContactEng(){
	if(document.contact.checkemail.checked==false && document.contact.checktelefon.checked==false){
		alert('Please, mark method of contact.');
				document.contact.checkemail.focus();
		return false;
	}
	else{
		if(Entry(document.contact.osoba.value)==''){
			alert('Please, give your name.');
			document.contact.osoba.focus();
			return false;
		}
		if(document.contact.checkemail.checked==true){		//mail checked?
			if(Entry(document.contact.email.value)==''){
				alert('Please, give your e-mail address.');
				document.contact.email.focus();
				return false;
			}
		}
		if(document.contact.checktelefon.checked==true){		//phone checked?
			if(Entry(document.contact.telefon.value)==''){
				alert('Please, give your telephone number.');
				document.contact.telefon.focus();
				return false;
			}
		}
		if(Entry(document.contact.wpis.value)==''){
			if(confirm("Do you want to send message without any content?")){
				return true;
			}
			else{
				document.contact.wpis.focus();
				return false;
			}
		}
	}
	return true;
}

function CheckContactDeu(){
	if(document.contact.checkemail.checked==false && document.contact.checktelefon.checked==false){
		alert('Bitte unterstreichen die Kontaktaufnahmeweise.');
				document.contact.checkemail.focus();
		return false;
	}
	else{
		if(Entry(document.contact.osoba.value)==''){
			alert('Bitte Vorname angeben.');
			document.contact.osoba.focus();
			return false;
		}
		if(document.contact.checkemail.checked==true){		//mail checked?
			if(Entry(document.contact.email.value)==''){
				alert('Bitte Email-Adresse angeben.');
				document.contact.email.focus();
				return false;
			}
		}
		if(document.contact.checktelefon.checked==true){		//phone checked?
			if(Entry(document.contact.telefon.value)==''){
				alert('Bitte Telefonnummer angeben.');
				document.contact.telefon.focus();
				return false;
			}
		}
		if(Entry(document.contact.wpis.value)==''){
			if(confirm("Willst du eine Nachricht ohne Text senden?")){
				return true;
			}
			else{
				document.contact.wpis.focus();
				return false;
			}
		}
	}
	return true;
}

function CheckPraca(){
	if(document.praca.checkemail.checked==false && document.praca.checktelefon.checked==false){
		alert('Proszę zaznaczyć sposób kontaktu.');
				document.praca.checkemail.focus();
		return false;
	}
	else{
		if(Entry(document.praca.osoba.value)==''){
			alert('Proszę podać imię i nazwisko.');
			document.praca.osoba.focus();
			return false;
		}
		if(Entry(document.praca.adreskont.value)==''){
			alert('Proszę podać adres kontaktowy.');
			document.praca.adreskont.focus();
			return false;
		}
		if(document.praca.checkemail.checked==true){		//mail checked?
			if(Entry(document.praca.email.value)==''){
				alert('Proszę podać adres e-mail.');
				document.praca.email.focus();
				return false;
			}
		}
		if(document.praca.checktelefon.checked==true){		//phone checked?
			if(Entry(document.praca.telefon.value)==''){
				alert('Proszę podać numer telefonu.');
				document.praca.telefon.focus();
				return false;
			}
		}
		if(Entry(document.praca.cvdoc.value)==''){
			alert('Proszę podać ścieżkę do pliku z CV.');
			document.praca.cvdoc.focus();
			return false;
		}
		if(document.praca.checkzgoda.checked==false){
			alert('Proszę zaznaczyć pole w celu wyrażenia zgody\nna przetwarzanie danych osobowych.');
			document.praca.checkzgoda.focus();
			return false;
		}
	}
	return true;
}

//ze sprawdzaniem pola file
/*function CheckPraca(praca, file){
	if(document.praca.checkemail.checked==false && document.praca.checktelefon.checked==false){
		alert('Proszę zaznaczyć sposób kontaktu.');
				document.praca.checkemail.focus();
		return false;
	}
	else{
		if(Entry(document.praca.osoba.value)==''){
			alert('Proszę podać imię i nazwisko.');
			document.praca.osoba.focus();
			return false;
		}
		if(Entry(document.praca.adreskont.value)==''){
			alert('Proszę podać adres kontaktowy.');
			document.praca.adreskont.focus();
			return false;
		}
		if(document.praca.checkemail.checked==true){		//mail checked?
			if(Entry(document.praca.email.value)==''){
				alert('Proszę podać adres e-mail.');
				document.praca.email.focus();
				return false;
			}
		}
		if(document.praca.checktelefon.checked==true){		//phone checked?
			if(Entry(document.praca.telefon.value)==''){
				alert('Proszę podać numer telefonu.');
				document.praca.telefon.focus();
				return false;
			}
		}
		if(Entry(document.praca.cvdoc.value)==''){
			alert('Proszę podać ścieżkę do pliku z CV.');
			document.praca.cvdoc.focus();
			return false;
		}
		if(document.praca.checkzgoda.checked==false){
			alert('Proszę zaznaczyć pole w celu wyrażenia zgody\nna przetwarzanie danych osobowych.');
			document.praca.checkzgoda.focus();
			return false;
		}
		extArray = new Array(".doc", ".pdf"); // TABLICA Z ROZSZERZENIAMI PLIKOW KTORE MAJA BYC AKCEPTOWANE DO WYSLANIA
		allowSubmit = false;
		if(!file) return;
		while(file.indexOf("\\") != -1){
			file = file.slice(file.indexOf("\\") + 1);
			ext = file.slice(file.indexOf(".")).toLowerCase();
			for(var i = 0; i < extArray.length; i++){
				if(extArray[i] == ext){
					allowSubmit = true; break;
					return true; break;
				}
			}
		}
		if(allowSubmit) praca.submit();
		else{
			alert("Prosimy wysyłać tylko pliki typu: "
			+ (extArray.join(" ")) + "\n(Microsoft Word, Adobe Reader)."
			+ "\nProszę wybrać nowy plik i wysłać ponownie.");
			allowSubmit = false;
			return false;
		}
	}
	return true;
}*/