

var strPreCheckStatus;


function main()
{

	if(window.parent.parent.blnPerformSystemCheck) {

		//document.getElementById('MainTable').style.visibility = 'visible';
		Initialize();
		ComponentChecked('Start','','','','');
	
	} else {
		GoToPostPreCheckURL();
	}
}

function Initialize()
{
	CheckURL = window.parent.parent.postPreCheckPath();
	document.getElementById('aPostPreCheckPath').href= CheckURL;

	//The speed test and download manager tests are disabled at the core until a usable routine for either is proven.

	strPreCheckStatus = 'Passed';

	ActivateTest(blnCheckAcrobat,'Acrobat');
	ActivateTest(blnCheckColorDepth,'ColorDepth');
	ActivateTest(blnCheckConnectionSpeed,'ConnectionSpeed');
	ActivateTest(blnCheckLargeFonts,'LargeFonts');
	ActivateTest(blnCheckMSXML,'MSXML');
	ActivateTest(blnCheckCodecs,'Codecs');
	ActivateTest(blnCheckActiveMovie,'ActiveMovie');
	ActivateTest(blnCheckDownloadManager,'DownloadManager');
	ActivateTest(blnCheckPopups,'Popups');
	ActivateTest(blnCheckScripting,'Scripting');
	ActivateTest(blnCheckBrowser,'Browser');
	ActivateTest(blnCheckOS,'OS');

}


function ActivateTest(in_blnTest,in_strTestName)
{

	if (in_blnTest)
	{
		obj = document.getElementById('Light' + in_strTestName)
		obj.style.display = 'inline';
		obj = document.getElementById('Check' + in_strTestName)
		obj.style.display = '';
	}

}

