/**
* scripts do site...
*/
/*testar CPF*/
function TestaCPF(strCPF){
var Soma;
var Resto;
Soma = 0;
if (strCPF == "00000000000") return false;
for (i=1; i<=9; i++) Soma = Soma + parseInt(strCPF.substring(i-1, i)) * (11 - i);
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(strCPF.substring(9, 10)) ) return false;
Soma = 0;
for (i = 1; i <= 10; i++) Soma = Soma + parseInt(strCPF.substring(i-1, i)) * (12 - i);
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(strCPF.substring(10, 11) ) ) return false;
return true;
}
// Testando a validação usando jQuery
$(function(){
// Aciona a validação a cada tecla pressionada
var temporizador = false;
$('.CPF').keypress(function(){
// O input que estamos utilizando
var input = $(this);
// Limpa o timeout antigo
if (temporizador){
clearTimeout(temporizador);
}
// Cria um timeout novo de 500ms
temporizador = setTimeout(function(){
// Remove as classes de válido e inválido
input.removeClass('valido');
input.removeClass('invalido');
// O CPF ou CNPJ
var CPF = input.val();
// Valida
var valida = TestaCPF ( CPF );
// Testa a validação
if ( valida ) {
input.addClass('valido');
} else {
input.addClass('invalido');
}
}, 300);
});
});
$(document).ready(function() {
UR_Start();
$("input[name=NR_chip]").select();
$("select[name=ID_evento]").change(function(){
$("select[name=ID_etapa]").html('');
$.post("../scripts/etapas.php",
{ID_evento:$(this).val()},
function(valor){
$("select[name=ID_etapa]").html(valor);
}
)
})
$("select[name=ID_etapa]").change(function(){
$("select[name=ID_percurso]").html('');
$.post("../scripts/percursos.php",
{ID_evento:$("select[name=ID_evento]").val(), ID_etapa:$(this).val()},
function(valor){
$("select[name=ID_percurso]").html(valor);
}
)
})
});
function UR_Start() {
UR_Nu = new Date;
UR_Indhold = showFilled(UR_Nu.getHours()) + ":" + showFilled(UR_Nu.getMinutes()) + ":" + showFilled(UR_Nu.getSeconds());
document.getElementById("ur").innerHTML = UR_Indhold;
setTimeout("UR_Start()", 1000);
}
function showFilled(Value) {
return (Value > 9) ? "" + Value : "0" + Value;
}
function removeAcento(strToReplace) {
str_acento= "áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ ";
str_sem_acento = "aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC";
var newString="";
for (var i = 0; i < strToReplace.length; i++) {
if (str_acento.indexOf(strToReplace.charAt(i)) != -1) {
newString+=str_sem_acento.substr(str_acento.search(strToReplace.substr(i,1)),1);
} else {
newString+=strToReplace.substr(i,1);
}
}
return newString;
}