/**
 * Flash detection
 */

var flash = {

	/**
	 * Internal function that does all of the heavy-lifting.
	 *
	 * @returns An associative array containing values for the user-facing functions.
	 * @type Array
	 * @private
	 */
	init: function() {
		var v = [];

		if (navigator.plugins && navigator.plugins.length) {
			for (x = 0; x < navigator.plugins.length; x++) {
				if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
					v['version'] = navigator.plugins[x].description.split('Shockwave Flash ')[1].split(' r').join('.');
					v['installed'] = true;
					break;
				}
			}
		}
		else if (window.ActiveXObject) {
			for (x = 1; x <= 20; x++) {
				try {
					fl = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.' + x);
					if (fl) {
						v['version'] = x;
						v['installed'] = true;
					}
				}
				catch(e) {}
			}
		}
		return v;
	},

	installed: function() {
		var v = flash.init();
		return v['installed'];
	},

	version: function() {
		var v = flash.init();
		return v['version'];
	},

	base: function(v) {
		return (flash.installed() && parseInt(flash.version()) >= v) ? true:false;
	}
};
