<!--
<!--
//=========== JavaScript International Time Calculator ===========
//=========== Copyright 1996 Ian Fennell (redlodge@gem.co.za) all rights reserved =========
//
// =========== Customizing this script ==========
// It's easy to change the locations displayed in the table or add new items to the listbox.
//
// To add a location you need to know its standard offset from GMT/UTC and 
//  if it observes Daylight Savings Time and what that period is (see below).
//
// The GMT offset and DST period are held in the listbox in this format:
//	"GMT offset%DST period" - the % is a separator.
//
// The GMT offset must be a value between 12 and -11 (you don't need a '+' for ahead of GMT).
// If the offset is not round hours, enter the minutes after a decimal point,
//	e.g. India (5 hours 30 mins ahead of GMT) = 5.30 
//
// The DST period should be one of the following, which are 'built into' this page:
//	0 - Daylight Savings never used, or have no info.
//	1 - Uncertain; they do or have in the past, but don't have definite info.
//	2 - DST from 1st Sun in April to Last Sun in October (USA/Canada)
//	3 - DST from Last Sun in March to Last Sun in October (UK/Europe/Russia)
//	4 - DST from Last Sun in October to Last Sun in March (Australia - NSW, Vic, ACT, SA)
//	5 - DST from 1st Sun in October to Last Sun in March (Australia - Tasmania)
//	6 - DST from 1st Sun in October to Third Sun in March (New Zealand)
//	7 - DST from Last Sun in March to 1st Sun in September ( - )
//
// ========== 7 is not Russia's DST period - CJN 11.10.01 =========
//
// (If you are sure of other DST periods and know JavaScript, they can be added to the 
//  function 'CheckDST' and also to the warning message script. Alternatively, you can
//  e-mail me so that I can update the page).
// 
// Customising the locations that appear in the main table on the page is simple.
//  Example: to add Italy the data would be stored as "1%3" as in the listbox;
//	<OPTION VALUE= "1%3">Italy
//  (standard time 1 hour ahead of GMT, Daylight Savings period 3 in list above)
//  Go to the === CUSTOMIZE TABLE === section and simply add the following line -
//	"1%3", "Italy",
//
// Simple! Of course you can delete any places you don't care much for.
//-->


<!--
	dstZones = new Array ();
	qReport = new Array ();
	TableTimes = new Array();
	currentQuery = null;

	var Local = new Date();
	var GMToffset = Local.getTimezoneOffset();

//	if (navigator.appName == "Netscape") {
//		if (GMToffset < 0) {GMToffset = Math.abs(GMToffset)}
//		else {GMToffset = GMToffset - (Math.abs(GMToffset) *2)};
//	};
	var newline= (navigator.appVersion.lastIndexOf('Win') != -1) ? "\r\n" : "\n";

// ========== Above unnecessary, erroneous results - CJN 9.10.01 ==========

function Into24hrs (time) {
	if ( time >= 1440)
		{ time -= 1440}
	else
		{ if ( time <0) { time = 1440 + time } };
	return time;
	}

function GMTnow (GMT) {
	var time = new Date();
	hrs = time.getHours();
	mins = time.getMinutes();
	GMT = (hrs*60 + mins) + GMToffset;
	GMT = Into24hrs(GMT);
	return GMT;
	}

// ========== Sign change, add above GMToffset - CJN 9.10.01 ==========

function formatRelative (time) {
	var Report = null;
	var Direction  = (time > 0) ? " ahead" : " behind";
	time = Math.abs (time);
	var Hours = Math.floor (time/60);
	var Mins = (time - Hours * 60);
	Report = Hours + "h ";
	if (Mins != 0) {Report=Report+Mins + "m "};
	Report = Report + Direction;
	if (time == 0) {Report="Same Time"};
	return Report;
	}; 

function formatTime (time) {
	var fHours = Math.floor (time/60) ;
	if (fHours <= 9) {fHours = "0" + fHours}; 
	var fMins = time - (fHours * 60);
	if (fMins <= 9) {fMins = "0" + fMins}; 
	var fTime = fHours + ":" + fMins;
	return fTime;
	};

function checkLeap (uYear) {
	if ( (uYear % 4 == 0 && uYear % 100 != 0) || uYear % 400 == 0 )
		{return true}
	else
		{return false};
	}

function TodayNumber (uMonth, uDate) {
	MonthDays = new Array (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334);
	var TodayNum = MonthDays [uMonth] + uDate;	
	return TodayNum;
	}

