/*
        Flash Player detection and embedding

        copyright 2006 Artgig Studio - all rights reserved.
        http://www.artgig.com

        v1.0.3: 1-11-2007
*/



var fV = 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' };
	if ( _bg ) this.setParam( 'bgcolor', _bg );
};
FlashEmbed.prototype = {
	create:function( _id ) {
		if ( document.getElementById && fV >= this.v ) {
			var obj = document.getElementById( _id )
			if ( obj ) {
				obj.innerHTML = this.getHtml();
			}
		}
	},
	getHtml:function() {
		var html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
		html += 'codebase="http';
		if ( document.location.protocol == "https:" ) html += 's';
		html += '://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" swLiveConnect="true" 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 + '"';
		for ( var pn in this.p ) html += ' ' + pn + '="' + this.p[pn] + '"';
		html += ' />';
		html += '</object>';
		return html;
	},
	writeHtml:function() {
		document.writeln( this.getHtml() );
	},
	setParam:function( _p, _v ) { this.p[_p] = _v; }
};



getFlashPlayerVersion = function() {
	if ( fV == 0 ) {
		if ( navigator.plugins && navigator.mimeTypes.length ) {
			var x = navigator.plugins["Shockwave Flash"];
			if ( x && x.description ) {
				fV = 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; }
					fV = parseInt( axo.GetVariable("$version").split(" ")[1].split(",")[0] );
				@else @*/
					try {
						fV = parseInt( axo.GetVariable("$version").split(" ")[1].split(",")[0] );
					}
					catch (e) {
						// do nothing, leave as player version 0
					}
			   /*@end
			@*/
		}
	}
	return fV;
}

getFlashPlayerVersion();

