<!--
// 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(!hasValidOSBrowserImpl()){
    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=" + isCookieEnabledImpl()
        +  "&validosbrowser=" + hasValidOSBrowserImpl()
        +  "&os=" + getOSName()
        +  "&validbrowser=" + hasValidBrowserImpl()
        +  "&btype=" + getBrowserType()
        +  "&bversion=" + getBrowserVersion()
        +  "&hasreal=" + detectRealImpl()
        +  "&haswindowsmedia=" + detectWindowsMediaImpl()
        +  "&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">'+i18narr['vshow.tys.system.test.column.title']+'</div>	<div id="statusMessageHeader"> <div class="message">'+i18narr['vshow.tys.text.message.criticalError']+'</div>'+getLocaleDropDown()+'	</div><div id="statusMessage">'+i18narr['vshow.tys.text.message.config.failed']+'</div>	<div id="testResult">		<table width="100%" cellpadding="0" cellspacing="0" border="1">			<tr><td class="TYSGridHeaderItem" width="170">'+i18narr['vshow.tys.system.test.column.title']+'</td><td class="TYSGridHeaderItem" width="285">'+i18narr['vshow.tys.system.req.column.title']+'</td><td class="TYSGridHeaderItem" width="195">'+i18narr['vshow.tys.system.config.column.title']+'</td><td class="TYSGridHeaderItem" width="90">'+i18narr['vshow.tys.system.status.column.title']+'</td><td class="TYSGridHeaderItem" width="160">'+i18narr['vshow.tys.system.info.column.title']+'</td></tr>'
    var messageTail="</table><div><br><br>\n\<input type='button' value='"+i18narr['vshow.tys.button.testAgain']+"' onclick='handleTestAgain()'/></div></div></div>"
    //var messageTail="</table><div><br><br>\n\<input type='button' value='"+i18narr['vshow.tys.button.testAgain']+"' onclick='window.top.location.reload();return false;'/></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>'+i18narr['vshow.tys.system.test.os.combo']+'</td><td>'+ osbrowsereq(i18narr['vshow.tys.system.req.os.win'],i18narr['vshow.tys.system.req.browser.ie'],i18narr['vshow.tys.text.with']) +', '
        + osbrowsereq(i18narr['vshow.tys.system.req.os.win'],i18narr['vshow.tys.system.req.browser.fx'],i18narr['vshow.tys.text.with'])+', '
        + osbrowsereq(i18narr['vshow.tys.system.req.os.mac'],i18narr['vshow.tys.system.req.browser.sf'],i18narr['vshow.tys.text.with'])+', '
        + osbrowsereq(i18narr['vshow.tys.system.req.os.mac'],i18narr['vshow.tys.system.req.browser.fx'],i18narr['vshow.tys.text.with'])+', '
        + osbrowsereq(i18narr['vshow.tys.system.req.os.lnx'],i18narr['vshow.tys.system.req.browser.fx'],i18narr['vshow.tys.text.with'])+
        '</td><td>'+getUserBrowserConfigI18N()+'</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">'+i18narr['vshow.tys.system.info.combo']+'</a></td></tr>'
    } else if(code=='flashnotinstalled'){
        messageBody = '<tr class="gridRowFailure"><td>'+i18narr['vshow.tys.system.test.flash']+'</td><td>'+i18narr['vshow.tys.system.req.flash']+'</td><td>'+i18narr['vshow.tys.system.config.notInstalled']+'</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">'+i18narr['vshow.tys.system.info.flashPlayer']+'</a></td></tr>'
    } else if(code=='flashnotvalidversion'){
        messageBody = '<tr class="gridRowFailure"><td>'+i18narr['vshow.tys.system.test.flash']+'</td><td>'+i18narr['vshow.tys.system.req.flash']+'</td><td>'+i18narr['vshow.tys.system.config.flash']+ 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">'+i18narr['vshow.tys.system.info.flashPlayer']+'</a></td></tr>'
    }
	
    return messageHead + messageBody + messageTail;
}

function handleTestAgain() {
    runTestAgainImpl();
}


function osbrowsereq(os, browser, withstr){
    str = withstr.replace("{0}",os).replace("{1}",browser);
    return str;
}

function getLocaleDropDown(){
    str = "<div class='localepref'><select name='locale' onchange='handleLocaleSelection(this)'>";
    for (var v in locales) {
        str +="<option value='"+v+"' ";
        if(v == currentLocale){
            str+=" selected ";
        }
        str+=">"+locales[v]+"</option>";
    }
    str+="</select></div>";
    return str;
}

