var timerID = null
var timerRunning = false

function stopClock()
{
	if(timerRunning)
	{
		clearTimeout(timerID)
	}
	timerRunning = false
}

function startClock()
{	
	stopClock()
	showTime()
}

function showTime()
{
	var now = new Date()
	var month = now.getMonth()
	var date = now.getDate()
	var year = now.getFullYear()
	
	var hours = now.getHours()
	var minutes = now.getMinutes()
	var seconds = now.getSeconds()
	
	switch(month)
	{
		case 0 :
			month = "January";
			break;
		case 1 :
			month = "February";
			break;
		case 2 :
			month = "March";
			break;
		case 3 :
			month = "April";
			break;
		case 4 :
			month = "May";
			break;
		case 5 :
			month = "June";
			break;
		case 6 :
			month = "July";
			break;
		case 7 :
			month = "August";
			break;
		case 8 :
			month = "September";
			break;
		case 9 :
			month = "October";
			break;
		case 10 :
			month = "November";
			break;
		case 11 : 
			month = "December";
			break;
		default :
			month = "";
			
	}
	
	var timeValue = month + " " + date + ", " + year
	var AMPM = "A.M."
	
	if(hours >= 12)
	{
		AMPM = "P.M."
	}

	if (hours > 12)
	{	
		hours = hours - 12
	}
	timeValue += " " + hours
	
	if (minutes < 10)
	{
		minutes = ":0" + minutes
	}
	else
	{
		minutes = ":" + minutes
	}
	timeValue += minutes

	if(seconds < 10)
	{
		seconds = ":0" + seconds
	}
	else
	{
		seconds = ":" + seconds
	}
	timeValue += seconds
	timeValue += " " + AMPM

	document.getElementById('clock').innerText = timeValue;
	timerID = setTimeout("showTime()",1000)
	timerRunning = true
}	