// ------------------------------------------------------------------------------
// Library for playing Windows Media Player and Flash player inline a web browser
// Written by Quynh Nguyen - 25/9/2006
// Home page: http://quynhnguyen.chungta.com
//
// ------------------------------------------------------------------------------

// ------------------------------------------------------------------------------
// show Windows Media Player
function showWindowsMediaPlayer()
{
	var mediaUrl = arguments[0]||'';
	var width = arguments[1]||232;
	var height = arguments[2]||300;
	var playCount = arguments[3]||1;
	var uiMode = arguments[4]||"full";
	
	// test Windows Media Player 7
	var WMP7;
	try
	{
		if (navigator.appName != "Netscape")
			WMP7 = new ActiveXObject('WMPlayer.OCX');
	}
	catch (error)
	{
		;
	}
	
	// html code for showing Windows Media Player
	var html = '';

	// Windows Media Player 7 Code
	if (WMP7)
	{
		html +=  ('<OBJECT height="' +height + '" width="' +width + '" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" VIEWASTEXT>');
		html +=  ('<PARAM NAME="URL" VALUE="' + mediaUrl + '">');
		html +=  ('<PARAM NAME="rate" VALUE="1">');
		html +=  ('<PARAM NAME="balance" VALUE="0">');
		html +=  ('<PARAM NAME="currentPosition" VALUE="0">');
		html +=  ('<PARAM NAME="defaultFrame" VALUE="">');
		html +=  ('<PARAM NAME="playCount" VALUE="' + playCount + '">');
		html +=  ('<PARAM NAME="autoPlay" VALUE="0">');
		html +=  ('<PARAM NAME="transparentatStart" VALUE="false">');
		html +=  ('<PARAM NAME="showControls" VALUE="true">');
		html +=  ('<PARAM NAME="animationatStart" VALUE="true">');
		html +=  ('<PARAM NAME="currentMarker" VALUE="0">');
		html +=  ('<PARAM NAME="invokeURLs" VALUE="-1">');
		html +=  ('<PARAM NAME="baseURL" VALUE="">');
		html +=  ('<PARAM NAME="mute" VALUE="0">');
		html +=  ('<PARAM NAME="uiMode" VALUE="' + uiMode + '">');
		html +=  ('<PARAM NAME="stretchToFit" VALUE="1">');
		html +=  ('<PARAM NAME="windowlessVideo" VALUE="1">');
		html +=  ('<PARAM NAME="enabled" VALUE="-1">');
		html +=  ('<PARAM NAME="enableContextMenu" VALUE="1">');
		html +=  ('<PARAM NAME="fullScreen" VALUE="0">');
		html +=  ('<PARAM NAME="SAMIStyle" VALUE="">');
		html +=  ('<PARAM NAME="SAMILang" VALUE="">');
		html +=  ('<PARAM NAME="SAMIFilename" VALUE="">');
		html +=  ('<PARAM NAME="captioningID" VALUE="">');
		html +=  ('<PARAM NAME="Volume" VALUE="100">');
		html +=  ('</OBJECT>');
	}

	// Windows Media Player 6.4 Code
	else
	{
		height -= 18;
		html +=  ('<OBJECT  classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" ');
		html +=  ('codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" ');
		html +=  ('width="' +width + '" height="' + height + '"');
		html +=  ('standby="Loading Microsoft Windows Media Player components..." ');
		html +=  ('type="application/x-oleobject" VIEWASTEXT> ');
		html +=  ('<PARAM NAME="FileName" VALUE="' + mediaUrl + '">');
		html +=  ('<PARAM NAME="TransparentAtStart" VALUE="false">');
		html +=  ('<PARAM NAME="AutoStart" VALUE="true">');
		html +=  ('<PARAM NAME="AnimationatStart" VALUE="false">');
		html +=  ('<PARAM NAME="ShowControls" VALUE="false">');
		html +=  ('<PARAM NAME="ShowDisplay" VALUE="false">');
		html +=  ('<PARAM NAME="playCount" VALUE="' + playCount + '">');
		html +=  ('<PARAM NAME="displaySize" VALUE="0">');
		html +=  ('<PARAM NAME="Volume" VALUE="100">');
		html +=  ('<Embed type="application/x-mplayer2" ');
		html +=  ('pluginspage= ');
		html +=  ('"http://www.microsoft.com/Windows/MediaPlayer/" ');
		html +=  ('src="' + mediaUrl + '" ');
		html +=  ('Name=MediaPlayer ');
		html +=  ('transparentAtStart=0 ');
		html +=  ('autostart=1 ');
		html +=  ('playcount=' + playCount + ' ');
		html +=  ('volume=100');
		html +=  ('animationAtStart=0 ');
		html +=  ('width="' +width + '" height="' + height + '"');	
		html +=  ('displaySize=0></embed> ');
		html +=  ('</OBJECT> ');
	}	

	// show player	
	document.write(html);
	
}

// ------------------------------------------------------------------------------
// show Flash Player
function showFlashPlayer()
{
	var mediaUrl = arguments[0]||'';
	var width = arguments[1]||500;
	var height = arguments[2]||350;

	var html = '';
	html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ';
	html += 'width="' + width + '" height="' + height + '">';
	html += '<param name="movie" value="' + mediaUrl + '" />';
	html += '<param name="quality" value="high" />';
	html += '<PARAM NAME=wmode VALUE=transparent>';
	html += '<embed src="' + mediaUrl + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	html += 'type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed></object>';

	// show player	
	document.write(html);

}