	var timeStart = 0;


	function timeNow() {
		var time = new Date();
		return time.getTime();
	}

	function calculateSpeed(timeStart, onLoadFunction){
		//given the start time, and the fact that the image is one megabyte
		var filesize = 100; // 100 KB
		var timeEnd = timeNow();
		var timeElapsed = (timeEnd - timeStart)/1000; // time in milliseconds - converted to seconds
		var kbytespersecond = filesize/timeElapsed; // 1024 kB = 1MB, so this is in kB per second
		var bitspersecond = kbytespersecond * 1024 * 8; // times 1024 to get bytes, times 8 to get bits
		eval( onLoadFunction )( bitspersecond );
	}

	function checkSpeed(theFunction) {
		//onLoadFunction = theFunction;
		var theImage;
		theImage = new Image();
		var timeStart = timeNow();
		var myFunction = new Function( "return calculateSpeed( " + timeStart + ", " + theFunction + " );" );
		theImage.onload = myFunction;
		theImage.src="/events/images/100k.jpg?random=" + Math.round(Math.random()*400000) + "";
	}