function kontrola_email(adresa) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(adresa)) {
    return true;
  }
  else {
    return false;
  }
}

function kontrola() {
  var text_jmena = self.document.forms.kontakt.jmeno_field.value;
  var je_jmeno_ok = text_jmena != "";

  var text_emailu = self.document.forms.kontakt.email_field.value;
  var je_email_ok = text_emailu != "";

  var text_dotazu = self.document.forms.kontakt.dotaz_field.value;
  var je_dotaz_ok = text_dotazu != "";

  var text = "Musíte vyplnit povinné údaje:\n";
  if (!je_jmeno_ok) {
    document.getElementById("jmeno_field").style.backgroundColor = "rgb(70,122,167)";
    document.getElementById("jmeno_field").style.color = "white";
    text = text + "- Vaše jméno\n";  
  }
  if (!je_email_ok) {
    document.getElementById("email_field").style.backgroundColor = "rgb(70,122,167)";
    document.getElementById("email_field").style.color = "white";
    text = text + "- Váš email\n";  
  }
  if (!je_dotaz_ok) {
    document.getElementById("dotaz_field").style.backgroundColor = "rgb(70,122,167)";
    document.getElementById("dotaz_field").style.color = "white";
    text = text + "- Váš dotaz\n";  
  }
  if (!(je_jmeno_ok && je_email_ok && je_dotaz_ok)) {
    alert(text);
    return false;
  }
  else {
    var email_ok = kontrola_email(self.document.forms.kontakt.email_field.value);
    if (!email_ok) {
      document.getElementById("email_field").style.backgroundColor = "rgb(70,122,167)";
      document.getElementById("email_field").style.color = "white";      
      alert("Neplatný tvar e-mailu.");
      return false;
    }
    return true;
  }
}

function vymazat() {
  document.getElementById("jmeno_field").style.backgroundColor = "white";
  document.getElementById("jmeno_field").style.color = "black";
  
  document.getElementById("email_field").style.backgroundColor = "white";
  document.getElementById("email_field").style.color = "black";
  
  document.getElementById("dotaz_field").style.backgroundColor = "white";
  document.getElementById("dotaz_field").style.color = "black";  
}
