function abre(url,janela,larg,alt,scroll) {
    window.open(url, janela, "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars="+scroll+", resizable=no, copyhistory=no, width="+larg+", height="+alt);
}

function mOvr(src,clrOver) {
    src.style.cursor = 'hand';
    src.bgColor = clrOver;
}

function mOut(src,clrIn) {
    src.style.cursor = 'default';
    src.bgColor = clrIn;
}

function mClk(src) {
    if(event.srcElement.tagName=='TD') {
        src.children.tags('A')[0].click();
    }
}
function abrirPagina(nomeArq,frame) {
    window.open(nomeArq,frame);
}

function verificaUsuario() {
    with (document.formUsuario) {
         if (nome.value.length == 0) {
            alert('Por favor, preencha o campo nome');
            return false;
         }
         if (username.value.length == 0) {
            alert('Por favor, preencha o campo username');
            return false;
         }

         if (emailu.value.length == 0) {
            alert('Por favor, preencha o campo email');
            return false;
         }
         return true;
    }
}

function verificaProjeto() {
    with (document.formProjeto) {
        if (nome.value.length == 0) {
            alert('Por favor, preencha o campo nome');
            return false;
        }
        if (pasta.value.length == 0) {
            alert('Por favor, preencha o campo pasta');
            return false;
        }
        if (descricao.value.length == 0) {
            alert('Por favor, preencha o campo descrição');
            return false;
        }
        return true;
     }
}

function verificaSenha() {
     with (document.formSenha) {
        if (novasenha.value.length == 0) {
            alert('Por favor, preencha o campo senha');
            return false;
        }
        if (repetenovasenha.value.length == 0) {
            alert('Por favor, preencha o campo repetição de senha');
            return false;
        }
        if ((novasenha.value) != (repetenovasenha.value)) {
            alert('Campos nova senha e repete nova senha não conferem');
            return false;
        }
        return true;
     }
}

function verificaCliente() {
     with (document.formCliente) {
        if (descricao.value.length == 0) {
            alert('Por favor, preencha o campo nome');
            return false;
        }
        if (endereco.value.length == 0) {
            alert('Por favor, preencha o campo endereco');
            return false;
        }
        if (telefone.value.length == 0) {
            alert('Por favor, preencha o campo telefone');
            return false;
        }
        return true;
     }
}

function verificaUpload() {
    with (document.formUpload) {
        if (file.value.length == 0) {
            alert('Por favor, selecione um arquivo');
            return false;
        }
        mostraCarregando();
        return true;
    }
}

function verificaSubPasta() {
    with (document.formSubPasta) {
        if (subpasta.value.length == 0) {
            alert('Por favor, informe o nome da pasta');
            return false;
        }
        return true;
    }
}

function excluir(mensagem,pagina) {
    if(confirm(mensagem)) {
        window.open(pagina,"mainIFrame")
    }
}

function verificaEmail() {
    with (document.formEmail) {
        if (useremail.value.length == 0) {
            alert('Por favor, preencha o campo nome do usuário');
            return false;
        }
        if (senha.value.length == 0) {
            alert('Por favor, preencha o campo senha');
            return false;
        }
        if (repetesenha.value.length == 0) {
            alert('Por favor, preencha o campo repete senha');
            return false;
        }
        if ((senha.value) != (repetesenha.value)) {
            alert('Campos senha e repete senha não conferem');
            return false;
        }
        return true;
    }
}

function verificaContato() {
    with (document.formContato) {
        if (nome.value.length == 0) {
            alert('Por favor, preencha o campo nome');
            return false;
        }
        if (email.value.length == 0) {
            alert('Por favor, preencha o campo email');
            return false;
        }
        if (assunto.value.length == 0) {
            alert('Por favor, preencha o campo assunto');
            return false;
        }
        if (mensagem.value.length == 0) {
            alert('Por favor, preencha o campo mensagem');
            return false;
        }
        return true;
    }
}

function verificaLogar() {
    with (document.formLogar) {
        if (username.value.length == 0) {
            alert('Por favor, preencha o campo username');
            return false;
        }
        if (senha.value.length == 0) {
            alert('Por favor, preencha o campo senha');
            return false;
        }
        return true;
    }
}

function verificaCalendario() {
    with (document.formCalendario) {
        if (anoInicio.value.length == 0) {
            alert('Por favor, preencha o ano do campo Data de Início');
            return false;
        }
        if (anoFim.value.length == 0) {
            alert('Por favor, preencha o ano do campo Data de Fim');
            return false;
        }
        if (descricao.value.length == 0) {
            alert('Por favor, preencha o campo descricao');
            return false;
        }
        return true;
    }
}

function desabilitaCheck(valor) {
    with(document.formCalendario) {
        for(i=0;i<elements.length;i++) {
            thiselm = elements[i];
            if(thiselm.name.substring(0,10) == 'chkUsuario')
                thiselm.disabled = valor
        }
    }
}

function marcaCheck(valor) {
    with(document.formNotificacao) {
        for(i=0;i<elements.length;i++) {
            thiselm = elements[i];
            if(thiselm.type == "checkbox")
                thiselm.checked = valor;
        }
    }
}

function verificaNotificacao() {
    with(document.formNotificacao) {
        if (assunto.value.length == 0) {
            alert('Por favor, preencha o campo assunto');
            return false;
        }
        if (conteudo.value.length == 0) {
            alert('Por favor, preencha o campo conteúdo');
            return false;
        }
        marcou = false;
        for(i=0;i<elements.length;i++) {
            thiselm = elements[i];
            if(thiselm.type== "checkbox")
                if (thiselm.checked == true)
                    marcou = true;
        }
        if (marcou == false) {
            alert('Por favor, selecione algum usuário para enviar a notificação');
            return false;
        }
        return true;
    }
}

function mostraCarregando() {
    document.images.item(0).style.visibility = "visible";
}

function ocultaLinhasTabela (primeiraLinha, ultimaLinha, nomeTabela) {
    var table = document.getElementById(nomeTabela) ? document.getElementById(nomeTabela) : document.all.nomeTabela;
    for (var r = primeiraLinha; r < ultimaLinha; r++) {
        if (table.rows[r].style.display == 'none')
            table.rows[r].style.display = '';
        else
            table.rows[r].style.display = 'none';
    }
}

function ocultaDiv () {
    var selectClientes = document.formUsuario.clientes;
    for (i=0;i<selectClientes.length;i++) {
        document.getElementById(selectClientes[i].value).style.display = 'none';
    }
    indice = selectClientes[selectClientes.selectedIndex].value;
    document.getElementById(indice).style.display = '';
}
function ocultaDivCliente (idPerfil) {

    if (idPerfil == 1) {
       document.getElementById('lblCliente').style.display = 'none';
       document.getElementById('selectCliente').style.display = 'none';
       document.getElementById('clientesProjetos').style.display = 'none';
    }
    else if (idPerfil == 2) {
       document.getElementById('lblCliente').style.display = 'none';
       document.getElementById('selectCliente').style.display = 'none';
       document.getElementById('clientesProjetos').style.display = '';
       document.getElementById('clientes').style.display = '';
       indice = selectClientes[selectClientes.selectedIndex].value;
       document.getElementById(indice).style.display = 'none';
    }
    else {
         document.getElementById('lblCliente').style.display = '';
         document.getElementById('selectCliente').style.display = '';
         document.getElementById('clientesProjetos').style.display = '';
         document.getElementById('clientes').style.display = 'none';
         indice = selectClientes[selectClientes.selectedIndex].value;
         document.getElementById(indice).style.display = '';
    }
}


