ddd = '';
function valida_compre() {
	//Validação do Formulário
	var validacao = $('form#formInclude').jForm({
		includeNome:		$('#includeNome').jField({ name: 'Nome', empty: 'no', minLength: 3 }),
		includeEmpresa:		$('#includeEmpresa').jField({ name: 'Empresa', empty: 'no', minLength: 3 }),
		includeEstado:		$('#includeEstado').jField({ name: 'Estado', type: 'select', empty: 'no' }),
		includeCidade:		$('#includeCidade').jField({ name: 'Cidade', type: 'select', empty: 'no' }),
		includeTelefone:	$('#includeTelefone').jField({ name: 'Telefone', type: 'tel', empty: 'no', minLength: 14 }),
		includeEmail:		$('#includeEmail').jField({ name: 'E-mail', type: 'email', empty: 'no', minLength: 3 }),
		includeEquipamento:		$('#includeEquipamento').jField({ name: 'Equipamento', empty: 'no', minLength: 3 }),		
		includeComentarios:	$('#includeComentarios').jField({ name: 'Comentários', empty: 'no', minLength: 20 })
	});
	
	$('form#formInclude').submit(function() {
		if ($.jForm.checkFields(validacao)) {
			var postData = {};
			$('form#formInclude input, form#formInclude textarea, form#formInclude select').each(function() {
				postData[this.name] = this.value;
				if (this.name != 'secao' && this.name != 'pagina') {
					this.value = '';
				}
			});
			
			$.post($('form#formInclude').attr('action'), postData, function() {
				$('#flashMessage').show();
			});
		
			return false;
		} else {
			return false;
		}
	});
	
	//Carrega Lista de Estados
	$('#includeEstado').html('<option>Carregando estados...</option>');
	$.get(baseURL + 'includes/lookup_estados.php', function(data){
		eval('var estados = ' + data + ';');
		
		var options = '<option value="0">Selecione</option>';
		for (i in estados) {
			options += '<option id="' + i + '" value="' + i + '">' + estados[i] + '</option>';
		}
		
		$('#includeEstado').html(options);
		$('#includeEstado').val(0);
	});
	$('#includeEstado').change(function(){
		id_estado = this.selectedIndex;
		id_estado = this.options[id_estado].id;
		$('#compreCidade').html('<option>Carregando cidades...</option>');
		$.get(baseURL + 'includes/lookup_cidades.php?id='+id_estado, function(data){
			eval(data);
			
			var options = '<option value="0">Selecione</option>';
			for (i in cidades) {
				options += '<option id="' + i + '" value="' + cidades[i] + '">' + cidades[i] + '</option>';
			}
			
			$('#includeCidade').html(options);
			$('#includeCidade').val(0);
		});
	});
}