<!--

// Updated 5 may 2010 17:11:30 CET
function isCanvasSupported(){
  var elem = document.createElement('canvas');
  return !!(elem.getContext && elem.getContext('2d'));
}
function myAudio() {

	// alert('does audio/ogg : ' + doesPlayOgg); // Firefox and Safari with ogg
	// alert('does audio/mpeg : ' + doesPlayMPEG);
	// alert('does audio/mp4 : ' + doesPlayMP4); // Safari
	// alert('does audio/aac : ' + doesPlayAAC); // Safari
	
	d=document.getElementById('button').title;
	if (d === 'stop') {

		document.all.playButton.innerHTML = '<img id="button" src="http://blagavest.bg/images/play.jpg" title="play" />' ;
		theAudio.src = '';
		theAudio.load();

		}

	else if (d === 'play') {

		document.all.playButton.innerHTML = '<img id="button" src="http://blagavest.bg/images/stop.jpg" title="stop" />' ;
		
		if ( ( doesPlayMP4 == 'maybe' ) | ( doesPlayMPEG == 'maybe' ) | ( doesPlayAAC == 'maybe' ) ) {

			// alert ('MP4/AAC will be used');
			audioHTML5 = 'http://blagavest.bg:8000/;';
			theAudio.src = audioHTML5;

			}

		else if ( ( doesPlayMP4 == 'probably' ) | ( doesPlayMPEG == 'probably' ) | ( doesPlayAAC == 'probably' ) ) {

			// alert ('AAC will be used');
			audioHTML5 = 'http://blagavest.bg:8000/;';
			theAudio.src = audioHTML5;

			}


		theAudio.load();
		theAudio.play();

		}


} // end myAudio

function initAudio() {

	// Global vars

	theButton = document.getElementById('playButton');
	theAudio = document.getElementById('myAudio');
	thePlayer = document.getElementById('radioPlayer'); // changed the name from theDIVPlayer to thePlayer

	// preferred audio types
	
	audioHTML5 = '';
	
	// End Global vars

	try {

		// The canPlayType function code forces MSIE and Flock to use Flash audio.
		if (isCanvasSupported()){
		doesPlayOgg = theAudio.canPlayType("audio/ogg"); // preferred audio type
		doesPlayMPEG = theAudio.canPlayType("audio/mpeg");
		doesPlayMP4 = theAudio.canPlayType("audio/mp4");
		doesPlayAAC = theAudio.canPlayType("audio/aac"); // preferred audio type
		
		if (( doesPlayMP4 == '' ) & ( doesPlayMPEG == '' ) & ( doesPlayAAC == '' ) ) {
			thePlayer.style.visibility = 'visible';
		}
		else if (doesPlayAAC == "probably") {

			// code to run in iPhone/iPad. We guess on load. No need to choose it later.

			theAudio.src = audioHTML5;
			theAudio.load();
			theAudio.style.visibility = 'visible';
			theButton.style.width = '12px'; // forces the controller to center

//			alert('Audio for iPhone and iPad is loaded when page loads');

			}

		else {

			theButton.style.visibility = 'visible';
			thePlayer.innerHTML = ""; // added to prevent Google Chrome displaying the Flash audio player.

			}
		}
		else {
			thePlayer.style.visibility = 'visible';
			}
		}

	catch(err) {
	
		// error routine when the canPlayType function fails.

		theButton.style.visibility = 'hidden';

		if ((thePlayer.style.visibility == 'visible') & (( doesPlayMP4 != '' ) | ( doesPlayMPEG != '' ) | ( doesPlayAAC != '' ))) {

			// alert('hide');
			thePlayer.style.visibility = 'hidden';

			}

		else {

			// alert('Your browser does not supprt html5 audio.\nA Flash audioplayer will be used.');

			thePlayer.style.visibility = 'visible';
			theContainer.style.height = '22px';

			}

		}

} // end init

// -->

