window.onload = showTheTime;

function showTheTime() {
     var dayName = new Array("Sunday", "Monday", "Tuesday",
"Wednesday",
"Thursday", "Friday", "Saturday");
     var monName = new Array("January", "February", "March", "April",
"May", "June", "July", "August", "September", "October", "November",
"December");

     var now = new Date();
     var thisMonth = now.getMonth() + 1;

    var dtString = dayName[now.getDay()] + ", " +
      monName[now.getMonth()] + " " + now.getDate() + ", " +
now.getFullYear();


        var theTime = showTheHours(now.getHours()) +
showZeroFilled(now.getMinutes()) + showZeroFilled(now.getSeconds()) +
showAmPm();

        document.getElementById("showTime").innerHTML = dtString + " " +
theTime;

        setColor();

        setTimeout("showTheTime()",1000);

        function showTheHours(theHour) {
           if (theHour == 0) {
               return 12;
           }
           if (theHour < 13) {
              return theHour;
           }
           return theHour - 12;
        }

        function showZeroFilled(inValue) {
           if (inValue > 9) {
              return ":" + inValue;
           }
           return ":0" + inValue;
         }

        function showAmPm() {
           if (now.getHours() < 12) {
              return " am";
           }
           return " pm";
        }

        function setColor() {
           if ((now.getSeconds() > 54) || (now.getSeconds() == 0)) {
             document.getElementById("showTime").style.color = "red";
           }
           else {
             document.getElementById("showTime").style.color = "#0087FF";
           }
        }
}


