
	var nav_isIE = false;
	var globalpath="tools/ajax/media_center_processar.php";	
	var windowposition=0;
	var time_scroll;
   var stream_online='';
	
	Mouse = {}
	Mouse.doc = document;
	Mouse.MouseMoveHandler = function (e) {
		 e = e || window.event;
		 Mouse.x = (Mouse.doc.body.scrollLeft || 0) + e.clientX;
		 Mouse.y = (Mouse.doc.body.scrollTop || 0) + e.clientY;
		 Mouse.currentTarget = e.target || e.srcElement;
		 return true;
	}
	
	if (Mouse.doc.attachEvent)
	   Mouse.doc.attachEvent("onmousemove",Mouse.MouseMoveHandler);
	else if (Mouse.doc.addEventListener)
	   Mouse.doc.addEventListener("mousemove",Mouse.MouseMoveHandler,false);
	   
	var xmlhttp=false;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
		// branch for IE/Windows ActiveX version
	} else{
		nav_isIE = true;
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	function urldecode(texto){
		texto=texto.replace(/\+/g," ");
		texto=unescape(texto);
		return texto;
	}
	function trim( text ) {
	   if(text==null) return null;
	   return text.replace(/^[ \t]+|[ \t]+$/g, "");
	}
	
	
	var processarGeral= function(url,path){
	  if(xmlhttp.readyState != 2 && xmlhttp.readyState != 3) {
			xmlhttp.open('POST', path ,false);
			xmlhttp.setRequestHeader('Method',"POST " + " HTTP/1.1");
			xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xmlhttp.send(url);
		}
	}
			  
			  function showFotoDetails(val) {
				processarGeral("action=foto_details&compare=" + val ,"tools/ajax/media_center_processar.php"); 
			 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				var contents = urldecode(xmlhttp.responseText)
				tooltips=document.getElementById('divtooltips');
				//if(lastposition==0){
					tooltips.style.top= Mouse.y - 200;
					tooltips.style.left= Mouse.x - 50;
					tooltips.style.width='auto';
				//}
				
			tooltips.innerHTML =  contents;
			lastposition=tooltips.style.top;
			tooltips.style.display='block';
			  }  
	}
	
	
	
	
	function get_calendario(val) {
					if(screen.width > 800)
						var minus=260
						else
						var minus=380
						
		processarGeral("action=get_calendario&compare=" + val ,"tools/ajax/JSXprocessar.php");
			 if (xmlhttp.readyState == 4 || xmlhttp.status == 200) {
				 
					var thevalue = urldecode(xmlhttp.responseText)
					var tooltips = (document.all) ? document.all.divtooltips : document.getElementById("divtooltips");
					tooltips.style.top=  Mouse.y ;
					tooltips.style.left=Mouse.x - minus;
					
						
						
					if(parseInt(thevalue)!=0){
						tooltips.style.width=400;
					}else{
						tooltips.style.width=200;
						thevalue='Não disponível';
					 }
					 
					tooltips.innerHTML =  thevalue;
					tooltips.style.display='block';
					
			  }  
	}
	
	function hideobj( obj ) {
	   try{
		   document.getElementById(obj).style.display='none';
	   }catch(e){}
	}
	
	function abrir_janela(valor,medidas) {
		self.OnError=null;
		window.open(valor,'Popup','toolbar=no,location=no,scrollbars=yes,status=no,menubar=no,resizable=no,' + medidas);
	}
	function cookiesenable(){
		r=(navigator.cookieEnabled == 0)? false:true
		return  r;
	}
	

	// scripts fixos
	function getmedia_lista() {
			processarGeral("action=getmedia_lista&compare=" ,globalpath);
			 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		 			var tooltips =  document.getElementById('media_list');
					var thevalue = urldecode(xmlhttp.responseText)
					tooltips.innerHTML =  thevalue;					
			  }  
	}
	
	
	function search_news() {
		   pesq= document.getElementById('pesq').value;
		   if(pesq){
			 processarGeral("action=search_news&compare=" + pesq ,globalpath);
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		 			var tooltips =  document.getElementById('media_list');
					var thevalue = urldecode(xmlhttp.responseText)
					tooltips.innerHTML =  thevalue;					
			  }  
		   }
	}


		function send_news_comentario() {
			
			var campo1=document.frmComentario.idnews.value;
			var campo2=escape(document.frmComentario.de.value);	
			var campo3=escape(document.frmComentario.comentario.value);
			var compare= campo1 + "::" + campo2 + "::" + campo3;
			
			if(compare){
					processarGeral("action=send_news_comentario&compare=" + compare ,globalpath);			
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
						var divcoments =  document.getElementById('divcoments');
						var thevalue = urldecode(xmlhttp.responseText)
						divcoments.innerHTML =  thevalue;					
						document.frmComentario.comentario.value='';
				}  
			}else{
				alert('Dados incompletos para envio');
			}
			
		}
		
		
	function get_news_comentario(val) {
		processarGeral("action=get_news_comentario&compare=" + val ,globalpath);
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				var divcoments =  document.getElementById('divcoments');
				var thevalue = urldecode(xmlhttp.responseText)
				divcoments.innerHTML =  thevalue;					
			}  
		}
	
	function playMovie(id,title){
			window.iframe_v.location.href='pages/videos.php?idv=' + id ;
		if(!nav_isIE ){
				  window.iframe_v.location.refresh;
		}
	}
		
	

