	imageStartTime = null;
	
	function startSpeedTest()
	{
		holderDiv = document.getElementById('image_holder');
		
		document.getElementById('initialParagraph').style.display = "none";
		document.getElementById('pleaseWait').style.display = "block";
		document.getElementById('resultsText').style.display = "none";

		resultsBox = document.getElementById('timeCell');
		if ( resultsBox.hasChildNodes() )
		{
		    while ( resultsBox.childNodes.length >= 1 )
		    {
		        resultsBox.removeChild( resultsBox.firstChild );       
		    } 
		}

		resultsBox = document.getElementById('speedCell');
		if ( resultsBox.hasChildNodes() )
		{
		    while ( resultsBox.childNodes.length >= 1 )
		    {
		        resultsBox.removeChild( resultsBox.firstChild );       
		    } 
		}		
		
		if(document.getElementById('userSpeedRow'))
		{
			document.getElementById('speedTable').deleteRow(document.getElementById('userSpeedRow').rowIndex);
		}
				
		theImage = document.createElement('img');
		theImage.setAttribute('id','theTestImage');
		theImage.style.display = "none";
		theImage.src = "/images/download.jpg?"+Math.random();
		imageStartTime = new Date();
		theImage.onload = function() { endSpeedTest(imageStartTime.getTime()); }
		holderDiv.appendChild(theImage);
	}
	
	function endSpeedTest(startSeconds)
	{
		document.getElementById('pleaseWait').style.display = "none";
		
		imageEndTime = new Date();
		miliSecondDifference = imageEndTime.getTime() - startSeconds;
		theSeconds = miliSecondDifference/1000;
		theKbps = (322649 * 8) / theSeconds / 1000;
		
		document.getElementById('image_holder').removeChild(document.getElementById('theTestImage'));
		
		document.getElementById('resultsText').style.display = "block";

		theresultsText = document.createTextNode((Math.round(theSeconds*1000)/1000)+' s');
		document.getElementById('timeCell').appendChild(theresultsText);

		theresultsText = document.createTextNode(+Math.round(theKbps)+' Kbps');
		document.getElementById('speedCell').appendChild(theresultsText);

		//Add in the neccesary row
		if(theKbps<=53.3)
		{
			insertLocal = 1;
		}
		else if(theKbps>53.3 && theKbps<=768)
		{
			insertLocal = 2;
		}
		else if(theKbps>768 && theKbps<=6000)
		{
			insertLocal = 3;
		}
		else if(theKbps>6000 && theKbps<=8000)
		{
			insertLocal = 4;
		}
		else if(theKbps>8000)
		{
			insertLocal = 5;
		}
		spdTable = document.getElementById('speedTable');
		yourRow = spdTable.insertRow(insertLocal);
		yourRow.setAttribute('id','userSpeedRow');
		
		newCell = yourRow.insertCell(0);
		newCell.setAttribute('align','right');
		newCell.setAttribute('class','speedTableLCell redBoldLCell');
		newCell.setAttribute('className','speedTableLCell redBoldLCell');
		ysText = document.createTextNode('Your Speed ('+Math.round(theKbps)+' Kbps)');
		newCell.appendChild(ysText);
		
		newCell = yourRow.insertCell(1);
		newCell.setAttribute('class','speedTableRCell');
		newCell.setAttribute('className','speedTableRCell');
		
		aGraphic = document.createElement('img');
		aGraphic.setAttribute('src','/images/speedtest/speed_test_left_end-ys.gif');
		newCell.appendChild(aGraphic);
		
		aGraphic = document.createElement('img');
		aGraphic.setAttribute('src','/images/speedtest/speed_test_middle-ys.gif');
		aGraphic.setAttribute('height','10');
		aGraphic.setAttribute('width',Math.round(Math.round(theKbps)*.0112));
		newCell.appendChild(aGraphic);

		aGraphic = document.createElement('img');
		aGraphic.setAttribute('src','/images/speedtest/speed_test_right_end-ys.gif');
		newCell.appendChild(aGraphic);
	}	