//class Player WM
//public
function PlayerWM(onChangeState,onCommand){
this.playerType="WM";
this.onChangeState=onChangeState;
this.onCommand=onCommand;
this.myState="null";
//this.myLastTime=-2;
this.myEndofclip=false;
this.myMediatrack=new Array();
this.myPlayer=null;
this.Starttime=0;
this.myURL="";
this.myCurrentindex=-1;
this.myTotalDuration=9595959;
this.myscheduleClip=null;
this.mylog="";
}//end function

//public
PlayerWM.prototype.hook=function Player_hook(func){
this.onChangeState=func;
}//end function

//public
PlayerWM.prototype.init=function Player_init(q_URL,q_SSIZE,q_INSTREAM,q_CONTROL,q_ALLOWMENU,q_AUTOSTART,q_eventlist,q_STARTTIME){
logga("init "+q_STARTTIME);

this.myFormat="WM";
this.myTag=(WIN()&&(IE()||NS()||FX())?"OBJECT":"EMBED");
this.myURL=q_URL;
this.myDisplaysize=q_SSIZE;
this.mySevent=true;
this.myInstream=q_INSTREAM;
this.myAllowmenu=q_ALLOWMENU;
this.myScriptable=true;//until proven otherwise
this.myAutostart=q_AUTOSTART;//||FX();
this.myShowcontrols=q_CONTROL;
if(false && FX()){//Change to embed for Firefox
	this.myAutostart=true;
	this.myTag="EMBED";
}//end if
this.setMediatrack(q_eventlist);
this.setTime(q_STARTTIME);
this.setMyURL(q_STARTTIME);
}//end function

//public
PlayerWM.prototype.paint=function Player_paint(q_obj,q_OVERWRITE){
this.myContainer=q_obj;
this.myPlayername=q_obj.id+"img";
var q_WIDTH=parseInt(this.myContainer.offsetWidth);
var q_HEIGHT=parseInt(this.myContainer.offsetHeight);
this.myOverwrite=q_OVERWRITE;
logga("Player.paint "+this.time2pos(this.myStarttime));
if(q_OVERWRITE || !div(this.myPlayername)){
	this.myContainer.innerHTML=Player_mediaplayer_html(this.myPlayername,"WM", this.myTag, this.myURL,q_WIDTH,q_HEIGHT,this.myDisplaysize,this.mySevent,this.myInstream,this.myShowcontrols,this.myShowcontrols,this.myAllowmenu,this.myAutostart,this.time2pos(this.myStarttime));
	this.myPlayer=document.getElementById(this.myPlayername);
	WINFXWM_patch(this.myPlayername);
}else{
	this.myPlayer=document.getElementById(this.myPlayername);
}//end if
}//end function

//public
PlayerWM.prototype.dispose=function Player_dispose(){
if(!this.noPlayer()){
	this.stop();
	this.myPlayer=null;
	this.myContainer.innerHTML="";
}//end if
}//end function

//public
PlayerWM.prototype.initandpaint=function Player_paint(q_obj,q_URL,q_SSIZE,q_INSTREAM,q_CONTROL,q_ALLOWMENU,q_AUTOSTART,q_OVERWRITE){
this.init(q_URL,q_SSIZE,q_INSTREAM,q_CONTROL,q_ALLOWMENU,q_AUTOSTART,eventlist,0);
this.paint(q_obj,q_OVERWRITE);
return true;
}//end function

//public
PlayerWM.prototype.setPlayer=function Player_setPlayer(q_name,format){
//try{
this.myFormat=format;
this.myPlayer=document.getElementById(q_name);
this.myContainer=this.myPlayer.parentNode;
//}catch(errObj){
//}//end catch
}//end function

//public
PlayerWM.prototype.play=function Player_play(){
if(this.noPlayer()){
//experiment create embed tag when asking for play
	this.myAutostart=true;
	this.paint(div("video"),true);
}else{
	//try{
		this.myPlayer.controls.play();
	//}catch(errObj){
	//	WINFXWM_wakeup(this.myPlayername);
	//}//end catch
}//end if
}//end function

