﻿var clockDiv;

function GetMonth(nMonth) {
    var aMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    return aMonth[nMonth];
}

function GetDayName(nDay) {
    var aDay = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); 
    return aDay[nDay];
}

function clock() {
    if (!clockDiv) clockDiv = $("clock");
	var oDate = new Date();
	var nDate = oDate.getDate();
	var sMonth = GetMonth(oDate.getMonth());
	var sDay = GetDayName(oDate.getDay());
	var nYear = oDate.getFullYear();
	var oTime = "";	
	
	// Add Hours
	if (oDate.getHours() < 10) oTime += "0";
	oTime += oDate.getHours() + (oDate.getSeconds() % 2 == 0 ? " " : ":");
	
	// Add Mins
	if (oDate.getMinutes() < 10) oTime += "0";
	oTime += oDate.getMinutes();  //+ ":";
	
	// Add Seconds
	//if (oDate.getSeconds() < 10) oTime += "0";	    
	//oTime += oDate.getSeconds();
    
    var sDate = nDate + " " + sMonth + " " + nYear;
    var sRet = oTime + " &nbsp; " + sDate;
	if (clockDiv) { clockDiv.innerHTML = sRet; clockDiv.title = sDay + ", " + sDate; }
	setTimeout("clock()",1000);		
} 
