function showTimer(icounters){ if(icounters) { for(i in icounters) { (function(icounters, i) { var offset = -1, idate = icounters[i], date = new Date(), daymonth = idate.split(' ')[0], hourminute = idate.split(' ')[1]; date.setHours(hourminute.split(':')[0]); date.setMinutes(hourminute.split(':')[1]); date.setDate(daymonth.split('.')[0]); date.setMonth(daymonth.split('.')[1] - 1); date.setSeconds(0); var func = function() { var time = Math.ceil(date.getTime() / 1000) - 1351683299 - (offset += 1); var days = Math.floor(time / 86400), hours = Math.floor(time / 3600), minutes = Math.floor(time / 60), seconds = time, $d, $p; seconds -= (minutes * 60); minutes -= (hours * 60); hours -= (days * 24); $d = ($p = days % 100) % 10; if(time > 0) { document.getElementById(i).innerHTML = ([' ', ' ', ' '])[ ($d == 0 || ($p > 10 && $p < 15) || ($d >= 5 && $d <= 9)) ? 2 : ($d == 1 ? 0 : 1) ] + ' ' + (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds; } else { document.getElementById(i).innerHTML = 'Началось'; clearInterval(icounters[i]); } }; icounters[i] = setInterval(func, 1000); func(); })(icounters, i); } } }