

function DisplayStatus(p_iObjectId) {

	// attributes
	this.m_iObjectId = p_iObjectId;

	// methods
	this.refresh = refreshDisplayStatus;
}



function PositionSlider(p_iObjectId) {

	// attributes
	this.m_iObjectId = p_iObjectId;
	
	// methods
	this.refresh = refreshPositionSlider;

}

function refreshDisplayStatus(p_iStatus, p_iBuffering, p_iPosition, p_iTotalTime) {

	if (this.m_iObjectId == null)
		return;
		
	if (!movieIsLoaded(this.m_iObjectId))
		return;

	var sFeedBack = '';
	
	if (p_iStatus == connecting) {
		sFeedBack = "Connecting...";	
	}
	else if (p_iStatus == stopped) {
		sFeedBack = "Stopped";
	}
	else if (p_iStatus == buffering) {
		sFeedBack = "Buffering: " + p_iBuffering + "%";
	}
	
	if (sFeedBack != '')
		//this.m_iObjectId.SetVariable("text", sFeedBack);
		//this.m_iObjectId.SetVariable("text", "");
		return;
	if (p_iPosition>=0)
	{
		var oTime = new Date(p_iPosition);
			
		var t_hour = fixTime(p_iPosition/3600000).substring(0,2);//oTime.getHours();     // Returns hours
		var t_min = oTime.getMinutes();    // Returns minutes
		var t_sec = oTime.getSeconds();    

		var sTime = (t_hour != "00" ? t_hour + ":": "") + fixTime(t_min) + ":" + fixTime(t_sec);

		var sTotalTime = "";

		if (p_iTotalTime > 0 && p_iTotalTime < 3600000*7)
		{
		  var oTotalTime = new Date(p_iTotalTime);
			
		  t_hour = fixTime(p_iTotalTime/3600000).substring(0,2);//oTotalTime.getHours();     // Returns hours
		  t_min = oTotalTime.getMinutes();    // Returns minutes
		  t_sec = oTotalTime.getSeconds();    

		  sTotalTime =  (t_hour != "00" ? t_hour + ":": "")  + fixTime(t_min) + ":" + fixTime(t_sec);
		  sTotalTime = " / " + sTotalTime;
		}

		this.m_iObjectId.SetVariable("text", sTime + sTotalTime);

	}
	else
	        this.m_iObjectId.SetVariable("text", "00:00 / 00:00");
	
}

function refreshPositionSlider(p_iPosition, p_iTotalTime) {

	if (this.m_iObjectId == null)
		return;
		
	if (p_iPosition == -1)
	{
		this.m_iObjectId.SetVariable("enable", 0);
		return;
	}
	
	this.m_iObjectId.SetVariable("enable", 1);

	var iValue = p_iPosition*100/p_iTotalTime;
	if (iValue >0 )
		iValue = Math.round(iValue);

	this.m_iObjectId.SetVariable("xtoset", iValue);
}

function fixTime(the_time) {

	if (the_time <10) 
	{
		the_time = "0" + the_time;
	}
	return the_time;
}

function movieIsLoaded (theMovie) {
  // First make sure the movie's defined.
  if (typeof(theMovie) != "undefined") {
    // If it is, check how much of it is loaded.
    return theMovie.PercentLoaded() == 100 && theMovie.IsPlaying();
  } else {
    // If the movie isn't defined, it's not loaded.
    return false;
  }
}
