MetaWrap.Platform.MediaManager.SpecCheck = {};
MetaWrap.Platform.MediaManager.SpecCheck.g_mm_sniffer = false;
MetaWrap.Platform.MediaManager.SpecCheck.g_wmp_version = 'N/A';
MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = 'Unknown OS';
MetaWrap.Platform.MediaManager.SpecCheck.g_browser_version = 'Unknown Browser';
MetaWrap.Platform.MediaManager.SpecCheck.g_dotnet_version = "N/A";
MetaWrap.Platform.MediaManager.SpecCheck.g_wmc_version = "N/A";
MetaWrap.Platform.MediaManager.SpecCheck.g_flash_version = "";
MetaWrap.Platform.MediaManager.SpecCheck.g_individualised = false;
MetaWrap.Platform.MediaManager.SpecCheck.g_individualisation_version = "";
MetaWrap.Platform.MediaManager.SpecCheck.g_media_manager_version = "";

// Version of Media Manager required
MetaWrap.Platform.MediaManager.SpecCheck.g_media_manager_version_required = "3.0.0.494";

// Major version of Flash required
var requiredMajorVersion = 8;

// Minor version of Flash required
var requiredMinorVersion = 0;

// Revision # of Flash required
var requiredRevision = 0;

// the version of javascript supported
var jsVersion = 1.1;

var versionMajor  = 0;
var versionMinor = 0;
var g_flash_url = "http://www.adobe.com/go/getflashplayer";
var g_flash_message = "The required version of the Flash browser plugin could not be detected. Please choose 'OK' to exit BigPond Movie Downloads ViiV, and install the Flash browser plugin from the Macromedia website at '" + g_flash_url + "' to install the Flash browser. \nChoose 'CANCEL' to exit..";
var g_flash_message_remote = "The required version of the Flash browser plugin could not be detected. Please load this application on your ViiV PC to install the required software.";
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;


/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkFlash = function()
    @brief      Detect the required flash version
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkFlash = function()
{
	var reqMajorVer = requiredMajorVersion;
	var reqMinorVer  = requiredMinorVersion;
	var reqRevision  = requiredRevision;

	// JavaScript helper required to detect Flash Player PlugIn version information
	function JSGetSwfVer(i)
	{
	    // NS/Opera version >= 3 check for Flash plugin in plugin array
	    if (navigator.plugins != null && navigator.plugins.length > 0) {
	        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
	            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
	            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
	            descArray = flashDescription.split(" ");
	            tempArrayMajor = descArray[2].split(".");
	            versionMajor = tempArrayMajor[0];
	            versionMinor = tempArrayMajor[1];
	            if ( descArray[3] != "" ) {
	                tempArrayMinor = descArray[3].split("r");
	            } else {
	                tempArrayMinor = descArray[4].split("r");
	            }
	            versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
	            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
	        } else {
	            flashVer = -1;
	        }
	    }
	    // MSN/WebTV 2.6 supports Flash 4
	    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	    // WebTV 2.5 supports Flash 3
	    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	    // older WebTV supports Flash 2
	    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	    // Can't detect in all other cases
	    else {

	        flashVer = -1;
	    }
	    return flashVer;
	}

    try
    {
        reqVer = parseFloat(reqMajorVer + "." + reqRevision);
        // loop backwards through the versions until we find the newest version
        for (i=25;i>0;i--)
        {
            if (isIE && isWin && !isOpera)
            {
                versionStr = VBGetSwfVer(i);
            } else
            {
                versionStr = JSGetSwfVer(i);
            }
            if (versionStr == -1 )
            {
                return false;
            } else if (versionStr != 0)
            {
                if(isIE && isWin && !isOpera)
                {
                    tempArray         = versionStr.split(" ");
                    tempString        = tempArray[1];
                    versionArray      = tempString .split(",");
                }
                else
                {
                    versionArray      = versionStr.split(".");
                }
                versionMajor      = versionArray[0];
                versionMinor      = versionArray[1];
                versionRevision   = versionArray[2];

                versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
                versionNum        = parseFloat(versionString);

                // Get the version
				MetaWrap.Platform.MediaManager.SpecCheck.g_flash_version = versionString;

                // is the major.revision >= requested major.revision AND the minor version >= requested minor
                if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) )
                {
                    return true;
                }
                else
                {
                    return ( ((versionNum >= reqVer) && (versionMinor >= reqMinorVer) ) ? true : false );
                }
            }
        }
    }
    catch(l_e)
    {
        return false;
    }
}


