/* This script gets the current time and date stamp for the local computer and
   display it in the id text area that is passed by the ItemID value.  The
   ItemID must be able to use .innerHTML method. */

// Define local variables.
var Months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var Days = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
var LastTime = "";

function GetCurrentTime(LabelID) {
  // Define private variables.
  var D = new Date();
  var Hour = D.getHours();
  var Minutes = D.getMinutes();
  var Day = D.getDay();
  var Dates = D.getDate();
  var Month = D.getMonth();
  var Year = D.getYear();
  var Part = 'AM';
  
  /* Format the time stamp.
     HH:MM A[P]M DAY, MONTH DD, YYYY  */
  if (Hour >= 12) { if (Hour > 12) { Hour -= 12 }; Part = 'PM'; }
  if (Minutes < 10) { Minutes = "0" + Minutes; }

  if (!IE4) { Year += 1900; }
  
  // Assemble the CurrentTime string to be returned.
  var CurrentTime = Hour + ":" + Minutes + " " + Part + " " + Days[Day] + ". " + Months[Month] + " " + Dates + ", " + Year;
  
  // Determine if the time is the same as last time.
  if (CurrentTime != LastTime) {
    // Display the time stamp.
    if (IE4) {
      document.all[LabelID].innerHTML = CurrentTime;
    }
    // Display the time stamp if not an IE browser.
    else {
      document.getElementById(LabelID).innerHTML = CurrentTime;
    }

    // Same the last time to the current time.
    LastTime = CurrentTime;
  }
  
  // Wait for 2 seconds and call the GetCurrentTime() function again.
  setTimeout("GetCurrentTime('" + LabelID + "')",1000);
}