
function buscarNoticia(doc){
 var obj = doc.getElementById("tdLocNoticia");
    obj.innerHTML='Painel de Notícia > buscar';
    ajax('noticia/buscarNoticia.jsp', 'conteudoNoticia');
}

function cadastrarNoticia(doc){
 var obj = doc.getElementById("tdLocNoticia");
    obj.innerHTML='Painel de Notícia > cadastrar';
    ajax('noticia/cadNoticia.jsp', 'conteudoNoticia');
}

function buscarCategoriaNoticia(doc){
 var obj = doc.getElementById("tdLocNoticia");
    obj.innerHTML='Painel de Categoria Notícia > buscar';
    ajax('categoriaNoticia/buscarCategoriaNoticia.jsp', 'conteudoCategoriaNoticia');
}

function cadastrarCategoriaNoticia(doc){
 var obj = doc.getElementById("tdLocNoticia");
    obj.innerHTML='Painel de Categoria Notícia > cadastrar';
    ajax('categoriaNoticia/cadCategoriaNoticia.jsp', 'conteudoCategoriaNoticia');
}

function verificaNoticia(form){
    
    var txt = form.chamadaNoticia.value;
    if (form.tituloNoticia.value == ''){
        alert('Insira um título para a notícia');
        return false;    
    }
    }


function verificaFoto(form){
    
    var txt = form.arquivo.value;
    if (form.tituloNoticia.value == ''){
        alert('Insira um arquivo');
        return false;    
    }
}


function listaNoticia(form){
    indice = form.categNoticia.selectedIndex;
    idcategorianoticia = form.categNoticia.value;
    ajax("noticia/listaNoticia.jsp?idCategoriaNoticia="+idcategorianoticia+"&tituloNoticia="+form.tituloNot.value,"conteudoBuscaNoticia");
    return false;
}

function excluirNoticia(idNoticia){
    if(confirm("Deseja excluir a notícia?")){
      ajax("noticia/deletarNoticia.jsp?idNoticia="+idNoticia,"conteudoNoticia");
    }  
}

function contCaracteres(objeto,limiteChar){
    var limite = limiteChar;
    var erro = "Você ultrapassou o limite de caracteres.";

    tamanho = objeto.value.length;
    if (tamanho>limite) {
        objeto.value = objeto.value.substring(0,limite);
        alert(erro);
    } else {
        document.getElementById('restantes').innerHTML = (limite-objeto.value.length);
    }
}

function carregaTipoChamada(form){

    var Radio = null;
    var trfoto = document.getElementById("trFoto");
    var trfotoinput = document.getElementById("trFotoInput");
    var trchamada = document.getElementById("trChamada");
    var trchamadatext = document.getElementById("trChamadaText");
    var chamada = document.getElementById("chamadaNoticia");
    var chamadaBanco = document.getElementById("chamadaBanco");
    Radio = form.radioNoticia;
    for(var i=0;i<Radio.length;i++) {
        if(Radio[i].checked) {
            if(Radio[i].id == "foto"){
                alert("ooi");
                trfoto.style.display = "block";
                trfotoinput.style.display = "block";
                trchamada.style.display = "none";
                trchamadatext.style.display = "none";
                chamada.value = chamadaBanco.value;
                contCaracteres(chamada,150);
            }else{
                trfoto.style.display = "none";
                trfotoinput.style.display = "none";
                trchamada.style.display = "block";
                trchamadatext.style.display = "block";
            }
        }
    }
    
}