//public
PlayerWM.prototype.pause=function Player_pause(){
try{
	this.myPlayer.controls.pause();
}catch(errObj){

}//end catch
}//end function

//public
PlayerWM.prototype.stop=function Player_stop(){
try{
	this.myPlayer.controls.stop();
}catch(errObj){
}//end catch
}//end function

//public
PlayerWM.prototype.up=function Player_volumeUp(){
try{
	this.myPlayer.settings.volume= this.myPlayer.settings.volume + 10;
}catch(errObj){
}//end catch
}//end function

//public
PlayerWM.prototype.down=function Player_volumeDown(){
try{
	this.myPlayer.settings.volume=this.myPlayer.settings.volume - 10;
}catch(errObj){
}//end catch
}//end function

//public
PlayerWM.prototype.mute=function Player_mute(q_muted){
try{
	if(q_muted==false){
		this.myPlayer.settings.volume=50;
	}else{
		this.myPlayer.settings.volume=0;
	}//end if
}catch(errObj){
}//end catch
}//end function

//public
PlayerWM.prototype.updateEvent=function Player_updateEvent(){
if(!this.noPlayer()){
	if(this.isMulticlip()){
		if(this.isLastclip()){
			if(this.getTime()>this.myTotalDuration){
				logga("pause at end");
				gPlayer.pause();
			}//end if
		}else{
			var q_nextClipstart=this.myMediatrack[this.myCurrentindex+1].myClipstart;
			var q_clipTimeLeft=q_nextClipstart-this.getTime();
			if(q_clipTimeLeft<-0.1){//we passed a clip end
				logga("enter new clip");
				gPlayer.setTime(q_nextClipstart);
			}else if(q_clipTimeLeft<1.5){
				this.scheduleClip(q_nextClipstart,q_clipTimeLeft*1000-100);
			}//end if
		}//end if
	}else{
		if(this.getTime()>this.myTotalDuration){
			logga("pause at end");
			gPlayer.pause();
		}//end if
	}//end if
}//end if
}//end function

//public
PlayerWM.prototype.setTime=function Player_setTime(q_playtime){
this.unScheduleClip();
logga("setTime("+q_playtime+")");
if(this.noPlayer()){
	return this.setStarttime(q_playtime);
}else{
	if(this.isMulticlip()){
		return this.setMediatrackPos(q_playtime);
	}else{
		return this.setPos(q_playtime);
	}//end if
}//end if
}//end function

//public
PlayerWM.prototype.getTime=function Player_getTime(){
if(this.noPlayer()){
	return this.myStarttime;
}else{
	if(this.isMulticlip()){
		return this.getMediatrackPos();
	}else{
		return this.getPos();
	}//end if
}//end if
}//end function

//public
PlayerWM.prototype.getDuration=function Player_getDuration(){
if(this.isMulticlip()){
		return this.getMediatrackDuration();
}else{
	try{
	if(this.noPlayer()){
		alert("getDuration/Singleclip&&NoPlayer is not implemented");
		return 0;
	}else{
		if(isASX(gPlayer.myPlayer.URL)){
			return this.getAsxDuration();
		}else{
			return this.myPlayer.currentMedia.duration;
		}//end if
	}//end if
	}catch(errObj){
		return -1;
	}//end catch
}//end if
}//end function

//public
PlayerWM.prototype.getSrc=function Player_getSrc(){
if(this.myPlayer){
	if(this.myPlayer.URL){
		return replace(this.myPlayer.URL,"\\","/");
	}else{
		return this.myURL;
	}//end if
}else{
	return this.myURL;
}//end if
}//end function

//public
PlayerWM.prototype.setSrc=function Player_setSrc(src){
var cmp=src.replace("file://","");
if(this.getSrc()!=cmp){
	this.myURL=cmp;
	if(this.myPlayer){
		return this.myPlayer.URL=this.myURL;
	}//end if
}else{
	return false;
}//end if
}//end function

