var total_busca = 0;
var exibeLoader = true;

function ajaxLoader(_id) {
	$('#'+_id).html(ajax_loader);
}

function paginacaoRetornoAjax(_id, _origem, _total, _retornoAjax, _callback) {
	$('#'+_id).html(_retornoAjax);
	
	if ( _origem == 'busca' ) {
		total_busca += eval(_total);
		$('#totalBusca').html(total_busca);
		
		try {
			//go_google_mod( cfg_termo_buscar, $('#' + _id + ' ul').get(0) );
			if ( _total == 0 ) {
				$('#' + _id).remove();
			}
		}
		catch (ex) { }
	}
	
	try { _callback.call(); } catch (ex) { }
	
}

function paginacaoAjax(_id, _url, _pag, _start, _querystring, _callback) {
	
	if ( exibeLoader ) {
		ajaxLoader(_id);
	}
	
	var _type = 'GET';
	var _pars = 'pag=' + _pag + '&start=' + _start + '&url_req=' + _url + '' + _querystring;
	
	var requisicaoAjax = jQuery.ajax( {
		dataType: 'html',
		type: _type,
		data: _pars,
		url: _url,
		success: function(_retornoAjax)
		{
			var _id			= requisicaoAjax.getResponseHeader('id');
			var _origem		= requisicaoAjax.getResponseHeader('origem');
			var _total		= requisicaoAjax.getResponseHeader('total');
			paginacaoRetornoAjax(_id, _origem, _total, _retornoAjax, _callback);
		}
	} );
}
