// Update date & time information in tag 'id'
// class="de" selects german time format
// Use: 
//	<body onload="startClock('today');">
//	<div id="clock" class= "de"></div>

function startClock(id) {
	updateClock('today');
	setInterval('updateClock("today")', 1000);
}

function updateClock (id) {
	var cTime = new Date ( );

	var cYear = cTime.getYear();
	if (cYear<=99) cYear= "19"+cYear;
	if ((cYear>99) && (cYear<2000)) cYear+=1900;

	var cMonth = cTime.getMonth() + 1;
	var cDay = cTime.getDate();
	var cHours = cTime.getHours ( );
	var cMinutes = cTime.getMinutes ( );
	var cSeconds = cTime.getSeconds ( );

	// Pad the minutes and seconds with leading zeros, if required
	cMinutes = ( cMinutes < 10 ? "0" : "" ) + cMinutes;
	cSeconds = ( cSeconds < 10 ? "0" : "" ) + cSeconds;

	// Compose the string for display
	if (document.getElementById(id).className == "de") {
		// German time format with 24-hour clock
		var currentTimeString = cDay + "." + cMonth + "." + cYear + " " + cHours + ":" + cMinutes + ":" + cSeconds;
	} else {
		// English time format with 12-hour clock "AM" or "PM" as appropriate
		var timeOfDay = ( cHours < 12 ) ? "AM" : "PM";
		// Convert the hours component to 12-hour format if needed
		cHours = ( cHours > 12 ) ? cHours - 12 : cHours;
		// Convert an hours component of "0" to "12"
		cHours = ( cHours == 0 ) ? 12 : cHours;
		var currentTimeString = cDay + "-" + cMonth + "-" + cYear + " " + cHours + ":" + cMinutes + ":" + cSeconds + " " + timeOfDay;
	}
	// Update the time display
	document.getElementById(id).firstChild.nodeValue = currentTimeString;
}
