<!--
//displays countdown to 5pm of the 5th day (Friday)
var month = '0';     //  '*' for next month, '0' for this month or 1 through 12 for the month 
var day = '5';       //  Offset for day of month day or + day  // NOW IS DAY OF WEEK TO COUNT TO!
var hour = 17;        //  0 through 23 for the hours of the day
var tz = +10;         //  Offset for your timezone in hours from UTC
var lab = 'wcount';    //  The id of the page entry where the timezone countdown is to show

function start() 
{
	displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);
}

    // **    The start function can be changed if required   **
function setTZCountDown(month,day,hour,tz) 
{
	var toDate = new Date();
	if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
	else if (month > 0) { 
		if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
		toDate.setMonth(month-1);
	}
	var checkDate=new Date()
	if (checkDate.getDay() == 6) { //it's the weekend! 
		return -1;
	}
	if (checkDate.getDay() == 7) { //it's the weekend! 
		return -1;
	}
	day = ((day - checkDate.getDay()) + checkDate.getDate())
	var sub7 = false;
	if (day>28) {day=day-7; sub7 = true;} //subtract a week if over 28 days as we don't care which week in the month...
	toDate.setDate(day)
	toDate.setHours(hour);
	toDate.setMinutes(0-(tz*60));
	toDate.setSeconds(0);
	var fromDate = new Date();
	fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
	if (sub7) { fromDate.setDate(fromDate.getDate()-7);} //subtract a week if over 28 days as we don't care which week in the month...
	var diffDate = new Date(0);
	diffDate.setMilliseconds(toDate - fromDate);
	return Math.floor(diffDate.valueOf()/1000);
}


function displayTZCountDown(countdown,tzcd) 
{
	if (countdown < 0) document.getElementById(tzcd).innerHTML = " - it's the weekend!"; 
	else 
	{
		var secs = countdown % 60; 
		if (secs < 10) secs = '0'+secs;
		var countdown1 = (countdown - secs) / 60;
		var mins = countdown1 % 60; 
		if (mins < 10) mins = '0'+mins;
		countdown1 = (countdown1 - mins) / 60;
		var hours = countdown1 % 24;
		var days = (countdown1 - hours) / 24;
		document.getElementById(tzcd).innerHTML = "<span class='weekendVar'><span class='weekendValue'>" + days + "</span> day" + (days == 1 ? '' : 's') + "</span> <span class='weekendVar'><span class='weekendValue'>" +hours+ "</span> hour" + (hours == 1 ? ' ' : 's ') + "</span> <span class='weekendVar'><span class='weekendValue'>"+ mins+ "</span> min"+ (mins == 1 ? ' ' : 's ')+ "</span> <span class='weekendVar seconds'><span class='weekendValue'>" + secs+"</span> sec"+(secs == 1 ? '' : 's')+'</span>';
		setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
	}
}
//-->