//public
PlayerWM.prototype.setSize=function Player_setSize(width,height){
if(width=="full"){
	this.myPlayer.fullscreen=true;
}else if (width=="normal"){
	if(this.myPlayer.fullscreen){
		this.myPlayer.fullscreen=false;
	}else{
		this.myPlayer.width=this.myContainer.offsetWidth;
		this.myPlayer.height=this.myContainer.offsetHeight;
	}//end if
}else if(isNumeric(width)){
	this.myPlayer.fullscreen=false;
	this.myPlayer.width=width;
	this.myPlayer.height=height;
}//end if
}//end function

//public
PlayerWM.prototype.setShowcontrols=function Player_setShowcontrols(q_show){
if(this.myPlayer){
	this.myPlayer.uiMode=(q_show)?"full":"none";
	this.myPlayer.stretchToFit=(q_show)?false:true;
	return this.myPlayer.uiMode;
}//end if
}//end function

//public
PlayerWM.prototype.canScript=function Player_canScript(){
if(this.myPlayer){
	if(this.myPlayer.controls){
		return true;
	}//end if
}//end if
return false;
}//end function

//public
PlayerWM.prototype.setState=function Player_setState(state){
if(("play,pause,stop,connect,buffer,idle,").indexOf(state+",")>-1){
	if(this.myState!=state){
		this.myState=state;
		this.onChangeState(this.myState);
	}//end if
}//end if
}//end function
//end class

//public
PlayerWM.prototype.setCmd=function Player_setCmd(q_cmd){
if(this.onCommand){
	this.onCommand(q_cmd,null,null);
}//end if
}//end function
//end class

//public
PlayerWM.prototype.getState=function Player_getState(){
try{
	this.updateState();
	if(this.myState){
		return this.myState;
	}else{
		return "null";
	}//end if
}catch(errObj){
	return "null";
}//end catch
}//end function

//public
PlayerWM.prototype.getBuffering=function Player_getBuffering(){
try{
	var q_v=this.myPlayer;
	if(this.myFormat=="WM"){
		return q_v.network.bufferingProgress;
	}else if(this.myFormat=="RM"){
		if (q_v.getBufferingTimeRemaining()+ q_v.getBufferingTimeElapsed()>0){
			return Math.floor(100*q_v.getBufferingTimeElapsed()/ (q_v.getBufferingTimeRemaining()+q_v.getBufferingTimeElapsed()));
		}else{
			return 100;
		}//end if
	}else{
		return 100;
	}//end if
}catch(errObj){
	return 0;
}//end catch
}//end function

//public
PlayerWM.prototype.getBandwidth=function Player_getBandwidth(){
if(this.myPlayer){
	if(this.myPlayer.network){
		if(this.myPlayer.network.sourceProtocol){
			if(this.myPlayer.network.sourceProtocol.toLowerCase()=="file"){
				return Math.floor(this.myPlayer.network.bitRate/1000);
			}else{
				return Math.floor(this.myPlayer.network.bandWidth/1000);
			}//end if
		}//end if
	}//end if
}//end if
return 0;
}//end function

//public
PlayerWM.prototype.getFramerate=function Player_getFramerate(){
if(this.myPlayer){
	if(this.myPlayer.network){
		return Math.floor(0.5+this.myPlayer.network.frameRate/100);
	}//end if
}//end if
return 0;
}//end function

//public
PlayerWM.prototype.getVersion=function Player_getVersion(){
return this.myPlayer.versionInfo;
}//end function

//public
PlayerWM.prototype.stateConstWM=function Player_stateConstWM(q_stateNum){
switch (q_stateNum){
case 0:return "idle";//Undefined
case 1:return "stop";//Stopped
case 2:return "pause";//Paused
case 3:return "play";//Playing
case 4:return "play";//ScanForward
case 5:return "play";//ScanReverse
case 6:return "buffer";//Buffering
case 7:return "connect";//Waiting
case 8:return "idle";//MediaEnded
case 9:return "connect";//Transitioning
case 10:return "idle";//Ready
case 11:return "connect";//Reconnecting
default:return "idle";
}//end switch
return "null";
}//end function

