// versionMajor, versionMinor, versionRevision are only needed for Flash pieces that require
// a different version from the default set in expressScriptCheck()
function replaceFlash(targets, swfLocation, versionMajor, versionMinor, versionRevision)
{
	if (!targets.length)
	{
		targets = [targets];
	}
	
	if (targets)
	{
		for (var i = 0; i < targets.length; i++)
		{
			var e = targets[i];
			
			// 1. make sure <object> exists
			// 2. if swfLocation was passed in, run through Express Install option
			// 3. if IE, suck in <object> and spit it back out to get around the activation bug
			if (e && e.getElementsByTagName("object")[0] && (!swfLocation || (swfLocation && !expressScriptCheck(e, swfLocation, versionMajor, versionMinor, versionRevision))) && window.ActiveXObject)
			{
				e.innerHTML = recreateObjectTag(e);
			}
		}
	}
}

// versionMajor, versionMinor, versionRevision override the defaults in this function

function expressScriptCheck(e, swfLocation, versionMajor, versionMinor, versionRevision)
{
	// Globals
	// Major version of Flash required
	var requiredMajorVersion = versionMajor || 9;
	// Minor version of Flash required
	var requiredMinorVersion = versionMinor || 0;
	// Minor version of Flash required
	var requiredRevision = versionRevision || 0;
	// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
	var hasProductInstall = DetectFlashVer(6, 0, 65);
	// Version check based upon the values defined in globals
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	// Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
	if ( hasProductInstall && !hasReqestedVersion ) {
		// MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
		// This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
		// DO NOT MODIFY THE FOLLOWING FOUR LINES
		// Location visited after installation is complete if installation is required
		var MMPlayerType = (window.ActiveXObject ? "ActiveX" : "PlugIn");
		var MMredirectURL = window.parent ? window.parent.location : window.location;
		var MMdoctitle = document.title;
		var obj = e.getElementsByTagName("object")[0];
		
		e.innerHTML = '<object type="application/x-shockwave-flash" width="' + obj.getAttribute("width") + '" height="' + obj.getAttribute("height") + '" data="' + swfLocation + '?MMredirectURL=' + MMredirectURL + '&MMplayerType=' + MMPlayerType + '&MMdoctitle=' + MMdoctitle + '" wmode="transparent">' +
		'<param name="movie" value="' + swfLocation + '?MMredirectURL=' + MMredirectURL + '&MMplayerType=' + MMPlayerType + '&MMdoctitle=' + MMdoctitle+'" />' +
		'<param name="wmode" value="transparent" />' +
		'</object>';
		
		return true;
	}
	
	return false;
}

function recreateObjectTag(e)
{
	var id = e.getElementsByTagName("object")[0].id;
	var ret = "<object" + (id ? " id='" + id + "'" : '') + " type='application/x-shockwave-flash'>\n";
	var param;
	
	for (var j = 0; j < e.getElementsByTagName("param").length; j++)
	{
		param = e.getElementsByTagName("param")[j];
		
		ret += "<param name='" + param.name + "' value='" + param.value + "'>\n";
	}
	
	ret += e.getElementsByTagName("object")[0].innerHTML + "\n";
	ret += "</object>";
	
	return ret;
}