/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkWMP = function()
    @brief      Detect the media player version
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkWMP = function()
{
    function WmpPatchLevelsOk(patchedVersion, detectedDRMVersion)
    {
        /************
         * BEGIN: Check if the WMP meets the Patched level
         */

         var patchedArray = patchedVersion.split('.');
         var detectedArray = detectedDRMVersion.split('.');

         var patchLength = patchedArray.length;
         var detLength = detectedArray.length;

         var maxIterations = patchLength;

         //Check that the length of the Detected Version has more minor versions
         // than the Patched version.
         if(detLength < patchLength){
            maxIterations = detLength;
         }

         for (var loop=0; loop < maxIterations; loop++) {
         if (parseInt(patchedArray[loop], 10) > parseInt(detectedArray[loop], 10))
            {
            // Change Message to direct the user to windows update to get patched version of WMP
            actionWMP = actionWMP2;
            return(false);
            }
        }
        // We are patched to the right version or above
         return(true);
         /************
         * END: Windows media patch level check
         */
    }

	function checkIndividualisation()
	{
	  var sXMLCommand, objClientInformation, objXMLDOM, xmlNode;
	  var sFoundSec;
	  var nRequiredSec = '2200', nFoundSec = 0.0;
	  sFoundSec = new String('0.0')

	  if (document.netobj != null)
	  {

		  objClientInformation = document.netobj.GetSystemInfo();
		  sXMLCommand = '<?xml version="1.0"?><MEDIATEST><WMP>7</WMP>' +
		                netobj.GetSystemInfo() + '</MEDIATEST>';
		  try {
		    objXMLDOM = new ActiveXObject("Msxml2.DOMDocument");
		  }
		  catch (xmlException) {
		    objXMLDOM = new ActiveXObject("Msxml.DOMDocument");
		  }
		  objXMLDOM.loadXML (sXMLCommand);

		  xmlNode = objXMLDOM.selectSingleNode("MEDIATEST/CLIENTINFO/SECURITYVERSION");
		  if (xmlNode)
		  {
		    var sRegEx
		    sRegEx = /\./g;
		    sFoundSec = String(xmlNode.text);
		    sFoundSec = sFoundSec.replace(sRegEx, '');
		  }

		  MetaWrap.Platform.MediaManager.SpecCheck.g_individualisation_version = sFoundSec;

		  if (Number(sFoundSec) < nRequiredSec)
		  {
		    // individualisation doesn't meet the minimum required level
		    return false;
		  }
		  else
		  {
		    // Finally, we're done, and everything looks ok.
		     return true;
		  }
	  }

	  return false;
	}




    /************
     * BEGIN: Windows media player check
     */
    {
        var is_WMP10up = false;
        var is_WMP9 = false;

        var agt = navigator.userAgent.toLowerCase();
        var appVer = navigator.appVersion.toLowerCase();
        var is_win = (agt.indexOf("win")!=-1);
        var is_ie = (appVer.indexOf('msie')!=-1);
        var is_WMP = false;
        var is_WMP64 = false;
        var is_WMP7up = false;
        var WMPVer;
        var PatchedWMPVersion = '10.00.00.3802';

        if (is_win && is_ie)
        {
            var objMediaPlayer;
            try
            {
                objMediaPlayer = new ActiveXObject("MediaPlayer.MediaPlayer.1");
                is_WMP = true;
                is_WMP64 = true;
            }
            catch(objError)
            {
                is_WMP = false;
                is_WMP64 = false;
            }

            if (is_WMP)
            {
                try
                {
                    objMediaPlayer = new ActiveXObject("WMPlayer.OCX");
                    is_WMP7up = true;
                }
                catch(objError) {
                    is_WMP7up = false;
                }
            }
            if (is_WMP7up)
            {
                WMPVer = objMediaPlayer.versionInfo;
                objMediaPlayer = null;
            }
            else
            {
            	WMPVer = "6.4";
			}

            var is_WMPMinor = parseFloat(WMPVer);
            var is_WMPMajor = parseInt(is_WMPMinor);

            is_WMP10up = (is_ie) ? (is_WMPMinor >= 10) : is_WMP;
            is_WMP9 = (is_ie) ? (is_WMPMinor == 9) : false;

            // Update the detected version
            MetaWrap.Platform.MediaManager.SpecCheck.g_wmp_version = WMPVer;


            // If WMP is Version 10 or above.
            if (is_WMP10up)
            {
				// we don't care if they hare individualised
				return true;

                // create a WMP security and licensing object.
                document.write('<div id="killme"><object id="netobj"  classid=clsid:A9FC132B-096D-460B-B7D5-1DB0FAE0C062 width=0 height=0></object></div>');

				try
				{
					// Check individualisation - this works the most reliably.
					MetaWrap.Platform.MediaManager.SpecCheck.g_individualised = checkIndividualisation();

	                // Check if the WMP DRM version meets the Patched Version - this sometimes falls over... (see catch)
	                var drmVersion = netobj.GetDRMVersion();

					// Check for a specific patch version...
	                if (WmpPatchLevelsOk(PatchedWMPVersion,drmVersion))
	                {
	                    return true;
	                }
                }

                catch(l_e)
                {
                	// so that failed - as a last resort (if we need to) lets go through the MM API.

					if (!MetaWrap.Platform.MediaManager.SpecCheck.g_individualised)
					{
                            var l_media_manager = null;
					        try
					        {
                                try
                                {
                                    // Try the old method
                                    l_media_manager = new ActiveXObject('thePlatform.MediaManager.ActiveX.Wrapper');

                                }
                                catch(l_e)
                                {
                                }

                                // If that failed
                                if (l_media_manager == null)
                                {
                                    // Try the new method
                                    var l_factory = new ActiveXObject('thePlatform.MediaManager.ActiveX.AxMediaManagerFactory');

                                    // request a new object
                                    l_media_manager = l_factory.GetRemoteMediaManager();
                                }

					            MetaWrap.Platform.MediaManager.SpecCheck.g_individualised = l_media_manager.IsIndividualized;

					        }
					        catch(l_e)
					        {

					        }
					}


					return MetaWrap.Platform.MediaManager.SpecCheck.g_individualised;
                }
            }
            else if (is_WMP9)
            {
				return true;
			}


        }
        else
        {
            // Must be mozilla or another OS
            is_WMP = (typeof navigator.mimeTypes["application/x-mplayer2"] == "object");
        }
    }

    /************
     * END: Windows media player check
     */

     return false;
}