//public
PlayerWM.prototype.showCurrent=function showCurrent(){
if(this.isMulticlip()){
	var q_media=this.getCurrentMedia();
	if(q_media){
		return "Multiclip,["+this.myCurrentIndex+"],"+q_media.myClipstart+","+q_media.mySrc+","+q_media.myMarkin+","+q_media.myDuration;
	}else{
		return "Multiclip,no current media";
	}//end if
}else{
		return "Singleclip,"+this.myURL;
}//end if
}//end function

//public
PlayerWM.prototype.player2Sync=function Player_player2Sync(q_offset){
var q_obj=slideimg.document.getElementById("videoimg");
if(q_obj){
	var player2State=this.stateConstWM(q_obj.playState);
	if(this.getState()=="play" && player2State=="play"){
		if(Math.abs(this.player2Diff())>0.1){
			if(q_offset){
				q_obj.controls.currentPosition=this.getTime()+q_offset;
			}else{
				q_obj.controls.currentPosition=this.getTime()+0.1;
				setTimeout("gPlayer.player2Sync()",2000);
			}//end if
		}//end if
	}else{
		setTimeout("gPlayer.player2Sync()",5000);		
	}//end if
}//end if
}//end function
//---------------------------------------------------------------------------------------------------

//private
PlayerWM.prototype.setMyURL=function Player_setMyURL(q_STARTTIME){
logga("setMyURL "+q_STARTTIME);
this.myStarttime=q_STARTTIME;
this.myCurrentindex=this.getMediatrackIndex(this.myStarttime);
if(this.myURL==""&&this.myCurrentindex>-1){
	this.myURL=this.getCurrentMedia().mySrc;
}//end if
}//end function

//private
function WINFXWM_patch(o){//Workaround for a Firefox bug when scripting Windows Media
if(FX()){
	setTimeout("WINFXWM_wakeup('"+o+"')",2000);
}//end if
}//end function
function WINFXWM_wakeup(o){
return inf(div(o));
}//end function

var gVHTML="";
//private
function Player_mediaplayer_html(q_name,SFORMAT, TAG, URL,VIDEOWIDTH, VIDEOHEIGHT,SSIZE,SEVENT,INSTREAM,CONTROL,STATUS, ALLOWCHANGESIZE,AUTOSTART,q_STARTTIME){
logga("Player_mediaplayer_html "+q_STARTTIME);
var html,UIMode,Fullscreen,StretchToFit,DisplaySize,AutoSize,CONTROLHEIGHT,cname;
html="";
	//### fixup player format
	if((CONTROL==false)&&(STATUS==false)){
		UIMode="none";
	}else{
		UIMode="full";//mini
	}//end if
		Fullscreen="false";
		StretchToFit="false";
	switch(SSIZE){
	case "-1":
		UIMode="invisible";
		break;
	case "0":
		break;
	case "1":
		break;
	case "2":
		StretchToFit="true";
		break;
	case "3":
		Fullscreen="true";
		break;
	}//end switch
	
	if((TAG=="OBJECT")||(TAG=="BOTH")){
		html=html+"<OBJECT id='"+q_name+"' name='"+q_name+"' width='"+VIDEOWIDTH+"' height='"+VIDEOHEIGHT+"'\n";
		if(FX()&&WIN()){
			html=html+"type='application/x-ms-wmp'>\n";
		}else{
			html=html+"CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'>\n";
		}//end if
		html=html+"<PARAM NAME='URL' value = '"+URL+"'>\n";
		html=html+"<PARAM NAME='currentPosition' VALUE='"+parseInt(q_STARTTIME)+"'>\n";
		html=html+"<PARAM NAME='autoStart' value='"+AUTOSTART+"'>\n";
		html=html+"<PARAM NAME='uiMode' VALUE='"+UIMode+"'>\n";
		html=html+"<PARAM NAME='stretchToFit' VALUE='"+StretchToFit+"'>\n";
		html=html+"<PARAM NAME='fullScreen' VALUE='"+Fullscreen+"'>\n";
		html=html+"<PARAM NAME='enableContextMenu' VALUE='"+ALLOWCHANGESIZE+"'>\n";
	}//end if
	if((TAG=="EMBED")||(TAG=="BOTH")){
		html=html+"<embed src='"+URL+"' type='application/x-mplayer2' id='"+q_name+"' name='"+q_name+"' \n";
		html=html+"pluginsPage='http://www.microsoft.com/Windows/Downloads/Contents/Products/Mediaplayer/'\n";
		html=html+"width="+VIDEOWIDTH+" height="+VIDEOHEIGHT+"\n";
		html=html+"currentPosition='"+q_STARTTIME+"' \n";
		html=html+"autoStart='"+AUTOSTART+"' \n";
		html=html+"uiMode='"+UIMode+"' \n";
		html=html+"stretchToFit='"+StretchToFit+"' \n";
		html=html+"fullScreen='"+Fullscreen+"' \n";
		if(UIMode=="none"){
			html=html+"showControls='false' \n";
			html=html+"showTracker='false' \n";
		}//end if
		html=html+">\n";
		html=html+"</embed>\n";
	}//end if
	if((TAG=="OBJECT")||(TAG=="BOTH")){
		html=html+"</OBJECT>";
	}//end if
	if(INSTREAM==true){
		html=html+"<script for='"+q_name+"' event='Scriptcommand(sType, sParam)'>if(sType.toLowerCase()=='text'){if(gPlayer)gPlayer.setCmd(sParam);}else{} </script>\n";
	}//end if
	if(SEVENT==true){
		html=html+"<script for='"+q_name+"' event='PlayStateChange(NewState)'>if(typeof(gPlayer)!='undefined')gPlayer.setState(gPlayer.stateConstWM(NewState));</script>\n";
	}//end if
	gVHTML=HTMLEncode(html);
return html;
}//end method

