/* -------------------------------------------------------
	Checks is the Flash Player plugin is installed for
	the specified version.
	**
	Inputs:
		- contentVersion:
			Version required to play hosted content.
	Output:
		Returns true if a valid version of the Flash
		Player plugin is installed, false either.
   ------------------------------------------------------- */

function testFlash(contentVersion)
{
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
						? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin )
	{
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
			if (isNaN(parseInt(words[i])))
				continue;
			var pluginVersion = words[i];
	    }
		var flashCanPlay = (pluginVersion >= contentVersion);
	}
	else if (navigator.appName.indexOf("Microsoft") != -1 && navigator.appName.indexOf("Mac") == -1)
	{
		document.write('<script language=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('xFlashObj = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash"))\n');
		document.write('</script\> \n');
		flashCanPlay = xFlashObj;
	}
	
	return flashCanPlay;
}

/* -------------------------------------------------------
	Writes to the document the object embed code or 
	the replace code for the image.
   ------------------------------------------------------- */

function displayFlashContent(contentVersion, width, height, flashURL, altImageURL, altImageLink, title)
{
	if (testFlash(contentVersion))
	{
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + contentVersion + ',0,0,0" ');
		document.write('width="' + width + '" height="' + height + '">');
		document.write('<param name="movie" value="' + flashURL + '" />');
		document.write('<param name="quality" value="high" />');
		document.write('<embed src="' + flashURL + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ');
		document.write('width="' + width + '" height="' + height + '"></embed>');
		document.write('</object>');
	}
	else if (altImageURL != '')
	{
		if (altImageLink != '')
			document.write('<a href="' + altImageLink + '" title="' + title + '">');
		document.write('<img src="' + altImageURL + '" width="' + width + '" height="' + height + '" title="' + title + '" />');
		if (altImageLink != '')
			document.write('</a>');
	}
}