var timerID = null
var timerRunning = false

function stopclock()
{
	if(timerRunning)
		clearTimeout(timerID)
	timerRunning = false
}

function startclock()
{
	stopclock()
	showtime()
}

function showtime()
{
	var now = new Date()

	// Local
	var hours = now.getHours()
	var minutes = now.getMinutes()
	var seconds = now.getSeconds()
	var totsecs = hours*3600 + minutes*60 + seconds + (now.getTime() % 1000) / 1000

	// Decimal
	var dectime = totsecs
	var centidays = ((dectime - (dectime % 864)) / 864)
	var secs = (dectime - (dectime % 1) - (centidays * 864))

	// IDL
	var def = now.getTimezoneOffset()
	var idl = ((60 * now.getHours()) + (def - 720))
	if (idl < 0) idl = 1440 + idl
	idl = idl / 60
	totsecs = idl*3600 + minutes*60 + seconds + (now.getTime() % 1000) / 1000
	mtime = totsecs
	var globalcentidays = ((mtime - (mtime % 864)) / 864)
	var globalsecs = (mtime - (mtime % 1) - (globalcentidays * 864))

	// Create strings
	var localValue = ((centidays < 10) ? "0" : "") + centidays + ":"
	localValue += ((secs < 10) ? "0" : "") +((secs < 100) ? "0" : "") + secs + " LCST"

	var globalValue = ((globalcentidays < 10) ? "0" : "") + globalcentidays + ":"
	globalValue += ((globalsecs < 10) ? "0" : "") +((globalsecs < 100) ? "0" : "") + globalsecs + " GCST"

	document.local_cday_second_time.face.value = localValue
	document.global_cday_second_time.face.value = globalValue
	timerID = setTimeout("showtime()", 86)
	timerRunning = true
}
