﻿<!--
// The main part of the script:
function showClock(){
// Set the text to display before the clock:
var mypre_text = " ";

// Display the time in 24 or 12 hour time?
// 0 = 24, 1 = 12
var my12_hour = 1;

// How often do you want the clock updated?
// 0 = Never, 1 = Every Second, 2 = Every Minute
// If you pick 0 or 2, the seconds will not be displayed
var myupdate = 1;

// Display the date?
// 0 = No, 1 = Yes
var DisplayDate = 1;

// Global varibale definitions:
var dn="";

// The following arrays contain data which is used in the clock's
// date function. Feel free to change values for Days and Months
// if needed (if you wanted abbreviated names for example).
var DaysOfWeek = new Array(7);
		DaysOfWeek[0] = "星期日";
		DaysOfWeek[1] = "星期一";
		DaysOfWeek[2] = "星期二";
		DaysOfWeek[3] = "星期三";
		DaysOfWeek[4] = "星期四";
		DaysOfWeek[5] = "星期五";
		DaysOfWeek[6] = "星期六";

var MonthsOfYear = new Array(12);
		MonthsOfYear[0] = "1";
		MonthsOfYear[1] = "2";
		MonthsOfYear[2] = "3";
		MonthsOfYear[3] = "4";
		MonthsOfYear[4] = "5";
		MonthsOfYear[5] = "6";
		MonthsOfYear[6] = "7";
		MonthsOfYear[7] = "8";
		MonthsOfYear[8] = "9";
		MonthsOfYear[9] = "10";
		MonthsOfYear[10] = "11";
		MonthsOfYear[11] = "12";

// This array controls how often the clock is updated,
// based on your selection in the configuration.
var ClockUpdate = new Array(3);
		ClockUpdate[0] = 0;
		ClockUpdate[1] = 1000;
		ClockUpdate[2] = 60000;	
	
	
// Get all our date variables:
var Digital = new Date();
var year = Digital.getYear();
var day = Digital.getDay();
var mday = Digital.getDate();
var month = Digital.getMonth();
var hours = Digital.getHours();

var minutes = Digital.getMinutes();
var seconds = Digital.getSeconds();

// Set up the hours for either 24 or 12 hour display:
if(my12_hour){
		dn = "AM";
		if (hours > 12) { dn = "PM"; hours = hours - 12; }
		if (hours == 0) { hours = 12; }
} 
else{
		dn = "";
}

if (minutes <= 9) { minutes = "0"+minutes; }
if (seconds <= 9) { seconds = "0"+seconds; }
if (year < 1000) {year += 1900; }

// This is the actual HTML of the clock. If you're going to play around
// with this, be careful to keep all your quotations in tact.
myclock = '';
myclock += mypre_text;
myclock += hours+':'+minutes;
		
if ((myupdate < 2) || (myupdate == 0)) { myclock += ':'+seconds; }
myclock += ' '+dn;
		
if (DisplayDate){ myclock += ' ' + year + '年' + MonthsOfYear[month] + '月'+mday+'日' + ' ' + DaysOfWeek[day]; }

if(!$("datetime")) return false;
$("datetime").innerHTML = myclock;            

if(myupdate != 0){ 
	setTimeout("showClock()",ClockUpdate[myupdate]); 
}
}

setOnloadEvent(showClock);
function setOnloadEvent(func){
	 var oldonload = window.onload;
	 if(typeof window.onload != "function"){
		  window.onload = func;
	 }
	 else{
	    window.onload = function(){
	    	 oldonload();
	    	 func();
	    }	
	 }
}

//-->
