// I M I R A G E
//
// Essroc Clock
// Author: Brion Updegrove (updegroveb@imirage.com)
// Date: 03/25/04
//
// This function displays the current date and time information
// 
// Edited: Ken Hilbert 08.23.04 - Changed the days of the week to abbreviated three letters so there would be no breaking of the line.

function clockDisplay(){

	// Assign variables
	var thisDate=new Date();
	var month=thisDate.getMonth();
	var day=thisDate.getDay();
	var numday=thisDate.getDate();
	var hours=thisDate.getHours();
	var minutes=thisDate.getMinutes();
	var seconds=thisDate.getSeconds();

	// Day and month name arrays
	var weekDay=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
	var monthName=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

	// AM/PM variable
	dn="AM EST";

	// Calculating AM/PM
	if ((hours>=12)&&(minutes>=1)||(hours>=13)){
		dn="PM EST";
		hours=hours-12;
	}

	// If hours is 0, it is 12AM, need to display 12 instead of zero
	if (hours==0){
		hours=12;
	}

	// If minutes are less than ten, need to add preceeding zero
	if (minutes < 10){
		minutes = "0" + minutes;
	}

	// If seconds are less than ten, need to add preceeding zero
	if (seconds < 10){
		seconds = "0" + seconds;
	}

	// Outputting formatted time
	document.getElementById("clock").innerHTML=weekDay[day] + " " + monthName[month] + " " + numday + " " + hours + ":" + minutes + ":" + seconds + " " + dn;
		
	// The setTimeout function will continuously call this function every second (1000 = 1 sec)
	setTimeout("clockDisplay()",1000)
}