//////////////////////////////////
// validace formulare - registrace 
//////////////////////////////////
function kontrola_registrace() {	
   if (document.formular.login.value == "")  {
   	  document.formular.login.focus();
   	  alert ("Uživatelské jméno je povinné!");
   	  return false;
   }         
   
   var heslo_1 = document.formular.heslo_1.value;	 
   if (heslo_1.length < 6) { 
	   window.alert("Heslo je povinné!"); 
	   return false; 
   }
    
   if (document.formular.heslo_1.value != document.formular.heslo_2.value)  {
   	  document.formular.login.focus();
   	  alert ("Hesla se neshodují!");
   	  return false;
   }
   
   if (document.formular.jm_prij_do.value == "")  {
   	  document.formular.jm_prij_do.focus();
   	  alert ("Příjmení a jméno je povinné!");
   	  return false;
   }  
   
   if (document.formular.ulice_do.value == "")  {
   	  document.formular.ulice_do.focus();
   	  alert ("Ulice je povinná!");
   	  return false;
   }      
   
   if (document.formular.mesto_do.value == "")  {
   	  document.formular.mesto_do.focus();
   	  alert ("Město je povinné!");
   	  return false;
   }  
   
   if (document.formular.psc_do.value == "")  {
   	  document.formular.psc_do.focus();
   	  alert ("PSČ je povinné!");
   	  return false;
   }     
   
   if (document.formular.jm_prij_k.value == "")  {
   	  document.formular.jm_prij_k.focus();
   	  alert ("Kontaktní osoba je povinná!");
   	  return false;
   }
   
   if (document.formular.telefon_k.value == "")  {
   	  document.formular.telefon_k.focus();
   	  alert ("Telefon je povinný!");
   	  return false;
   }
   
   if (document.formular.email_k.value == "" || document.formular.email_k.value == "@" )  {
   	  document.formular.email_k.focus();
   	  alert ("Email je povinný!");
   	  return false;
   }
   
       
   /*
   if (window.RegExp) { 
	  telefon = new RegExp("^[+]420[0-9]{9}$");  
	  if (!telefon.test(document.getElementById("telefon_k").value)) { 
		 window.alert("Telefon je povinný!"); 
		 return false; 
	  } 
   } 
  
   if (window.RegExp) { 
	  email = new RegExp("^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$");  
	  if (!email.test(document.getElementById("email_k").value)) { 
		 window.alert("Email je povinný!"); 
		 return false; 
	  } 
   } 
   */   
}

/////////////////////////////
// validace formulare - zmena 
/////////////////////////////
function kontrola_zmena() {
   var heslo_1 = document.formular.heslo_1.value;	
   if (document.formular.heslo_old.value || document.formular.heslo_1.value || document.formular.heslo_2.value  )  {     
	  if (heslo_1.length < 6) { 
	     window.alert("Nové Heslo je povinné!");
		 return false;  
	  }
	 
	  if (document.formular.heslo_1.value != document.formular.heslo_2.value) {
	     window.alert("Hesla se neshodují!"); 
	     return false;
	  }	  
   }
   
   if (document.formular.jm_prij_do.value == "")  {
   	  document.formular.jm_prij_do.focus();
   	  alert ("Příjmení a jméno je povinné!");
   	  return false;
   }  
   
   if (document.formular.ulice_do.value == "")  {
   	  document.formular.ulice_do.focus();
   	  alert ("Ulice je povinná!");
   	  return false;
   }      
   
   if (document.formular.mesto_do.value == "")  {
   	  document.formular.mesto_do.focus();
   	  alert ("Město je povinné!");
   	  return false;
   }  
   
   if (document.formular.psc_do.value == "")  {
   	  document.formular.psc_do.focus();
   	  alert ("PSČ je povinné!");
   	  return false;
   }
   
   if (document.formular.jm_prij_k.value == "")  {
   	  document.formular.jm_prij_k.focus();
   	  alert ("Kontaktní osoba je povinná!");
   	  return false;
   } 
   if (document.formular.telefon_k.value == "")  {
   	  document.formular.telefon_k.focus();
   	  alert ("Telefon je povinný!");
   	  return false;
   }
   
   if (document.formular.email_k.value == "" || document.formular.email_k.value == "@" )  {
   	  document.formular.email_k.focus();
   	  alert ("Email je povinný!");
   	  return false;
   }
   
       
   /*
   if (window.RegExp) { 
	  telefon = new RegExp("^[+]420[0-9]{9}$");  
	  if (!telefon.test(document.getElementById("telefon_k").value)) { 
		 window.alert("Telefon je povinný!"); 
		 return false; 
	  } 
   } 
  
   if (window.RegExp) { 
	  email = new RegExp("^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$");  
	  if (!email.test(document.getElementById("email_k").value)) { 
		 window.alert("Email je povinný!"); 
		 return false; 
	  } 
   } 
   */    	    
}

