var poc = 0;



function toggle(targetId) {
     	
     	if(document.getElementById) {
         target = document.getElementById(targetId);
           if(target.style.display == "none")  {
             target.style.display = "";
           }
             else {
                  target.style.display = "none";
             }
       }
     	
     } // end function

function toggleBorder(targetId) {
     	
     	if(document.getElementById) {
         target = document.getElementById(targetId);
           if(target.className == "whead")  {
             target.className = "whead2";
           }
             else {
                  target.className = "whead";
             }
       }
     	
     } // end function



function showInfo(imWidth,imHeight,winFile)  
    { 
      if (poc !== 0) { iwin.close(); }; 
     
      url = winFile; 
      resStr = "resizable=0,scrollbars=0";

                                             // define window oversize
      winPlusWidth = 0;
      winPlusHeight = 0;
                                             // calculate window size
      winHeight = imHeight + winPlusHeight;
      winWidth = imWidth + winPlusWidth;
                                             // test if the window is not too large
		heightOK = true;
		
      if (winHeight>screen.availHeight)
        {
         winHeight = screen.availHeight-80;
      	 resStr=",resizable=1,scrollbars=1";
    	 heightOK = false;
      	}
      	
      if (heightOK==false)
        { 
         winWidth = winWidth+22;
      	}	
      								 
      if (winWidth>screen.width)
        { 
          winWidth = screen.width-80;
      	  resStr=",resizable=1,scrollbars=1";
      	}								 

                                                        // calculate centered window position
      winLeft = Math.round((screen.width-winWidth)/2);
      winTop  = Math.round((screen.availHeight-winHeight)/2);

      iwin = window.open(url, "", "left="+winLeft+",top="+winTop+",height="+winHeight+",width="+winWidth+",directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=0,scrollbars=auto");
      
      poc++;
      return true;
    }
    
   
    
    
    
    
    
  //----------------------------------- to same, ale se scrollbarem...  ------------------------------------------------------------------------
    
    
    function showInfo2(imWidth,imHeight,winFile)  
    { 
      if (poc !== 0) { iwin.close(); }; 
     
      url = winFile; 
      resStr = "resizable=0,scrollbars=0";

                                             // define window oversize
      winPlusWidth = 0;
      winPlusHeight = 0;
                                             // calculate window size
      winHeight = imHeight + winPlusHeight;
      winWidth = imWidth + winPlusWidth;
                                             // test if the window is not too large
		heightOK = true;
		
      if (winHeight>screen.availHeight)
        {
         winHeight = screen.availHeight-80;
      	 resStr=",resizable=1,scrollbars=1";
    	 heightOK = false;
      	}
      	
      if (heightOK==false)
        { 
         winWidth = winWidth+22;
      	}	
      								 
      if (winWidth>screen.width)
        { 
          winWidth = screen.width-80;
      	  resStr=",resizable=1,scrollbars=1";
      	}								 

                                                        // calculate centered window position
      winLeft = Math.round((screen.width-winWidth)/2);
      winTop  = Math.round((screen.availHeight-winHeight)/2);

      iwin = window.open(url, "", "left="+winLeft+",top="+winTop+",height="+winHeight+",width="+winWidth+",directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=0,scrollbars=1");
      
      poc++;
      return true;
    } 
    

   
    
//----------------------------------------------------------------------------------------------------------------------------------------
function isNum(passedVal) {
			if (passedVal == "") {
				return false
			}
			for (i=0; i<passedVal.length; i++) {
				if (passedVal.charAt(i) < "0") {
					return false
				}
				if (passedVal.charAt(i) > "9") {
					return false
				}
			}
			return true
		} 


    
     function validEmail(email) {
			invalidChars = " /:,;"
	
			if (email == "") {
				return false
			}
			for (i=0; i < invalidChars.length; i++) {
				badChar = invalidChars.charAt(i)
				if (email.indexOf(badChar,0) > -1) {
					return false
				}
			}
			atPos = email.indexOf("@",1)
			if (atPos == -1) {
				return false
			}
			if (email.indexOf("@",atPos+1) > -1) {
				return false
			}
			periodPos = email.indexOf(".",atPos)
			if (periodPos == -1) {
				return false
			}
			if (periodPos+3 > email.length)	{
				return false
			}
			return true
		}
		
		
		
		
		
		function bezdiakEmail(email) {
		
			var sdiak = "áäčďéěíĺľňóôőöŕšťúůűüýřžÁÄČĎÉĚÍĹĽŇÓÔŐÖŔŠŤÚŮŰÜÝŘŽ";
	
		  var spravne = 1;  // 1 = bez diakritiky, 2 = s diakritikou
                                                                                                                                                         
      for(p = 0; p < email.length; p++) { // proverim, jestli v nazvu neni znak s diakritikou...
                                                   
                if(sdiak.indexOf(email.charAt(p)) != -1) {
                                                          spravne = 2;
                                                          break;
                }
                  else continue;                                                   
                                                   
      } // end for
      
      
      if(spravne > 1) return false;
      
        else return true;
      
		} // end function
		
