var Tday = new Array();
var daysms = 24 * 60 * 60 * 1000
var hoursms = 60 * 60 * 1000
var Secondms = 60 * 1000
var microsecond = 1000
var DifferHour = -1
var DifferMinute = -1
var DifferSecond = -1
function clock(key){
	var time = new Date();
	var convertHour =DifferHour
	var convertMinute =DifferMinute
	var convertSecond =DifferSecond
	var Diffms =Math.floor(Tday[key]*1000) - Math.floor(Date.parse(time))
	if(Diffms > 0){
		DifferHour = Math.floor(Diffms/ daysms)
		Diffms -= DifferHour *daysms
		DifferMinute =Math.floor(Diffms / hoursms)
		Diffms -= DifferMinute *hoursms
		DifferSecond =Math.floor(Diffms / Secondms)
		Diffms -= DifferSecond *Secondms
		var dSecs = Math.floor(Diffms/ microsecond)
		DifferHour = checkTime(DifferHour);
		DifferMinute = checkTime(DifferMinute);
		DifferSecond = checkTime(DifferSecond);
		dSecs = checkTime(dSecs);
		if(convertHour != DifferHour)a="<em>"+DifferHour+"</em>：";
		if(convertMinute !=DifferMinute) b="<em>"+DifferMinute+"</em>：";
		if(convertSecond !=DifferSecond) c="<em>"+DifferSecond+"</em>：";
		d="<em>"+dSecs+"</em>";
		if (DifferHour>0) {a=a}
		else {a=''}
		$("#leftTime_"+key).html("还剩："+a + b + c + d);
	}else{
	  $("#leftTime_"+key).html('促销已结束'); 
	}
}
function checkTime(i){
	if (i < 10) {    
	   i = "0" + i;
	}    
	return i
}