
$(document).ready( function () {
	/*
	//controla o loading
	jQuery().ajaxStart(function() {
		$("#img-loading").show();
	}).ajaxStop(function() {
		$("#img-loading").hide();
	});
	
	function startAjax(uf, pg)
	{
		$.ajax({
			type: "GET",
			url: ROOT_DIR + "/clientes/index/uf/" + uf + "/pg/" + pg,
			success: function(data) {
				//console.info(data);
				body = $("tbody", data).html();
				pag  = $("tfoot tr td:first", data).html();
				
				$("tbody", "#tbl-clientes").html(body);
				$("tfoot tr td:first", "#tbl-clientes").html(pag);
				
				addEvent();
				
			}
		});
	}
	
	function addEvent()
	{
		
		$("tbody tr:odd", "#tbl-clientes").addClass("odd");
		$("tfoot tr td:first", "#tbl-clientes").find("a").bind("click", function() {
			$(this).unbind();
			params = $(this).attr("title").split("|");
			
			startAjax(params[0], params[1]);
			return false;
			
		});
		
		$('html,body').animate({scrollTop: $("body").offset().top}, 1000);

	}
	
	//função para fazer a paginação dos estados
	function mudaUf()
	{
		
		prev = i-1;
		next = i+1;
		
		if (i == 25) 
		{
			next = 0;
		}
		else if (i == 0)
		{
			prev = 25;
		}
		
		$("#uf-left a").html(uf[prev][0]);
		$("#uf-center b").html(uf[i][1]);
		$("#uf-right a").html(uf[next][0]);
		
		startAjax(uf[i][0], 1);
	}
	
	
	var i  = 11; //começar com MG
	var uf = [
				["AC" , "Acre"],
				["AL" , "Alagoas"],
				["AP" , "Amapá"],
				["AM" , "Amazonas"],
				["BA" , "Bahia"],
				["CE" , "Ceará"],
				["DF" , "Distrito Federal"],
				["ES" , "Espírito Santo"],
				["GO" , "Goiás"],
				["MA" , "Maranhão"],
				["MS" , "Mato Grosso do Sul"],
				["MG" , "Minas Gerais"],
				["PA" , "Pará"],
				["PB" , "Paraíba"],
				["PR" , "Paraná"],
				["PE" , "Pernambuco"],
				["PI" , "Piauí"],
				["RJ" , "Rio de Janeiro"],
				["RN" , "Rio Grande do Norte"],
				["RS" , "Rio Grande do Sul"],
				["RO" , "Rondônia"],
				["RR" , "Roraima"],
				["SC" , "Santa Catarina"],
				["SP" , "São Paulo"],
				["SE" , "Sergipe"],
				["TO" , "Tocantins"]
			];
		
	$("#uf-left a").bind("click", function() {
		$(this).unbind();
		i--;
		mudaUf();
		return false;
	});
	
	$("#uf-right a").bind("click", function() {
		$(this).unbind();
		i++;
		mudaUf();
		return false;
	});
	
	$("#img-loading").hide();
	
	addEvent();
	*/
});