form_block = false;
help_over = false;

if (self.location != top.location) {
      top.location = self.location;
}

document.cookie = (screen.width < 801) ? 'noright=1' : 'noright=0';

function show_photo(typ, file, hash) {
   var img = document.getElementById('photo_show');
   var bg = "url(/";
   bg += "fotka.php?t="+typ+"&foto=";
   bg += file+'&h='+hash+")";
   img.style.backgroundImage = bg;
}

function isIE() {
   return (document.all && !isOpera()
           && navigator.appName == 'Microsoft Internet Explorer') ?
           true : false;
}

function isOpera() {
   return (window.opera) ? true : false;
}

function getEl(id) {
   return document.getElementById(id);
}
function getElTags(tag) {
   return document.getElementsByTagName(tag);
}

function getSelText() {
   return (document.all) ? document.selection.createRange().text : window.getSelection().toString();
}

function setBlock(id) {
   getEl(id).style.display = 'block';
   return false;
}
function setNone(id) {
   getEl(id).style.display = 'none';
}

function isEmail(email) {
   re_email = /^[-a-zA-Z0-9_.+]+@[-a-zA-Z0-9_.+]+\.[a-zA-Z0-9]{2,6}$/;
   return re_email.test(email);
}

function box_search_focus() {
   if (getEl('search_text').value == 'hledaný text') {
      getEl('search_text').value = '';
   }
}

function add_file(el, id) {
   var count = parseInt(getEl('files_count').value) + 1;
   if (id) {
      var table = getEl(id);
      table.style.marginTop = '5px';
      var new_tr = table.insertRow(-1);
   }
   else {
      var tr = el.parentNode.parentNode;
      var new_tr = tr.parentNode.insertRow(tr.rowIndex + 1);
      new_tr.insertCell(-1);
   }
   var td = new_tr.insertCell(-1);
   td.innerHTML = '<input type="file" class="small" name="file' + count + '" /> (do 350kB)';
   getEl('files_count').value = count;
   if (count > 4) {
      setNone('add_file_link');
   }
   return false;
}

function disable_enter(event) {
   var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
   return (keyCode == 13) ? false : true;
}

function validate_form_search(form) {
   if (form.q.value == 'hledaný text') {
   	form.q.value = '';
   	alert("Není co hledat!");
   	form.q.focus();
   	return false;
   }
   if (form.q.value.length < 3) {
   	alert("Hledám pouze slova dlouhá nejméně 3 znaky!"); 
      form.q.focus(); 
	   return false;
   }
   return true; 
}

function highlight_validate(form) {
   if (form_block) {
      return false;
   }
   if (form.search.value.length < 3) {
      alert("Hledám minimálně tři znaky."); 
      form.search.focus(); 
      return false;
   }
   form_block = true;
   return true; 
}

function form_validate(form, show_tab_id) {
   if (form_block) return false;

   var elems = ['input','textarea','select'];
   var form_error = false;
   var tag_focus = false;
   for(var y = 0; y < elems.length; y++) {
      var tags = form.getElementsByTagName(elems[y]);  
      if (tags.length) {
         for(var i = 0; i < tags.length; i++) {
            var error = false;
            if (tags[i].className.indexOf('frequired_') > -1) {
               if (tags[i].className.indexOf('frequired_text') > -1) {
                  if (tags[i].value.length < 1) error = true;
               }
               if (tags[i].className.indexOf('frequired_email') > -1) {
                  if (!isEmail(tags[i].value)) error = true;
               }
               if (tags[i].className.indexOf('frequired_select') > -1) {
                  if (!parseInt(tags[i].value)) error = true;
               }            
               var id_name = 'form_validate_'+elems[y]+tags[i].name+i;
               if (error) {
                  if (!getEl(id_name) && tags[i].title) {
                     var div = document.createElement('div');
                     div.innerHTML = tags[i].title;
                     div.id = id_name;
                     div.style.color = "red";
                     div.style.fontWeight = 'normal';
                     div.style.fontSize = '10px';
                     tags[i].parentNode.insertBefore(div, tags[i]);
                  }
                  tags[i].style.borderColor = 'red';
                  if (!form_error && !show_tab_id) {
                     tags[i].focus();
                  }
                  else if (!form_error && show_tab_id) {
                     tag_focus = tags[i];
                  }
                  form_error = true;
               }
               else {
                  if (getEl(id_name)) {                  
                     var div = getEl(id_name);
                     div.parentNode.removeChild(div);
                  }
                  tags[i].style.borderColor = '';  
               }
            }
         }
      }
   }
   if (form_error && show_tab_id) show_tab(show_tab_id);
   if (tag_focus) tag_focus.focus();
   if (form_error) return false;
   form_block = true;
   return true;
}

function reg_validate(form) {
   if (form.login.value.length < 1) {
      alert("Musíte zadat přístupové jméno (login)"); 
      form.login.focus(); 
      return false;
   }
   if (form.heslo.value.length < 5) {
      alert("Musíte zadat heslo (min. 5 znaků)"); 
      form.heslo.focus(); 
      return false;
   }
   if (form.heslo.value.length > 4 && form.heslo_znovu.value.length < 5) {
      alert("Musíte zadat heslo ještě jednou pro kontrolu"); 
      form.heslo_znovu.focus(); 
      return false;
   }
   if (form.heslo.value != form.heslo_znovu.value) {
      alert("Hesla se liší, vyplňte je znovu"); 
      form.heslo.value = ""; 
      form.heslo_znovu.value = ""; 
      form.heslo.focus(); 
      return false;
   }
   if (form.email.value.length < 1) {
      alert("Musíte zadat e-mail!"); 
      form.email.focus(); 
      return false;
   }
   if (!isEmail(form.email.value)) {
      alert("Chybně zadaný e-mail"); 
      form.email.focus(); 
      return false;
   }
   if (!form.pravidla.checked) {
      alert("Bez souhlasu s pravidly se nelze do fóra zaregistrovat"); 
      return false;  
   }
   return true;
}

function switch_div(id) {
   if (getEl(id)) {
      display = getEl(id).style.display;
      display = (display == 'none') ? 'block' : 'none';
      getEl(id).style.display = display;
   }
   return false;
} 

function switch_div_help(id) {
   if (!help_over) {
      getEl(id).style.display = 'none';
   }
   return false;
} 