function ComponentChecked(in_strComponent,in_strStatus,in_strDisplayStatus,in_strResult,in_strInfo)
{

	var strComponentToCheck;

	if(!(in_strComponent==''))
	{
		switch(in_strStatus)
		{
			case 'Passed':
				//Update Results Table
				document.getElementById(in_strComponent + '_D').innerHTML = '<span style="color:green;">' + in_strResult + '</span>';
				document.getElementById(in_strComponent + '_S').innerHTML = '<span style="color:green;">' + in_strDisplayStatus + '</span>';
				document.getElementById(in_strComponent + '_I').innerHTML = '<img src="images/Check.gif">';
				document.getElementById(in_strComponent + '_N').innerHTML = in_strInfo;

				//Update Status Balls
				document.getElementById('Light' + in_strComponent).innerHTML = '<img src="images/icon_glassballgreen.gif">';
				break;
			case 'Warning':
				//Update Results Table
				document.getElementById(in_strComponent + '_D').innerHTML = '<span style="color:#8B4513;">' + in_strResult + '</span>';
				document.getElementById(in_strComponent + '_S').innerHTML = '<span style="color:#8B4513;">' + in_strDisplayStatus + '</span>';
				document.getElementById(in_strComponent + '_I').innerHTML = '<img src="images/Warning.gif">';
				document.getElementById(in_strComponent + '_N').innerHTML = in_strInfo;

				//Update Status Balls
				document.getElementById('Light' + in_strComponent).innerHTML = '<img src="images/icon_glassballyellow.gif">';
				
				if(strPreCheckStatus=='Passed')
					strPreCheckStatus = 'Warning';
				break;
			case 'Failed':
				//Update Results Table
				document.getElementById(in_strComponent + '_D').innerHTML = '<span style="color:red;">' + in_strResult + '</span>';
				document.getElementById(in_strComponent + '_S').innerHTML = '<span style="color:red;">' + in_strDisplayStatus + '</span>';
				document.getElementById(in_strComponent + '_I').innerHTML = '<img src="images/Fail.gif">';
				document.getElementById(in_strComponent + '_N').innerHTML = in_strInfo;

				//Update Status Balls
				document.getElementById('Light' + in_strComponent).innerHTML = '<img src="images/icon_glassballred.gif">';

				if((strPreCheckStatus=='Warning') || (strPreCheckStatus=='Passed'))
					strPreCheckStatus = 'Failed';
				break;
		}

	}

	strComponentToCheck = in_strComponent;

	switch(strComponentToCheck)
	{
		case 'OS':
			strComponentToCheck = 'Browser';
			break;
		case 'Browser':
			strComponentToCheck = 'Scripting';
			break;
		case 'Scripting':
			strComponentToCheck = 'Popups';
			break;
		case 'Popups':
			strComponentToCheck = 'DownloadManager';
			break;
		case 'DownloadManager':
			strComponentToCheck = 'ActiveMovie';
			break;
		case 'ActiveMovie':
			strComponentToCheck = 'Codecs';
			break;
		case 'Codecs':
			strComponentToCheck = 'MSXML';
			break;
		case 'MSXML':
			strComponentToCheck = 'LargeFonts';
			break;
		case 'LargeFonts':
			strComponentToCheck = 'ConnectionSpeed';
			break;
		case 'ConnectionSpeed':
			strComponentToCheck = 'ColorDepth';
			break;
		case 'ColorDepth':
			strComponentToCheck = 'Acrobat';
			break;
		case 'Acrobat':
			strComponentToCheck = 'Complete';
			break;
	}

	//Determine next component to check
	//alert(strComponentToCheck);
	if(strComponentToCheck == 'Start') strComponentToCheck = 'OS';
	if((strComponentToCheck == 'OS') && (!blnCheckOS)) strComponentToCheck = 'Browser';
	if((strComponentToCheck == 'Browser') && (!blnCheckOS)) strComponentToCheck = 'Scripting';
	if((strComponentToCheck == 'Scripting') && (!blnCheckScripting)) strComponentToCheck = 'Popups';
	if((strComponentToCheck == 'Popups') && (!blnCheckPopups)) strComponentToCheck = 'DownloadManager';
	if((strComponentToCheck == 'DownloadManager') && (!blnCheckDownloadManager)) strComponentToCheck = 'ActiveMovie';
	if((strComponentToCheck == 'ActiveMovie') && (!blnCheckActiveMovie)) strComponentToCheck = 'Codecs';
	if((strComponentToCheck == 'Codecs') && (!blnCheckCodecs)) strComponentToCheck = 'MSXML';
	if((strComponentToCheck == 'MSXML') && (!blnCheckMSXML)) strComponentToCheck = 'LargeFonts';
	if((strComponentToCheck == 'LargeFonts') && (!blnCheckLargeFonts)) strComponentToCheck = 'ConnectionSpeed';
	if((strComponentToCheck == 'ConnectionSpeed') && (!blnCheckConnectionSpeed)) strComponentToCheck = 'ColorDepth';
	if((strComponentToCheck == 'ColorDepth') && (!blnCheckColorDepth)) strComponentToCheck = 'Acrobat';
	if((strComponentToCheck == 'Acrobat') && (!blnCheckAcrobat)) strComponentToCheck = 'Complete';
	//alert(strComponentToCheck);

	switch(strComponentToCheck)
	{
		case 'OS':
			setTimeout('CheckComponent_OS()',250,'javascript');	
			break;
		case 'Browser':
			setTimeout('CheckComponent_Browser()',250,'javascript');	
			break;
		case 'Scripting':
			setTimeout('CheckComponent_Scripting()',250,'javascript');	
			break;

		case 'Popups':
			setTimeout('CheckComponent_Popups()',250,'javascript');	
			break;
		case 'DownloadManager':
			setTimeout('CheckComponent_DownloadManager()',250,'javascript');
			break;

		case 'ActiveMovie':
			setTimeout('CheckComponent_ActiveMovie()',250,'javascript');
			break;
		case 'Codecs':
			setTimeout('CheckComponent_Codecs()',250,'javascript');
			break;
		case 'MSXML':
			setTimeout('CheckComponent_MXSML()',250,'javascript');	
			break;

		case 'LargeFonts':
			setTimeout('CheckComponent_LargeFonts()',250,'javascript');	
			break;
		case 'ConnectionSpeed':
			setTimeout('CheckComponent_ConnectionSpeed()',250,'javascript');
			break;
		case 'ColorDepth':
			setTimeout('CheckComponent_ColorDepth()',250,'javascript');
			break;

		case 'Acrobat':
			setTimeout('CheckComponent_Acrobat()',250,'javascript');
			break;

		case 'Complete':
			setTimeout('CheckComplete()',250,'javascript');	
			break;
	}

}

function CheckComplete()
{
	if((strPreCheckStatus == 'Warning') || (strPreCheckStatus =='Failed'))
	{

		if(strPreCheckStatus == 'Warning')
			document.getElementById('WarningMessage').style.display = '';
		else
			document.getElementById('CriticalMessage').style.display = '';

		document.getElementById('ProblemMessage').style.display = '';

		document.getElementById('divChecking').style.display = 'none';
		document.getElementById('divRequirements').style.display = 'inline';
	}
	else
	{
		GoToPostPreCheckURL();

	}
}

function GoToPostPreCheckURL()
{
	strPostPreCheckURL = window.parent.parent.postPreCheckPath();
	window.location.href = strPostPreCheckURL + window.parent.parent.location.search;


}

function MoreInfo(in_strURL)
{
	if(mblnPopupEnabled)
	{
		in_strURL = in_strURL + '?Return=Close';
		window.open(in_strURL,'','width=550,height=300,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,title=no,toolbar=no');

	} else {
		
		in_strURL = in_strURL + '?Return=Back';
		window.location.href = in_strURL;
	}

}


