function player(name) {
	this.open = function(table, uid, autoplay, player) {
		Autoplay = autoplay;
	
		var request = new swx_AjaxRequest("POST", "./modules/player/onopen.php", true);
		request.setResponseHandler(4, this.openPost);
		if (player)
			request.sendRequest("name=" + encodeURIComponent(Name) + "&table=" + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid) + "&player=" + encodeURIComponent(player));
		else
			request.sendRequest("name=" + encodeURIComponent(Name) + "&table=" + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid));
	}
	this.openPost = function(request) {
		// INFO: Extract document root from current URL.
		var root = window.location.href.substr(0, document.location.href.indexOf("index.php"));

		document.getElementById(Name).innerHTML = request.responseText;
		if (document.getElementById(Name+"_FlowPlayer")) {
			var container = document.getElementById(Name+"_FlowPlayer");
			var file = root+container.innerHTML;
			if (container.currentStyle) {
				var splash = container.currentStyle.backgroundImage;
				var height = parseInt(container.currentStyle.height);
				var width = parseInt(container.currentStyle.width);
			}
			else {
				var splash = document.defaultView.getComputedStyle(container, "").getPropertyValue("background-image");
				var height = document.defaultView.getComputedStyle(container, "").getPropertyValue("height");
				var width = document.defaultView.getComputedStyle(container, "").getPropertyValue("width");
			}

			// INFO: Remove 'url(...)' respectively 'url("...")' from the
			//       background-image property to use it as splash image URL.
			splash = (splash.charAt(4) == "\"") ? splash.substr(5, splash.length-7) : splash.substr(4, splash.length-5);

			if ((splash != "none") && (splash != ""))
				flashembed(Name+"_FlowPlayer", {src:'./modules/player/flowplayerdark.swf'}, {config: {backgroundColor:'0x000000', controlBarBackgroundColor:'0x000000', controlBarGloss:'none', splashImageFile:splash, autoPlay:false, loop:false, autoRewind:true, initialScale:'fit', videoFile:file}});
			else
				flashembed(Name+"_FlowPlayer", {src:'./modules/player/flowplayerdark.swf'}, {config: {backgroundColor:'0x000000', controlBarBackgroundColor:'0x000000', controlBarGloss:'none', autoPlay:Autoplay, loop:false, autoRewind:true, initialScale:'fit', videoFile:file}});	
		}
		else if (document.getElementById(Name+"_QuicktimePlayer")) {
			var container = document.getElementById(Name+"_QuicktimePlayer");
			var file = root+container.innerHTML;
			if (container.currentStyle) {
				var height = parseInt(container.currentStyle.height);
				var width = parseInt(container.currentStyle.width);
			}
			else {
				var height = document.defaultView.getComputedStyle(container, "").getPropertyValue("height");
				var width = document.defaultView.getComputedStyle(container, "").getPropertyValue("width");
			}

			var playercode = "<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\" height=\""+height+"\" width=\""+width+"\">";
			playercode += "<param Name=\"src\" value=\""+file+"\">";
			playercode += "<param Name=\"Autoplay\" value=\""+String(Autoplay)+"\">";
			playercode += "<param Name=\"scale\" value=\"ToFit\">";
			playercode += "<param Name=\"bgcolor\" value=\"#000000\">";
			playercode += "<param Name=\"type\" value=\"video/quicktime\">";
			playercode += "<embed src=\""+file+"\" height=\""+height+"\" width=\""+width+"\" bgcolor=\"#000000\" scale=\"ToFit\" Autoplay=\""+String(Autoplay)+"\" type=\"video/quicktime\" pluginspage=\"http://www.apple.com/quicktime/download/\">";
			playercode += "</object>";
			document.getElementById(Name+"_QuicktimePlayer").innerHTML = playercode;
		}

		if (container) container.parentNode.style.width = width;
	}

	var Autoplay = false;
	var Name = name;
}
