Скрипт таймера, как сделать два таймера на странице?

R
На сайте с 28.06.2014
Offline
0
746

Есть скрипт таймера, один он работает, а два уже нет. Я пробовал переименовывать все команды и дивы - все равно не хочет. Кто подскажет, как запустить этот скрипт два раза на одной странице? (два таймера с разными значениями)

<div id="CDT"></div><script>

function CountdownTimer(elm,tl,mes){
this.initialize.apply(this,arguments);
}
CountdownTimer.prototype={
initialize:function(elm,tl,mes) {
this.elem = document.getElementById(elm);
this.tl = tl;
this.mes = mes;
},
countDown:function(){
var timer='';
var today = new Date();
while ((this.tl.getTime() - today.getTime()) < 0) {
this.tl.setTime(this.tl.getTime() + 24 * 60 * 60 * 1000);
}
var day = Math.floor((this.tl-today)/(24*60*60*1000));
var hour = Math.floor(((this.tl-today)%(24*60*60*1000))/(60*60*1000));
var min = Math.floor(((this.tl-today)%(24*60*60*1000))/(60*1000))%60;
var sec = Math.floor(((this.tl-today)%(24*60*60*1000))/1000)%60%60;
var me = this;

timer += '<span class="number-wrapper-day"><div class="line"></div><div class="captionday">Дней:</div><span class="number day">'+day+'</span></span>';
timer += '<span class="number-wrapper"><div class="line"></div><div class="caption">:</div><span class="number hour">'+hour+'</span></span>';
timer += '<span class="number-wrapper"><div class="line"></div><div class="caption">:</div><span class="number min">'+this.addZero(min)+'</span></span><span class="number-wrapper"><div class="line"></div><div class="caption"></div><span class="number sec">'+this.addZero(sec)+'</span></span>';
this.elem.innerHTML = timer;
tid = setTimeout( function(){me.countDown();},10 );
},
addZero:function(num){ return ('0'+num).slice(-2); }
}
function CDT(){
// Set countdown limit year mounth date
var tl = new Date('2014/03/09 23:59:59');
// You can add time's up message here
var timer = new CountdownTimer('CDT',tl,'<span class="number-wrapper"><div class="line"></div><span class="number end">Time is up! </span></span>');
timer.countDown();
}
window.onload = function() {
CDT();
}
</script>

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий