function updateTimer() {
    var timer=document.getElementById('timer');
    if (timer==null) 
	return;
    var milliseconds = new Date().getTime() - document.clockStart.getTime();
    var minutes = Math.floor((milliseconds/1000)/60);
    if (minutes < 10)
	minutes = "0"+minutes;
    var seconds = Math.floor(milliseconds/1000)%60;
    if (seconds < 10)
	seconds = "0"+seconds;
    timer.innerHTML=minutes+":"+seconds+" Stop";
}
function startTimer() {
    var timer=document.getElementById('timer');
    document.clockStart= new Date();
    document.intervalId = window.setInterval(updateTimer, 1000);
    timer.onclick=stopTimer;	
}
function stopTimer() {
    var timer=document.getElementById('timer');
    if (document.intervalId != undefined) 
        window.clearInterval(document.intervalId);
    timer.innerHTML='Timer';
    timer.onclick = startTimer;
    document.clockStart = null;
}

