var day = document.getElementById("day");
var hours = document.getElementById("hours");
var min = document.getElementById("min");
var sec = document.getElementById("sec");
var DifferenceHour = -1;
var DifferenceMinute = -1;
var DifferenceSecond = -1;
//var Tday = new Date("11 20,2010 10:00:00")   //**倒计时时间点-注意格式
//var Tday = new Date("03/26/2011 20:30:00");   //IE:月/日/年
var daysms = 24 * 60 * 60 * 1000;
var hoursms = 60 * 60 * 1000;
var Secondms = 60 * 1000;
var microsecond = 1000;




function daojishi() {
    
 var time = new Date();
 var hour = time.getHours();
 var minute = time.getMinutes();
 var second = time.getSeconds();
 var timevalue = "" + ((hour > 12) ? hour - 12 : hour);
 
 timevalue += ((minute < 10) ? ":0":":") + minute;
 timevalue += ((second < 10) ? ":0" : ":") + second;

 timevalue += ((hour > 12) ? " PM" : " AM");
 
 var convertHour = DifferenceHour;
 var convertMinute = DifferenceMinute;
 var convertSecond = DifferenceSecond;
 var Diffms = Tday.getTime() - time.getTime();
 
 DifferenceHour = Math.floor(Diffms / daysms);
 Diffms -= DifferenceHour * daysms;
 
 DifferenceMinute = Math.floor(Diffms / hoursms);
 Diffms -= DifferenceMinute * hoursms;
 
 DifferenceSecond = Math.floor(Diffms / Secondms);
 Diffms -= DifferenceSecond * Secondms;


 
 var dSecs = Math.floor(Diffms / microsecond);
 if (convertHour != DifferenceHour) {
 
  day.innerHTML = DifferenceHour;
}




if (convertMinute != DifferenceMinute) {
    if (DifferenceMinute < 10) {

        hours.innerHTML = "0"+DifferenceMinute;
    }
    else {
        hours.innerHTML = DifferenceMinute;
    } 
}

if (convertSecond != DifferenceSecond) {

    if (DifferenceSecond < 10) {
        min.innerHTML = "0"+DifferenceSecond;
    }
    else {
        min.innerHTML = DifferenceSecond;
    }
}



if (dSecs < 10) {
    sec.innerHTML = "0"+dSecs;
}
else {
    sec.innerHTML = dSecs;
}


 setTimeout("daojishi()", 1000);
}
