﻿//var cApoio = document.getElementById("apoio").getElementsByTagName("A");
var iApoio = 0
var timeoutId;

function valida_cpf(cpf) {
	var numeros, digitos, soma, i, resultado, digitos_iguais;
	digitos_iguais = 1;
	if (cpf.length < 11)
		return false;
	for (i = 0; i < cpf.length - 1; i++)
		if (cpf.charAt(i) != cpf.charAt(i + 1)) {
			digitos_iguais = 0;
			break;
		}
	if (!digitos_iguais) {
		numeros = cpf.substring(0, 9);
		digitos = cpf.substring(9);
		soma = 0;
		for (i = 10; i > 1; i--)
			soma += numeros.charAt(10 - i) * i;
		resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
		if (resultado != digitos.charAt(0))
			return false;
		numeros = cpf.substring(0, 10);
		soma = 0;
		for (i = 11; i > 1; i--)
			soma += numeros.charAt(11 - i) * i;
		resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
		if (resultado != digitos.charAt(1))
			return false;
		return true;
	}
	else
		return false;
}

function inscricoes(obj, div) {
	if (obj.innerHTML == "+") {
		obj.innerHTML = "&ndash;";
		document.getElementById(div).className = "op";
		ativarCampos(div);
	} else {
		obj.innerHTML = "+";
		document.getElementById(div).className = "op off";
		desativarCampos(div);
	}
}

function ativarCampos(div) {
	switch (div) {
		case "part_01":
			document.getElementById("ctl00_body_txtCPFParticipante04").disabled = false;
			document.getElementById("ctl00_body_txtNomeParticipante04").disabled = false;
			document.getElementById("ctl00_body_txtEmailParticipante04").disabled = false;
			document.getElementById("ctl00_body_ddlIESParticipante04").disabled = false;
			document.getElementById("ctl00_body_ddlCursoParticipante04").disabled = false;
			document.getElementById("ctl00_body_hfParticipante04").value = "1";


			break;
		case "part_02":
			document.getElementById("ctl00_body_txtCPFParticipante05").disabled = false;
			document.getElementById("ctl00_body_txtNomeParticipante05").disabled = false;
			document.getElementById("ctl00_body_txtEmailParticipante05").disabled = false;
			document.getElementById("ctl00_body_ddlIESParticipante05").disabled = false;
			document.getElementById("ctl00_body_ddlCursoParticipante05").disabled = false;
			document.getElementById("ctl00_body_hfParticipante05").value = "1";

			break;
	}
}

function desativarCampos(div) {
	switch (div) {
		case "part_01":
			document.getElementById("ctl00_body_txtCPFParticipante04").disabled = true;
			document.getElementById("ctl00_body_txtNomeParticipante04").disabled = true;
			document.getElementById("ctl00_body_txtEmailParticipante04").disabled = true;
			document.getElementById("ctl00_body_ddlIESParticipante04").disabled = true;
			document.getElementById("ctl00_body_ddlCursoParticipante04").disabled = true;
			document.getElementById("ctl00_body_hfParticipante04").value = "0";

			break;
		case "part_02":
			document.getElementById("ctl00_body_txtCPFParticipante05").disabled = true;
			document.getElementById("ctl00_body_txtNomeParticipante05").disabled = true;
			document.getElementById("ctl00_body_txtEmailParticipante05").disabled = true;
			document.getElementById("ctl00_body_ddlIESParticipante05").disabled = true;
			document.getElementById("ctl00_body_ddlCursoParticipante05").disabled = true;
			document.getElementById("ctl00_body_hfParticipante05").value = "0";

			break;
	}
}

function giraApoio() {
	/*
	clearTimeout(timeoutId);
	for (var i = 0; i < cApoio.length; i++) {
		if (i == iApoio)
			cApoio[i].style.display = 'block';
		else
			cApoio[i].style.display = 'none';
	}
	iApoio++;
	if (iApoio == cApoio.length) iApoio = 0;

	timeoutId = setTimeout(giraApoio, 3000);
	*/
}
