var timerID = null;
var timerRunning = false;

function stopclock ()
{
	if(timerRunning)
		clearTimeout(timerID);
	timerRunning = false;
}

function showtime ()
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	var timeValue = "" + ((hours >12) ? hours -12 :hours)
		if (timeValue == "0") timeValue = 12;
		timeValue += ((minutes < 10) ? ":0" : ":") + minutes
		timeValue += ((seconds < 10) ? ":0" : ":") + seconds
		timeValue += (hours >= 12) ? " PM" : " AM"
		timerID = setTimeout("showtime()",1000);
	timerRunning = true;
	runtime.innerHTML = timeValue;
}

function startclock()
{
	stopclock();
	document.write (month());
	document.write ("&nbsp;&nbsp;<span id='runtime'></span>");
	showtime();
}

function month()
{
	var months=new Array(13);
	months[1]="Jan";		months[2]="Feb";		months[3]="Mar";		months[4]="Apr";
	months[5]="May";		months[6]="Jun";		months[7]="Jul";		months[8]="Aug";
	months[9]="Sep";		months[10]="Oct";		months[11]="Nov";		months[12]="Dec";
	
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var dates=new Array(32);

	dates[1]="01";		dates[2]="02";		dates[3]="03";		dates[4]="04";
	dates[5]="05";		dates[6]="06";		dates[7]="07";		dates[8]="08";
	dates[9]="09";		dates[10]="10";		dates[11]="11";		dates[12]="12";
	dates[13]="13";		dates[14]="14";		dates[15]="15";		dates[16]="16";
	dates[17]="17";		dates[18]="18";		dates[19]="19";		dates[20]="20";
	dates[21]="21";		dates[22]="22";		dates[23]="23";		dates[24]="24";
	dates[25]="25";		dates[26]="26";		dates[27]="27";		dates[28]="28";
	dates[29]="29";		dates[30]="30";		dates[31]="31";

	var ldate=dates[time.getDate()];
	var year=time.getYear();
	if (year < 2000)    // Y2K Fix, Isaac Powell
		year = year + 1900; // http://onyx.idbsu.edu/~ipowell
		
	var javadate =  lmonth + " " + ldate + ", " + year;
	return javadate;
}

