var FlashSnifferURL = "swf/detectFlash.swf";

var latestPluginRevision = new Object();

latestPluginRevision["6.0"] = new Object();
latestPluginRevision["5.0"] = new Object();
latestPluginRevision["4.0"] = new Object();
latestPluginRevision["3.0"] = new Object();
latestPluginRevision["2.0"] = new Object();

latestPluginRevision["6.0"]["Windows"] = 00;
latestPluginRevision["6.0"]["Macintosh"] = 00;

latestPluginRevision["5.0"]["Windows"] = 30;
latestPluginRevision["5.0"]["Macintosh"] = 30;

latestPluginRevision["4.0"]["Windows"] = 28;
latestPluginRevision["4.0"]["Macintosh"] = 27;
latestPluginRevision["4.0"]["Unix"] = 12;

latestPluginRevision["3.0"]["Windows"] = 10;
latestPluginRevision["3.0"]["Macintosh"] = 10;

latestPluginRevision["2.0"]["Windows"] = 11;
latestPluginRevision["2.0"]["Macintosh"] = 11;

var MM_FlashControlInstalled;
var MM_FlashControlVersion;

function FlashInfo() {
	if (navigator.plugins && navigator.plugins.length>0) {
		this.implementation = "Plug-in";
		this.autoInstallable = false;
		if (navigator.plugins["Shockwave Flash"]) {
	    		this.installed = true;
			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;
	}
	this.canPlay = FlashCanPlay;
}

var FlashPluginsPage = "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";

function FlashDispatch(contentVersion,upgradeURL) {
	var player = new FlashInfo();
	if (player.installed==null) {
		var sniffer =
			"<EMBED HIDDEN=\"true\" TYPE=\"application/x-shockwave-flash\""+
			" WIDTH=\"18\" HEIGHT=\"18\" BGCOLOR=\""+document.bgcolor+"\""+
			" SRC=\""+FlashSnifferURL+"?contentVersion="+contentVersion+
			"&requireLatestRevision=true&latestRevision="+
			FlashLatestPluginRevision(contentVersion)+
			"&upgradeURL="+upgradeURL+"\""+
			" LOOP=\"false\" MENU=\"false\""+
			" PLUGINSPAGE=\""+FlashPluginsPage+"\">"+
			"</EMBED>";
		document.open();
		document.write("<HTML><HEAD><TITLE>");
		document.write("Checking for the Flash Player");
		document.write("</TITLE></HEAD>");
		document.write("<BODY BGCOLOR=\""+document.bgcolor+"\">");
		document.write(sniffer);
		document.write("</BODY>");
		document.write("</HTML>");
		document.close();
    	} else if (player.installed) {
		if (!player.canPlay(contentVersion)) {
			if (disableAutoInstall) {
				location = upgradeURL;
			} else if (player.autoInstallable==false) {
				location =  upgradeURL;
			}
		}
    	} else {
		location = upgradeURL;
	}
}

/*********************************************************************
 * THE FOLLOWING FUNCTIONS ARE NOT PUBLIC.  DO NOT CALL THEM DIRECTLY.
 *********************************************************************/

function 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 = latestPluginRevision[playerVersion][platform];
	return latestRevision;
}


function FlashCanPlay(contentVersion) {
	var canPlay;
	if (this.version) {
		canPlay = (parseInt(contentVersion)<=this.version);
		if (this.revision && this.revision<FlashLatestPluginRevision(this.version)) {
			canPlay = false;
		}
	} else canPlay = false;
	return canPlay;
}