/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkOS = function()
    @brief      Detect the operating system version
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkOS = function()
{
     /************
     * BEGIN: Operating System Check
     */

    {
        if (navigator.appVersion.toLowerCase().indexOf("win")!=-1) MetaWrap.Platform.MediaManager.SpecCheck.g_os_version="Windows";
        if (navigator.appVersion.toLowerCase().indexOf("mac")!=-1) MetaWrap.Platform.MediaManager.SpecCheck.g_os_version="MacOS";
        if (navigator.appVersion.toLowerCase().indexOf("x11")!=-1) MetaWrap.Platform.MediaManager.SpecCheck.g_os_version="UNIX";
        if (navigator.appVersion.toLowerCase().indexOf("linux")!=-1) MetaWrap.Platform.MediaManager.SpecCheck.g_os_version="Linux";

        // If windows was detected, explore further to find the version
        if (MetaWrap.Platform.MediaManager.SpecCheck.g_os_version == 'Windows')
        {

            if (navigator.userAgent.toLowerCase().indexOf("windows 95") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows 95";
            }
            else if(navigator.userAgent.toLowerCase().indexOf("win95") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows 95";
            }
            if (navigator.userAgent.toLowerCase().indexOf("windows 98") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows 98";
            }
            else if(navigator.userAgent.toLowerCase().indexOf("win98") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows 98";
            }
            else if(navigator.userAgent.toLowerCase().indexOf("windows nt 4.0") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows NT";
            }
            else if(navigator.userAgent.toLowerCase().indexOf("windows nt 5.0") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows 2000";
            }
            else if(navigator.userAgent.toLowerCase().indexOf("windows nt 5.1") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows XP";
                return true;
            }
            else if(navigator.userAgent.toLowerCase().indexOf("windows 2000") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows 2000";
            }
            else if(navigator.userAgent.toLowerCase().indexOf("windows nt 6.") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows Vista";
                return true;
            }
            else if(navigator.userAgent.toLowerCase().indexOf("windows nt") != -1) {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows (Post 2007)";
                return true;
            }
            else
            {
                MetaWrap.Platform.MediaManager.SpecCheck.g_os_version = "Windows (unknown version) " + navigator.userAgent;
            }
        }
    }

     /************
     * END: Operating System Check
     */

     return false;
}