function button(co, type, color) {
   var over = '#c0c5aa';
   var out = '#f5f5e6';
   if (color == 2) {
      over = '#f5f5e6';
      out = '#c0c5aa'; //'#b0b59a'; //c0c5aa';
   }
   if (type == 1) {
      co.style.background = over; 
      //co.style.textDecoration = 'underline'; 
      co.style.cursor = 'pointer';
   }
   else {
      co.style.background = out; 
      //co.style.textDecoration = 'none';
   } 
}

function count_chars(element, max_limit) {
   var delka = max_limit - element.value.length;
   var znaku = ' znaků';
   if (delka > 1 && delka < 5) znaku = ' znaky';
   if (delka == 1) znaku = ' znak';
   if (delka >= 0) {
      delka = 'zbývá ' + delka + znaku;
      getEl('chars_count').innerHTML = delka;
   }
}

function test_chars_limit(element, max_limit) {
   if (element.value.length > max_limit) {
      element.value = element.value.substr(0, max_limit);
      alert('Můžete zadat max. ' + max_limit + ' znaků');
      return false;
   }
   return true;
}

function bgcol(co, barva) {
   var tr = co.parentNode;
   for (i = 0; i < tr.cells.length; i++) {
      tr.cells[i].style.backgroundColor = barva
   }
}

function confirm_delete() {
   return confirm('POZOR!\nSkutečně nenávratně smazat?');
}
function confirm_trash() {
   return confirm('POZOR!\nSkutečně přesunout do koše?');
}
function confirm_clock() {
   return confirm('Skutečně nastavit dnešní datum?');
}

function validate_user_info(form) {
   if (form.heslo && form.heslo.value.length < 1) {
      alert("Pro změnu údajů musíte zadat současné heslo"); 
      form.heslo.focus(); 
      return false;
   }
   if (form.heslo_new_1.value.length > 1 && form.heslo_new_2.value.length < 1) {
      alert("Musíte zadat heslo ještě jednou pro kontrolu"); 
      form.heslo_new_2.focus(); 
      return false;
   }
   if (form.heslo_new_2.value != form.heslo_new_1.value) {
      alert("Hesla se liší, vyplňte je znovu"); 
      form.heslo_new_1.value = ""; 
      form.heslo_new_2.value = ""; 
      form.heslo_new_1.focus(); 
      return false;
   }
   return true;
}

function strchar(code) {
   return String.fromCharCode(code);
}

function convert_azbuka() {
   var text = getEl('azb_src').value;
   var l = {'jo': 1105, 'ch': 1093, 'šč': 1097 ,'\\+\\+': 1066, '\\*\\*': 1068, 'e\\+': 1101, 'ju': 1102, 'ja': 1103,
        'ě\\+': 1123, 'Ě\\+': 1122, 'g\\+': 1169, 'G\\+': 1168, 'ě': 1108, 'Ě': 1028, 
        'a': 1072, 'b': 1073, 'c': 1094, 'č': 1095, 'd': 1076, 'e': 1077, 'f': 1092, 'g': 1075, 'h': 1075, 'i': 1080,
        'j': 1081, 'k': 1082, 'l': 1083, 'm': 1084, 'n': 1085, 'o': 1086, 'p': 1087, 'r': 1088, 's': 1089,
        'š': 1096, 't': 1090, 'u': 1091, 'v': 1074, 'y': 1099, 'z': 1079, 'ž': 1078, 'JO': 1025, 'CH': 1061, 
        'ŠČ': 1065, 'E\\+': 1069, 'JU': 1070, 'JA': 1071, 'A': 1040, 'B': 1041, 'C': 1062, 'Č': 1063, 'D': 1044,
        'E': 1045, 'F': 1060, 'G': 1043, 'H': 1043, 'I': 1048, 'J': 1049, 'K': 1050, 'L': 1051, 'M': 1052, 'N': 1053, 'O': 1054,
        'P': 1055, 'R': 1056, 'S': 1057, 'Š': 1064, 'T': 1058, 'U': 1059, 'V': 1042, 'Y': 1067, 'Z': 1047, 'Ž': 1046,
        '\\+': 1098, '\\*': 1100}
   for (key in l) {
      regexp = new RegExp(key, 'g');
      text = text.replace(regexp, strchar(l[key]));   
   }  
   getEl('azb_dest').value = text;
}

function azbuka_window(fl) {
   var fl = (fl) ? '' : ' float-right';
   var div = '<div class="darkgreen small'+fl+'">';
      div += '<input title="Klikni pro zobrazení pomůcky pro azbuku" onclick="switch_div(\'azbuka\')" style="_background: #d8d8c2;" class="valign-middle noborder" type="checkbox" /> <span class="bold">Pomůcka - azbuka &nbsp; &nbsp;</span>';
      div += '<div style="display: none;" id="azbuka" class="azbuka">';
         div += 'latinka: <span class="help-button" onmouseover="this.style.cursor=\'help\';setBlock(\'azbuka_help\');" onmouseout="setNone(\'azbuka_help\');">&nbsp;?&nbsp;</span><br />';
         div += '<div id="azbuka_help" class="help-div">';
            div += '<strong>Některé&nbsp;speciální&nbsp;znaky<br /> napíšete takto:</strong><br />';
            div += '* = &#1100; <br />** = &#1068;<br />';
            div += '+ = &#1098; <br />++ = &#1066;<br />';
            div += 'e+ = &#1101; <br />E+ = &#1069;<br />';
            div += 'ě = &#1108; <br />Ě = &#1028;<br />';
            div += 'ě+ = &#1123; <br />Ě+ = &#1122;<br />';
            div += 'g+ = &#1169; <br />G+ = &#1168;';
         div += '</div><input onkeypress="return disable_enter(event)" id="azb_src" onchange="convert_azbuka();" onkeyup="convert_azbuka()" type="text" style="width: 125px;" /><br />';
         div += 'azbuka:<br />';
         div += '<input onkeypress="return disable_enter(event)" id="azb_dest" class="dis" type="text" style="width: 125px;" /><br />';
         div += '<div class="bold align-center"><input title="Zkopíruje azbuku do hlavního okna" class="button2" onclick="copy_azbuka(); return false;" onmouseover="button(this,1,2);" onmouseout="button(this,2,2);" type="button" value="&lt; Vložit" /></div>';
      div += '</div></div>';
   document.write(div);
}

