/*
 * Code to display the current date and time in a nice format
 */

function calcTime(){
	var currenttime = new Date();
	var hours = currenttime.getHours();
	var minutes = currenttime.getMinutes();
	var seconds = currenttime.getSeconds();
	var timesuffix = "am";
	if (hours > 11){
		timesuffix = "pm";
		hours = hours - 12;
	}
	if (hours == 0){
		hours = 12;
	}
	if (hours < 10) {
		hours = "0" + hours;
	}
	if (minutes < 10) {
		minutes = "0" + minutes;
	}
	if (seconds < 10){
		seconds = "0" + seconds;
	}
	var clocklocation = document.getElementById('timestamp_clock');
	clocklocation.innerHTML = hours + ":" + minutes + ":" + seconds + " " + timesuffix;
	setTimeout("calcTime()", 1000);
}


function calcDate() {
	var aDayLongNames = new Array(
                        'Sunday',
						'Monday',
						'Tuesday',
						'Wednesday',
						'Thursday',
						'Friday',
						'Saturday'
                    );
	var aMonthLongNames = new Array(
						  '',
                          'January',
                          'February',
                          'March',
                          'April',
                          'May',
                          'June',
                          'July',
                          'August',
                          'September',
                          'October',
                          'November',
                          'December'
                      );
	var oToday = new Date();
	var iDay   = oToday.getDay();
	var iDate  = oToday.getDate();
	var iMonth = oToday.getMonth() + 1;
	var iYear  = oToday.getFullYear();
	var sDate  = aMonthLongNames[iMonth] + ' ' + iDate + ', ' + iYear;
	var datelocation = document.getElementById('timestamp_date');
	datelocation.innerHTML = sDate;
}
				
function calcDateTime(){
	calcDate();
	calcTime();
}