﻿global_name='';function countdown_clock(year,month,day,hour,minute,format,name)
{global_name=name;html_code='<div id="countdown"></div>';document.write(html_code);countdown(year,month,day,hour,minute,format,name);}
function countdown(year,month,day,hour,minute,format)
{Today=new Date();Todays_Year=Today.getFullYear()-2000;Todays_Month=Today.getMonth()
Todays_Date=(new Date(Todays_Year,Todays_Month,Today.getDate(),Today.getHours(),Today.getMinutes(),Today.getSeconds())).getTime();Target_Date=(new Date(year,month-1,day,hour,minute,00)).getTime();Time_Left=Math.round((Target_Date-Todays_Date)/1000);if(Time_Left<0)
Time_Left=-1;days=Math.floor(Time_Left/(60*60*24));Time_Left%=(60*60*24);hours=Math.floor(Time_Left/(60*60));Time_Left%=(60*60);minutes=Math.floor(Time_Left/60);Time_Left%=60;seconds=Time_Left;switch(format)
{case 0:innerHTML='До турніру <div class="tournament_name"><br>'+global_name+'</div> залишилось:<br><div id="d">'+days+'</div>'+' дн'+' ';innerHTML+='<div id="h">'+hours+'</div>'+' год'+' ';innerHTML+='<div id="m">'+minutes+'</div>'+' хв'+' ';innerHTML+='<div id="s">'+seconds+'</div>'+' с';break;case 1:innerHTML='Time left until tournament <div class="tournament_name"><br>'+global_name+'</div>:<br><div id="d">'+days+'</div>'+' d'+' ';innerHTML+='<div id="h">'+hours+'</div>'+' h'+' ';innerHTML+='<div id="m">'+minutes+'</div>'+' m'+' ';innerHTML+='<div id="s">'+seconds+'</div>'+' s';break;default:innerHTML=Time_Left+' seconds';}
if(Time_Left<=-1)
switch(format)
{case 0:var innerHTML='<div class="start">Турнір розпочався!</div>';break;case1:var innerHTML='<div class="start">Tournament started!</div>';break;default:var innerHTML='<div class="start">Tournament started!</div>';}
document.getElementById('countdown').innerHTML=innerHTML;setTimeout('countdown('+year+','+month+','+day+','+hour+','+minute+','+format+');',1000);}
global_name2='';function countdown_clock2(year,month,day,hour,minute,format,name)
{global_name2=name;html_code='<div id="countdown2"></div>';document.write(html_code);countdown2(year,month,day,hour,minute,format,name);}
function countdown2(year,month,day,hour,minute,format)
{Today=new Date();Todays_Year=Today.getFullYear()-2000;Todays_Month=Today.getMonth()
Todays_Date=(new Date(Todays_Year,Todays_Month,Today.getDate(),Today.getHours(),Today.getMinutes(),Today.getSeconds())).getTime();Target_Date=(new Date(year,month-1,day,hour,minute,00)).getTime();Time_Left=Math.round((Target_Date-Todays_Date)/1000);if(Time_Left<0)
Time_Left=-1;days=Math.floor(Time_Left/(60*60*24));Time_Left%=(60*60*24);hours=Math.floor(Time_Left/(60*60));Time_Left%=(60*60);minutes=Math.floor(Time_Left/60);Time_Left%=60;seconds=Time_Left;switch(format)
{case 0:innerHTML='До турніру <div class="tournament_name">'+global_name2+'</div> залишилось:<br><div id="d">'+days+'</div>'+' дн'+' ';innerHTML+='<div id="h">'+hours+'</div>'+' год'+' ';innerHTML+='<div id="m">'+minutes+'</div>'+' хв'+' ';innerHTML+='<div id="s">'+seconds+'</div>'+' с';break;case 1:innerHTML='Time left until tournament <div class="tournament_name">'+global_name2+'</div>:<br><div id="d">'+days+'</div>'+' d'+' ';innerHTML+='<div id="h">'+hours+'</div>'+' h'+' ';innerHTML+='<div id="m">'+minutes+'</div>'+' m'+' ';innerHTML+='<div id="s">'+seconds+'</div>'+' s';break;default:innerHTML=Time_Left+' seconds';}
if(Time_Left<=-1)
switch(format)
{case 0:var innerHTML='<div class="start">Турнір розпочався!</div>';break;case1:var innerHTML='<div class="start">Tournament started!</div>';break;default:var innerHTML='<div class="start">Tournament started!</div>';}
document.getElementById('countdown2').innerHTML=innerHTML;setTimeout('countdown2('+year+','+month+','+day+','+hour+','+minute+','+format+');',1000);}
