// © Antfarm IP Deliveries, 2007. All Rights Reserved - September 2007 //
// Metro FM

var WMPVer = "unknown";       // Set to WMP version string detected
var fHasWMP = false;          // True if either WMP v6.4 or v7+ found
var fHasWMP64 = false;        // True if WMP v6.4 found
var fHasWMP7 = false;         // True if WMP v7+ (8, 9) found
var fAppletRunning = false;   // True if v9 Applet is in use
var fPluginRunning = false;   // True if v6.4 Netscape plugin is in use
var streamurl = "http://www.antfarm.co.za/clients/metrofm/metrofm_22.asx";
//var playerwidth = <%=width %>;
//var playerheight = <%=height %>;

//alert("For reasons of broadcasting rights, please note that this radio stream will not be accessible outside of South Africa this evening between 18h30 and 21h00 (4 Dec 2009). If the IP Address of your browsing session is known to originate from an international location, this radio stream will not be accessible to you over this period."); 


function GetBrowser()
{
   var agt=navigator.userAgent.toLowerCase();
   if( ((agt.indexOf("msie") != -1) && (agt.indexOf("pera") == -1)) )
       return "IE";
   else if( ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
         && (agt.indexOf('compatible') == -1) && (agt.indexOf('pera')==-1)
         && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)) )
       return "Netscape";
   else if (agt.indexOf("pera") > 0)
		return "opera";
   else
       return "unknown";
}

function GetPlayerMajorVer()
{
	var strVer = new String(WMPVer);
	var s = strVer.split(".");
    return s[0];
}


function GetPlayerMinorVer()
{
	var strVer = new String(WMPVer);
	var s = strVer.split(".");
	if (s[1])
		return s[1];
	else
		return("unknown");
}

function IsNSPluginInstalled()
{
    // See if 6.4 pluggin installed
    if (navigator.mimeTypes && navigator.mimeTypes["application/x-mplayer2"] && navigator.mimeTypes["application/x-mplayer2"].enabledPlugin)
		return(true);
	else
		return(false);
}

function OnDSScriptCommandEvt(command, param)
{  // default command code goes here...
  // leave blank to just use the javascript functions
}

function CheckForApplet()
{
    navigator.plugins.refresh();  // Refresh pluggins/applets
    
	// If java runtime not enabled, give error message box
    if (!navigator.javaEnabled())
        alert("Java is not enabled.  Windows Media Player applet for Netscape requires a Java runtime.");

    // If applet not loaded redirect to download page
	if ( !( document // document available
	        && document['MediaPlayer'] // applet available in js
	        && document['MediaPlayer'].isActive  // applet active
	       )
	   )
;
//		AddDownloadLink("unknown");
//	    window.location="wmp9download.htm";	    	    
}

function AddDownloadLink(MajorVer)
{
 if (!(MajorVer) || MajorVer=="unknown" || MajorVer<9)
  { 
   document.write('<tr><td>You do not have a suitable Windows Media Player version or Plugin.<BR><A HREF="http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx"><IMG SRC="http://www.microsoft.com/windows/windowsmedia/images/Download_88x31_static.gif" WIDTH="88" HEIGHT="31" BORDER="0" ALT="Get Windows Media Player" VSPACE="7"></A></td></tr>');
  } 
}



document.writeln("	<OBJECT classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95  codebase=\"../../#Version=6,4,5,715\" height=1 id=WMP64 width=1 VIEWASTEXT></OBJECT>");
document.writeln("	<OBJECT classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6  codebase=\"../../#Version=7,0,0,1954\" height=1 id=WMP7 width=1 VIEWASTEXT></OBJECT>");



	var br = GetBrowser();        

if  (br=="IE"){
      document.write(
         ' <scr' + 'ipt language=VBScript>' + '\n' +
         ' On error resume next' + '\n' +
         ' fHasWMP64 = (WMP64.FileName="")'  + '\n' +
         ' fHasWMP7 = (WMP7.URL = "")' + '\n' +
         '<\/sc' + 'ript>'
      );
				}
	  
	fHasWMP=true;
	if( fHasWMP7 ) WMPVer=WMP7.versionInfo; 
	else if( fHasWMP64 ) WMPVer="6.4";
	else {
	   WMPVer="unknown";
	   fHasWMP=false;
	}   

	var pm = GetPlayerMajorVer(); 
	var pn = GetPlayerMinorVer(); 

