function UpdateTimer(max_time_sub) {
// this doesn't work correctly at midnight...
	if (max_time_sub > 0) {
		max_time = max_time_sub * 60;
	}
	var now = new Date()
	var nowSecs = (now.getHours()*60*60) + (now.getMinutes()*60) + now.getSeconds()
	var elapsedSecs = nowSecs - startSecs;
	if (elapsedSecs > max_time) {
		var style2 = document.getElementById('main_div').style;
		style2.backgroundImage = "url('fitnesstimer_files/images/green_ani_bg.gif')";
	}
	var hours = Math.floor( elapsedSecs / 3600 )
	elapsedSecs = elapsedSecs - (hours*3600)

	var minutes = 	Math.floor( elapsedSecs / 60 )
	elapsedSecs = elapsedSecs - (minutes*60)

	var seconds = elapsedSecs;

	var timeValue = "" + hours
	timeValue  += ((minutes < 10) ? ":0" : ":") + minutes
	timeValue  += ((seconds < 10) ? ":0" : ":") + seconds

		// Update display
	document.theTimer.theTime.value = timeValue 
	timerID = setTimeout("UpdateTimer()",1000)
	timerRunning = true
}

function Start(max_time) {
	startDate = new Date()
	startSecs = (startDate.getHours()*60*60) + (startDate.getMinutes()*60) 
						+ startDate.getSeconds()

	Stop()
	UpdateTimer(max_time)
}

function Stop() {
	var style2 = document.getElementById('main_div').style;
	style2.backgroundImage = "url('fitnesstimer_files/images/spacer.gif')";
	if(timerRunning)
		clearTimeout(timerID)
		timerRunning = false
}