var timerID = null;
var timerRunning = false;
var timerWeekArray = new Array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
var timerShowerObject = null;

function stopclock() {
	if (timerRunning) clearTimeout(timerID);
	timerRunning = false;
}

function showtime() {
	var now = new Date();
	var field = now.getFullYear();
	var timeValue= field+'年';
	field = now.getMonth() + 1;
	timeValue += ((field < 10) ? '0' : '') + field+'月';
	field = now.getDate();
	timeValue += ((field < 10) ? '0' : '') + field+'日';
	field = now.getHours();
	timeValue += ' ' + ((field < 10) ? '0' : '') + field;
	field = now.getMinutes();
	timeValue += ((field < 10) ? ':0' : ':') + field;
	field = now.getSeconds()
	timeValue += ((field < 10) ? ':0' : ':') + field;
	field = now.getDay();
	timeValue += ' '+timerWeekArray[field];
	timerShowerObject.data = timeValue;
	timerID = setTimeout('showtime()', 1000);
	timerRunning = true;
}

function startclock() {
	var obj = document.getElementById('titleTimer');
	if (obj == null) return;
	timerShowerObject = document.createTextNode('');
	obj.appendChild(timerShowerObject);
	stopclock();
	showtime();
}
