// ConnectionSpeed Detection section
var datasize;
var startTime=0;
var endTime=0;
var date=0;
var textMessage="";
var conntype = "";
var throughput;

//Throughput calc function
function calcThroughput() {
var diffTimeMilliseconds = endTime - startTime;
var diffTimeSeconds = diffTimeMilliseconds/1000;
var bits = (datasize*8);   // convert Bytes to bits,
kbits = Math.round(bits/1024);     // convert bits to kbits
throughput = kbits/(diffTimeSeconds);
throughput = throughput * .93;  // account for IP packet header overhead - averages about 7%
//throughput = Math.floor(throughput);
if(throughput > 499)
{
		conntype = "HighBroadband";
		throughput = Math.floor(throughput/500)*500;
} 
else if (throughput > 49)
{
		conntype = "LowBroadband";
		throughput = Math.floor(throughput/50)*50;
} 
else
{
		conntype = "Dialup";
		throughput = Math.round(throughput/5)*5;
	}
;

setCookie("MediaThroughput", throughput, "365");
setCookie("ConnectionType", conntype, "365");
textMessage = "Time to load: (sec): <B>" + diffTimeSeconds + "</B><BR>kbits:<B> " + kbits + "</B><BR>Throughput (kbps): <B>" + throughput + "</B><BR>Connection Type: <B>" + conntype + "</B>";
return conntype,throughput}
