%STARTINCLUDE%
<script type="text/javascript" src="%ATTACHURL%/jquery.js"></script>
<script type="text/javascript">
$("document").ready(function(){
var opcoes = [0,0,0,0,0];
var cont = 1;
function seleciona (it) {
if (opcoes[it] == 0) {
opcoes[it] = cont;
} else {
opcoes[it] = 0;
}
cont = 1;
for (var i = 0; i < 5; i++) {
if (opcoes[i] != 0)
cont++;
}
for (var i = 1; i <= cont; i++) { //pra cada uma das opções selecionadas
var menor = 5;
for (var j = 0; j < 5; j++) { //encontra a menor
if (opcoes[j] >= i) {
if ((menor == 5) || (opcoes[j] < opcoes[menor])) {
menor = j;
}
}
}
opcoes[menor] = i;
}
for (var i = 0; i < 5; i++) {
$(".mostrador:eq("+ i +")").html(opcoes[i]);
}
}
$("#inscricao :checkbox").click(function(){
if ($(this).attr("id") == "o1") {
seleciona(0);
} else if ($(this).attr("id") == "o2") {
seleciona(1);
} else if ($(this).attr("id") == "o3") {
seleciona(2);
} else if ($(this).attr("id") == "o4") {
seleciona(3);
} else if ($(this).attr("id") == "o5") {
seleciona(4);
}
/*var of = $(this).attr("id");
$("#inscricao #oficinas").attr("value",
$("#inscricao #oficinas").attr("value") + of
);*/
});
//preenchimento do formulario
$("#inscricao :submit").click(function(){
var ordemOficinas = "\n";
for (var i = 1; i <= 5; i++) {
ordemOficinas += "\n" + "Oficina " + i + ": " + opcoes[i-1];
}
$("#inscricao textarea").attr("value",
"Nome: " + $("#inscricao #nome").attr("value") + "\n" +
"E-mail: " + $("#inscricao #from").attr("value") + "\n" +
"CPF: " + $("#inscricao #cpf").attr("value") + "\n" +
"Endereço: " + $("#inscricao #endereco").attr("value") + "\n" +
"Telefones: " + $("#inscricao #telefones").attr("value") + "\n" +
"Instituto e curso de origem: " + $("#inscricao #instituto").attr("value") + "\n" +
"Formação: " + $("#inscricao #formacao").attr("value") + "\n" +
"Observações: " + $("#inscricao #observacoes").attr("value") + "\n" +
"Oficinas: " + ordemOficinas + "\n"
);
});
$("#conteudo [href*='http://']").attr("target", "_blank");
$("#conteudo [href*='https://']").attr("target", "_blank");
$("[href*='.pdf']").attr("target", "_blank");
});
</script>
%STOPINCLUDE%