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('jmeno')) {kontrola=false;}
  if (!kontrolaPrazdna('prijmeni')) {kontrola=false;}
  if (!kontrolaMailu('adresa')) {kontrola=false;}
  if (!kontrolaPrazdna('telefon')) {kontrola=false;}
  if (!kontrola) {window.alert('Špatně vyplněný formulář! \n\nZkontroluje zda-li máte správně vyplněny všechny povinné položky.');}

  return kontrola; 
}