// ==================================================================================

// poradna.php


function validate() {

  chyba = "";
  
  
  if( (document.dotazForm.dotaz.value=="") || (document.dotazForm.dotaz.value==" Váš dotaz") ) chyba = "Napište text Vašeho dotazu.\n\n";
  if( (document.dotazForm.jmeno.value=="") || (document.dotazForm.jmeno.value==" Vaše jméno") ) chyba = chyba + "Uveďte Vaše jméno.\n\n";
  
  if( ( (document.dotazForm.email.value !== "") && (document.dotazForm.email.value !== " Váš e-mail") ) && (!validEmail(document.dotazForm.email.value))) chyba = chyba + "Uvedená e-mailová adresa není platná.\n\n";

   if( (document.dotazForm.ikod.value == "") || (document.dotazForm.ikod.value.length !== 3) ) chyba = chyba + "Přepište kontrolní kód.";

  if(chyba == "") return true;
  
    else {
       alert(chyba);
       return false;
    }

} // end function




// ohlasy.php

function validateOhlas() {

  var chyba = "";
  
  
  if( (document.dotazForm.dotaz.value=="") || (document.dotazForm.dotaz.value==" Váš ohlas") ) chyba = "Napište text Vašeho ohlasu.\n\n";
  if( (document.dotazForm.jmeno.value=="") || (document.dotazForm.jmeno.value==" Vaše jméno") ) chyba = chyba + "Uveďte Vaše jméno.\n\n";
  
  if( ( (document.dotazForm.email.value !== "") && (document.dotazForm.email.value !== " Váš e-mail") ) && (!validEmail(document.dotazForm.email.value))) chyba = chyba + "Uvedená e-mailová adresa není platná.\n\n";

    if( (document.dotazForm.ikod.value == "") || (document.dotazForm.ikod.value.length !== 3) ) chyba = chyba + "Přepište kontrolní kód.";


  if(chyba == "") return true;
  
    else {
       alert(chyba);
       return false;
    }

} // end function







// workshop_prihlasit.php


function validateSignup() {

  chyba = "";
  
  if(document.signupForm.jmeno.value=="") chyba = "Uveďte Vaše jméno.\n\n";
  if(document.signupForm.prijmeni.value=="") chyba = chyba + "Uveďte Vaše příjmení.\n\n";
  
  if(!(document.signupForm.pohlavi[0].checked || document.signupForm.pohlavi[1].checked )) chyba = chyba + "Uveďte, zda jste muž nebo žena.\n\n";
  
  if(document.signupForm.email.value=="") chyba = chyba + "Uveďte Vaši e-mailovou adresu.\n\n";
  
  if( (document.signupForm.email.value !== "") && (!validEmail(document.signupForm.email.value))) chyba = chyba + "Uvedená e-mailová adresa není platná.\n\n";
  
  if(  (document.signupForm.email.value !== "") && (!bezdiakEmail(document.signupForm.email.value)) )  chyba = chyba + "E-mailová adresa nesmí obsahovat diakritiku.\n\n";
  
  if( (document.signupForm.ulice.value=="") || (document.signupForm.obec.value=="") || (document.signupForm.psc.value=="") ) chyba = chyba + "Uveďte kompletní adresu Vašeho bydliště.\n\n";
  
  if(document.signupForm.zarazeni.value < 1) chyba = chyba + "Vyberte Vaše zařazení.";

  if(chyba == "") return true;
  
    else {
       alert(chyba);
       return false;
    }

} // end function


  function checkMail() {
  
    if(document.checkForm.email.value=="") {
                       alert("Zadejte svoji e-mailovou adresu.");
                       document.checkForm.email.focus();
                       return false;
    }
    
      else {
            if(!validEmail(document.checkForm.email.value)) {
                         alert("Zadaná e-mailová adresa není platná.");
                         document.checkForm.email.select();
                         return false;            
            }
            
              else return true;
      
      
      }
    
  
  }  // end function
  
  
  
  
  function checkEle() {
  
    if(document.zverejnitForm.odpoved.value == "")  {
      alert("Napište odpověď");
      document.zverejnitForm.odpoved.focus();
      return false;
    }
       else return true;
    
  }  // end function
  
  
  
  
  
