//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer

//Detect Plugin (Flash, Java, RealPlayer etc) script- By Frederic (fw4@tvd.be)
//Visit http://javascriptkit.com for this script and more

//SAMPLE USAGE- detect "Flash"
//if (pluginlist.indexOf("Flash")!=-1)
//document.write("You have flash installed")

// Reformatted  and comments added by Jeff Hall, jeffhall@hallsinternet.com
// Removed detection of SVG, Shockwave Director, Shockwave Flash and Acrobat Reader
// 1/15/2002 Flash added back by rf 2/15/06

// Detect browser and OS
var agt = navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);
var pluginlist = "";

// If Internet Explorer running under windows
if (ie && win) {
	//pluginlist += detectIE("Adobe.SVGCtl","SVG Viewer"); 
    //pluginlist += detectIE("SWCtl.SWCtl.1","Shockwave Director");
    pluginlist += detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash");
    pluginlist += detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer");
    pluginlist += detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime");
    pluginlist += detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player");
    //pluginlist += detectIE("PDF.PdfCtrl.1","Acrobat Reader");
    }

// If Netscape or not windows (everything else)    
if (ns || !win) {
    nse = ""; 
    for (var i=0;i<navigator.mimeTypes.length;i++) {
        nse += navigator.mimeTypes[i].type.toLowerCase();
       // document.write(navigator.mimeTypes[i].type.toLowerCase()+'<br>');
    }
    //pluginlist += detectNS("image/svg-xml","SVG Viewer");
    // pluginlist += detectNS("application/x-director","Shockwave Director");

    pluginlist += detectNS("application/x-shockwave-flash","Shockwave Flash");
    pluginlist += detectNS("audio/x-pn-realaudio-plugin","RealPlayer");
    pluginlist += detectNS("video/quicktime","QuickTime");
    pluginlist += detectNS("application/x-mplayer2","Windows Media Player");
    //pluginlist += detectNS("application/pdf","Acrobat Reader");
}

// Detect under IE-windows, try to create specified object
function detectIE(ClassID,name) {
    result = false;
    document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n');
    if (result) return name+','; else return ''; 
}

// Detect under Netscape and others, check mime type list.
function detectNS(ClassID,name) {
    n = "";
    //document.write ('class id:' + ClassID + ' - ' + name + ' - ');
    //document.write (' index: ' + nse.indexOf(ClassID) + '<br>');
    
    if (nse.indexOf(ClassID) != -1) {
        if (navigator.mimeTypes[ClassID].enabledPlugin != null) {
            n = name+","; 
        }
    }
    return n;
}

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

function checkPlugin(name){
// Added by Jeff Hall 1-17-01
    if (pluginlist.indexOf(name) >= 0){
        return true;
    }
    else{
        return false;
    }
}

//----------------------------------------------------------------------------
// JH - added for testing
// only seems to works for Netscape
function showMimeTypes(){
    for (var i=0;i<navigator.mimeTypes.length;i++) {
        nse += navigator.mimeTypes[i].type.toLowerCase();
        document.write(navigator.mimeTypes[i].type.toLowerCase()+'<br>');
    }
}

function showNSPlugins(){
    for (var i=0;i<navigator.plugins.length;i++) {
        //nse += navigator.plugins[i].value;
        document.write(navigator.plugins[i].name+'<br>');
    }
}