
function JPlug(){
	var that=this;
	window['MMSS_PLUGIN']=null;
	var MICROSOFT_VBCODE_HEAD="<"+'script language="VBscript"'+">"+'\n on error resume next'+'\n VBScriptEngine = False'+'\n If ScriptEngineMajorVersion >= 2 then'+'\n VBScriptEngine = True'+'\n End If'+'\n'+"<"+'/scr'+'ipt'+">";
	var MICROSOFT_VBCODE_BODY="<"+'script language="VBscript"'+">"+'\n If VBScriptEngine Then'+'\n on error resume next'+'\n CreateObject("JavaPlugin")'+'\n If Err.Number <> 0 Then'+'\n MMSS_PLUGIN = false'+'\n Else'+'\n MMSS_PLUGIN = true'+'\n End If'+'\n End If'+"<"+'/scr'+'ipt'+">";
	var PLUGINS_NAME='Java';
	var MIMETYPES_NAME='application/x-java-applet';
	
	function getPluginsJava()
	{
		if(navigator.plugins && navigator.plugins.length && navigator.plugins.length > 1)
		{
			var plugs = navigator.plugins;
			for(var i=0;i<plugs.length;i++)
			{
				if(plugs[i].name.toLowerCase().indexOf(PLUGINS_NAME.toLowerCase())!= -1)
				{
					return true;
				}
			}
			return false;
		}
		return null;
	}
	
	function getMimeTypesJava()
	{
		if(navigator.mimeTypes && navigator.mimeTypes.length && navigator.mimeTypes.length > 0)
		{
			for(var i=0;i<navigator.mimeTypes.length;i++)
			{
				if(navigator.mimeTypes[i].description.toLowerCase().indexOf('java') != -1)
				{
					if(navigator.mimeTypes[i].type.toLowerCase().indexOf(MIMETYPES_NAME) != -1)
					{
						that.pluginMimeInfo.name=navigator.mimeTypes[i].enabledPlugin.name;
						that.pluginMimeInfo.description=navigator.mimeTypes[i].enabledPlugin.description;
						that.pluginMimeInfo.filename=navigator.mimeTypes[i].enabledPlugin.filename;
						that.pluginMimeInfo.length=navigator.mimeTypes[i].enabledPlugin.length;
						for(var m=0;m<that.pluginMimeInfo.length;m++)
						{
							for(y in navigator.mimeTypes[i].enabledPlugin[m])
							{
								if(y=='type')
								{
									that.pluginMimeInfo.typeStrings += navigator.mimeTypes[i].enabledPlugin[m][y]+', ';
								}
							}
						}
						that.isMimeListed=true;
						return;
					}
				}
			}
		}
		that.isMimeListed=false;
	}
	
	function get()
	{
		if(getPluginsJava() != null && navigator.javaEnabled)
		{
			that.isEnabled = navigator.javaEnabled();
			return navigator.javaEnabled();
		}
		return null;
	}
	
	function init()
	{
		if(navigator.userAgent.toLowerCase().indexOf('mac') == -1 && window.ActiveXObject)
		{
			document.write(MICROSOFT_VBCODE_HEAD);
		}
	}
	
	function exec()
	{
		that.isPluginsListed = (getPluginsJava() != null) ? getPluginsJava() : false;
		getMimeTypesJava();
		get();
	}
	
	function detectMicrosoft()
	{
		if(typeof VBScriptEngine != 'undefined')
		{
			document.write(MICROSOFT_VBCODE_BODY);
		}
				
		if(window['MMSS_PLUGIN'] != null)
		{
			that.isEnabled=window['MMSS_PLUGIN'];
		}
	}
	
	this.detect = function()
	{
		init();
		exec();
		detectMicrosoft();
		return that.isEnabled;
	};
	
	this.output=function()
	{
		var jPluginStr='<p><b>Java Plugin Detection [JPlug Class]</b></p>';
		if((that.isPluginsListed !=null) && (that.isMimeListed != null))
		{
			jPluginStr+='<p>Listed in navigator.plugins: '+that.isPluginsListed+'<br />\n'+'Listed as a mime-type: '+that.isMimeListed+'<br />\n'+'<b>This browser is Java-enabled</b>: <font color="red">'+that.isEnabled+'</font><br /></p>\n';
			if(that.pluginMimeInfo.typeStrings!='')
			{
				jPluginStr+='<p>Additional information provided by the browser (first entry found only): '+'<br />Name: '+'<i>'+that.pluginMimeInfo.name+'</i>'+'<br />Description: '+'<i>'+that.pluginMimeInfo.description+'</i>'+'<br />Filename: '+'<i>'+that.pluginMimeInfo.filename+'</i>'+'<br />Listed mime-type strings: '+'<i>'+that.pluginMimeInfo.typeStrings+'</i>'+'</p>';
			}
		}
		else
		{
			jPluginStr+='<p>Nothing to output. You must instantiate and call the detect() method on the JPlug class before doing any output:</p>'+'<code>MyJPlugin.detect();</code>';
		}
		document.write(jPluginStr);
	};
	
	this.isPluginsListed=null;
	this.isMimeListed=null;
	this.pluginMimeInfo={name:null,length:0,description:null,filename:null,typeStrings:''};
	this.isEnabled=null;
	if(typeof _instance=='undefined'){_instance=this;}
	return _instance;
};