//dateClock.js
//source for javascript code borrowed from http://www.nisbett.com/
//dCol='000000';//date colour.
//fCol='000000';//face colour.
//sCol='000000';//seconds colour.
//mCol='000000';//minutes colour.
//hCol='000000';//hours colour.
dCol='0055ff';//date colour.
fCol='0055ff';//face colour.
sCol='0055ff';//seconds colour.
mCol='0055ff';//minutes colour.
hCol='0055ff';//hours colour.
ClockHeight=30;
ClockWidth=30;

d=new Array("SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY");
m=new Array("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER");
date=new Date();
day=date.getDate();
year=date.getYear();
if (year < 2000) year=year+1900; 
TodaysDate=" "+d[date.getDay()]+" "+day+" "+m[date.getMonth()]+" "+year;
D=TodaysDate.split('');

H=4;
M=5;
S=8;

Face='1 2 3 4 5 6 7 8 9 10 11 12';
font='Arial';
size=1;
speed=0.6;
ns=(document.layers);
ie=(document.all);
Face=Face.split(' ');
n=Face.length; 
a=size*10;
ymouse=0;
xmouse=0;
scrll=0;
props="<font face="+font+" size="+size+" color="+fCol+"><B>";
props2="<font face="+font+" size="+size+" color="+dCol+"><B>";
Split=360/n;
Dsplit=360/D.length;
HandHeight=ClockHeight/4.5
HandWidth=ClockWidth/4.5
HandY=6;
HandX=6;
scrll=0;
step=0.05;
currStep=0;
Y=0;
X=0;

if (ns){
for (i=0; i < D.length; i++)
document.write('<layer name="nsDate'+i+'" top=0 left=0 height=15 width=15><center>'+props2+D[i]+'</font></center></layer>');
for (i=0; i < n; i++)
document.write('<layer name="nsFace'+i+'" top=0 left=0 height=15 width=15><center>'+props+Face[i]+'</font></center></layer>');
for (i=0; i < S; i++)
document.write('<layer name=nsSeconds'+i+' top=0 left=0 bgcolor='+sCol+' clip="0,0,2,2"></layer>');
for (i=0; i < M; i++)
document.write('<layer name=nsMinutes'+i+' top=0 left=0 bgcolor='+mCol+' clip="0,0,2,2"></layer>');
for (i=0; i < H; i++)
document.write('<layer name=nsHours'+i+' top=0 left=0 bgcolor='+hCol+' clip="0,0,2,2"></layer>');
}

if (ie){
for (i=0; i < D.length; i++)
document.write('<div id="ieDate" style="position:absolute;top:0px;left:0;width:15px;height:15px;text-align:center">'+props2+D[i]+'</B></font></div>');
for (i=0; i < n; i++)
document.write('<div id="ieFace" style="position:absolute;top:0px;left:0;width:15px;height:15px;text-align:center">'+props+Face[i]+'</B></font></div>');
for (i=0; i < H; i++)
document.write('<div id="ieHours" style="position:absolute;top:0px;left:0;width:2px;height:2px;font-size:2px;background:'+hCol+'"></div>');
for (i=0; i < M; i++)
document.write('<div id="ieMinutes" style="position:absolute;top:0px;left:0;width:2px;height:2px;font-size:2px;background:'+mCol+'"></div>');
for (i=0; i < S; i++)
document.write('<div id="ieSeconds" style="position:absolute;top:0px;left:0;width:2px;height:2px;font-size:2px;background:'+sCol+'"></div>');
}

function ClockAndAssign(){
if (ns){
Y=window.pageYOffset+window.innerHeight-90;
X=window.pageXOffset+window.innerWidth-100;
}
if (ie){
Y=document.body.scrollTop+window.document.body.clientHeight-70;
//X=document.body.scrollLeft+window.document.body.clientWidth-70;
X=document.body.scrollLeft+window.document.body.clientWidth/2;
}
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360;

for (i=0; i < n; i++){
 var F=(ns)?document.layers['nsFace'+i]:ieFace[i].style; 
 F.top=Y + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180);
 F.left=X + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180);
 }
for (i=0; i < D.length; i++){        
 var DL=(ns)?document.layers['nsDate'+i]:ieDate[i].style; 
 DL.top=Y + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180);
 DL.left=X + ClockWidth*1.5*Math.cos(currStep+i*Dsplit*Math.PI/180); 
 }
for (i=0; i < H; i++){
 var HL=(ns)?document.layers['nsHours'+i]:ieHours[i].style;
 HL.top=Y+HandY+(i*HandHeight)*Math.sin(hrs);
 HL.left=X+HandX+(i*HandWidth)*Math.cos(hrs);
 }
for (i=0; i < M; i++){
 var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes[i].style;
 ML.top=Y+HandY+(i*HandHeight)*Math.sin(min);
 ML.left=X+HandX+(i*HandWidth)*Math.cos(min);
 }
for (i=0; i < S; i++){
 var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds[i].style;
 SL.top=Y+HandY+(i*HandHeight)*Math.sin(sec);
 SL.left=X+HandX+(i*HandWidth)*Math.cos(sec);
 }
currStep-=step;
setTimeout('ClockAndAssign()',1000);
}
if (ns||ie)window.onload=ClockAndAssign;
//-->

