var poc = 0;



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;
    } 
    


    //----------------------------------- kontrola vyplneni vyhledavaciho formulare...  ------------------------------------------------------------------------
     
    function checkSearch() {
    
    if((document.searchform.string.value == "") || (document.searchform.string.value == " Hledat")) {
    
     document.searchform.string.value == "";
     document.searchform.string.focus();
     return false;
    
    }
    
      else 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
		}
		

    
      
   
// funkce pro zkontrolovani formulare v kontakt.php
    
function validate() {
    
if (document.mailform.dotaz.value == "")  {
                                           alert("Nic jste nenapsal(a).");
                                           document.mailform.dotaz.focus();
                                           return false;
                                          }

    else {    
    
    
        if(document.mailform.jmeno.value == "") {
                                                 alert("Uveďte prosím své jméno.");
                                                 document.mailform.jmeno.focus();
                                                 return false;
        
                                                }
    
           else {
    
    
             if ( (document.mailform.email.value == "") || (document.mailform.email.value == "@") )
              {
	
	           alert("Uveďte prosím svoji e-mailovou adresu.");
	           document.mailform.email.focus();
	           return false;
	
    	      }
 
            else
            {
            
               if(!validEmail(document.mailform.email.value)) {
               
               alert("Zadaná e-mailová adresa není platná.");
	           document.mailform.email.focus();
	           return false;
               
                    }
            
                   
            
                  else  return true;
                    
                     
                      
              }
                  
         }

              }  
      
      
        
    
} // end function







// funkce pro zkontrolovani formulare v en/kontakt.php
    
