function pegaMercados(id) {
	if (id != '0') {
		$('select#cadastroMercado').html('<option>Aguarde...</option>');

		$.post(baseURL + 'includes/form_cadastro.php', { action: 'pegaMercados', id: id }, function(data) {
			$('select#cadastroMercado').html(data);
		});
	}
}

function valida_cadastro() {
//Validação do Formulário
	var validacao = $('form#formCadastro').jForm({
		cadastroNome:				$('#cadastroNome').jField({ name: 'Nome', empty: 'no', minLength: 3 }),
		cadastroEmail:				$('#cadastroEmail').jField({ name: 'E-mail', type: 'email', empty: 'no', minLength: 3 }),
		cadastroSegmento:			$('#cadastroSegmento').jField({ name: 'Segmento', type: 'select', empty: 'no' }),
		cadastroMercado:			$('#cadastroMercado').jField({ name: 'Mercado', type: 'select', empty: 'no' })
	}, 'msgErro', false);

	$('form#formCadastro').submit(function() {
		if ($.jForm.checkFields(validacao)) {
			var postData = {};
			$('form#formCadastro input, form#formCadastro select').each(function() {
				postData[this.name] = this.value;
				this.value = '';
			});
			
			$.post(baseURL + 'includes/envio_cadastro.php', postData, function() {
				$('#flashMessage').show();
			});
		
			return false;
		} else {
			return false;
		}
	});
};
