// set this to the max version of flash that you'll ever deal with.
var MAX_FLASH_VERSION = 9;

// this needs to be global to use in VBScript with IE/Win
var FlashVersionInstalled = 0;

function flashDetect (passVersion) {
	var checkVersion = passVersion.toString();
	var detectVersion = "";
	
	var flashDescription = '';
		if(!navigator)return false; //??

		if(navigator.appVersion) {
			if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.toLowerCase().indexOf("win") != -1) detectVersion = FlashVersionInstalled;
		}

		if(navigator.mimeTypes||navigator.plugins){
			if(navigator.mimeTypes) {
				if(navigator.mimeTypes['application/x-shockwave-flash']){
					this.HasFlash=true;
					if(navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin){
						if(navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description){
							// A flash plugin-description (usually) looks like this: Shockwave Flash 7.0 r19
							// pull the first number out of it, and hope for the best!
							flashDescription=navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description;
						}else this.errors+='no description on the flash plugin.\n'; //can't know version without description.
					}else this.errors+='the mimeType is defined, but no plugin is enabled.\n'; //? this is weird.  
				}
			}else{
				//no mimeTypes.  Try the plugins array
				if(navigator.plugins['Shockwave Flash']||navigator.plugins['Shockwave Flash 2.0']){
					var isVersion2 = navigator.plugins['Shockwave Flash 2.0'] ? ' 2.0' : '';
					flashDescription = navigator.plugins['Shockwave Flash' + isVersion2].description;
				}
			}
		}
		if(flashDescription != '') {
			//found something somewhere...
			var v=parseInt(flashDescription.replace(/^[^0-9]*/,''));
			if(!isNaN(v)) detectVersion=v;
		}
		//doing this in a weird way because we might have flash, and yet not know the version.
		if(detectVersion){
			this.HasFlash=true;
			//whatever the error was, we worked past it!
			this.errors='';
		}
		this.Detected = true;
		return eval(detectVersion >= checkVersion);
}

// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
// I changed the VBScript from the original MoockFPI in order to reduce the
// number of steps that the browser must go through. --IZS
if(navigator){
	if(navigator.appVersion) {
		if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.toLowerCase().indexOf("win") != -1) {
			document.write('<scr' + 'ipt language="VBScript" type="text/VBScript"> \n');
			document.write('on error resume next\n');
			document.write('dim i,f\n');
			document.write('i = MAX_FLASH_VERSION\n');
			document.write('Do While i >= 2 \n');
			document.write('	Set f = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)\n');
			document.write('	If Err.Number = 0 Then\n');
			document.write('		FlashVersionInstalled = i\n');
			document.write('		Set f = Nothing\n');
			document.write('		Exit Do\n');
			document.write('  Else\n');
			document.write('    Err.Clear\n');
			document.write('	End If\n');
			document.write('	Set f = Nothing\n');
			document.write('	i = i - 1\n');
			document.write('Loop\n');
			document.write('<\/scr' + 'ipt> \n'); // break up end tag so it doesn't end our script
		}
	}
}