//private
PlayerWM.prototype.noPlayer=function Player_noPlayer(){
if(this.myPlayer){
	if(this.myPlayer.controls){
		return false;
	}//end if
}//end if
return true;
}//end function

//private
PlayerWM.prototype.scheduleClip=function Player_scheduleClip(q_start,q_at){
if(this.myscheduleClip){
}else{
	logga("schedule new clip in "+q_at+"ms");
	this.myscheduleClip=setTimeout("gPlayer.setTime("+q_start+")",q_at);
}//end if
}//end function

//private
PlayerWM.prototype.unScheduleClip=function Player_unScheduleClip(){
if(this.myscheduleClip){
	clearTimeout(this.myscheduleClip);
	this.myscheduleClip=null;
}//end if
}//end function

//private
PlayerWM.prototype.isLastclip=function Player_isLastclip(){
return (this.myCurrentindex==this.myMediatrack.length-1);
}//end function

//private
PlayerWM.prototype.setStarttime=function Player_setStarttime(q_pos){
logga("setStarttime "+q_pos);
	this.myStarttime=q_pos;
	if(this.setMediatrackIndex(q_pos)>-1){
		this.myURL=this.getCurrentMedia().mySrc;
	}//end if
	return this.myStarttime;
}//end function

//private
PlayerWM.prototype.setPos=function Player_setPos(arg){
var plist=this.myPlayer.currentPlaylist;
if(plist){
	if(plist.count>1){
		var q_start=0;
		for(var q_i=0;q_i<plist.count;q_i++){
			if(arg<q_start+plist.item(q_i).duration){
				if(!this.myPlayer.currentMedia.isIdentical(plist.item(q_i))){
					this.myPlayer.controls.currentItem=plist.item(q_i);
					this.currentItem=q_i;
				}//end if
				this.myPlayer.controls.currentPosition=parseInt(arg)-q_start;
				logga("Setpos "+arg+"=("+q_i+","+(parseInt(arg)-q_start)+") return "+(q_start+this.myPlayer.controls.currentPosition));
				return q_start+this.myPlayer.controls.currentPosition;
			}//end if
			q_start=q_start+plist.item(q_i).duration;
		}//next
		logga("Setpos "+arg+" return arg");
		return arg;
	}else{
		this.currentItem=0;
		this.myPlayer.controls.currentPosition=arg;
		logga("Setpos "+arg+" return curpos "+this.myPlayer.controls.currentPosition);
		return arg;
	}//end if
}//end if
}//end function