/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkBrowser = function()
    @brief      Detect the browser
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkBrowser = function()
{
     /************
     * BEGIN: Browser Check
     */
    {
        // Use a string tokenizer to break up the user agent
        var separator = " ";

        var tokenizer = new StringTokenizer (navigator.userAgent, separator);

        var foundBrowser = false;
        while (tokenizer.hasMoreTokens() && !foundBrowser)
        {
            // Get the next token
            var token = tokenizer.nextToken();

            // Check if the MSIE can be found in a token
            if (token.toLowerCase().indexOf("msie") != -1)
            {
                // IE has been found
                MetaWrap.Platform.MediaManager.SpecCheck.g_browser_version = "I.E";
                foundBrowser = true;

                // Now check the next token which should contain the version
                if (tokenizer.hasMoreTokens()) {
                    var nextToken = tokenizer.nextToken();

                    // Remove any semi colons
                    nextToken = nextToken.replace(";", "");

                    // Add the browser version to the detected browser string
                    MetaWrap.Platform.MediaManager.SpecCheck.g_browser_version = MetaWrap.Platform.MediaManager.SpecCheck.g_browser_version + " v" + nextToken;

                    // Pass the if the version is later than 5.5 (if token is not a number it will be handled)
                    try {
                        if (nextToken >= 6.0)
                        {
                            return true;
                        }
                    }
                    catch (objError) {
                        // Token must not have been a valid number
                    }
                }
            }

            // Check to see if the browser is of type FireFox
            else if (token.toLowerCase().indexOf("firefox") != -1) {
                // Browser is of type FireFox so show the full token as the detected browser
                MetaWrap.Platform.MediaManager.SpecCheck.g_browser_version = token;
            }
        }  // end while
    }

     /************
     * END: Browser Check
     */

     return false;
}

/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkDotNetFramework = function()
    @brief      Detect the .NET framework
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkDotNetFramework = function()
{
     /************
     * BEGIN: .Net Framework Check
     */

    {
        if (navigator.appVersion.toLowerCase().indexOf(".net clr") != -1) {

            // A version of the framework is installed so check the version by
            // using a string tokenizer to break up the app version string
            var separator = "; ";

            var tokenizer = new StringTokenizer (navigator.appVersion.toLowerCase(), separator);

            //alert(navigator.appVersion.toLowerCase());

            var foundToken = false;
            while (tokenizer.hasMoreTokens() )
            {

                // Get the next token
                var token = tokenizer.nextToken();

                // Check if it is the .Net token
                if (token.indexOf(".net clr") != -1) {
                    foundToken = true;

                    // Token is in the form of ".NET CLR 1.1.4322" so tokenise the token by space
                    var tokenSeparator = " ";
                    var tokenTokenizer = new StringTokenizer (token, tokenSeparator);

                    var foundVersion = false;
                    while (tokenTokenizer.hasMoreTokens() && !foundVersion) {

                        // Get the next token
                        var dotNetToken = tokenTokenizer.nextToken();

                        // Check if it is the .Net token
                        if (dotNetToken.indexOf(".net") == -1 && dotNetToken.indexOf("clr") == -1) {
                            foundVersion = true;

                            // Remove any brackets that may exist around the version number
                            if (dotNetToken.indexOf("(") != -1) {
                                dotNetToken = dotNetToken.substring(dotNetToken.indexOf("("), dotNetToken.length);
                            }
                            if (dotNetToken.indexOf(")") != -1) {
                                dotNetToken = dotNetToken.substring(0, dotNetToken.indexOf(")"));
                            }

                            // Save the version detected
                            MetaWrap.Platform.MediaManager.SpecCheck.g_dotnet_version = dotNetToken;

                            //alert(MetaWrap.Platform.MediaManager.SpecCheck.g_dotnet_version);

                            var l_dnf = MetaWrap.Platform.MediaManager.SpecCheck.g_dotnet_version.split('.');

                            //alert(MetaWrap.Platform.MediaManager.SpecCheck.g_dotnet_version);
                            //alert(l_dnf[0]);
                            //alert(l_dnf[1]);

                            // Check if the version meets the min requirements
                            if (
                               ((l_dnf[0] == 1) && (l_dnf[1] >= 1))
                                ||
                                ((l_dnf[0] == 3) && (l_dnf[1] >= 0))
                                )
                            {

                                // Test passed
                                return true;
                            }
                        }

                    } // END while
                }
            }  // end while
        }
    }

     /************
     * END: .Net Framework Check
     */

     return false;
}


