//
//usage:
//<body onload=auto_clock_start()>
//<span id=auto_clock></span>
//format:
//12月15日 星期五 11:04 am
//
var ac_timerID = null;
var ac_timerRunning = false;
function auto_clock_stop (){
	if(ac_timerRunning)
		clearTimeout(ac_timerID);
	ac_timerRunning = false;
}
function auto_clock_start () {
	auto_clock_stop();
	auto_clock_show();
}
function auto_clock_show () {
	var now = new Date();
	var year = now.getYear();
	var month = now.getMonth();
	var date = now.getDate();
	var day = now.getDay();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	//var seconds = now.getSeconds();
	
	var day_cn = "";
	switch(day) {
	case 0:
		day_cn = "日"; break;
	case 1:
		day_cn = "一"; break;
	case 2:
		day_cn = "二"; break;
	case 3:
		day_cn = "三"; break;
	case 4:
		day_cn = "四"; break;
	case 5:
		day_cn = "五"; break;
	case 6:
		day_cn = "六"; break;
	}
	var timeValue = "";
	timeValue += (month+1) + "月";
	timeValue += date + "日 ";
	timeValue += "星期" + day_cn + " ";
	timeValue += ((hours >12) ? hours -12 :hours)
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes
	//timeValue += ((seconds < 10) ? ":0" : ":") + seconds
	timeValue += ((hours >= 12) ? " pm" : " am" )
	document.getElementById("auto_clock").innerHTML = timeValue;
	ac_timerID = setTimeout("auto_clock_show()",30000);
	ac_timerRunning = true;
}