function show_help(help_id, div_width, show_br) {
   switch (help_id) {
      case 'nastav_ip_help':
         help = 'Pro zvýšení bezpečnosti je možné kontrolovat, zda po přihlášení přistupujete stále ze stejné IP adresy. U některých typů připojení se však IP adresa může v čase měnit, proto je tato volba ve výchozím nastavení vypnuta.';
      break;
      case 'nastav_ua_help':
         help = 'Pro zvýšení bezpečnosti je možné kontrolovat, zda po přihlášení přistupujete stále ze stejného prohlížeče. Tento údaj se ale za určitých okolností může měnit, proto je tato volba ve výchozím nastavení vypnuta.';
      break;
      case 'nastav_dhtml_help':
         help = 'Vizuální editaci (kdy přesně vidíte např. tučné písmo jako tučné apod.) je možné používat pouze v prohlížečích <strong>Internet Explorer verze 5.5 a vyšší</strong>, prohlížečích <strong>Mozilla, Firefox</strong> a prohlížeči <strong>Opera verze 9 a vyšší</strong>.';
         help += '<br />Pokud by se vyskytly problémy, je možné ji zde vypnout.<br />';
      break;
      case 'nastav_chat_help':
        help = 'Pokud nechcete být obtěžováni online vzkazy ostatních uživatelů, můžete si chatovací okno vypnout. Ostatní uživatelé vás potom neuvidí v seznamu "Pro" při zasílání vzkazu.';
      break;
      case 'nastav_smiles_help':
        help = 'Týká se to smajlíků, hvězd, fotek uživatelů.';
      break;
      case 'history_log':
         help = 'Sem můžete napsat nějakou poznámku k úpravám, které jste provedli - poznámka se zobrazí v tabulce historie změn této položky.';
      break;
      case 'online_help':
         help = '<strong>Barvičky:</strong><br />';
         help += '<img src="/gfx/nic.gif" class="bg-green img-online" /> - byl(a) aktivní v posledních 5 minutách<br />';
         help += '<img src="/gfx/nic.gif" class="bg-yellow img-online" /> - byl(a) aktivní před 5-15 minutami<br />';
         help += '<img src="/gfx/nic.gif" class="bg-orange img-online" /> - byl(a) aktivní před 15-30 minutami<br />';
         help += '<img src="/gfx/nic.gif" class="bg-red img-online" /> - byl(a) aktivní před více než 30 minutami<br />';
         help += '<br /><strong>Jména:</strong><br />';
         help += '<strong style="color: #001088">jméno</strong> - uživatel<br />';
         help += '<strong class="green">jméno</strong> - uživatel ve fóru méně než 2 měsíce<br />';
         help += '<strong class="red">jméno</strong> - moderátor nebo administrátor';
      break;
      case 'tema_help':
         help ='Nezakládejte témata, která již ve fóru existují. Duplicitní témata budou mazána.';
      break;
      case 'help_rewrite':
         help = '"Pěkná" adresa stránky, která se zobrazí v adresním řádku prohlížeče. Např.: www.fronta.cz/vychodni-fronta <br />Kvůli vyhledavačům je vhodné vytvořit ji klíčovými slovy v prvním pádu. Zadaný text se automaticky převede do patřičného tvaru.<br /><strong>Ve většině případů je doporučeno nezadávat nic - adresa se pak vytvoří automaticky z názvu.</strong>';      
      break;
      case 'help_meta_desc':
         help = 'Obsah tagu Meta Description - pro vyhledavače je vhodné sem doplnit klíčová slova v prvním pádu.';
      break;
      case 'help_meta_keys':
        help = 'Obsah tagu Meta Keywords - pro vyhledavače je vhodné sem doplnit klíčová slova v prvním pádu.';
      break;
      case 'user_pic_help':
         help = 'Obrázek musí být ve formátu <strong>JPEG, GIF</strong> nebo <strong>PNG</strong>.<br />';
         help += 'Aby byl přenesen na server musí mít <strong>méně než 40kB</strong>.<br />';
         help += 'Obrázek bude automaticky upraven na 150 pixelů na šířku, bez ohledu na to jestli je větší nebo menší.<br />';
         help += 'Ideální je si obrázek dopředu připravit v přesné velikosti <strong>150x200 pixelů</strong> - jeho rozměry pak nebudou nijak upravovány.';
      break;
      case 'burza_pic_help':
         help = 'Obrázek musí být ve formátu <strong>JPEG, GIF</strong> nebo <strong>PNG</strong>.<br />';
         help += 'Aby byl přenesen na server musí mít <strong>méně než 200kB</strong>.<br />';
         //help += 'Obrázek bude automaticky upraven na max. 170 pixelů na šířku.';
      break;
      case 'map_small_help':
         help = 'Náhled mapy musí být ve formátu <strong>JPEG, GIF</strong> nebo <strong>PNG</strong>.<br />';
         help += 'Aby byl přenesen na server musí mít <strong>méně než 40kB</strong>.<br />';
         help += 'Obrázek bude automaticky upraven na 150 pixelů na šířku, bez ohledu na to jestli je větší nebo menší.<br />';
         help += 'Ideální je si obrázek dopředu připravit v přesné šířce <strong>150 pixelů</strong> - jeho rozměry pak nebudou nijak upravovány.';
      break;
      case 'map_big_help':
         help = 'Velká mapa musí být ve formátu <strong>JPEG, GIF</strong> nebo <strong>PNG</strong>.<br />';
         help += 'Aby byla přenesena na server musí mít <strong>méně než 2MB</strong>.<br />';
         help += 'Rozměry obrázku nebudou nijak upravovány.<br />';
      break;
      case 'help_photo':
         help = 'Fotka musí být ve formátu <strong>JPEG, GIF</strong> nebo <strong>PNG</strong>.<br />';
         help += 'Aby byla přenesena na server musí mít <strong>méně než 300kB</strong>.<br />';
         help += 'Fotku si již dopředu připravte v grafickém editoru v ideálních rozměrech, ostrosti apod. <br />Úpravy na webu používejte jen výjimečně. ';
         help += 'Při příliš velkých rozměrech zdrojové fotografie se příp. úpravy nemusí podařit vzhledem k paměťovým a časovým omezením skriptu na straně serveru.<br />';
      break;
      case 'tema_filter_help':
         help = 'Hledat můžete více slov naráz, přesné fráze uzavřete do uvozovek. <br />Povoleny jsou standardní operátory <strong>AND, OR, NOT,</strong> je možné používat závorky.<br />Hledají se pouze slova, která mají <strong>alespoň 3 znaky.</strong><br />';
         help += '<br /><strong>Příklady:</strong><br />';
         help += '<em>panther</em><br />';
         help += 'najde příspěvky obsahující slovo "panther"<br />';
         help += '<em>"střední tank"</em> (v uvozovkách)<br />';
         help += '- najde příspěvky obsahující přesnou frázi "střední tank"<br />';
         help += '<em>panther AND tiger</em><br />';
         help += 'najde příspěvky obsahující slovo "panther" a zároveň obsahující slovo "tiger"<br />';
         help += '<em>panther NOT (tiger OR sherman)</em><br />';
         help += 'najde příspěvky obsahující slovo "panther" a neobsahující slovo "tiger" nebo "sherman"';
      break;
      case 'autor_filter_help':
         help = 'Můžete zadat více jmen naráz, nebo jenom jejich části.<br />Např.: hartm egli alger';
      break;
      case 'colors_help':
         help = 'Barvy můžete zadávat dvěma způsoby:<br /><ul>';
         help += '<li><strong>definovanými názvy</strong> (red, green apod.)  - jejich přehled je <a target="_blank" href="http://www.w3schools.com/html/html_colornames.asp">např. zde</a></li><li>nebo přímo kódem ve tvaru <strong>#RRGGBB</strong> - můžete použít jednoduchý <a href="http://wellstyled.com/tools/colorscheme/index.html" target="_blank">color mixer</a></li></ul>';
         help += 'Zaškrtnutím políčka dole a uložením se vrátíte k výchozímu nastavení.</div>';   
      break;
      case 'help_clanek_datum':
         help = 'Pokud zadáte datum v budoucnosti, článek se na webu objeví až daný den, tímto způsobem je možné naplánovat zveřejňování článků.';
      break;
      case 'help_doc_datum':
         help = 'Pokud znáte pouze rok a měsíc tak zadejte 00.XX.YYYY';
      break;
      case 'help_right_col':
         help = 'U článku s např. nějakými širokými tabulkami je možné pravý sloupec vypnout. Uživatelům s rozlišením 800x600 se nezobrazuje automaticky. Ve vyšším rozlišení je naopak lepší, když je text díky zobrazenému pravému sloupci užší.';
      break;
      case 'help_edit':
         help = '<h3 class="title">Povolené formátování ve fóru</h3>';
         help += '<ul style="line-height: 150%"><li>&lt;b&gt;tučné písmo&lt;/b&gt; se zobrazí: <strong>tučné písmo</strong></li>';
         help += '<li>&lt;i&gt;skloněné písmo&lt;/i&gt; se zobrazí: <em>skloněné písmo</em></li>';
         help += '<li>&lt;u&gt;podtržené písmo&lt;/u&gt; se zobrazí: <u>podtržené písmo</u></li>';
         help += '<li>&lt;u&gt;&lt;b&gt;&lt;i&gt;tučné skloněné podtržené&lt;/i&gt;&lt;/b&gt;&lt;/u&gt; se zobrazí: <strong><em><u>tučné skloněné podtržené</u></em></strong></li>';
         help += '<li>text&lt;sub&gt;dolní index&lt;/sub&gt; se zobrazí: text<sub style="font-size: 8px">dolní index</sub></li>';
         help += '<li>text&lt;sup&gt;horní index&lt;/sup&gt; se zobrazí: text<sup style="font-size: 8px">horní index</sup></li>';
         help += '<li>&lt;h3&gt;nadpis&lt;/h3&gt; se zobrazí: <h3 style="display: inline;">nadpis</h3><br /></li>';
         help += '<li>:-) se zobrazí: <img src="/gfx/smile1.gif" alt="" /> :-( se zobrazí: <img src="/gfx/smile2.gif" alt="" /> ';
         help += ':-)) se zobrazí: <img src="/gfx/smile3.gif" alt="" /><br />8-) se zobrazí: <img src="/gfx/smile4.gif" alt="" /> ';
         help += ';-( se zobrazí: <img src="/gfx/smile5.gif" alt="" /></li>';
         help += '<li>&lt;hr&gt; se zobrazí: <hr /></li>';
         help += '<li>&lt;citace&gt;citace&lt;/citace&gt; se zobrazí: <div class="forum-citace">citace</div></li>';
         help += '<li>&lt;dokument&gt;dokument&lt;/dokument&gt; se zobrazí: <div class="forum-doc">dokument</div></li>';   
         help += '<li>to co začíná na <strong>http://</strong> se automaticky zobrazí jako odkaz</li>';
         help += '<li>před odkaz na obrázek napište <strong>image:</strong> - např. image:http://www.neco.cz/neco.jpg</li>';
         help += '<li>před odkaz na youtube video napište <strong>youtube:</strong> - např. youtube:http://youtube.com/watch?v=QVLdfgdfg</li>';
         help += '</ul>';
      break;
      case 'help_tables':
         help = '<div class="article-text">';
         help += '<table class="invisible pad3"><tr><td style="border: 0">';         
         help += '<table class="size11 pad3 type-1"><tr class="header"><td colspan="2">Typ 1</td></tr><tr class="even"><td>Lichý</td><td>řádek</td></tr><tr class="odd"><td>Sudý</td><td>řádek</td></tr></table>';
         help += '</td><td style="border: 0">';         
         help += '<table class="size11 pad3 type-2"><tr class="header"><td colspan="2">Typ 2</td></tr><tr class="odd"><td>Lichý</td><td>řádek</td></tr><tr class="odd"><td>Sudý</td><td>řádek</td></tr></table>';
         help += '</td></tr><tr><td style="border: 0">';         
         help += '<table class="size11 pad3 type-3"><tr class="header"><td colspan="2">Typ 3</td></tr><tr class="even"><td>Lichý</td><td>řádek</td></tr><tr class="even"><td>Sudý</td><td>řádek</td></tr></table>';
         help += '</td><td style="border: 0">';         
         help += '<table class="size11 pad3 type-4"><tr class="even"><td colspan="2">Typ 4</td></tr><tr class="even"><td>Lichý</td><td>řádek</td></tr><tr class="even"><td>Sudý</td><td>řádek</td></tr></table>';
         help += '</td></tr><tr><td style="border: 0" class="valign-top">';         
         help += '<table class="size11 pad3 type-5"><tr class="odd"><td colspan="2">Typ 5</td></tr><tr class="odd"><td>Lichý</td><td>řádek</td></tr><tr class="odd"><td>Sudý</td><td>řádek</td></tr></table>';
         help += '</td><td style="border: 0">&nbsp;</td></tr></table><strong>Neviditelná:</strong><br />Je totéž, co Typ 5, ale orámování je vidět pouze v editoru, na webu vidět nebude - lze ji tak využít pro nějaké složitější formátování';         
         help += '<br /><strong>Silnější rámeček:</strong><br />Vnější rám tabulky bude silnější linkou';
         help += '<br /><strong>Buňky:</strong><br />Okraj mezi rámečkem a obsahem buňky v pixelech';
         help += '</div>';
      break;
      case 'pics_box_help':
         help = '<strong>Uložení nového obrázku</strong><br />Přidávat můžete obrázky ve formátu <strong>JPEG, GIF nebo PNG</strong> menší než 100kB. Obrázky je dobré si dopředu připravit ve velikosti <strong>max. 550px na šířku</strong> (do textu by neměly být dávány širší obrázky, aby nebylo nutné stránku posunovat do stran). Obrázky menší než 550px na šířku se uloží na server bez jakýchkoli úprav. Obrázky širší než 550px se automaticky zmenší na tuto velikost.';
         help += '<br /><br /><strong>Vložení obrázku do textu</strong><br /><strong>1)</strong> nejprve zvolte <strong>zarovnání,</strong> zda bude obrázek obtékán textem zleva či zprava nebo zda nebude obtékán vůbec a zaškrtněte, zda pod obrázkem bude popisek.<br />';
         help += '<strong>2)</strong> poté umístěte kurzor do textu na místo, kam chcete obrázek umístit<br />';
         help += '<strong>3)</strong> poté klikněte na volbu <strong>vložit do textu</strong> u daného obrázku';
         help += '<br /><br />Kliknutím na název obrázku se můžete na obrázek v novém okně podívat.<br />Při smazání obrázku nezapomeňte obrázek odstranit i z textu.'
      break;
      case 'help_editor':
         help = '<img src="/gfx/help_edit.gif" alt="" />';
      break;
      case 'help_hodn':
         help = 'Zrušením hodnocení dojde i ke smazání všech známek, co jste udělil(a) nebo vám byly uděleny.';
      break;
      case 'files_box_help':
         help = 'K článku si můžete uložit nějaké další soubory, na které se třeba v textu článku chcete odkazovat (třeba PDF, DOC apod.). Nebo může jít o velké obrázky, na které se chcete odkazovat z menších náhledů. Max. povolená velikost souboru je 1MB.';
         help += '<br /><br />Kliknutím na <strong>vložit odkaz do textu</strong> vytvoříte v editoru z označeného textu odkaz na daný soubor.';
         help += '<br /><br />Zašrtnutím <strong>použít lightbox</strong> zajístíte, že obrázek s otevře na stejné stránce v rámečku.';
      break;
   }
   help_div = '<span title="Nápověda" style="font-style: normal;" class="help-button" onmouseover="this.style.cursor=\'pointer\'" onclick="hide_all_help(); this.style.cursor=\'help\'; help_over = true; switch_div(\''+help_id+'\');" onmouseout="help_over = false; setTimeout(\'switch_div_help(\\\''+help_id+'\\\')\', 500);">&nbsp;?&nbsp;</span>';
   help_div += (show_br) ? '<br />' : ' ';
   help_div += '<div onmouseout="help_over = false; setTimeout(\'switch_div_help(\\\''+help_id+'\\\')\', 500);" onmouseover="this.style.cursor=\'help\'; help_over = true;" class="help-div2" style="color: black; font-style: normal; width: '+div_width+'px" id="'+help_id+'">'
   help_div += help+'</div>';   
   document.write(help_div);
}

