<!--

/*
Clock display - show Melbourne time & date for all web users
31/10/06 Added daylight savings automatic adjustment for last Sunday in October & March 
Copyright Swe-Check P/L 2006
*/

var now;
var finaltime;
var hrs;
var	mins;
var	secs;
var	date;
var month;
var	year;
var	day;

function MelbourneTime()
{
	weekdays = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	ampm='';
	now=new Date();	//get local time & date
		
	zone=10;	//Melbourne GMT +10hrs
	ofst=now.getTimezoneOffset()/60;	//get difference between local time & GMT
	//change the time & date to Melbourne local time
	now.setHours((now.getHours() + parseInt(ofst)) + parseInt(zone));
		
	//get seperate components of date/time
	hrs=now.getHours();
	mins=now.getMinutes();
	secs=now.getSeconds();
	date=now.getDate();
	month=now.getMonth();
	month=month+1	//add one as month is from 0 to 11
	year=now.getYear();
	day=weekdays[now.getDay()];
	
	dsadj = DaylightSaving();
	hrs+= dsadj;	//add daylight savings adjustment to hours
		
	//format the answer into am/pm
	if(hrs>12)
	{	
		hrs=hrs-12;
		ampm="pm";
	}
	else
	{	
		ampm="am";	
	}
	
	//add zeroes if required to format correctly
	//if (hrs<10) hrs="0"+hrs;
	if (mins<10) mins="0"+mins;
	if (secs<10) secs="0"+secs;

	//setup the output string
	outputstr=hrs+':'+mins+':'+secs+' '+ampm+' '+day+', '+date+'/'+month+'/'+year;
	finaltime='(Local time is: ' + outputstr + ')';
	
	if (document.all)
		melbournetime.innerHTML=finaltime
	else if (document.getElementById)
		document.getElementById("melbournetime").innerHTML=finaltime
		else if (document.layers)
		{
			document.melbournetimens.document.melbournetimens2.document.write(finaltime)
			document.melbournetimens.document.melbournetimens2.document.close()
		}
	setTimeout('MelbourneTime()',1000);  //Keep updating the time
	
}

function DaylightSaving()
{
	ds_adj=0;
	if(month>3 && month<10) 
	{	//outside of daylight saving zone
		//alert("Outside of daylight saving zone");
		return ds_adj;	//exits function
	}
	if(month > 10 || month < 3 )
	{	//daylight saving adjustment does apply
		ds_adj = 1;
		//alert("Month is either Nov, Dec, Jan or Feb");
	}
	else
	{	//Month is October or March
		future=now;	  //get current time & date setting
		
		future.setDate("31");  //change the date to the end of this month
		futureday = future.getDay();  //get the day 
		dsdate = 31 - futureday; //calculate the date of the last sunday of the month
		if(month==10)
		{	//October
			if(date == dsdate)
			{	//last Sunday in the month of October	
				if(hrs > 2)
				{	//After 2am turn daylight saving on
					ds_adj= 1;
					//alert("After 2am in October");
				}
			}
			else
			{	if(date > dsdate)
				{	//passed last Sunday in October
					ds_adj= 1;
					//alert("Beyond last Sunday in October");
				}
			
			}
		}
		else
		{	//March
			if(date == dsdate)
			{	//last Sunday in the month of March	
				if(hrs<2)
				{	//Prior to 2am turn daylight saving on
					ds_adj= 1;
					//alert("Prior to 2am");
				}
			}
			else
			{	if(date < dsdate)
				{	//prior to last Sunday in March
					ds_adj= 1;
					//alert("Prior to last Sunday in March");
				}
			
			}
		}
	}
	return ds_adj;
}

-->
