// System independent clock allowing one to display the server time.
// Used by the Use Points modules to display the current time. 
//	10/10/2007 Bob: Initial Version
//
// Requires the following:
//	An element with innerText of the ID: 
//		currentTime
//	This initialization a end of calling program
// 		<script> startclock('<starting Time>'); </script>

//Initialize Globally
var thetime=new Date();

function hasInnerText()
	{
	return (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
}

function startclock(curTime)
	{
	var cTime=new Date(curTime);
	thetime.setHours(cTime.getHours())
	thetime.setMinutes(cTime.getMinutes())
	thetime.setSeconds(cTime.getSeconds())
	displaytime();
}

function displaytime()
	{
	var nhours=thetime.getHours();
	var nmins=thetime.getMinutes();
	var nsecn=thetime.getSeconds();
	var AorP=" ";

	if (nhours>=12)
		 AorP="PM";
	else
		 AorP="AM";

	if (nhours>=13)
		 nhours-=12;

	if (nhours==0)
		nhours=12;

	if (nsecn<10)
		nsecn="0"+nsecn;

	if (nmins<10)
		nmins="0"+nmins;

	var currentTimeField = document.getElementById('currentTime');
	if(!hasInnerText())
		currentTimeField.textContent=nhours+":"+nmins+":"+nsecn+" "+AorP;
	else
		currentTimeField.innerText=nhours+":"+nmins+":"+nsecn+" "+AorP;

	thetime.setSeconds(thetime.getSeconds()+1);

	setTimeout('displaytime()',1000);
} 


