// barra play 
function BarraPlay(){
	var controle = document.getElementById('controletvi');
	controle.innerHTML ='<span><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td background="images/player/espaco-2.jpg"><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td width="7%"><a href="javascript:void(0)" onclick="BarraStop()"><img src="images/player/bt_stop.jpg" width="35" height="30" border="0" alt="Clique aqui para assistir" /></a></td>'
			+'<td width="76%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="TVi_SemSom();return false;"><img src="images/player/bt_som.jpg" width="24" height="30" border="0" alt="Clique aqui para diminuir o som" /></a></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="destacaPlayer()"><img src="images/player/bot_popup.jpg" width="27" height="30" border="0" alt="Clique aqui para assistir em uma janela popup" /></a></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="Tela_Cheia();return false;"><img src="images/player/bt_maximizar.jpg" width="24" height="30" border="0" alt="Clique aqui para assistir em tela cheia" /></a></td>'
			+'</tr>'
			+'</table></td>'
			+'</tr>'
			+'</table></span>';
			WM.controls.play();
		//AbreTV();
}

// barra stop
function BarraStop(){
	var controle = document.getElementById('controletvi');
	var WM = document.getElementById('WM');
	//alert('stop');
	controle.innerHTML ='<span><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td background="images/player/espaco-2.jpg"><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td width="7%"><a href="javascript:void(0)" onclick="BarraPlay()"><img src="images/player/bt_player.jpg" width="35" height="30" border="0" alt="Clique aqui para assistir" /></a></td>'
			+'<td width="76%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="TVi_SemSom();return false;"><img src="images/player/bt_som.jpg" width="24" height="30" border="0" alt="Clique aqui para diminuir o som" /></a></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="destacaPlayer()"><img src="images/player/bot_popup.jpg" width="27" height="30" border="0" alt="Clique aqui para assistir em uma janela popup" /></a></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="Tela_Cheia();return false;"><img src="images/player/bt_maximizar.jpg" width="24" height="30" border="0" alt="Clique aqui para assistir em tela cheia" /></a></td>'
			+'</tr>'
			+'</table></td>'
			+'</tr>'
			+'</table></span>';
		WM.controls.stop();
}



/// FUNCAO PARA ABRIR A TV
function AbreTV(){
	document.getElementById('televisao').innerHTML = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=7,4,5,715" id="WM" height="356" width="475">'
		+ '<param name="URL" value="rtsp://server3.impactro.net/LgImagesLive" />'
		+ '<param name="uiMode" value="none" />'
		+ '<param name="stretchToFit" value="-1" />'
        + '<param name="rate" value="1">'
        + '<param name="balance" value="0">'
		+ '<param name="currentPosition" value="0">'
		+ '<param name="defaultFrame" value>'
        + '<param name="playCount" value="1">'
		+ '<param name="autoStart" value="1">'
		+ '<param name="currentMarker" value="0">'
		+ '<param name="invokeURLs" value="-1">'
		+ '<param name="baseURL" value>'
		+ '<param name="volume" value="50">'
		+ '<param name="mute" value="0">'
		+ '<param name="windowlessVideo" value="0">'
		+ '<param name="enabled" value="-1">'
		+ '<param name="enableContextMenu" value="-1">'
		+ '<param name="fullScreen" value="0">'
		+ '<param name="SAMIStyle" value>'
		+ '<param name="SAMILang" value>'
		+ '<param name="SAMIFilename" value>'
		+ '<param name="captioningID" value>'
		+ '<param name="enableErrorDialogs" value="0">'
		+ '<param name="_cx" value="11748">'
		+ '<param name="_cy" value="8890">'
		+ '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx/" filename="rtsp://server3.impactro.net/LgImagesLive" showcontrols="0" showdisplay="0" showstatusbar="0" width="444" height="336"></embed>'
		+ '</object>';
		WM.controls.play();
}

// tela full
function Tela_Cheia(){
	var TVi = document.getElementById('WM');
	var st = TVi.PlayState;
		if (st != 6 || st == 3) {
			TVi.fullscreen=true;
		}
	
}

// remover som
function TVi_SemSom(){
	var TVi = document.getElementById('WM');
	var st = TVi.PlayState;
		if (st != 6 || st == 3) {
			if (TVi.Settings.mute==true){
				TVi.Settings.mute = false;				
			} else {
				TVi.Settings.mute = true;				
			}
		}
}

