// Copyright 2002 Bontrager Connection, LLC
// See http://willmaster.com/possibilities/archives/ for more info
//
// Specify the spelling of month names. They can be abbreviated 
//    or completely spelled out, and can be in any written language.

Month1  = 'January';
Month2  = 'February';
Month3  = 'March';
Month4  = 'April';
Month5  = 'May';
Month6  = 'June';
Month7  = 'July';
Month8  = 'August';
Month9  = 'September';
Month10 = 'October';
Month11 = 'November';
Month12 = 'December';

//
// Specify the spelling of month names. They can be abbreviated 
//    or completely spelled out, and can be in any written language.

Weekday1  = 'Sunday';
Weekday2  = 'Monday';
Weekday3  = 'Tuesday';
Weekday4  = 'Wednesday';
Weekday5  = 'Thursday';
Weekday6  = 'Friday';
Weekday7  = 'Saturday';


// Specify the format you want for your date/time display. Whatever 
//    you type between the quotes will be printed, except the 
//    following placeholders will be replaced with live data --
//
// Note 1: All placeholders are case sensitive.
//
//       YEAR -- The 4-digit year.
//         YR -- The 2-digit year.
//
//      MONTH -- The month name.
//         MT -- The month number.
//        0MT -- The month number, with a zero leading single digits.
// Note 2: The first character of 0MT is a zero, not a capital letter Oh.
//
//    WEEKDAY -- The day of the week.
//
//        DAY -- The day of the month.
//       0DAY -- The day of the month, with a zero leading single digits.
// Note 3: The first character of 0DAY is a zero, not a capital letter Oh.
//
//        H12 -- replaced with the hour (12-hour clock).
//       0H12 -- replaced with the hour (12-hour clock), with a zero leading single digits.
//        H24 -- replaced with the hour (12-hour clock).
//       0H24 -- replaced with the hour (12-hour clock), with a zero leading single digits.
//         MM -- replaced with the minute.
//         0M -- replaced with the minute, with a zero leading single digits.
//         SS -- replaced with the second.
//         0S -- replaced with the second, with a zero leading single digits.
//       AMPM -- replaced with "AM" if the time is before noon, "PM" otherwise.
// Note 4: The first character of 0H12, 0H24, 0M, and 0S is a zero, not a capital letter Oh.
//
// Here, specify the format:

DateTimeFormat = "WEEKDAY, 0H24:0M";



//
// No customizations are required below this point of 
//    this JavaScript code section.
//

function FormatDateTimeString(fixedtime) {
	var currentYear     = fixedtime.getFullYear();
	var currentMonth    = fixedtime.getMonth();
	var currentWeekDay  = fixedtime.getDay();
	var currentMonthDay = fixedtime.getDate();
	var currentHour     = fixedtime.getHours();
	var currentMinute   = fixedtime.getMinutes();
	var currentSecond   = fixedtime.getSeconds();
	var re = '';
	var datetimeString = DateTimeFormat;
	re = /YEAR/g;
	datetimeString = datetimeString.replace(re,currentYear);
	var st = new String(currentYear);
	var shortYear = st.charAt(2) + st.charAt(3);
	re = /YR/g;
	datetimeString = datetimeString.replace(re,shortYear);
	currentMonth = currentMonth + 1;
	st = String('st2 = Month' + currentMonth);
	var st2 = '';
	eval(st);
	re = /MONTH/g;
	datetimeString = datetimeString.replace(re,st2);
	var si = '';
	if(currentMonth < 10){ 
		si = '0' + currentMonth; 
	}
	else{ 
		si = currentMonth; 
	}
	re = /0MT/g;
	datetimeString = datetimeString.replace(re,si);
	re = /MT/g;
	datetimeString = datetimeString.replace(re,currentMonth);
	currentWeekDay = currentWeekDay + 1;
	st = String('st2 = Weekday' + currentWeekDay);
	eval(st);
	re = /WEEKDAY/g;
	datetimeString = datetimeString.replace(re,st2);
	si = '';
	if(currentMonthDay < 10) { 
		si = '0' + currentMonthDay; 
	}
	else{ 
		si = currentMonthDay; 
	}
	re = /0DAY/g;
	datetimeString = datetimeString.replace(re,si);
	re = /DAY/g;
	datetimeString = datetimeString.replace(re,currentMonthDay);
	var AmPm = 'pm';
	if(currentHour < 12) { 
		AmPm = 'am';
	}
	var twelveHour = currentHour;
	if(currentHour > 12) { 
		twelveHour = currentHour - 12; 
	}
	var zeroCurrentHour = currentHour;
	if(currentHour < 10) { 
		zeroCurrentHour = '0' + currentHour; 
	}
	var zeroCurrentMinute = currentMinute;
	if(currentMinute < 10) { 
		zeroCurrentMinute = '0' + currentMinute; 
	}
	var zeroCurrentSecond = currentSecond;
	if(currentSecond < 10) { 
		zeroCurrentSecond = '0' + currentSecond; 
	}
	var zeroTwelveHour = twelveHour;
	if(twelveHour < 10) {
		zeroTwelveHour = '0' + twelveHour; 
	}
	re = /AMPM/g;
	datetimeString = datetimeString.replace(re,AmPm);
	re = /0H12/g;
	datetimeString = datetimeString.replace(re,zeroTwelveHour);
	re = /H12/g;
	datetimeString = datetimeString.replace(re,twelveHour);
	re = /0H24/g;
	datetimeString = datetimeString.replace(re,zeroCurrentHour);
	re = /H24/g;
	datetimeString = datetimeString.replace(re,currentHour);
	re = /0M/g;
	datetimeString = datetimeString.replace(re,zeroCurrentMinute);
	re = /MM/g;
	datetimeString = datetimeString.replace(re,currentMinute);
	re = /0S/g;
	datetimeString = datetimeString.replace(re,zeroCurrentSecond);
	re = /SS/g;
	datetimeString = datetimeString.replace(re,currentSecond);
	re = /am/g;
	datetimeString = datetimeString.replace(re,'AM');
	re = /pm/g;
	datetimeString = datetimeString.replace(re,'PM');
	return datetimeString;
} // end of function FormatDateTimeString()

