/* math */ function inarray(co, kde) { var len = kde.length; var rslt = -1; var i=0; while ( i < len && rslt==-1 ) { if (kde[i] == co) rslt = i; i++; } return rslt!=-1 ? rslt : false; } function round(cislo, prec) { var zaklad = Math.floor(cislo); if (zaklad == cislo) return zaklad; var desmista = cislo - zaklad; var exp = Math.pow(10, prec); desmista = Math.round(desmista*exp) / exp; return zaklad + desmista; } /* bloky */ function givefocus() { blok = document.getElementById('takefocus'); if (blok != null) blok.focus(); return true; } function hide(name) { blok = document.getElementById(name); if (!blok) return false; blok.style.display = 'none'; } function show(name) { blok = document.getElementById(name); if (!blok) return false; blok.style.display = 'block'; } function mailto(name, domain) { if (name == '' || domain == undefined || domain == '') return ''; return(document.location.href="mailto:"+name+"@"+domain); } function emailsplit(name, domain) { if (name == '' || domain == undefined || domain == '') return ''; return(name+"@"+domain); } function catchkeypress(e) { var pressedKey = ("undefined" == typeof (e)) ? event.keyCode : e.keyCode ; /* if (pressedKey == "27") { // ASCII code of the ESC key alert('Zmackls ESC. Proc?'); } */ return true; } /* windows */ function OpenWindow(url, name) { return window.open(url, name); } function openwindow(url, name) { return OpenWindow(url, name); } function closeandredirect(url) { window.opener.document.location.href = url; window.close(); return true; } function redirect(url) { document.location.href=url; return true; } function delconfirm() { return window.confirm('Opravdu smazat?'); } /* nejede, hazi rekurzi v mozille function confirm(zprava) { if (zprava == undefined) zprava = 'Jste si jist?'; return window.confirm(zprava); } */ function doconfirm() { return window.confirm('Jste si jist?'); } var delay = 0; var andelay = 0; var dl = false; var dl2 = false; var derror = false; function countdown() { if (delay > 0 || andelay > 0) { if (derror) derror.innerHTML = showerror(delay); if (dl2) dl2.innerHTML = showanerror(andelay); if (delay>0) delay--; if (andelay>0) andelay--; setTimeout('countdown()', 1000); } else { if (derror) derror.innerHTML = ''; if (dl) dl.innerHTML = ''; if (dl2) dl2.innerHTML = ''; } } function initdelay() { dl = document.getElementById('delay'); derror = document.getElementById('derror'); dl2 = document.getElementById('anketadelay'); return true; } function showerror(d) { return "Další příspěvek můžete odeslat za "+showtimebysec(d)+"."; } function showanerror(d) { return "Znova kliknout na tuto anketu můžete za "+showtimebysec(d)+"."; } function showtimebysec(s) { var dnu = Math.floor(s / 86400); s -= dnu*86400; var hod = Math.floor(s / 3660); s -= hod*3660; var min = Math.floor(s / 60); s -= min*60; var sek = s; var result = ''; if (dnu>=1) result += dnu+" "+sklonuj(dnu,"den","dny","dnů")+", "; if (hod>=1) result += hod+" "+sklonuj(hod,"hodinu","hodiny","hodin")+", "; if (min>=1) result += min+" "+sklonuj(min,"minutu","minuty","minut")+" a "; result += sek+" "+sklonuj(sek,"sekundu","sekundy","sekund"); return result; } function sklonuj(pocet, jeden, dva, petavic) { if (pocet == 0 || pocet >= 5 ) return petavic; if (pocet > 1 && pocet < 5) return dva; else return jeden; }