// JavaScript Document WorldClock.js
/*
This Javascript is used to tell the user their current system
time, GMT time, and the time in any city they select. I have
just included it in our web page as a fun thing for visitors to
see and play with.
This script may be reused for non-commercial purposes, provided
this description and copyright notice is not altered in any way.
This script is copyright 2005 by Eagle Computer Technologies, Inc.
All Rights Reserved.

History
=======

Version: 1.0, Date: Thursday March 03, 2005, Programmer: RFH
Description: Initial Version

For Questions, Comments, and Bugs, you can contact the programmer.
Programmer : Russ Howard
E-mail: russ.howard@eaglecomputertechnologies.com
*/

//variables
var Separator=";"		// Seperator for cities array
var Fields=6;			// Number of fields in the cities array

var days=new Array()					// days array
days[0]="Sun";
days[1]="Mon";
days[2]="Tue";
days[3]="Wed";
days[4]="Thu";
days[5]="Fri";
days[6]="Sat";

var months=new Array()					// months array
months[0]="Jan";
months[1]="Feb";
months[2]="Mar";
months[3]="Apr";
months[4]="May";
months[5]="Jun";
months[6]="Jul";
months[7]="Aug";
months[8]="Sep";
months[9]="Oct";
months[10]="Nov";
months[11]="Dec";

