var timers = new Array(); function startTimer(id, secsleft) { ed = new Date(); ed.setTime(ed.getTime() + secsleft); timers[id] = ed; runTimer(id); } function runTimer(id) { d=new Date(); days=0; hours=0; mins=0; secs=0; str=''; endtime = timers[id]; count=Math.floor( (endtime.getTime()-d.getTime()) / 1000); if (count == 0) { window.location.reload(); } else if(count < 0) { str = 'The auction has ended'; } else if (count > 0) { window.setTimeout('runTimer('+id+')',500); secs=count%60; count=Math.floor(count/60); mins=count%60; count=Math.floor(count/60); hours=count%24; count=Math.floor(count/24); days=count; str = days + ' days ' + hours + ' hours ' + mins + ' minutes ' + secs + ' seconds'; } elname = 'timer'+id; if(document.getElementById) { document.getElementById(elname).innerHTML = str; } else if (document.all) { document.all[elname].innerHTML = str; } }