function FlashObject(name, src, width, height) {

    this.attributes = new Object();
	this.variables = new Object();

	this.setAttribute('id', name);
	this.setAttribute('name', name);
	this.setAttribute('src', src);
	this.setAttribute('width', width);
	this.setAttribute('height', height);
};

// FLASHVARS

FlashObject.prototype = {
	
	setAttribute: function(n, v) {
		this.attributes[n] = v;
	},
	
	getAttribute: function(n) {
		return this.attributes[n];
	},

	addVariable: function(n, v) {

		while ( v.search(' ') != -1 ) {
			v = v.replace(' ', '%20');
		}
		while ( v.search('&') != -1 ) {
			v = v.replace('&', '%26');
		}

		this.variables[n] = v;
	},

	getVariables: function(n, v) {
		return this.variables;
	},

	getVariablePairs: function() {
		var a = new Array();
		var key;
		var v = this.getVariables();

		for ( key in v ) {
			a.push( key + "=" + v[key] );
		}

		return a;
	},

	write: function(n) {
		var c = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" type="application/x-shockwave-flash" id="' + this.getAttribute('name') + '" width="' + this.getAttribute('width') + '" height="' + this.getAttribute('height') + '"';

		if ( this.getAttribute('align') ) { c = c + ' align="' + this.getAttribute('align') + '"'; }
		if ( this.getAttribute('style') ) { c = c + ' style="' + this.getAttribute('style') + '"'; }
		if ( this.getAttribute('class') ) { c = c + ' class="' + this.getAttribute('class') + '"'; }

		c = c + '>';

		c = c + '<!--[if IE]><param name="movie" value="' + this.getAttribute('src') + '"><![endif]-->';

		var vp = this.getVariablePairs().join("&");
		if ( vp.length ) { c = c + '<param name="flashvars" value="' + vp + '">'; }

		if ( this.getAttribute('wmode') ) { c = c + '<param name="wmode" value="' + this.getAttribute('wmode') + '">'; }
		if ( this.getAttribute('bgcolor') ) { c = c + '<param name="bgcolor" value="' + this.getAttribute('bgcolor') + '">'; }

		c = c + '<embed';
		
		if ( this.getAttribute('bgcolor') ) { c = c + ' bgcolor="' + this.getAttribute('bgcolor') + '"'; }
		if ( vp.length ) { c = c + ' flashvars="' + vp + '"'; }

		if ( this.getAttribute('style') ) { c = c + ' style="' + this.getAttribute('style') + '"'; }
		c = c + ' wmode="' + this.getAttribute('wmode') + '"';
		c = c + ' name="' + this.getAttribute('name') + '"';
		c = c + ' src="' + this.getAttribute('src') + '"';
		c = c + ' width="' + this.getAttribute('width') + '"';
		c = c + ' height="' + this.getAttribute('height') + '"';
		c = c + ' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

		c = c + '<\/object>';

		if ( typeof(n) == 'undefined')
		{
			document.write(c);
		}
		else if ( typeof(document.getElementById(n)).innerHTML != 'object' )
		{
			document.getElementById(n).innerHTML = c;
		}
	},

    encodeMyHtml: function(v) {
		v = new String(v);
		v = v.replace(/</g,"&lt;");
		v = v.replace(/>/g,"&gt;");
		return v;
	} 
}
