function hideGeneralDiv(id){
  var e = document.getElementById(id);
  if(e) e.style.display = 'none';
  return;
}

function showGeneralDiv(id){
  var e = document.getElementById(id);
  if(e) e.style.display = 'block';
  return;
}

function hideRozhovor(){
  hideGeneralDiv('a_hide_rozhovor');
  showGeneralDiv('a_show_rozhovor');
  hideGeneralDiv('div_rozhovor');
  
  return;
}

function showRozhovor(){
  hideGeneralDiv('a_show_rozhovor');
  showGeneralDiv('a_hide_rozhovor');
  showGeneralDiv('div_rozhovor');

  return;
}

function showDetail(id){
  var a_hide = 'href_hideDetail_' + id;
  var a_show = 'href_showDetail_' + id;
  var d_show = 'div_detail_' + id;
  
  showGeneralDiv(a_hide);
  hideGeneralDiv(a_show);
  showGeneralDiv(d_show);

  return;
}

function hideDetail(id){
  var a_hide = 'href_hideDetail_' + id;
  var a_show = 'href_showDetail_' + id;
  var d_show = 'div_detail_' + id;

  hideGeneralDiv(a_hide);
  showGeneralDiv(a_show);
  hideGeneralDiv(d_show);

  return;
}

function kontrola_comment(id){
  var f = document.forms[id];
  var flag = true;

  if(f && f.c_autor && f.c_title && f.c_comment){

    if(f.c_autor.value == ''){
      alert('Vyplňte své jméno.');
      flag = false;
    }

    if(f.c_autor_mail.value != ''){
      if(!kontrola_emailu(f.c_autor_mail, 'E-mail není vyplněn správně.')){
        flag = false;
      }
    }
    
    if(f.c_title.value == ''){
      alert('Vyplňte předmět příspěvku.');
      flag = false;
    }
    if(f.c_comment.value == ''){
      alert('Vyplňte text příspěvku.');
      flag = false;
    }

  }else flag = false;
  
  return flag;
}

/** e-mail control
 *@param email - input element
 *@param alert_msg - alerting message
 */
function kontrola_emailu(email, alert_msg){
  if(window.RegExp){
    maska = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$");
    if(email){
      if (!maska.test(email.value)){
        window.alert(alert_msg);
        email.focus();
        return false;
      }else return true;
    }else return true;
  }else return true;
}

