function EmbedObjectTag() {
	this.attrs = {}; // attributes go in the object tag itself
	this.params = {}; // params go in <param> tags
	this.UseEmbed = true;
	this.UseObject = true;
	this.innerHTML = "";
	this.objParams = {}; // objecttag only params
	this.embParams = {};
	this.objAttrs = {};
	this.embAttrs = {};
	/* convenience attributes & params */
	this.classid; // used for object (optional)
	this.id;
	this.type; // used for embed (optional)
	this.codebase;
	this.width;
	this.height;
	this.src;

	this.WriteIntoId = function(elId) {
		var el = document.getElementById(elId);
		this.WriteInto(el);
	}
	this.WriteInto = function(el) {
		el.innerHTML = this.Html();
	}
	this.WriteHere = function() {
		document.writeln(this.Html());
	}
	this.Html = function() {
		if (typeof(this.PreRender) == "function")
			this.PreRender();
		this.SetupVars();
		var objCode, embCode;
		objCode = '<object';
		embCode = '<embed';
		for (key in this.attrs) {
			var value = this.attrs[key];
			var str = keyValStr(key, value);
			objCode += str;
			embCode += str;
		}
		for (key in this.embAttrs) {
			var value = this.embAttrs[key];
			embCode += keyValStr(key, value);
		}
		for (key in this.objAttrs) {
			var value = this.objAttrs[key];
			objCode += keyValStr(key, value);
		}
		objCode += '>';
		for (key in this.params) {
			var value = this.params[key];
			objCode += paramStr(key, value);
			embCode += keyValStr(key, value);
		}
		for (key in this.embParams) {
			var value = this.embParams[key];
			embCode += keyValStr(key, value);
		}
		for (key in this.objParams) {
			var value = this.objParams[key];
			objCode += paramStr(key, value);
		}
		var html = this.innerHTML;
		if (this.UseEmbed)
			html = embCode+"></embed>";
		if (this.UseObject)
			html = objCode + html + "</object>";
		return html;
	}
	this.SetupVars = function() {
		if (this.src) {
			this.params.src = this.src;
		}
		if (this.type)
			this.embAttrs.type = this.type;
		if (this.classid)
			this.objAttrs.classid = this.classid;
		if (this.codebase) {
			this.objAttrs.codebase = this.codebase;
			this.embAttrs.pluginspage = this.codebase;
		}
		if (this.width)
			this.attrs.width = this.width;
		if (this.height)
			this.attrs.height = this.height;
		if (this.id)
			this.attrs.id = this.id;
	}
	var isValue = function(value) {
		// sometimes functions, undefineds or objects will appear
		if (typeof(value) == 'string' || typeof(value) == 'number')
			return true;
		return false;
	}
	var keyValStr = function(key, value) {
		if (!isValue(value))
			return "";
		return ' '+key+'="'+value+'"';
	}
	var paramStr = function(key, value) {
		if (!isValue(value))
			return "";
		return '<param name="'+key+'" value="'+value+'"/>';
	}
}

EmbedFlashTag.prototype = new EmbedObjectTag;
function EmbedFlashTag() {
	this.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
	this.codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0";
	this.movie;
	this.bgcolor;
	this.quality;
	this.align;
	this.wmode;
	this.vars;
	this.PreRender = function() {
		this.embParams.src = this.movie;
		this.objParams.movie = this.movie;
		if (!this.quality)
			this.quality = 'autohigh';
		if (this.align)
			this.attrs.align = this.align;
		if (this.wmode)
			this.params.wmode = this.wmode;
		if (this.vars)
			this.params.FlashVars = this.vars;
		this.params.quality = this.quality;
		this.params.bgcolor = this.bgcolor;
	}
}

EmbedPUFTag.prototype = new EmbedObjectTag;
function EmbedPUFTag() {
	this.classid = "CLSID:C873F389-FE2A-41B4-A843-F3BB84774C73";
	this.UseEmbed = false;
}

/* 
 * Convenience Instances
 */
ObjectTag = new EmbedObjectTag();
FlashTag = new EmbedFlashTag();