// Globals

var speed=1000;
var tid = 0;
var num=0;
var clockEl;
var offset;

// Refresh the date
function doDate(e)
{
    dt = new Date();
	
    if (offset != 0) {
      gt = dt.getTime();
      gt = gt + offset;
      dt.setTime(gt);
    }
	
	var ampm = dt.getUTCHours() < 12 ? ' am' : ' pm';
	dt = dt.toUTCString();
	dt = dt.substring(0,(dt.length-7));
    clockEl.value = dt + ampm;
  	tid=window.setTimeout("doDate()",speed);
}

// Start the date refresh process
function start(diff) {
  offset = (diff)*60*1000;
  tid=window.setTimeout("doDate()",speed);
}

// Clear the current clock timer
function cleartid() {
  window.clearTimeout(tid);
}

// Main clock intialisation function
function ServerClock()
{
	// Get the minutes to UTC value from the data form
	var intMinsToUTC = document.getElementById("intMinsToUTC").value;
	clockEl = document.getElementById("inputClock");
	if (!clockEl) return;
	// Start the clock refresh process
	start(intMinsToUTC);
}
