var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday'];
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September' ,'October', 'November', 'December'];

function getClockContents() {
  var now = new Date();
  
  var hrs = now.getHours();   if (hrs < 10) { hrs = "0" + hrs; } else { hrs = hrs.toString(); }
  var mns = now.getMinutes(); if (mns < 10) { mns = "0" + mns; } else { mns = mns.toString(); }
  var scs = now.getSeconds(); if (scs < 10) { scs = "0" + scs; } else { scs = scs.toString(); }
  var time = hrs + ":" + mns + ":" + scs + " hrs";
  
  var date = days[now.getDay()]
           + " " + now.getDate()
           + " " + months[now.getMonth()]
           + " " + now.getFullYear();
           
  return "<div class=\"time\">" + time + "</div>\n"
       + "<div class=\"date\">" + date + "</div>";
}

function updateClockEl(el) {
  if (typeof(el) == "string") { el = document.getElementById(el); }
  el.innerHTML = getClockContents();
}

addLoadEvent(function() {
  el = document.getElementById("clock");
  if (el) {
    setInterval(function() { updateClockEl(el); }, 1000);
  }
});