


	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) {
        //alert( "check" );
	    //onLoadFunction = theFunction;

	    //theImage = new Image();
	    var timeStart = timeNow();
	    var myFunction = new Function( "return calculateSpeed( " + timeStart + ", " + theFunction + " );" );
	    //theImage.onload = myFunction;
	    //theImage.src="100k.jpg?random=" + Math.round(Math.random()*400000) + "";
    	
	    var imageTag = document.createElement('img');
    	
	    imageTag.onload = myFunction;
	    imageTag.style.display = "none";
	    imageTag.src="/events/images/100k.jpg?random=" + Math.round(Math.random()*400000) + "";

//	    document.body.appendChild( imageTag );
        
    	
    }