  var voto
  voto=0

  var img = null;
  function getImgChild(el){
    for(var i=0;i<el.childNodes.length;i++){
      if(el.childNodes[i].tagName == 'SPAN'){
        getImgChild(el.childNodes[i]);
      }
      else if(el.childNodes[i].tagName == 'IMG'){
        img = el.childNodes[i].src;
      }
    }
  }
 
  function AbrirPopUp(secao,img) {
        var tagBase = document.getElementsByTagName("BASE")[0].href;
	janela = null;
	var window_width = 1024;
	var window_height = 768;
	var window_top = (screen.height-window_height)/2;
	var window_left = (screen.width-window_width)/2;
	popup = window.open(tagBase + 'popup/popup.asp?secao=' + secao + '&img=' + img,'popUp','width=' + window_width + ',height=' + window_height + ',,top=' + window_top + ',left=' + window_left + 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,leftmargin=0,border=0,topmargin=0,marginheight=0,marginwid=0').focus();
  }

  function sendenquete(wenq,opt)
  {
   if (opt != 0){
     voto=opt;
   }
   if (voto != 0){
     window.open('../SendEnquete.asp?Enquete='+wenq+'&RespostaEnquete='+voto,'Enquete','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=408,height=280');

     }
   else
     alert('Selecione alguma opção para votar.');
  }

  function setavoto(opt)
  {
     voto=opt;
  }

  function mostraresultado(wenq)
  {
    window.open('../enquete.asp?codenquete='+wenq+'&id=0','Enquete','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=408,height=280');
  }

  function calllink(pagina)
  {
//    alert(pagina);
    if (browser.isIE){
      document.location.href=pagina;
    }
    else{
      pagina=pagina.replace('../','').replace('../','').replace('../','').replace('../','').replace('../','').replace('../','').replace('../','').replace('../','');
  //    alert(pagina);
      document.location.href='http://www.imip.org.br/site/'+pagina;
    }
  }

  function buscar(txtbusca){
    if(txtbusca.value == ''){
      alert('Campo de busca vazio.');
      txtbusca.focus();
    }else{
      var base = document.getElementsByTagName('BASE');

      document.location.href=base[0].href+'/Resultados.asp?texto='+txtbusca.value;
    }
  }

  function chama(){
    if(event.keyCode == 13){
      buscar();
    }
  }


  function setAnchorPath(obj){

   var caminho_completo = document.location.toString();

   if(caminho_completo.indexOf("#") != -1){
     caminho_completo = caminho_completo.slice(0,caminho_completo.indexOf("#"));
   }

   if(obj.href.indexOf("#") != -1){
      for(var i=0;i<obj.href.length;i++){
        if(obj.href.slice(i,i+1) == "#"){
          obj.href = caminho_completo + obj.href.slice(i,obj.href.length);
        }
      }
   }
 }
  function showdiv(cod){
      var divs = document.getElementsByTagName('div');
      if(divs.length > 0){
        var idpai = cod;
        for(var i=0;i<divs.length;i++){
          if(divs[i].id.length == (idpai.length)+2){

//            alert(divs[i].id.toUpperCase()+'  >  '+idpai.toUpperCase()+ '  =  '+divs[i].id.toUpperCase().indexOf(idpai.toUpperCase()));

            if(divs[i].id.toUpperCase().indexOf(idpai.toUpperCase()) > -1){

              if(divs[i].style.display == ''){
                divs[i].style.display='none';
              }
              else{
                divs[i].style.display='';
              }
            }
          }
          else if(divs[i].id.length > idpai.length){  // mesmo entrando no if acima , este elseif é testado , oq está errado.. por isso , o mesmo if acima está repetido abaixo...
            if(divs[i].id.toUpperCase().indexOf(idpai.toUpperCase()) > -1){
              divs[i].style.display='none';
            }
          }


        }
      }
  }




  function Browser() {

  	var ua, s, i;

  	this.isIE	 = false;
  	this.isNS	 = false;
  	this.version = null;

  	ua = navigator.userAgent;

  	s = "MSIE";
  	if ((i = ua.indexOf(s)) >= 0) {
  		this.isIE = true;
  		this.version = parseFloat(ua.substr(i + s.length));
  		return;
  	}

  	s = "Netscape6/";
  	if ((i = ua.indexOf(s)) >= 0) {
  		this.isNS = true;
  		this.version = parseFloat(ua.substr(i + s.length));
  		return;
  	}

  	// Treat any other "Gecko" browser as NS 6.1.

  	s = "Gecko";
  	if ((i = ua.indexOf(s)) >= 0) {
  		this.isNS = true;
  		this.version = 6.1;
  		return;
  	}
  }

  var browser = new Browser();


