// Script to determine connection speed
// kward 02/07/2006

DIALUP_LIMITER = 80;
BROADBAND_MEDIUM_LIMITER = 300;
BROADBAND_HIGH_LIMITER = 650;

connectionSpeed = 0;

testSummary = "0-299kbps = dialup\r\n300-649kbps = Medium Broadband\r\n 650+kbps = Broadband";
	// The variable where connection speed information
	// will be stored when it is available.

function drawCSImageTag( fileLocation, fileSize, imgTagProperties ) {
	// This function draws the image tag required to run this process.
	start = (new Date()).getTime();
		// Record Start time of <img> load.
		
	filename = fileLocation + '?t=' + escape(start);
		// Append the Start time to the image url
		// to ensure the image is not in disk cache.
		
	document.write('<img src="' + filename + '" ' + imgTagProperties + ' onload="connectionSpeed=computeConnectionSpeed(' + start + ',' + fileSize + ');">');
		// Write out the <img> tag.
	
	return;
}

function computeConnectionSpeed( start, fileSize ) {
	// This function returns the speed in kbps of the user's connection.
	end = (new Date()).getTime();
	connectSpeed = (Math.floor((((fileSize * 8) / ((end - start) / 1000)) / 1024) * 10) / 10);
	return connectSpeed;
}