$(function(){
	SetServerTime()/*设置服务器时间 */
	ShowTime()/*显示信息 */
});



//设置服务器时间
function SetServerTime()
{
	servertime = Date.parse($("#servertime").val().replace(/-/g,"/"))
	endtime = Date.parse($("#endtime").val().replace(/-/g,"/"))
}


//显示信息
function ShowTime()
{
	CalculateTime();
	if(surplussecond>0) //显示当前期期号和时间
	{
		IssueState = true;
		window.setTimeout("ShowTime()",1000)
	}
	else
	{
		IssueState = false;
	}
}

//计算离各时间还有多少秒
function CalculateTime()
{
	
	servertime = servertime + 1000
	surplussecond = Math.round((endtime-servertime)/1000);
	if(surplussecond>0)
	{
		var h = Math.floor(surplussecond/3600);
		var d = parseInt(h/24);
		h = h%24;
		if (h < 10)
		{
			h = "0"+h;
		}
		var syms = Math.floor(surplussecond%3600);
		var m = Math.floor(syms/60);
		if (m<10)
		{
			m = "0"+m;
		}
		var s = Math.floor(syms%60);
		if(s<10)
		{
			s = "0"+s;
		}
		if (d>0)
		{
			$("#countDownSpan > span.last_time").text(d+"天"+h+"小时"+m+"分")
		}
		else
		{
			$("#countDownSpan > span.last_time").text(h+"小时"+m+"分"+s+"秒")
		}
	}
	else
	{
		$("#countDownSpan").html("<font color='red'>已截止</font>")
	}
}