//private
PlayerWM.prototype.getMediatrackIndex=function Player_getMediatrackIndex(q_pos){
var plist=this.myMediatrack;
for(var q_i=plist.length-1;q_i>=0;q_i--){
	if(q_pos>=plist[q_i].myClipstart && plist[q_i].myDuration==-1){
		return q_i;
	}else if(q_pos>=plist[q_i].myClipstart && q_pos<plist[q_i].myClipstart+plist[q_i].myDuration){
		return q_i;
	}//end if
}//next
return -1;
}//end function

//private
PlayerWM.prototype.time2pos=function Player_time2pos(q_time){
var q_i=this.getMediatrackIndex(q_time);
if(q_i>=0){
	var q_media=this.myMediatrack[q_i];
	return q_media.myMarkin+parseInt(q_time)-q_media.myClipstart;
}else{
	return 0;
}//end if
}//end function

//private
PlayerWM.prototype.setMediatrackIndex=function Player_setMediatrackIndex(q_pos){
var q_i=this.getMediatrackIndex(q_pos);
if(q_i>=0){
	this.myCurrentindex=q_i;
	return this.myCurrentindex;
}else{
	return -1;
}//end if
}//end function

//private
PlayerWM.prototype.getCurrentMedia=function Player_getCurrentMedia(){
	return this.myMediatrack[this.myCurrentindex];
}//end function

//private
PlayerWM.prototype.setMediatrackPos=function Player_setMediatrackPos(arg){
if(this.setMediatrackIndex(arg)>-1){
	q_media=this.getCurrentMedia();
	if(!this.isIdentical(q_media)){
		this.myPlayer.setSrc(q_media.mySrc);
	}//end if
	this.myPlayer.controls.currentPosition=q_media.myMarkin+parseInt(arg)-q_media.myClipstart;
	return this.myPlayer.controls.currentPosition-q_media.myMarkin+q_media.myClipstart;
}else{
	return -1;
}//end if
}//end function

//private
PlayerWM.prototype.getPos=function Player_getPos(){
if(this.myPlayer){
	if(this.myPlayer.controls){
		var plist=this.myPlayer.currentPlaylist;
		if(plist){
			var q_start=0;
			for(var q_i=0;q_i<plist.count;q_i++){
				if(this.myPlayer.currentMedia.isIdentical(plist.item(q_i))){
					return q_start+this.myPlayer.controls.currentPosition;
				}//end if
				q_start=q_start+plist.item(q_i).duration;
			}//next
		}//end if
		return this.myPlayer.controls.currentPosition;
	}else{
		return -1;
	}//end if
}else{
	return -1;
}//end if
}//end function

//private
PlayerWM.prototype.getMediatrackPos=function Player_getMediatrackPos(){
var q_i=this.myCurrentindex;
if(q_i>=0){
	q_media=this.getCurrentMedia();
	if(this.isIdentical(q_media)){
		return this.myPlayer.controls.currentPosition-q_media.myMarkin+q_media.myClipstart;
	}else{
		return -1;
	}//end if
}else{
	return -1;
}//end if
}//end function

//private
PlayerWM.prototype.isValidpos=function Player_isValidpos(q_pos){
if(q_pos>=0 && this.getDuration()==-1){//duration undefined - time is presumably within the clip
	return true;
}else if(q_pos>=0 && q_pos <= this.getDuration()){
	return true;
}else{
	return false;
}//end if
}//end function

//private
PlayerWM.prototype.getAsxMarkin=function Player_getAsxMarkin(){
var q_m=this.myPlayer.controls.currentItem;
if(q_m.getItemInfo("StartTime")>"0"){
	return parseInt(q_m.getItemInfo("StartTime"));
}else{
	return 0;
}//end if 
}//end function

