var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1;
var date = today.getDate();
var day = today.getDay();
var hour = today.getHours();
var minute = today.getMinutes();

function show_date_time(id) {
	var obj = document.getElementById(id);
	if(obj != null)
		obj.innerHTML = get_full_date_time(year, month, date, day, hour, minute);
}

function get_month(m) {
   switch(m) {
      case 1:
         return "Jan";
      case 2:
         return "Feb";
      case 3:
         return "Mar";
      case 4:
         return "Apr";
      case 5:
         return "May";
      case 6:
         return "Jun";
      case 7:
         return "Jul";
      case 8:
         return "Aug";
      case 9:
         return "Sep";
      case 10:
         return "Oct";
      case 11:
         return "Nov";
      case 12:
         return "Dec";
   }
}

function get_day(d) {
   switch(d) {
      case 0:
         return "(Sun)";
      case 1:
         return "(Mon)";
      case 2:
         return "(Tue)";
      case 3:
         return "(Wed)";
      case 4:
         return "(Thu)";
      case 5:
         return "(Fri)";
      case 6:
         return "(Sat)";
   }
}

function change_to_2(d) {
   if (d < 10)
      return "0" + d;
   else
      return "" + d;
}

function get_time_wording(h) {
   if(h < 12)
      return "A.M.";
   else
      return "P.M.";
}

function get_hour(h) {
   if(h <= 12)
      return change_to_2(h);
   else
      return change_to_2(h - 12);
}

function get_full_date(year, month, date, day) {
      return change_to_2(date) + "&nbsp;" + get_month(month) + "&nbsp;" + year + "&nbsp;" + get_day(day);
}

function get_full_time(hour, minute) {
      return get_hour(hour) + ":" + change_to_2(minute) + get_time_wording(hour);
}

function get_full_date_time(year, month, date, day, hour, minute) {
   return get_full_date(year, month, date, day) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + get_full_time(hour, minute);
}
