function checa_cpf(CPF)
{
//alert(CPF);
var mensagem = "informe corretamente o número do CPF"
var msg = true;
if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
  CPF == "22222222222" || CPF == "33333333333" || CPF == "44444444444" ||
  CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
  CPF == "88888888888" || CPF == "99999999999")
msg = false;
soma = 0;
for (y=0; y < 9; y ++)
soma += parseInt(CPF.charAt(y)) * (10 - y);
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11)resto = 0;
if (resto != parseInt(CPF.charAt(9)))
  msg = false; soma = 0;
for (y = 0; y < 10; y ++)
  soma += parseInt(CPF.charAt(y)) * (11 - y);
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11) resto = 0;
if (resto != parseInt(CPF.charAt(10)))
  msg = false;
return msg;
}

function checkMail(mail)
{
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
                }
    }else{
        return false;
        }
}

function validaForm(form)
{
    for (i=0;i<form.length;i++)
    {
        if ((form[i].value == "") || (form[i].value.substring(0,1)==" "))
        {
            var nome = form[i].name;
            alert('Favor preencher todos os campos!');
            form[i].select();
            form[i].focus();
            return false;
        }//if
    }//for
    if(!checkMail(document.getElementById('email').value))
    {
        alert("Digite um endereço de e-mail válido");
        document.getElementById('email').value = "";
        document.getElementById('email').focus();
        return false;
    }
    return true;
}//function


function valida(cd)
{
    var esquerda = ((screen.width - 425) / 2);
    var topo = ((screen.height - 350) / 2);
    var vai ="";
    var resp = document.getElementsByName('resp');
    var selecionada = false;
    for(cont=0; cont<resp.length; cont++)
    {
        if(resp[cont].checked)
        {
            selecionada = true;
            vai = resp[cont].value;
        }

    }
    if(!selecionada)
    {
        alert("Favor selecionar uma resposta");
        return false;
    }
    abre(vai);
    //alert(vai);
    return false;

}

function abre(url)
{
    var esquerda = ((screen.width - 345) / 2);
    var topo = ((screen.height - 350) / 2);
    window.open("enqresultado.php?acao=votar&resp="+url,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=345,height=350, top="+topo+", left="+esquerda);
}

function ver_resultados(url)
{
    var esquerda = ((screen.width - 345) / 2);
    var topo = ((screen.height - 350) / 2);
    window.open("enqresultado.php?acao=ver&enq="+url,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=345,height=350, top="+topo+", left="+esquerda);
}

function abre_jogos(url)
{
    var esquerda = ((screen.width - 640) / 2);
    var topo = ((screen.height - 480) / 2);
    window.open(url,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=640,height=480, top="+topo+", left="+esquerda);
}

function galeria(url)
{
    var esquerda = ((screen.width - 640) / 2);
    var topo = ((screen.height - 480) / 2);
    window.open("galeria-de-fotos.php?cd="+url,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=640,height=480, top="+topo+", left="+esquerda);
}
