//----倒计时JS--------------------
var xb_time_id, xb_span_time_msg, xb_span_time_str, xb_now, xb_h, xb_m, xb_s, xb_now_time, xb_left_time;
var sb_time = 3600*8 + 60*00;	//上班时间：8:30
var xb_time = 3600*17 + 60*30;	//下班时间：17:30

function start_time()
{
	xb_now = new Date();
	xb_h=xb_now.getHours();
	xb_m=xb_now.getMinutes();
	xb_s=xb_now.getSeconds();
	
	xb_now_time = 3600*xb_h + 60*xb_m + xb_s;	//现在时间

	xb_span_time_msg = document.getElementById("xb_span_time_msg");
	xb_span_time_str = document.getElementById("xb_span_time_str");
	
	if(xb_now_time <= sb_time || xb_now_time >= xb_time)
	{
		show_time();
	}
	else
	{
		count_down();
	}
}
function show_time()
{
	xb_span_time_msg.innerHTML = "当前时间";
	
	xb_now = new Date();
	xb_h=xb_now.getHours();
	xb_m=xb_now.getMinutes();
	xb_s=xb_now.getSeconds();
	
	xb_now_time = 3600*xb_h + 60*xb_m + xb_s;	//现在时间
	
	cyc_show_time();
}
function cyc_show_time()
{
	if(xb_now_time > sb_time && xb_now_time < xb_time)
	{
		clearTimeout(xb_time_id);
		count_down();
		return;
	}
	xb_span_time_str.innerHTML = ch_time(xb_now_time);
	xb_now_time++;
	xb_time_id = setTimeout('cyc_show_time()', 1000);
}
function count_down()
{
	xb_span_time_msg.innerHTML = "现在距您离下班时间还有";
	
	xb_now = new Date();
	xb_h=xb_now.getHours();
	xb_m=xb_now.getMinutes();
	xb_s=xb_now.getSeconds();
	
	xb_now_time = 3600*xb_h + 60*xb_m + xb_s;	//现在时间
	xb_left_time = xb_time - xb_now_time;
		
	cyc_count_down();
}
function cyc_count_down()
{
	if(xb_left_time <= 0)
	{
		clearTimeout(xb_time_id);
		show_time();
		return;
	}
	xb_span_time_str.innerHTML = ch_time(xb_left_time);
	xb_left_time--;
	xb_time_id = setTimeout('cyc_count_down()', 1000);
}
function ch_time(lt)
{
	xb_h = Math.floor(lt/3600);
	xb_m = Math.floor((lt - 3600 * xb_h)/60);
	xb_s = lt - 3600 * xb_h - 60 * xb_m;
	
	return "&nbsp;"+xb_h + "小时" + (xb_m < 10? "0"+xb_m : xb_m) + "分" + (xb_s < 10? "0"+xb_s : xb_s) + "秒";
}