function validateEn() {
    
if (document.mailform.dotaz.value == "")  {
                                           alert("Message box is empty.");
                                           document.mailform.dotaz.focus();
                                           return false;
                                          }

    else {    
    
    
        if(document.mailform.jmeno.value == "") {
                                                 alert("Please type in your name.");
                                                 document.mailform.jmeno.focus();
                                                 return false;
        
                                                }
    
           else {
    
    
             if ( (document.mailform.email.value == "") || (document.mailform.email.value == "@") )
              {
	
	           alert("Please type in your e-mail.");
	           document.mailform.email.focus();
	           return false;
	
    	      }
 
            else
            {
            
               if(!validEmail(document.mailform.email.value)) {
               
               alert("The e-mail address is not valid.");
	           document.mailform.email.focus();
	           return false;
               
                    }
            
                   
            
                  else  return true;
                    
                     
                      
              }
                  
         }

              }  
      
      
        
    
} // end function























   
    
    
 // kontrola v show.php   
    
 function validate_dotaz()
 {
 
 if(document.dotazform.dotaz.value=="") 
   {	
	alert("Nic jste nenapsal(a).");
	document.dotazform.dotaz.focus();
	return false;	
   }
 
 
 
 
 else if(document.dotazform.email.value=="") 
   {	
	alert("Nezadal(a) jste svoji e-mailovou.");
	document.dotazform.email.focus();
	return false;	
   }

	else if(!validEmail(document.dotazform.email.value)) {
	
	alert("Zadal(a) jste neplatnou e-mailovou adresu.");
	document.dotazform.email.select();
	return false;
	
	}
	
	
	

     else  return true;
 
 
 }
 
 
 
 
 
 
 
 function validate_mailForm() {


    if((!mailform.rd.checked) && (!mailform.poz.checked) && (!mailform.byt.checked) && (!mailform.bytv.checked) && (!mailform.cha.checked) && (!mailform.kom.checked) && (!mailform.nebyt.checked)) {
	
	alert("Nevybral(a) jste žádný typ nemovitosti");
	
	return false;
	
	}

	else if((mailform.mailaddress.value=="") || (mailform.mailaddress.value=="@")) {
	
	alert("Nezadal(a) jste e-mailovou adresu");
	mailform.mailaddress.focus();
	return false;
	
	}

	else if(!validEmail(mailform.mailaddress.value)) {
	
	alert("Zadal(a) jste neplatnou e-mailovou adresu");
	mailform.mailaddress.select();
	return false;
	
	}	

     else  return true;
}

 function validate_mailFormEn() {


    if((!mailform.rd.checked) && (!mailform.poz.checked) && (!mailform.byt.checked) && (!mailform.bytv.checked) && (!mailform.cha.checked) && (!mailform.kom.checked) && (!mailform.nebyt.checked)) {
	
	alert("Please choose type of property you're interested in.");
	
	return false;
	
	}

	else if((mailform.mailaddress.value=="") || (mailform.mailaddress.value=="@")) {
	
	alert("Please fill in your e-mail address.");
	mailform.mailaddress.focus();
	return false;
	
	}

	else if(!validEmail(mailform.mailaddress.value)) {
	
	alert("The e-mail address is not valid.");
	mailform.mailaddress.select();
	return false;
	
	}	

     else  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 checkdbForm() { // databanka.php

    chyba = "";
    
   
    typNab = -1
			for (i=0; i < document.dbform.akce.length; i++) {
				if (document.dbform.akce[i].checked) {
					typNab = i
				}
			}
			
    
    
    if(typNab == -1) chyba = chyba + 'Není vybrán typ nabídky.\n\n'; 
	if(document.dbform.typ.value == "vyberte") chyba = chyba + 'Není vybrán typ nemovitosti.\n\n';
	if(document.dbform.adresa.value == "") chyba = chyba + 'Není uvedena adresa nemovitosti.\n\n';
	
	if( (document.dbform.rok.value !== "") && (!isNum(document.dbform.rok.value)) ) chyba = chyba + 'Uvedený rok výstavby není platné číslo.\n\n';
	if( (document.dbform.zastavena_plocha.value !== "") && (!isNum(document.dbform.zastavena_plocha.value)) ) chyba = chyba + 'Uvedená zastavěná plocha není platné číslo.\n\n';
	if( (document.dbform.uzitna_plocha.value !== "") && (!isNum(document.dbform.uzitna_plocha.value)) ) chyba = chyba + 'Uvedená užitná plocha není platné číslo.\n\n';
	if( (document.dbform.pozemek.value !== "") && (!isNum(document.dbform.pozemek.value)) ) chyba = chyba + 'Uvedená velikost pozemku není platné číslo.\n\n';
	
	if(document.dbform.prijmeni.value == "") chyba = chyba + 'Není uvedeno Vaše příjmení.\n\n';	
	if(document.dbform.email.value == "") chyba = chyba + 'Není uveden Váš e-mail.\n\n';	
	if(document.dbform.email.value == "@") chyba = chyba + 'Není uveden Váš e-mail.\n\n';

	if(chyba == "")  {
	                  if(!validEmail(document.dbform.email.value)) {	
                                                           alert("Zadal(a) jste neplatnou e-mailovou adresu");
                                                           document.dbform.email.select();
                                                           return false;	
                                                           }	
                     
                                    else return true;
                                         
	                  }
	                  
	                  
	             else {
	                   alert(chyba);	                   
	                   return false;
	                   }
                                  
}


    
function checkdbFormEn() { // en/databanka.php

    chyba = "";
    
   
    typNab = -1
			for (i=0; i < document.dbform.akce.length; i++) {
				if (document.dbform.akce[i].checked) {
					typNab = i
				}
			}
			
    
    
    if(typNab == -1) chyba = chyba + 'Type of offer is not chosen.\n\n'; 
	if(document.dbform.typ.value == "vyberte") chyba = chyba + 'Typ of property is not chosen.\n\n';
	if(document.dbform.adresa.value == "") chyba = chyba + 'Address of property is missing.\n\n';
	
	if( (document.dbform.rok.value !== "") && (!isNum(document.dbform.rok.value)) ) chyba = chyba + 'The year of build is not valid number.\n\n';
	if( (document.dbform.zastavena_plocha.value !== "") && (!isNum(document.dbform.zastavena_plocha.value)) ) chyba = chyba + 'The build up area is not valid number.\n\n';
	if( (document.dbform.uzitna_plocha.value !== "") && (!isNum(document.dbform.uzitna_plocha.value)) ) chyba = chyba + 'The usable up area is not valid number.\n\n';
	if( (document.dbform.pozemek.value !== "") && (!isNum(document.dbform.pozemek.value)) ) chyba = chyba + 'The plot size is not valid number.\n\n';
	
	if(document.dbform.prijmeni.value == "") chyba = chyba + 'Surname is missing.\n\n';	
	if(document.dbform.email.value == "") chyba = chyba + 'E-mail address is missing.\n\n';	
	if(document.dbform.email.value == "@") chyba = chyba + 'E-mail address is missing.\n\n';

	if(chyba == "")  {
	                  if(!validEmail(document.dbform.email.value)) {	
                                                           alert("The e-mmail address is not valid");
                                                           document.dbform.email.select();
                                                           return false;	
                                                           }	
                     
                                    else return true;
                                         
	                  }
	                  
	                  
	             else {
	                   alert(chyba);	                   
	                   return false;
	                   }
                                  
}


    