function skryj(x,y,z) {
  if(!document.getElementById && document.all) document.getElementById = document.all;
  document.getElementById(x).style.display="none";
		document.getElementById(y).style.display="none";
		document.getElementById(z).style.display="none";
}
function zmen_vypis(x) {
  if(!document.getElementById && document.all) document.getElementById = document.all;
  document.getElementById(x).style.backgroundColor="#FFBB00";
}

function reset_vypis1(x) {
  if(!document.getElementById && document.all) document.getElementById = document.all;
  document.getElementById(x).style.backgroundColor="#FFFFFF";
}
function reset_vypis2(x) {
  if(!document.getElementById && document.all) document.getElementById = document.all;
  document.getElementById(x).style.backgroundColor="#ECE9D8";
}
function zmen_vypis3(x) {
  if(!document.getElementById && document.all) document.getElementById = document.all;
  document.getElementById(x).style.backgroundColor="#ECE9D8";
}
function reset_vypis3(x) {
  if(!document.getElementById && document.all) document.getElementById = document.all;
  document.getElementById(x).style.backgroundColor="#FFBB00";
}
function foto(x) {
msg=window.open('vice.php?id_zaznam='+x+'', 'foto', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,width=790,height=535,top=0,left=0');
msg.focus();
}

function foto_hledam(x) {
msg=window.open('vice.php?hledam=true&id_zaznam='+x+'', 'foto', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,width=790,height=535,top=0,left=0');
msg.focus();
}

function foto_spolu(x) {
msg=window.open('vice.php?spolu=true&id_zaznam='+x+'', 'foto', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,width=790,height=350,top=0,left=0');
msg.focus();
}

function jencisla() {
  with (event)
   if(keyCode<48 || keyCode>57){
   alert ("Volte prosím pouze čísla!");
   returnValue=false;
   }
}
function formular(x) {
  if(x==3) {
    msg=window.open('formular.php?akce='+x+'', 'formular', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,width=520,height=555,top=0,left=0');
  }
  else {
    msg=window.open('formular.php?akce='+x+'', 'formular', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,width=520,height=515,top=0,left=0');
  }
  msg.focus();
}
function formular_test(x) {
  msg=window.open(x, 'formular', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,width=520,height=515,top=0,left=0');
  msg.focus();
}
function add_redirect(x) {
  msg=window.open('add_redirect.php?akce='+x+'', 'add_redirect');
  msg.focus();
}

function bezuvozovek() {
  with (event)
  if(keyCode==34 || keyCode==39){
    alert ("Používat úvozovky není povoleno!");
    returnValue=false;
  }
}

function required(x) {
  var odeslat = true;
		if(x==2) {
		  if (document.formular.polozka.value=="") {
		    alert ("uveďte prosím popis objektu");
		    odeslat=false;
		    document.formular.polozka.focus();
		  }
		  else {
		    if (document.formular.lokalita.value=="") {
		      alert ("uveďte prosím lokalitu, ve které se objekt nachází");
		      odeslat=false;
		      document.formular.lokalita.focus();
		    }
						else if (document.formular.cena.value=="") {
		      alert ("uveďte prosím požadovanou cenu");
		      odeslat=false;
		      document.formular.cena.focus();
		    }
		    else {
		      if (document.formular.jmeno.value=="") {
		        alert ("uveďte prosím Vaše jméno");
		        odeslat=false;
		        document.formular.jmeno.focus();
		      }
		      else {
		        if (document.formular.mail.value=="") {
		          alert ("uveďte prosím Váš kontaktní e-mail");
		          odeslat=false;
		          document.formular.mail.focus();
		        }
										else {
															if (window.RegExp) {
													  re = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$", "i");
													  if (!re.test(document.formular.mail.value)) {
														   alert("Pravděpodobně jste nesprávně vyplnili Vaši e-mailovou adresu.");
														   document.formular.mail.focus();
														   return false;
												   }
												 }	
										}
		      }
		    }
		  }
		}
		else if(x==1) {
		  if (document.formular.polozka.value=="") {
		    alert ("uveďte prosím popis hledaného objektu");
		    odeslat=false;
		    document.formular.polozka.focus();
		  }
		  else {
		    if (document.formular.lokalita.value=="") {
		      alert ("uveďte prosím lokalitu pro spolubydlení");
		      odeslat=false;
		      document.formular.lokalita.focus();
		    }
						else if (document.formular.cena.value=="") {
		      alert ("uveďte prosím maximální cenu");
		      odeslat=false;
		      document.formular.cena.focus();
		    }
		    else {
		      if (document.formular.jmeno.value=="") {
		        alert ("uveďte prosím Vaše jméno");
		        odeslat=false;
		        document.formular.jmeno.focus();
		      }
		      else {
		        if (document.formular.mail.value=="") {
		          alert ("uveďte prosím Váš kontaktní e-mail");
		          odeslat=false;
		          document.formular.mail.focus();
		        }
										else {
															if (window.RegExp) {
													  re = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$", "i");
													  if (!re.test(document.formular.mail.value)) {
														   alert("Pravděpodobně jste nesprávně vyplnili Vaši e-mailovou adresu.");
														   document.formular.mail.focus();
														   return false;
												   }
												 }	
										}
										
		      }
		    }
		  }		
		}	
		
		else if(x==3) {
		  if (document.formular.polozka.value=="") {
		    alert ("specifikujte prosím, zda hledáte spoubydlící(ho) nebo zda spolubydlení nabízíte");
		    odeslat=false;
		    document.formular.polozka.focus();
		  }
		  else {
		    if (document.formular.lokalita.value=="") {
		      alert ("uveďte prosím příslušnou lokalitu");
		      odeslat=false;
		      document.formular.lokalita.focus();
		    }
						else if (document.formular.cena.value=="") {
		      alert ("uveďte prosím cenu");
		      odeslat=false;
		      document.formular.cena.focus();
		    }						
		    else {
		      if (document.formular.jmeno.value=="") {
		        alert ("uveďte prosím Vaše jméno");
		        odeslat=false;
		        document.formular.jmeno.focus();
		      }
		      else {
		        if (document.formular.mail.value=="") {
		          alert ("uveďte prosím Váš kontaktní e-mail");
		          odeslat=false;
		          document.formular.mail.focus();
		        }
										else {
															if (window.RegExp) {
													  re = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$", "i");
													  if (!re.test(document.formular.mail.value)) {
														   alert("Pravděpodobně jste nesprávně vyplnili Vaši e-mailovou adresu.");
														   document.formular.mail.focus();
														   return false;
												   }
												 }	
										}
										
		      }
		    }
		  }		
		}		
			
  if (odeslat == true) {
    return true;
  }
  else {
    return false;
  }
}

function check() {
			var cform=document.forms.odeslat;
			if ((cform.jmeno.value=="jméno") || (cform.jmeno.value=="")) {
							alert("Zapomněli jste uvést Vaše jméno");
							cform.jmeno.focus();
							return false;
			}			
			else if ((cform.email.value=="e-mail") || (cform.email.value=="")) {
				alert("Zapomněli jste uvést Vaši e-mailovou adresu.");
				cform.email.focus();
				return false;
			}
			else if ((cform.telefon.value=="telefon") || (cform.telefon.value=="")) {
							alert("Zapomněli jste uvést Váš telefon");
							cform.telefon.focus();
							return false;
			}				
			else if ((cform.message.value=="zpráva pro nás") || (cform.message.value=="")) {
				alert("Zapomněli jste uvést zprávu pro nás");
				cform.message.focus();
				return false;
			}
			else if (cform.message.value.length>5000) {
				alert("Text zprávy je příliš dlouhý, byl zkrácen na 5000 znaků.");
				cform.message.value=cform.message.value.substring(0,4999);
				cform.message.focus();
				return false;
			}
			else if (window.RegExp) {
				re = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$", "i");
				if (!re.test(cform.email.value)) {
					alert("Pravděpodobně jste nesprávně vyplnili Vaši e-mailovou adresu.");
					cform.email.focus();
					return false;
				}
		}			
		else 
				return true;
}

function tisk() {
if (window.print != null) { window.print(); } else { alert('Vaše verze prohlížeče nepodporuje tento druh zadání tisku.\nTiskněte prosím z menu (FILE / PRINT) nebo kombinací kláves Ctrl+P'); }
}

function check_signup(x) {
  if(x==1) {
    var cform=document.forms.kontakt;
    if (cform.message.value=="") {
      alert("Uveďte prosím Vaši zprávu");
      cform.message.focus();
      return false;
    }
    else if (cform.email.value=="") {
      alert("Pravděpodobně jste zapomněl(a) vyplnit Váš e-mail");
      cform.email.focus();
      return false;
    }
    else if (window.RegExp) {
      re = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$", "i");
      if (!re.test(cform.email.value)) {
        alert("Zadaný e-mail nemá správnou syntaxi");
        cform.email.focus();
        return false;
      }
    }
  }
  return true;
}
