var mobjFrame_HS;

function CheckComponent_ConnectionSpeed() {

	dateTime = new Date();
	strTime = dateTime.getTime();

	strSpeedTestURL = 'CheckModules/ConnectionSpeed.htm?a=' + strTime;

	mobjFrame_HS = parent.frmTestArea
	mobjFrame_HS.location.href = strSpeedTestURL;
}

function CheckComponent_ConnectionSpeed_CallBack(in_bps) {

	var lngConnectionSpeed = in_bps;
	var strConnectionSpeed;
	var blnHighSpeed;

	alert(in_bps);
	
//	if (mobjWindow_HS != null) mobjWindow_HS.close();

	switch(true) {
		case lngConnectionSpeed > 1000000 :
			strConnectionSpeed = (Math.floor(lngConnectionSpeed / 10240) / 100) + '&nbsp Mbps';
			break;
		case lngConnectionSpeed > 1000 :
			strConnectionSpeed = (Math.floor(lngConnectionSpeed / 10.24) / 100) + '&nbsp Kbps';
			break;
		default :
			strConnectionSpeed = (Math.floor(lngConnectionSpeed * 100) / 100) + '&nbsp bps';
			break;
	}

	blnHighSpeed = (lngConnectionSpeed > 500000);
	switch(true) {
		
		case lngConnectionSpeed > 750000 :
			strStatus = 'Passed';
			strDisplayStatus = 'Passed';
			strResult = strConnectionSpeed;
			strNotes = 'Requirement met';
			break;

		case lngConnectionSpeed > 500000 :
			strStatus = 'Warning';
			strDisplayStatus = 'Warning';
			strResult = strConnectionSpeed;
			strNotes = '<table class="info"><tr><td class="infotext">While quick, your connection may not be fast enough to run the software in a timely fashion.</td><td class="moreinfo" width="100px" onclick=javascript:MoreInfo("MedSpeed.html")><img bordor="0" align="absmiddle" src="images/Help.gif">&nbsp More Info...</td></tr></table>';
			break;

		default :
			strStatus = 'Failed';
			strDisplayStatus = 'Failed';
			strResult = strConnectionSpeed;
			strNotes = '<table class="info"><tr><td class="infotext">Your connection is not fast enough to run the software in a timely fashion.</td><td class="moreinfo" width="100px" onclick=javascript:MoreInfo("LowSpeed.html")><img bordor="0" align="absmiddle" src="images/Help.gif" >&nbsp More Info...</td></tr></table>';
			break;

	}

	ComponentChecked('ConnectionSpeed',strStatus,strDisplayStatus,strResult,strNotes);
	CheckComponent_ConnectionSpeed_Cleanup();
}

function CheckComponent_ConnectionSpeed_Cleanup() {

	mobjFrame_HS.location.href = 'CheckModules/NoWindow.htm';
}

