
function detect()
{
	var UNDEF = "undefined",
		OBJECT = "object",
		SHOCKWAVE_FLASH = "Shockwave Flash",
		SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
		FLASH_MIME_TYPE = "application/x-shockwave-flash",
		EXPRESS_INSTALL_ID = "SWFObjectExprInst",
		
		win = window,
		doc = document,
		nav = navigator;
		
		var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
			playerVersion = [0,0,0],
			d = null;

		if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) 
		{
			d = nav.plugins[SHOCKWAVE_FLASH].description;
			if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) 
			{ 
				// navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
				d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
				playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
				playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
			}
		}
		else if (typeof win.ActiveXObject != UNDEF) 
		{
			var a = null, fp6Crash = false;
			try 
			{
				a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
			}
			catch(e) {
				try { 
					a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
					playerVersion = [6,0,21];
					a.AllowScriptAccess = "always";	 // Introduced in fp6.0.47
				}
				catch(e) {
					if (playerVersion[0] == 6) 
					{
						fp6Crash = true;
					}
				}
				if (!fp6Crash) 
				{
					try {
						a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
					}
					catch(e) {}
				}
			}
			if (!fp6Crash && a) 
			{ 
				// a will return null when ActiveX is disabled
				try {
					d = a.GetVariable("$version");	// Will crash fp6.0.21/23/29
					if (d) 
					{
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
				catch(e) {}
			}
		}

	flashMajorVersion = playerVersion[0];
	flashInstalled = true;
}

detect();
//alert(flashMajorVersion);


// THIS FUNCTION SHOULD BE CALLED FROM THE HTML/ASP PAGE, AND IS A
// WORK AROUND FOR THE 4/11/2006 SECURITY TO INTERNET EXPLORER.


function embedFlash( swfFile, swfWidth, swfHeight, paramString, requiredVersion, bgColor ) {
	
	if ( requiredVersion == undefined ) { var requiredVersion = 7 }
	
	// THIS WRITES THE CODE TO DISPLAY FLASH FILE OR ALTERNATE
	
	if ( flashInstalled && flashMajorVersion >= requiredVersion ) {
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ');
		document.write(' ID="' + swfFile + '" WIDTH="' + swfWidth + '" HEIGHT="' + swfHeight + '" ALIGN="">');
		document.write(' <PARAM NAME=movie VALUE="' + swfFile + paramString + '"> <PARAM NAME=loop VALUE=false> <PARAM NAME=menu VALUE=false>');
		document.write(' <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=' + bgColor + '> <param name=wmode value=transparent>'); 
		document.write(' <EMBED src="' + swfFile + paramString + '" loop=false menu=false quality=high bgcolor=' + bgColor + ' wmode="transparent"');
		document.write(' swLiveConnect=TRUE WIDTH="' + swfWidth + '" HEIGHT="' + swfHeight + '" NAME="' + swfFile + '" ALIGN=""');
		document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
		document.write(' </EMBED>');
		document.write(' </OBJECT>');
	} else {
		document.write('<TABLE WIDTH=100% HEIGHT=100% BORDER=0><TR><TD ALIGN=CENTER VALIGN="MIDDLE"><FONT COLOR="#999999" SIZE=2 FACE="Arial">');
		document.write('<P><B>Requires the <A HREF="http://www.macromedia.com/go/getflashplayer" TARGET="_BLANK">Macromedia Flash plug-in</A> version ' + requiredVersion + ' or higher.</B><BR>');
		document.write('</FONT></TD></TR></TABLE>');
	}
	
	
}