var isIeMac = navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Win")==-1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

					//////////////////   Player object  //////////////////////////
function Player_qt(p_PlayerId, p_sName, p_bAutoPlay, p_iPosition) {
    
     // specfic methods
     this.play = play_qt;
     this.playPause = playPause_qt;
     this.pause = pause_qt;
     this.stop = stop_qt;
     this.goToPosition = goto_qt;
     this.fullScreen = fullScreen_qt;
     this.checkEvents = checkEvents_qt;
     this.getCurrentMediaName = getCurrentMediaName_qt;
 	 this.setMediaLoop = setMediaLoop_qt;  
 	   
     this.startPlayTimer = startPlayTimer_qt;
     
     this.init_gen = init_gen;
     
     //specific attributes
     this.m_iPlayTimerId = null;
     
     // general init
     this.init_gen(p_PlayerId, p_sName, p_bAutoPlay, p_iPosition);
}
					//////////////////   Play Method (QuickTime)    //////////////////////////

function play_qt(p_sFilename) {
  if (!isIeMac) {
	if (p_sFilename!= null)
	{
		this.m_sMediaFile = p_sFilename;
	}

	if (this.m_iPlayTimerId != null) {
		clearTimeout(this.m_iPlayTimerId );
		this.m_iPlayTimerId = null;
	}
	    		
    var sStatus = this.m_PlayerId.GetPluginStatus();
    
    // SetURL method is not used for the moment since it crashes IE (the URL is placed in SRC param of embed object)
/*	  
	if (this.m_sWaitingPlayFile!= '' && (sStatus == "Waiting" || sStatus == "Loading" || sStatus == "Complete" || sStatus == "Playable"))
	{	
		alert(this.m_sWaitingPlayFile);
		this.m_PlayerId.SetURL(this.m_sWaitingPlayFile);
		this.m_sWaitingPlayFile= '';
		//this.StartPlayTimer(); // to play stream
	 return;
	}
*/ 
	 
	//if (sStatus == "Complete" || sStatus == "Playable")
	//{
	//	if (this.m_iStatus != playing && this.m_sMediaFile!='') {
			this.m_PlayerId.play();
			this.play_gen(p_sFilename);
	//	}		
	//}
	//else	
	//	this.startPlayTimer();
	}
}

function startPlayTimer_qt() {
  if (!isIeMac) {
	this.m_iPlayTimerId = IEX ? window.setTimeout(this.m_sName + '.play()',1000) : window.setTimeout(this.m_sName + ".play()",1000);
	}
}
					//////////////////   PlayPause Method (QuickTime)    //////////////////////////


function playPause_qt() {
  if (!isIeMac) {
	this.playPause_gen();
	}
}

					//////////////////   Pause Method (QuickTime)    //////////////////////////
					
function pause_qt() {
  if (!isIeMac) {
	this.m_PlayerId.Step(0);
	this.pause_gen();
	}
}


					//////////////////   Stop Method (QuickTime)    //////////////////////////
				
function stop_qt() {
  if (!isIeMac) {
	if (this.m_iStatus != stopped)
	{
		this.m_PlayerId.Stop(); 
		this.m_PlayerId.SetTime(0);
		this.stop_gen();
	}
	}
}

					//////////////////   Goto Method (QuickTime)    //////////////////////////
					
function goto_qt(p_iPosition) {
  if (!isIeMac) {
	var iTimeScale = this.m_PlayerId.GetTimeScale();
	iTimeScale == 0 ? 1 : iTimeScale;
    this.m_PlayerId.SetTime(p_iPosition/1000*iTimeScale);
    this.goto_gen(p_iPosition);
    }
}

					//////////////////   CheckEvents Method (QuickTime)    //////////////////////////

function checkEvents_qt() {
     if (!isIeMac) {
 	// Position event
	var iTimeScale = this.m_PlayerId.GetTimeScale();

	iTimeScale == 0 ? 1 : iTimeScale;
	var currentposition =  this.m_PlayerId.GetTime()*1000;
	currentposition = currentposition/iTimeScale;
	
	this.m_iTotalTime = this.m_PlayerId.GetDuration()*1000;
	this.m_iTotalTime = this.m_iTotalTime/iTimeScale;
	   
	 this.checkEvents_gen(this.m_iStatus, currentposition); // to complete
	 }
}
					//////////////////   FullScreen Method (QuickTime)    //////////////////////////

function fullScreen_qt(p_bDoIt)
{
	
}

function getCurrentMediaName_qt()
{
	
}

function setMediaLoop_qt()
{
	this.m_PlayerId.SetLoop();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

