// JavaScript Document
function onLoadPage(){
	$("#pelicula").hide();
	$("#pelicula").width($(document).width());
	$("#pelicula").height($(document).height());
}


function pelicula(chave){
	if(chave==true) {
		$("#pelicula").show();
		$("ul").hide();
	}else{
		$("#pelicula").hide();
		$("ul").show();
	}
}

function tvGirafa(chave){
	if(chave==true) { include('tvGirafa.php','televisao','');}
	if(chave==false){ document.getElementById('televisao').innerHTML = '';}
}

//Ligando tv
//tvGirafa(true);

function arquivo(chave){
	if(chave==true) { include('arquivo.php','palco',''); tvGirafa(false); pelicula(true); }
	if(chave==false){ document.getElementById('palco').innerHTML = ''; tvGirafa(true); pelicula(false);}
}

function arquivoAbrir(a){
	arquivo(false);
	var dados = '?a='+a;
	include('arquivoAbrir.php','televisao',dados);
}

function pesquisar(){
	var dados = '?t='+document.getElementById('t').value+'&diadata='+document.getElementById('diadata').value+'&mesdata='+document.getElementById('mesdata').value+'&anodata='+document.getElementById('anodata').value+'&pesquisaForm='+document.getElementById('pesquisaForm').value+'&tipo='+document.getElementById('tipo').value;
	include('arquivo.php'+dados,'palco',dados);
}

function trocaTipo(tipo){
	if(tipo==1){
		document.getElementById('porTexto').style.display ='block';
		document.getElementById('porData').style.display  ='none';
	}
	
	if(tipo==2){
		document.getElementById('porTexto').style.display ='none';
		document.getElementById('porData').style.display  ='block';
	}
	
	if(tipo==3){
		document.getElementById('porTexto').style.display ='block';
		document.getElementById('porData').style.display  ='block';
	}
}

function carregarNoPalco(file){
	pelicula(true);
	include(file,'palco','');
}

function carregarNaTv(file){
	pelicula(false);
	include(file,'televisao','');
}

function include(url, destino, parametros){

    if(parametros!=''){
		delimitador = '&';
	}else{
		delimitador = '?';
	}

	urlAdd = delimitador + Math.ceil(Math.random() * 100000) + '=0';
	$("#carregando").show();
	$("#"+destino).load(url+parametros+urlAdd,function(){$("#carregando").hide();});
	//alert(url+parametros+urlAdd);

}