﻿function ShowFlash(flashUrl, imageUrl, height, width)
{
    var flashVersion = GetFlashVersion();

    if ( flashVersion >= 8 )
    {
        document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + width + '" height="' + height + '" ');
        document.write('   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0">');
        document.write('   <PARAM NAME="movie" VALUE="' + flashUrl + '">');
        document.write('   <PARAM NAME="quality" VALUE="high">');
        document.write('   <PARAM NAME="bgcolor" VALUE="#FFFFFF">');
        document.write('<EMBED src="' + flashUrl + '" quality="high" bgcolor="#000000" width="' + width + '" height="' + height + '" type="application/x-shockwave-flash"  ');
        document.write('     pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
        document.write('   </EMBED>');
        document.write('</OBJECT>');
    }
    else if(imageUrl != '')
    {
        document.write('<IMG SRC="' + imageUrl + '" WIDTH="' + width + '" HEIGHT="' + height + '" usemap="#script" BORDER=0>');
    }
}

// Will return 0 if flash is not installed. -1 if flash is installed 
// but the version number is not known, or a # greater than 0 
// representing the version of flash that the client hinstalled
function GetFlashVersion()
{
	// Flash detection script original copied from: http://www.quirksmode.org/js/flash.html
	var version = 0;

	try
	{
		if (navigator.plugins && navigator.plugins.length)
		{
			x = navigator.plugins["Shockwave Flash"];
			if (x)
			{
				if (x.description)
				{
					y = x.description;
					version = y.charAt(y.indexOf('.')-1);
				}
			}

			if (navigator.plugins["Shockwave Flash 2.0"])
			{
				version = 2;
			}
		}
		else if (navigator.mimeTypes && navigator.mimeTypes.length)
		{
			x = navigator.mimeTypes['application/x-shockwave-flash'];
			if (x && x.enabledPlugin)
			{
				version = -1;
			}
		}
		else
		{
			for(var i=10; i>0; i--)
			{
				version = 0;
				try
				{
					var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
					version = i;
					break;
				}
				catch(e)
				{
				}
			}
		}
	}
	catch(e)
	{
	}

	return version;
}