function hide_all_help() {
   help_divs = getElTags('div');
   for (i = 0; i < help_divs.length; i++) {
      if (help_divs[i].className == 'help-div2') {
         help_divs[i].style.display = 'none';
      }
   }
}

function time_counter() {
   time_limit--;
   if (time_limit < 0) return;
   minut = parseInt(time_limit/60);
   sekund = parseInt(time_limit%60);
   if (sekund < 10) sekund = "0" + sekund;
   window.defaultStatus = "Na psaní příspěvku máte: " + minut + ":" + sekund + " (po " +time_max_limit + " minutách nečinnosti budete automaticky odhlášeni) " ;
   setTimeout("time_counter()", 1000);
   if (time_limit == 0) alert("Byl překročen časový limit nečinnosti\nnyní budete automaticky odhlášen(a).");
}

function color_set(id, barva) {
   getEl(id).style.background = barva;
}


menu_over = false;
menu_timeout = 0;
menu_ids = 0;

function menu_on(id) {
   menu_off_all(id);
   menu_over = true;
   getEl(id).style.display = 'block';
}

function menu_off_all(not_this_id) {
   if (!menu_over) {
      for(i = 1; i <= menu_ids; i++) {
         if (not_this_id != 'sub'+i) {
            getEl('sub'+i).style.display = 'none';         
         }
      } 
   }
   clearTimeout(menu_timeout);         
}
function set_menu_over() {
   clearTimeout(menu_timeout);
   menu_over = true;
}

