var weekdays = new Array(7);
weekdays[0]="Sunday";
weekdays[1]="Monday";
weekdays[2]="Tuesday";
weekdays[3]="Wednesday";
weekdays[4]="Thursday";
weekdays[5]="Friday";
weekdays[6]="Saturday";

function dateToString(dte)
{
	return weekdays[dte.getDay()] + ' ' + dte.toLocaleTimeString();
}

function isDaylightSavings()
{
	// This function returns whether or not it is Daylight savings in the northern hemisphere
	// It is not accurate to the day as daylight savings start on the first Sunday of April
	// and finishes on the last Sunday of October
	var today = new Date();
	var m = today.getUTCMonth() + 1;
	return (m >= 4 && m <=10);
}

function addHours(dte, hours)
{
	dte.setTime(dte.getTime() + (1000*60*60*hours));
}

function addMinutes(dte, minutes)
{
	dte.setTime(dte.getTime() + (1000*60*minutes));
}

function setClockTime(clockName, dte) {
    var activeClock = document.getElementById(clockName);
    if (activeClock != null) activeClock.innerHTML = dateToString(dte);
}

function updateClocks() 
{
	var now = new Date();
	addMinutes(now, now.getTimezoneOffset()); // set to utc time
	

	
	if(isDaylightSavings()) 
		addHours(now, 0);
	else
	    addHours(now, 0);

	setClockTime("londonclock", now);
	
	if(isDaylightSavings()) 
		addHours(now, 10);
	else
	    addHours(now, 10);

	setClockTime("brisbaneclock", now);

	setTimeout('updateClocks()',500);
}