function checkPublikace() {
    
      var chyba = "";
      
      var formular = document.formular;
      
      var pocetks = 0;
      
      if( (!(formular.p1.value == "")) && (!isNum(formular.p1.value))) chyba += "Počet ks musí být platné číslo (publikace č. 1)\n";
        else pocetks = pocetks + formular.p1.value;
        
      if( (!(formular.p2.value == "")) && (!isNum(formular.p2.value))) chyba += "Počet ks musí být platné číslo (publikace č. 2)\n";
        else pocetks = pocetks + formular.p2.value;
        
      if( (!(formular.p3.value == "")) && (!isNum(formular.p3.value))) chyba += "Počet ks musí být platné číslo (publikace č. 3)\n";
        else pocetks = pocetks + formular.p3.value;
        
      if( (!(formular.p4.value == "")) && (!isNum(formular.p4.value))) chyba += "Počet ks musí být platné číslo (publikace č. 4)\n";
        else pocetks = pocetks + formular.p4.value;
        
      if( (!(formular.p5.value == "")) && (!isNum(formular.p5.value))) chyba += "Počet ks musí být platné číslo (publikace č. 5)\n";
        else pocetks = pocetks + formular.p5.value;
        
      if( (!(formular.p6.value == "")) && (!isNum(formular.p6.value))) chyba += "Počet ks musí být platné číslo (publikace č. 6)\n";
        else pocetks = pocetks + formular.p6.value;
        
      if( (!(formular.p7.value == "")) && (!isNum(formular.p7.value))) chyba += "Počet ks musí být platné číslo (publikace č. 7)\n";
        else pocetks = pocetks + formular.p7.value;
        
      if( (!(formular.p8.value == "")) && (!isNum(formular.p8.value))) chyba += "Počet ks musí být platné číslo (publikace č. 8)\n";
        else pocetks = pocetks + formular.p8.value;
        
      if( (!(formular.p9.value == "")) && (!isNum(formular.p9.value))) chyba += "Počet ks musí být platné číslo (publikace č. 9)\n";
        else pocetks = pocetks + formular.p9.value;
        
      if( (!(formular.p10.value == "")) && (!isNum(formular.p10.value))) chyba += "Počet ks musí být platné číslo (publikace č. 10)\n";
        else pocetks = pocetks + formular.p10.value;  
     
      
      if(pocetks < 1) chyba += "Nevybral(a) jste ani jeden kus žádné publikace.\n";
      
      
			if ( (!formular.doruceni[0].checked) && (!formular.doruceni[1].checked)) chyba += "Vyberte způsob doručení publikací (osobně/poštou).\n";
			  else if((formular.doruceni[1].checked) && (formular.adresa.value=="")) chyba += "Vybral(a) jste doručení poštou - uveďte poštovní adresu, na kterou chcete publikace zaslat.\n";
			
      if(formular.jmeno.value=="") chyba = chyba + "Uveďte Vaše jméno.\n\n";
      
      if( (formular.email.value !== "")  && (!validEmail(formular.email.value))) chyba = chyba + "Uvedená e-mailová adresa není platná.\n\n";
    
        if( (formular.ikod.value == "") || (formular.ikod.value.length !== 3) ) chyba = chyba + "Přepište kontrolní kód.";
    
    
      if(chyba == "") return true;
      
        else {
           alert(chyba);
           return false;
        }
    
    
} // end function
  