function CheckDST () {var uNow = new Date();
	var uMonth = uNow.getMonth();
	var uDate = uNow.getDate();
	var uDay = uNow.getDay();

//	var FirstSun8Feb = ( (uMonth == 1 && uDate > 14) || uMonth > 1 ) ? true : false;
//	if ((uMonth == 1)&&(uDate >= 8)) {
//		var DaysLeft = 14  - uDate;
//		FirstSun8Feb = (uDay + DaysLeft <= 6) ? true : false;
//		};

// ========== Above correct but unused - CJN 10.10.01 ==========

	var FirstSun15Mar = ( (uMonth == 2 && uDate > 21) || uMonth > 2 ) ? true : false;
	if ((uMonth == 2)&&(uDate >= 15)) {
		DaysLeft = 21  - uDate;
		FirstSun15Mar = (uDay + DaysLeft <= 6) ? true : false;
		};

	var LastSunMar = (uMonth > 2) ? true : false;
	if ((uMonth == 2)&&(uDate >= 25)) {
		DaysLeft = 31  - uDate;
		LastSunMar = (uDay + DaysLeft <= 6) ? true : false;
		};

	var FirstSunApr = ( (uMonth == 3 && uDate > 7) || uMonth > 3 ) ? true : false;
	if ((uMonth == 3)&&(uDate <= 7)) {
// x		var DaysGone = 7  - uDate;
// x		FirstSunApr = (uDay - DaysGone > 0) ? true : false;
		FirstSunApr = (uDay - uDate < 0) ? true : false;
		};

// ========== Above giving incorrect results - CJN 10.10.01 ==========

//	var FirstSunSep = ( (uMonth == 8 && uDate > 7) || uMonth > 8  ) ? true : false;
//	if (uMonth == 8 && uDate <= 7) {
//		FirstSunSep = (uDay - uDate < 0) ? true : false;
//		};

//	var LastSunSep = (uMonth > 8) ? true : false;
//	if ((uMonth == 8)&&(uDate >= 24)) {
//		DaysLeft = 30  - uDate;
//		LastSunSep = (uDay + DaysLeft <= 6) ? true : false;
//		};

	var FirstSunOct = ( (uMonth == 9 && uDate > 7) || uMonth > 9  ) ? true : false;
	if (uMonth == 9 && uDate <= 7) {
// x		DaysGone = 7  - uDate;
// x		FirstSunOct = (uDay - DaysGone > 0) ? true : false;
		FirstSunOct = (uDay - uDate < 0) ? true : false;
		};

//	var FirstSun15Oct = ( (uMonth == 9 && uDate > 21) || (uMonth > 9) ) ? true : false;
//	if ((uMonth == 9)&&(uDate >= 15)) {
//		DaysLeft = 21  - uDate;
//		FirstSun15Oct = (uDay + DaysLeft <= 6) ? true : false;
//		};

	var LastSunOct = (uMonth > 9) ? true : false;
	if ((uMonth == 9)&&(uDate >= 25)) {
		DaysLeft = 31  - uDate;
		LastSunOct = (uDay + DaysLeft <= 6) ? true : false;
		};

	dstZones[0] = "X";
	dstZones[1] = "?";
	dstZones[2] =  (FirstSunApr && !LastSunOct) ? "Y" : "N";    // usa/canada
	dstZones[3] =  (LastSunMar && !LastSunOct) ? "Y" : "N";     // uk/europe/russia
	dstZones[4] =  (LastSunOct || !LastSunMar) ? "Y" : "N";     // aus
	dstZones[5] =  (FirstSunOct || !LastSunMar) ? "Y" : "N";    // aus-tasmania
	dstZones[6] =  (FirstSunOct || !FirstSun15Mar) ? "Y" : "N"; // nz
//	dstZones[7] =  (LastSunMar && !FirstSunSep) ? "Y" : "N";

// ========== Correct Russia period same as uk/europe - CJN 10.10.01 ==========

	} 

function qHandler(ZoneData) {
	qReport[0] = ""; qReport[1] = ""; qReport[2] = ""; qReport[3] = "";	

	var qGMTparse = parseFloat(ZoneData);
	var qGMToffset_hrs = parseInt(qGMTparse, 10) ; 
	var qGMToffset_min= parseInt ( Math.round((qGMTparse-qGMToffset_hrs) * 100), 10);
	var qDSTperiod = ZoneData.charAt (ZoneData.length - 1);
	var qGMTperiod = 1440/60;
	if ( (qGMToffset_hrs > 12) || (qGMToffset_hrs <-11) ) {qReport[0] = "BAD DATA"; return};
	if (qDSTperiod > dstZones.length) {qReport[3] = "BAD DATA"};


	var relGMT = (qGMToffset_hrs * 60) + qGMToffset_min; 
	if (dstZones [qDSTperiod] == "Y") {relGMT += 60; qReport[3] = "Yes (+1 hour)"};
	if (dstZones [qDSTperiod] == "N") {qReport[3] = "Not currently"};
	if (dstZones [qDSTperiod] == "X") {qReport[3] = "n/a"};
	if (dstZones [qDSTperiod] == "?") {qReport[3] = "uncertain"};

	var qPlaceTotMins = GMTnow (qPlaceTotMins);
	qPlaceTotMins += relGMT; 
	qPlaceTotMins = Into24hrs (qPlaceTotMins);
	qReport[0] = qPlaceTotMins;

	qReport[2] = formatRelative (relGMT);

	var relLoc = relGMT + GMToffset;
	qReport[1] = formatRelative (relLoc);
	}

