function ConnectActiveX()
{
  var d = document.getElementById("ActiveX" + CurrentSelectedMachineId);
  d.innerHTML = "<OBJECT id='VSClientControl" + CurrentSelectedMachineId + "' VIEWASTEXT CODEBASE='ActiveX/VMRCActiveXClient1.cab' classid='clsid:4EFA317A-8569-4788-B175-5BAF9731A549' height=400 width=640>" +
	"<PARAM NAME='MenuEnabled' VALUE='0'>" +
	"<PARAM NAME='HostKey' VALUE='Key_RightAlt'>" +
	"<PARAM NAME='ServerAddress' VALUE='" + Machines[CurrentSelectedMachineId-1][0] + "'>" +
	"<PARAM NAME='ServerPort' VALUE='" + Machines[CurrentSelectedMachineId-1][1] + "'>" +
	"<PARAM NAME='ServerDisplayName' VALUE='" + Machines[CurrentSelectedMachineId-1][2] + "'>" +
	"<PARAM NAME='UserDomain' VALUE='" + Machines[CurrentSelectedMachineId-1][3] + "'>" +
	"<PARAM NAME='UserName' VALUE='" + Machines[CurrentSelectedMachineId-1][4] + "'>" +
	"<PARAM NAME='UserPassword' VALUE='" + Machines[CurrentSelectedMachineId-1][5] + "'>" +
	"<PARAM NAME='ProxyAddress' VALUE='" + ProxyAddress + "'>" +
	"<PARAM NAME='ProxyPort' VALUE='" + ProxyPort + "'>" +
	"<PARAM NAME='ProxyUserName' VALUE='" + ProxyUserName + "'>" +
	"<PARAM NAME='ProxyPassword' VALUE='" + ProxyPassword + "'>" +
	"<PARAM NAME='ViewOnlyMode' VALUE='1'>" +
	"<PARAM NAME='ReducedColorsMode' VALUE='1'>" +
	"</OBJECT>";
  d.style.cssText='display:inline;';
}
function GetCurrentControl()
{
	current = CurrentSelectedMachineId;
	var control = eval("VSClientControl" + current);
	return control;
}
function LoadFlash()
{
  var d = $("flashmovie");
  d.innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='340' height='15' id='flashmovie' align='middle' title='Building Virtual Training Environment' >" +
	"<PARAM NAME='movie' VALUE='flash/loading.swf'>" +
	"<PARAM NAME='quality' VALUE='high'>" +
	"<PARAM NAME='wmode' VALUE='transparent'>" +
	"</OBJECT>";
}
function $(elementID) {
    return document.getElementById(elementID);
}

var WindowObjectReference;
var RandomConsoleNumber;
RandomConsoleNumber = Math.round(Math.random()*500);

function openConsole()
{
	if(WindowObjectReference == null || WindowObjectReference.closed)
	{
		var w = 658;
		var h = 430;
		wleft = (screen.width - w) / 2;
		wtop = (screen.height - h - 95) / 2;
		if (wleft < 0) wleft = 0;
		if (wtop < 0) wtop = 0;
		WindowObjectReference = window.open("systemcheck.aspx", "trainingwindow"+RandomConsoleNumber, "height="+h+",width="+w+",left="+wleft+",top="+wtop+",scrollbars=yes,status=1,resizable=1",true);
	}
	else
	{
		WindowObjectReference.focus();
	}
}