function processarFormulario() {
	_etapa = Number(document.getElementById('etapa').value) -1;
	
	if(_etapa == 4)  {
		
		if(document.getElementById('nome').value == '' || document.getElementById('email').value == '' || document.getElementById('cidade').value == '' || document.getElementById('estado').value == '') {
			alert('Todos os dados são obrigatórios, exceto o telefone.');
			return false;
		}
		_email = document.getElementById('email');
		if(!validarEmail(_email.value)) {
			alert('O e-mail digitado é inválido.');
			_email.select();
			_email.focus();
			return false;
		}
		
	} else if(_etapa == 1) {
		
		_opcao_selecionada = false;
		for(i=0; document.getElementById('opcaosimulador_tipo'+i); i++) {
			if(document.getElementById('opcaosimulador_tipo'+i).checked) {
				_opcao_selecionada = true;
				break;
			}
		}
		if(!_opcao_selecionada) {
			alert('Escolha uma das opções.');
			return false;
		}
		
	} else if(_etapa == 2) {
		
		_opcao_selecionada = false;
		for(i=0; document.getElementById('opcaosimulador_faixa_credito_inicio'+i); i++) {
			if(document.getElementById('opcaosimulador_faixa_credito_inicio'+i).checked) {
				_opcao_selecionada = true;
				break;
			}
		}
		if(!_opcao_selecionada) {
			alert('Escolha uma das opções.');
			return false;
		}
		
	} 
	/*else if(_etapa == 5) {
		
		_opcao_selecionada = false;
		for(i=0; document.getElementById('opcaosimulador'+i); i++) {
			if(document.getElementById('opcaosimulador'+i).checked) {
				_opcao_selecionada = true;
				break;
			}
		}
		if(!_opcao_selecionada) {
			alert('Escolha uma das opções.');
			return false;
		}
		
	}
	*/
	return true;
}

		
function paginaAnterior() {
	document.getElementById('formulario').action = 'index.php?voltar=1';
	document.getElementById('etapa').value = Number(document.getElementById('etapa').value) - 2;
	document.getElementById('formulario').submit();
}

function simularNovamente() {
	document.getElementById('formulario').action = 'index.php';
	document.getElementById('etapa').value = 2;
	document.getElementById('formulario').submit();
}
