function createWindow(imgSRC, x, y) {
	if (Win == null)
		var Win = window.open("","displayWindow",'width=' + x + ',height=' + y + ',resizable=0,scrollbars=no,menubar=no' );
	Win.document.close();
	Win.document.writeln("<html>");
	Win.document.writeln("<head>");
	Win.document.writeln('<title>Francedom ::: Zapraszamy');
	Win.document.writeln('</title>');
	Win.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">');
	Win.document.writeln('<link rel="StyleSheet" href="parkietstyl.css" type="text/css">');
	Win.document.writeln('</head>');
	Win.document.writeln('<body style="margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;" cellspacing="0" cellpadding="0">');
	Win.document.writeln('<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">');
	Win.document.writeln('<tr valign="center"><td align="center">');
	Win.document.writeln('<img style="cursor: hand;" src="');
	Win.document.writeln(imgSRC);
	Win.document.writeln('" border="1" onClick="javascript:window.close()" alt="Zamknij obrazek" />');
	Win.document.writeln('</td></tr></table></body>');
	Win.document.writeln('</html>');
	Win.focus();
}

function trim(s) {
  return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}

function loginSubmit() {
 if(trim(document.forms[0].login.value).length==0 ||
     (trim(document.forms[0].haslo.value).length==0)) {
    alert("Wypełnij pole loginu i hasła");
    return false;
 }
 return true;
}

function registerSubmit() {
 if(  trim(document.forms[1].imie.value).length==0 ||
      trim(document.forms[1].nazwisko.value).length==0 ||
      trim(document.forms[1].email.value).length==0 ) {
         alert("Wypełnij pole imie, nazwisko i e-mail");
         return false;
 }   
 if(!checkEmail(document.forms[1].email.value)) {
   	alert("Aders e-mail ma nieprawidłowy format");
        return false;
 } 	 
 document.forms[1].submit.value="ok";
  return true;    
 }
 
function studEditSubmit() {	
 if(  trim(document.forms[0].imie.value).length==0 ||
      trim(document.forms[0].nazwisko.value).length==0 ||
      trim(document.forms[0].email.value).length==0 ) {
    alert("Pole imie, nazwisko i e-mail muszą pozostać wypełnione");
    return false;
 } 
 if(!checkEmail(document.forms[0].email.value)) {
   	alert("Aders e-mail ma nieprawidłowy format");
        return false;
 } 	 
 document.forms[0].submit.value="ok";
  return true; 
} 
 

function studPasswdSubmit() {	
 if(  trim(document.forms[0].hasloOld.value).length==0 ||
      trim(document.forms[0].hasloNew1.value).length==0 ||
      trim(document.forms[0].hasloNew2.value).length==0 ) {
    alert("Wszystkie pola musz± zostać wypełnione");
    return false;
 } 
 document.forms[0].submit.value="ok";
 return true; 
} 


function checkEmail(emailStr) {
               if (emailStr.length == 0) {
                   return true;
               }
               var emailPat=/^(.+)@(.+)$/;
               var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
               var validChars="\[^\\s" + specialChars + "\]";
               var quotedUser="(\"[^\"]*\")";
               var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
               var atom=validChars + '+';
               var word="(" + atom + "|" + quotedUser + ")";
               var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
               var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
               var matchArray=emailStr.match(emailPat);
               if (matchArray == null) {
                   return false;
               }
               var user=matchArray[1];
               var domain=matchArray[2];
               if (user.match(userPat) == null) {
                   return false;
               }
               var IPArray = domain.match(ipDomainPat);
               if (IPArray != null) {
                   for (var i = 1; i <= 4; i++) {
                      if (IPArray[i] > 255) {
                         return false;
                      }
                   }
                   return true;
               }
               var domainArray=domain.match(domainPat);
               if (domainArray == null) {
                   return false;
               }
               var atomPat=new RegExp(atom,"g");
               var domArr=domain.match(atomPat);
               var len=domArr.length;
               if ((domArr[domArr.length-1].length < 2) ||
                   (domArr[domArr.length-1].length > 3)) {
                   return false;
               }
               if (len < 2) {
                   return false;
               }
               return true;
}

function adminChangeRez() {
  //sprawdzenie czy ktory z chcekboxow jest zaznaczony
  var i,flag;
  flag=0;
  i=0;
  do {
    //if(document.forms[0].rezCheck[i])
	    flag=1;
      i++;  
  }while (i<105 || flag==0);
  if (flag==0)  { //nie ma zaznaczonego zadnego dnia ani godziny
     alert("Zaznacz dzień i godzinę");	  
     return false;
  }   
  document.forms[0].changeRez.value="ok";
  return true;
}

function studentLekcjeRez() {
 var info="Czy zatwierdzić Twój wybór?";
    if(confirm(info)) {
      document.forms[0].studentRez.value="ok";
      return true;
    }
    return false;
}


function szczegStudSubmit() {
 var info="Czy ustawić warto¶ć "+document.forms[0].godziny.value+" godziny?";
    if(confirm(info)) {
      document.forms[0].noweGodz_Hidd.value="ok";
      return true;
    }
    return false;
}

function probnaSubmit() {
   if(document.forms[0].probnaLekcja.value=="ok")
     return false;	    
   document.forms[0].probnaLekcja.value="ok";
   return true;
}

function przypHaslo() {
 if (trim(document.forms[1].login.value).length==0) {
     alert("Musisz podać login");		
     return false;
 }
 document.forms[1].przypHasloSubmit.value="ok";
 return true; 
}


function delStud() {
 var info="Czy usun±ć konto użytkownika?";
    if(confirm(info)) {
      document.forms[0].studentRez.value="ok";
      return true;
    }
    return false;
}

