/*
 *  Copyright 2000 Quidnunc All Rights Reserved
 *
 *  detect_flash.js
 *
 *  This is the JavaScript flash sniffer.
 *
 *  Author: Quidnunc
 *  Version: d3
 *
 *
 *  Ver Date            Who                     Comments
 *  -------------------------------------------------------------------------
 *  d1  00-Oct-200      Nathan Reetz            Created.
 *  d2  18-Jun-2001     Nathan Reetz            Reviewed.
 *  d3  12-Jul-2001     Chris Pederick          Updated to use new browser
 *                                               sniffer.
 *  -------------------------------------------------------------------------
 */

// --------------------------------------------------------------------------
// Variables
// --------------------------------------------------------------------------

var bFlash2Installed = false;
var bFlash3Installed = false;
var bFlash4Installed = false;
var bFlash5Installed = false;
var iMaxVersion      = 5;

// Calls the code and sets the variables above
detectFlash();

/*
 * Detects flash and sets the variables accordingly.
 */
function detectFlash()
/*
Ver Date          Who                     Comments
-------------------------------------------------------------------------
d3  12-Jul-2001   Chris Pederick          Created.
-------------------------------------------------------------------------
*/
{
    if(isInternetExplorer() && isWindows())
    {
        // Do VBScript test for Windows IE
        document.write('<SCR' + 'IPT LANGUAGE="VBScript"\>\n');
        document.write('on error resume next\n');
        document.write('bFlash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2")))\n');
        document.write('bFlash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n');
        document.write('bFlash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
        document.write('bFlash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
        document.write('</SCR' + 'IPT\>\n');
    }
    else if(navigator.plugins)
    {
        // Do JavaScript test for other browsers
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"])
        {
            var sVersion2         = "";
            var sFlashDescription = "";
            var iFlashVersion     = 0;

            // If is version 2
            if(navigator.plugins["Shockwave Flash 2.0"])
            {
                sVersion2 = " 2.0";
            }

            sFlashDescription = navigator.plugins["Shockwave Flash" + sVersion2].description;
            iFlashVersion     = parseInt(sFlashDescription.charAt(sFlashDescription.indexOf(".") - 1));

            if(iFlashVersion == 2)
            {
                bFlash2Installed = true;
            }
            else if(iFlashVersion == 3)
            {
                bFlash3Installed = true;
            }
            else if(iFlashVersion == 4)
            {
                bFlash4Installed = true;
            }
            else if(iFlashVersion == 5)
            {
                bFlash5Installed = true;
            }
        }
    }
}

/*
 * Displays info about flash.
 */
function displayFlashInfo()
/*
Ver Date          Who                     Comments
-------------------------------------------------------------------------
d3  12-Jul-2001   Chris Pederick          Created.
-------------------------------------------------------------------------
*/
{
    var iActualVersion = 0;

    if(isFlash5())
    {
        iActualVersion = 5;
    }
    else if(isFlash4())
    {
        iActualVersion = 4;
    }
    else if(isFlash3())
    {
        iActualVersion = 3;
    }
    else if(isFlash2())
    {
        iActualVersion = 2;
    }

    // Displays info about flash
    alert("Flash version :: " + iActualVersion);
}

// --------------------------------------------------------------------------
// Selectors
// --------------------------------------------------------------------------

function isFlash2()
/*
Ver Date          Who                     Comments
-------------------------------------------------------------------------
d1  03-Jan-2001   Chris Pederick          Created.
-------------------------------------------------------------------------
*/
{
  if(bFlash2Installed)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function isFlash3()
/*
Ver Date          Who                     Comments
-------------------------------------------------------------------------
d1  03-Jan-2001   Chris Pederick          Created.
-------------------------------------------------------------------------
*/
{
  if(bFlash3Installed)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function isFlash4()
/*
Ver Date          Who                     Comments
-------------------------------------------------------------------------
d1  03-Jan-2001   Chris Pederick          Created.
-------------------------------------------------------------------------
*/
{
  if(bFlash4Installed)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function isFlash5()
/*
Ver Date          Who                     Comments
-------------------------------------------------------------------------
d1  03-Jan-2001   Chris Pederick          Created.
-------------------------------------------------------------------------
*/
{
  if(bFlash5Installed)
  {
    return true;
  }
  else
  {
    return false;
  }
}

