
	var m_bIsTestRunning = false;
	var m_nTransferCountMax = 10;
	var m_nTransferCount = 0;
	var m_nTransferSize = 0;
	var m_nTransferBytes = 0;
	var m_nTotalTransferTime = 0;
	var m_nTransferSpeed = 0;
	var m_sCurrentData = "";
	var m_oHTTP = null;
	var CONST_LIVE_SERVER = "http://2007.hq.comcept.net/common/repeat.asp";

	rnd.today = new Date();
	rnd.seed = rnd.today.getTime();

	function rnd()
	{
		rnd.seed = (rnd.seed * 9301 + 49297) % 233280;
		return rnd.seed / (233280.0);
	}

	function rand(number)
	{
		return Math.ceil( rnd() * number );
	}

	function BeginSpeedTest()
	{
		m_bIsTestRunning = true;
		m_nTransferCount = 0;
		m_nTransferBytes = 0;
		m_nTransferSpeed = 0;
		m_nTotalTransferTime = 0;
		m_nTransferCountMax = document.getElementById( 'cboTransferCount' ).value;
		m_nTransferSize = document.getElementById( 'cboTransferCount' ).value;

		UpdateStatistics();

		m_sCurrentData = MakeData( m_nTransferSize );

		window.setTimeout( "PerformOneTransfer()", 10 );
	}

	function CancelSpeedTest()
	{
		m_bIsTestRunning = false;
	}

	function PerformOneTransfer()
	{
		if ( m_bIsTestRunning )
		{
			TransferData();
			UpdateStatistics();

			m_nTransferCount += 1;
			if ( m_nTransferCount > m_nTransferCountMax )
			{
				m_bIsTestRunning = false;
			}

			window.setTimeout( "PerformOneTransfer()", 10 );
			
		}
		else
			CompareTransferSpeed();
	}

	function UpdateStatistics()
	{
		document.getElementById( 'lblTransferCount' ).value = m_nTransferCount;
		document.getElementById( 'lblTransferBytes' ).value = m_nTransferBytes;
		document.getElementById( 'lblTotalTransferTime' ).value = m_nTotalTransferTime;
		document.getElementById( 'lblAverageSpeed' ).innerHTML = m_nTransferSpeed;
	}

	function TransferData()
	{
		var sReturn;
		var nStartTime;
		var nEndTime;
		//
		//	This page just regurgitates any XML you send it...
		//
		m_oHTTP = new ActiveXObject( "Msxml2.XMLHTTP.3.0" );

		nStartTime = GetCurrentTimeValue();

		m_oHTTP.open( "POST", CONST_LIVE_SERVER, false );
		m_oHTTP.send( "" + m_sCurrentData );
		sReturn = m_oHTTP.responseText;

		nEndTime = GetCurrentTimeValue();

		m_oHTTP = null;
		
		m_nTransferBytes = parseFloat( m_nTransferBytes ) + ( parseFloat( m_sCurrentData.length ) * 2 );
		m_nTotalTransferTime = parseFloat( m_nTotalTransferTime ) + parseFloat( nEndTime - nStartTime );
		m_nTransferSpeed = ( parseFloat( m_nTransferBytes ) / 1024 ) / ( parseFloat( m_nTotalTransferTime ) / 1000 ) ;

		return;
	}

	function MakeData( Size )
	{
		var sReturn = "";

		while ( sReturn.length < Size )
		{
			sReturn +=	"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>" +
						"<Tag>This is junk data.  This data is completely fake. , ABCDEFGHIJKLMNOPQRSTUVWXYZ12345676890</Tag>";
		}

		return "<xml>" + sReturn + "</xml>";
	}

	function GetCurrentTimeValue()
	{
		var dDate = new Date();
		return dDate.getTime();
	}