$(document).ready(function(){

	// Botão voltar
	$('.bt-back').click(function(){ history.back(); });

	// Botão imprimir
	$('.bt-imprimir').click(function(){ window.print(); });

	// Cursor pointer
	$('input[type=submit]').css('cursor','pointer');
	$('input[type=button]').css('cursor','pointer');

	// Target blank
	$("a[rel=external]").attr("target", "_blank");
	$("a[rel=external nofollow]").attr("target", "_blank");
	
	$(".lista-agenda li a").click(function(){
		$(".lista-agenda li a").removeClass("active");
		$(this).addClass("active");
		var pegaId = $(this).attr("href");
		$(".abre-agenda").slideUp();
		$(pegaId).slideDown();
	});

	// Mascara
	if($.fn.mask != undefined){
		$(".cepp").mask("99999-999");
		$(".telefone").mask("(99)9999-9999");
		$(".data").mask("99/99/9999");
		$(".cpf").mask("999.999.999-99");
		$(".cnpj").mask("99.999.999/9999-99");
		$(".nr_crc").mask("999999");
	}

	// Historico
	$(".submenu-historico li a span").after("/");
	$(".tab-conselheiros tbody tr td:last-child").css("text-align","right").css("padding-right","20px");
	$(".tab-conselheiros tbody tr th:last-child").css("text-align","right").css("padding-right","20px");

	// Select da cidade
	$("#msel").change(function(){
      $("#myresult").html("This is " + $("#msel").val() + " and other info");
	});

	// FLASH's
	$('.header .flash-topo').flash({
	    src: 'swf/header.swf',
	    width: 190,
	    height: 190,
		wmode: 'transparent',
		expressInstall: true
	});

	// Cycle
	if ($.fn.cycle != undefined) {
		$('.holder').cycle( {
			fx: "fade",
			prev: ".prev",
			next: ".next",
			pager: ".target",
			speed: 300,
			timeout: 0
		});
	}

	// Navegação do site
	$("ul.nav").superfish({
		animation: { height:'show' }
    });


	// Menu de histórico com abas
	$(".submenu-historico li a").click(function(){
		var target = $(this).attr("href");
		$(".submenu-historico li a").removeClass("active");
		$(this).addClass("active");

		$(".conteudo-tab").slideUp("fast");
		setTimeout(function () {
			$(target).removeClass("block");
			$(target).addClass("none");
		}, 4000);

		$(target).slideDown("fast");
		return false;
	});

	$('.bt-a-criacao').click();
	$('.comunicado-home').click();

	// Recuperar senha
	$("a.link-recupera-senha").click(function(){

		$login			= $("#form-login-curriculo");
		$recupera_senha	= $("#form-senha-curriculo");
		
		if($login.css("display") == 'block'){
			$login.css("display", 'none');
			$recupera_senha.css("display", 'block');
		}else{
			$recupera_senha.css("display", 'none');
			$login.css("display", 'block');
		}
		return false;
	});

});


/**
  * Função Validar Formulário
  * @param form Identificador do form
  * @return Boolean
  **/
function validaForm(form) {
    for (var i = 0; i < document.getElementById(form).elements.length; i++) {
        var nomeObj = document.getElementById(form).elements[i].name;
        var idObj 	= document.getElementById(form).elements[i].id;
		var relObj 	= document.getElementById(form).elements[i].getAttribute("rel");
		if ((relObj == "email")) {
			expressao = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i;
			if (!expressao.test(document.getElementById(form).elements[i].value)) {
				alert(document.getElementById(form).elements[i].title);
				document.getElementById(form).elements[i].value = "";
				document.getElementById(form).elements[i].focus();
				return false;
			}
		} else if (relObj == "required") {
			if ((document.getElementById(form).elements[i].value == null) || (document.getElementById(form).elements[i].value == "")) {
				alert(document.getElementById(form).elements[i].title);
				document.getElementById(form).elements[i].focus();
				return false;
			}
		}
    }
    return true;
}

/**
  * Função limpa espaço
  * @param str String
  * @return nada
  **/
