
function PlayClick() 
{ 
    document.getElementById('MediaPlayer').Play();
    stop_pressed = 0;
} 

function StopClick() 
{ 
    stop_pressed = 1;
	document.getElementById('MediaPlayer').Stop(); 
    if (navigator.appName.indexOf('Netscape') != -1) { 
        document.getElementById('MediaPlayer').SetCurrentPosition(0); 
    } else { 
        document.getElementById('MediaPlayer').CurrentPosition = 0; 
    }
}

function PauseClick() 
{ 
   /* if (navigator.appName.indexOf('Netscape') != -1) { 
        estado=document.MediaPlayer.GetPlayState(); 
    } else { 
        estado=document.MediaPlayer.PlayState; 
    } 

    if (estado==1) { 
        document.MediaPlayer.Play(); 
    } else if (estado==2) 
    { */
        document.getElementById('MediaPlayer').Pause(); 
    //} 
} /*
function UpVolumeClick() 
{ 
    if (document.MediaPlayer.Volume <= -300) { 
        document.MediaPlayer.Volume = document.MediaPlayer.Volume + 300; 
    } 
} 
function DownVolumeClick() 
{ 
    if (document.MediaPlayer.Volume >= -8000) { 
        document.MediaPlayer.Volume = document.MediaPlayer.Volume - 300; 
    } 
} */
	stop_pressed = 0;
	
	play_interval = 0;
	
	controle = 1;

	function PlayPause() {
		if(navigator.appName != 'Microsoft Internet Explorer')
			return;
		
		if (document.getElementById('MediaPlayer').PlayState == 2){ // Em play
	    	document.getElementById('MediaPlayer').Pause();
		}
		else{ // Qq outro estado
			clearInterval(play_interval);
			play_interval = setInterval("ThingsToDoWhilePlaying();", 1000);
	    	document.getElementById('MediaPlayer').Play();
		}
	}
	function SetVolume(updown){
		if(updown == "+" && MediaPlayer.Volume <= -300)
			MediaPlayer.Volume = MediaPlayer.Volume+300;
		else if(updown == "-" && MediaPlayer.Volume >= -8000)
			MediaPlayer.Volume = MediaPlayer.Volume-300;
		SetImgVolume(MediaPlayer.Volume);
	}
	function SetImgVolume(vol){
		if (vol = 101) {
			vol = MediaPlayer.Volume;
		}
		//como o limite é -8300 até 0 o valor vai sempre dar negativo
		//e o result. da divisão dar -5 qdo tiver no mínimo (-8300) 
		//e 0 qdo estiver no máximo, por isso a soma com 5
		led = Math.floor(vol/1660) + 5; 
	}

	function SecondsToMinutes(val){
		minutes = 0; seconds = 0;
		while(val > 60){
			val = val - 60;
			minutes++;
		}
		seconds = Math.floor(val)+"";
		minutes = minutes+"";
		if(minutes.length < 2) minutes = "0"+minutes;
		if(seconds.length < 2) seconds = "0"+seconds;
		return minutes+":"+seconds;
	}

	function PrintData(val){
//		if(navigator.appName == "Microsoft Internet Explorer"){
//			//var dDiv = eval('statusbox');
//			obj = parent.mainFrame.document.getElementById('statusbox');
//			obj.innerHTML = val;
//		}
//		else
		{
			dDiv = document.getElementById('statusbox');
			dDiv.innerHTML = val;
		}
	}

	function ThingsToDoWhileBuffering() {
		PrintData("Carregando "+MediaPlayer.BufferingProgress+"%");
	}
	
	
	function ThingsToDoWhilePlaying(n) {
		if(document.getElementById('MediaPlayer').CurrentPosition > 0) {
			
			
			//alert(document.getElementById('tempbox'));
			//if(showing == 0) {
				PrintData("&nbsp; <i>" + document.getElementById('tempbox').innerHTML + "</i>");
			//}
			//showing = 1;
		} else {
			//showing = 0;
			if(stop_pressed != 1) { //caso esteja parado e o stop não tenha sido pressionado
				PlayPause();
			}
		}
		if(document.getElementById('MediaPlayer').PlayState == 0) {
			PrintData("Parado");
			clearInterval(play_interval);
		}
		else if(document.getElementById('MediaPlayer').PlayState == 1){
			if(controle == 1) {
				controle = 0;
				PrintData("Em pausa");
			}
			else {
				controle = 1;
				PrintData("");
			}
		}
	}
	
	play_interval = setInterval("ThingsToDoWhilePlaying();", 10000);

	function init() {
		//empty
	}

	function clearBuffInterval() {
		for(i=0; i<buff_interval.length; i++){
			clearInterval(buff_interval[i]);
		}
	}
	
	buff_interval = new Array();