/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkViiVMM = function()
    @brief      Detect the ViiV Media Manager
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkViiVMM = function()
{

        try
        {

            var l_media_manager = null;

            try
            {
                // Try the old method of registration
                l_media_manager = new ActiveXObject('thePlatform.MediaManager.ActiveX.Wrapper');

                if (l_media_manager != null)
                {
                	return true;
                }
            }
            catch(l_e)
            {
            	l_media_manager = null;
            }

            // If that failed - we try the new method of registration
            if (l_media_manager == null)
            {

                // Try the new method
                var l_factory = new ActiveXObject('thePlatform.MediaManager.ActiveX.AxMediaManagerFactory');

                // request a new object
                l_media_manager = l_factory.GetRemoteMediaManager();
            }

            try
            {
            	var l_sc = MetaWrap.Platform.MediaManager.SpecCheck;

                l_sc.g_media_manager_version = "" + l_media_manager.Version;

                // If the version we require is greater than the version we have..
                if (l_sc.g_media_manager_version_required > l_sc.g_media_manager_version)
                {
                    // then fail detection to force the user to upgrade
                	return false;
                }
            }
            catch(l_e2)
            {

            }

            return (l_media_manager != null);
        }
        catch(l_e)
        {

            return false;
        }

}

/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkViiVRemoted = function()
    @brief      Detect if ViiV thinks we are remoted
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkViiVRemoted = function()
{
    try
    {
        var platform = new ActiveXObject("IntelDH.Platform");
        if (platform.GetFeature("/IntelDH/ApplicationServer"))
        {
            var appServer = new ActiveXObject("IntelDH.ApplicationServer");
            var session = appServer.GetSession("");
            if (session)
                return true;
            else
                return false;
        }
    }
    catch (e)
    {
        return false;
    }
    return false;
}

/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkMCE = function()
    @brief      Detect if we are running in WMC mode
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkMCE = function()
{
    try
    {
        // if this is not a console session ...
        if (window.external.MediaCenter != null)
        {

            try
            {
                var nMajVer = window.external.MediaCenter.MajorVersion
            }
            catch (e)
            {
                MetaWrap.Platform.MediaManager.SpecCheck.g_wmc_version = "";
            }
            if (nMajVer < 7)
            {
                MetaWrap.Platform.MediaManager.SpecCheck.g_wmc_version = "2004";
            }
            else
            if (nmajVer = 7)
            {
                MetaWrap.Platform.MediaManager.SpecCheck.g_wmc_version =  "2005";
            }
            else
            {
               MetaWrap.Platform.MediaManager.SpecCheck.g_wmc_version =  "2005+";
            }

            return true;
        }
        else
        {
            // If not, this is a Media Center session on the console PC, so return false

            return false
        }
    }
    catch(e)
    {
        /* If above cause errors, user is probably accessing from a browser outside of Media Center.
        Return false to indicate that it is not an extender session. */
        return false
    }
}

/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkMCERemoted = function()
    @brief      Detect if we are running in WMC Remoted mode
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkMCERemoted = function()
{
    try
    {
        // if this is not a console session ...
        if (window.external.MediaCenter.Capabilities.IsConsole == false)
        {
            /* ...then it is either a Media Center Extender session or a traditional Remote Desktop session.
             To tell which type of session it is, check if video is allowed. If video is allowed... */
            if (window.external.MediaCenter.Capabilities.IsVideoAllowed == true)
            {
                // ... then it is an extender session, so return true
                return true
            }
            // Media Center does not allow video in a traditional Remote Desktop session. So if video is not allowed ...
            else
            {
                /* IsConsole and IsVideoAllowed are both false false, so user is accessing through a traditional Remote
                Desktop session, rather than from an extender device. That means that they probably have access to a keyboard
                and mouse, but they cannot play video. If your application features video playback, you may want to
                adjust your functionality for this user accordingly.
                Returning false simply indicates that this is not an Extender session.  */
                return false
            }
        }
        else
        {
            // If not, this is a Media Center session on the console PC, so return false
            return false
        }
    }
    catch(e)
    {
        /* If above cause errors, user is probably accessing from a browser outside of Media Center.
        Return false to indicate that it is not an extender session. */
        return false
    }
}


