
var swfVersion = function(){
	
	var UNDEF = "undefined",
		OBJECT = "object",
		SHOCKWAVE_FLASH = "Shockwave Flash",
		SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
		FLASH_MIME_TYPE = "application/x-shockwave-flash",
		EXPRESS_INSTALL_ID = "SWFObjectExprInst",
		ON_READY_STATE_CHANGE = "onreadystatechange",
		
		win = window,
		doc = document,
		nav = navigator,
		
		plugin = false,
		storedAltContent,
		storedAltContentId,
		storedCallbackFn,
		storedCallbackObj,
		isDomLoaded = false,
		isExpressInstallActive = false,
		dynamicStylesheet,
		dynamicStylesheetMedia,
		autoHideShow = true,
	
	ua2 = function() 
	{
		try
		{
			var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
				u = nav.userAgent.toLowerCase(),
				p = nav.platform.toLowerCase(),
			windows = p ? (/win/.test(p)) : (/win/.test(u)),
			mac = p ? (/mac/.test(p)) : (/mac/.test(u)),
				webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
				ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
				playerVersion = [0,0,0],
				d = null;
		}
		catch(e)
		{
			playerVersion = [-1,-1,-1];
		}
		if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) 
		{
			try
			{
				d = nav.plugins[SHOCKWAVE_FLASH].description;
				if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
					plugin = true;
					ie = false; // cascaded feature detection for Internet Explorer
					d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
					playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
					playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
					playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
				}
			}
			catch(e)
			{
				playerVersion = [-2,-2,-2];
			}
		}
		else if (typeof win.ActiveXObject != UNDEF) 
		{
		    //var failed = false;
		    var a = null;
			try 
			{
				a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
				if (a) 
				{ // a will return null when ActiveX is disabled
					d = a.GetVariable("$version");
					if (d) 
					{
						ie = true; // cascaded feature detection for Internet Explorer
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
			}
			catch (e) 
			{
			}
			
			if (!d)
	        {
	            //failed = false;
	            try 
	            {
		            a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		            d = a.GetVariable("$version");
		            if (d) 
					{
						ie = true; // cascaded feature detection for Internet Explorer
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
	            } 
	            catch (e) 
				{
				}
            }
            
            if (!d)
	        {
	            //failed = false;
		        try 
		        {
			        // version will be set for 6.X players only
			        a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
        			
			        // installed player is some revision of 6.0
			        // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			        // so we have to be careful. 
        			
			        // default to the first public version
			        d = "WIN 6,0,21,0";

			        // throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			        a.AllowScriptAccess = "always";

			        // safe to call for 6.0r47 or greater
			        d = a.GetVariable("$version");
			        
			        if (d) 
					{
						ie = true; // cascaded feature detection for Internet Explorer
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
		        } 
		        catch (e) 
				{
				}
	        }
	        
	        if (!d)
	        {
	            //failed = false;
		        try 
		        {
			        // version will be set for 4.X or 5.X player
			        a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			        d = a.GetVariable("$version");
			        
			        if (d) 
					{
						ie = true; // cascaded feature detection for Internet Explorer
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
		        } 
		        catch (e) 
				{
				}
	        }
	        
	        if (!d)
	        {
	            //failed = false;
		        try 
		        {
			        // version will be set for 3.X player
			        a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			        d = "WIN 3,0,18,0";
			        if (d) 
					{
						ie = true; // cascaded feature detection for Internet Explorer
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
		        } 
		        catch (e) 
				{
				}
	        }
		}
		return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
	}();
	

	return {
		ua2: ua2,		
		getFlashPlayerVersion2: 
		function() {
			return { major:ua2.pv[0], minor:ua2.pv[1], release:ua2.pv[2] };			
		}
	};
}();

