﻿ns=(document.layers);
ns6=(document.getElementById&&!document.all);
ie=(document.all);
Top=(ns)?90:92;
Left=(ns)?67:60;
Scroll=false;      //true or false. Top and Left void if true!
civCol=''; //12 colour.
dotCol=''; //dot colour.
hCol='';   //hours colour.
mCol='';   //minutes colour.
sCol='';   //seconds colour.
ampmCol='';//am-pm colour.
//Alter nothing below! Alignments will be lost!
h=3;
m=4;
s=5;
civ='1 2 3 4 5 6 7 8 9 10 11 12';
civ=civ.split(' ');
n=civ.length;
ClockHeight=22;
ClockWidth=22;
f12="<font face='Arial' size=2 color="+civCol+" style='font-weight:bold;' >";
e=360/n;
HandHeight=ClockHeight/4;
HandWidth=ClockWidth/4;
y=0;
x=0;
zone=0;
isitlocal=true;
ampm='';
n6timer=null;
if (!ns)
document.write("<div id='disp' style='position:absolute;width:50px;height:20px;text-align:center'></div>");
else
document.write("<layer name='disp' top=0 left=0 width=50 height=20></layer>");
for (i=0; i < n; i++){
if (!ns)
document.write('<div id="Civ'+i+'" style="position:absolute;width:15px;height:15px;text-align:center;">'+f12+'</font></div>');
else
document.write('<layer name="Civ'+i+'" width=15 height=15><center>'+f12+'</font></center></layer>');
}
for (i=0; i < n; i++){
if (!ns)
document.write('<div id="D'+i+'" style="position:absolute;width:2px;height:2px;font-size:2px;background:'+dotCol+'"></div>');
else
document.write('<layer name="D'+i+'" bgcolor='+dotCol+' width=2 height=2></layer>');
}
for (i=0; i < s; i++){
if (!ns)
document.write('<div id="S'+i+'" style="position:absolute;width:3px;height:3px;font-size:2px;background:'+sCol+';"></div>');
else
document.write('<layer name="S'+i+'" bgcolor='+sCol+' width=2 height=2></layer>');
}


for (i=0; i < m; i++){
if (!ns)
document.write('<div id="M'+i+'" style="position:absolute;width:3px;height:3px;font-size:2px;background:'+mCol+';"></div>');
else
document.write('<layer name="M'+i+'" bgcolor='+mCol+' width=3 height=3></layer>');
}
for (i=0; i < h; i++){
if (!ns)
document.write('<div id="H'+i+'" style="position:absolute;width:3px;height:3px;font-size:1px;background:'+hCol+';"></div>');
else
document.write('<layer name="H'+i+'" bgcolor='+hCol+' width=4 height=4></layer>');
}
function lcl(z){
zone=z.options[z.selectedIndex].value;
isitlocal=(z.options[0].selected)?true:false;
clearTimeout(n6timer);
}
var _d=(ns||ie)?'document.':'document.getElementById("';
var _a=(ns||ns6)?'':'all.';
var _n6r=(ns6)?'")':'';
var _s=(ns)?'':'.style';
var Dsp=eval(_d+_a+"disp"+_n6r+_s);
var O=eval(_d+_a+"OffSet"+_n6r+_s);
function ClockAndAssign(){
ShowThisTime();
now=new Date();
ofst=now.getTimezoneOffset()/60;
secs=now.getSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?" ":" ";
statusampm = ampm.toLowerCase();
hr2 = hr;
hr2 %= 12;
(hr2 < 1)?hr2+12:hr2;
var Q1=hr2+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs)+' '+statusampm;
var Q2=((hr < 10)?"0"+hr:hr)+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs);
sy=(ie)?document.body.scrollTop+window.document.body.clientHeight-ClockHeight*2:window.pageYOffset+window.innerHeight-ClockHeight*2;
sx=(ie)?document.body.scrollLeft+window.document.body.clientWidth-ClockWidth*2:window.pageXOffset+window.innerWidth-ClockWidth*3;
y=(Scroll)?sy:Top;
x=(Scroll)?sx:Left;
Dsp.top=y-17;
Dsp.left=x-24;
O.top=y-80;
O.left=(ns)?x-57:x-49;
for (i=0; i < s; i++){var d1=eval(_d+_a+"S"+i+_n6r+_s);d1.top=y+(i*HandHeight)*Math.sin(sec);d1.left=x+(i*HandWidth)*Math.cos(sec)}
for (i=0; i < m; i++){var d2=eval(_d+_a+"M"+i+_n6r+_s);d2.top=y+(i*HandHeight)*Math.sin(min);d2.left=x+(i*HandWidth)*Math.cos(min)}
for (i=0; i < h; i++){var d3=eval(_d+_a+"H"+i+_n6r+_s);d3.top=y+(i*HandHeight)*Math.sin(hrs);d3.left=x+(i*HandWidth)*Math.cos(hrs)}
for (i=0; i < n; i++){var d4=eval(_d+_a+"D"+i+_n6r+_s);d4.top=y+ ClockHeight*Math.sin(-1.0471+i*e*Math.PI/180);d4.left=x+ ClockWidth*Math.cos(-1.0471+i*e*Math.PI/180)}
for (i=0; i < n; i++){var d5=eval(_d+_a+"Civ"+i+_n6r+_s);d5.top=y-6+ClockHeight*1.4*Math.sin(-1.0471+i*e*Math.PI/180);d5.left=x-6+ClockWidth*1.4*Math.cos(-1.0471+i*e*Math.PI/180)}
if (ie)disp.innerHTML="<font face='Arial' size='1' color='"+ampmCol+"'>"+ampm+"</font>";
if (ns){
 Dsp.document.write("<font face='Arial' size='1' color='"+ampmCol+"'>"+ampm+"</font>");
 Dsp.document.close();
 }
window.status=Q1+'   '+Q2
setTimeout('ClockAndAssign()',100);
}
function nsixampm(){
 if (ns6){
 document.getElementById("disp").innerHTML="<font face='Arial' size='1' color='"+ampmCol+"'>"+ampm+"</font>";
 n6timer=setTimeout('nsixampm()',10000);
 }
}
if (ns6)nsixampm();
window.onresize=function(){
if(ns){window.location.reload()}
}

function ShowThisTime(){
	var NowTime = new Date();
	var BeiJingTime = new Date();
	var BeiJingSecond;
    BeiJingSecond=NowTime.getTime()+NowTime.getTimezoneOffset()*60*1000+8*60*60*1000
    BeiJingTime.setTime(BeiJingSecond)
	if (BeiJingTime.getMinutes()<10) 	bjmin=0
	else	bjmin=""
	if (BeiJingTime.getSeconds()<10)	bjsin=0
	else	bjsin=""
	
    document.getElementById("NowTime").innerHTML="Beijing Time: "+BeiJingTime.getHours()+":"+bjmin+ +BeiJingTime.getMinutes()+":"+bjsin+ +BeiJingTime.getSeconds()+" "+ BeiJingTime.getDate() +"/"+(BeiJingTime.getMonth()+1)+"/"+BeiJingTime.getFullYear() + " " +"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(",")[BeiJingTime.getDay()]
}

