
<!-- 
String.prototype.format = function(){ 
 var tmpStr = this; 
 var iLen = arguments.length; 
 for(var i=0;i<iLen;i++){ 
  tmpStr = tmpStr.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]); 
 } 
 return tmpStr; 
} 
Number.prototype.We = function(bt){ 
 var byte = bt || 2; 
 var data = this.toString(); 
 return (new Array(byte + 1).join("0") + data).substring(data.length); 
} 
function $() { 
  var elements = new Array(); 
  for (var i = 0; i < arguments.length; i++) { 
    var element = arguments[i]; 
    if (typeof element == 'string') 
      element = document.getElementById(element); 
    if (arguments.length == 1)  
      return element; 
    elements.push(element); 
  } 
return elements; 
} 
function CountDown(){ 
 var ref = this; 
 var temp = ""; 
 this.Timer = null; 
 this.Max = 0; 
 this.Current = 0; 
 this.Element = null; 
 this.Format = "mm:ss"; 
 this.Step = 1000; 
 function formatDate(template, input){ 
  var day = input / 60 /60 /24 | 0; 
  var hour = (input - day * 60* 60 * 24) / 60 /60 | 0; 
  var minute = (input - day * 60* 60 * 24 - hour * 60 * 60) / 60 | 0; 
  var second = input - day * 60* 60 * 24 - hour * 60 * 60 - minute * 60; 
  if(temp == ""){ 
   temp = template.replace(/dd/g, "{0}").replace(/d/g, "{1}"); 
   temp = temp.replace(/hh/g, "{2}").replace(/h/g, "{3}"); 
   temp = temp.replace(/mm/g, "{4}").replace(/m/g, "{5}"); 
   temp = temp.replace(/ss/g, "{6}").replace(/s/g, "{7}"); 
  } 
  return temp.format(day.We(), day, hour.We(), hour, minute.We(), minute, second.We(), second) 
 } 
 this.Reset = function(){ 
  this.Clear(); 
  this.Current = this.Max; 
 } 
 this.Create = function(element){ 
  if(typeof(element) == "string"){ 
   if($(element) == null)document.write("<div id=\"{0}\"></div>".format(element)); 
   this.Element = $(element); 
  } else this.Element = element; 
 } 
 this.Start = function(){ 
  this.OnBeforeStart(); 
  this.Clear(); 
  if(this.Current == 0)this.Current = this.Max; 
  this.Timer = setInterval(this.ShowText, this.Step); 
 } 
 this.Stop = function(){ 
  this.Reset(); 
  this.OnStop(); 
 } 
 this.Pause = function(){ 
  this.Clear(); 
  this.OnPause(); 
 } 
 this.Clear = function(){ 
  if(this.Timer != null)clearInterval(this.Timer); 
 } 
 this.ShowText = function(){ 
  with(ref){ 
   if(--Current > -1) Element.innerText = formatDate(Format, Current); 
   else {Clear();OnTimeOut();}; 
  } 
 } 
 this.OnBeforeStart = function(){} 
 this.OnStop = function(){} 
 this.OnPause = function(){} 
 this.OnTimeOut = function(){} 
 this.toString = function(){ 
  return "DHTML CountDown"; 
 } 
} 
//var cd = new CountDown(); 
//cd.Create("ddd"); 
//cd.Max = 60; 
//cd.Start(); 
//cd.OnTimeOut = function(){alert("Ê±¼äµ½!");} 
var cd1 = new CountDown(); 
cd1.Format = "dÌì h:mm:ss"; 
cd1.Create("dd"); 
cd1.Max = int_dajishi; 
cd1.Start(); 
//--> 