//destaca player - popup
function destacaPlayer() {
	width = 480;
	height = 432;
	leftVal = (screen.width - width) / 2;
	topVal = (screen.height - height) / 3.5;
	window.open('/Player_Tvi.html','video_pop_','width=' + width + ',height=' + height + ',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,top=' + topVal + ',left=' + leftVal);
	//WM.controls.stop();
	return false;
}

///////////////






function BarraPlayStop(vOpcao){
	var controle = document.getElementById('controletv');
		controle.innerHTML ='<span><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td background="images/player/espaco-2.jpg"><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td width="7%"><a href="javascript:void(0)" onclick="BarraPlay()"><img src="images/player/bt_stop.jpg" width="35" height="30" border="0" alt="Clique aqui para assistir" /></a></td>'
			+'<td width="76%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="TVi_SemSom();return false;"><img src="images/player/bt_som.jpg" width="24" height="30" border="0" alt="Clique aqui para diminuir o som" /></a></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="destacaPlayer()"><img src="images/player/bot_popup.jpg" width="27" height="30" border="0" alt="Clique aqui para assistir em uma janela popup" /></a></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="Tela_Cheia();return false;"><img src="images/player/bt_maximizar.jpg" width="24" height="30" border="0" alt="Clique aqui para assistir em tela cheia" /></a></td>'
			+'</tr>'
			+'</table></td>'
			+'</tr>'
			+'</table></span>';
	

}

function TVi_ComSom(){
	var TVi = document.getElementById('WM');
	var st = TVi.PlayState;
		if (st != 6 || st == 3) {
			TVi.Settings.mute = false;
		}
}

/// popup
// barra play 
function BarraPlayPopup(){
	var controle = document.getElementById('controletvi');
	controle.innerHTML ='<span><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td background="images/player/espaco-2.jpg"><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td width="7%"><a href="javascript:void(0)" onclick="BarraStopPopup()"><img src="images/player/bt_stop.jpg" width="35" height="30" border="0" alt="Clique aqui para assistir" /></a></td>'
			+'<td width="76%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="TVi_SemSom();return false;"><img src="images/player/bt_som.jpg" width="24" height="30" border="0" alt="Clique aqui para diminuir o som" /></a></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><img src="images/player/bot_popup.jpg" width="27" height="30" border="0" /></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="Tela_Cheia();return false;"><img src="images/player/bt_maximizar.jpg" width="24" height="30" border="0" alt="Clique aqui para assistir em tela cheia" /></a></td>'
			+'</tr>'
			+'</table></td>'
			+'</tr>'
			+'</table></span>';
			WM.controls.play();
		//AbreTV();
}

// barra stop
function BarraStopPopup(){
	var controle = document.getElementById('controletvi');
	controle.innerHTML ='<span><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td background="images/player/espaco-2.jpg"><table width="100%" border="0" cellspacing="0">'
			+'<tr>'
			+'<td width="7%"><a href="javascript:void(0)" onclick="BarraPlayPopup()"><img src="images/player/bt_player.jpg" width="35" height="30" border="0" alt="Clique aqui para assistir" /></a></td>'
			+'<td width="76%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="TVi_SemSom();return false;"><img src="images/player/bt_som.jpg" width="24" height="30" border="0" alt="Clique aqui para diminuir o som" /></a></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><img src="images/player/bot_popup.jpg" width="27" height="30" border="0"></td>'
			+'<td width="1%">&nbsp;</td>'
			+'<td width="5%"><a href="javascript:void(0)" onclick="Tela_Cheia();return false;"><img src="images/player/bt_maximizar.jpg" width="24" height="30" border="0" alt="Clique aqui para assistir em tela cheia" /></a></td>'
			+'</tr>'
			+'</table></td>'
			+'</tr>'
			+'</table></span>';

		WM.controls.stop();
}

// controle dos videos