var wts=new Array() 					// array for cities, states, offsets, hours, minutes
wts[1]="Abidjan;Cote d'Ivoire - CI;+;0;;"
wts[2]="Abu Dhabi;United Arab Emirates - AE;+;4;;"
wts[3]="Adana;Turkey - TR;+;2;;"
wts[4]="Addis Ababa; Ethiopia - ET;+;3;;"
wts[5]="Adelaide *;South Australia - Australia - AU;+;10;30;"
wts[6]="Aden; South Yemen - YE;+;3;;"
wts[7]="Aklavik;Yukon - Canada - CA;-;9;;"
wts[8]="Aleutian;Aleutian Islands;-;10;;"
wts[9]="Alexandria;Egypt - EG;+;2;;"
wts[10]="Algiers;Algeria - DZ;+;0;;"
wts[11]="Amsterdam;Netherlands - NL;+;1;;"
wts[12]="Anadyr; Russia - RU;+;13;;"
wts[13]="Anchorage;Alaska - USA - US;-;9;;"
wts[14]="Ankara;Turkey - TR;+;2;;"
wts[15]="Antananarivo; Madagascar - MG;+;3;;"
wts[16]="Antwerp;Belgium - BE;+;0;;"
wts[17]="Asuncion *;Paraguay - PY;-;3;;"
wts[18]="Athens;Greece - GR;+;2;;"
wts[19]="Atlanta;Georgia - USA - US;+;5;;"
wts[20]="Auckland *;New Zealand - NZ;+;12;;"
wts[21]="Aveiro;Portugal - PT;+;0;;"
wts[22]="Baghdad;Iraq - IQ;+;3;;"
wts[23]="Bamako;Mali - ML;+;0;;"
wts[24]="Bandar Seri Begawan;Brunei - BN;+;8;;"
wts[25]="Bangkok;Thailand - TH;+;7;;"
wts[26]="Bangui;Central African Republic - CF;+;1;;"
wts[27]="Banjul;Gambia - GM;+;1;;"
wts[28]="Barcelona;Spain - ES;+;1;;"
wts[29]="Barranquilla;Colombia - CO;-;5;;"
wts[30]="Beijing;China - CN;+;8;;"
wts[31]="Beirut;Lebanon - LB;+;2;;"
wts[32]="Belgrade;Serbia - YU;+;1;;"
wts[33]="Belize City;Belize - BZ;-;5;;"
wts[34]="Berlin;Germany - DE;+;1;;"
wts[35]="Blantyre;Malawi - MW;+;2;;"
wts[36]="Bogota;Colombia - CO;-;5;;"
wts[37]="Bologna;Italy - IT;+;2;;"
wts[38]="Bombay - Mumbai;India - IN;+;6;;"
wts[39]="Brasilia;Brazil - BR;-;3;;"
wts[40]="Bratislava;Slovak Republic - SK;+;1;;"
wts[41]="Brazzaville;Congo - CG;+;0;;"
wts[42]="Bridgetown;Barbados - BB;-;4;;"
wts[43]="Brisbane;Queensland - Australia - AU;+;10;;"
wts[44]="Brussels;Belgium - BE;+;1;;"
wts[45]="Bucharest;Romania - RO;+;2;;"
wts[46]="Budapest;Hungary - HU;+;1;;"
wts[47]="Buenos Aires;Argentina - AR;-;3;;"
wts[48]="Bujumbura;Burundi - BI;+;2;;"
wts[49]="Cairo;Italy - IT;+;2;;"
wts[50]="Calcutta;India - IN;+;6;;"
wts[51]="Calgary;Alberta - Canada - CA;-;6;;"
wts[52]="Cali;Colombia - CO;+;0;;"
wts[53]="Cape Town;South Africa - ZA;+;1;;"
wts[54]="Caracas;Venezuela - VE;-;4;;"
wts[55]="Cebu;Philippines - PH;+;8;;"
wts[56]="Chicago;Illinois - USA - US;-;6;;"
wts[57]="Christchurch;New Zealand - NZ;+;12;;"
wts[58]="Colombo;Sri Lanka - LK;+;5;30;"
wts[59]="Conakry;Guinea - GN;+;0;;"
wts[60]="Copenhagen;Denmark - DK;+;1;;"
wts[61]="Cotonou;Benin - BJ;+;0;;"
wts[62]="Dakar;Senegal - SN;+;0;;"
wts[63]="Dallas;Texas - USA - US;-;6;;"
wts[64]="Darwin;Northern Territory - Australia - AU;+;10;;"
wts[65]="Delhi;India - IN;+;5;30;"
wts[66]="Detroit;Michigan - USA - US;-;5;;"
wts[67]="Dhaka;Bangladesh - BD;+;6;;"
wts[68]="Djibouti;Djibouti - DJ;+;2;;"
wts[69]="Dover;Delaware - USA - US;-;5;;"
wts[70]="Dubai;United Arab Emirates - AE;+;3;;"
wts[71]="Dublin;Ireland - IE;+;0;;"
wts[72]="Dusseldorf;Germany - DE;+;1;;"
wts[73]="Edmonton;Alberta - USA - US;-;7;;"
wts[74]="Fairbanks;Alaska - USA - US;-;9;;"
wts[75]="Florence;Italy - IT;+;2;;"
wts[76]="Fort de France;Martinique - MQ;-;4;;"
wts[77]="Frankfurt;Germany - DE;+;1;;"
wts[78]="Freetown;Sierra Leone - SL;+;0;;"
wts[79]="Gaborone;Botswana - BW;+;1;;"
wts[80]="Geneva;Switzerland - CH;+;1;;"
wts[81]="Gibraltar;Spain - ES;+;1;;"
wts[82]="Glasgow;England - GB;+;0;;"
wts[83]="GMT;GMT - ;+;0;;"
wts[84]="Guatemala City;Guatemala - GT;-;6;;"
wts[85]="Guayaquil;Ecuador - EC;-;5;;"
wts[86]="Hamilton;Bermuda - GM;-;4;;"
wts[87]="Harare;Zimbabwe - ZW;+;2;;"
wts[88]="Havana;Cuba - CU;-;5;;"
wts[89]="Helsinki;Finland - FI;+;2;;"
wts[90]="Hobart;Tasmania - Australia - AU;+;10;;"
wts[91]="Hong Kong;Hong Kong - HK;+;8;;"
wts[92]="Honolulu;Hawaii - US;-;10;;"
wts[93]="Indianapolis;Indiana - USA - US;-;5;;"
wts[94]="Ipswich;Queensland - Australia - AU;+;10;;"
wts[95]="Islamabad;Pakistan - PK;+;5;;"
wts[96]="Istanbul;Turkey - TR;+;2;;"
wts[97]="Jakarta;Indonesia - ID;+;7;;"
wts[98]="Jerusalem;Israel - IL;+;2;;"
wts[99]="Johannesburg;South Africa - ZA;+;2;;"
wts[100]="Kabul;Afghanistan - AF;+;5;;"
wts[101]="Kaduna;Nigeria - NG;+;0;;"
wts[102]="Kahira;Egypt - EG;+;2;;"
wts[103]="Kamchatka;Russia - RU;+;11;;"
wts[104]="Kano;Nigeria - NG;+;1;;"
wts[105]="Karachi;Pakistan - PK;+;5;;"
wts[106]="Kathmandu;Nepal - NP;+;6;;"
wts[107]="Kiev;Ukraine - UA;+;3;;"
wts[108]="Kigali;Rwanda - RW;+;1;;"
wts[109]="Kingston;Jamaica - JM;-;5;;"
wts[110]="Kinshasa;Zaire - ZR;+;1;;"
wts[111]="Kobe;Japan - JP;+;9;;"
wts[112]="Kosice;Slovak Republic - SK;+;1;;"
wts[113]="Kuala Lumpur;Malaysia - MY;+;8;;"
wts[114]="Kuwait City;Kuwait - KW;+;3;;"
wts[115]="Kyoto;Japan - JP;+;9;;"
wts[116]="La Paz;Bolivia - BO;-;5;;"
wts[117]="Lagos;Nigeria - NG;+;1;;"
wts[118]="Libreville;Gabon - GA;+;0;;"
wts[119]="Lima;Peru - PE;-;5;;"
wts[120]="Limon;Costa Rica - CR;-;5;;"
wts[121]="Lisbon;Portugal - PT;+;0;;"
wts[122]="Lome;Togo - TO;+;0;;"
wts[123]="London;England - UK - GB;+;0;;"
wts[124]="Los Angeles;California - USA - US;-;8;;"
wts[125]="Lubumbashi;Zaire - ZR;+;1;;"
wts[126]="Luxembourg;Luxembourg - LU;+;1;;"
wts[127]="Madrid;Spain - ES;+;1;;"
wts[128]="Manama;Bahrain - BH;+;3;;"
wts[129]="Manila;Philippines - PH;+;8;;"
wts[130]="Maracaibo;Venezuela - VE;-;5;;"
wts[131]="Maseru;Lesotho - LS;+;2;;"
wts[132]="Mayaguez;Puerto Rico - PR;-;4;;"
wts[133]="Mbabane;Swaziland - SZ;+;2;;"
wts[134]="Medan;Indonesia - ID;+;8;;"
wts[135]="Medellin;Colombia - CO;-;5;;"
wts[136]="Melbourne *;Victoria - Australia - AU;+;10;;"
wts[137]="Mexico City;Mexico - MX;-;6;;"
wts[138]="Milan;Italy - IT;+;1;;"
wts[139]="Mogadishu;Somalia - SO;+;3;;"
wts[140]="Mombasa;Kenya - KE;+;3;;"
wts[141]="Monrovia;Liberia - LR;+;0;;"
wts[142]="Monte Carlo;Monaco - MC;+;1;;"
wts[143]="Montevideo;Uruguay - UY;-;3;;"
wts[144]="Montreal;Quebec - Canada - CA;-;5;;"
wts[145]="Morgantown;West Virginia - USA - US;-;5;;"
wts[146]="Moscow;Russia - RU;+;3;;"
wts[147]="Mumbai - Bombay;India - IN;+;5;30;"
wts[148]="Munich;Germany - DE;+;1;;"
wts[149]="Murmansk;Rusia - RU;+;2;;"
wts[150]="Muscat;Oman - OM;+;3;;"
wts[151]="N'Djamena;Chad - TD;+;0;;"
wts[152]="Nagasaki;Japan - JP;+;9;;"
wts[153]="Nagoya;Japan - JP;+;9;;"
wts[154]="Nairobi;Kenia - KE;+;3;;"
wts[155]="Naples;Italy - IT;+;1;;"
wts[156]="Nassau;Bahamas - BS;-;5;;"
wts[157]="New Hebrides;New Hebrides - US;+;11;;"
wts[158]="New York City;New York - USA - US;-;5;;"
wts[159]="Newfoundland;Newfoundland - Canada - CA;-;3;;"
wts[160]="Niamey;Niger - NE;+;0;;"
wts[161]="Nice;France - FR;+;1;;"
wts[162]="Nicosia;Cyprus - CY;+;2;;"
wts[163]="Nome;Alaska - USA - US;-;9;;"
wts[164]="Nottingham;England - UK - GB;+;0;;"
wts[165]="Nouakchott;Mauritania - MR;+;0;;"
wts[166]="Nuk;Greenland - GL;-;3;30;"
wts[167]="Odessa;Ukraine - UA;+;3;;"
wts[168]="Oran;Algeria - DZ;+;0;;"
wts[169]="Osaka;Japan - JP;+;9;;"
wts[170]="Oslo;Norway - NO;+;1;;"
wts[171]="Ottawa;Ontario - Canada - CA;-;5;;"
wts[172]="Ouagadougou;Burkina Faso - BF;+;0;;"
wts[173]="Oulu;Finland - FI;+;2;;"
wts[174]="Oxford;England - UK - GB;+;0;;"
wts[175]="Palma;Mallorca - ES;+;1;;"
wts[176]="Panjim;Goa - India - IN;+;5;30;"
wts[177]="Paramaribo;Suriname - SR;-;4;;"
wts[178]="Paris;France - FR;+;1;;"
wts[179]="Peking;China - CN;+;8;;"
wts[180]="Perth;Western Australia - Australia - AU;+;8;;"
wts[181]="Phoenix;Arizona - USA - US;-;7;;"
wts[182]="Ponce;Puerto Rico - PR;-;4;;"
wts[183]="Port Louis;Mauritius - MU;+;4;;"
wts[184]="Port Moresby;Papua New Guinea - PG;+;10;;"
wts[185]="Port of Spain;Trinidad and Tobago - TT;-;4;;"
wts[186]="Prague;Czech Republic - CZ;+;1;;"
wts[187]="Praia;Cape Verde - CV;-;2;;"
wts[188]="Puntarenas;Costa Rica - CR;-;5;;"
wts[189]="Quebec;Quebec - Canada - CA;-;5;;"
wts[190]="Quito;Ecuador - EC;-;5;;"
wts[191]="Rangoon;Barma - ;+;7;;"
wts[192]="Reykjavik;Iceland - IS;-;1;;"
wts[193]="Riga;Latvia - LW;+;4;;"
wts[194]="Rio de Janeiro;Brazil - BR;-;3;;"
wts[195]="Riyadh;Saudi Arabia - SA;+;3;;"
wts[196]="Rome;Italy - IT;+;1;;"
wts[197]="Saigon;Vietnam - VN;+;7;;"
wts[198]="Saint Petersburg - Leningrad;Russia - RU;+;3;;"
wts[199]="Salt Lake City;Utah - USA - US;-;7;;"
wts[200]="Salzburg;Austria - AU;+;1;;"
wts[201]="San Francisco;California - USA - US;-;8;;"
wts[202]="San Jose;Costa Rica - CR;-;6;;"
wts[203]="San Juan;Puerto Rico - PR;-;4;;"
wts[204]="Santa Cruz de Tenerife;Canarias Islands - ES;+;0;;"
wts[205]="Santiago *;Chile - CL;-;3;;"
wts[206]="Santo Domingo;Dominican Republic - DO;-;4;;"
wts[207]="Sao Paulo;Brazil - BR;-;3;;"
wts[208]="Sapporo;Japan - JP;+;9;;"
wts[209]="Sarajevo;Bosnia - BA;+;1;;"
wts[210]="Seattle;Washington - USA - US;-;8;;"
wts[211]="Seoul;South Korea - KR;+;9;;"
wts[212]="Shanghai;China - CN;+;8;;"
wts[213]="Singapore;Singapore - SG;+;8;;"
wts[214]="Sofia;Bulgaria - BG;+;2;;"
wts[215]="Stockholm;Sweden - SE;+;1;;"
wts[216]="Stuttgart;Germany - DE;+;1;;"
wts[217]="Surabaya;Indonesia - ID;+;7;;"
wts[218]="Suva;Fiji Islands - FJ;+;12;;"
wts[219]="Sydney *;New South Wales - Australia - AU;+;11;;"
wts[220]="Taipei;Thaiwan - TH;+;8;;"
wts[221]="Tallinn;Estonia - EE;+;2;;"
wts[222]="Tampere;Finland - FI;+;2;;"
wts[223]="Tashkent;Uzbekistan - UZ;+;3;;"
wts[224]="Tegucigalpa;Honduras --;5;;"
wts[225]="Tehran;Iran - IR;+;4;;"
wts[226]="Tel Aviv;Israel - IL;+;2;;"
wts[227]="Tokyo;Japan - JP;+;9;;"
wts[228]="Toronto;Ontario - Canada - CA;-;5;;"
wts[229]="Tripoli;Libya - LY;+;1;;"
wts[230]="Tunis;Tunisia - TN;+;1;;"
wts[231]="Turin;Italy - IT;+;1;;"
wts[232]="Ulanbatar;Mongolia - MN;+;8;;"
wts[233]="Valletta;Malta - MT;+;1;;"
wts[234]="Vancouver;British Columbia - Canada - CA;-;8;;"
wts[235]="Vatican;Vatican City - VA;+;1;;"
wts[236]="Venice;Italy - IT;+;1;;"
wts[237]="Victoria Falls;Zimbabwe - ZW;+;2;;"
wts[238]="Vienna;Austria - AT;+;1;;"
wts[239]="Vientiane;Laos - LA;+;7;;"
wts[240]="Vladimir;Russia - RU;+;3;;"
wts[241]="Vladivostok;Russia - RU;+;10;;"
wts[242]="Warsaw;Poland - PL;+;1;;"
wts[243]="Washington DC;Washington - USA - US;-;5;;"
wts[244]="Wellington *;New Zealand - NZ;+;12;;"
wts[245]="Winnipeg;Manitoba - Canada - CA;-;6;;"
wts[246]="Yalta;Ukraine - UA;+;3;;"
wts[247]="Zagreb;Croatia - HR;+;1;;"
wts[248]="Zaragoza;Spain - ES;+;1;;"
wts[249]="Zurich;Switzerland - CH;+;1;;"
//* means that the shown time has been adjusted due to local daylight saving.