// ========== Sign change, add GMToffset in relLoc expression - CJN 9.10.01 ==========
// ==========  fix for relative times, Sydney 2h behind NZ not 22h ahead!   ==========

function qReply (ZoneData) {
	
	currentQuery = ZoneData;
	qHandler (ZoneData);
	document.Places.elements[0].value =
		"Current Time:  " + formatTime ( qReport[0] )
		+ newline + "Relative to Local:  "+ qReport[1] 
		+ newline + "Relative to GMT:  "+ qReport[2]
		+ newline + "Using Daylight Savings?  " + qReport[3]; 
	}


function writeTable () {

	cities = new Array (

// ============================ CUSTOMIZE TABLE =============================
// IMPORTANT! - No comma after last item in list! (the others must have one)

		"2%0", "Johannesburg",
		"10%4", "Sydney",
		"9%0", "Tokyo",
		"3%3", "Moscow",
		"1%3", "Paris",
		"0%3", "London",
		"-5%2", "New York"
		
// =========================================================================

		);

	document.write ("<P><CENTER>"
	+ "<TABLE WIDTH=700  BORDER=0  >"
	+ "<TR>"
	+ "<TD>&nbsp;"
	+ "<TD vAlign=top ALIGN=center><p><strong>Current Time</strong></p>"
	+ "<TD vAlign=top ALIGN=center><p><strong>Relative to Local</strong></p>"
	+ "<TD vAlign=top ALIGN=center><p><strong>Relative to GMT</strong></p>"
	+ "<TD vAlign=top ALIGN=center><p><strong>Daylight Savings?</strong></p>");

	for (var idx = 0; idx < cities.length; idx+=2) {

	var qGMTparse = parseFloat(cities[idx]);
	var qGMToffset_hrs = parseInt(qGMTparse, 10) ; 
	var qGMToffset_min= parseInt ( Math.round((qGMTparse-qGMToffset_hrs) * 100), 10);
	var qDSTperiod = cities[idx].charAt (cities[idx].length - 1);
	var relGMT = (qGMToffset_hrs * 60) + qGMToffset_min; 
	if (dstZones [qDSTperiod] == "Y") {relGMT += 60};
	TableTimes[idx/2] = relGMT;

	qHandler( cities[idx] );

	document.write ("<TR>"
	+ "<TD vAlign=top ALIGN=right><strong><p>" + cities[idx+1] + "</strong>&nbsp&nbsp" 
	+ "<TD vAlign=top ALIGN=center><p><INPUT TYPE=text SIZE=10></p>"
	+ "<TD vAlign=top ALIGN=center ><p>" + qReport[1] 
	+ "<TD vAlign=top ALIGN=center ><p>" + qReport[2]
	+ "<TD vAlign=top ALIGN=center ><p>" + qReport[3]);
		}; // for
	
	document.write ("</TABLE></CENTER></FORM>");
	} // ---- writeTable 


var timerID = null;
var timerRunning = false;
var id;

function stopclocks (){
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
	}

function showclocks () {
	var GMT = GMTnow (GMT);
	var fTime = formatTime ( Into24hrs (GMT - GMToffset) );
	document.Table.elements[0].value = "     "+ fTime; 
	var fTime = formatTime ( Into24hrs (GMT) ); 
	document.Table.elements[1].value = "     "+ fTime; 

	var TableClock = null;
	for (var idx = 2; idx <= TableTimes.length+1; idx++) {
		TableClock = null;
		TableClock += GMT+TableTimes[idx-2];
		document.Table.elements[idx].value = "     "+ formatTime ( Into24hrs ( TableClock ) );
		};

	if (currentQuery != null) {qReply (currentQuery)};

	timerID = setTimeout("showclocks()",1000);
	timerRunning = true;
	}

// ========== Sign change, subtract GMToffset in fTime expression - CJN 9.10.01 ==========

function startClocks () {
	document.Places.elements[0].value= newline + '   Other cities and countries...'
	stopclocks();
	showclocks();
	}

