/*********************************************************************
 *
 * Macromedia Flash Dispatcher -- a scriptable detector for Flash Player
 *
 *
 * copyright (c) 2000 Macromedia, Inc.
 *
 *********************************************************************/


/*
 * URL of the Flash self-detecting movie ("sniffer").
 *
 * Reset this if you move the file out of the directory in which the
 * document containing the script that calls MM_FlashDispatch() resides.
 */

var MM_FlashSnifferURL = "detectFlash.swf";


/*
 * Latest available revisions of the Plug-in.
 */

var MM_latestPluginRevision = new Object();MM_latestPluginRevision["7.0"] = new Object();MM_latestPluginRevision["6.0"] = new Object();
MM_latestPluginRevision["5.0"] = new Object();
MM_latestPluginRevision["4.0"] = new Object();
MM_latestPluginRevision["3.0"] = new Object();
MM_latestPluginRevision["2.0"] = new Object();

/*
 * This table must be updated as new versions and revisions of the
 * plug-in are released, in support of the 'requireLatestRevision'
 * option in MM_FlashDispatch().
 */

MM_latestPluginRevision["7.0"]["Windows"] = 14;

MM_latestPluginRevision["6.0"]["Windows"] = 47;
MM_latestPluginRevision["6.0"]["Macintosh"] = 47;

MM_latestPluginRevision["5.0"]["Windows"] = 30;
MM_latestPluginRevision["5.0"]["Macintosh"] = 30;

MM_latestPluginRevision["4.0"]["Windows"] = 28;
MM_latestPluginRevision["4.0"]["Macintosh"] = 27;
MM_latestPluginRevision["4.0"]["Unix"] = 12;

MM_latestPluginRevision["3.0"]["Windows"] = 10;
MM_latestPluginRevision["3.0"]["Macintosh"] = 10;

MM_latestPluginRevision["2.0"]["Windows"] = 11;
MM_latestPluginRevision["2.0"]["Macintosh"] = 11;


/*
 * MM_FlashInfo() -- construct an object representing Flash Player status
 *
 * Constructor:
 *
 *	new MM_FlashInfo()
 *
 * Properties:
 *
 *	installed		true if player is installed
 *				(undefined if undetectable)
 *
 *	implementation		the form the player takes in this
 *				browser: "ActiveX control" or "Plug-in"
 *
 *	autoInstallable		true if the player can be automatically
 *				installed/updated on this browser/platform
 *
 *	version			player version if installed
 *
 *	revision		revision if implementation is "Plug-in"
 *
 * Methods:
 *
 *	canPlay(contentVersion)	true if installed player is capable of
 *				playing content authored with the
 *				specified version of Flash software
 *
 * Description:
 *
 *	MM_FlashInfo() instantiates an object that contains as much
 *	information about Flash Player--whether it is installed, what
 *	version is installed, and so one--as is possible to collect.
 *
 *	Where Flash Player is implemented as a plug-in and the user's
 *	browser supports plug-in detection, all properties are defined;
 *	this includes Netscape on all platforms and Microsoft Internet
 *	Explorer 5 on the Macintosh.  Where Flash Player is implemented
 *	as an ActiveX control (MSIE on Windows), all properties except
 *	'revision' are defined.
 *
 *	Prior to version 5, Microsoft Internet Explorer on the Macintosh
 *	did not support plug-in detection.  In this case, no properties
 *	are defined, unless the cookie 'MM_FlashDetectedSelf' has been
 *	set, in which case all properties except 'version' and 'revision'
 *	are set.
 *
 *	This object is primarily meant for use by MM_FlashDispatch(), but
 *	may be of use in reporting the player version, etc. to the user.
 */

var MM_FlashControlInstalled;	// is the Flash ActiveX control installed?
var MM_FlashControlVersion;	// ActiveX control version if installed