var militime = 3600000;				// number of miliseconds in one hour
var GMTClockID = null;
var GMTClockRunning = false;
var TSCClockID = null;
var TSCClockRunning = false;
var GMT = "";						// holder for GMT time to tell if its ok to get time for selected city

function getdaydate(dateobject)		// function to get the monthly date of the day
{
	var daydate = dateobject.getDate();		// get the date
	
	if (daydate < 10)						// add in the extra zero if the date is before the 10th
		daydate = "0" + daydate;
		
	return daydate;							// send it back to the caller
}	// end the function to get the monthly date of the day

function getmonth(dateobject)		// function to get the month as a three character string
{	
	var month=dateobject.getMonth();	// use the date object to get the month
	return months[month];				// send the month back to the caller
}		// end get the month function

function getyear(dateobject)		// function to get the four digit year
{
	var year=dateobject.getFullYear();	// use the date object to get the four digit year
	return year;						// send the year back to the caller
}		// end get the year function

function getday(dateobject)			// function to get the three character day of the week
{
	var day=dateobject.getDay();	// use the day object to get the three character day of the week
	return days[day];				// send the day of week back to the caller
}	// end get the day of the week function

function gethours(dateobject, hourstring)	// function to get both the hour time and the am or pm setting
{
	if (hourstring == "")			// if the hours are not sent in
	{
		var hours=dateobject.getHours();	// get the hours (24 hours format) from the datestring
	}
	else							// otherwise
	{
		var hours = hourstring;		// use the hours sent in
	}
	
	var displayhours = new Object();	// create an object for the return variables
	displayhours.hours = "0";		// initialize the number of hours
	displayhours.night = "";		// initialize the am or pm indicator
	
	if (hours > 11)
	{	// if it is noon or later
		displayhours.night = "pm";	// set the am/pm indicator to night
		
		if (hours > 12)		// if it is past 12 noon
			displayhours.hours = hours - 12;	// reset the clock to use the 12 hour format
		else				// otherwise
			displayhours.hours = hours;		// use the hours as they are
	}	// end noon or later check
	else
	{	// if it is before noon
		displayhours.night = "am";	// set the am/pm indicator to daytime

		if ((hours < 10) && (hourstring == "")) // if it's before 10 and we didn't pass the hours in
			hours = "0" + hours;	// put the leading zero in front of the hours
			
		if (hours == 0)	// if it's in the 12 midnight hour
			displayhours.hours = "12";	// reset to the 12 hour clock
		else	// otherwise
			displayhours.hours = hours;	// use the hours value we have
	}	// end before noon check
	
	return displayhours;	// return object to caller
}	// end function to get hours and am/pm indicator

