/**
 * WMVObject Light v0.3: Windows Media embed generator by Gedoc for ViewOnTV - http://www.viewontv.com
**/
if(typeof ViewOnTV=="undefined"){var ViewOnTV=new Object();}
if(typeof ViewOnTV.WMVObject=="undefined"){ViewOnTV.WMVObject=new Object();}

ViewOnTV.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); }	
};

ViewOnTV.WMVObject.prototype={	
	addParam:function(_name,_value){  this.params[_name]=_value;  },
	setAttribute:function(_id,_value){	this.attributes[_id]=_value; },
	getEmbedHTML:function(){
		var _Object = "";
		var _Embed = "";
		var addUrlParam = true;
		_Object += '<OBJECT ID="'+this.attributes["name"]+'" width="'+this.attributes["width"]+'" height="'+this.attributes["height"]+'"\n';
		_Object += '   classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"\n';
		_Object += '   CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"\n';
		_Object += '        standby="Loading Microsoft® Windows® Media Player components..." \n';
		_Object += '        type="application/x-oleobject">\n';
		_Object += '	<PARAM NAME="FileName" VALUE="'+this.attributes["src"]+'">\n';
		_Embed += '		  <EMBED type="application/x-mplayer2" \n';
		_Embed += '   pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"\n';
		for(var key in this.attributes){
			_Embed += key+'="'+this.attributes[key]+'"\n';
		}
		var _params = this.params;
		for(var key in _params){
			if(!(key=="InvokeURLs"&&!addUrlParam)){
				_Object += '	<PARAM NAME="' + key + '" VALUE="' + _params[key] + '">\n';
				_params[key] = (typeof _params[key]=="string")?_params[key]:_params[key].toString();
				_params[key] = (_params[key].toLowerCase()=="true")?1:0;
				_Embed += key + '="' + _params[key] + '"\n';
				if(key=="InvokeURLs"){ addUrlParam = false; }
			}
		}
		var _Close = '></EM' + 'BED>';
		_Close += '</OBJ' + 'ECT>';
		return _Object + _Embed + _Close;
	},
	write:function(_layer){
		var d = (typeof(_layer)=="string")?document.getElementById(_layer):_layer;
		d.innerHTML=this.getEmbedHTML();
		return true;
	}
};

var WMVObject=ViewOnTV.WMVObject;
