//
// DXStudioPlayer.js - Script to include the player's ActiveX control
// v1.01
//

var dxsutil = new Object();

dxsutil.DXStudioPlayer = function(src, id, width, height, noinstaller)
{
	if (!document.getElementById)
		return;
	this.params = new Object();
	this.src=src;
	this.id=id;
	this.width=width;
	this.height=height;
	this.noinstaller=noinstaller;
	this.paramString="";
}

dxsutil.DXStudioPlayer.prototype = {
	addParam: function(name, value)
	{
		this.params[name] = value;
	},
	getParams: function()
	{
		return this.params;
	},
	installer: function()
	{
		return !(this.noinstaller==true);
	},
	getHTML: function()
	{
		var nodeHTML = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length)
		{
			if (this.installer())
			{
				nodeHTML +='<div style="position: absolute; height:0px; width:0px; left:0px; "><embed type="application/x-dxstudioplayerinstall" id="dxsinstall" name="dxsinstall" classid="clsid:8EF6B33A-D553-4440-8EC1-CF1B0AFEE9D2" codebase="http://www.dxstudio.com/downloads/DXWebSetup.dll" width="0" height="0"></embed></div>';
				nodeHTML +='<scr'+'ipt for="dxsinstall" event="Installed(result)" language="javascript">if (result) history.go();</scr'+'ipt>';
				nodeHTML +='<scr'+'ipt for="dxsinstall" event="FoundPlayer(result)" language="javascript">//if (result) dxs.style.visibility="visible";</scr'+'ipt>';
			}
			nodeHTML = '<embed type="application/x-dxstudioplayer" src="'+ this.src +'" width="'+ this.width +'" height="'+ this.height +'"';
			nodeHTML += ' id="'+ this.id +'" name="'+ this.id +'" ';
			var params = this.getParams();
			for(var key in params)
				nodeHTML += [key] +'="'+ params[key] +'" ';
			nodeHTML += '/>';
		}
		else
		{
			if (this.installer())
			{
				nodeHTML +='<div style="position: absolute; height:0px; width:0px; left:0px; "><object name="dxsinstall" classid="clsid:8EF6B33A-D553-4440-8EC1-CF1B0AFEE9D2" codebase="http://www.dxstudio.com/downloads/DXWebSetup.dll" width="0" height="0"></object></div>';
				nodeHTML +='<scr'+'ipt for="dxsinstall" event="Installed(result)" language="javascript">if (result) history.go();</scr'+'ipt>';
				nodeHTML +='<scr'+'ipt for="dxsinstall" event="FoundPlayer(result)" language="javascript">//if (result) dxs.style.visibility="visible";</scr'+'ipt>';
			}
			nodeHTML += '<object id="'+ this.id +'" '+'classid="clsid:0AC2706C-8623-46F8-9EDD-8F71A897FDAE" width="'+ this.width +'" height="'+ this.height +'">';
			nodeHTML += '<param name="src" value="'+ this.src +'" />'+this.paramString;
			var params = this.getParams();
			for(var key in params)
				nodeHTML += '<param name="'+ key +'" value="'+ params[key] +'" />';
			nodeHTML += '</object>';
		}
		return nodeHTML;
	},
	write: function(elementId)
	{
		var elem = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
		elem.innerHTML = this.getHTML();
		return false;
	}
}

var DXStudioPlayer = dxsutil.DXStudioPlayer;