function getminutes(dateobject)	// function to get the minutes
{
	var minutes=dateobject.getMinutes();	// get number of minutes from date object
	
	if (minutes < 10)				// if we are under 10 minutes
		minutes = "0" + minutes;	// add the leading zero
		
	return minutes;		// return minutes to calling program
}	// end function to get minutes

function getseconds(dateobject)		// function to get the seconds
{
	var seconds=dateobject.getSeconds();	// get number of seconds from date object
	
	if (seconds < 10)				// if we are under 10 seconds
		seconds = "0" + seconds;	// add the leading zero
		
	return seconds;		// return seconds to calling program
}	// end function to get seconds

function endofmonth (monthname, year)	// function used to determine how many days in a month
{
	var days = 0;	// number of days to return
	
	switch (monthname.toUpperCase())
	{	// find the month
		case "JAN":	// january
		case "MAR":	// march
		case "MAY":	// may
		case "JUL":	// july
		case "AUG":	// august
		case "OCT":	// october
		case "DEC":	// december
			days = 31;	// all the above have 31 days
			break;
		case "APR":	// april
		case "JUN":	// june
		case "SEP":	// september
		case "NOV":	// november
			days = 30;	// the above four have 30 days
			break;
		case "FEB":	// ah!February
			if (year % 4 != 0)
            	days = 28;	// if the year is not divisible by four, it has 28 days
            else if (year % 400 == 0)
                days = 29;	// if the year is divisible by 400, it's a leap year
            else if (year % 100 == 0)
                days = 28;	// if the year is divisible by 100, but not 400, it has 28 days
            else
                days = 29;	// otherwise, it's a leap year
			break;
	}	// end month switch
	
	return days;	// return the number of days in the month
}	// end find number of days in a month

