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) {
		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') + '">'; }

		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') + '"'; }
		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')
		{
			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;
	} 
}

function flashControl(SRC,WIDTH,HEIGHT,FLASHVARS,WMODE,BGCOLOR,ALIGN,STYLE) {

	if ( FLASHVARS ) {
		while ( FLASHVARS.search(' ') != -1 ) {
			FLASHVARS = FLASHVARS.replace(' ', '%20');
		}
	}

	if ( ALIGN ) {
	    var algn = 'align="' + ALIGN + '"';
	}
	if ( STYLE ) {
	    var styl = 'style="' + STYLE + '"';
	}

	document.write('<object type="application/x-shockwave-flash" data=' + SRC+ ' width=' + WIDTH + ' height=' + HEIGHT + ' ' + algn + ' ' + styl + '>');
	document.write('<!--[if IE]><param name="movie" value=' + SRC+ '>< ![endif]-->');

	if ( FLASHVARS ) { document.write('<param name="flashvars" value=' + FLASHVARS + '>'); }
	if ( WMODE ) { document.write('<param name="wmode" value=' + WMODE + '>'); }
	if ( BGCOLOR ) { document.write('<param name="bgcolor" value=' + BGCOLOR + '>'); }

  document.write('<param name="quality" value="high">');
	document.write('<\/object>');
}