function view_address()
{
	var address = document.getElementById("e").firstChild;
	var txt = address.nodeValue;

	txt = txt.replace("[at]", "@");
	txt = txt.replace("[dot]", ".");
	txt = txt.replace("[dot]", ".");

	address.nodeValue = txt;
	address.parentNode.setAttribute("href", "mailto:" + txt);
}

function calc_time(mtz, dst, stdz, dayz)
{
	var now = new Date();
	var second = now.getUTCSeconds();
	now.setUTCMinutes(now.getUTCMinutes() + (mtz + dst) * 60);
	var minute = now.getUTCMinutes();
	var hour = now.getUTCHours();
	var ampm = 'AM';
	var pad = ':';
	if (hour > 11) {
		ampm = 'PM';
		hour -= 12;
	}
	if (hour === 0) {
		hour = 12;
	}
	if (minute < 10) {
		pad += '0';
	}
	var txt = hour + pad + minute + ' ' + ampm + ' (';
	if (dst) {
		txt += dayz;
	}
	else {
		txt += stdz;
	}
	txt += ')';

	var time_in_adelaide = document.getElementById("time").firstChild;
	time_in_adelaide.nodeValue = txt;
	setTimeout('calc_time(' + mtz + ',' + dst + ',"' + stdz + '","' + dayz + '")', (60 - second) * 1000);
}

function view_time()
{
	var gmt = new Date();	// Today
	var fsa = new Date();	// First Sunday in April
	var fso = new Date();	// First Sunday in October

	fsa.setMonth(3);	// April
	fsa.setDate(7);
	var day = fsa.getDay();	// day of week of 7th April
	fsa.setDate(7 - day);	// first Sunday

	fso.setMonth(9);	// October
	fso.setDate(7);
	day = fso.getDay();	// day of week of 7th October
	fso.setDate(7 - day);	// first Sunday

	var dst = 0;		// Initialise the daylight saving flag
	if (gmt < fsa || gmt >= fso) {
		dst = 1;
	}

	calc_time(9.5, dst, 'ACST', 'ACDT');	// hours ahead of UTC, daylight saving flag, standard time indicator, DST indicator
}

window.onload = function()
{
	view_address();
	view_time();
};
