function sprawdz(formularz) {
         for (i = 0; i < formularz.length; i++) {
              var pole = formularz.elements[i];
              var n =  new Array;
                  n[0] = 'fname';
                  n[1] = 'sname';
                  n[2] = 'region';
                  n[3] = 'city';
				  n[4] = 'mailadr';
				  n[5] = 'login';
              if (pole.type == 'text') {
                  for (j=0; j< n.length; j++) {
                    if (pole.name == n[j] && pole.value == '') {
                        alert('Proszę wypełnić wszystkie pola zaznaczone oznaczone jako wymagane! ');
                        if(pole.focus) pole.focus();
                        return false;
                      }
                    }
                  }
              }
              return true;
         }//koniec function sprawdz
         
         
function check_select(formularz,n) {
	for (i = 0; i < formularz.length; i++) {
    	var pole = formularz.elements[i];
        if ((pole.name == n) && pole.value == '')  {
             alert('Proszę wypełnić wszystkie pola zaznaczone oznaczone jako wymagane!');
             if(pole.focus)
             pole.focus();
             return false;
        }
    }
    return true;
}
         
                                                     function checkPass(formularz) {
                                                        for (i = 0; i < formularz.length; i++) {
                                                            var pole = formularz.elements[i];
                                                            if ((pole.type == 'password') && pole.value == '') {
                                                                     alert('Nie wpisałeś hasła!');
                                                                     if(pole.focus)
             															pole.focus();
                                                                     return false;
                                                            }
                                                        }
                                                       return true;
                                                     }      
                                                     function checkEqualPass(password,password1)  {
                                                     	if (password.value != password1.value) {
                                                     		alert('Poadane przez ciebie hasła różnią się od siebie!!');
                                                     		password.value = "";
                                                     		password1.value = "";
                                                     		if (password.focus) password.focus();
                                                     		return false;
                                                     	}
                                                     	return true;
                                                     }

        
function accept_terms(form){
if ((form.agree.checked == false) || (form.agree1.checked == false))
{
alert('Aby zarejestrować się w bazie danych Biura Karier AWF należy zapoznać się z warunkami!');
return false;
}else
return true;
}

function email_check(field) {
  var str=field.value;
  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
     alert("Nieprawidłowy adres mailowy!");
     field.focus();
     return false;
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Nieprawidłowy adres mailowy!");
     field.focus();
     return false;
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Nieprawidłowy adres mailowy!");
      field.focus();
      return false;
  }
   if (str.indexOf(at,(lat+1))!=-1){
      alert("Nieprawidłowy adres mailowy!");
      field.focus();
      return false;
   }
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      alert("Nieprawidłowy adres mailowy!");
      field.focus();
      return false;
   }
   if (str.indexOf(dot,(lat+2))==-1){
      alert("Nieprawidłowy adres mailowy!");
      field.focus();
      return false;
   }
   if (str.indexOf(" ")!=-1){
      alert("Nieprawidłowy adres mailowy!");
      field.focus();
      return false;
   }
   return true
}






function check_form(form) {
    if(sprawdz(form) &&
    	check_select(form,'region') &&
        email_check(form.mailadr) &&
        checkPass(form) &&
        checkEqualPass(form.password,form.password1)) return true;
    return false;
}

