    
    var iWSCountDown   = 15;       //Web Service connection test count down
    var iFlashCountDown = 15;      //Flash connection test count down
    var tmrWS;
    var tmrFlash;
    var hasReqestedVersion=false;  //Does the user have requested Flash version?
    var bFlashConn = false;        //Can Flash connect to server?
    var skipFlag;                  //Set to "1" to fail all tests.
    
    function doTest(stepNumId, debugFlag, skipFlagIn)
    {
        skipFlag = skipFlagIn;
        var stepNumVal=document.getElementById(stepNumId).value;
        if(debugFlag=="1") alert(stepNumVal);
        if(skipFlag!="1")
        {
            switch(stepNumVal)
            {
                case "0":
                    document.forms[0].hidStepNum.value="1";
                    break;
                case "1":
                    document.forms[0].hidStepNum.value="2";
                    checkScreenRes();
                    break;
                case "2":
                    document.forms[0].hidStepNum.value="3";
                    checkPopupBlocker();
                    break;
                case "3":
                    document.forms[0].hidStepNum.value="4";
                    checkWebService();
                    break;
                case "4":
                    document.forms[0].hidStepNum.value="5";
                    checkFlash();
                    break;
                case "5":
                    document.forms[0].hidStepNum.value="6";
                    checkFlashConn();
                    break;
                case "6":
                    document.forms[0].hidStepNum.value="7";
                    break;
            }
        }
        else  //fail all tests
        {
            switch(stepNumVal)
            {
                case "3": 
                    checkWebService();
                    break;
                case "4":
                    checkFlash();
                    break;
                case "5":
                    checkFlashConn();
                    break;
            }
            document.forms[0].hidStepNum.value = parseInt(stepNumVal) + 1;
        }
    }

    function checkScreenRes()
    {
        document.forms[0].hidHeight.value = window.screen.height;
        document.forms[0].hidWidth.value = window.screen.width;
    }
    
    function checkPopupBlocker()
    {
        var features = "width=25,height=25,left=10,top=10,toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable=no,alwaysRaised,dependent,titlebar=no";
        var contents =
            "<html><head></head>" + "\n" +
            "<body>" + "\n" +
            "<script type='text/javascript'>" + "\n" +
            "window.opener.document.forms[0].hidPopupTest.value='1';" + "\n" +
            "window.close();" + "\n" +
            "<\/script>" + "\n" +
            "<\/body>" + "\n" +
            "<\/html>" + "\n";
            
        var popwin = window.open("", "_pop", features, true);
        try
        {
            popwin.document.writeln(contents);
        }
        catch(e)
        {
        }
    }
    
    function debugFlash(info)
    {
        alert(info);
    }
    
    //Flash detection function using SWFObject 1.5
    //http://blog.deconcept.com/swfobject/
    function checkFlash()
    {
        // Major version of Flash required
        var requiredMajorVersion = 8;
        // Minor version of Flash required
        var requiredMinorVersion = 0;
        // Minor version of Flash required
        var requiredRevision = 0;

        //do version test
        var version = deconcept.SWFObjectUtil.getPlayerVersion();
		if (document.getElementById && version["major"] >= requiredMajorVersion) 
		{
            hasReqestedVersion = true;
			if(skipFlag!="1")
		    {
			    document.forms[0].hidFlashVerTest.value="1";
			}
		}
		else
		{
		    hasReqestedVersion = false;
		}
    }
    
//    function checkFlashConn()
//    {
//        //Do Flash connection test no matter a correct version is detected or not because version test is not 100% right.
//        //if (hasReqestedVersion) 
//        //{
//	        tmrFlash = window.setInterval(waitFlashConnTimeOut,1000);

//	        if(skipFlag!="1")
//	        {
//                try
//                {
//                    var so = new SWFObject("TestFlash.swf", "mymovie", "25", "26", "8", "#ffffff");
//                    so.addParam("wmode", "transparent");
//                    so.addVariable("f", tmcF);
//                    so.write("divFlashObj");
//                    mymovie = document.getElementById("mymovie");
//                }
//                catch(e)
//                {
//                }
//	        }
//        //}
//        //else
//        //{
//        //    window.setTimeout(doAjaxTimerPostBack,2000);
//        //}
//    }
    
    function checkFlashConn()
    {
        //Do Flash connection test no matter a correct version is detected or not because version test is not 100% right.
        //if (hasReqestedVersion) 
        //{
	        tmrFlash = window.setInterval(waitFlashConnTimeOut,1000);

	        if(skipFlag!="1")
	        {
                try
                {
                    mymovie = document.getElementById("mymovie");
                    var oMyMovie = document.getElementById("mymovie");
                    oMyMovie.movie="TestFlash.swf";   //for IE
                    document.embeds["mymovie"].src="TestFlash.swf"; //for Firefox
                    divFlashObj.innerHTML=divFlashObj.innerHTML;    //for Firefox
                }
                catch(e)
                {
                }
	        }
        //}
        //else
        //{
        //    window.setTimeout(doAjaxTimerPostBack,2000);
        //}
    }
    
    function waitFlashConnTimeOut()
    {
        if(iFlashCountDown > 0)
        {
            document.getElementById("spnFlashCD").innerHTML= "(in " + iFlashCountDown + " secs)";
            iFlashCountDown--;
        }
        else
        {
             doFlashFinal();
        }
    }
    
    function doFlashFinal()
    {
        window.clearInterval(tmrFlash);
        document.getElementById("spnFlashCD").innerHTML="";
        doAjaxTimerPostBack();
    }
    
    function CDNConnResults(success, extInfo)
    {
        //CDNConnResults() gets called back from TestFlash.swf several times.
        //bFlashConn gets set to true and the logic is executed when the first time a success(true) is returned.
        //Afterward, the logic is skipped.
        if(!bFlashConn)
        {
            if(success)
            {
                document.forms[0].hidFlashConnTest.value="1";
                bFlashConn = true;
                doFlashFinal();
                document.getElementById("extInfo").innerHTML="Flash connection URL: " + extInfo;
            }
            else
            {
                //CDNConnResults() gets called back several times.
                //The last error message is put here.
                document.forms[0].hidFlashConnErr.value = extInfo;
                document.getElementById("extInfo").innerHTML="Flash error message: " + extInfo;
            }
        }
    }

    function checkWebService()
    {
        tmrWS = window.setInterval(waitWebServiceTimeOut,1000);
        if(skipFlag != "1")
        {
            WILink.VCall.VCallWebServices.VCallScriptServices.TestConnection ("hello",TestConnectionCallback);
        }
    }
    
    function TestConnectionCallback(result, eventArgs)
    {
        document.forms[0].hidWebServiceTest.value=result;
        doWebServiceFinal();
    }
    
    function waitWebServiceTimeOut()
    {
        if(iWSCountDown > 0)
        {
            document.getElementById("spnWSCD").innerHTML= "(in " + iWSCountDown + " secs)";
            iWSCountDown--;
        }
        else
        {
             doWebServiceFinal();
        }
    }
    
    function doWebServiceFinal()
    {
        window.clearInterval(tmrWS);
        document.getElementById("spnWSCD").innerHTML="";
        doAjaxTimerPostBack();
    }
    
    function passSoundTest()
    {
        document.forms[0].hidSoundTest.value="1";
        doAjaxTimerPostBack();
    }
    
    function failSoundTest()
    {
        document.forms[0].hidSoundTest.value="0";
        doAjaxTimerPostBack();
    }
