	function FlashPlayerVersion(arrVersion)
	{
		this.major = parseInt(arrVersion[0]) || 0;
		this.minor = parseInt(arrVersion[1]) || 0;
		this.rev = parseInt(arrVersion[2]) || 0;
	}

	FlashPlayerVersion.prototype.versionIsValid = function(fv)
	{
		if(this.major < fv.major) return false;
		if(this.major > fv.major) return true;
		if(this.minor < fv.minor) return false;
		if(this.minor > fv.minor) return true;
		if(this.rev < fv.rev) return false;
		return true;
	}

	function Flash(movie, id, width, height, ver, bg, fv, substImg)
	{
		this.movie = movie;
		this.id = id;
		this.width = width;
		this.height = height;
		this.ver = ver ? ver : "8,0,0,24";
		this.substImg = substImg;

		this.align ="middle";

		this.attributes = new Array();
		this.params = new Object();

		if(bg)
			this.setParam("bgcolor", bg);
		if(fv)
			this.setParam("FlashVars", fv);

		this.setParam("allowScriptAccess", "sameDomain");
		this.setParam("quality", "high");
		this.setParam("menu", "false");
	}

	Flash.prototype.addAttribute = function(n, v)
	{
		if(v)
			this.attributes[this.attributes.length] = n + '="' + v + '"';
		else
			this.attributes[this.attributes.length] = n;
	}

	Flash.prototype.setParam = function(n, v)
	{
		this.params[n] = v;
	}

	Flash.prototype.render = function()
	{
		if(this.ver.length < 2)
			this.ver += ",0,0,0";

   		var installedVer = getFlashPlayerPlayerVersion();
		var expressInstallReqVer = new FlashPlayerVersion([7,0,0]);

		if( !installedVer.versionIsValid(expressInstallReqVer) && this.substImg )
		{
			s = '<img src="' + this.substImg + '" ' + 
				(this.width ? 'width="' + this.width + '" ' : '') + 
				(this.height? 'height="' + this.height + '" ' : '') + 
				'align="' + this.align + '" ' + '/>';
		}
		else
		{
			var s = '<object id="' + this.id + '" ' +
				(this.width ? 'width="' + this.width + '" ' : '') + 
				(this.height? 'height="' + this.height + '" ' : '') + 
				'align="' + this.align + '" ';
			s += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.ver + '" ';
			for(var i=0; i<this.attributes.length; i++)
				s += this.attributes[i] + " ";
			s += '>';
	
			s += '<param name="movie" value="' + this.movie + '" />';
			for(var k in this.params)
				s += '<param name="' + k + '" value="' + this.params[k] + '" />';

			s += '<embed src="' + this.movie + '" ';
			s += (this.width ? 'width="' + this.width + '" ' : '') + 
				(this.height? 'height="' + this.height + '" ' : '') + 
				'name="' + this.id + '" align="' + this.align + '" ';
			for(var k in this.params)
				s += k + '="' + this.params[k] + '" ';

			s += 'swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" />';

			s += '</object>';
		}

		document.write(s);
	}

	function getFlashPlayerPlayerVersion()
	{
		var PlayerVersion = new FlashPlayerVersion(0,0,0);
		if(navigator.plugins && navigator.mimeTypes.length){
			var x = navigator.plugins["Shockwave Flash"];
			if(x && x.description) {
				PlayerVersion = new FlashPlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
		}
		else if (window.ActiveXObject)
		{
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				PlayerVersion = new FlashPlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
	   		} 
			catch (e) {}
		}
		return PlayerVersion;
	}
