
	var t=[0, 0, 0, 0, 0, 0, 0, 1];

	function ss() 
	{
	t[t[2]]=(new Date()).valueOf();
	t[2]=1-t[2];
	if (0==t[2]) 
	{
		clearInterval(t[4]);
		t[3]+=t[1]-t[0];
		t[4]=t[1]=t[0]=0;
		disp();
	} 
	else 
	{
		t[4]=setInterval(disp, 43);
	}
	}

	function r() 
	{
	if (t[2]) ss();
	t[4]=t[3]=t[2]=t[1]=t[0]=0;
	disp();
	t[7]=1;
	}
	
	function beep()
	{
		var el;
		
		el = document.getElementById('beeper');
		if (el) {
			try { el.Play(); }
			catch (e) {}
		}
	}

	function disp() 
	{
	if (t[2]) t[1]=(new Date()).valueOf();
	t[6].value=format(t[3]+t[1]-t[0]);
	t[3]+t[1]-t[0];


	if (Math.floor((t[3]+t[1]-t[0])/1000) == 180) {
		alert('ONE bell - 3 minutes - OK or ENTER to continue');
	}
	
	if (Math.floor((t[3]+t[1]-t[0])/1000) == 300) {
		alert('TWO bells - 5 minutes - OK or ENTER to continue');
	}

	if (Math.floor((t[3]+t[1]-t[0])/1000) == 330) {
		alert('THREE bells - 5:30 minutes - OK or ENTER to continue');
	}
	}

	function format(ms) 
	{
	var d=new Date(ms+t[5]).toString()
		.replace(/.*([0-9][0-9]:[0-9][0-9]:[0-9][0-9]).*/, '$1');

	return d;
	}

	function load() 
	{
	t[5]=new Date(1970, 1, 1, 0, 0, 0, 0).valueOf();
	t[6]=document.getElementById('disp');
	disp();
	}



