function HTMLWMediaPlayer(params){
	if(typeof(params) == undefined || params == null || typeof(params.id) == 'undefined' || params.id == null || params.id.length == 0)
	this.id = 'HTMLWMediaPlayer'+Math.round(Math.random()*10000);
	this.element;
	this.parElem;
	this.d = document;
	this.events = {};
	this.browser = new wbds_GetBrowser();
	this.width = 320;
	this.height = 240;
	this.params = {};
	this.hasClick = false;
	this.playCount = 0;
	this.hidden = false;
	this.attributes = {
		classid:"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6",
		standby:"Loading Microsoft® Windows® Media Player components..."		
	};
	//type:"application/x-oleobject"
	this.params.autoStart = true; 
	this.params.balance;
	this.params.baseURL;
	this.params.captioningID;
	this.params.currentPosition;
	this.params.currentMarker; 
	this.params.defaultFrame;
	this.params.enableContextMenu;
	this.params.enabled = true;
	this.params.fullScreen;
	this.params.invokeURLs;
	this.params.mute;
	this.params.playCount;
	this.params.rate;
	this.params.SAMIFileName;
	this.params.SAMILang;
	this.params.SAMIStyle;
	this.params.stretchToFit;
	this.params.uiMode;// = 'none';
	this.params.URL;
	this.params.FileName;
	this.params.volume;
	this.params.windowlessVideo;
	this.blockCInner = false;
	this.isAd = false;
	this.startOnNoAutoStart = true;
	for(i in params){
		switch(i){
			case 'attributes':
			case 'params':
				for(j in params[i]){
					this[i][j] = params[i][j];
				}
			break;
			default:
				this[i] = params[i];
			break;
		}
	}
	this.name = this.id;
	
	wbds_BroadCaster.prototype.initialize(this);
	
	this._watchfunction = function(){
		arguments.callee.owner._watchSrc();
	}
	this._watchfunction.owner = this;
	this._watchfunction.noelmcnt = 0;
	this._watchfunction.elmcnt = 0;
	this.criticalRegions = {
		src:false
	}
	this._lastSrc = null;	
}
pt = HTMLWMediaPlayer.prototype;
pt._onunload = function(){
	try{
		if(isS(this.element)){
			this.element.owner=null;
			if(isS(this.element.object)){
				this.element.object.close();
			}
			this.element.innerHTML = "";
		}
	}catch(e){}	
	try{
		this.clearEvents();
	}catch(e){}	
}
pt.clear = pt._onunload;
pt.reset = function(){
	this.playCount = 0;
	try{
		this.clearEvents();
	}catch(e){}
	for(var i in this.criticalRegions){
		this.criticalRegions[i] = false;
	}
}
pt.hide = function(){
	this.hidden = true;
	if(this.element != null){
		this.element.style.display = 'none';
		this.element.style.visibility = 'hidden';
		if(isS(this.element.object)){
			this.element.object.close();
			this.element.object.controls.stop();
		}
	}
}
pt.unhide = function(){
	this.hidden = false;
	if(this.element !=  null){
		this.element.style.display = '';
		this.element.style.visibility = 'visible';
	}
}
pt.getHTML = function(){
	var i,src,tmp;//6BF52A52-394A-11d3-B153-00C04F79FAA6|22D6F312-B0F6-11D0-94AB-0080C74C7E95
	if(this.browser.is_ie && !this.browser.is_mac){
		var obj = this.d.createElement('OBJECT');
		
		if(typeof(this.attributes.id) != 'undefined' && this.attributes.id != null) obj.id=this.attributes.id;
		else if(typeof(this.id) != 'undefined') obj.id=this.id;
			
		if(typeof(this.attributes.name) != 'undefined' && this.attributes.name != null) obj.name=this.attributes.name;
		else if(typeof(this.name) != 'undefined') obj.name = this.name;
		
		if(typeof(this.attributes.width) != 'undefined' && this.attributes.width != null) obj.width=this.attributes.width;
		else if(typeof(this.width) != 'undefined') obj.width=this.width;
			
		if(typeof(this.attributes.height) != 'undefined' && this.attributes.height != null) obj.height=this.attributes.height;
		else if(typeof(this.height) != 'undefined') obj.height=this.height;
		
		for(i in this.params){
			tmp=this.d.createElement('param');			
			tmp.name = i;
			tmp.value = this.params[i];
			obj.appendChild(tmp);
		}

		for(i in this.attributes){
			switch(i){
				case 'width':
				case 'height':
				case 'id':					
				case 'name':
				case 'data':
				break;				
				default:
					obj.setAttribute(i,this.attributes[i]);
				break;
			}
		}
	}else{
		var obj = this.d.createElement('EMBED');
		obj.type = 'application/x-mplayer2';
		obj.pluginspage = 'http://www.microsoft.com/Windows/MediaPlayer/';
		if(typeof(this.attributes.id) != 'undefined' && this.attributes.id != null) obj.id=this.attributes.id;
		else if(typeof(this.id) != 'undefined') obj.id=this.id;
			
		if(typeof(this.attributes.name) != 'undefined' && this.attributes.name != null) obj.name=this.attributes.name;
		else if(typeof(this.name) != 'undefined') obj.name = this.name;
		
		if(typeof(this.attributes.width) != 'undefined' && this.attributes.width != null) obj.width=this.attributes.width;
		else if(typeof(this.width) != 'undefined') obj.width=this.width;
			
		if(typeof(this.attributes.height) != 'undefined' && this.attributes.height != null) obj.height=this.attributes.height;
		else if(typeof(this.height) != 'undefined') obj.height=this.height;
			
  	for(i in this.params){
	  	il = i.toLowerCase();
  		switch(il){
				case 'url':
  			case 'filename':
  			case 'src':
  			case 'data':
  				if(this.params[i] != null && typeof(this.params[i]) != 'undefined' && this.params[i] != ''){
	  				src = this.params[i];
  				}
  			break;
  			default:
  				if(this.params[i] != null && typeof(this.params[i]) != 'undefined' && this.params[i] != ''){
  					obj[il] = this.params[i];
  				}
  			break;
  		}
  	}
  	
		for(i in this.attributes){
			switch(i){
				case 'width':
				case 'height':
				case 'id':					
				case 'name':
				case 'classid':
				case 'standby':
				break;
				case 'url':
  			case 'filename':
  			case 'src':
  			case 'data':
  				obj.setAttribute(i,src);	
  			break;
				default:
					obj.setAttribute(i,this.attributes[i]);
				break;
			}
		}		
		obj.src = src;
  }
  obj.windowlessVideo = true;
	//obj.uiMode = 'invisible';  
	return obj;
}