function seta_media_divs(id,tipo){
		
	  externo=document.getElementById('box_externo' + id);
	  interno=document.getElementById('box_interno' + id);
	  
		  if(tipo=='none'){ 
		  		externo.className='box_externo'
		  }else{
		 externo.className='box_externo_on'
		  }
		  
	   interno.style.display=tipo;
	   
	}
	
	


// functions para reload nos 
// ifrmes de  video e noticias
function play_(val,t){
	if(t=='v')
	 window.iframe_v.location.href='pages/videos.php?idv=' + val;
	else
	 window.iframe_n.location.href='pages/banners.php?idn=' + val;
}

function show_contents(val){
	return true;
}



function thisexist(val) {
	processarGeral("action=thisexist&" + val,"tools/ajax/JSXprocessar.php" );
	 if (xmlhttp.readyState == 4 || xmlhttp.status == 200) {
					 var thevalue = urldecode(xmlhttp.responseText)
					 return thevalue; 
	}
}
	
function get_stream_online() {
		processarGeral("action=thisexist&" ,"../pages/online.php" );
		 if (xmlhttp.readyState == 4 || xmlhttp.status == 200) {
					 var thevalue = urldecode(xmlhttp.responseText);
					 return thevalue; 
		}
}



function ouvidor(){
	try{
		playstatus=document.getElementById('MediaPlayer').playState;
		
		if(parseInt(indice_matriz) >  matriz_stream_url.length) indice_matriz=0;
		
		stream_online = get_stream_online();
		
		if(playstatus==0 || (stream_online && playstatus==0) ){
				if(stream_online){
						document.getElementById('MediaPlayer').fileName=stream_online;
						document.getElementById('MediaPlayer').play();
						seta_div_no_ar('Ao Vivo');	
				}else{
					document.getElementById('MediaPlayer').fileName=matriz_stream_url[parseInt(indice_matriz)];
					document.getElementById('MediaPlayer').play();
					seta_div_no_ar(matriz_stream_titulo[parseInt(indice_matriz)]);
					if(parseInt(num_tentativas)%2==0)  indice_matriz++;
					num_tentativas++;
				}
		}
		
		setTimeout("ouvidor()",5000);
	}catch(e){}
}

function seta_div_no_ar(thevalue){
			var obj=parent.document.getElementById('no_ar') ;
			obj.innerHTML = thevalue ;		
	}
		
function div_publicidade(w,h){
	obj=document.getElementById('div_publicidade');
	obj.style.width=w;
	obj.style.height=h;
}

function Resize(){
	if(navigator.appName!="Microsoft Internet Explorer"){
	window.moveTo(0,0);
	window.resizeTo(screen.width-1,screen.height-1);
	window.resizeTo(screen.width,screen.height);
}

}

 function setaLogin(id){
	 for(var x=1;x<=4;x++){
		 var obj=document.getElementById('login' + x);
		 obj.style.display = (id==x) ? 'block': 'none';
		 
	 }
 }
 
moz=document.getElementById&&!document.all
mozHeightOffset=20

function resize_iframe(){
document.getElementById("iframe_c").height=100 // required for Moz bug, value can be "", null, or integer
document.getElementById('iframe_c').height=window.frames["iframe_c"].document.body.scrollHeight+(moz?mozHeightOffset:0)
}

