function updateClock()
{
	var clientTime = new Date();
  	var currentTime = new Date(clientTime.getTime()+offset);

 	var loadEpoch    = loadTime.getTime();
  	var currentEpoch = currentTime.getTime();

  	var pageage = currentEpoch - loadEpoch;

  	//if (pageage > 1000*60) window.location.reload(); // Reload

	var currentHours   = currentTime.getHours ( );
  	var currentMinutes = currentTime.getMinutes ( );
  	var currentSeconds = currentTime.getSeconds ( );

 	currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  	currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
  	currentHours   = ( currentHours == 0 ) ? 12 : currentHours;

  	var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;
  	document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

function reloadpage()
{
	window.location.reload();
}


function maximiseWindow()
{
	window.screenX = 0;
	window.screenY = 0;
	window.innerWidth = screen.width;
	window.innerHeight = screen.height;
	alwaysLowered = false;
}

function updateCountdown()
{
	var clientTime = new Date();
	var currentTime = new Date(clientTime.getTime()+offset);
  	var currentEpoch = currentTime.getTime();

	var diff = talkEpoch - currentEpoch;

	var sign = (diff > 0) ? "-" : ""; 
	if (diff < 0) diff = -diff;

	diff = diff / 1000;	
	var currentHours   = Math.floor(diff / 3600);
	diff = diff - 3600 * currentHours;
	var currentMinutes = Math.floor(diff / 60);
	diff = diff - 60 * currentMinutes;
  	var currentSeconds = Math.round(diff);

 	currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  	currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  	var currentTimeString = sign + currentHours + ":" + currentMinutes + ":" + currentSeconds;

	if (sign == "" && currentMinutes >= 15)
	{
		//maximiseWindow();
		currentTimeString = "<font color='red'>" + currentTimeString + " Question time</font>";
	}

  	//document.getElementById("countdown").firstChild.nodeValue = currentTimeString;
  	document.getElementById("countdown").innerHTML = currentTimeString;
}


