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);
	this.setAttribute('wmode', 'opaque');
	this.setAttribute('allowFullScreen', 'true');
};

// FLASHVARS

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

	addVariable: function(n, v) {
		v = new String(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 type="application/x-shockwave-flash" data="' + this.getAttribute('src') + '"  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') + '">'; }
		if ( this.getAttribute('allowFullScreen') ) { c = c + '<param name="allowFullScreen" value="' + this.getAttribute('allowFullScreen') + '">'; }
		c = c + '<!--[if IE]><param name="movie" value="' + this.getAttribute('src') + '"><![endif]-->';

		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') + '"'; }
		if ( this.getAttribute('wmode') ) { c = c + ' wmode="' + this.getAttribute('wmode') + '"'; }
		if ( this.getAttribute('allowFullScreen') ) { c = c + ' allowFullScreen="' + this.getAttribute('allowFullScreen') + '"'; }
		c = c + ' name="e_' + 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' || n == '')
		{
			document.write(c);
		} else {
			document.getElementById(n).innerHTML = c;
		}
		return c;
	},

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