function FormEDTUsrDataValidator(theForm){
  objImie = document.getElementById('imie');
  objNazwisko = document.getElementById('nazwisko');
  objStanowisko = document.getElementById('stanowisko');
  objFirma = document.getElementById('firma');
  objMiasto = document.getElementById('miasto');
  objNip = document.getElementById('nip');
  objKod = document.getElementById('kod');
  objTelefon = document.getElementById('telefon');
  objAdres = document.getElementById('adres');
  objWojew = document.getElementById('wojew');
  objEmail = document.getElementById('email');

  if (theForm.imie.value.length < 2){
	  objImie.style.display = 'inline';	
	  theForm.imie.focus();
	  return (false);
  }else{ objImie.style.display = 'none'; }

  if (theForm.nazwisko.value == ""){
  	 objNazwisko.style.display = 'inline';
	 theForm.nazwisko.focus();
	 return (false);
  }else{ objNazwisko.style.display = 'none'; }

  if (theForm.stanowisko.value == ""){
  	 objStanowisko.style.display = 'inline';
	 theForm.stanowisko.focus();
	 return (false);
  }else{ objStanowisko.style.display = 'none'; }

  if (theForm.firma.value == ""){
  	 objFirma.style.display = 'inline';
	 theForm.firma.focus();
	 return (false);
  }else{ objFirma.style.display = 'none'; }
  
  if (theForm.miasto.value == ""){
    objMiasto.style.display = 'inline';
	 theForm.miasto.focus();
	 return (false);
  }else{ objMiasto.style.display = 'none'; }
  
  var alertsay = "";
  if (theForm.nip.value.length < 13){
  	objNip.style.display = 'inline';
	theForm.nip.focus();
	return (false);
  }else{ objNip.style.display = 'none'; }
  
  if (theForm.kod.value == ""){
    objKod.style.display = 'inline';
	 theForm.kod.focus();
	 return (false);
  }else{ objKod.style.display = 'none'; }
  
  if (theForm.telefon.value == ""){
    objTelefon.style.display = 'inline';
	 theForm.telefon.focus();
	 return (false);
  }else{ objTelefon.style.display = 'none'; }
  
  if (theForm.adres.value == ""){
    objAdres.style.display = 'inline';
	 theForm.adres.focus();
	 return (false);
  }else{ objAdres.style.display = 'none'; }

  if (theForm.wojew.value == 0){
    objWojew.style.display = 'inline';
	 theForm.wojew.focus();
	 return (false);
  }else{ objWojew.style.display = 'none'; }
  
  //sprawdza miala
  var checkEmail = "@ .";
  var checkStr = theForm.email.value;
  var EmailValid = false;
  var EmailAt = false;
  var EmailPeriod = false;
  var EmailSpace = false;
  for (i = 0;  i < checkStr.length;  i++){
  	  ch = checkStr.charAt(i);
	  for (j = 0;  j < checkEmail.length;  j++){
	  	  if (ch == checkEmail.charAt(j) && ch == "@") EmailAt = true;
		  if (ch == checkEmail.charAt(j) && ch == ".") EmailPeriod = true;
		  if (ch == checkEmail.charAt(j) && ch == " ") EmailSpace = true;
		  if (EmailAt && EmailPeriod && (!EmailSpace)) break;
		  if (j == checkEmail.length) break;
	  }
	  // if both the @ and . were in the string
	  if (EmailAt && EmailPeriod && (!EmailSpace)){
		  EmailValid = true
		  break;
	  }
  }
  if (!EmailValid){
    objEmail.style.display = 'inline';
	 theForm.email.focus();
	 return (false);
  }else{ objEmail.style.display = 'none'; }
}

function FormEDTUsrPasValidator(theForm){
 var alertsay = "";
 if (theForm.sernik.value.length < 5){
 	alert("Długo¶ć Hasła musi mieć przynajmniej 5 znaków.");
	theForm.sernik.focus();
	return (false);
 }

 if (theForm.login.value == ""){
 	alert("Login nie został wypełnione.");
	theForm.login.focus();
	return (false);
 }
}

function FormSerchUsrDataValidator(theForm){
 var alertsay = "";
 if (theForm.nsearchname.value.length < 3){
 	alert("Proszę podać co najmniej 3 litery nazwiska.");
	theForm.nsearchname.focus();
	return (false);
 }
}
function FormSerch2UsrDataValidator(theForm){
 var alertsay = "";
 if (theForm.nsearchalbum.value.length < 3){
 	alert("Proszę podać co najmniej 3 znaki numeru albumu.");
	theForm.nsearchalbum.focus();
	return (false);
 }
}


