var installedPlugins = {
    'java': navigator.javaEnabled()
};

(function(){
    var plugins = {
        'flash': {
            'mimeType': ['application/x-shockwave-flash'],
            'ActiveX': ['ShockwaveFlash.ShockwaveFlash', 'ShockwaveFlash.ShockwaveFlash.3', 'ShockwaveFlash.ShockwaveFlash.4', 'ShockwaveFlash.ShockwaveFlash.5', 'ShockwaveFlash.ShockwaveFlash.6', 'ShockwaveFlash.ShockwaveFlash.7']
        },
        'quicktime': {
            'mimeType': ['video/quicktime'],
            'ActiveX': ['QuickTime.QuickTime', 'QuickTimeCheckObject.QuickTimeCheck.1', 'QuickTime.QuickTime.4']
        }
    };
    
    //check support for a plugin
    function checkSupport(p){
        var support = false;
        
        //for standard compliant browsers
        if (navigator.mimeTypes) {
            for (var i = 0; i < p['mimeType'].length; i++) {
                if (navigator.mimeTypes[p['mimeType'][i]] && navigator.mimeTypes[p['mimeType'][i]].enabledPlugin) {
                    support = true;
                }
            }
        }
        
        //for IE
        if (typeof ActiveXObject != 'undefined') {
            for (var i = 0; i < p['ActiveX'].length; i++) {
                try {
                    new ActiveXObject(p['ActiveX'][i]);
                    support = true;
                } 
                catch (err) {
                }
            }
        }
        
        return support;
    }
    
    //we loop through all the plugins
    for (plugin in plugins) {
        //if we find one that's installed...
        if (checkSupport(plugins[plugin])) {
            //we add a property that matches that plugin's name to our "installedPlugins" object and set it's value to "true"
            installedPlugins[plugin] = true;
            
            //and add a class to the html element, for styling purposes
            document.documentElement.className += ' ' + plugin;
        }
        else {
            installedPlugins[plugin] = false;
        }
    }
})();
