/**
 * Carrega informa��es de CEP
 */
	
function load_cep(obj,value,pNome)
{
	// Nome deve ser uma variável Global
	nome = "endereco";
	
	if (pNome && pNome != "")
		nome = pNome;

	var cep = filterNum(obj.value);
		 
	if (cep.length != 8){
		obj.className = "invalid";
		return;
	}

	obj.value = cep.substring(0,2) + "." + cep.substring(2,5) + "-" + cep.substring(5,8);

	obj.className = "valid";
	
	
	var url = '/logradouros/show/' + cep + '.json';
	
	jQuery.ajax({
  		url: url,
  		type: "GET",
  		dataType: "json",
  		success: function(json) {
			jQuery("#" + nome + "_logradouro").attr({ value: json.logradouro});
			jQuery("#" + nome + "_bairro").attr({ value: json.bairro});
			jQuery("#" + nome + "_cidade").attr({ value: json.cidade});
			jQuery("#" + nome + "_uf").attr({ value: json.uf});
  		},
  		error: function(json,nome){
    	jQuery("#" + nome + "_logradouro").attr({ value: ""});
			jQuery("#" + nome + "_bairro").attr({ value: ""});
			jQuery("#" + nome + "_cidade").attr({ value: ""});
			jQuery("#" + nome + "_uf").attr({ value: ""});
			
  		}
	});


}