function set_menu_out() {
   if (menu_over) {
      menu_over = false;
      menu_timeout = setTimeout('menu_off_all()', 500);
   }
}

function menu_start() {
   for (i = 1; i <= 3; i++) {
      if (getEl('main'+i)) {
         menu_ids++;
         getEl('main'+i).onmouseover = new Function ('menu_on("sub'+i+'");'); 
         getEl('main'+i).onmouseout = set_menu_out;
   
         ul_element = getEl('sub'+i);
         var a_elements = ul_element.getElementsByTagName("A");
         for (j = 0; j < a_elements.length; j++) {
   	    	a_elements[j].onmouseover = set_menu_over;
   		   a_elements[j].onmouseout = set_menu_out;
         }
      }
   }
}

function rpc(id_rpc, path, warning, notime) {
   cont = true;
   if (warning) {
      cont = confirm(warning);
   }
   if (cont) {   
      path = path.replace(/&amp;/gi, "&");
      var head_el = getElTags('head')[0];
   	if (getEl(id_rpc)) head_el.removeChild(getEl(id_rpc));
   	
   	script_el = document.createElement('script');
   	script_el.id = id_rpc;
   	date = new Date();
      script_el.src = (notime) ? path : path+'&'+date.getTime();           
   	head_el.appendChild(script_el);  	
   }
 	return false;
}

