// JavaScript Document
function ukaz(id)
{
document.getElementById(id).style.display="block";
};
function zmiz(id)
{
document.getElementById(id).style.display="none";
};
function zmiztext()
{
document.getElementById('message').value="";
}

/*Honza Schenk - novy kod na formulare*/

function kontrolaPrazdna(id) {
  if (!jePrazdny(document.getElementById(id).value)) {
      document.getElementById(id).style.background = '#CAFBC0';
      document.getElementById(id).style.border = '1px solid #30FF00';
    return true;
  } else {
      document.getElementById(id).style.background = '#FBC0C0';
      document.getElementById(id).style.border = '1px solid #FF0000';
    return false;
  }
}

function kontrolaMailu(id) {
    value=document.getElementById(id).value;
		reg_vyraz=/.+@.+\..+/;
		if (reg_vyraz.test(value)) {
        document.getElementById(id).style.background = '#CAFBC0';
        document.getElementById(id).style.border = '1px solid #30FF00';
      return true;
    } else {
        document.getElementById(id).style.background = '#FBC0C0';
        document.getElementById(id).style.border = '1px solid #FF0000';
      return false;
    }
}

function jePrazdny(retezec)
    {
      for(var i = 0; i < retezec.length; i++) {
        var znak = retezec.charAt(i);
        if ((znak != ' ') && (znak != '\n') && (znak != '\t')) return false;
      }
      return true;
    }

function spam() {
            if ( document.getElementById('kontrola') ) { 
              document.getElementById('kontrola').value = '123';
            }
            if ( document.getElementById('kontrola-div') ) { 
              document.getElementById('kontrola-div').style.visibility = 'hidden';
              document.getElementById('kontrola-div').style.display = 'none';
            }
}


// -- KONTROLA CELEHO FORMULARE ------------------------------------------------
function kontrolaFormulare() {
  var kontrola = true;
  if (!kontrolaPrazdna('first_name')) {kontrola=false;}
  if (!kontrolaPrazdna('last_name')) {kontrola=false;}
  if (!kontrolaPrazdna('e_mail')) {kontrola=false;}
  if (!kontrolaPrazdna('add')) {kontrola=false;}
  if (!kontrolaPrazdna('message')) {kontrola=false;}
  if (!kontrola) {alert('Špatně vyplněný formulář! \n\nZkontroluje zdali máte správně vyplněny všechny povinné položky.');}
  return kontrola; 
}


/*puvodni kod - zakomentoval Honza Schenk 

function kontrolaPrazdna(id) {
  if (!jePrazdny(document.getElementById(id).value)) {
      document.getElementById(id).style.background = '#e1ffc1';
      document.getElementById(id).style.border = '1px solid #53a100';
    return true;
  } else {
      document.getElementById(id).style.background = '#ffc1c1';
      document.getElementById(id).style.border = '1px solid #c10000';
    return false;
  }
}

function kontrolaTelefonu(id) {
    value=document.getElementById(id).value;
		reg_vyraz=/^[ 0-9\.\+\/\-]{8,}$/;
		if (reg_vyraz.test(value)) {
        document.getElementById(id).style.background = '#e1ffc1';
        document.getElementById(id).style.border = '1px solid #53a100';
      return true;
    } else {
        document.getElementById(id).style.background = '#ffc1c1';
        document.getElementById(id).style.border = '1px solid #c10000';
      return false;
    }
}

function kontrolaJmena(id) {
    value=document.getElementById(id).value;
		reg_vyraz=/^[a-zA-Z0-9-_ áčďéěíňóřšťúůýžÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]{3,30}$/;
		if (reg_vyraz.test(value)) {
        document.getElementById(id).style.background = '#e1ffc1';
        document.getElementById(id).style.border = '1px solid #53a100';
      return true;
    } else {
        document.getElementById(id).style.background = '#ffc1c1';
        document.getElementById(id).style.border = '1px solid #c10000';
      return false;
    }
}

function kontrolaMailu(id) {
    value=document.getElementById(id).value;
		reg_vyraz=/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/;
		if (reg_vyraz.test(value)) {
        document.getElementById(id).style.background = '#e1ffc1';
        document.getElementById(id).style.border = '1px solid #53a100';
      return true;
    } else {
        document.getElementById(id).style.background = '#ffc1c1';
        document.getElementById(id).style.border = '1px solid #c10000';
      return false;
    }
}

function jePrazdny(retezec)
    {
      for(var i = 0; i < retezec.length; i++) {
        var znak = retezec.charAt(i);
        if ((znak != ' ') && (znak != '\n') && (znak != '\t')) return false;
      }
      return true;
    }


// -- KONTROLA CELEHO FORMULARE ------------------------------------------------
function kontrolaCeleho() {
  var kontrola = true;
  if (document.getElementById('kuryr').checked == true) {
    if (!kontrolaPrazdna('adresa')) {kontrola = false;}
    if (!kontrolaPrazdna('telefon')) {kontrola = false;}
    if (!kontrolaPrazdna('odkdy')) {kontrola = false;}
    if (!kontrolaPrazdna('dokdy')) {kontrola = false;}   
  }
  if (!kontrolaJmena('jmeno')) {kontrola=false;}
  if (!kontrolaMailu('mail')) {kontrola=false;}
  
  if (!kontrola) {alert('Špatně vyplněný formulář! \n\nZkontroluje, zdali máte správně vyplněny všechny povinné položky.');}
  return kontrola; 
}

*/

