/*
 * wmp 11 functionality
 * http://msdn.microsoft.com/en-us/library/bb614509(VS.85).aspx
 */

	function addAudio() {
		dojo.byId("control").className = "html5start";

		var audioElement = new Audio(url + 'listen.pls');
		audioElement.id = 'antennePlayer';
		audioElement.setAttribute('autobuffer', 'autobuffer');
		//audioElement.setAttribute("autoplay", 'true');
		playing = false;
		document.body.appendChild(audioElement);
	}

	if (useHTML5) {
		//dojo.addOnLoad(addAudio);
		document.addEventListener("DOMContentLoaded", addAudio, false)
	}
	else if(-1 != ua.indexOf("MSIE") || -1 != ua.indexOf("Opera"))
	{
	  oldAutostart = autoStart == "true" ? 0 : 1

	  embedStr =  '<OBJECT id="Player" width='+w+' height='+h+''
     + ' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">'
     + ' <PARAM name="autoStart" value="'+autoStart+'">'
     + ' <PARAM name="URL" value="'+url+'">'
     +'</OBJECT>';

	  /*
	  embedStr += '<embed type="application/x-mplayer2" '
		 + ' pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" '
		 + ' name="Player" ShowStatusBar="false" EnableContextMenu="false" '
		 + ' enabled="1" showcontrols="0" displaySize="1" '
		 + ' autostart="'+oldAutostart+'" width="'+w+'" height="'+h+'" '
		 + ' src="'+url+'" url="'+url+'" '
		 + '/>';
		*/
		document.write(embedStr);
	}
	else if(-1 != ua.indexOf("Mozilla") )
	{
	  document.write('<OBJECT id="Player" width='+w+' height='+h+'');
	  document.write(' type="application/x-ms-wmp">');
	  document.write(' <PARAM name="autoStart" value="'+autoStart+'">');
	  document.write(' <PARAM name="URL" value="'+url+'">');
	  document.write(' </OBJECT>');
	}


/*
 * start it up
*/
function StartMeUp ()
{
	if ( useHTML5 ) {
		document.getElementById('antennePlayer').play();
		dojo.byId("control").className = "html5stop";
	} else {
		dojo.byId("Player").URL = url;
		dojo.byId("control").className = "stop";
	}
	playing = true;
}

function ShutMeDown ()
{
	if ( useHTML5 ) {
		document.getElementById('antennePlayer').pause();
		dojo.byId("control").className = "html5play";
	} else {
		dojo.byId("Player").controls.stop();
		dojo.byId("control").className = "play";
	}
	playing = false;
}

function VolumeUp()
{
	if ( useHTML5 ) {
		alert( document.getElementById('antennePlayer').volume );
		document.getElementById('antennePlayer').volume += 20;
	} else
		dojo.byId("Player").settings.volume += 20;
}

function VolumeDown()
{
	if ( useHTML5 ) {
		document.getElementById('antennePlayer').volume -= 20;
	} else
		dojo.byId("Player").settings.volume -= 20;
}

function StopAndGo()
{
  if (playing) {
    ShutMeDown();
  } else {
    StartMeUp();
  }
}