pt.setSrc = function(src){
	if(!isS(this.element)){
		this.element = this.d.getElementById(this.id);
	}
	this.criticalRegions.src = true;
	try{
	this._lastSrc = src;
	this.params.FileName = src;
	this.attributes.src = src;	
	if(this.browser.hasActiveX){
		if(this.element.readyState<3){
			var args = [],i;
			for(i=0;i<arguments.length;i++){
				args[i] = arguments[i];
			}
			this.waitObjectReady(this,arguments.callee,args);
			return;
		}
		this.element.data = "";
		this.element.src = "";
		this.element.URL = src;
		this.element.FileName = src;
		
		
		if((typeof(this.element.settings.autoStart) == 'undefined' || !this.element.settings.autoStart) && this.startOnNoAutoStart){									
			setTimeout(this.owner.varname+".player.element.controls.play();",20);
		}
		
		if(isS(arguments.callee.bpplayid)) clearTimeout(arguments.callee.bpplayid);
		if((typeof(this.element.settings.autoStart) != 'undefined' && this.element.settings.autoStart)){
			arguments.callee.bpplayid = setTimeout("var state = "+this.owner.varname+".player.element.playState;if(state == 0 || state == 1 || state == 8 || state == 10){"+this.owner.varname+".player.element.controls.play();}",2500);	
		}
	}else{
		if(!isS(this.parElem))
			this.parElem = this.element.parentNode;

		var r1=false,r2=false;
		if(!this.params.autoStart && this.startOnNoAutoStart){
			this.params.autoStart = true;
			r1 = true;
		}

		if((!this.attributes.autostart || this.attributes.autostart == '0')  && this.startOnNoAutoStart){
			this.attributes.autostart = true;
			r2 = true;
		}
		this.element = null;
		this.blockCInner = false;
		this.cInner(this.parElem);
		if(r1){
			this.params.autoStart = false;
		}
		if(r2){
			this.attributes.autostart = false;
		}		
	}
	}catch(e){
	}finally{
		this.criticalRegions.src = false;
	}
}
pt.cWrite = function(){
	this.d.write(this.getHTML().innerHTML);
	var elm = this.d.getElementById(this.id);
	elm.obj = this;
	this.element = elm;
	this.element.owner = this;
}
pt.cInner = function(elm){
	if(this.blockCInner) {
		if(!isS(this.element.id) || this.element.id == '') this.element.id = this.id;
		this.element.owner = this;
		this.parElem = this.element.parentNode;
		return;		
	}
	//this.cInnerElement = elm;
	
	elm.innerHTML = "";
	
	elm.appendChild(this.getHTML());

	
	//this.d = elm.ownerDocument;
	var elm2 = this.d.getElementById(this.id);
	/*elm2.obj = this;*/	
	this.element = elm2;
	this.element.owner = this;
	this.parElem = this.element.parentNode;
}
pt.setClick = function(url){
	this.hasClick = true;
	if(this.browser.hasActiveX){
		this.registerEvent("Click","var a = document.createElement('A');a=document.getElementsByTagName('body')[0].appendChild(a);a.href='"+url+"';a.target='_BLANK';a.style.display='none';a.click();");
	}else{
		/*var ar = this.d.createElement('DIV');
		ar = this.cInnerElement.insertBefore(ar,this.element);
		ar.style.position = 'absolute';
		ar.style.top = 0;
		ar.style.width ="500px";
		ar.style.height ="500px";
		ar.style.zIndex = 9999999999;
		ar.style.backgroundColor = 'red';
    ar.onclick = function(){alert("/workshop/graphics/sun.gif")};*/
	}
}
pt.removeClick = function(){
	this.unRegisterEvent("Click");
	this.hasClick = false;
}
pt.registerEvent = function(name,code,args){
	try{
		if(!isS(this.events[name])){
			var script = this.d.createElement("script");
			script.htmlFor = this.id;
			script.event = (name.indexOf('(')>0) ? name: (arguments.length <= 2) ? name + '(arg)' :name +args;
			script.text = code;
			this.events[name.replace(/[\(\)]/g,'_')] = this.d.getElementsByTagName("head")[0].appendChild(script);
		}else{
			code = this.events[name].text+";"+code;
			this.unRegisterEvent(name);
			this.registerEvent(name,code);
		}
	}catch(e){
		//alert('couldnot register event: '+e);
	}
}
pt.unRegisterEvent = function(name){
	name = name.replace(/[\(\)]/g,'_');
	if(isS(this.events[name]) && isS(this.events[name].parentNode)){		
		this.events[name].parentNode.removeChild(this.events[name]);
		this.events[name] = null;
	}
}
pt.clearEvents = function(){
	for(var i in this.events){
		try{
			this.unRegisterEvent(i);
		}catch(e){};
	}
}
pt.waitObjectReady = function(obj,func,args){
	this.__waitObjectReady.obj = obj;
	this.__waitObjectReady.func = func;
	this.__waitObjectReady.args = args;
	this._waitObjectReady.owner = this;
	setTimeout(this._waitObjectReady,10);
}
pt._waitObjectReady = function(){
	var ce = arguments.callee,ow = ce.owner;
	if(ow.element.readyState>2){
		ow.__waitObjectReady();
	}else
		setTimeout(ce,10);
}
pt.__waitObjectReady = function(){
	var ce = arguments.callee;
	ce.func.apply(ce.obj,ce.args);
}
pt.watchSrc = function(){
	if(!isS(this._watchfunction.intid) || this._watchfunction.intid<0)
		this._watchfunction.intid = setInterval(this._watchfunction,10);
}
pt._watchSrc = function(){
	if(this.browser.hasActiveX)
		var element = this.element;
	else
		var element = this.d.getElementById(this.id);
	if(isS(element) && !this.criticalRegions.src){
		this._watchfunction.elmcnt++
		if((this._watchfunction.noelmcnt>0 && this._watchfunction.elmcnt>1) || this._watchfunction.noelmcnt==0){			
		var changed = false;
		var empcnt = 0;
		var fcnt = 0;
		if(isS(element.URL) &&  element.URL != this._lastSrc){
			changed = true;
			if(element.URL == '')empcnt++;
			else{
				this._lastSrc = element.URL;
				fcnt++;
			}
		}
		if(!changed && isS(element.FileName) && element.FileName != this._lastSrc){
			changed = true;
			if(element.FileName == '' || (empcnt==0 && element.FileName != element.URL))empcnt++;
			else{
				this._lastSrc = element.FileName;
				fcnt++;
			}
		}
		if(!changed && isS(element.data) && element.data != this._lastSrc){
			changed = true;
			if(element.data == '')empcnt++;
			else{
				this._lastSrc = element.data;
				fcnt++;
			}
		}
		if(!changed && isS(element.src) && element.src != this._lastSrc){
			changed = true;
			if(element.src == '')empcnt++;
			else{
				this._lastSrc = element.src;
				fcnt++;
			}
		}
		if(changed){
			if(fcnt>0){
				//alert('non empty changes: '+this._lastSrc);
				this.broadcastMessage('onSourceChange',this);		
			}else if(empcnt == 4){
				this._lastSrc = "";
				//alert('all empty changes: '+this._lastSrc);
				this.broadcastMessage('onSourceChange',this);
			}			
		}
		}else{
			if(this.element != element) this.element = element;
			this._watchfunction.noelmcnt = 0;
		}
	}else{
		this._lastSrc = "";
		this._watchfunction.elmcnt = 0;
		this._watchfunction.noelmcnt++;
	}
}