function rpc_show(id, text) {
   while(getEl(id).hasChildNodes()) getEl(id).removeChild(getEl(id).childNodes[0]);
   getEl(id).innerHTML = text;
   return false;   
}

function DateSelector(form_input, id_name){

   this.mesice = new Array('Leden','Únor','Březen','Duben','Květen','Červen','Červenec','Srpen','Září','Říjen','Listopad','Prosinec');
   this.dny = new Array('Po','Út','St','Čt','Pá','So','Ne');

  this.id_name = id_name;
  this.form_input = getEl(form_input);
  this.mesic = 0;
  this.rok = 0;

  date_sel_pic = document.createElement('img');
  date_sel_pic.src = '/gfx/date_selector.gif';
  date_sel_pic.className = "date-sel-image";
  date_sel_pic.style.verticalAlign = 'text-bottom';
  date_sel_pic.style.margin = '0px 0px 0px 5px';
  date_sel_pic.alt = 'výběr data z kalendáře';
  date_sel_pic.title = 'výběr data z kalendáře';
  date_sel_pic.date_selector = this.id_name;
  date_sel_pic.onclick = this.popupDateSelector;

  this.form_input.parentNode.appendChild(date_sel_pic);  
   
  var dateSelectorDiv = document.createElement('div');
  dateSelectorDiv.className = "date-sel-div";
  dateSelectorDiv.style.display = 'none';
  dateSelectorDiv.id = "date_sel_div"+this.id_name;
  
  obj = getElTags('body')[0];
  obj.insertBefore(dateSelectorDiv, obj.firstChild);
 
  this.date_selector_div = getEl("date_sel_div"+this.id_name);

  this.updateTable();  
}

DateSelector.prototype.popupDateSelector = function() {
  obj = eval(this.date_selector);
  parent_obj = getElTags('body')[0]; 
  obj.date_selector_div.style.zIndex = '100';
  obj.date_selector_div.style.left = parseInt(get_x_offset(this)-get_x_offset(parent_obj)+21)+'px';
  obj.date_selector_div.style.top = parseInt(get_y_offset(this)+5)+'px';

  obj.date_selector_div.style.display = (obj.date_selector_div.style.display == 'block') ? 'none' : 'block'; 
}

DateSelector.prototype.insertIntoForm = function(den){
  this.form_input.value = den + '.' + (parseInt(this.mesic)+1) + '.' + this.rok;
  this.date_selector_div.style.display = 'none';
}

DateSelector.prototype.updateTable = function(rok, mesic){

   if (typeof(rok) == 'undefined' || typeof(mesic) == 'undefined') {
      date_regexp = /^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/;
      if(this.form_input.value != '' && date_regexp.test(this.form_input.value)) {
         parts = date_regexp.exec(this.form_input.value);
         rok = parts[3];
         mesic = parts[2]-1;
      }
      else { 
         new_date = new Date();
         rok = new_date.getFullYear();
         mesic = new_date.getMonth();
      }
   } 

   this.mesic = mesic;
   this.rok = rok;
   
   output = '';  
   close_title = 'zavřít';
   output += '<a title="'+close_title+'" class="close-button" onmouseover="this.className=\'close-button-over\'" onmouseout="this.className=\'close-button\'" onclick="'+this.id_name+'.date_selector_div.style.display = \'none\';">×</a>';

   output += '<span class="topselect">';
   output += '<select style="display: inline;" size="1" onchange="'+this.id_name+'.updateTable('+this.rok+',parseInt(this.value))">';
   for(i = 0; i < this.mesice.length; i++) {
     output += '<option value="'+i+'"';
     if (i == this.mesic) output += ' selected="selected"';
     output += '>'+this.mesice[i]+'</option>';
   }
   output += '</select>';
   output += '<span onmouseover="this.className=\'date-year-over\'" onmouseout="this.className=\'date-year\'" class="date-year" onclick="'+this.id_name+'.updateTable('+(this.rok-1)+','+this.mesic+')">&lt;</span><span class="year-text">&nbsp;'+this.rok+'&nbsp;</span><span class="date-year" onmouseover="this.className=\'date-year-over\'" onmouseout="this.className=\'date-year\'"  onclick="'+this.id_name+'.updateTable('+(parseInt(this.rok)+1)+','+this.mesic+')">&gt;</span>';
   output += '</span>';

   output += '<table><tr>';
   
   for(i = 0; i < this.dny.length; i++){
   	output += '<th>' + this.dny[i] + '</th>';
   }
   output += '</tr>';
   
   den_offset = new Date(rok, mesic, 1).getDay();
   if (den_offset == 0) den_offset = 7; 
   den_outset = new Date(rok, mesic+1, 0).getDate();
      
   den_tyden = 0;	
   for(i = 1; i < den_offset; i++){
   	output += '<td onmouseover="this.style.cursor=\'default\'">&nbsp;</td>';
   	den_tyden++;
   }
   
   for(i = 1; i <= den_outset; i++){
      if (den_tyden == 7) { 
   		   output += '</tr><tr>';
   			den_tyden = 0;
   	}
   	den_tyden++;
      output += '<td onmouseover="this.className=\'date-over\'" onmouseout="this.className=\'\'" onclick="this.className=\'\';'+this.id_name+'.insertIntoForm('+i+')">'+i+'</td>';
   }
   
   for(i = den_tyden; i < 7; i++) {
      output += '<td onmouseover="this.style.cursor=\'default\'">&nbsp;</td>';
   }
   output += '</tr></table>';

   this.date_selector_div.innerHTML = output;  
}

function get_x_offset(obj){
  var x = 0;
  if(obj.offsetParent){
    while(obj.offsetParent){
      x += obj.offsetLeft;
      obj=obj.offsetParent;
    }
  }
  else if(obj.x) x += obj.x;
  return parseInt(x);
}

function get_y_offset(obj){
  var y =0;
  if(obj.offsetParent){
    while(obj.offsetParent){
      y +=obj.offsetTop
      obj=obj.offsetParent;
    }
  }
 else if(obj.y) y += obj.y;
  return parseInt(y);
}

function gallery(obrazek, width, height) {
	var win = window.open("","popis","width="+(width+20)+",height="+(height+20)+",menubar=no,toolbar=no");
	win.document.write("<html><head><title>Náhled obrázku</title></head><body style='margin: 0; margin-left: 5px; margin-top: 5px;padding: 0;'>");
	win.document.write("<div><a title='Zavřít okno' href='javascript:window.close()'><img src='"+obrazek+"' border='0' alt='Zavřít okno' /></a></div>");
   win.document.write("</body></html>");
	win.document.close();
   return (typeof(win) == "object") ? true : false;
}