if (pm=="unknown" && br=="Netscape" && parseInt(navigator.appVersion)<5 && IsNSPluginInstalled())  
	   {
document.writeln("<object id=\"AnRadioPlayer\" width=" + playerwidth + "  height=" + playerheight + " classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" standby=\"Loading Microsoft Media Player components...\" type=\"application/x-oleobject\">");
document.writeln("<param name=\"Filename\" value=\""+streamurl+"\">");
document.writeln("<param name=\"AutoStart\" value=\"True\">");
document.writeln("<param name=\"ShowControls\" value=\"True\">");
document.writeln("<param name=\"ShowStatusBar\" value=\"False\">");
document.writeln("<param name=\"ShowAudioControls\" value=\"True\">");
document.writeln("<param name=\"ShowDisplay\" value=\"False\">");
document.writeln("<param name=\"AutoRewind\" value=\"True\">");
document.writeln("<embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/\"  width=\"" + playerwidth + "\" height=\"" + playerheight + "\" src=\"" +streamurl + "\" autostart=\"True\" showcontrols=\"True\" showstatusbar=\"True\" showdisplay=\"False\" autorewind=\"True\" ShowTracker=\"False\" EnableTracker=\False\" ShowPositionControls=\"False\" ShowAudioControls=\"True\" EnablePositionControls=\"False\" name=\"AntRadioPlayer\">");
document.writeln("</object>");
	   }	
