/**
 *
 * Arquivo de funções Ajax do Site
 * Autor: Gustavo Borges Michel
 * Website: www.gust.com.br
 *
 */

/**
 * Função de Erro de Ajax
 */
function x_erro(){
	alert('Ocorreu um erro durante a consulta. Desculpe-nos o transtorno.');
}

/**
 * Função que retorna as consultas do Twitter
 */
function x_twitter(){
	
	$('.conteudo-box').html('<span class="txt-carregando">Carregando Twitter...</span>');
	$('.conteudo-box').animate({'height': 74}, 'slow');

	$.ajax({
		type	: "POST",
		url		: base_url + "index.php/apps/x_twitter",
		data	: "app=Twitter",
		success	: function(msg) {
			
			$('.conteudo-box').html(msg);

			if($('.twitter-load').height() > $('.conteudo-box').height()){
				height = $('.twitter-load').height();
				$('.conteudo-box').animate({'height': height}, 'slow');
			}			

			$('.txt-carregando').fadeOut().remove();

		},
		error: x_erro,
		timeout: x_erro
	});


}

/**
 * Função que retorna o usuário do Gmail
 */
function x_gmail(){

	$('.conteudo-box').html('<span class="txt-carregando">Carregando Gmail...</span>');
	$('.conteudo-box').animate({'height': 74}, 'slow');

	$.ajax({
		type	: "POST",
		url		: base_url + "index.php/apps/x_gmail",
		data	: "app=Gmail",
		success	: function(msg) {
			
			$('.conteudo-box').html(msg);

			if($('.twitter-load').height() > $('.conteudo-box').height()){
				height = $('.twitter-load').height();
				$('.conteudo-box').animate({'height': height}, 'slow');
			}			

			$('.txt-carregando').fadeOut().remove();

		},
		error: x_erro,
		timeout: x_erro
	});

}
