Flash = Class.create();
Flash.prototype = {
	isIE : Boolean,
	html : String,
	params : Array,
	attributes : Array,
	variables : Array,
	
	initialize : function(movie, id, width, height, initParams){
		this.html 		= "";
		this.params		= new Array();
		this.variables	= new Array();

		this.setBrowser();
		
		this.addAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
		this.addAttribute("codebase", "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,22,0");
		this.addAttribute("type", "application/x-shockwave-flash");
		
		this.addParameter("pluginurl", "http://www.macromedia.com/go/getflashplayer_br");
					
		if(movie) {
			this.addAttribute("data", movie);
			this.addParameter("movie", movie);
		}	
			
		if(initParams != undefined){
			for(var i in initParams){
				this.addParameter(i.toString(), initParams[i]);
			}
		}
		
		if(id && id != null){
			this.addAttribute("id", id);
		}
		if(width){
			this.addAttribute("width", width);
		}
		if(height){
			this.addAttribute("height", height);
		}
	},
	
	setBrowser : function(){
		var	isIE		= (	window.ActiveXObject
							&& document.all
							&& navigator.userAgent.toLowerCase().indexOf("msie") > -1
							&& navigator.userAgent.toLowerCase().indexOf("opera") == -1)
						? true
						: false;
						
		return (this.isIE = isIE);
	},
	
	addAttribute : function(prop, val){
		return (this.attributes[prop] = val);
	},
	
	addParameter : function(prop, val){
		return (this.params[prop] = val);
	},
	
	addVariable : function(prop, val){
		return (this.variables.push([prop, val]));
	},
	
	getFlashVars : function(){
		var tempString = new Array();
		
		for(var i=0; i<this.variables.length; i++){
			tempString.push(this.variables[i].join("="));
		}
		
		return tempString.join("&");
	},
	
	getObjectByExceptions : function(obj, excep){
		var tempObj = {};
		for(var i in obj){
			var inclui = true;
			for(var j=0; j<excep.length; j++)
				if(excep[j] == i.toString()) { inclui = false; break; };
			if(inclui) tempObj[i] = obj[i];
		}
		return tempObj;
	},			
	
	toString : function(){
		this.params.flashVars = this.getFlashVars();
		if(this.isIE){
			this.html = "<ob" + "ject";
			var attr = this.getObjectByExceptions(this.attributes, ["type", "data"]);
			for(var i in attr) if(i.toString() != "extend") this.html += " " + i.toString() + " = \"" + attr[i] + "\"";
			this.html += "> ";
			var params = this.getObjectByExceptions(this.params, ["pluginurl", "extend"]);
			for(var i in params) if(i.toString() != "extend") this.html += "<param name=\"" + i.toString() + "\" value=\"" + params[i] + "\" /> ";
			this.html += " </obj" + "ect>";
		} else {
			this.html = "<!--[if !IE]> <--> <obj" + "ect";
			var attr = this.getObjectByExceptions(this.attributes, ["classid", "codebase"]);
			for(var i in attr) if(i.toString() != "extend") this.html += " " + i.toString() + " = \"" + attr[i] + "\"";
			this.html += "> ";
			var params = this.getObjectByExceptions(this.params, ["extend"]);
			for(var i in params) if(i.toString() != "extend") this.html += "<param name=\"" + i.toString() + "\" value=\"" + params[i] + "\" /> ";
			this.html += " </obj" + "ect> <!--> <![endif]-->";
		}
	
		return this.html;
	},
	
	write : function(w){
		w = $(w);
		if( w != undefined && w ){
			w.innerHTML = this.toString();
		}
		else{
			document.write( this.toString() );
		}
	}
}