/*
	unFocusFlashPlayerInfo, version 1.0b1 (beta) (2005/07/28)
	Copyright: 2005, Kevin Newman (http://www.unfocus.com/)
	License: http://creativecommons.org/licenses/LGPL/2.1/
*/
if (typeof com == 'undefined') var com = {};
if (!com.unFocus) com.unFocus = {};
if (!com.unFocus.Flash) com.unFocus.Flash = {};
if (!com.unFocus.Flash.Player) new function() {
	com.unFocus.Flash.Player = this;
	
	// private vars
	var _installed = false;
	var _beta = false;
	var _majorVersion = 0;
	var _minorVersion = 0;
	var _betaVersion = 0;
	
	var _version;
	
	// detection work
	if (navigator.plugins && navigator.plugins.length > 0) {
		_version = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description;
		if (_version) {
			_installed = true;
			if (/Shockwave Flash/.test(_version)) {
				_majorVersion = _version.match(/Shockwave Flash (\d\.\d)/)[1];
				if (/r\d+/.test(_version))
					_minorVersion = _version.match(/r(\d+)/)[1];
				else if (/[bd]\d+/.test(_version)) { // I'm not sure what other letters would be here, but I've encountered b and d so far
					_beta = true;
					_betaVersion = _version.match(/d(\d+)/)[1];
				}
			} else _majorVersion = 1;
		}
	} else if (typeof ActiveXObject != 'undefined') {
		// unFocusDetectActiveX.vbs
		document.write('<scr'+'ipt type="text/vbscript"\>\nFunction unFocusDetectActiveX(C)\n',
			'On Error Resume Next\nunFocusDetectActiveX=IsObject(CreateObject(C))\n',
			'End Function\nFunction unFocusDetectFlashVersion()\nOn Error Resume Next\n',
			'Set C=CreateObject("ShockwaveFlash.ShockwaveFlash.4")\n',
			'unFocusDetectFlashVersion=C.GetVariable("$',
			'version")\nEnd Function\n</scr'+'ipt\>');
		_version = unFocusDetectFlashVersion();
		if (_version) {
			_version = _version.split(',');
			_majorVersion = _version[0].match(/\d+/)+'.'+_version[1];
			_minorVersion = _version[2];
			_betaVersion = _version[3];
			if (_version[3]) _beta = true;
		} else if (unFocusDetectActiveX('ShockwaveFlash.ShockwaveFlash.4'))
			_majorVersion = 4;
		else if (unFocusDetectActiveX('ShockwaveFlash.ShockwaveFlash.3'))
			_majorVersion = 3;
		else if (unFocusDetectActiveX('ShockwaveFlash.ShockwaveFlash')) 
			// Tested on Windows 95 with flash player 2 - using the ".2" at the end doesn't work, but this does ;-)
			_majorVersion = 2;
		if (_majorVersion) _installed = true;
	} else if (/WebTV/.test(navigator.userAgent)) { // WebTV
		_version = navigator.userAgent.match(/WebTV\/(\d\.\d)/)[1];
		if (_version > 2.5) _majorVersion = 4;
		else if (_version == 2.5) _majorVersion = 3;
		else _majorVersion = 2;
	}
	
	// public/priveleged Getters
	this.isInstalled = function() {
		return _installed;
	};
	this.isBeta = function() {
		return _beta;
	};
	this.getMajorVersion = function() {
		return _majorVersion;
	};
	this.getMinorVersion = function() {
		return _minorVersion;
	};
	this.getBetaVersion = function() {
		return _betaVersion;
	};
};
// flash player 8 r22 is the first release of flash player 8