function changeday (currentday, direction)	// function used to increment or decrement the day of the week
{
	var arycnt = 0;		// subscript into days array above
	var newday = "";	// 3 character day of week string to return
	
	switch (currentday.toUpperCase())
	{	// switch on whatever day was passed in (the old day)
		case "SUN":	// Sunday
			arycnt = 0;	// set the array subscript to 0
			break;
		case "MON":	// Monday
			arycnt = 1;	// set the array subscript to 1
			break;
		case "TUE":	// Tuesday
			arycnt = 2;	// set the array subscript to 2
			break;
		case "WED":	// Wednesday
			arycnt = 3;	// set the array subscript to 3
			break;
		case "THU":	// Thursday
			arycnt = 4;	// set the array subscript to 4
			break;
		case "FRI":	// Friday
			arycnt = 5;	// set the array subscript to 5
			break;
		case "SAT":	// Saturday
			arycnt = 6;	// set the array subscript to 6
			break;
	}	// end switch on current day

	if (direction == "up")
	{	// if you are incrementing the day
		if (arycnt == 6)	// if the current array subscript is the end
			arycnt = 0;		// reset it to the beginning
		else				// otherwise
			arycnt = arycnt + 1;	// just increment the array subscript
	}	// end incrementing the day
	else
	{	// if we are decrementing the day
		if (arycnt == 0)	// if the current array subscript is the beginning
			arycnt = 6;		// reset it to the end
		else				// otherwise
			arycnt = arycnt - 1;	// just decrement the array subscript
	}	// end decrementing the day
		
	newday = days[arycnt];	// set up the new day
	return newday;	// send the new day back to the caller
}	// end function to increment or decrement the day

function changemonth (currentmonth, direction)	// function used to increment or decrement the month
{
	var arycnt = 0;		// index into the months array above
	var newmonth = "";	// 3 character month name to return to caller
	
	switch (currentmonth.toUpperCase())
	{	// switch on whatever month was passed in (the old month)
		case "JAN":		// january
			arycnt = 0;		// set the array index to 0
			break;
		case "FEB":		// february
			arycnt = 1;		// set the array index to 1
			break;
		case "MAR":		// march
			arycnt = 2;		// set the array index to 2
			break;
		case "APR":		// april
			arycnt = 3;		// set the array index to 3
			break;
		case "MAY":		// may
			arycnt = 4;		// set the array index to 4
			break;
		case "JUN":		// june
			arycnt = 5;		// set the array index to 5
			break;
		case "JUL":		// july
			arycnt = 6;		// set the array index to 6
			break;
		case "AUG":		// august
			arycnt = 7;		// set the array index to 7
			break;
		case "SEP":		// september
			arycnt = 8;		// set the array index to 8
			break;
		case "OCT":		// october
			arycnt = 9;		// set the array index to 9
			break;
		case "NOV":		// november
			arycnt = 10;	// set the array index to 10
			break;
		case "DEC":		// december
			arycnt = 11;	// set the array index to 11
			break;
	}	// end switch on current month

	if (direction == "up")
	{	// if we are increment the month
		if (arycnt == 11)	// if we are at the end of the months array
			arycnt = 0;		// start over at 0
		else				// otherwise
			arycnt = arycnt + 1;	// increment the month
	}	// end increment month check
	else
	{	// if we are decrementing the month
		if (arycnt == 0)	// if we are at the beginning of the months array
			arycnt = 11;	// go to the end of the array at 11
		else				// otherwise
			arycnt = arycnt - 1;	// decrement the months array index
	}	// end decrement month check
		
	newmonth = months[arycnt];	// put the 3 character representation of the new month in the return variable
	return newmonth;	// return the name of the new month to the caller
}	// end function to increment and decrement the month

function getNextDateElement(datestring, spanner, starting)
{	// function to parse a datestring and get each piece
	var elementdata = new Object();	// object to hold return values
	elementdata.data = "";		// return value for parsed out data
	elementdata.ending = 0;		// zero based index the parsed string ended on (for next parse)
	
	elementdata.ending = datestring.indexOf(spanner, starting);	// span the string to find where the end of the substring should be
	
	if (elementdata.ending == -1)	// if we've gone to the end of the string then 
		elementdata.data = datestring.substring (starting, (datestring.length));	// get the rest of the string as the substring
	else		// otherwise
		elementdata.data = datestring.substring (starting, (elementdata.ending));	// end where we determined the end to be earlier
	
	return elementdata;	// return the object to the caller
}	// end the function to parse a date string

