/**
Using:
<script type="text/javascript" language="JavaScript" src="/js/Embeder.js" >//</script>
<script type="text/javascript" language="JavaScript">
// <![CDATA[

var emb=new Embeder()
//emb.type=""
emb.addAttribute("width",)
emb.addAttribute("height",)
emb.addAttribute("file","")
//emb.addAttribute("wmode","transparent")
// ]]>
</script>
IN HTML:
<div id="embedContent"></div>
emb.assignToElement("embedContent")
*/
function Embeder(){
this.pluginComMethod="none"//auto - javascript/fscommand zależnie od browsera|javascript
this.type="application/x-shockwave-flash"//flash, quicktime, java
this.attributes={}
this.addAttribute=function(n,v){
this.attributes[n]=v
}
this.variables={}
this.addVariable=function(n,v){
this.variables[n]=v
}
this.getHTML=function(){

	var str='<object  type="'+this.type+'" width="'+this.attributes.width+'" height="'+this.attributes.height+'"' 
	var ua=navigator.userAgent.toLowerCase()
	if(ua.indexOf("msie")==-1){
	str+=' data="'+this.attributes.file+'"'
	}
	if(this.attributes.id){
		str+=' id="'+this.attributes.id+'" name="'+this.attributes.id+'"'
		if(this.pluginComMethod=="auto"){
			if(ua.indexOf("windows")>-1 && ua.indexOf("msie")>-1){
				this.addVariable("canUseFscommand","true")
			}else{
				this.addVariable("fscommandFunctionName",this.attributes.id+"_DoFSCommand")
			}
		}else if(this.pluginComMethod=="javascript"){
			this.addVariable("fscommandFunctionName",this.attributes.id+"_DoFSCommand")
		}
	}
	if(this.attributes.style){
		str+=' style="'+this.attributes.style+'"'
	}
	str+='>'
	str+='<param name="movie" value="'+this.attributes.file+'" />'
	if(this.type=="application/x-shockwave-flash"){
		var re=/file|width|height|id|style/
		for(var el in this.attributes){
			if(re.test(el)){
				continue;
			}
			str+='<param name="'+el+'" value="'+this.attributes[el]+'" />'
		}
		
		var fva=new Array()
		for(var el in this.variables){
			fva.push(el+"="+this.variables[el])
		}
		if(fva.length>0){
			str+='<param name="flashvars" value="'+fva.join("&")+'" />'
		}
	}
	
	
	str+='</object>';
	return str
}
this.assignToElement=function(elId){
document.getElementById(elId).innerHTML=this.getHTML()
}
}
