// ****  Time Zone Count Down Javascript  **** //
/*
Visit http://rainbow.arch.scriptmania.com/scripts/
 for this script and many more
*/

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////

var hour = 7.30;        //  0 through 23 for the hours of the day
var tz = -0.5;         //  Offset for your timezone in hours from UTC
var lab = 'tzcd';    //  The id of the page entry where the timezone countdown is to show

function setCountdownDate (eventmonth, eventday)
{
	month = eventmonth;
	day = eventday;
}


    // **    The start function can be changed if required   **
//starttimer();

////////// DO NOT EDIT PAST THIS LINE //////////////////

function setTZCountDown(month,day,hour,tz) 
{
today =  new Date();
var yy = today.getFullYear();
//alert ("yy="+yy+" ------------ " + today+" ------------ " + today.getYear());
if (month <= today.getMonth()) yy++;

var toDate = new Date(yy,month-1,day,hour,0-(tz*60),0);
/*
if (month == '*') {
	toDate.setMonth(toDate.getMonth() + 1);
}
else if (month > 0) 
{ 
	alert ("month > 0");
	if (month <= toDate.getMonth()){
		//alert ("next year");
		toDate.setYear(toDate.getYear() + 1);
	}
	month -= 1;
	toDate.setMonth(month);
	alert ("toDate.setMonth("+month+")");
}
if (day.substr(0,1) == '+') 
{
	alert ("day.substr(0,1)");
	var day1 = parseInt(day.substr(1));
	toDate.setDate(toDate.getDate()+day1);
} 
else{
	alert ("day toDate.setDate("+day+")");
	toDate.setDate(day);
}
toDate.setHours(hour);
toDate.setMinutes(0-(tz*60));
toDate.setSeconds(0);
*/
//alert (toDate+" "+toDate.getYear());
var fromDate = new Date();
fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
var diffDate = new Date(0);
diffDate.setMilliseconds(toDate - fromDate);
return Math.floor(diffDate.valueOf()/1000);
}

function displayTZCountDown(countdown,tzcd) 
{
	//alert ("countdown="+countdown);
if (countdown < 0) document.getElementById(tzcd).innerHTML = "Online bookings are closed for this event"; 
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;
	//alert ("days="+days);

document.getElementById(tzcd).innerHTML = days + " day" + (days == 1 ? '' : 's') + ' <span class=greytext> ' +hours+ 'h : ' +mins+ 'm : '+secs+'s</span>';
setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
}
}