// barra stop
function BarraStopVideos(){
	var controle = document.getElementById('controletvi');
	var WM = document.getElementById('WM');
	msgStatusVideo('Video parado..');
	controle.innerHTML ='<span><table width="100%" border="0" cellspacing="0">'
  			+'<tr>'
    			+'<td background="images/player/espaco-2.jpg"><table width="100%" border="0" cellspacing="0">'
      			+'<tr>'
        			+'<td width="7%"><a href="javascript:void(0)" onclick="BarraPlayVideos()"><img src="images/player/bt_player.jpg" width="35" height="30" border="0" alt="Clique aqui para parar" /></a></td>'
        			+'<td width="38%"><a href="javascript:void(0)" onclick="BarraPauseVideos()"><img src="images/player/bt_pause.jpg" width="35" height="30" border="0" alt="Clique aqui para parar" /></a></td>'
        			+'<td width="38%">&nbsp;</td>'
        			+'<td width="5%"><a href="javascript:void(0)" onclick="TVi_SemSom();return false;"><img src="images/player/bt_som.jpg" width="24" height="30" border="0" alt="Clique aqui para diminuir o som" /></a></td>'
        			+'<td width="1%">&nbsp;</td>'
        			+'<td width="5%"><a href="#" onclick=""><img src="images/player/bot_popup.jpg" width="27" height="30" border="0" alt="Clique aqui para assistir em uma janela popup" /></a></td>'
        			+'<td width="1%">&nbsp;</td>'
        			+'<td width="5%"><a href="javascript:void(0)" onclick="Tela_Cheia();return false;"><img src="images/player/bt_maximizar.jpg" width="24" height="30" border="0" alt="Clique aqui para assistir em tela cheia" /></a></td>'
      			+'</tr>'
   			  +'</table></td>'
  			+'</tr>'
		+'</table></span>';
		WM.controls.stop();
}

// barra play 
function BarraPlayVideos(){
	var controle = document.getElementById('controletvi');
	var WM = document.getElementById('WM');
	controle.innerHTML ='<span><table width="100%" border="0" cellspacing="0">'
  			+'<tr>'
    			+'<td background="images/player/espaco-2.jpg"><table width="100%" border="0" cellspacing="0">'
      			+'<tr>'
        			+'<td width="7%"><a href="javascript:void(0)" onclick="BarraStopVideos()"><img src="images/player/bt_stop.jpg" width="35" height="30" border="0" alt="Clique aqui para parar" /></a></td>'
        			+'<td width="38%"><a href="javascript:void(0)" onclick="BarraPauseVideos()"><img src="images/player/bt_pause.jpg" width="35" height="30" border="0" alt="Clique aqui para parar" /></a></td>'
        			+'<td width="38%">&nbsp;</td>'
        			+'<td width="5%"><a href="javascript:void(0)" onclick="TVi_SemSom();return false;"><img src="images/player/bt_som.jpg" width="24" height="30" border="0" alt="Clique aqui para diminuir o som" /></a></td>'
        			+'<td width="1%">&nbsp;</td>'
        			+'<td width="5%"><a href="#" onclick=""><img src="images/player/bot_popup.jpg" width="27" height="30" border="0" alt="Clique aqui para assistir em uma janela popup" /></a></td>'
        			+'<td width="1%">&nbsp;</td>'
        			+'<td width="5%"><a href="javascript:void(0)" onclick="Tela_Cheia();return false;"><img src="images/player/bt_maximizar.jpg" width="24" height="30" border="0" alt="Clique aqui para assistir em tela cheia" /></a></td>'
      			+'</tr>'
   			  +'</table></td>'
  			+'</tr>'
		+'</table></span>';
			WM.controls.play();
}

function xPlayStat(){
	var TVi = document.getElementById('WM');
	var st = TVi.PlayState;
		if (st != 6 || st == 3) {
				TVi.controls.Pause();
				msgStatusVideo('Video pausado..');
		} 
		if (st == 2){
				TVi.controls.play();
				msgStatusVideo('Transmitindo video..');
		}
}

function msgStatusVideo(msg){
	document.getElementById('txtStatus').innerHTML= msg;
}

function showDuration(){
	var wmp = document.getElementById('WM');
	var dis = document.getElementById('txtStatus');
	var ps = wmp.playState;
	var dur=wmp.controls.currentPositionString + " / " + wmp.currentMedia.durationString;
	
		if(ps==9)
			setTimeout("showDuration()",100);
		else
			{
		alert(dur);
				return true;
			}
}

function startCheckPlayer() {
	window.setTimeout("checkPlayer()",1000);
	window.setInterval("checkPlayerStatus()",1000);
}
function checkPlayerStatus() {
	document.formular2.clipPosition.value = parseInt(document.MediaPlayer.currentPosition);
	document.formular2.playerStatus.value = document.MediaPlayer.PlayState;
	document.formular2.percPos.value = parseInt(document.MediaPlayer.currentPosition / document.MediaPlayer.duration*100);
}
function checkPlayer () {
	document.formular1.clipTitel.value = document.MediaPlayer.GetMediaInfoString(8);
	document.formular1.clipAuthor.value = document.MediaPlayer.GetMediaInfoString(9);
	document.formular1.clipCopyright.value = document.MediaPlayer.GetMediaInfoString(10);
	document.formular2.clipLength.value = parseInt(document.MediaPlayer.duration);
}

