

var flashPlayerVersion = 0;

FlashEmbed = function( _f, _v, _w, _h, _bg, _id, _c ) {
	this.f = _f;
	this.v = _v;
	this.id = _id;
	this.c = _c;
	this.w = _w;
	this.h = _h;
	this.p = { quality:'high', scale:'noscale' };
	if ( _bg ) this.setParam( 'bgcolor', _bg );
};
FlashEmbed.prototype = {
	create:function( _id ) {
		if ( document.getElementById && flashPlayerVersion >= this.v ) {
			var obj = document.getElementById( _id )
			if ( obj ) {
				var html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
				html += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.v + ',0,0,0"';
				if ( this.w ) html += ' width="' + this.w + '"';
				if ( this.h ) html += ' height="' + this.h + '"';
				if ( this.id ) html += ' id="' + this.id + '"';
				if ( this.c ) html += ' class="' + this.c + '"';
				html += '>';
				html += '<param name="allowScriptAccess" value="sameDomain" />';
				html += '<param name="movie" value="' + this.f + '" />';
				for ( var pn in this.p ) html += '<param name="' + pn + '" value="' + this.p[pn] + '" />';
				html += '<embed src="' + this.f + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"';
				if ( this.w ) html += ' width="' + this.w + '"';
				if ( this.h ) html += ' height="' + this.h + '"';
				if ( this.id ) html += ' name="' + this.id + '"';
				if ( this.c ) html += ' class="' + this.c + '"';
				html += ' />';
				html += '</object>';
				obj.innerHTML = html;
			}
		}
	},
	setParam:function( _p, _v ) { this.p[_p] = _v; }
};



getFlashPlayerVersion = function() {
	if ( flashPlayerVersion == 0 ) {
		if ( navigator.plugins && navigator.mimeTypes.length ) {
			var x = navigator.plugins["Shockwave Flash"];
			if ( x && x.description ) {
				flashPlayerVersion = parseInt( x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")[0] );
			}
		}
		else if ( window.ActiveXObject ) {
			var axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" );
			// this will throw an error for controls prior to Flash 4...
			/*@cc_on
   				/*@if (@_jscript_version < 5)
					// Older version of Windows IE do not support try/catch, so here's a poor-man's version:
					window.onerror = function () { return true; }
					flashPlayerVersion = parseInt( axo.GetVariable("$version").split(" ")[1].split(",")[0] );
				@else @*/
					try {
						flashPlayerVersion = parseInt( axo.GetVariable("$version").split(" ")[1].split(",")[0] );
					}
					catch (e) {
						// do nothing, leave as player version 0
					}
			   /*@end
			@*/
		}
	}
	return flashPlayerVersion;
}

getFlashPlayerVersion();