function getTrim(str) {
	if(typeof(str) !== 'undefined'){
		return str.replace(/^\s+|\s+$/g, "");
	}else{
		return "";
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarNewsletter(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-newsletter.php",
			data: str,
			success: function(txt) {
				alert("Cadastro realizado com sucesso!");
				document.getElementById(form).reset();
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarLicitacao(form) {
	if (validaForm(form)) {
		if ($("#pw_senha").val() != $("#pw_senha_confirma").val()) {
			alert("Senha e Confirma senha não conferem.");
			document.getElementById("pw_senha").focus();
			return false;
		}
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-licitacao.php",
			data: str,
			success: function(txt) {

				/**
				   * Funções de retorno
				   *
				   * 0 - CNPJ inválido!
				   * 1 - CNPJ já cadastrado.
				   * 2 - Cadastro realizado com sucesso.
				   **/
				if (getTrim(txt) == 0) {
					alert("CNPJ inválido!");
					document.getElementById("ds_cnpj").focus();
				} else if (getTrim(txt) == 1) {
					alert("CNPJ já cadastrado.");
					document.getElementById("ds_cnpj").focus();
				} else if (getTrim(txt) == 2) {
					alert("Cadastro realizado com sucesso.");
					document.getElementById(form).reset();
				} else {
					alert("Não foi possível realizar o cadastro, tente novamente.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarAssinaturaPF(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-assinatura-pf.php",
			data: str,
			success: function(txt) {

				/**
				   * Funções de retorno
				   *
				   * 0 - CPF inválido!
				   * 1 - Data de nascimento inválida!
				   * 2 - RG já cadastrado.
				   * 3 - CPF já cadastrado.
				   * 4 - E-mail já cadastrado.
				   * 5 - Cadastro realizado com sucesso.
				   **/
				if (getTrim(txt) == 0) {
					alert("CPF inválido");
					document.getElementById("ds_cpf").focus();
				} else if (getTrim(txt) == 1) {
					alert("Data de nascimento inválida!");
					document.getElementById("dt_nascimento").focus();
				} else if (getTrim(txt) == 2) {
					alert("RG já cadastrado.");
					document.getElementById("ds_rg").focus();
				} else if (getTrim(txt) == 3) {
					alert("CPF já cadastrado.");
					document.getElementById("ds_cpf").focus();
				} else if (getTrim(txt) == 4) {
					alert("E-mail já cadastrado.");
					document.getElementById("ds_email").focus();
				} else if (getTrim(txt) == 5) {
					alert("Cadastro realizado com sucesso.");
					document.getElementById(form).reset();
					$(".close").click();
				} else {
					alert("Não foi possível realizar o cadastro, tente novamente.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarAssinaturaPJ(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-assinatura-pj.php",
			data: str,
			success: function(txt) {

				/**
				   * Funções de retorno
				   *
				   * 0 - CNPJ inválido!
				   * 1 - CNPJ já cadastrado.
				   * 2 - E-mail já cadastrado.
				   * 3 - Cadastro realizado com sucesso.
				   **/
				if (getTrim(txt) == 0) {
					alert("CNPJ inválido");
					document.getElementById("ds_cnpj").focus();
				} else if (getTrim(txt) == 1) {
					alert("CNPJ já cadastrado.");
					document.getElementById("ds_cnpj").focus();
				} else if (getTrim(txt) == 2) {
					alert("E-mail já cadastrado.");
					document.getElementById("ds_email").focus();
				} else if (getTrim(txt) == 3) {
					alert("Cadastro realizado com sucesso.");
					document.getElementById(form).reset();
					$(".close").click();
				} else {
					alert("Não foi possível realizar o cadastro, tente novamente.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarAssinaturaPedido(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-assinatura-pedido.php",
			data: str,
			success: function(txt) {

				/**
				   * Funções de retorno
				   *
				   * 0 - Cadastro realizado com sucesso.
				   **/
				if (getTrim(txt) == 0) {
					alert("Cadastro realizado com sucesso.");
					document.getElementById(form).reset();
					$(".close").click();
				} else {
					alert("Não foi possível realizar o cadastro, tente novamente.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarContato(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-contato.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - Setor não encontrado.
				   * 1 - Fale conosco enviado com sucesso.
				   * 2 - Não foi possível enviar o fale conosco.
				   * 3 - Não foi possível enviar o fale conosco.
				   **/
				if (getTrim(txt) == 0) {
					alert("Setor não encontrado.");
					document.getElementById("con_setor").focus();
				} else if (getTrim(txt) == 1) {
					alert("Fale conosco enviado com sucesso.");
					document.getElementById(form).reset();
				} else if (getTrim(txt) == 2) {
					alert("Não foi possível enviar o fale conosco.");
				} else if (getTrim(txt) == 3) {
					alert("Não foi possível enviar o fale conosco.");
				} else {
					alert("Não foi possível enviar o fale conosco.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarOuvidoria(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-ouvidoria.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - Mensagem enviada com sucesso.
				   * 1 - Não foi possível enviar a mensagem.
				   * 2 - Não foi possível enviar a mensagem.
				   **/
				if (getTrim(txt) == 0) {
					alert("Mensagem enviada com sucesso.");
					document.getElementById(form).reset();
				} else if (getTrim(txt) == 1) {
					alert("Não foi possível enviar a mensagem.");
				} else if (getTrim(txt) == 2) {
					alert("Não foi possível enviar a mensagem.");
				} else {
					alert("Não foi possível enviar a mensagem.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarMacrodelegacia(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-macrodelegacia.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - Macrodelegacia não encontrada.
				   * 1 - Mensagem enviada com sucesso.
				   * 2 - Não foi possível enviar a mensagem.
				   * 3 - Não foi possível enviar a mensagem.
				   **/
				if (getTrim(txt) == 0) {
					alert("Macrodelegacia não encontrada.");
					document.getElementById("mac_macrodelegacia").focus();
				} else if (getTrim(txt) == 1) {
					alert("Mensagem enviada com sucesso.");
					document.getElementById(form).reset();
				} else if (getTrim(txt) == 2) {
					alert("Não foi possível enviar a mensagem.");
				} else if (getTrim(txt) == 3) {
					alert("Não foi possível enviar a mensagem.");
				} else {
					alert("Não foi possível enviar a mensagem.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarCurso(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-curso.php",
			data: str,
			success: function(txt) {
				$("#div-curso-selecionado").html(txt);
			}
		});
	}
}

/**
  * Função monta caixa de seleção
  * @param div DIV
  * @param id Identificador
  * @return nada
  **/
function montaCaixa(div, id) {
	$.ajax({
		type: "POST",
		url: "lib/acao-monta-caixa.php",
		data: 	"" + "div=" + div + "&" + "id=" + id + "&" + "",
		success: function(txt) {
			$("#" + div).html(txt);
		}
	});
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarCurriculo(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-curriculo.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - E-mail já cadastrado.
				   * 1 - Cadastro realizado com sucesso.
				   * 2 - Cadastro alterado com suceso.
				   * 3 - Não foi possível realizar o cadastro.
				   * 4 - Data de Nascimento inválida.
				   * 5 - Data admissão (Empresa 01) inválida.
				   * 6 - Data de saída (Empresa 01) inválida.
				   * 7 - Data admissão (Empresa 02) inválida.
				   * 8 - Data de saída (Empresa 02) inválida.
				   * 9 - Data admissão (Empresa 03) inválida.
				   * 10 - Data de saída (Empresa 03) inválida.
				   **/
				if (getTrim(txt) == 0) {
					alert("E-mail já cadastrado.");
				} else if (getTrim(txt) == 1) {
					alert("Cadastro realizado com sucesso.");
					document.getElementById(form).reset();
					window.location = "index.php?cmd=bolsa-de-oportunidades";
				} else if (getTrim(txt) == 2) {
					alert("Cadastro alterado com suceso.");
					document.getElementById(form).reset();
					window.location = "index.php?cmd=bolsa-de-oportunidades";
				} else if (getTrim(txt) == 3) {
					alert(" Não foi possível realizar o cadastro.");
					document.getElementById(form).reset();
				} else if (getTrim(txt) == 4) {
					alert("Data de Nascimento inválida.");
					document.getElementById("dt_nascimento").focus();
				} else if (getTrim(txt) == 5) {
					alert("Data admissão (Empresa 01) inválida.");
					document.getElementById("dt_empresa_admissao1").focus();
				} else if (getTrim(txt) == 6) {
					alert("Data de saída (Empresa 01) inválida.");
					document.getElementById("dt_empresa_saida1").focus();
				} else if (getTrim(txt) == 7) {
					alert("Data admissão (Empresa 02) inválida.");
					document.getElementById("dt_empresa_admissao2").focus();
				} else if (getTrim(txt) == 8) {
					alert("Data de saída (Empresa 02) inválida.");
					document.getElementById("dt_empresa_saida2").focus();
				} else if (getTrim(txt) == 9) {
					alert("Data admissão (Empresa 03) inválida.");
					document.getElementById("dt_empresa_admissao3").focus();
				} else if (getTrim(txt) == 10) {
					alert("Data de saída (Empresa 03) inválida.");
					document.getElementById("dt_empresa_saida3").focus();
				} else {
					alert("Não foi possível realizar o cadastro.");
					document.getElementById(form).reset();
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarCurriculoLogin(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-curriculo-login.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - E-mail ou senha Inválidos.
				   * 1 - Login efetuado com sucesso.
				   **/
				if (getTrim(txt) == 0) {
					alert("E-mail ou senha Inválidos.");
				} else if (getTrim(txt) == 1) {
					window.location = "index.php?cmd=bolsa-de-oportunidades&bolsa=cadastrar-curriculo";
				} else {
					alert("Não foi possível realizar o login.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarCurriculoRecuperaSenha(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-curriculo-senha.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - E-mail Inválido.
				   * 1 - Senha recuperada com sucesso.
				   **/
				if (getTrim(txt) == 0) {
					alert("E-mail Inválido.");
				} else if (getTrim(txt) == 1) {
					alert("Verifique seu e-mail para obter sua nova senha.");
					window.location = "index.php?cmd=bolsa-de-oportunidades&bolsa=alterar-curriculo";
				} else {
					alert("Não foi possível recuperar sua senha, tente novamente.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarVaga(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-curriculo-vaga.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - Não foi possível realizar o cadastro.
				   * 1 - Cadastro alterado com suceso.
				   **/
				if (getTrim(txt) == 0) {
					alert("Não foi possível realizar o cadastro.");
				} else if (getTrim(txt) == 1) {
					alert("Cadastro realizado com suceso.");
					window.location = "index.php?cmd=bolsa-de-oportunidades";
				} else {
					alert("Não foi possível realizar o cadastro.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function abrirPop(url, tam1, tam2) {
	window.open(url, "pop-cadastros", "status=1, scrollbars=0, width=" + tam1 + ", height=" + tam2 + "");
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarSolicitarSenha(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-form-solicitar-senha.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - Não foi possível realizar o cadastro.
				   * 1 - Cadastro realizado com suceso.
				   **/
				if (getTrim(txt) == 0) {
					alert("Não foi possível realizar o cadastro.");
				} else if (getTrim(txt) == 1) {
					alert("Cadastro realizado com suceso.");
					document.getElementById(form).reset();
				} else {
					alert("Não foi possível realizar o cadastro.");
				}
			}
		});
	}
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarLicitacaoLogin(form) {
	if (validaForm(form)) {
		var str = $("#" + form).serialize();
		/*  */
		arr1 = str.split('&');
		arr2 = arr1[0].split('=');
		//alert(arr2[1]);
		/*  */
		$.ajax({
			type: "POST",
			url: "lib/acao-form-licitacao-login.php",
			data: str,
			success: function(txt) {
				/**
				   * 0 - CNPJ ou senha Inválidos.
				   * 1 - Login efetuado com sucesso.
				   * 2 - CNPJ inválido!
				   **/
				if (getTrim(txt) == 0) {
					alert("CNPJ ou senha Inválidos.");
				} else if (arr2[1] != "") {
					if (getTrim(txt) == arr2[1]) {
						window.location = "index.php?cmd=licitacao-detalhe&id="+arr2[1];
					}
				} else if (getTrim(txt) == 1) {
						window.location = "index.php?cmd=licitacao";
				} else if (getTrim(txt) == 2) {
					alert("CNPJ inválido!");
				} else {
					alert("Não foi possível realizar o login.");
				}
			}
		});
	}
}

/**
  * Função troca valores do formulário
  * @param nada
  * @return nada
  **/
function trocaValores(parametros) {
	var html = "";
	parametros = parametros.split("&");
	for (i in parametros) {
		dadosInput = parametros[i].split("=");
		html += '<input type="hidden" name="' + dadosInput[0] + '" id="' + dadosInput[0] + '" value="' + dadosInput[1] + '" />';
	};
	document.getElementById("div-servico-campos").innerHTML = html;
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarServicosOnline() {
	switch(document.getElementById("ser_nome").value) {

		// Acesso Público ao Cadastro do CRC
		case "1":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consulta_simplesv03.dll/login";
			url = "Modo=Visitante&Estado=WW&OrigemLg=Principal&Origem=Principal&TpCad=Prof&Tipo=MenuInicial";
			trocaValores(url);
		break;
		case "2":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consulta_simplesv03.dll/login";
			url = "Modo=Visitante&Estado=WW&OrigemLg=Principal&Origem=Principal&TpCad=Escr&Tipo=MenuInicial";
			trocaValores(url);
		break;
		case "3":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consulta_simplesv03.dll/login";
			url = "Modo=Visitante&Estado=WW&OrigemLg=Principal&Origem=Principal&TpCad=EscrInd&Tipo=MenuInicial";
			trocaValores(url);
		break;

		// Acesso Restrito ao Cadastro do CRC
		case "4":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=Cadastrado&TpUsu=Prof&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Cadastro&TpCad=Prof&Tipo=Formulario&TipoDestino=Formulario";
			trocaValores(url);
		break;
		case "5":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=Cadastrado&TpUsu=Escr&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Cadastro&TpCad=Escr&Tipo=Formulario&TipoDestino=Formulario";
			trocaValores(url);
		break;
		case "6":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=Cadastrado&TpUsu=EscrInd&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Cadastro&TpCad=EscrInd&Tipo=Formulario&TipoDestino=Formulario";
			trocaValores(url);
		break;
		case "7":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=NCadastrado&TpUsu=NCadastrado&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Cadastro&TpCad=Prof&Tipo=Grid&TipoDestino=Grid";
			trocaValores(url);
		break;

		// Atualizar Cadastro
		case "8":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=Cadastrado&TpUsu=Prof&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Principal&TpCad=Prof&Tipo=ALTEnderecoASPX&TipoDestino=ALTEnderecoASPX";
			trocaValores(url);
		break;
		case "9":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=Cadastrado&TpUsu=Prof&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Principal&TpCad=Prof&Tipo=ALTTelefoneASPX&TipoDestino=ALTTelefoneASPX";
			trocaValores(url);
		break;
		case "10":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=Cadastrado&TpUsu=Prof&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Principal&TpCad=Prof&Tipo=ALTEmailASPX&TipoDestino=ALTEmailASPX";
			trocaValores(url);
		break;

		// Solicitação de Registro
		case "11":
			acao = "http://cadastro2.crcsc.org.br:8080/spw/fichacadastral/crc/";
			url = "";
			trocaValores(url);
		break;

		// Registro Secundário
		case "12":
			acao = "http://189.112.51.170/spw/secundario/inicio.aspx?codigo=1&url=cadastro2.crcsc.org.br:8080/spw/ConsultaMenu/consultaMENU.aspx&estado=SC";
			url = "";
			trocaValores(url);
		break;
		case "13":
			acao = "http://189.112.51.170/spw/secundario/inicio.aspx?codigo=1&url=cadastro2.crcsc.org.br:8080/spw/ConsultaMenu/consultaMENU.aspx&estado=SC";
			url = "";
			trocaValores(url);
		break;
		case "14":
			acao = "http://189.112.51.170/spw/secundario/inicio.aspx?codigo=1&url=cadastro2.crcsc.org.br:8080/spw/ConsultaMenu/consultaMENU.aspx&estado=SC";
			url = "";
			trocaValores(url);
		break;
		case "15":
			acao = "http://189.112.51.170/spw/secundario/inicio.aspx?codigo=1&url=cadastro2.crcsc.org.br:8080/spw/ConsultaMenu/consultaMENU.aspx&estado=SC";
			url = "";
			trocaValores(url);
		break;

		// DECORE/DHP Eletrônica
		case "16":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/SQL_dhpv03.dll/login";
			url = "Cv=&SCv=&Modo=&TpUsu=&Estado=WW&Origem=Principal&TipoRegistro=1&TipoRequisicao=1&Acao=1&IDFormReq=1";
			trocaValores(url);
		break;

		// Certificado de Habilitação (Sociedade)
		case "17":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/SQL_dhpv03.dll/login";
			url = "Cv=&SCv=&Modo=CADASTRADO&TpUsu=2&Estado=WW&Origem=Principal&TipoRegistro=2&TipoRequisicao=1&Acao=1&IDFormReq=1";
			trocaValores(url);
		break;

		// Certidões
		case "18":
			acao = "http://cadastro2.crcsc.org.br:8080/SPW/crpentrada_mod01.htm";
			url = "";
			trocaValores(url);
		break;
		case "19":
			acao = "http://cadastro2.crcsc.org.br:8080/SPW/crpentrada_mod02.htm";
			url = "";
			trocaValores(url);
		break;
		case "20":
			acao = "http://cadastro2.crcsc.org.br:8080/SPW/crpentrada_mod03.htm";
			url = "";
			trocaValores(url);
		break;
		case "21":
			acao = "http://189.112.51.170/spw/secundario/inicio.aspx?codigo=1&url=cadastro2.crcsc.org.br:8080/spw/ConsultaMenu/consultaMENU.aspx&estado=SC";
			url = "";
			trocaValores(url);
		break;
		case "22":
			acao = "http://189.112.51.170/spw/secundario/inicio.aspx?codigo=1&url=cadastro2.crcsc.org.br:8080/spw/ConsultaMenu/consultaMENU.aspx&estado=SC";
			url = "";
			trocaValores(url);
		break;
		case "23":
			acao = "http://189.112.51.170/spw/secundario/inicio.aspx?codigo=1&url=cadastro2.crcsc.org.br:8080/spw/ConsultaMenu/consultaMENU.aspx&estado=SC";
			url = "";
			trocaValores(url);
		break;
		
		// Alvarás
		case "24":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=Cadastrado&TpUsu=Escr&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Principal&TpCad=Escr&Tipo=crp&TipoDestino=crp&Rt=31&TipoCRP=5";
			trocaValores(url);
		break;
		case "25":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_consultav03.dll/login";
			url = "Modo=Cadastrado&TpUsu=EscrInd&AcaoLg=Lg01&Estado=WW&OrigemLg=Principal&Origem=Principal&TpCad=EscrInd&Tipo=crp&TipoDestino=crp&Rt=31&TipoCRP=6";
			trocaValores(url);
		break;
		
		// Confirmar Veracidade
		case "26":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/SQL_dhpv03.dll/login";
			url = "Cv=&SCv=&Modo=&TpUsu=&Estado=WW&Origem=Principal&TipoRegistro=1&TipoRequisicao=60&Acao=2&IDFormReq=1";
			trocaValores(url);
		break;
		case "27":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_servicosv03.dll/login";
			url = "Cv=&Modo=Visitante&TpUsu=Visitante&TpCad=Prof&Tipo=NumCRP&Estado=WW&Or=CRC&OrigemLg=Principal&Origem=Principal&Versao=NOVA";
			trocaValores(url);
		break;
		case "28":
			acao = "http://189.112.51.170/spw/secundario/inicio.aspx?codigo=2&url=cadastro2.crcsc.org.br:8080/spw/ConsultaMenu/consultaMENU.aspx&estado=SC";
			url = "";
			trocaValores(url);
		break;
		case "29":
			acao = "http://cadastro2.crcsc.org.br:8080/scripts/sql_servicosv03.dll/login";
			url = "&Cv=&Modo=Visitante&TpUsu=Visitante&TpCad=Prof&Tipo=NumCRP&Estado=WW&Or=CRC&OrigemLgPrincipal&OrigemPrincipal&Versao=NOVA";
			trocaValores(url);
		break;

		// Padrão
		default:
			alert("Selecione o serviço online.");
			return false;
		break;
	}
	document.getElementById("form-servico-online").action = acao;
	document.getElementById("form-servico-online").target = "_blank";
	document.getElementById("form-servico-online").submit();
	document.getElementById("form-servico-online").reset();
	document.getElementById("div-servico-campos").innerHTML = "";
	return false;
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarLicitacaoLembrarSenha(form) {
	if (document.getElementById("lem_cnpj").value == "") {
		alert("Digite o CNPJ");
		return false;
	}
	var str = $("#" + form).serialize();
	$.ajax({
		type: "POST",
		url: "lib/acao-form-licitacao-lembrar-senha.php",
		data: str,
		success: function(txt) {
			/**
			   * 0 - CNPJ ou senha Inválidos.
			   * 1 - Login efetuado com sucesso.
			   * 2 - CNPJ inválido!
			   **/
			if (getTrim(txt) == 0) {
				alert("CNPJ inválido.");
			} else if (getTrim(txt) == 1) {
				alert("Senha alterada com sucesso.");
			} else if (getTrim(txt) == 2) {
				alert("Não foi possível enviar o e-mail.");
			} else if (getTrim(txt) == 3) {
				alert("CNPJ não confere.");
			} else {
				alert("Não foi possível lembrar sua senha.");
			}
		}
	});	
}

/**
  * Função validar
  * @param nada
  * @return nada
  **/
function validarComPost(form) {
	validarComPostFacebox(form,false);
}

/**
  * Função validar
  * @param form: id do form
  * @return nada
  **/
function validarComPostFacebox(form,fechar) {
	if (validaForm(form)) {
		switch(form){
			case 'form-avaliar-medico':
				pagina = "index.php?cmd=avaliar-medico-2";
			break;
			default:
				pagina = "";
			break;
		}
		var str = $("#" + form).serialize();
		$.ajax({
			type: "POST",
			url: "lib/acao-" + form + ".php",
			data: str,
			beforeSend: function() {
			},
			success: function(txt) {
				arr = txt.split("<!-- SEPARADOR -->");
				erroCod = getTrim(arr[0]);
				erroMsg = getTrim(arr[1]);
				if (erroCod == "0") {
					alert(erroMsg);
				} else {
					if ((erroCod == 1) || (erroCod == "ok")) {
						if(erroMsg != "" && erroMsg != "undefined"){
							alert(erroMsg);
						}
						document.getElementById(form).reset();
						if(fechar){
							$.facebox.close();
						}
						if(pagina != "" ){
							window.location = pagina;
						}
					} else {
						if(erroMsg != "" && erroMsg != "undefined"){
							alert(erroMsg);
						}else{
							alert(erroCod);
						}
					}
				}
			},
			error: function(txt) {
				alert("Erro: " + txt);
			}
		});
	}
}
/**
  * Função validar
  * @param form: id do form
  * @return nada
  **/
function buscaNome(form) {
	var str = $("#" + form).serialize();
	$.ajax({
		type: "POST",
		url: "lib/acao-" + form + "-nome.php",
		data: str,
		beforeSend: function() {
		},
		success: function(txt) {
			arr = txt.split("<!-- SEPARADOR -->");
			erroCod = getTrim(arr[0]);
			erroMsg = getTrim(arr[1]);
			if (erroCod == "0") {
				$('#nome_crc').val(erroMsg);
			} else {
				if ((erroCod == 1) || (erroCod == "ok")) {
					$('#nome_crc').val(erroMsg);
				} else {
					if(erroMsg != "" && erroMsg != "undefined"){
//						alert(erroMsg);
					}else{
//						alert(erroCod);
					}
				}
			}
		},
		error: function(txt) {
			alert("Erro: " + txt);
		}
	});
}
