//<!--
var amorpm = "AM";

writeTime();

function writeTime() {
  
  // get a date object
  var today = new Date();

  // ask the object for some information
  var Thours = today.getHours();
  var minutes = today.getMinutes();
  var seconds = today.getSeconds();


  // fixTime makes the minutes and seconds look right
  // it just sticks a zero in front of numbers less than 10
  minutes = fixTime(minutes);
  seconds = fixTime(seconds);
  Thours = fixHours(Thours);
  
  // put together the time string and write it out
  var the_time = Thours + ":" + minutes + ":" + seconds + " " + amorpm;
  window.document.timebox.timenow.value = the_time;

  // run this function again in half a second
  the_timeout= setTimeout('writeTime();',500);

} 

function fixHours(hours)
{
	if (hours >= 0 && hours <= 11)
	{
		amorpm = "AM";
		if (hours == 0)
		{
			hours = 12;
		}
	} 
	else if (hours >= 12 && hours <=23)
	{
		amorpm = "PM";
		
		if (hours >= 13 && hours <= 23)
		{
			hours = hours - 12;
		}
	}
	return hours;
}

function fixTime(the_time) {

	if (the_time < 10) 
	{
		the_time = "0" + the_time;
	}
	return the_time;
}
//-->