
WMVObject = function(_file, _id, _width, _height){

	this.attributes=new Array();

	this.params=new Array();

	if(_file){	this.setAttribute("src",_file); }

	if(_id){ this.setAttribute("name",_id); }

	if(_width){ this.setAttribute("width",_width); }	

	if(_height){ this.setAttribute("height",_height); }	

};



WMVObject.prototype={	

	addParam:function(_name,_value){  this.params[_name]=_value;  },

	getParams:function(){	return this.params;  },

	setAttribute:function(_id,_value){	this.attributes[_id]=_value; },

	getAttributes:function(){	return this.attributes;  },

	getEmbedHTML:function(){

		var myObject = "";

		var myEmbed = "";

		var myScript = "";

		var _attributes=this.getAttributes();

		var addUrlParam = true;

		myObject += '<OBJECT ID="'+_attributes["name"]+'" width="'+_attributes["width"]+'" height="'+_attributes["height"]+'"\n';

		myObject += '   classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"\n';

		myObject += '   CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"\n';

		myObject += '        standby="Loading Microsoft® Windows® Media Player components..." \n';

		myObject += '        type="application/x-oleobject">\n';

		myObject += '	<PARAM NAME="SRC" VALUE="'+_attributes["src"]+'">\n';

		myObject += '	<PARAM NAME="URL" VALUE="'+_attributes["src"]+'">\n';

		myEmbed += '		  <EMBED type="application/x-mplayer2" \n';

		myEmbed += '   pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"\n';

		for(var key in _attributes){

			myEmbed += key+'="'+_attributes[key]+'"\n';

		}

		var _params=this.getParams();

		for(var key in _params){

			if(key=="InvokeURLs"&&!addUrlParam){ }else{

				myObject += '	<PARAM NAME="'+key+'" VALUE="'+_params[key]+'">\n';

				if(_params[key].toLowerCase()=="true"){ _params[key]=1; }else{ _params[key]=0; }

				myEmbed += key+'="'+_params[key]+'"\n';

				if(key=="InvokeURLs"){ addUrlParam = false; }

			}

		}

		myClose = '></EM' + 'BED>';

		myClose += '</OBJ' + 'ECT>';

		this.myScript = "\n"+myScript;

		return myObject+myEmbed+myClose;

	},

	write:function(_layer){

		var n=(typeof _layer=="string")?document.getElementById(_layer):_layer;

		n.innerHTML=this.getEmbedHTML();

		document.write(this.myScript);

		return true;}

};