function maz(){
    var email = document.getElementById("email1");
    var uzivatel = document.getElementById("username1");
    var heslo1 = document.getElementById("password1");
    var heslo2 = document.getElementById("password2"); 
    

    email.setAttribute("class", "valid");
    uzivatel.setAttribute("class", "valid");
    heslo1.setAttribute("class", "valid");
    heslo2.setAttribute("class", "valid");
}
function ok(stat){
    if(stat == true)
          {  return true;
          }
        else{
            alert("Vyplňte prosím správně označená políčka");                 
            return false;
          }
}    
function control_user(){
    var uzivatel = document.getElementById("username1");
    var ok_val = true;
    var val_uzivatel = uzivatel.value;
    
     if(val_uzivatel == "")
        	{ok_val = false; uzivatel.setAttribute("class", "error");
          }
        else{
           uzivatel.setAttribute("class", "valid");
    }
    
}

function control_email(){
    var email = document.getElementById("email1");
    var ok_val = true;             
    var val_email = email.value;
    
    if(val_email == "")
        	{ok_val = false; email.setAttribute("class", "error");
          }
    else{
           email.setAttribute("class", "valid");
    }
    znaky=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$"); 
    if (!znaky.test(val_email)) 
    { ok_val = false; email.setAttribute("class", "error");
    
    }
    else{
           email.setAttribute("class", "valid");
    }
    
}
function control_password(){
    var heslo1 = document.getElementById("password1");
    var heslo2 = document.getElementById("password2");
    var ok_val = true; 
    var val_heslo1 = heslo1.value;
    var val_heslo2 = heslo2.value; 
    
    if(val_heslo1 != val_heslo2 | val_heslo1 == "" | val_heslo2 == "")
    	{ok_val = false; 
       heslo1.setAttribute("class", "error");
       heslo2.setAttribute("class", "error");
      } 
    else{
       heslo1.setAttribute("class", "valid");
       heslo2.setAttribute("class", "valid");
    }     
    
}
function control_all(){
    control_user();
    control_email();
    control_password();
}
function kontroluj(){
    var email = document.getElementById("email1");
    var uzivatel = document.getElementById("username1");
    var heslo1 = document.getElementById("password1");
    var heslo2 = document.getElementById("password2");
    
    var spravne = true;
    
    var val_email = email.value;
    var val_uzivatel = uzivatel.value;
    var val_heslo1 = heslo1.value;
    var val_heslo2 = heslo2.value;  
         /*---------------------------------------------------------------*/
        if(val_email == "")
        	{ok_val = false; email.setAttribute("class", "error");
          }
        else{
               email.setAttribute("class", "valid");
        }
        znaky=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$"); 
        if (!znaky.test(val_email)) 
        { ok_val = false; email.setAttribute("class", "error");
        
        }
        else{
               email.setAttribute("class", "valid");
        }
        /*---------------------------------------------------------------*/
        if(val_heslo1 != val_heslo2 | val_heslo1 == "" | val_heslo2 == "")
        	{spravne = false; 
           heslo1.setAttribute("class", "error");
           heslo2.setAttribute("class", "error");
          } 
          else{
           heslo1.setAttribute("class", "valid");
           heslo2.setAttribute("class", "valid");
          }
         /*---------------------------------------------------------------*/
        
        if(val_uzivatel == "")
        	{spravne = false; uzivatel.setAttribute("class", "error");
          }
        else{
           uzivatel.setAttribute("class", "valid");
        }
        /*---------------------------------------------------------------*/     
        if(spravne == true)
          {  return true;
          }
        else{
            alert("Vyplňte prosím správně označená políčka");                 
            return false;
          }
}

function kontroluj_prihlaseni(){
  var uzivatel = document.getElementById("username");
  var heslo = document.getElementById("password");
  
  var spravne = true;
  
  var val_uzivatel = uzivatel.value;
  var val_heslo = heslo.value;
  
  
  if(val_heslo == "")
    	{spravne = false; 
       heslo.setAttribute("class", "error");
      } 
  else{
      heslo.setAttribute("class", "valid");
      }
        
  if(val_uzivatel == "")
    	{spravne = false; uzivatel.setAttribute("class", "error");
      }
  else{
      uzivatel.setAttribute("class", "valid");
      }
         
  if(spravne == true)
    {  return true; 
    }
  else{
      alert("Vyplňte prosím správně označená políčka");                 
      return false;
    }






}
function check_delete(){
  var answer = confirm ("Opravdu smazat?")
  if (answer)
    return true;
  else
    return false;
}
