function FlashObject(swf, id, width, height, color) {
	this.swf = swf;
	this.id = id;
	this.classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
	this.codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0";
	this.width = width;
	this.height = height;
	this.color = color;
	
	this.params = new Array();
	this.variables = new Array();
	this.flashVars = "";
	
	this.type = "application/x-shockwave-flash";
	this.pluginsPage = "http://www.macromedia.com/go/getflashplayer";
	
	this.object_str = "";
	
	this.focus = false;
}

FlashObject.prototype.setClassId = function(value) {
	this.classid = value;
}

FlashObject.prototype.setCodebase = function(value) {
	this.codebase = value;
}

FlashObject.prototype.setType = function(value) {
	this.type = value;
}

FlashObject.prototype.setPluginsPage = function(value) {
	this.pluginsPage = value;
}

FlashObject.prototype.addParam = function(name, value) {
	var tmpArray = new Array(2);
	tmpArray[0] = name;
	tmpArray[1] = value;
	this.params.push(tmpArray);
}

FlashObject.prototype.addVariable = function(name, value) {
	var tmpArray = new Array(2);
	tmpArray[0] = name;
	tmpArray[1] = value;
	this.variables.push(tmpArray);
}

FlashObject.prototype.setFocus = function() {
	this.focus = true;
}

FlashObject.prototype.build = function() {
	// Sammensætter objectet.
	this.object_str += "<object classid=\"" + this.classid + "\" codebase=\"" + this.codebase + "\" width=\"" + this.width + "\" height=\"" + this.height + "\" id=\"" + this.id + "\">\n";
	
	// indsætter standard param-tags
	this.object_str += "\t<param name=\"movie\" value=\"" + this.swf + "\" />\n";
	this.object_str += "\t<param name=\"bgcolor\" value=\"" + this.color + "\" />\n";
	
	// indsætter brugerens param-tags
	for (i=0; i<this.params.length; i++) {
		this.object_str += "\t<param name=\"" + this.params[i][0] + "\" value=\"" + this.params[i][1] + "\" />\n";
	}
		
	// her genereres flashVars strengen
	for (i=0; i<this.variables.length; i++) {
		this.flashVars += this.variables[i][0] + "=" + this.variables[i][1];
		if (i < this.variables.length - 1) {
			this.flashVars += "&";
		}
	}
	if (this.flashVars != "") {
		this.object_str += "\t<param name=\"flashvars\" value=\"pageURL=" + escape(location.href) + "&" + this.flashVars + "\" />\n";
	}
	
	// embed-tag
	this.object_str += "\t<embed src=\"" + this.swf + "\" bgcolor=\"" + this.color + "\" width=\"" + this.width + "\" height=\"" + this.height + "\" name=\"" + this.id + "\" ";
	
	if (this.flashVars != "") {
		this.object_str += "flashvars=\"" + this.flashVars + "\" ";
	}
	
	for (i=0; i<this.params.length; i++) {
		this.object_str += this.params[i][0] + "=\"" + this.params[i][1] + "\" ";
	}
	
	this.object_str += "type=\"" + this.type + "\" pluginspage=\"" + this.pluginsPage + "\" />\n";
	
	
	this.object_str += "</object>";
	document.write(this.object_str);
	
	if (this.focus) {
		document.getElementById(this.id).focus();
	}
}
