var  Flash = (function(){
	function constructor(src, w, h, version, clearParent){
		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){
		var f = document.documentElement.childNodes[1];
		if(document.all){
			f.innerHTML = "<object type=\"application/x-shockwave-flash\" data=\""+movie+"\" width="+this.width+" height="+this.height+"><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);
			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(){
		var p = document.documentElement.childNodes[1];
		while(p.hasChildNodes()){
			p.removeChild(p.firstChild);
		}
	}
	
	return constructor; 
})();
