// Javascript detection of plug-ins and mime types

//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer
// (use the above exactely for text comparisons!!)

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);

if (ie && win) {
	pluginlist = detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") +
				detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player"); 
				// removed this because it gives a warning with IE 7
				//detectIE("QuickTimeCheckObject.QuickTimeCheck.1","3GP") +
}
if (ns || !win) {
		nse = ""; 
		for (var i=0;i<navigator.mimeTypes.length;i++) 
			nse += navigator.mimeTypes[i].type.toLowerCase();
		pluginlist = detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + 
					detectNS("video/quicktime","Quicktime") + 
					detectNS("application/sdp","3GP") + 
					detectNS("application/x-mplayer2","Windows Media Player");
}

// IE doesn't keep a list of mimetypes, the only way is to use VBScript
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 ''; 
}

// Use only mime types in the case of Mozilla, because the plug-in may not have been
// installed yet although the mime type is recognized.
function detectNS(ClassID,name) {
	n = "";
	if (nse.indexOf(ClassID) != -1) {
		//if (navigator.mimeTypes[ClassID].enabledPlugin != null)  see note above
			n = name+",";
	}
	return n; 
}

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

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