//<script>

function PluginObject()
{
	this.document = document;
	this.fixAttrs = function(attrs) { /* default does nothing */ }
	this.init = function(attrs, params)
	{
		if (attrs != null)
		{
			this.fixAttrs(attrs);
			this.attrs = attrs;
		}
		if (params != null)
		{
			this.params = params;
		}
	}
	this.create = function(attrs, params)
	{
		this.init(attrs, params);
		Compat.writeObjectDefinition(this.document, this.attrs, this.params);
	}
	this.getNode = function() { return this.document.getElementById(this.attrs.id); }
	if (Compat.isIE)
	{
		this.getObject = function() { return this.getNode().object; }
		this.install = function(pluginName, fnPostInstall)
		{
			this.attrs.codebase = this.attrs.codebaseIE;
			this.document = Compat.createDocument();
			this.create();
			if (fnPostInstall != null)
			{
				var node = this.getNode();
				node.onreadystatechange = function()
				{
					if (node.readyState == 4)
						fnPostInstall((node.object == null) ? -1 : 0);	// 0 is success.
				}
			}
		}
	}
	if (Compat.isMoz)
	{
		this.getObject = this.getNode;
		this.install = function(pluginName, fnPostInstall)
		{
			var installHandler = null;
			if (typeof(fnPostInstall) == "function")
				installHandler = function(url, status) { fnPostInstall(status); }
			var plugin = { };
			plugin[pluginName] = this.attrs.codebaseMoz;
			InstallTrigger.install(plugin, installHandler);
		}
	}
}

var DRM = new PluginObject();
var SafeView = new PluginObject();

if (Compat.isIE)
{
	DRM.fixAttrs = function(attrs)		{ attrs.classid = "CLSID:41603E7E-4007-415b-9A8D-3D55B1460A2A"; }
	DRM.getOldComputerID = function(obj){ try { return obj.GetComputerID(); } catch (e) { return ""; }}
	DRM.getNewComputerID = function(obj){ try { return obj.GetComputerID(1); } catch (e) { return ""; }}
	DRM.getComputerName = function()	{ try { return this.getObject().GetComputerName(); } catch (e) { return ""; }}

	SafeView.fixAttrs = function(attrs) { attrs.classid = "CLSID:3743E8B0-BE34-4652-9F11-7C4EB22F39B9"; }
}
if (Compat.isMoz)
{
	function nu(s)	{ return (s == null) ? "" : s; }
 
	DRM.fixAttrs = function(attrs)		{ attrs.type = "application/x-safeview"; }
	DRM.getObject = function()			{ return this.document.getElementById(this.attrs.id); }
	DRM.getOldComputerID = function(obj){ try { return nu(obj.ComputerID); } catch (e) { return ""; }}
	DRM.getNewComputerID = function(obj){ try { return nu(obj.GetComputerID(1)); } catch (e) { return ""; }}
	DRM.getComputerName = function()	{ try { return nu(this.getObject().ComputerName); } catch (e) { return ""; }}

	SafeView.fixAttrs = function(attrs) { attrs.type = "application/x-safeview"; }
}

DRM.getComputerID = function ()
{
	try {
		var obj = this.getObject();
		this.version = obj.Test();
		if (this.version < "4.4" && getFirefoxVersion() == "3")
		{
			this.mustUpgrade = true;
			return "";
		}
		return (this.getNewComputerID(obj) || this.getOldComputerID(obj));
	} catch (e) { return ""; }
}
