function getWMP()
{
  var r = getElem('MediaPlayer');
  //if(!r) r = getElem('eMediaPlayer');
  return r;
}

function MessageOpenStreamExt()
{
  var mp = getWMP();
  if (mp.PlayState != null) {mp.Stop();}
  alert('De stream wordt nu gestart in de standaard speler voor het geselecteerde formaat.\nLet op: als het fragment op dit moment speelt, moet u deze stoppen, om te voorkomen dat er twee streams tegelijkertijd spelen.');
}

function CheckPlayer()
{
  var player;
  try 
  {
    if(window.ActiveXObject)
    {
      player = new ActiveXObject("WMPlayer.OCX.7");
    }
    else if (window.GeckoActiveXObject)
    {
      player = new GeckoActiveXObject("WMPlayer.OCX.7");
    }
  }
  catch(e)
  {
    // Handle error -- no WMP 7 or 9 control
    // Can use WMP 6 also if necessary, but this is legacy software nowadays
  }
  return player;
}

function InsertWMP(sWidth, bAutoStart, sURL)
{
  if (CheckPlayer)
  {
    // Windows Media Player control exists and it is version 7 or 9
    // Can use WMP 7 or 9 API -- call versionInfo property, only in 7 and 9

    var WMP7;
    try
    {
      if ( navigator.appName != "Netscape" )
      {
        WMP7 = new ActiveXObject('WMPlayer.OCX');
      }
    }
    catch(e)
    {
      //...
    }
    
    // Windows Media Player 7 Code
    if ( WMP7 )
    {
	document.write('<object');
	document.write(' id="MediaPlayer" name="MediaPlayer"');
	document.write(' CLASSID="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"');
	//document.write(' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"');
	document.write(' standby="Bezig met het laden van Microsoft Windows® Media Player onderdelen..."');
	document.write(' type="application/x-oleobject" width="'+sWidth+'" height="69">');
	document.write(' <param name="url" value="'+sURL+'">');
	document.write(' <param name="fileName" value="'+sURL+'">');
	document.write(' <param name="autoStart" value="'+ (bAutoStart ? 'true' : 'false') +'">');
	document.write(' <param name="showControls" value="true">');
	document.write(' <param name="uiMode" value="full">');
      document.write(' <param name="AllowChangeDisplaySize" value="false">');
	document.write(' <param name="showStatusBar" value="true">');
	document.write(' <param name="animationatStart" value="false">');
	document.write(' <param name="transparentatStart" value="false">');
	document.write(' <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"');
	document.write('  src="'+sURL+'" name="MediaPlayer" id="MediaPlayer" width='+sWidth+' height=69');
	document.write('  autostart='+ (bAutoStart ? 'true' : 'false') +' showcontrols=1 uimode=full AllowChangeDisplaySize=0 showstatusbar=1 animationatstart=0 transparantatstart=0>');
	document.write(' </embed>');
	document.write('</object>');
    }
        
    // Windows Media Player 6.4 Code
    else
    {
	document.write('<object');
	document.write(' id="MediaPlayer" name="MediaPlayer"');
	document.write(' CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"');
      document.write(' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" ');
	document.write(' standby="Bezig met het laden van Microsoft Windows® Media Player onderdelen..."');
	document.write(' type="application/x-oleobject" width="'+sWidth+'" height="69">');
	//document.write(' <param name="url" value="'+sURL+'">');
	document.write(' <param name="FileName" value="'+sURL+'">');
	document.write(' <param name="AutoStart" value="'+ (bAutoStart ? 'true' : 'false') +'">');
	document.write(' <param name="ShowControls" value="true">');
	//document.write(' <param name="uiMode" value="full">');
      //document.write(' <param name="AllowChangeDisplaySize" value="false">');
	document.write(' <param name="ShowStatusBar" value="true">');
	//document.write(' <param name="animationatStart" value="false">');
	//document.write(' <param name="transparentatStart" value="false">');
	document.write(' <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"');
	document.write('  src="'+sURL+'" name="MediaPlayer" id="MediaPlayer" width='+sWidth+' height=69');
	document.write('  AutoStart='+ (bAutoStart ? 'true' : 'false') +' ShowControls=1 AllowChangeDisplaySize=0 ShowStatusBar=1>');
	document.write(' </embed>');
	document.write('</object>');
    }
  }
  else
  {
     document.write('<br>Uw computer beschikt niet over de benodigde programmatuur, of uw browser ondersteunt wellicht het afspelen van audiofragmenten binnen uw browser niet.<br><br><a href="http://www.microsoft.com/windowsmedia/" target="_blank">Klik hier</a> om de gratis Windows Mediaplayer te downloaden.<br><br>Heeft u de plug-in wel geinstalleerd? Klik dan op een van onderstaande buttons om het fragment de openen in een alternatieve speler.');
  }
}

function InsertWimpy(theWidth, bAutoStart, sURL)
{
	randNum = Math.floor(Math.random()*(100000));
	flashVersion = "6,0,47,0";

	myuid = new Date().getTime();
	flashProxy = new FlashProxy(myuid, 'static/JavaScriptFlashGateway.swf');
  
  tptBkgd_param = '<param name="wmode" value="transparent" />';
	tptBkgd_embed = 'wmode="transparent" ';
	tptHeight = 50;

	if(bAutoStart) {
  	theConfigFile = "static/wimpy_"+theWidth+"_autostart.xml"
	}	else {
  	theConfigFile = "static/wimpy_"+theWidth+".xml"
	}
	if(sURL)	{
		writePlaylist = "&wimpyApp="+sURL;
	}	else {
		writePlaylist = "";
	}

	queryString = "static/wimpy.swf"+'?x='+randNum+'&wimpyConfigs='+theConfigFile+writePlaylist;
	flashCode = '';
	flashCode += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flashVersion+'" width="'+theWidth+'" height="'+tptHeight+' name="wimpy'+randNum+'" id="wimpy'+randNum+'"">';
	flashCode += '<param name="movie" value="'+queryString+'" />';
	flashCode += '<param name="loop" value="false" />';
	flashCode += '<param name="menu" value="false" />';
	flashCode += '<param name="quality" value="high" />';
	flashCode += '<param name="scale" value="noscale" />';
	flashCode += '<param name="salign" value="lt" />';
	flashCode += '<param name="bgcolor" value="#000000" />';
	flashCode += '<param name="flashvars" value="lcId='+myuid+'"/>';
	flashCode += tptBkgd_param;
	flashCode += '<embed src="'+queryString+'" width="'+theWidth+'" height="'+tptHeight+'" bgcolor="#000000" flashvars="lcId='+myuid+'" loop="false" menu="false" quality="high" scale="noscale" salign="lt" name="wimpy'+randNum+'" id="wimpy'+randNum+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"" '+tptBkgd_embed+'/></object>';
	document.write(flashCode);
}