function getAddedCityTime (addhrs, addmins, day, daydate, month, year, hours, mins, secs)
{  // function for adding time to GMT for a designated city
	var finaldata = new Object;		// create the object to return to caller
	finaldata.datestring = "";		// altered datestring to return as part of object
	finaldata.timestring = "";		// altered timestring to return as part of object
	var daysinmonth = "";			// variable to hold how many days in the selected month
	var night = "";					// variable used to hold either am or pm
	var themins = mins;				// variable for minutes
	var thehours = hours;			// variable for hours
	var thesecs = secs;				// variable for seconds
	var theday = day;				// variable for day of week
	var thedaydate = daydate;		// variable for date of day of week
	var themonth = month;			// variable for month
	var theyear = year;				// variable for 4 digit year
	
	if (addmins > 0)	// if we have minutes to add for the new time
		themins = (themins * 1) + (addmins * 1);	// add the minutes
		
		/******** SPECIAL NOTE *******
		/ due to the way javascript handles the precedence of addition and concatenation and
		/ the way it handle variables (you never have to declare a type), the above workaround
		/ is used to make sure that addition is called on the variables and not concatenation.
		/ This is CRUCIAL!!!!!!
		******* END SPECIAL NOTE *****/
		
	if (themins > 59)
	{ 	// if we are into the next hour after we add the minutes
		themins -= 60;	// reset the minutes by subtracting 60 from them
		thehours = (thehours * 1) + (1);	// increment the hours
	}	// end into the next hour check

	if (themins < 10)				// if the minutes are less than 10
		themins = "0" + themins;	// add in the leading 0
	
	if (addhrs > 0)					// if we need to add hours
		thehours = (thehours * 1) + (addhrs * 1);	// add the hours in
		
	if (thehours > 23)
	{	// if we are into the next day after adding the minutes and hours
		thehours = thehours - 24;	// reset the hours by subtracting 24
		thedaydate = (thedaydate * 1) + (1);	// increment the date
		theday = changeday(theday, "up"); // increment the day of the week
	}	// end the check for being into the next day
	
	if (thehours > 11)
	{	// now that we have changed are hour, are we past 11am?
		thehours = thehours - 12;	// if we arem then switch to a 12 hour clock
		night = "pm";	// set the day/night indicator to night
	}	// end nighttime check
	else
	{	// otherwise, no need to change hours scale
		night = "am";	// set day/night indicator for day
	}	// end otherwise morning check
	
	if (thehours < 10)	// if our hours are below 10
		thehours = "0" + thehours;	// tack on the leading 0

	if (thedaydate > (daysinmonth = endofmonth (themonth, theyear)))
	{	// if we have moved into the next month as a result of adding time
		thedaydate = "01";	// set the day date to the first of the month
		themonth = changemonth(themonth, "up");	// move the month up
		
		if (themonth == "Jan")	// if this caused us to move into the next year
			theyear = (theyear * 1) + (1);	// move it up
	}

	finaldata.datestring = theday + " " + thedaydate + " " + themonth + ", " + theyear;	// put it all together for the date string to return
	finaldata.timestring = thehours + ":" + themins + ":" + thesecs + " " + night;	// put it all together for the time string to return
	return finaldata;	// send the return data object back to the caller
}	// end function for adding time to GMT for the selected city

function getSubtractedCityTime (addhrs, addmins, day, daydate, month, year, hours, mins, secs)
{	// function for subtracting time from GMT for the selected city
	var finaldata = new Object;	// create the object to return to the caller
	finaldata.datestring = "";	//  altered datestring to return as part of object
	finaldata.timestring = "";	// altered timestring to return as part of object
	var daysinmonth = "";		// variable to hold how many days in a month
	var night = "";				// variable to indicate night or day
	var theday = day;			// variable to hold the day of the week as a 3 character string
	var thedaydate = daydate;	// variable to hold the month date for the day of the week
	var themonth = month;		// variable to hold the month as a 3 character string
	var theyear = year;			// variable to hold the full four digit year
	var thehours = hours;		// variable to hold the hours for the time
	var themins = mins;			// variable to hold the minutes for the time
	var thesecs = secs;			// variable to hold the seconds for the time
	
	themins = mins - addmins;	// subtract any minutes needed

	if (themins < 0)
	{	// if the subtraction gives us a number of minutes below zero
		themins = 60 - abs(themins);	// reset the number to a positive number of minutes on the clock
		thehours = thehours - 1;	// subtract one from the hours
	}	// end if negative result check
	
	if (themins < 10)	// if number of minutes is less than ten
		themins = "0" + themins;	// add in leading zero
		
	thehours = thehours - addhrs;	// if we have hours to subtract from GMT for the city, do it
	
	if (thehours < 0)
	{	// if the subtraction puts us below zero
		thehours = 24 - abs(thehours);		// reset hours to a positive number
		thedaydate = thedaydate - 1;		// subtract one from the date
		theday = changeday(theday, "down");	// move the day of the week back one
	}	// end negative hours check
	
	if (thehours > 11)
	{	// if the hour are 12 or greater
		thehours = thehours - 12;	// switch to 12 hour clock
		night = "pm";	// set am/pm indicator to night
	}	// end hours 12 or over
	else
	{	// otherwise
		night = "am";	// set the indicator to morning
	}	// end otherwise
	
	if (thehours < 10)	// if hours are less than ten
		thehours = "0" + thehours;	// add leading 0

	if (thedaydate < 1)
	{	// if we are past the beginning of the month
		themonth = changemonth(themonth, "down");	// set the month to the previous month
		thedaydate = endofmonth(themonth, theyear);	// set the date to the last day of the previous month
		
		if (themonth == "Dec")	// if we've slipped into the previous year
			theyear = theyear - 1;	// subtract one from the year
	}	// end past start of month check
	
	finaldata.datestring = theday + " " + thedaydate + " " + themonth + ", " + theyear;	// set up date return string
	finaldata.timestring = thehours + ":" + themins + ":" + thesecs + " " + night;	// set up time return string
	return finaldata;	// return date and time string object to caller
}	// end function for subtracting time from GMT for selected city

