/////////////// CONFIGURATION /////////////////////////

	// Display the time in 24 or 12 hour time?
	// 0 = 24, 1 = 12
	var my12_hour = 1;

/////////////// END CONFIGURATION /////////////////////

// Browser detect code
	var ie4=document.all
	var ns4=document.layers
	var ns6=document.getElementById&&!document.all

// Global varibale definitions:
	var dn = "";
	var old = "";
	var mtz = 5;	//EST is five hours behind UTC
	var dst = 0;	//turn daylight saving time on or off

// 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] = "週六";

// For Version 4+ browsers, write the appropriate HTML to the
// page for the clock, otherwise, attempt to write a static
// date to the page.
	if (ie4||ns6) { //all the browsers that I tested so far belong here, jen
		document.write('<span id="LiveClockIE"></span>');
	} else if (document.layers) {
		document.write('<ilayer id="ClockPosNS" visibility="hide"><layer id="LiveClockNS"></layer></ilayer>');
	} else {
		old = "true";
		show_clock();
	}

//Jen: configure to display my specified standard Time
function init_clock(m, d) {
	mtz = m;
	dst = d;
	show_clock();
}

// The main part of the script:
function show_clock() {
	if (old == "die") { return; }
	
	//show clock in NS 4
		if (ns4)
			document.ClockPosNS.visibility="show"

	// Get all our date variables:
		var Digital = new Date();
		var day = Digital.getDay();
		var mday = Digital.getDate();
		var month = Digital.getMonth();
		var hours = Digital.getHours();
		var minutes = Digital.getMinutes();
		var seconds = Digital.getSeconds();

	//Jen: configure to display the specified Standard Time
	yourOffset = Math.round((new Date()).getTimezoneOffset() / 60);
	ourDifference = eval(mtz - yourOffset - dst);
	//alert(hours + ' ' + yourOffset + ' ' + mtz + ' ' + ourDifference); //•••
	if (hours >= ourDifference) {
		hours = eval(hours - ourDifference);
		if (hours >= 24) { //jen
			hours = hours - 24;
			day = day+1;
			if (day>6) day=0;
		}
	} else {
		hours = eval(24 + hours - ourDifference);
		day = day-1;	//this only takes care of Monday/Sunday etc, not actual date, jen
		if (day<0) day=6;
	}

	// Set up the hours for either 24 or 12 hour display:
		if (my12_hour) {
			dn = "AM";
			if (hours >= 12) { //was (hours > 12), jen
				dn = "PM"; hours = hours - 12;
			}
			if (hours == 0) { hours = 12; }
		} else {
			dn = "";
		}
		if (minutes <= 9) { minutes = "0"+minutes; }
		if (seconds <= 9) { seconds = "0"+seconds; }

	// 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 += '<font style="color:#008000; font-size:12pt;">';
		myclock += DaysOfWeek[day]+' ';
		myclock += hours+':'+minutes;
		myclock += ':'+seconds;
		myclock += ' '+dn;
		myclock += '</font>';

		if (old == "true") {
			document.write(myclock);
			old = "die";
			return;
		}

	// Write the clock to the layer:
		if (ns4) {
			clockpos = document.ClockPosNS;
			liveclock = clockpos.document.LiveClockNS;
			liveclock.document.write(myclock);
			liveclock.document.close();
		} else if (ie4) {
			LiveClockIE.innerHTML = myclock;
		} else if (ns6){
			document.getElementById("LiveClockIE").innerHTML = myclock;
		}            

	setTimeout("show_clock()", 1000);
}