/////////////////////////////
// validace formulare - login 
/////////////////////////////
function kontrola_login() {	
   if (document.formular1.login.value == "")  {
   	  document.formular1.login.focus();
   	  alert ("Uživatelské jméno je povinné!");
   	  return false;
   }    

   if (document.formular1.pass.value == "")  {
   	  document.formular1.pass.focus();
   	  alert ("Heslo je povinné!");
   	  return false;
   }   
}

////////////////////////////////////////
// validace formulare - zapomenute heslo 
////////////////////////////////////////
function kontrola_heslo() {	
   if (document.formular2.login_heslo.value == "")  {
   	  document.formular2.login_heslo.focus();
   	  alert ("Uživatelské jméno je povinné!");
   	  return false;
   }  
}

//////////////////////////////////////////////
// validace formulare - koupit (jen pro nereg) 
//////////////////////////////////////////////
function kontrola_koupit_nereg() {	   
   if (document.formular.jm_prij_do.value == "")  {
   	  document.formular.jm_prij_do.focus();
   	  alert ("Příjmení a jméno je povinné!");
   	  return false;
   }  
   
   if (document.formular.ulice_do.value == "")  {
   	  document.formular.ulice_do.focus();
   	  alert ("Ulice je povinná!");
   	  return false;
   }      
   
   if (document.formular.mesto_do.value == "")  {
   	  document.formular.mesto_do.focus();
   	  alert ("Město je povinné!");
   	  return false;
   }  
   
   if (document.formular.psc_do.value == "")  {
   	  document.formular.psc_do.focus();
   	  alert ("PSČ je povinné!");
   	  return false;
   }     
   
   if (document.formular.jm_prij_k.value == "")  {
   	  document.formular.jm_prij_k.focus();
   	  alert ("Kontaktní osoba je povinná!");
   	  return false;
   } 
   
   if (document.formular.telefon_k.value == "")  {
   	  document.formular.telefon_k.focus();
   	  alert ("Telefon je povinný!");
   	  return false;
   }
   
   if (document.formular.email_k.value == "" || document.formular.email_k.value == "@" )  {
   	  document.formular.email_k.focus();
   	  alert ("Email je povinný!");
   	  return false;
   }
   
       
   /*
   if (window.RegExp) { 
	  telefon = new RegExp("^[+]420[0-9]{9}$");  
	  if (!telefon.test(document.getElementById("telefon_k").value)) { 
		 window.alert("Telefon je povinný!"); 
		 return false; 
	  } 
   } 
  
   if (window.RegExp) { 
	  email = new RegExp("^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$");  
	  if (!email.test(document.getElementById("email_k").value)) { 
		 window.alert("Email je povinný!"); 
		 return false; 
	  } 
   } 
   */   
}

///////////////////////////////
// validace formulare - kontakt 
///////////////////////////////
function kontrola_kontakt() {	
   if (document.formular.jmeno.value == "")  {
   	  document.formular.jmeno.focus();
   	  alert ("Jméno je povinné!");
   	  return false;
   }    

   if (window.RegExp) { 
	  email = new RegExp("^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$");  // regularni vyraz
	  if (!email.test(document.getElementById("email").value)) { 
		 window.alert("Email je povinný!"); 
		 return false; 
	  } 
   }
   
   if (document.formular.okres.value == "")  {
   	  document.formular.okres.focus();
   	  alert ("Okres je povinný!");
   	  return false;
   }    
   
   if (document.formular.dotaz.value == "")  {
   	  document.formular.dotaz.focus();
   	  alert ("Dotaz je povinný!");
   	  return false;
   }     
}

///////////////////////////////
// validace formulare - diskuze 
///////////////////////////////
function kontrola_diskuze() {	
   if (document.formular.jm_prij.value == "")  {
   	  document.formular.jm_prij.focus();
   	  alert ("Příjmení a jméno je povinné!");
   	  return false;
   }    
   if (document.formular.email.value != "" && document.formular.email.value != "@")  {
   	  if (window.RegExp) { 
	  	 email = new RegExp("^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$");  // regularni vyraz
	  	 if (!email.test(document.getElementById("email").value)) { 
		 	window.alert("Email není vyplněn správně!"); 
		 	return false; 
	  	 } 
      }
	}  
      
   if (document.formular.dotaz.value == "")  {
   	  document.formular.dotaz.focus();
   	  alert ("Dotaz je povinný!");
   	  return false;
   } 
   
   if (document.formular.captcha.value == "")  {
   	  document.formular.captcha.focus();
   	  alert ("Antispam je povinný!");
   	  return false;
   }        
}

///////////////////////
// validace newsletteru
///////////////////////
function kontrola_newsletter() {
	if (window.RegExp) { 
	  	 email = new RegExp("^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$");  // regularni vyraz
	  	 if (!email.test(document.getElementById("email_n").value)) { 
		 	window.alert("Email není vyplněn správně!"); 
		 	return false; 
	  	 } 
   }
}	