
function DetectFlashPlugin()
{
    var flashVersion = false;

    if ((navigator.plugins != null) && 
        (navigator.plugins.length > 0) && 
        (navigator.plugins["Shockwave Flash"] != null))
    {
        var desc = navigator.plugins["Shockwave Flash"].description;
        if (desc != null)
        {
            var re = /(\d+)\.\d+/;
            re.exec(desc);
            if (RegExp.$1.length > 0)
                flashVersion = parseInt(RegExp.$1, 10);
            else
                flashVersion = 1;
        }
        else
            flashVersion = 1;
    }
    else if ((navigator.mimeTypes != null) && 
             (navigator.mimeTypes.length > 0) && 
             (navigator.mimeTypes["application/x-shockwave-flash"] != null) && 
             (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin))
    {
        flashVersion = 1;    
    }
    else
    {
        for (var i = 9; i >= 3; i--)
        {
            try
            {
                var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i.toString());
                flashVersion = i;
                break;
            }
            catch (e) { }
        }
    }
    
    return flashVersion;
}
