// JavaScript Document

function mediaplayer(strFname, nWidth, nHeight, strBkg , strDivId) {
	// strFname must include the relative path to the asx file.
	// strBkg must include the relative path to the background image.
	// strDivId must be the div ID of the enclosing div tag 

	var str;

	str  = '<a style="position:relative; top:0; left:0; display:block; ';
	str += '	width: ' + nWidth + 'px; height: ' + nHeight + 'px; ';
	str += '	background: url(' + strBkg + ') no-repeat center center;" ';
	str += '	href="javascript:void(0);" ';
	str += '	onclick="javascript:document.getElementById(\'' + strDivId + '\').innerHTML=\'';
	str += escapeChars(mediaEmbedCode(strFname, nWidth, nHeight));
	str += '\';return false;"></a>'

	document.writeln(str);
}

function mediaEmbedCode(strFname, nWidth, nHeight) {
	// strFname must include the relative path to the asx file.

	var str;
	var WMP7;

	if ( navigator.appName != "Netscape" ){
     WMP7 = new ActiveXObject('WMPlayer.OCX');
	}

	if ( WMP7 ){	
	// Windows Media Player 7 Code
		//IE Code
		str  = '<OBJECT ID=MediaPlayer ';
		str += '        CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 ';
		//str += '        standby="Loading Microsoft Windows Media Player components..." ';
		str += '        TYPE="application/x-oleobject" width="' + nWidth + '" ';
		str += 'height="' + nHeight + '"> ';
		str += '    <PARAM NAME="url" VALUE="' + strFname + '"> ';
		str += '    <PARAM NAME="AutoStart" VALUE="False"> ';
		str += '    <PARAM NAME="uiMode" VALUE="mini"> ';
		//Netscape code		
		str += '    <Embed type="application/x-mplayer2" ';
		str += '        pluginspage="http://www.microsoft.com/windows/windowsmedia/" ';
		str += '        filename="' + strFname + '" ';
		str += '        src="' + strFname + '" ';
		str += '        Name=MediaPlayer ';
		str += '        EnableTracker=1 ';
		str += '        ShowTracker=1 ';
		str += '        ShowDisplay=0 ';
		str += '        AutoStart=1 ';
		str += '        width=' + nWidth + '';
		str += '        height=' + nHeight + '> ';
		str += '    </embed> ';
		str += '</OBJECT>';

	} else {
	// Windows Media Player 6.4 Code

	 //IE Code
		str  = '<OBJECT ID=MediaPlayer ';
		str += '        CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 ';
		str += '        CODEBASE=http://activex.microsoft.com/activex/ ';
		str += 'controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ';
		// str += '        standby="Loading Microsoft Windows Media Player components..." ';
		str += '	      TYPE="application/x-oleobject" width="' + nWidth + '" ';
		str += 'height="' + nHeight + '">';
		str += '    <PARAM NAME="FileName" VALUE="' + strFname + '"> ';
		str += '    <PARAM NAME="AutoStart" VALUE="False"> ';
		str += '    <PARAM NAME="EnableTracker" VALUE="1"> ';
		str += '    <PARAM NAME="ShowTracker" VALUE="0"> ';
		str += '    <PARAM NAME="ShowDisplay" VALUE="0"> ';
	 //Netscape code
		str += '	 <Embed type="application/x-mplayer2" ';
		str += '				pluginspage="http://www.microsoft.com/windows/windowsmedia/" ';
		str += '            filename="' + strFname + '" ';
		str += '				src="' + strFname + '" ';
		str += '           	Name=MediaPlayer ';
		str += '           	EnableTracker=1 ';
		str += '           	ShowTracker=1 ';
		str += '           	ShowDisplay=0 ';
		str += '           	AutoStart=1 ';
		str += '           	width=' + nWidth +'';
		str += '           	height=' + nHeight + '> ';
		str += '    </embed> ';

		str += '</OBJECT> ';
	}

	return str;
}

function escapeChars(inStr) {

	var outStr;

	outStr = inStr;

	outStr = outStr.replace(/>/g,"/>");

	outStr = outStr.replace(/\"/g,"&quot;");

	return outStr;
}

