/////////////////////////////////////////////////////////
// Add load events
/////////////////////////////////////////////////////////
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}



/////////////////////////////////////////////////////////
// Clock
/////////////////////////////////////////////////////////
function getCurrentTime() {
	var tDate = new Date();
	var tHours = ( tDate.getHours() < 10 ? "0" : "" ) + tDate.getHours();
	var tMinutes = ( tDate.getMinutes() < 10 ? "0" : "" ) + tDate.getMinutes();
	var tSeconds = ( tDate.getSeconds() < 10 ? "0" : "" ) + tDate.getSeconds();
	var timeOfDay = ( tHours < 12 ) ? "AM" : "PM"; // Choose either "AM" or "PM" as appropriate
	tHours = ( tHours > 12 ) ? tHours - 12 : tHours; // Convert the hours component to 12-hour format if needed
	tHours = ( tHours == 0 ) ? 12 : tHours; // Convert an hours component of "0" to "12"
	return " " + tHours + ":" + tMinutes + ":" + tSeconds + " " + timeOfDay;
}
function updateClock() {
	var curr_time = document.getElementById('curr_time');
	if (curr_time) {
		curr_time.innerHTML = getCurrentTime();
		setTimeout("updateClock()", 1000);
	}
}
addLoadEvent(updateClock);

