if (top.location != document.location) top.location = document.location;

function changeFontSize(size)
{
	document.getElementById('startstopbutton').style.fontSize=size+"px";
	document.getElementById('splitbutton').style.fontSize=size+"px";
	document.getElementById('disp').style.fontSize=size+"px";
	document.getElementById('disp').style.height=document.getElementById('startstopbutton').style.height;
	document.getElementById('resetbutton').style.fontSize=size+"px";
	document.getElementById('split').style.fontSize=size+"px";
}
function changeBackground(color)
{
	document.bgColor=color;
	document.getElementById('disp').style.backgroundColor=color;
}
function removeUnderline(linknumber)
{
	for (i = 0; i <4; i++)
	{
		if(i==linknumber)
		{
			document.links[i].style.textDecoration = "none";
			document.links[i].style.fontWeight = "normal";
		}
		else
		{
			document.links[i].style.textDecoration = "underline";
			document.links[i].style.fontWeight = "bold";
		}
	}
}
function removeUnderline2(linknumber)
{
	for (i = 4; i <9; i++)
	{
		if(i==linknumber)
		{
			document.links[i].style.textDecoration = "none";
			document.links[i].style.fontWeight = "normal";
		}
		else
		{
			document.links[i].style.textDecoration = "underline";
			document.links[i].style.fontWeight = "bold";
		}
	}
}
/*stopwatch start*/
// 0/1 = start/end
// 2 = state
// 3 = length, ms
// 4 = timer
// 5 = epoch
// 6 = disp el
// 7 = split count
var t=[0, 0, 0, 0, 0, 0, 0, 1];
var firstsplitflag = 0;
var splittime;

function stopstart() {
	t[t[2]]=(new Date()).valueOf();
	t[2]=1-t[2];

	if (0==t[2]) {
		clearInterval(t[4]);
		t[3]+=t[1]-t[0];
		document.getElementById("startstopbutton").value="Start";
		document.getElementById('split').innerHTML+=
			(t[7]++)+' Stop: '+format(t[1]-t[0])+'<br>';
		t[4]=t[1]=t[0]=0;
		disp();
		firstsplitflag = 0;
	} else {
		document.getElementById("startstopbutton").value="Stop";
		t[4]=setInterval(disp, 43);
	}
	//GA
	urchinTracker('http://stopwatch.onlineclock.net/conversions/stopstartbutton');
}
function dosplit(){
		if(0!==t[2])
		{
		document.getElementById('split').innerHTML+=
			(t[7]++)+' Split: '+format(t[1]-t[0])+'<br>';
		}
	//GA
	urchinTracker('http://stopwatch.onlineclock.net/conversions/splitbutton');
}
function reset_it() {
	if (t[2]) stopstart();
	t[4]=t[3]=t[2]=t[1]=t[0]=0;
	disp();
	document.getElementById('split').innerHTML='';
	t[7]=1;
	//GA
	urchinTracker('http://stopwatch.onlineclock.net/conversions/resetbutton');
}

function disp() {
	if (t[2]) t[1]=(new Date()).valueOf();
	t[6].value=format(t[3]+t[1]-t[0]);
}
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');
	var x=String(ms%1000);
	while (x.length<3) x='0'+x;
	d+='.'+x;
	return d;
}

function load() {
	t[5]=new Date(1970, 1, 1, 0, 0, 0, 0).valueOf();
	t[6]=document.getElementById('disp');

	disp();
}
