// JavaScript Document


window.onload = function(){
	
	//debugger;
	alinhaDivs('esquerda','meio');

	window.ucgtvonline = -1;
	verificaHabilitacao();
	
	

}



verificaHabilitacao = function(){
	
	
	
	new Ajax.Request('horaLocal.php',{
						 			method: 'get', 
					 			    onComplete: habilitacao,				    	    	            
					                onFailure: function(){ alert('Comunicação interrompida')  }});		
	
}

habilitacao = function(xmlRequest){
	

	var valor = parseInt(xmlRequest.responseText);
	
	
	//alert(valor);
	
	if (valor != window.ucgtvonline){
		new Ajax.Updater("tvOnline","tvOnline.php");
		
		
		window.ucgtvonline = valor;
		
		
	}
	
	
	if(valor==1){
		
		$('horarios').style.display = 'none';
		
	}else if (valor==0){
		
		$('horarios').style.display = 'block';
		
	}
	
	
	$('horaLocal').innerHTML = valor;
	
	setTimeout("verificaHabilitacao()",3000);
}




alinhaDivs = function(div1, div2){
	
	//debugger;
	var elem1 = document.getElementById(div1);
	var elem2 = document.getElementById(div2);
	
	var x = elem1.clientHeight;
	var y = elem2.clientHeight;			
		
	var tam = 0;
		
	if(x>=y){
		tam = x;	
	}else{
		tam = y;
	}
		
	elem1.style.height = tam + "px";
	elem2.style.height = tam + "px";
	
}


alinhaPeloMenor = function(div1, div2){
	
	//debugger;
	var elem1 = document.getElementById(div1);
	var elem2 = document.getElementById(div2);
	
	var x = elem1.clientHeight;
	var y = elem2.clientHeight;			
		
	var tam = 0;
		
	if(x<=y){
		tam = x;	
	}else{
		tam = y;
	}
		
	elem1.style.height = tam + "px";
	elem2.style.height = tam + "px";
	
}
