function detalhaEstudantes(){
	var ajaxTeste	= new ajax('GET', 'includes/detalhe_estudantes.php', true, '', 'showEstudantes');
	ajaxTeste.ajaxResponse();
}

function showEstudantes(tx_html) {
	// resolve problemas c/ acentuação [' e "]
	tx_html				= decodeURI(tx_html);
	// Pega os tamanhos atuais da página, como largura, altura, ...
	var sizesPage		= getPageSize();
	// Vamos criar uma tag div
	var dv_estudantes			= document.createElement('div');
	dv_estudantes.setAttribute('id','dv_estudantes');
	with (dv_estudantes.style) {
		position		= 'absolute';
		top				= '180px';
		verticalAlign	= 'middle';
		zIndex			= '1900';
	}
	// escreve o retorno do AJAX na div
	dv_estudantes.innerHTML	= tx_html;
	// remove o loadinf da tela
	loading(false);
	
	// Evita criar a div novamente
	if (!document.getElementById('dv_estudantes')) {
		document.body.appendChild(dv_estudantes);
	}
}

/*# Fecha detalhes do mapa e destrava o site */
function fechaDetalheEstudantes() {
	if (document.getElementById('bgBody')) {
		var dv_estudantes		= document.getElementById('dv_estudantes');
		var bgBody		= document.getElementById('bgBody');
		with (bgBody.parentNode) {
			removeChild(dv_estudantes);
			removeChild(bgBody);
		}
	}
}

function detalhaMapa(){
	var ajaxTeste	= new ajax('GET', 'includes/detalhe_mapa.php', true, '', 'showMapa');
	ajaxTeste.ajaxResponse();
}

function showMapa(tx_html) {
	// resolve problemas c/ acentuação [' e "]
	tx_html				= decodeURI(tx_html);
	// Pega os tamanhos atuais da página, como largura, altura, ...
	var sizesPage		= getPageSize();
	// Vamos criar uma tag div
	var dv_mapa			= document.createElement('div');
	dv_mapa.setAttribute('id','dv_mapa');
	with (dv_mapa.style) {
		position		= 'absolute';
		top				= '300px';
		verticalAlign	= 'middle';
		zIndex			= '1900';
	}
	// escreve o retorno do AJAX na div
	dv_mapa.innerHTML	= tx_html;
	// remove o loadinf da tela
	loading(false);
	
	// Evita criar a div novamente
	if (!document.getElementById('dv_mapa')) {
		document.body.appendChild(dv_mapa);
	}
}

/*# Fecha detalhes do mapa e destrava o site */
function fechaDetalheMapa() {
	if (document.getElementById('bgBody')) {
		var dv_mapa		= document.getElementById('dv_mapa');
		var bgBody		= document.getElementById('bgBody');
		with (bgBody.parentNode) {
			removeChild(dv_mapa);
			removeChild(bgBody);
		}
	}
}

function detalhaFilme(horarioID){
	horarioID		= parseInt(horarioID);
	var ajaxTeste	= new ajax('GET', 'includes/detalhe_programacao.php?horarioID='+horarioID, true, '', 'showFilme');
	ajaxTeste.ajaxResponse();
}

/*# Fecha detalhes do filme e destrava o site */
function fechaDetalheFilme() {
	if (document.getElementById('bgBody')) {
		var dv_filme	= document.getElementById('dv_filme');
		var bgBody		= document.getElementById('bgBody');
		with (bgBody.parentNode) {
			removeChild(dv_filme);
			removeChild(bgBody);
		}
	}
}

/*# Apresenta conteúdo retornado pelo AJAX na tela */
function showFilme(tx_html) {
	// resolve problemas c/ acentuação [' e "]
	tx_html				= decodeURI(tx_html);
	// Pega os tamanhos atuais da página, como largura, altura, ...
	var sizesPage		= getPageSize();
	// Vamos criar uma tag div
	var dv_filme		= document.createElement('div');
	dv_filme.setAttribute('id','dv_filme');
	with (dv_filme.style) {
		position		= 'absolute';
		top				= '300px';
		left			= 'auto';
		zIndex			= '1900';
	}

	// escreve o retorno na div
	dv_filme.innerHTML	= tx_html;
	// remove o loadinf da tela
	loading(false);
	
	// Evita criar a div novamente
	if (!document.getElementById('dv_filme')) {
		document.body.appendChild(dv_filme);
	}	
}

/*# trava a tela com div branca c/ opacidade */
function travaTela() {
	// Seleciona a tag body. item(0) por que só existe uma tag body
	var tagBody						= document.getElementsByTagName('body').item(0);
	// Pega os tamanhos atuais da página, como largura, altura, ...
	var sizesPage					= getPageSize();
	// Vamos criar uma tag div
	var bgBody						= document.createElement('div');
	// Setar o atributo ID a div criada
	bgBody.setAttribute('id','bgBody');
	with (bgBody.style) {
		top				= '0px';
		left			= '0px';
		// Essa div terá o tamanho exato da página
		height			= sizesPage[1] + 'px';
		// Essa div terá a largura exata da página
		width			= sizesPage[0] + 'px';
	}
	
	// Evita criar a div novamente
	if (!document.getElementById('bgBody')) {
		tagBody.insertBefore(bgBody, tagBody.firstChild);
	}	
}

/*# Utilizado para criar o efeito de loading */
function loading(opt) {
	if (opt == true) {
		// A tag que receberá a img de loading
		var bgBody = document.getElementById('bgBody');
		// O tamanho da referida tag
		var bgBodyHeight = getPageSize();
		// Dizemos que os elementos dentro dela será alinhado ao centro
		bgBody.style.textAlign = 'center';
		// Criamos uma imagem, img.
		var img = document.createElement('img');
		// Informamos o caminho da img
		img.setAttribute('src','imagens/loading.gif');
		// Setamos um atributo ID na img criada
		img.setAttribute('id','loading');
		// Dizemos que o margin-top será a metada do tamanho da div
		img.style.position = 'absolute'; //(bgBodyHeight[3]/2) + 'px';
		img.style.top = '50%'; //(bgBodyHeight[3]/2) + 'px';
		// Evita que seja criada duas ou mais img de loading
		if (!document.getElementById('loading')) {
			// Insere a img na tag informada na variável bgBody
			bgBody.insertBefore(img, bgBody.firstChild);
		}
	} else if (opt == false) {
		// Referenciamos a img de login através de seu ID
		var imgLoading = document.getElementById('loading');
		// Removemos a img de loading
		if (imgLoading) {
			imgLoading.parentNode.removeChild(imgLoading);
		}
	}
}

/* Retorna o tamanho da página */
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	
	return arrayPageSize;

}

/*# redireciona usuário
	@vc_redirect:String		=	página q o usuário será enviada
	@it_segundo	:Integer	=	número de segundos antes de redirecionar
								[opcional, padrão -> 3segundos]			*/
function redirect(vc_redirect, it_segundo) {
	it_segundo	= (it_segundo) ? parseInt(it_segundo * 1000) : 3000;
	setTimeout('self.location.href=\'' + vc_redirect + '\'', it_segundo)
}

/*# função para exibir/ocultar layers */
function sL(layerName){
	document.getElementById(layerName).style.visibility = "visible";
}
        
function hL(layerName){
	document.getElementById(layerName).style.visibility = "hidden";
}
        
