// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 115;


// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

if(!hasValidOSBrowser()){
	document.write(getErrorMessage('browseros'))
} else if ( !hasProductInstall  ) {
	document.write(getErrorMessage('flashnotinstalled'))
} else if ( hasProductInstall && !hasRequestedVersion ) {
	document.write(getErrorMessage('flashnotvalidversion'))
	/*var alternateContent =  '<div id="installFlash">This content requires the latest version of Adobe Flash Player. '
   	+ '<a href="http://www.adobe.com/go/getflash/" target="_blank">Get Flash</a></div>';
    document.write(alternateContent);  // insert non-flash content*/
} else if (hasRequestedVersion) {
	// if we've detected an acceptable version
	// embed the Flash Content SWF when all tests are passed
	
	flashVariables += "&flashversion=" + GetSwfVer().replace("WIN ", "")
				+ "&cookieenabled=" + isCookieEnabled()
				+  "&validosbrowser=" + hasValidOSBrowser()
				+  "&os=" + getOSName()
				+  "&validbrowser=" + hasValidBrowser()
				+  "&btype=" + getBrowserType()
				+  "&bversion=" + getBrowserVersion()
				+  "&hasreal=" + detectReal()
				+  "&haswindowsmedia=" + detectWindowsMedia()
				+  "&screenresolution=" + screenWidth + "x" +  screenHeight
				+  "&realbuild=" + getRealPlayerBuild()
				+  "&wmbuild=" + getWMPlayerBuild();
	
	//alert(flashVariables)
	
	AC_FL_RunContent(
			"src", SWFSource,
			"FlashVars", flashVariables,
			"width", "100%",
			"height", "100%",
			"align", "middle",
			"id", "VirtualTradeshow",
			"quality", "high",
			"bgcolor", "#869ca7",
			"name", "VirtualTradeshow",
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
	);
} else {  // flash is too old or we can't detect the plugin
    var alternateContent =  'An error has occured. please contact technical support.';
    document.write(alternateContent);  // insert non-flash content
}

function getErrorMessage(code){
	var messageHead= '<div id="mainContent">	<div id="pageHeader">System Check</div>	<div id="statusMessageHeader">Critical Error</div>	<div id="statusMessage">Your system is not configured to view this show. Please update your system configuration and test again.</div>	<div id="testResult">		<table width="100%" cellpadding="0" cellspacing="0" border="1">			<tr><td class="TYSGridHeaderItem" width="170">Configuration Test</td><td class="TYSGridHeaderItem" width="285">Required Configuration</td><td class="TYSGridHeaderItem" width="195">User Configuration</td><td class="TYSGridHeaderItem" width="90">Test Status</td><td class="TYSGridHeaderItem" width="160">More Information</td></tr>'
	var messageTail='</table><div><br><br><a href="#" onclick="window.top.location.reload();return false;"><img src="/view/vts/tys/images/test-again-up.gif" onmouseover="this.src=\'/view/vts/tys/images/test-again-over.gif\'" onmouseout="this.src=\'/view/vts/tys/images/test-again-up.gif\'" class="button"/></a></div>	</div></div>'
	//var messageTail='</table><div><br><br><input type="button" value="Test Again" onclick="window.top.location.reload()"/></div>	</div></div>'
	
	var messageBody = "";
	
	if(code=='browseros'){
		messageBody = '<tr class="gridRowFailure"><td>OS / Browser Combination</td><td>Windows with IE, Windows with Firefox, Mac with Safari, Mac with Firefox, Linux with Firefox</td><td>'+getOSBrowserName()+'</td><td align="center"><img src="/view/vts/tys/images/icon_fail_red.png"/></td><td><a href="http://vshow.on24.com/clients/vshow/systemtest/help.html#OSBrowser" target="_blank">OS and Browser Combinations</a></td></tr>'
	} else if(code=='flashnotinstalled'){
		messageBody = '<tr class="gridRowFailure"><td>Flash</td><td>Flash Player 9.0.115+</td><td>Not Installed</td><td align="center"><img src="/view/vts/tys/images/icon_fail_red.png"/></td><td><a href="http://vshow.on24.com/clients/vshow/systemtest/help.html#Flash" target="_blank">Flash Player</a></td></tr>'
	} else if(code=='flashnotvalidversion'){
		messageBody = '<tr class="gridRowFailure"><td>Flash</td><td>Flash Player 9.0.115+</td><td>Flash Player '+GetSwfVer().replace("WIN ", "")+'</td><td align="center"><img src="/view/vts/tys/images/icon_fail_red.png"/></td><td><a href="http://vshow.on24.com/clients/vshow/systemtest/help.html#Flash" target="_blank">Flash Player</a></td></tr>'
	}
	
	return messageHead + messageBody + messageTail;
}