//private
PlayerWM.prototype.getAsxDuration=function Player_getAsxDuration(){
if(this.myPlayer.controls){
	var plist=this.myPlayer.currentPlaylist;
	if(plist){
		var q_dur=0;
		for(var q_i=0;q_i<plist.count;q_i++){
			q_dur=q_dur+plist.item(q_i).duration;
		}//next
	}//end if
	return q_dur;
}else{
	return 0;
}//end if
}//end function

//private
PlayerWM.prototype.getMediatrackDuration=function Player_getMediatrackDuration(){
var plist=this.myMediatrack;
var q_dur=0;
for(var q_i=0;q_i<plist.length;q_i++){
	q_dur=q_dur+plist[q_i].myDuration;
}//next
return q_dur;
}//end function

//private
PlayerWM.prototype.verifyMediatrackDuration=function Player_verifyMediatrackDuration(){
var plist=this.myMediatrack;
var q_verified=true;
for(var q_i=0;q_i<plist.length;q_i++){
	q_verified=q_verified && isEqualDuration(plist[q_i].myDuration,this.getRealDuration(q_i));
}//next
return q_verified;
}//end function

//private
function isEqualDuration(a,b){
return almostEqual(a,b);
}//end function

//private
PlayerWM.prototype.fixMediatrackDuration=function Player_fixMediatrackDuration(){
var plist=this.myMediatrack;
for(var q_i=0;q_i<plist.length;q_i++){
	plist[q_i].myDuration=this.getRealDuration(q_i);
}//next
return true;
}//end function

//private
PlayerWM.prototype.getRealDuration=function Player_getRealDuration(q_i){
var plist=this.myMediatrack;
if(q_i<plist.length-1){
	return plist[q_i+1].myClipstart-plist[q_i].myClipstart;
}else{
	return this.myTotalDuration-plist[q_i].myClipstart;
}//end if
}//end function

//private
PlayerWM.prototype.updateState=function Player_updateState(){
try{
	this.myState=this.stateConstWM(this.myPlayer.playState);
}catch(errObj){
}//end catch
}//end function

//private
PlayerWM.prototype.player2Diff=function Player_player2Diff(){
var q_obj=slideimg.document.getElementById("videoimg");
if(q_obj){
	return q_obj.controls.currentPosition-this.getTime();
}else{
	retunr -1;
}//end if
}//end function

//private
PlayerWM.prototype.player2Tune=function Player_player2Tune(q_offset){
var q_obj=slideimg.document.getElementById("videoimg");
if(q_obj){
//	if(Math.abs(this.player2Diff)<1){
	if(this.player2Diff()<0){
		gPlayer.pause();
		var q_pausetime=this.player2Diff()*1000;
		setTimeout("gPlayer.play()",q_pausetime-q_offset);
	}//end if
}//end if
}//end function

//private
PlayerWM.prototype.isMulticlip=function Player_isMulticlip(){
if(this.myMediatrack.length>1){
	return true;
}else if(this.myMediatrack[0]){
	return (this.myMediatrack[0].myMarkin>0);
}else{
	return false;
}//end if
}//end function

//private
PlayerWM.prototype.setMediatrack=function Player_setMediatrack(q_ev){
this.myMediatrack=new Array();
for (q_i=0;q_i<q_ev.length;q_i++){
if(isVideocmd(q_ev[q_i][1])){
	var v=js2array(q_ev[q_i][1]);
	this.myMediatrack[this.myMediatrack.length]=new Mediatrackitem(v[1],v[2],v[3],q_ev[q_i][0]);
}else if(startswith(q_ev[q_i][1],"eventlist_endmark(")){
	this.myTotalDuration=parseInt(q_ev[q_i][0]);
}//end if
}//next
}//end function

//private
PlayerWM.prototype.isIdentical=function Player_isIdentical(q_media){
return (this.getSrc().toLowerCase()==replace(q_media.mySrc.toLowerCase(),"file://",""));
}//end function

//end class




