function noticias() {
    //verifica se o browser tem suporte a ajaxNoti
    try {
        ajaxNoti = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e) {
        try {
            ajaxNoti = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(ex) {
            try {
                ajaxNoti = new XMLHttpRequest();
            }
            catch(exc) {
                alert("Esse browser não tem recursos para uso do ajaxNoti");
                ajaxNoti = null;
            }
        }
    }

    //se tiver suporte ajaxNoti
    if(ajaxNoti) {
        //deixa apenas o elemento 1 no option, os outros são excluídos
        // document.formulario.idEstado.options.length = 1;
        //document.formulario.idCidade.options.length = 1;

        div_mensagem  = document.getElementById("mensagem");

        ajaxNoti.open("POST", "/require/noticias/pesquisa-noticias.php", true);
        ajaxNoti.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

        ajaxNoti.onreadystatechange = function() {
            //enquanto estiver processando...emite a mensagem de carregando
            if(ajaxNoti.readyState == 1) {
                div_mensagem.innerHTML = "carregando ..";
            }
            //após ser processado - chama função processXML que vai varrer os dados
            if(ajaxNoti.readyState == 4 ) {
                if(ajaxNoti.responseXML) {
                    processXmlNoti(ajaxNoti.responseXML);
                }
                else {
            //caso não seja um arquivo XML emite a mensagem abaixo
            // mensagem.innerHTML = "Primeiro Selecione o País";
            }
            }
        }
        //passa o código do estado escolhido
        // var params = "idPais="+valor;
        ajaxNoti.send(null);
    }
}

function processXmlNoti(obj){
    //pega a tag cidade
    var dataArray   = obj.getElementsByTagName("noticia");

    div_mensagem.style.display = 'none';

    //total de elementos contidos na tag cidade
    if(dataArray.length > 0) {


        document.getElementById('qtdNoticias').value = dataArray.length;


        //percorre o arquivo XML paara extrair os dados
        for(var i = 0 ; i < dataArray.length ; i++) {
            var item = dataArray[i];
            //contéudo dos campos no arquivo XML
            var posicaoNotiEmpr     = item.getElementsByTagName("posicaoNotiEmpr")[0].firstChild.nodeValue;
            var urlNoticiaEmpr          = item.getElementsByTagName("urlNoticiaEmpr")[0].firstChild.nodeValue;
            var nomeNotiEmpr        = item.getElementsByTagName("nomeNotiEmpr")[0].firstChild.nodeValue;
            var descricaoNotiEmpr   = item.getElementsByTagName("descricaoNotiEmpr")[0].firstChild.nodeValue;
            var urlFotoNotiEmpr         = item.getElementsByTagName("urlFotoNotiEmpr")[0].firstChild.nodeValue;

            document.getElementById('urlNoticia['+posicaoNotiEmpr+']').innerHTML = urlNoticiaEmpr;

            document.getElementById('nomeNotiEmpr['+posicaoNotiEmpr+']').innerHTML = nomeNotiEmpr;
            document.getElementById('nomeNotiEmpr['+posicaoNotiEmpr+']').style.fontWeight ='bold';

            //document.getElementById('nomeNotiEmpr['+posicaoNotiEmpr+']').style.fontSize ='29';

            document.getElementById('descricaoNotiEmpr['+posicaoNotiEmpr+']').innerHTML = descricaoNotiEmpr;
            document.getElementById('descricaoNotiEmpr['+posicaoNotiEmpr+']').style.fontStyle ='italic';
            document.getElementById('descricaoNotiEmpr['+posicaoNotiEmpr+']').style.color ='#555';

            document.getElementById('urlFotoNotiEmpr['+posicaoNotiEmpr+']').style.backgroundImage = "url("+urlFotoNotiEmpr+")";
            document.getElementById('noticia['+posicaoNotiEmpr+']').style.display ='block';

       
        }

        alternaNoticia(0, null, false);
    }
    else {
//caso o XML volte vazio, printa a mensagem abaixo
//mensagem.innerHTML = "Primeiro Selecione o País";
}
}

