﻿/*
	// declare variables
	var currentTime = new Date()
	var month = currentTime.getMonth() + 1
	var day = currentTime.getDate()
	var year = currentTime.getFullYear()
	var hours = currentTime.getHours()
	var minutes = currentTime.getMinutes()
	var seconds = currentTime.getSeconds()
	
	// on time, if minutes are less than ten, write leading zero
	if (minutes < 10){
	minutes = "0" + minutes
	}
	
	// change number values to months
	if (month <2){
	month = "January"
	}
	else if (month <3){
	month = "February"
	}
	else if (month <4){
	month = "March"
	}
	else if (month <5){
	month = "April"
	}
	else if (month <6){
	month = "May"
	}
	else if (month <7){
	month = "June"
	}
	else if (month <8){
	month = "July"
	}
	else if (month <9){
	month = "August"
	}
	else if (month <10){
	month = "September"
	}
	else if (month <11){
	month = "October"
	}
	else if (month <12){
	month = "November"
	}
	else if (month <13){
	month = "December"
	}
	
	
	
	// set an auto update timer
	setTimeout("time", 1000) 
	

	// now write to screen
	document.write(day + " " + month + " " + year + " " + hours + ":" + minutes + ":" + seconds + " ")
	
	
	// if hours are higher than 11, write PM after the time, otherwise, write AM
	if(hours > 11){
	document.write("PM")
	} else {
	document.write("AM")
	}
	
	// done!
	
	*/
	
function updateClock ( )
{
  // create new date variable
  var currentTime = new Date ( );
  
  // assign minutes second hour variable
  var month = currentTime.getMonth() + 1
  var day = currentTime.getDate()
  var year = currentTime.getFullYear()
  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;
  
  // change number values to months
	if (month <2){
	month = "January"
	}
	else if (month <3){
	month = "February"
	}
	else if (month <4){
	month = "March"
	}
	else if (month <5){
	month = "April"
	}
	else if (month <6){
	month = "May"
	}
	else if (month <7){
	month = "June"
	}
	else if (month <8){
	month = "July"
	}
	else if (month <9){
	month = "August"
	}
	else if (month <10){
	month = "September"
	}
	else if (month <11){
	month = "October"
	}
	else if (month <12){
	month = "November"
	}
	else if (month <13){
	month = "December"
	}

  // Compose the string for display
  var currentTimeString = day + " " + month + " " + year + " " + currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

// -->
