//Copyright Netburn Web Solutions. You may "borrow" a line here and there, but not larger pieces of the code.
function l0(n){return n>9?n:'0'+n}
function TimeIs(t,dt,dy,pl,ld){
var t,tout='',prevTime=0,prevDate='',prevHm='',prevSync='',tickTime='',tickDate='',t,ticks=0,reloadCount=0,
timeDiv=gob(t),dateDiv=gob(dt),dayDiv=gob(dy),placeDiv=gob(pl),locationdetailsDiv=gob(ld)
this.initClock=function(){
t=new Date()
czo=-t.getTimezoneOffset()
if(conf['zo']==='')conf['zo']=czo
if(zone_offset==='')zone_offset=czo
t.setTime(t.getTime()-tD+(zone_offset)*60000)
if(tout!='')clearTimeout(tout)
tout=setTimeout('T_I.tick("",1)',1000-t%1000)
this.tick('',0)
var secD=Math.abs(tD/1000).toFixed(1)
if(secD<.4)syncm=ph_exactt
else{
var nicetime=''
var d=Math.floor(secD/86400)
if(d==1)nicetime+='1'+ph_day
else if(d!=0)nicetime+=d+ph_days
var remD=secD%86400
d=Math.floor(remD/3600)
if(d!=0){
if(nicetime!='')nicetime+=', '
if(d==1)nicetime+='1'+ph_hour
else if(d!=0)nicetime+=d+ph_hours
}
remD=remD%3600
d=Math.floor(remD/60)
if(d!=0){
if(nicetime!='')nicetime+=', '
if(d==1)nicetime+='1'+ph_minute
else if(d!=0)nicetime+=d+ph_minutes
}
if(nicetime!='')nicetime+=ph_and
d=(remD%60).toFixed(1)
nicetime+=d+ph_seconds+' '
nicetime=ph_your_clock_is+' '+nicetime.replace('.',ph_dec_sym)
if(tD<0)syncm=nicetime+ph_late+ph_exact_time_is
else syncm=nicetime+ph_early+ph_exact_time_is
}
if(secD<.4)syncdt='<p>'+ph_time_diff+(tD/1000).toFixed(3).replace('.',ph_dec_sym)+ph_seconds+' ('+ph_plusminus+(latency/2000).toFixed(3).replace('.',ph_dec_sym)+ph_seconds+').</p>'
else syncdt=''
}
this.tick=function(id,tack){
t=new Date()
t.setTime(t.getTime()-tD)
if((0<ztrans)&&(ztrans<t.getTime())){zone_offset=newzo;ztrans=chosen_sus=0;sus=[];gob('susdiv').innerHTML=''}
var tt2=new Date()
t.setTime(t.getTime()+zone_offset*60000)
if(ticks==1)httpSync()
if(ticks<6)ticks++
if((4<ticks)&&(t-prevTime<0)&&(reloadCount<5)){
httpSync()
prevTime=0
reloadCount++
return ''
}
prevTime=t
hours=t.getUTCHours()
if(hours<12)apv='AM';else{apv='PM';hours-=12}
if(hours==0)hours=12
tickTime=conf['t'].replace('h',l0(hours)).replace('H',l0(t.getUTCHours())).replace('i',l0(t.getUTCMinutes())).replace('s',l0(t.getUTCSeconds()))
timeDiv.innerHTML=tickTime.replace('A','<span style="font-size:'+ampmfontsize+'px;line-height:'+ampmfontsize+'px">'+apv+'</span>')
tickTime=tickTime.replace('A',apv)
var Hm=conf['t'].replace('h',l0(hours)).replace('H',l0(t.getUTCHours())).replace('i',l0(t.getUTCMinutes())).replace(':s','').replace('A',apv)
if(prevHm!=Hm){
prevHm=Hm
if(current_q!='')T_I.populate_sus(current_q)
var t2=new Date()
for(i=0;i<favcount;i++){
t2.setTime(t.getTime()+(favzone[i]-zone_offset)*60000)
hours=t2.getUTCHours()
if(hours<12)apv='AM';else{apv='PM';hours-=12}
if(hours==0)hours=12
var Hm=conf['t'].replace('h',l0(hours)).replace('H',l0(t2.getUTCHours())).replace('i',l0(t2.getUTCMinutes())).replace(':s','').replace('A',apv)
gob('favt'+i).innerHTML=Hm
}
}
date=t.getYear()+t.getUTCMonth()+t.getUTCDate()
if(date!=prevDate){
prevDate=date
var y=t.getUTCFullYear()+''
var m=t.getUTCMonth()+1
var nY=new Date(y,0,1)
var thoff=nY.getDay()-1
if(thoff==-1)thoff=6
var wn=Math.floor((t-nY-(t.getTimezoneOffset()-nY.getTimezoneOffset())*60000)/604800000+(thoff/7))
if(thoff<4)wn++
tickDate=conf['d'].replace('%j',t.getUTCDate()).replace('%d',l0(t.getUTCDate())).replace('%W',ph_week+wn).replace('%n',m).replace('%m',l0(m)).replace('%y',y.substr(2,2)).replace('%Y',y).replace('%F',months[m-1]).replace('%l',days[t.getUTCDay()]).replace('%D',daysh[t.getUTCDay()])
dateDiv.innerHTML=tickDate
today=l0(t.getUTCMonth()+1)+''+l0(t.getUTCDate())
if((typeof spdays[today]!='undefined')&&(spdays[today]!='')){dayDiv.innerHTML=spdays[today];dayDiv.style.display='block'}
else dayDiv.style.display='none'
if(typeof placeDiv=='object'){
if(loc!=''){placeDiv.style.display='block';placeDiv.innerHTML='<a href="/info/'+locurl+'">'+loc+'</a>'}
else placeDiv.style.display='none'
}
}
if(t.getUTCSeconds()%2)bod.className=bod.className.replace('timeIsEven','timeIsOdd')
else bod.className=bod.className.replace('timeIsOdd','timeIsEven')
if(!tack)return('')
tout=setTimeout('T_I.tick("",1)',1000-t%1000)
}
this.check_again=function(){
if(xmlhttp=='N/A')window.location.reload();else httpSync()}
this.recook=function(){var confstr='';for(var i in conf)confstr+=i+':'+conf[i]+'|';setcookie('conf',confstr)}
this.populate_sus=function(thisq){
chosen_sus=sus[thisq].length
var slist='<table cellpadding="0" cellspacing="0" border="0">'
if(chosen_sus!==0){
var ts=new Date()
for(var i in sus[thisq]){
ts.setTime(t.getTime()+(sus[thisq][i][2]-zone_offset)*60000)
hours=ts.getUTCHours()
if(hours<12)apv='AM';else{apv='PM';hours-=12}
if(hours==0)hours=12
var Hm=conf['t'].replace('h',l0(hours)).replace('H',l0(ts.getUTCHours())).replace('i',l0(ts.getUTCMinutes())).replace(':s','').replace('A',apv)
slist+='<tr valign="top" id="sus'+i+'"><td><a href="/'+susdest+sus[thisq][i][1]+'" onmouseover="T_I.choose_sus('+i+')"><span>'+sus[thisq][i][0]+'</span></a></td><td class="t"><a href="/'+susdest+sus[thisq][i][1]+'" onmouseover="T_I.choose_sus('+i+')">\
<span>'+Hm+'</span></a></td></tr>'
}}else slist+='<tr><td><a href="./"><span>'+ph_no_match+'</span></a></td><td class="t">&nbsp;</td></tr>'
gob('susdiv').innerHTML=slist+'</table>'
current_q=thisq
}
this.cycle_sus=function(n){
if(current_q!=''){
var new_chosen=chosen_sus+n
if(new_chosen<0)new_chosen=sus[current_q].length-1
if(new_chosen>=sus[current_q].length)new_chosen=0
this.choose_sus(new_chosen)
}
}
this.choose_sus=function(i){
if(i!==chosen_sus&&chosen_sus<sus[current_q].length)gob('sus'+chosen_sus).className=''
gob('sus'+i).className='chosen'
chosen_sus=i
}
sus=[]
chosen_sus=0
prevsustime=0
current_q=''
this.submit=function(q){
if(q!=current_q)return true
var u='/'+susdest
var i=chosen_sus
if(current_q!=''){
if(i==sus[current_q].length)i=0
if(sus[current_q].length!==0)u+=sus[current_q][i][1];
else if(q.length!=0)return true
}
window.location=u
return false
}
this.reconf=function(){this.recook();prevDate='';this.tick('',0)}
}
var ampmfontsize=20
fontfactor={
a:[5.2,1.1,8,1,2,20],
t:[4.2,1.2,8,1.1,2,22]
}
var wob=['canvas','timediv_ce','timediv','timeis_wrapper','daydiv','datediv','placediv','locationdetailsdiv','favs','syncmsgdiv','syncmsgdetaildiv','top','bottom','logowr']
function setsizes(){
var ww=1,wh=1,bgw,bgw,bgtop,bgleft
if(document.body.offsetWidth)ww=document.body.offsetWidth
else if(window.innerWidth)ww=window.innerWidth
wh=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight
pocketopera=0
if(ww==960&&wh==1400){wh=480;ww=800;pocketopera=1}
if(bgimg!==''){
if(ww/wh>cbgimg.width/cbgimg.height){
bgw=ww
bgh=cbgimg.height*ww/cbgimg.width
bgtop=wh-cbgimg.height*ww/cbgimg.width
bgleft=0
}
else{bgw=cbgimg.width*wh/cbgimg.height
bgh=wh
bgtop=0
bgleft=ww-cbgimg.width*wh/cbgimg.height
}
var bgios=gob('bgimg').style
bgios.width=bgw.toFixed(0)+'px'
bgios.height=bgh.toFixed(0)+'px'
bgios.top=bgtop.toFixed(0)+'px'
bgios.left=bgleft.toFixed(0)+'px'
}
f=conf['f']
timefontsize=(ww/fontfactor[f][0]).toFixed(0)
ampmfontsize=(timefontsize/3).toFixed(0)
if(ampmfontsize<fontfactor[f][5])ampmfontsize=fontfactor[f][5]
datefontsize=(timefontsize/fontfactor[f][2]).toFixed(0)
if(datefontsize<fontfactor[f][5])datefontsize=fontfactor[f][5]
if(conf['t'].length>5)timefontsize=(timefontsize*.88).toFixed(0)
timelineheight=(timefontsize/fontfactor[f][1]).toFixed(0)
datelineheight=(datefontsize/fontfactor[f][3]*1.2).toFixed(0)
canvaswidth=(ww-timefontsize/fontfactor[f][4]).toFixed(0)
canvaspaddingtop=((wh-timefontsize-datefontsize-fluffheight)/2).toFixed(0)
if(noctp==1||canvaspaddingtop<0||pocketopera||ww<401||wh<400)canvaspaddingtop=20
gob('canvas').style.paddingTop=canvaspaddingtop+'px'
for(i in wob)gob(wob[i]).style.width=canvaswidth+'px'
var mapo=gob('map_canvas')
gob('logowr').style.width=canvaswidth+'px'
if(mapo!=null){
mapo.style.width=ww+'px'
mapo.style.height=wh+'px'
if(typeof map=='object')google.maps.event.trigger(map,'resize')
}
timedivobj=gob('timediv')
timedivobj.style.fontSize=timefontsize+'px'
ampmdivobj=gob('ampm')
if(typeof ampmdivobject=='object')ampmdivobj.style.fontSize=ampmfontsize+'px'
timedivobj.style.lineHeight=timelineheight+'px'
datedivobj=gob('datediv')
datedivobj.style.fontSize=datefontsize+'px'
datedivobj.style.lineHeight=datelineheight+'px'
placedivobj=gob('placediv')
placedivobj.style.fontSize=datefontsize+'px'
placedivobj.style.lineHeight=datelineheight+'px'
}
function beginning_of_time(){
T_I=new TimeIs('timediv','datediv','daydiv','placediv','locationdetailsdiv')
T_I.initClock()
if(window.XMLHttpRequest||window.ActiveXObject)gob('syncmsgdiv').innerHTML='<h2>&nbsp;</h2>'
}
