var user_agent = navigator.userAgent;
var isOpera = user_agent.indexOf("Opera") >= 0;
var isFirefox = user_agent.indexOf("Firefox") >= 0;
var isWin32up = user_agent.indexOf("Win32") >= 0 
	|| user_agent.indexOf("Win64") >= 0
	|| user_agent.indexOf("Windows NT") >= 0;

// disallow Opera faking IE
var isIE = !isOpera && user_agent.indexOf("MSIE") >= 0;
var isIE55up = isIE && isWin32up && user_agent.match(/MSIE ((5\.5)|[6789])/);
var isIE55dn = isIE && !isIE55up;
var browser = "other";

if (isFirefox)
	browser = "firefox";
else if (isOpera) 
	browser = "opera";
else if (isIE55up) 
	browser = "ie55p";
else if (isIE55dn) 
	browser = "ie55d";


id = 1;

function writeLivePlayer(stream_url, width, height, showTracker, showControls, showStatus) {
	var trackerVal = (showTracker != null && showTracker) ? "1" : "0";
	var controlsVal = (showControls == null || showControls) ? "1" : "0";
	var statusVal = (showStatus == null || showStatus) ? "1" : "0";
	
	var playerObj = 
	"<object id=\"TVVideoPlay\" width=\"" + width + "\" height=\"" + height + "\"" +
	"  classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\"" +
	"  codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\"" +
	"  standby=\"Loading Microsoft Windows Media Player components...\"" +
	"  type=\"application/x-oleobject\">" +
	"          <param name=\"FileName\" value=\"" + stream_url + "\" />" +
	"          <param name=\"AutoStart\" value=\"1\" />" +
	"          <param name=\"AutoSize\" value=\"0\" />" +
	"          <param name=\"Volume\" value=\"-200\" />" +
	"          <param name=\"ShowControls\" value=\"" + controlsVal + "\" />" +
	"          <param name=\"ShowDisplay\" value=\"0\" />" +
	"          <param name=\"ShowStatusBar\" value=\"" + statusVal + "\" />" +
	"          <param name=\"ShowGotoBar\" value=\"0\" />" +
	"          <param name=\"ShowTracker\" value=\"" + trackerVal + "\" />" +
	"          <param name=\"ShowPositionControls\" value=\"0\" />" +
	"          <param name=\"EnablePositionControls\" value=\"0\" />" +
	"          <param name=\"EnableContextMenu\" value=\"0\" />" +
	"          <embed type=\"application/x-mplayer2\" " +
	"  pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/download/default.asp\" " +
	"  src=\"" + stream_url + "\" " +
	"  filename=\"" + stream_url + "\" " +
	"  name=\"TVVideoPlay\" " +
	"  AutoStart=\"1\"" +
	"  AutoSize=\"0\"" +
	"  Volume=\"-200\"" +
	"  ShowControls=\"" + controlsVal + "\"" +
	"  ShowDisplay=\"0\"" +
	"  ShowStatusBar=\"" + statusVal + "\" " +
	"  ShowGotoBar=\"0\" " +
	"  ShowTracker=\"" + trackerVal + "\" " +
	"  ShowPositionControls=\"0\" " +
	"  EnablePositionControls=\"0\" " +
	"  EnableContextMenu=\"0\" " +
	"  width=\"" + width + "\" height=\"" + height + "\"></embed>" +
	"</object>";
	document.write(playerObj);
}

function writeOnDemandPlayer(stream_url, width, height) {
	if (isIE)	  
		writeLivePlayer(stream_url, width, height, false, false, false);
	else
		writeLivePlayer(stream_url, width, height + 50, true, true, false);
}

