$(document).ready(function() {
    $('.nyroModal').nyroModal();
});

function formatText(index, panel) {
    return index + "";
}

function trim(str) {
    return str.replace(/^\s+|\s+$/g,"");
}

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 checarFale(theForm) {

    var Aviso = "Senepol Įgua Limpa                  \n\nAviso\n\n";
    
    if (trim(theForm.nome.value) == "" ) {
            alert(Aviso+"Informe o Nome Completo.         ");
            theForm.nome.focus();
            return (false);
    }

    if (!checkMail(trim(theForm.email.value))) {
        alert(Aviso+"Informe o seu Email corretamente.         ");
        theForm.email.focus();
        return (false);
    }

    if (trim(theForm.mensagem.value) == "" ) {
            alert(Aviso+"Digite a sua Mensagem.         ");
            theForm.mensagem.focus();
            return (false);
    }

    if (trim(theForm.code.value) == "" ) {
            alert(Aviso+"Informe os Caracteres para continuar.         ");
            theForm.code.focus();
            return (false);
    }

    theForm.submit;
}
