var _currentSeconds=0; function ActivateCountDown(strContainerID, initialValue) { _countDowncontainer = document.getElementById(strContainerID); if (!_countDowncontainer) { alert("count down error: container does not exist: "+strContainerID+ "\nmake sure html element with this ID exists"); return; } SetCountdownText(initialValue); window.setTimeout("CountDownTick()", 1000); } function CountDownTick() { if (_currentSeconds <= 0) { document.getElementById('kamera1').src='kamera1.php?'+Math.random(); document.getElementById('kamera2').src='kamera2.php?'+Math.random(); load_item('http://kamera.drsny.net/online.php?js=1', 'hash=HZ1Du2P0YR9fJrgSc9f7vDP13PfAdbI2', request_index); // window.location = '.'; ActivateCountDown('CountDownPanel','30'); return; } SetCountdownText(_currentSeconds-1); window.setTimeout("CountDownTick()", 1000); } function SetCountdownText(seconds) { //store: _currentSeconds = seconds; //get minutes: var minutes=parseInt(seconds/60); //shrink: seconds = (seconds%60); //get hours: var hours=parseInt(minutes/60); //shrink: minutes = (minutes%60); //build text: // var strText = AddZero(hours) + ":" + AddZero(minutes) + ":" + AddZero(seconds); var strText = seconds; //apply: _countDowncontainer.innerHTML = 'obnovení za ' + strText + ' sec.'; } function AddZero(num) { return ((num >= 0)&&(num < 10))?"0"+num:num+""; }