function montaSelectCidades() {
	obj = new Busca();
	arr_cidades = obj.listaCidades();
	html = '';
	for (i=0; i < arr_cidades.length; i++) {
		html = html + '<option value="' + arr_cidades[i] + '">' + arr_cidades[i] + '</option>';
	}
	return html;
}

function montaDivBairros(cidade_param) {
	html = '';
	obj = new Busca();
	arr_bairros = new Array();
	div_bairros = document.getElementById("bairros");
	div_bairros.innerHTML = '';
	html = '<h1>Escolha os bairros</h1>';
	if (cidade_param != '') {
		arr_bairros = obj.listaBairros(cidade_param);
		for (i=0; i < arr_bairros.length; i++) {
			html = html + '<span><input type="checkbox" id="chk_bairros" value="'+cidade_param+'|'+arr_bairros[i]+'" onclick="montaDivEmpreendimentos();" />' + arr_bairros[i] + '</span>';
		}
		div_bairros.innerHTML = html;
	}
}

function montaDivEmpreendimentos() {
	div_emp = document.getElementById("empreendimentos");
	div_emp.innerHTML = '<h1>Empreendimentos</h1>';
	arr_chks = document.getElementsByTagName("input");
	for (i=0;i<arr_chks.length;i++) {
		if (arr_chks[i].id == 'chk_bairros') {
			if (arr_chks[i].checked == true) {
				arr_local = arr_chks[i].value.split('|');
				cidade = arr_local[0];
				bairro = arr_local[1];
				mostraEmpreendimentos(cidade, bairro);
			} else {
				//alert('nao selecionado')
			}

		}
	}
}

function mostraEmpreendimentos(cidade, bairro) {
	obj = new Busca();
	div_emp = document.getElementById("empreendimentos");
	html = '';
	arr_emp = obj.listaEmpreendimentos(cidade,bairro);
	for (c=0; c < arr_emp.length; c++) {
		url = arr_emp[c]['url'];
		nome = arr_emp[c]['nome'];
		html = html + '<a href="' + url + '">&raquo;&nbsp;' + nome + '</a>';
	}
	div_emp.innerHTML = div_emp.innerHTML + html;
}
