var timerID = null;
var timerRunning = false;
function startclock () 
{
stopclock();
time();
}
function stopclock ()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function time ()
{
var now = new Date();
var yr = now.getYear();
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1;
var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
var ampm = (now.getHours() >= 12) ? "下午 " : "上午 "
var hours = now.getHours();
hours = ((hours > 12) ? hours - 12 : hours);
var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
if(dName==1) Day = "星期天";
if(dName==2) Day = "星期一";
if(dName==3) Day = "星期二";
if(dName==4) Day = "星期三";
if(dName==5) Day = "星期四";
if(dName==6) Day = "星期五";
if(dName==7) Day = "星期六";
if(mName==1) Month="1";
if(mName==2) Month="2";
if(mName==3) Month="3";
if(mName==4) Month="4";
if(mName==5) Month="5";
if(mName==6) Month="6";
if(mName==7) Month="7";
if(mName==8) Month="8";
if(mName==9) Month="9";
if(mName==10) Month="10";
if(mName==11) Month="11";
if(mName==12) Month="12";
var DayDateTime=(" "
+ " "
+ yr
+ "年 "
+ Month
+ "月"
+ dayNr
+ "日 "
+ Day
+ "　"
+ ampm
+ hours
+ minutes
+ seconds
);
window.status=DayDateTime;
timerID = setTimeout("time()",1000);
timerRunning = true;
}
function clearStatus()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
window.status=" "; 
}
startclock();
