
function PlaySound (src)
{
	this.src = src;
	this.width = 150;
	this.height = 46;

	this.sound_enabled = 0;
	this.plugin_enabled = 0;

	this.pluginUrl = "http://docs.info.apple.com/article.html?artnum=120133";

	this.useWMP 	= this.Detect ('MediaPlayer.MediaPlayer.1', 'application/x-mplayer2');
	this.useQT	= this.Detect ('QuickTimeCheckObject.QuickTimeCheck.1', 'video/quicktime');

	this.Check ();
}

PlaySound.prototype.Detect = function (chkTypeIE, chkTypeOther) {

	result = false;

	if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1))
	{
		document.write("<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject(\"" + chkTypeIE + "\"))</SCRIPT>\n");
	}
	else
	{
		if (navigator.mimeTypes && navigator.mimeTypes[chkTypeOther] && navigator.mimeTypes[chkTypeOther].enabledPlugin != null)
			result = true;
	}

	return result;
}

PlaySound.prototype.Write = function () {

	var IE4, NS, Win, Mac;

	IE4 = (document.all) ? 1 : 0;

	NS = (document.layers) ? 1 : 0;

	Mac = ((navigator.userAgent.toLowerCase()).indexOf("mac")!=-1);

	var IE = ((navigator.userAgent.toLowerCase()).indexOf("msie") != -1);

	if (Mac)// || !IE)
	{
		this.height = 29;
	}

	with (document)
	{
		if (this.sound_enabled)
		{
			if (this.useWMP)
			{
				this.height = 46;

				if (IE)
				{
					write ('<OBJECT ID="Player" height="' + this.height + '" width="' + this.width + '" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">\n');
					write ('<PARAM name="autoStart" value="False">\n');
					write ('<PARAM name="URL" value="' + this.src + '">\n');
					write ('</OBJECT>\n');

				}
				else
				{
					write ('<EMBED SRC="' + this.src + '" WIDTH="' + this.width + '" HEIGHT="' + this.height + '" autostart="0" type="application/x-mplayer2">\n');
				}
			}
			else
			{
				this.height = 20;
				write ('<EMBED SRC="' + this.src + '" WIDTH="' + this.width + '" HEIGHT="' + this.height + '" autostart="0">\n');
			}
		}
		/*
		else if (Mac)
  		{
			write ('<img src="../errmacl.gif" width="' + this.width + '" border="0" usemap="#mapErr">\n');
			write ('<map name="mapErr">\n');
			write ('<AREA ALT="" COORDS="0,62,313,73" HREF="http://docs.info.apple.com/article.html?artnum=120132" TARGET="_blank">\n');
			write ('</map>\n');
		}
		*/
		else
		{
			write ('Misslyckades att spela upp fil. Ladda hem Windows Media Player eller QuickTime');
			/*
			write ('<img src="../err_ljud.gif" width="' + this.width + '" border="0" usemap="#mapErr">\n');
			write ('<map name="mapErr">\n');
			write ('<AREA ALT="" COORDS="0,62,313,73" HREF="http://docs.info.apple.com/article.html?artnum=120133" TARGET="_blank">\n');
			write ('</map>\n');
			*/
		}
	}
}

PlaySound.prototype.CheckSoundType = function (s) {

	var i;
	var enabledPlugin, mimetype;

	if (navigator.plugins && navigator.plugins.length > 0)
	{
		var numPlugins = navigator.plugins.length;
  
  		for (i = 0; i < numPlugins; i++)
		{
			var plugin = navigator.plugins[i];
			var numTypes = plugin.length;

			for (j = 0; j < numTypes; j++)
			{
				mimetype = plugin[j];

				if (mimetype)
				{
					if (mimetype.suffixes.indexOf (s) != -1)
					{
						enabledPlugin = mimetype.enabledPlugin;

						if (enabledPlugin && (enabledPlugin.name == plugin.name))
						{
							return true;
						}
					}
    				}
			}
  		}
	}

	return false;
}

PlaySound.prototype.Check = function () {

	var IE, NS;

	var IE = ((navigator.userAgent.toLowerCase()).indexOf("msie") != -1);

	NS = (document.layers) ? 1 : 0;

	this.plugin_enabled = (navigator.plugins) ? 1 : 0;

	this.sound_enabled  = this.CheckSoundType ('mp3');

	if (IE)
	{
		this.sound_enabled = (IE && this.plugin_enabled);
	}
	else if (!this.sound_enabled)
	{
		this.sound_enabled = this.useQT | this.useWMP;
	}
}