function anchorEditAlert() {
   var anchors = getElTags('A');
   for(i = 0; i < anchors.length; i++) {
      if (anchors[i].className.indexOf('nowarning') < 0 && anchors[i].href != '' && typeof(anchors[i].onclick) != 'function' && anchors[i].href.indexOf('#') < 0 && anchors[i].href.indexOf('javascript:') < 0) {
         anchors[i].onclick = editWarning;
      }
   }
}
function editWarning() {
   return confirm('Skutečně opustit editační stránku?\n\nNezapomeňte úpravy uložit, jinak zmizí.');
}

function go_list_pos(type) {
   if (!type) type = 'list';
  show_obj_pos('go_'+type, 'a_go_'+type, 20, 15);
  if (getEl('go_'+type).style.display == 'block') {
     getEl('go-'+type+'-input').focus();
  }
   return false;
}

function show_go_list(hidden_inputs) {
   document.write('<a href="#" title="klikni a zadej přímo číslo listu" id="a_go_list" onclick="return go_list_pos()">Jdi na list</a> | ');
   document.write('<div id="go_list" class="go-list align-center">');
   document.write('<form onsubmit="setNone(\'go_list\');if (this.list.value == \'\') this.list.value = 1;this.list.value = parseInt(this.list.value) - 1;">Jdi na list: <input id="go-list-input" type="text" size="3" class="small" name="list" />');
   document.write(hidden_inputs);
   document.write(' <input type="submit" value=" Jdi " onmouseover="button(this,1);" onmouseout="button(this,2);" class="button3" /></form></div>'); 
}

function show_go_prisp(url) {
   document.write('<a href="#" title="klikni a zadej číslo příspěvku" id="a_go_prisp" onclick="return go_list_pos(\'prisp\')">Jdi na příspěvek</a> | ');
   document.write('<div id="go_prisp" class="go-list align-center">');
   document.write('<form method="post" action="'+url+'" onsubmit="setNone(\'go_prisp\');">Jdi na č.: <input id="go-prisp-input" type="text" size="3" class="small" name="id_prisp" />');
   document.write(' <input type="submit" value=" Jdi " onmouseover="button(this,1);" onmouseout="button(this,2);" class="button3" /></form></div>'); 
}

function show_search_box() {
   document.write('<div id="forum_search_box" class="forum-search-box align-center">');
   document.write('<form action="/forum.php" onsubmit="if (getEl(\'forum-search-input\').value == \'\') {alert(\'Není co hledat!\'); getEl(\'forum-search-input\').focus();return false;}setNone(\'forum_search_box\');"><input id="forum-search-input" type="text" size="20" class="small" name="search" />');
   document.write('<input type="hidden" name="sekce" value="forum_search" />');
   document.write(' <input type="submit" value=" Hledej " onmouseover="button(this,1);" onmouseout="button(this,2);" class="button3" /></form><img alt="" class="valign-middle" src="/gfx/lupa.gif" /> <a class="small bold" href="/forum.php?sekce=forum_search">Rozšířené hledání</a></div>'); 
}

function show_search() {
  show_obj_pos('forum_search_box', 'a_search_box', 20, 21);
  if (getEl('forum_search_box').style.display == 'block') {
     getEl('forum-search-input').focus();
  }
  return false;
}

function highlight_switch() {
   spans = getElTags('span');
   for(i = 0; i < spans.length; i++) {
      if (spans[i].className == 'search-highlight')  {
         spans[i].className = 'search-highlight-off';
      }
      else if (spans[i].className == 'search-highlight-off')  {
         spans[i].className = 'search-highlight';
      }
   }
   getEl('highlight_switch').innerHTML = (getEl('highlight_switch').innerHTML == 'Zapnout zvýraznění') ? 'Vypnout zvýraznění' : 'Zapnout zvýraznění';
   return false;
}

function user_info(id, id_prisp) {
   document.write(' <a title="Rychlé info o uživateli" id="a_user_info_'+id_prisp+'" href="#" onclick="if (getEl(\'user_info_'+id_prisp+'\').style.display == \'none\') {show_obj_pos(\'user_info_'+id_prisp+'\', \'a_user_info_'+id_prisp+'\', 30, 19);rpc(\'rpc_user_info\',\'/rpc_user_info.php?id='+id+'&id_prisp='+id_prisp+'\', \'\', true);} else {setNone(\'user_info_'+id_prisp+'\');} return false;"><img src="/gfx/button_info.gif" width="13" height="13" alt="Rychlé info o uživateli" /></a> ');
   div = document.createElement('div');
   div.className = 'author-info rpc-user-info';
   div.style.display = 'none';
   div.style.position = 'absolute';
   div.style.width = '500px';
   div.id = 'user_info_'+id_prisp;
   text = 'Načítám...';
   text = document.createTextNode(text);
   div.appendChild(text);
   obj = getElTags('body')[0];
   obj.insertBefore(div, obj.firstChild);
}

function poradna(id) {
   document.write(' <a title="Zobrazit odpověď" id="a_poradna_'+id+'" href="#" onclick="if (getEl(\'poradna_'+id+'\').style.display == \'none\') {show_obj_pos(\'poradna_'+id+'\', \'a_poradna_'+id+'\', 0, 19);rpc(\'rpc_poradna\',\'/rpc_poradna.php?id='+id+'\', \'\', true);} else {setNone(\'poradna_'+id+'\');} return false;"><img src="/gfx/button_info.gif" width="13" height="13" alt="Zobrazit odpověď" /></a> ');
   div = document.createElement('div');
   div.className = 'author-info rpc-user-info';
   div.style.display = 'none';
   div.style.position = 'absolute';
   div.style.width = '500px';
   div.style.background = 'white';
   div.id = 'poradna_'+id;
   text = 'Načítám...';
   text = document.createTextNode(text);
   div.appendChild(text);
   obj = getElTags('body')[0];
   obj.insertBefore(div, obj.firstChild);
}

function show_obj_pos(id1, id2, offset_x, offset_y) {
  obj = getEl(id1);
  el_a = getEl(id2);
  parent_obj = getElTags('body')[0]; 
  obj.style.zIndex = '100';
  obj.style.left = parseInt(get_x_offset(el_a)-get_x_offset(parent_obj)-offset_x)+'px';
  obj.style.top = parseInt(get_y_offset(el_a)+offset_y)+'px';
  obj.style.display = (obj.style.display == 'block') ? 'none' : 'block'; 
}