/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.checkViiV = function()
    @brief      Detect if we are running in ViiV enabled machine
    @return     boolean true if its been detected
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.checkViiV = function()
{
    try
    {
        // instantiate IntelDH ActiveX Control
        var platform = new ActiveXObject("IntelDH.Platform");

        // check if you are running on an Intel® Viiv technology-based PC
        if (!platform.GetFeature("/IntelDH"))
            return false;
    }
    catch (e)
    {
        // an exception will occur if you cannot instantiate the control
        // this control should not exist on PCs that do not contain
        // Intel® Viiv™ technology
        return false;
    }
    // you are running on an Intel® Viiv technology-based PC
    return true;
}

/*!
    @fn         MetaWrap.Platform.MediaManager.SpecCheck.run = function()
    @brief      Run all the spec checks and return an object with the results
    @return     An object
    @author     James Mc Parlane
    @date       1 August 2006
*/
MetaWrap.Platform.MediaManager.SpecCheck.run = function()
{
/*
	var l_result = {
		m_media_manager : false,
		m_wmc : true,
		m_viiv : true,
		m_viiv_remoting : false,
		m_dot_net : true,
		m_browser : true,
		m_os : true,
		m_wmp : true,

		m_media_manager_version : "",
		m_os_version : "XP Service Pack 2",
		m_wmp_version : "10.0.0.3802"
	};
*/

		// Start with an empty result
		var l_result = {};

		// Populate the flags that tell us what has been detected
		l_result.m_media_manager = MetaWrap.Platform.MediaManager.SpecCheck.checkViiVMM();
		l_result.m_wmc = MetaWrap.Platform.MediaManager.SpecCheck.checkMCE();
		l_result.m_wmc_remoting = MetaWrap.Platform.MediaManager.SpecCheck.checkMCERemoted();
		l_result.m_viiv = MetaWrap.Platform.MediaManager.SpecCheck.checkViiV();
		l_result.m_viiv_remoting = MetaWrap.Platform.MediaManager.SpecCheck.checkViiVRemoted();
		l_result.m_dot_net = MetaWrap.Platform.MediaManager.SpecCheck.checkDotNetFramework();
		l_result.m_browser = MetaWrap.Platform.MediaManager.SpecCheck.checkBrowser();
		l_result.m_os = MetaWrap.Platform.MediaManager.SpecCheck.checkOS();
		l_result.m_wmp = MetaWrap.Platform.MediaManager.SpecCheck.checkWMP();
   		l_result.m_indiv = MetaWrap.Platform.MediaManager.SpecCheck.g_individualised;
   		l_result.m_flash = MetaWrap.Platform.MediaManager.SpecCheck.checkFlash();

   		// Versions of the components that have been detected
        l_result.m_media_manager_version = MetaWrap.Platform.MediaManager.SpecCheck.g_media_manager_version;
		l_result.m_os_version = MetaWrap.Platform.MediaManager.SpecCheck.g_os_version;
		l_result.m_wmp_version = MetaWrap.Platform.MediaManager.SpecCheck.g_wmp_version;
		l_result.m_indiv_version = MetaWrap.Platform.MediaManager.SpecCheck.g_individualisation_version;
		l_result.m_wmc_version = MetaWrap.Platform.MediaManager.SpecCheck.g_wmc_version;
		l_result.m_flash_version = MetaWrap.Platform.MediaManager.SpecCheck.g_flash_version;
		l_result.m_dotnet_version = MetaWrap.Platform.MediaManager.SpecCheck.g_dotnet_version;

		return l_result;
}

// Save our result
MetaWrap.Platform.MediaManager.SpecCheck.m_result = MetaWrap.Platform.MediaManager.SpecCheck.run();


