var Flash = (function(){
	function constructor(parent, src, w, h, version, clearParent){
		this.parent = parent;
		this.src = src;
		this.width = w;
		this.height = h;
		this.flashVersion = version;
		this.clearParent = clearParent;
		return this;
	}
	
	constructor.prototype.detect = function(ver){
		var fv = 0;
		var a = navigator.plugins["Shockwave Flash"];
		if(navigator.plugins && navigator.plugins.length){
			var a = navigator.plugins["Shockwave Flash"];
			if (a && a.description){
				fv = a.description.replace(/^[^\d]*(\d*)\..*$/,"$1");
			}
		} else {
			try{
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
				fv = axo.GetVariable("$version").replace(/^[^\d]*(\d*),.*$/,"$1");
			} catch(e){}
		}
		return fv>=ver?true:false;
	};
	
	constructor.prototype.create = function(movie,content){
		var f = this.parent;
		if(document.all){
			f.innerHTML = "<object type=\"application/x-shockwave-flash\" data=\""+movie+"\" width=\""+this.width+"\" height=\""+this.height+"\"><param name=\"wmode\" value=\"transparent\"></param><param name=\"movie\" value=\""+movie+"\"></param></object>";
		} else {
			var e = document.createElement('embed');
			e.setAttribute("type","application/x-shockwave-flash");
			e.setAttribute("src",movie);
			e.setAttribute("width",this.width);
			e.setAttribute("height",this.height);
			e.setAttribute("wmode","transparent");
			f.appendChild(e);
		}
	};
	
	constructor.prototype.insert = function(){
		if(this.detect(this.flashVersion)){
			if(this.clearParent){this.clear();}
			this.create(this.src);
			return this.flashVersion;
		} else {
			return false;	
		}
	};
	
	constructor.prototype.clear = function(){
		while(this.parent.hasChildNodes()){
			this.parent.removeChild(this.parent.firstChild);
		}
	}
	
	return constructor; 
})();