function MM_FlashInfo()
{
    if (navigator.plugins && navigator.plugins.length > 0)
    {
	this.implementation = "Plug-in";
	this.autoInstallable = false;	// until Netscape SmartUpdate supported

	// Check whether the plug-in is installed:

		if (navigator.plugins["Shockwave Flash"]){
			this.installed = true;

			// Get the plug-in version and revision:

			var words =
			navigator.plugins["Shockwave Flash"].description.split(" ");

			for (var i = 0; i < words.length; ++i){
				if (isNaN(parseInt(words[i])))
				continue;

			this.version = words[i];

			this.revision = parseInt(words[i + 1].substring(1));
			}
		}else{
			this.installed = false;
		}
    }else if (MM_FlashControlInstalled != null){
		this.implementation = "ActiveX control";
		this.installed = MM_FlashControlInstalled;
		this.version = MM_FlashControlVersion;
		this.autoInstallable = true;
		
    }else if (MM_FlashDetectedSelf()){
	this.installed = true;
	this.implementation = "Plug-in";
	this.autoInstallable = false;
    }

    this.canPlay = MM_FlashCanPlay;	flashInfo = new Array();	flashInfo[0] = this.installed;	flashInfo[1] = this.implementation;	flashInfo[2] = this.autoInstallable;	flashInfo[3] = this.version;	flashInfo[4] = this.revision;		return flashInfo;
}


/*********************************************************************
 * THE FOLLOWING FUNCTIONS ARE NOT PUBLIC.  DO NOT CALL THEM DIRECTLY.
 *********************************************************************/

/*
 * MM_FlashLatestPluginRevision() -- look up latest Flash Player plug-in
 *				     revision for this platform
 *
 * Synopsis:
 *
 *	MM_FlashLatestPluginRevision(playerVersion)
 *
 *	Arguments:
 *
 *	    playerVersion	plug-in version to look up revision of
 *
 *	Returns:
 *
 *	    The latest available revision of the specified version of
 *	    the Flash Player plug-in on this platform, as an integer;
 *	    undefined for versions before 2.0.
 *
 * Description:
 *
 *	This look-up function is only intended to be called internally.
 */

function MM_FlashLatestPluginRevision(playerVersion)
{
    var latestRevision;
    var platform;

    if (navigator.appVersion.indexOf("Win") != -1)
	platform = "Windows";
    else if (navigator.appVersion.indexOf("Macintosh") != -1)
	platform = "Macintosh";
    else if (navigator.appVersion.indexOf("X11") != -1)
	platform = "Unix";

    latestRevision = MM_latestPluginRevision[playerVersion][platform];

    return latestRevision;
}


/*
 * MM_FlashCanPlay() -- check whether installed Flash Player can play content
 *
 * Synopsis:
 *
 *	MM_FlashCanPlay(contentVersion, requireLatestRevision)
 *
 *	Arguments:
 *
 *	    contentVersion		version of Flash software used to
 *					author content
 *
 *	    requireLatestRevision	Boolean indicating whether latest
 *					revision of plug-in should be required
 *
 *	Returns:
 *
 *	    true if the installed player can play the indicated content;
 *	    false otherwise.
 *
 * Description:
 *
 *	This function is not intended to be called directly, only
 *	as an instance method of MM_FlashInfo.
 */

function MM_FlashCanPlay(contentVersion, requireLatestRevision)
{
    var canPlay;

    if (this.version)
    {
	canPlay = (parseInt(contentVersion) <= this.version);

	if (requireLatestRevision)
	{
	    if (this.revision &&
		this.revision < MM_FlashLatestPluginRevision(this.version))
	    {
		canPlay = false;
	    }
	}
    }
    else
    {
	canPlay = MM_FlashDetectedSelf();
    }

    return canPlay;
}


/*
 * MM_FlashDetectedSelf() -- recall whether Flash Player has detected itself
 *
 * Synopsis:
 *
 *	MM_FlashDetectedSelf()
 *
 *	Returns:
 *
 *	    true if a cookie signifying that Flash Player has detected itself
 *	    is set; false otherwise.
 *
 * Description:
 *
 *	This function is only meant to be called internally.
 */

function MM_FlashDetectedSelf()
{
    return (document.cookie.indexOf("MM_FlashDetectedSelf") != -1);
}
