var WinTest = null;
var UserSystem = new SystemProfile ();

function createWin () {
	WinTest = window.open ('scripts/popUpTest.html#test', 'win', 'width=150,height=50');
	setTimeout ('detectWin ()', 700);
	window.focus ();
}
function detectWin () {
	var bBlock = false;
	((WinTest == null) || (typeof (WinTest) == "undefined") || (typeof (WinTest.location.hash) != "string")) ? bBlock = true : WinTest.close ();
	UserSystem.userBlocker = (bBlock) ? 'Enabled' : 'Disabled';
	UserSystem.testSystem ();
	createReport (UserSystem);
}

function changeHTML (sID, sText) {
	var fd = new FindDOM ();
	var path = fd.find (sID, 'id');
	path.innerHTML = sText;
}

function updateReport (oProfile) {
	changeHTML ('userPlatform', oProfile.userPlatform + '.');
	changeHTML ('userOS', oProfile.userOS + '.');
	changeHTML ('userScreen', oProfile.userScreen + '.');
	changeHTML ('browserName', oProfile.userBrowser + '.');
	changeHTML ('browserJavaScript', 'Enabled.');
	changeHTML ('browserCookies', oProfile.userCookie + '.');
	changeHTML ('browserBlocker', oProfile.userBlocker + '.');
	changeHTML ('browserStylesheets', oProfile.userCss + '.');
	changeHTML ('pluginFlash', oProfile.userFlash + '.');
	changeHTML ('pluginAcrobat', oProfile.userAcrobat + '.');
}
function updateMissing (aFail) {
	var sMissing ='<ol>';
	var nLength = aFail.length;
	for (var x = 0; x < nLength; x++) {
		var sFail = aFail[x]
		sMissing += '<li>' + sFail + '</li>';
	}
	sMissing += '</ol>';
	if (nLength != 0) changeHTML ('oiSystemError', sMissing);
}
function createReport (oProfile) {
	updateReport (oProfile);
	
	var aCheck = oProfile.testType, aFail = [];
	var nLength = aCheck.length;
	for (var x = 0; x < nLength; x++) {
		var sCheck = aCheck[x];
		var bPass = oProfile['pass' + sCheck];
		if (!bPass) {
			var sFail = oProfile.failSystem[sCheck];
			aFail.push (sFail);
		}
	}
	
	updateMissing (aFail);
}

function detectSystemProfile () {
	UserSystem.detectSystem ();
	createWin ();
}