function SystemClock()
{	// clock for current system time
	var datestring = "";	// variable to hold current system date
	var timestring = "";	// variable to hold current system time

	var now = new Date();	// get current local system time
  	var daydate = getdaydate(now);	// get the date (already padded, etc.)
  	var year = getyear(now);		// get the year
  	var displayhours = gethours(now, "");	// get the hours time to display
  	var minutes = getminutes(now);	// get the minutes (already padded, etc.)
	var seconds = getseconds(now);	// get the seconds (already padded, etc.)
	var month = getmonth(now);		// get the month (already as a string)
	var day = getday(now);			// get the day of the week (already as a string)
		
  	datestring = day + ", " + daydate + " " + month + ", " + year;	// put together the date string to display
    timestring = displayhours.hours + ":" + minutes + ":" + seconds + " " + displayhours.night;	// put together the timestring to display
    document.clockform.yourdate.value = datestring;	// show the datestring in the datestring text field
    document.clockform.yourtime.value = timestring;	// show the timestring in the timestring text field
	
    id = setTimeout("SystemClock()",1000);			// recalls this function every second to get new time
}	// end current system clock time function

function GMTClock()
{	// displays GMT time and date (yes, as in for Grennwich Mean Time)
  	var now = new Date();	// get current local system time
	var GMTString = now.toUTCString();	// get GMT time as a string
	var commaspan = ", ";		// what to search for when parsing the GMT date string the first time
	var datespanchar = " ";		// what to search for when parsing the rest of the GMT date string
	var timespanchar = ":";		// what to search for when parsing the time portion of the GMT date string
	var datestring = "";		// the completed date portion of the string when assembled
	var timestring = "";		// the completed time portion of the string when assembled

	retval = getNextDateElement (GMTString, commaspan, 0);	// parse out the day of the week
	var day = retval.data;

	retval = getNextDateElement (GMTString, datespanchar, (retval.ending + 2));	// parse out the date of the month
	var daydate = retval.data;

	retval = getNextDateElement (GMTString, datespanchar, (retval.ending + 1));	// parse out the month
	var month = retval.data;
	
	retval = getNextDateElement (GMTString, datespanchar, (retval.ending + 1));	// parse out the year
	var year = retval.data;
	
	retval = getNextDateElement (GMTString, timespanchar, (retval.ending + 1));	// parse out the hour
	var hour = retval.data;
	
	retval = getNextDateElement (GMTString, timespanchar, (retval.ending + 1));	// parse out the minutes
	var minutes = retval.data;
	
	retval = getNextDateElement (GMTString, datespanchar, (retval.ending + 1));	// parse out the seconds
	var seconds = retval.data;
	
	var displayhours = gethours("", hour);	// take the hours you parsed and format it, also determine am or pm
	
  	datestring = day + ", " + daydate + " " + month + ", " + year;		// set up datestring to display
    timestring = displayhours.hours + ":" + minutes + ":" + seconds;	// set up timestring 
	displaytimestring = timestring + " " + displayhours.night;			// set up timestring to display
    document.clockform.gmtdate.value = datestring;						// put datestring in its text field
    document.clockform.gmttime.value = displaytimestring;				// put imestring in its text field
	GMT = datestring + " " + timestring + "GMT";						// Set up global GMT string
  	stopGMTClock();														// Stop the GMT clock from running
	GMTClockID = setTimeout("GMTClock()", 1000);						// Set timer to wait for a sevond before restarting
	GMTClockRunning = true;												// tell user the timer is running
}	// end function to display GMT time

function yourcity(si)
{		// function used to find your city selected and time difference between local and GMT
	var offset = "";	// variable used to tell if city is plus or minus time to GMT
	var addhrs = "";	// hours to add or subtract to get GMT
	var addmin = "";	// minutes to add or subtract to get GMT
	
  	if (si != 0)
	{	// if a city was picked
    	offset = GetField(wts[si], 3);		// read plus or minus time
		addhrs = GetField(wts[si], 4);		// read hours to add or subtract

		if(GetField(wts[si], 5) != "")
		{	// if find minutes in array wts converts minutes to portion of an hour for later conversion to miliseconds
	  		addmin = (GetField(wts[si], 5) / 60);
		}
		else
		{	// otherwise, we have no additional minutes
			addmin = 0;
		}

		addtime = (militime * addhrs) + (militime * addmin); 	// figure total time to adjust
		stopTSCClock();	// stop the running city clock
		document.clockform.citydate.value = "";		// clear out date field on screen for city
		document.clockform.citytime.value = "";		// clear out time field on screen for city
		GMTClock();		// run the GMT time
  	}
  	else
	{	// if no city was picked
    	stopGMTClock();							// stop the GMT clock
		document.clockform.gmtdate.value = "";	// clear out the GMT date field on screen
		document.clockform.gmttime.value = "";	// clear out the GMT time field on screen
		stopTSCClock();							// stop the city clock
		document.clockform.citydate.value = "";	// clear out the city date field on screen
		document.clockform.citytime.value = "";	// clear out the city time field on screen
  	}	// end if no city was picked
}	// end function to find time difference information for selected city

