function CountDown(root) { this.root = document.getElementById(root); this.curentTime = 1268428689; this.minute = 60; this.hour = 60 * this.minute; this.day = 24 * this.hour; } CountDown.prototype.track = { 'Бахрейн' : 1268568000 , 'Австралия' : 1269759600 , 'Малайзия' : 1270368000 , 'Китай' : 1271574000 , 'Испания' : 1273406400 , 'Монако' : 1274011200 , 'Турция' : 1275220800 , 'Канада' : 1276444800 , 'Европа' : 1277640000 , 'Великобритания' : 1278849600 , 'Германия' : 1280059200 , 'Унгария' : 1280664000 , 'Белгия' : 1283083200 , 'Италия' : 1284292800 , 'Сингапур' : 1285502400 , 'Япония' : 1286690400 , 'Корея' : 1287900000 , 'Бразилия' : 1289149200 , 'Абу Даби' : 1289743200 }; var season = 2010; CountDown.prototype.Calculate = function () { for (i in this.track) { this.diffrent = this.track[i]; if (this.diffrent > this.curentTime) { this.road_name = i; this.StartCountDown(); return false; } } this.root.innerHTML = ''; //'End of season ' +season; } CountDown.prototype.StartCountDown = function () { var diff = this.diffrent - this.curentTime; var days = Math.floor(diff / this.day); diff -= days * this.day; var hours = Math.floor(diff / this.hour); diff -= hours * this.hour; var minutes = Math.floor(diff / this.minute); diff -= minutes * this.minute; var seconds = Math.floor(diff); if (days >= 0) { this.root.innerHTML = '
' +this.road_name+ '
' +this.toFix(days)+ 'дни' +this.toFix(hours)+ 'часа' +this.toFix(minutes)+ 'минути' +this.toFix(seconds)+ 'секунди'; this.curentTime ++; var self = this; setTimeout(function () {self.StartCountDown();}, 1000); } else this.Calculate(); } CountDown.prototype.toFix = function (sender) { if (sender < 10) { return '0'+sender; } return sender; }