/* Detector.js 
   Build time: 13/04/2009-14:36:48  Copyright (c) 2008-2131 Patrick 'Zener' Brunet */

/* Requires MainLinker.js */

var _kuDelay = 2000;
var _bPNGCheckDone = false;
var _ucTicks = 0;

function DoDetection()
{
    var uwScreen = screen.width;
    var tDhtml = "no";
    var tAgent = "unknown";

    try
    {
        tAgent = navigator.userAgent.toLowerCase();
        if( document.getElementById( 'Main') != null)
            if( document.getElementById( 'Main').innerHTML != null)
                tDhtml = "yes";
        if( document.getElementById( 'ztDHTML_1') != null)
            document.getElementById( 'ztDHTML_1').value = tDhtml;
        /* Force the PNG support (using the fix) for IE from v5.5 to v6.x (not IE 7) */
        if( document.getElementById( 'ztPNG_1') != null)
        {
            if( (tAgent.indexOf( "msie 5.5") != -1 || tAgent.indexOf( "msie 6.") != -1)
                && tAgent.indexOf( "opera") == -1   /* Opera fakes it */
                && window._bPNGCheckDone)                  /* IE fix script has run OK */
            {
                document.getElementById( 'ztPNG_1').value = "yes";
                document.getElementById( 'ztBkPNG_1').value = "no";
            }
            if( tAgent.indexOf( "msie 7") != -1 && tAgent.indexOf( "opera") == -1)
            {
                /* Native support in IE v.7, despite it does not tell it :-@ */
                document.getElementById( 'ztPNG_1').value = "yes";
                document.getElementById( 'ztBkPNG_1').value = "yes";
            }
        }
        if( document.getElementById( 'ztFlash_1') != null)
            if( IsFlashEnabled())
                document.getElementById( 'ztFlash_1').value = "yes";
        if( document.getElementById( 'ztScreenW_1') != null)
            document.getElementById( 'ztScreenW_1').value = uwScreen;
    }
    catch( e)
    {
        /* In case of error (IE 4 ?), restore the manual entry - HideElementAsap.js.src */
        document.getElementById( 'ButtonOK').style.display = 'inline';
    }
    setTimeout( 'Tick()', _kuDelay / 10);
}

function Tick()
{
    _ucTicks += 1;
    if( _ucTicks > 0 && _ucTicks <= 10)
        document.getElementById( "PB" + _ucTicks).className = "Active";
    if( _ucTicks == 10)
        document.getElementById( "Detector").submit();
    else
        setTimeout( 'Tick()', _kuDelay / 10);
}

/*-------------------------------------------
    Flash detection adapted (but a major problem found) from:
    sIFR v2.0.2 SOURCE
    Copyright 2004 - 2006 Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
    This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

function IsFlashEnabled()
{
    var uRequiredVersion = 6;

    if( navigator.appVersion.indexOf( "MSIE") != -1 
        && navigator.appVersion.indexOf( "Windows") > -1)
    {
      /*-------------------------------------------
        var tTestScript = '<script type="text/vbscript"\> \non error resume next \nbHasFlash = '
                          + '(IsObject( CreateObject( "ShockwaveFlash.ShockwaveFlash." & ' 
                          + uRequiredVersion + '))) \n</script\> \n';
      */
      /* Deletes the <body> !!! :-@   document.write( tTestScript);*/
      /* Rather do that in 100% Javascript */
        try
        {
            var oTest = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + uRequiredVersion);
            window.bHasFlash = true;
        }
        catch( e)
        {
        }
        /* If executed, the VBScript above checks for Flash and sets the bHasFlash variable. 
           If VBScript is not supported bHasFlash will keep undefined, so another test will 
           be done to make sure even Opera identified as IE will be tested. */
        if( window.bHasFlash != null)
            return( window.bHasFlash);
    }
    if( navigator.mimeTypes 
        && navigator.mimeTypes["application/x-shockwave-flash"] 
        && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
    {
        var tFlashDescription = (navigator.plugins["Shockwave Flash 2.0"] 
                                || navigator.plugins["Shockwave Flash"]).description;
        var nVersion = parseInt( tFlashDescription.charAt( tFlashDescription.indexOf( ".") - 1));
        return( nVersion >= uRequiredVersion);
    }
    return( false);
}

MainLinkerRegister( DoDetection);

/* End */

