﻿    
    function p(indice){
     return document.forms[0].elements[indice];
    }
    
    function e(elemento){
     return document.getElementById(elemento);
    }
    
    function limpa(el){
      el = e(el);
       if(el.hasChildNodes()){
        while(el.hasChildNodes()){
         el.removeChild(el.childNodes[0]);
        }
       }
    }
    
    function adiciona(el,obj){
     try{
      e(el).insertBefore(obj);
     }catch(ex){
       e(el).insertBefore(obj,e(el).childNodes[0]);
     }
    } 
 


//Define em qual aba o navegador esta
aba = 1;


function boxNoticias(b){

el = document.getElementById("bnoticias"+b);
if(b!=aba){
for(x=1;x<=3;x++){
 n = document.getElementById("bnoticias"+x);
 if(b==x){
  el.setAttribute("src","../../imagens/home/BotaoNoticias"+b+"_On.gif");
 }else{
 n.setAttribute("src","../../imagens/home/BotaoNoticias"+x+"_Of.gif");
 }
}
boxHome(b);
 aba=b;
}else{}
}


//xml = "";


function boxHome(pag,id){
 limpa("boxNoticiasLista");
 carregando("boxNoticiasLista");

 var oHTTPRequest = createXMLHTTP(); 
 var el = document.getElementById("boxNoticiasLista");
 var pagina = Array(4);

    pagina[1] = "../../Frames/Home/Noticias.aspx";
    pagina[2] = "../../Frames/Home/Verbanews.aspx";
    pagina[3] = "../../Frames/Home/Artigos.aspx";
    pagina[4] = "../../Frames/Home/VerbanewsModulo.aspx?id="+id;
 
     oHTTPRequest.open("post", pagina[pag], true);
     oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 
	 if (oHTTPRequest.readyState!=4){
	  void(0);
	 }

     oHTTPRequest.onreadystatechange=function(){
      if (oHTTPRequest.readyState==4){
       limpa("boxNoticiasLista");
         try{
           boxNoticiasResultado = oHTTPRequest.responseText;

           if(boxNoticiasResultado.indexOf("<title>") < 0){
            el.innerHTML = boxNoticiasResultado;
            }else{
             el.innerHTML = "<a href='javascript:boxHome(2,0);'>Clique aqui para atualizar</a>";
            }
          }catch(ex){limpa("boxNoticiasLista");}
		    }
		 }
       oHTTPRequest.send("");
}