// Mac OS
	else if(navigator.userAgent.toLowerCase().indexOf("mac") != -1)
{
document.writeln("<object id=\"AnRadioPlayer\" width=" + playerwidth + "  height=" + playerheight + " classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" standby=\"Loading Microsoft Media Player components...\" type=\"application/x-oleobject\">");
document.writeln("<param name=\"Filename\" value=\"asx.asp?parser=<%=ThePage%>\">");
document.writeln("<param name=\"AutoStart\" value=\"True\">");
document.writeln("<param name=\"ShowControls\" value=\"True\">");
document.writeln("<param name=\"ShowStatusBar\" value=\"False\">");
document.writeln("<param name=\"ShowDisplay\" value=\"False\">");
document.writeln("<param name=\"AutoRewind\" value=\"True\">");
document.writeln("<embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/\"  width=\"" + playerwidth + "\" height=\"" + playerheight + "\" src=\"" +streamurl + "\" autostart=\"True\" showcontrols=\"True\" showstatusbar=\"True\" showdisplay=\"False\" autorewind=\"True\" ShowTracker=\"False\" EnableTracker=\False\" ShowPositionControls=\"False\" ShowAudioControls=\"True\" EnablePositionControls=\"False\" name=\"AntRadioPlayer\">");
document.writeln("</embed>");
}
	else if (br=="opera"){

navigator.plugins.refresh();  // Refresh pluggins/applets
document.writeln("	<Embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer//\" src=\"" + streamurl + "\"");
document.writeln("Name=\"AntRadioPlayer\"");
document.writeln("AutoStart=1");
document.writeln("ShowStatusBar=1");
document.writeln("ShowControls=1");
document.writeln("ShowTracker=0");
document.writeln("EnableTracker=0");
document.writeln("ShowPositionControls=0");
document.writeln("EnablePositionControls=0");
document.writeln("width=" + playerwidth);
document.writeln("height=" + playerheight + ">");
document.writeln("</embed>");
}	
	else if(window.GeckoActiveXObject)
{

document.writeln("<object id=\"AnRadioPlayer\" width=" + playerwidth + "  height=" + playerheight + " classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" standby=\"Loading Microsoft Media Player components...\" type=\"application/x-oleobject\">");
document.writeln("<param name=\"Filename\" value=\"" + streamurl + "\">");
document.writeln("<param name=\"AutoStart\" value=\"True\">");
document.writeln("<param name=\"ShowPositionControls\" value=\"False\">");
document.writeln("<param name=\"EnablePositionControls\" value=\"False\">");
document.writeln("<param name=\"ShowTracker\" value=\"False\">");
document.writeln("<param name=\"EnableTracker\" value=\"False\">");
document.writeln("<param name=\"ShowControls\" value=\"False\">");
document.writeln("<param name=\"ShowStatusBar\" value=\"True\">");
document.writeln("<param name=\"ShowDisplay\" value=\"True\">");
document.writeln("<param name=\"ShowAudioControls\" value=\"True\">");

document.writeln("<embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/\"  width=\"" + playerwidth + "\" height=\"" + playerheight + "\" src=\"" +streamurl + "\" autostart=\"True\" showcontrols=\"-1\" showstatusbar=\"-1\" showdisplay=\"0\" autorewind=\"True\" ShowTracker=\"0\" EnableTracker=\0\" ShowPositionControls=\"0\" ShowAudioControls=\"-1\" EnablePositionControls=\"0\"  id=\"AntRadioPlayer\" Volume=\"100\" name=\"AntRadioPlayer\">");
document.writeln("</embed>");
document.writeln("</object>");


document.writeln("<script language=javascript>");
document.writeln("var Netscrap = document.getElementById(\"AntRadioPlayer\");");
//document.writeln("var NetApp = document.getElementById(\"appObs\");");
//document.writeln(" NetApp.setByProxyDSScriptCommandObserver(Netscrap, true);");
document.writeln("</script>");
//Netscrap.open(streamurl);

}
//	else if (br=="Netscape")
	else if (br=="Netscape")
	   {
document.writeln("<object id=\"AnRadioPlayer\" width=" + playerwidth + "  height=" + playerheight + " classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" standby=\"Loading Microsoft Media Player components...\" type=\"application/x-oleobject\">");
document.writeln("<param name=\"Filename\" value=\"" + streamurl + "\">");
document.writeln("<param name=\"AutoStart\" value=\"True\">");
document.writeln("<param name=\"ShowPositionControls\" value=\"False\">");
document.writeln("<param name=\"EnablePositionControls\" value=\"False\">");
document.writeln("<param name=\"ShowTracker\" value=\"False\">");
document.writeln("<param name=\"EnableTracker\" value=\"False\">");
document.writeln("<param name=\"ShowControls\" value=\"False\">");
document.writeln("<param name=\"ShowStatusBar\" value=\"True\">");
document.writeln("<param name=\"ShowDisplay\" value=\"True\">");
document.writeln("<param name=\"ShowAudioControls\" value=\"True\">");

document.writeln("<embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/\"  width=\"" + playerwidth + "\" height=\"" + playerheight + "\" src=\"" +streamurl + "\" autostart=\"True\" showcontrols=\"-1\" showstatusbar=\"-1\" showdisplay=\"0\" autorewind=\"True\" ShowTracker=\"0\" EnableTracker=\0\" ShowPositionControls=\"0\" ShowAudioControls=\"-1\" EnablePositionControls=\"0\"  id=\"AntRadioPlayer\" Volume=\"100\" name=\"AntRadioPlayer\">");
document.writeln("</embed>");
document.writeln("</object>");


document.writeln("<script language=javascript>");
document.writeln("var Netscrap = document.getElementById(\"AntRadioPlayer\");");
//document.writeln("var NetApp = document.getElementById(\"appObs\");");
//document.writeln(" NetApp.setByProxyDSScriptCommandObserver(Netscrap, true);");
document.writeln("</script>");
//Netscrap.open(streamurl);

	   }	
	else if (br=="IE" && pm>=7)
	   {
document.writeln("<OBJECT CLASSID=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\" HEIGHT=\"" + playerheight + "\" ID=\"AntRadioPlayer\" WIDTH=\"" + playerwidth + "\">");
document.writeln("<PARAM NAME=\"AutoSize\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"AutoStart\" VALUE=\"1\">");
document.writeln("    <PARAM NAME=\"Balance\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"BufferingTime\" VALUE=\"05\">");
document.writeln("    <PARAM NAME=\"ClickToPlay\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"DisplayMode\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"DisplaySize\" VALUE=\"5\">");
document.writeln("    <PARAM NAME=\"Enabled\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"EnableContextMenu\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"InvokeURLs\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"PreviewMode\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"Rate\" VALUE=\"1\">");
document.writeln("	  <param name=\"uiMode\" value=\"mini\">");
document.writeln("    <PARAM NAME=\"TransparentAtStart\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"enableErrorDialogs\" VALUE=\"1\">");
document.writeln("    <PARAM NAME=\"Volume\" VALUE=\"80\">");
document.writeln("    <PARAM NAME=\"WindowlessVideo\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"url\" VALUE=\"" + streamurl + "\">");
document.writeln("  </OBJECT>");
  
	   }	
	else if (br=="IE" && pm==6 && pn==4)
	   {


document.writeln("    <OBJECT ID=\"AntRadioPlayer\" width=" + playerwidth + " height=" + playerheight + " CLASSID=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,5,0803\"  standby=\"Loading Windows Media Player components...\"  type=\"application/x-oleobject\">");
document.writeln("    	<PARAM NAME=\"FileName\" VALUE=\"" + streamurl + "\">");
document.writeln("    	<PARAM NAME=\"AutoStart\" VALUE=\"1\">");
document.writeln("    	<PARAM NAME=\"AutoSize\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"AnimationAtStart\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"AllowScan\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"AllowChangeDisplaySize\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"AutoRewind\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"Balance\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"BufferingTime\" VALUE=\"05\">");
document.writeln("    <PARAM NAME=\"ClickToPlay\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"CursorType\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"CurrentPosition\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"CurrentMarker\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"DisplayBackColor\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"DisplayForeColor\" VALUE=\"16776015\">");
document.writeln("    <PARAM NAME=\"DisplayMode\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"DisplaySize\" VALUE=\"5\">");
document.writeln("    <PARAM NAME=\"Enabled\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"EnableContextMenu\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"EnablePositionControls\" VALUE=\"false\">");
document.writeln("    <PARAM NAME=\"EnableFullScreenControls\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"EnableTracker\" VALUE=\"false\">");
document.writeln("    <PARAM NAME=\"InvokeURLs\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"Language\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"Mute\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"PlayCount\" VALUE=\"1\">");
document.writeln("    <PARAM NAME=\"PreviewMode\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"Rate\" VALUE=\"1\">");
document.writeln("    <PARAM NAME=\"SelectionStart\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"SelectionEnd\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"SendOpenStateChangeEvents\" VALUE=\"true\">");
document.writeln("    <PARAM NAME=\"SendWarningEvents\" VALUE=\"true\">");
document.writeln("    <PARAM NAME=\"SendErrorEvents\" VALUE=\"true\">");
document.writeln("    <PARAM NAME=\"SendKeyboardEvents\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"SendMouseClickEvents\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"SendMouseMoveEvents\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"SendPlayStateChangeEvents\" VALUE=\"true\">");
document.writeln("    <PARAM NAME=\"ShowCaptioning\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"ShowControls\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"ShowAudioControls\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"ShowDisplay\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"ShowGotoBar\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"ShowPositionControls\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"ShowStatusBar\" VALUE=\"1\">");
document.writeln("    <PARAM NAME=\"ShowTracker\" VALUE=\"-1\">");
document.writeln("    <PARAM NAME=\"TransparentAtStart\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"VideoBorderWidth\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"VideoBorderColor\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"VideoBorder3D\" VALUE=\"0\">");
document.writeln("    <PARAM NAME=\"Volume\" VALUE=\"80\">");
document.writeln("    <PARAM NAME=\"WindowlessVideo\" VALUE=\"0\">");
document.writeln("      </OBJECT>");

	   }	   
// final check to see if MediaPLayer may exist while activeX disabled:
else if (window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1){
	
	alert("Please check your browser security permissions to allow or at least prompt for use of ActiveX components!!");
	document.writeln("<span style=\"background:url(http://www.antfarm.co.za/images/antplayerback.gif);font-size:10pt;color:black;padding-top:1px;font-family:Arial;height:" + playerheight + ";width:" + playerwidth + ";\"><img src=\"http://www.antfarm.co.za/images/securityWarningIcon.gif\" border=0 align=left valign=top><img src=\"http://www.antfarm.co.za/images/ant_player-droopy.gif\" border=0 align=left valign=top>Your browser security settings don't allow the ActiveX Control!</span>");
	
	}

else {
	window.self.location="http://www.antfarm.co.za/needplayer.asp"; 
	}