function handleLocaleSelection(element){
    writeLocalePreferenceCookie(element.value);

    runTestAgainImpl(element.value);
}

function getUserBrowserConfigI18N(){
    var os = getOSName();
    var browser = getBrowserType();
    var osstr="";
    var browserstr ="";
    if(os=="win"){
        osstr = i18narr['vshow.tys.system.req.os.win'];
    } else if(os=="mac"){
        osstr = i18narr['vshow.tys.system.req.os.mac'];
    } else if(os=="lnx"){
        osstr = i18narr['vshow.tys.system.req.os.lnx'];
    }

    if(osstr != ""){
        if(browser=="ie"){
            browserstr= i18narr['vshow.tys.system.req.browser.ie'];
        } else if(browser=="fx"){
            browserstr=i18narr['vshow.tys.system.req.browser.fx'];
        } else if(browser=="sf"){
            browserstr= i18narr['vshow.tys.system.req.browser.sf'];
        }
    }
    if(osstr == "" || browserstr == "") {
        return i18narr['vshow.tys.system.config.notSupported'];
    } else {
        return osbrowsereq(osstr, browserstr, i18narr['vshow.tys.text.with']);
    }
    
}

function writeLocalePreferenceCookie(userlocale){
    if(userlocale && userlocale != ""){
        objCookieUtils.setEscapedCookie("locale"+showId, userlocale,dateAfterOneYear, "/", ".on24.com");
    }
}

function getCookieLocale(){
    return objCookieUtils.getCookieValue("locale"+showId);
}

function getBrowserLocale(){
    return browserLocale;
}


function querySt(ji) {
	var hu = window.location.search.substring(1);
	var ps = hu.split("#");
	var gy = ps[0].split("&");
	for (var i=0;i<gy.length;i++) {
		var ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}


var reloadCalled = false;
function runTestAgainImpl(locale){
    if(reloadCalled) return;
    reloadCalled = true;

    var browser = getBrowserType();
    if(locale){
	var qslocale = querySt("l");
	var ps;
	var suf;

	if (browser == "ie")
	{
            if(qslocale){
                // replace the value with the new value if changed, else reload
		if (qslocale == locale) {
			window.location.reload();
		} else {
        	        window.location.href = window.location.href.replace('='+qslocale,'='+locale);
		}
            } else {
		ps = window.location.href.split("#");
		suf = "";
		if (ps.length > 1) {
			suf = "#" + ps[1];
		}
                window.location.href = ps[0] + (ps[0].indexOf("?") == -1?"?":"&") + "l="+locale + suf;
		
	    }
        }
	else
	{
            if(qslocale){
                // replace the value with the new value if changed, else reload
		if (qslocale == locale) {
			location.reload();
		} else {
	                location.href = location.href.replace('='+qslocale,'='+locale);
		}
            } else {
		ps = location.href.split("#");
		suf = "";
		if (ps.length > 1) {
			suf = "#" + ps[1];
		}
                location.href = ps[0] + (ps[0].indexOf("?") == -1?"?":"&") + "l="+locale + suf;
	    }
        }

    }
    else
    {
	if (browser == "ie")
	{
	    window.location.reload();
	}
	else
	{
	    location.reload();
	}
    }
}

function continueToShowImpl(locale){
    objCookieUtils.setEscapedSessionCookie ("vshow-tys-status", "success");

    var browser = getBrowserType();
    if(locale){
	var qslocale = querySt("l");
	var ps;
	var suf;

	if (browser == "ie")
	{
            if(qslocale){
        	// replace the value with the new value if changed, else reload
		if (qslocale == locale) {
			window.location.reload();
		} else {
                	window.location.href = window.location.href.replace('='+qslocale,'='+locale);
		}
            } else {
		ps = window.location.href.split("#");
		suf = "";
		if (ps.length > 1) {
			suf = "#" + ps[1];
		}
                window.location.href = ps[0] + (ps[0].indexOf("?") == -1?"?":"&") + "l="+locale + suf;
		
	    }
        }
	else
	{
            if(qslocale){
                // replace the value with the new value if changed, else reload
		if (qslocale == locale) {
			location.reload();
		} else {
        	        location.href = location.href.replace('='+qslocale,'='+locale);
		}
            } else {
		ps = location.href.split("#");
		suf = "";
		if (ps.length > 1) {
			suf = "#" + ps[1];
		}
                location.href = ps[0] + (ps[0].indexOf("?") == -1?"?":"&") + "l="+locale + suf;
	    }
        }

    }
    else
    {
	if (browser == "ie")
	{
	    window.location.reload();
	}
	else
	{
	    location.reload();
	}
    }
}

// -->