﻿/*
 * Detect whether Macromedia Flash player is installed in the browser, and
 * if it is what version.
 *
 * This script is a mildly modified version of one from QuirksMode 
 * (http://www.quirksmode.org/js/flash.html).
 * 
 * This script sets the following global variables which are available to any subsequent
 * scripts:
 * NAME                 VALUES
 * flashinstalled       0 = Not known; 1 = No flash; 2 = Flash installed
 * flashversion         Major version number of the installed player, if any
 */
 
var flashinstalled = 0;
var flashversion = 0;

if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
{
    // IE flash detection.
	for(var i=15; i>0; i--){ // The start value here will need upping when the Flash versions pass 15
		flashversion = 0;
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
			flashversion = i;
			break;
		}
		catch(e){
		}
	}
	if (flashversion == 0) {
	    flashinstalled = 1;
	} else {
	    flashinstalled = 2;
	}
}