function GetAndRelayCurrentDateTime() {
	var mytime = new Date();
	return FormatDateTimeString(mytime);
} // end of function GetAndRelayCurrentDateTime()

function UpdateDateTime() {
	var t = GetAndRelayCurrentDateTime();
	document.datetimeform.timespot.value = t;
	setTimeout('UpdateDateTime()',1000);
} // end of function UpdateDateTime()
//-->

// Copyright 2002 Bontrager Connection, LLC
// The data and functions in this section assume that 
//    the data and functions developed for the article, 
//    "JavaScript Clocks and Calendars, Part II, Custom Date/Time Display,"
//    are available in this web page's source code above this section. 
//    See http://willmaster.com/possibilities/archives/ for more info.

//
// Leave the following three lines as is:
	ItemName = new Array();
	ItemTime = new Array();
	HowMany = 0;
// Leave the above three lines as is.


//
// In the space below, specify the particulars of each time zone you 
//    want displayed on your page.
// For each time zone, you must specify a name and the adjustment 
//    plus or minus Universal Time. [Universal Time (UT) is the same 
//    as Greenwich Mean Time (GMT).]
// The name of the time zone can be anything you wish it to be. If 
//    the name contains quotation marks, they must be preceeded with 
//    a backslash, like: \"
// The adjustment can be specified in hours or minutes. Hours may 
//    be whole or decimal numbers, like +2 or -2.5 but minutes must 
//    be whole numbers only, like +120 or -150. If the number is 
//    over 12 or less than -12 it's deemed to be minutes, otherwise, 
//    it is assumed to represent hours. To indicate a time zone West 
//    of Greenwich, England, which is time zone 0 or UT, preceed the 
//    number with a minus sign (hyphen). To indicate a time zone East 
//    of 0, preceeding the number with a plus sign is optional.
// (Because this program does not have a database of individual world 
//    regions' Daylight Savings Time rules, separate Daylight Savings 
//    Time entries need to be added to the list for those you want 
//    displayed.)
// To specify the particulars of each time zone for display, follow 
//    this format, one line per time zone:
//       AddTimeZoneToList("Time Zone Name",0);
//    Replace "Time Zone Name" with the name of your time zone. And 
//    replace 0 with the number of hours or minutes, minus or plus, 
//    that the time zone differs from UT.
// The order you specify the time zones in the lines below is the order 
//    they will be displayed on your page.

	AddTimeZoneToList("Johannesburg",2);
	AddTimeZoneToList("New York",-5);
	AddTimeZoneToList("London",0);
	AddTimeZoneToList("Paris",1);
	AddTimeZoneToList("Hong Kong",8);
	AddTimeZoneToList("Singapore",8);
	AddTimeZoneToList("Dubai",3);


//
// Between the quotes, type the characters (if any) that you want displayed 
//    at the beginning of the list of time zones display. If your characters 
//    contain quotation marks, they must be preceeded with a backslash, 
//    like: \"

	var BeginListWith = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><th>Time Zone</th><th>Actual Time</th></tr>";


//
// Between the quotes, type the characters that you want displayed wherever 
//    a list time zone is displayed. Use TIMEZONENAME and TIMEZONETIME 
//    where you want the name of the time zone and the time of the time 
//    zone displayed, respectively. If your characters contain quotation 
//    marks, they must be preceeded with a backslash, like: \"

	var ListItemDisplay = "TIMEZONENAME - TIMEZONETIME";


//
// Between the quotes, type the characters (if any) that you want displayed 
//    at the end of the list of time zones display. If your characters 
//    contain quotation marks, they must be preceeded with a backslash, 
//    like: \"

	var EndListWith = "</table>";

//
// No customizations are required below this point of 
//    this JavaScript code section.
//

var globalCount=0;

function DisplayListOfTimeZones() {
	toWriteTo=document.getElementById('timeDisplayer');
	var centertime = new Date();
	var centerdigits = centertime.getTime() + (centertime.getTimezoneOffset() * 60 * 1000);
	centertime.setTime(centerdigits);
	var re = '';
	var myStr='';
//myStr=(BeginListWith);
	/*for(var i = 0; i < HowMany; i++) {*/
		var i= globalCount;
		var s = ListItemDisplay;
		re = /TIMEZONENAME/g;
		s = s.replace(re,ItemName[i]);
		centertime.setTime(centerdigits + (ItemTime[i] * 60 * 1000));
		var t = FormatDateTimeString(centertime);
		re = /TIMEZONETIME/g;
		s = s.replace(re,t);
		myStr+=(s);
	/*}*/
	//myStr+=(EndListWith);
	toWriteTo.innerHTML=myStr;
	globalCount++;
	if (globalCount==HowMany){
		globalCount=0;
	}
} // DisplayListOfTimeZones()

function AddTimeZoneToList(s,t) {
	ItemName[HowMany] = s;
	if((t <= 12) && (t >= -12)) { t = t * 60; }
	ItemTime[HowMany] = t;
	HowMany = HowMany + 1;
} // AddTimeZoneToList()

//Calls the display function repeatedly, bring up the next item in the time list in a loop
function Update(){
	DisplayListOfTimeZones();
	myClock=setInterval('DisplayListOfTimeZones()',5000);
}

onload=Update;