//JAVASCRIPT FOR TOURNAMENT INDEX PAGE TIMER STARTS 

var month = '0';     //  '*' for next month, '0' for this month or 1 through 12 for the month 
//var day = '3';       //  Offset for day of month day or + day  
//var hour = 8;        //  0 through 23 for the hours of the day
var tz = +5.50;         //  Offset for your timezone in hours from UTC
var lab = 'tzcd';    //  The id of the page entry where the timezone countdown is to show
//day = i;

function startTimerindex() 
{
	displayTZCountDownindex(setTZCountDownindex(month,day,hour,tz),lab);
}
    // **    The start function can be changed if required   **
////////// DO NOT EDIT PAST THIS LINE //////////////////
function setTZCountDownindex(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);
}
if (day.substr(0,1) == '+') 
{var day1 = parseInt(day.substr(1));
toDate.setDate(toDate.getDate()+day1);
} 
else{toDate.setDate(day);
}
toDate.setHours(hour);
toDate.setMinutes(0-(tz*60));
toDate.setSeconds(0);
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 displayTZCountDownindex(countdown,tzcd) 
{
if (countdown < 0){
document.getElementById('days').innerHTML = 'This tournament has ended';
}	
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;
days = days ;
hours = hours;
mins = mins ;
secs = secs ;
//document.getElementById('tournatext').innerHTML = 'Tournament closes in ' ;

document.getElementById('days').innerHTML = days + '</br><span class="tourgrtxt01">Days</span>';    
document.getElementById('hours').innerHTML = hours + '</br><span class="tourgrtxt01">Hours</span>'; 
document.getElementById('mins').innerHTML = mins + '</br><span class="tourgrtxt01">Mins</span>'; 
document.getElementById('secs').innerHTML = secs + '</br><span class="tourgrtxt01">Secs</span>';   
setTimeout('displayTZCountDownindex('+(countdown-1)+',\''+tzcd+'\');',999);
}
}


				
//JAVASCRIPT FOR TOURNAMENT INDEX PAGE TIMER ENDS 


//JAVASCRIPT FOR TOURNAMENT PLAY TIMER STARTS 

var month = '0';     //  '*' for next month, '0' for this month or 1 through 12 for the month 
//var day = '3';       //  Offset for day of month day or + day  
//var hour = 8;        //  0 through 23 for the hours of the day
var tz = +5.50;         //  Offset for your timezone in hours from UTC
var lab = 'tzcd';    //  The id of the page entry where the timezone countdown is to show
//day = i;

function startTimerplay() {displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);
}
    // **    The start function can be changed if required   **
////////// DO NOT EDIT PAST THIS LINE //////////////////
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);
}
if (day.substr(0,1) == '+') 
{var day1 = parseInt(day.substr(1));
toDate.setDate(toDate.getDate()+day1);
} 
else{toDate.setDate(day);
}
toDate.setHours(hour);
toDate.setMinutes(0-(tz*60));
toDate.setSeconds(0);
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) 
{
if (countdown < 0){
document.getElementById('days').innerHTML = 'This tournament has ended';
}	
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;
days = days + ' days ';
hours = hours + ' hours ';
mins = mins + ' mins ';
secs = secs + ' secs ';
//document.getElementById('tournatext').innerHTML = 'Tournament closes in ' ;

document.getElementById('days').innerHTML = days + '</br><span class="tourgrtxt01">Days</span>';    
document.getElementById('hours').innerHTML = hours + '</br><span class="tourgrtxt01">Days</span>'; 
document.getElementById('mins').innerHTML = mins + '</br><span class="tourgrtxt01">Days</span>'; 
document.getElementById('secs').innerHTML = secs + '</br><span class="tourgrtxt01">Days</span>'; 
setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
}
}