
/* FUNÇÕES NECESSÁRIAS PARA AVISOS
-----------------------------------------------------------------------*/

function alinha_centro(div){
	var posX = Math.round($(div).width() / 2);
	var posY = Math.round($(div).height() / 2);
	
	$(div).css({
		"position" : "fixed",
		"top": '50%',
		"left": '50%',
		"margin-left": - posX,
		"margin-top": - posY,
		"z-index": 1000
	});
}

// gera aviso (como alert);
function aviso(t,m){
	var div = '<div id="div_aviso"></div>';
	$('#div_aviso').remove();
	$('body').append(div);
	$('#div_aviso').html('<h1>' + t + '</h1><p>' + m + '</p><a href="javascript:void(0)" class="f">Fechar</a>');
	
	alinha_centro('#div_aviso');
	
	function fechar(){
		$('#div_aviso').fadeOut('slow',function(){
			$('#div_aviso').remove();
		});
	}
	
	$('#div_aviso').hide();
	$('#div_aviso').fadeIn(500);
	$('#div_aviso a.f').click(function(event){
		event.preventDefault();
		fechar();
	});
}

function debug(msg){
	aviso('Debug',msg);
}

function mostrarCarregando(texto){
	//carregando.show();
	if(texto == undefined){
		texto = 'Carregando...';
	}
	$('#carregando').html(texto);
	$('#carregando').fadeIn(200);
};
	
function ocultarCarregando(){
	$('#carregando').fadeOut(600)
};

/* EXECUTA AS FUNÇÕES AO CARREGAR O SITE (CÓDIGO FONTE)
-----------------------------------------------------------------------*/

$(document).ready(function(){
	ocultarCarregando();
	$('a.colorbox').colorbox();	
});

