<!-- hide from silly browsers or browsers 
// that does not recognize JavaScript

// global variables
var digitImages=new Array

if (document.images)
{
	var amImage=new Image
	var pmImage=new Image
}

// load the images used by the clock 
// (the images are are digits from 0 to 
// 9 with the same dimension for each image)
// if you have a different path(s) or filename(s), 
// substitute the filenames/path with the correct ones
// put quotes with nothing between for current directory
var imgPath="images/clock_nmr/"
function loadImages()
{
	// make sure browsers is capable to run this 
	// script by checking that "document.images" object exists
	if (document.images)
	{	
		digitImages=new Array
		for (i=0; i<10; i++)
		{
			digitImages[i]=new Image();
			digitImages[i].src=""+imgPath+i+".jpg";
		}
		// image of the am, pm sign
		amImage.src=imgPath+"blank.gif"
		pmImage.src=imgPath+"blank.gif"
	}
}

function tickClock()
{
	// this tells the browser to call the 
	// "tickClock()" function every 1 second
	setTimeout("tickClock()", 1000);

	// make sure all the digit images are loaded
        if (document.images)
        {
		for (i=0; i<10; i++)
		{
			if (!digitImages[i].complete)
				return;
		}
	}

	thisTime = new Date()
	hours = thisTime.getHours()
	minutes = thisTime.getMinutes()
	seconds = thisTime.getSeconds()

	if (hours>=24)
	{
		hours-=24
		if (document.images)
			document.ampmImage.src=pmImage.src
	}
	else
	{
		if (document.images)
			document.ampmImage.src=amImage.src
	}

	// convert the digit to string
	// make sure there're at least 2 digits
	hourString="0"+hours+""
	minuteString="0"+minutes+""
	secondString="0"+seconds+""

	// format the hour
	hour1=parseInt(hourString.charAt(hourString.length-1))
	hour2=parseInt(hourString.charAt(hourString.length-2))
	// format the minute
	minute1=parseInt(minuteString.charAt(minuteString.length-1))
	minute2=parseInt(minuteString.charAt(minuteString.length-2))
	// format the seconds
	second1=parseInt(secondString.charAt(secondString.length-1))
	second2=parseInt(secondString.charAt(secondString.length-2))

	// for browsers that support image object, update the clock by replacing
	// the images
	if (document.images)
	{
		// update the images	
		document.hour1Image.src=digitImages[hour2].src
		document.hour2Image.src=digitImages[hour1].src
		document.minute1Image.src=digitImages[minute2].src
		document.minute2Image.src=digitImages[minute1].src
		document.second1Image.src=digitImages[second2].src
		document.second2Image.src=digitImages[second1].src
	}
	// for browsers that do not support image object, put the time on the text-field
	else
	{
		document.clockForm.clock.value=""+hour2+hour1+":"+minute2+minute1+":"+second2+second1
	}
}

loadImages();