pokec_timeout = 0;

function rpc_pokec(type) {
   vzkaz = getEl('pokec_vzkaz').value;
   pro = getEl('pokec_pro').value;
   if (vzkaz.length) {
      getEl('pokec_submit').value = 'Odesílám...';
      getEl('pokec_submit').disabled = true;
      small = (type == 'small') ? '&small=1' : '';
      vzkaz = encodeURIComponent(vzkaz);
      if (pokec_timeout) {
         clearTimeout(pokec_timeout);
         pokec_timeout = 0;
      }
      rpc('pokec_rpc', '/rpc_pokec.php?pro='+pro+small+'&vzkaz='+vzkaz);
   }
   else {
      alert('Není co odesílat');
      getEl('pokec_vzkaz').focus();
   }
   return false;
}

function rpc_pokec_refresh(type) {
   if (getEl('pokec_vzkaz')) {      
      if (getEl('pokec_vzkaz').value.length == 0) {
         small = (type == 'small') ? '&small=1' : '';
         if (pokec_timeout) {
            clearTimeout(pokec_timeout);
            pokec_timeout = 0;
         }
         rpc('pokec_rpc', '/rpc_pokec.php?pro='+getEl('pokec_pro').value+'&refresh=1'+small);
      }
      else {
         pokec_timeout = setTimeout('rpc_pokec_refresh("'+type+'")', 15000);
      }
   }
}

function getParentElement(node) {
   node = node.parentNode;
   while (node.nodeType != 1) {
      node = node.parentNode;         
   }   
   return node;
}

function findParentElement(node, search) {
   if (!node) return false;
   while (node.nodeName != search && node.nodeName != 'BODY' && node.nodeName != 'HTML') {
      node = getParentElement(node);
   }
   return (node.nodeName == search) ? node : false;   
}


if (typeof XMLHttpRequest == 'undefined') {
   XMLHttpRequest = function() {
      return new ActiveXObject(navigator.userAgent.indexOf('MSIE 5') >= 0 ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP');
   }
}

function kalendar_table() {
   var img = new Image();
   img.src = '/gfx/ajax.gif';
   var els = getEl('kalendar').getElementsByTagName('A');
   for (var i = 0, a; a = els[i]; i++) {  
      if (a.className.indexOf('kalendar') > -1) {
         a.onclick = function() {
               var el = this;
               var num = el.className.replace(/kalendar ([0-9]+)/, '$1');
               if (num) {
                  var xhr = new XMLHttpRequest();
                  if (xhr) {
                     xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4 && xhr.status == 200) {
                           td.innerHTML = xhr.responseText;
                           el.onclick = function() {getEl('tr' + num).style.display = (getEl('tr' + num).style.display == 'none') ? '' : 'none'; return false;}
                        }
                     }
                     xhr.open('GET', '/rpc_kalendar.php?id=' + num, true); 
                     xhr.send(null);
                     var tr = findParentElement(el, 'TR');
                     var table = findParentElement(el, 'TABLE');                           
                     if (tr && table) {
                        var new_tr = table.insertRow(tr.rowIndex + 1);
                        new_tr.className = 'odd';
                        new_tr.id = 'tr' + num;
                        var td = new_tr.insertCell(0);
                        td.colSpan = 4;
                        td.innerHTML = '<div class="align-center"><img src="/gfx/ajax.gif" width="32" height="32" alt="" /></div>';
                     }
                     return false;
                  }
               }
               return true;
            }
      }      
   }
}

function editPhoto(id, type) {
   var img = new Image();
   img.src = '/gfx/ajax.gif';
   var div = getEl('phototext');
   var xhr = new XMLHttpRequest();
   if (xhr && div) {
      xhr.onreadystatechange = function() {
         if (xhr.readyState == 4 && xhr.status == 200) {
            div.innerHTML = xhr.responseText;
            new editor("popis");
         }
      }
      xhr.open('GET', '/rpc_photo_edit.php?id=' + id + '&type=' + type, true); 
      xhr.send(null);
      div.innerHTML = '<div class="align-center"><img src="/gfx/ajax.gif" width="32" height="32" alt="" /></div>';
      return false;
   }
   return true;
}

function editPhotoSave(id, type, token, form) {
   if (form_validate(form)) {
      var div = getEl('phototext');
      var xhr = new XMLHttpRequest();
      var els = ['nazev', 'popis', 'log_text', 'rewrite_url', 'id_sekce', 'set_active', 'id_autor', 'id_autor2', 'meta_keys', 'meta_desc'];
      var params = '', val;
      for (var i = 0, el; el = els[i]; i++) {
         val = (form[el].type == 'checkbox') ? (form[el].checked ? 1 : 0) : form[el].value;
         if (params) params += '&';
         params += el + '=' + encodeURIComponent(val);
      }
      if (xhr && div) {
         xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
               div.innerHTML = xhr.responseText;
            }
         }
         xhr.open('POST', '/rpc_photo_save.php?id=' + id + '&type=' + type + '&token=' + token, true); 
         xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
         xhr.send(params);
         div.innerHTML = '<div class="align-center"><img src="/gfx/ajax.gif" width="32" height="32" alt="" /></div>';
      }
      form_block = false;
   }
   return false;
}

function fb(url, id) {
   var el = getEl('fb' + id)
   var xhr = new XMLHttpRequest();
   if (xhr && el) {
      xhr.onreadystatechange = function() {
         if (xhr.readyState == 4 && xhr.status == 200) {
            el.innerHTML = xhr.responseText;         
         }
      }
      xhr.open('GET', '/rpc_fb.php?url=' + encodeURIComponent(url), true); 
      xhr.send(null);
      el.innerHTML = 'načítám...';
   }
   return false;
}

function kal(d, m, next) {
   
   var div = getEl('kal');
   var xhr = new XMLHttpRequest();
   if (xhr && div) {
      xhr.onreadystatechange = function() {
         if (xhr.readyState == 4 && xhr.status == 200) {
            div.innerHTML = xhr.responseText;
         }
      }
      xhr.open('GET', '/rpc_kal.php?d=' + d + '&m=' + m + '&next=' + next, true); 
      xhr.send(null);
      div.innerHTML = '<div class="align-center"><br /><img src="/gfx/ajax-kal.gif" width="28" height="28" alt="" /><br /><br /></div>';
   }
}