function TSCClock()
{		// displays time in selected city
	var today = new Date();		// get current local date
	var GMTDateString = today.toUTCString();	// store GMT date
	var commaspan = ", ";	// what to search for when parsing the GMT date string the first time
	var datespanchar = " ";	// what to search for when parsing the rest of the GMT date string
	var timespanchar = ":";	// what to search for when parsing the time portion of the GMT date string
	var datestring = "";	// the completed date portion of the string when assembled
	var timestring = "";	// the completed time portion of the string when assembled

	theValues = getNextDateElement (GMTDateString, commaspan, 0);	// parse out the day of the week
	var day = theValues.data;

	theValues = getNextDateElement (GMTDateString, datespanchar, (theValues.ending + 2));	// parse out the date of the month
	var daydate = theValues.data;

	theValues = getNextDateElement (GMTDateString, datespanchar, (theValues.ending + 1));	// parse out the month
	var month = theValues.data;
	
	theValues = getNextDateElement (GMTDateString, datespanchar, (theValues.ending + 1));	// parse out the four digit year
	var year = theValues.data;
	
	theValues = getNextDateElement (GMTDateString, timespanchar, (theValues.ending + 1));	// parse out the hour
	var hour = theValues.data;
	
	theValues = getNextDateElement (GMTDateString, timespanchar, (theValues.ending + 1));	// parse out the minutes
	var minutes = theValues.data;
	
	theValues = getNextDateElement (GMTDateString, datespanchar, (theValues.ending + 1));	// parse out the seconds
	var seconds = theValues.data;

	if (offset == "+")	// if we are adding time to GMT, do it
		outputstrings = getAddedCityTime (addhrs, addmin, day, daydate, month, year, hour, minutes, seconds);	
	else	// if we are subtracting time from GMT, do it
		outputstrings = getSubtractedCityTime (addhrs, addmin, day, daydate, month, year, hour, minutes, seconds);
		
  	datestring = outputstrings.datestring;	// put together the datestring for display
    timestring = outputstrings.timestring;	// put together the timestring for display
    document.clockform.citydate.value = datestring;		// display the datestring
    document.clockform.citytime.value = timestring;		// display the timestring
  	stopTSCClock();										// stop the city time clock
	TSCClockID = setTimeout("TSCClock()", 1000);		// calls the clock every second for display
	TSCClockRunning = true;								// the city clock is running
}	// end function to display time in selected city

function timecity (si)
{	// function to get city selected and time difference between it and GMT
	if (si != 0 && GMT != "")
	{	// if there is a city selected and we have gotten GMT, continue processing
    	offset = GetField(wts[si], 3);		// offset to GMT from array wts
		addhrs = GetField(wts[si], 4);		// hour time difference between city and GMT

		if (GetField(wts[si], 5) != "")
		{	// if find minutes in array wts converts minutes to milisecs
	  		addmin = (GetField(wts[si], 5) / 60);
		}	// end minutes difference check
		else
		{	// otherwise, there are no minutes to add
			addmin=0;
		}	// end no minutes to add

		addtime = (militime * addhrs) + (militime * addmin);	// get total time to add to GMT
		TSCClock();	// start the clock and display the chosen city's time
  	}	// end city selected and GMT exists check
  	else
	{	// no city selected or GMT not gotten yet
    	stopTSCClock();	// stop the city clock
		document.clockform.citydate.value = "";	// clear the city date field
		document.clockform.citytime.value = "";	// clear the city time field
		alert("Please choose the city to get the time for.");	// tell them to choose a city
		document.clockform.timesel.options[0].selected = true;	// select the directions message in the drop down
		document.clockform.timesel.focus();	// set the focus to the time city selector
  	}
}

function stopGMTClock()
{	// function to stop GMT time
  	if(GMTClockRunning)
	{	// make sure we're running before we try to stop it
		clearTimeout(GMTClockID);	// clear the timeout
		GMTClockRunning = false;	// we're not running now
	}	// end are we running check 
}	// end function to stop GMT clock

function stopTSCClock()
{	// function to stop the city timer
  	if(TSCClockRunning)
	{	// make sure we are running before we try to stop it
		clearTimeout(TSCClockID);	// clear the timeout
		TSCClockRunning = false;	// we're not running now
	}	// end are we running check
}

function GetField(Entry, number)
{	// parse fields from wts city array
  	var fielddata = "";	// variable to hold data requested
  	var firstchar;		// place to begin spanning
  	var lastchar;		// place to stop spanning
  
  	firstchar = 0;		// initialize first character to span index
  	lastchar = Entry.indexOf(Separator);	// find the last character to span
  
  	if(number == 1)	// if we want the first field
    	fielddata += Entry.substring(firstchar, lastchar);	// get it
  	else if(number == Fields)	// if we want the last field
    	fielddata += Entry.substring(Entry.lastIndexOf(Separator) + 1, Entry.length);	// get it
	else  
	{	// otherwise, we want a middle field
   		for (var i = 2; i <= number; i++)
   		{	// keep going until we find the field we want
   			firstchar = lastchar + 1;	// get the field beginning with the character after the end of the last field gotten
 			lastchar = Entry.indexOf(Separator, firstchar);		// get the end index
  		}

		fielddata += Entry.substring(firstchar, lastchar);	// get the data
	}	// end getting a middle section
	
  	return fielddata;	// return the data to find
}	// end parsing field function

function writecities (choicestring, fieldname)
{			// writes city list from array wts
	if (fieldname == "gmtsel")
	{	// we are working with the first dropdown
		document.writeln('<select name="gmtsel" class="clockcitychooser" onchange="yourcity(selectedIndex)">');
	}	// end working with the first dropdown

	if (fieldname == "timesel")
	{	// we are working with the second dropdown
		document.writeln('<select name="timesel" class="clockcitychooser" onchange="timecity(selectedIndex)">');
	}	// end working with the second dropdown
	
	document.writeln('<option value="0" class="clockcitychooser">' + choicestring + '</option>');	// set up direction element in dropdown

	for (var count = 1; count < wts.length; count++)
	{	// fill in the list of cities for whichever dropdown needs it
		document.writeln("<option value='" + count + "'" + " class='clockcitychooser'>" + GetField(wts[count], 1) + " - " + GetField(wts[count], 2) + "</option>");
	}
	
	return;	// return to caller
}	// end function to write city list for dropdowns
