
  var voto,texto
  voto=0
  texto=""
  function sendenquete(wenq,opt,pergunta)
  {
   if (opt != 0){
     voto=opt;
   }
   if (voto != 0){
     var base = document.getElementsByTagName('BASE');
     if(base != null){
//       window.open(base[0].href+'SendEnquete.asp?Enquete='+wenq+'&RespostaEnquete='+voto+'&pergunta='+pergunta+'&opcao='+texto,'Enquete','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=448,height=310');
       abreJanelaenquete(base[0].href+'SendEnquete.asp?Enquete='+wenq+'&RespostaEnquete='+voto+'&pergunta='+pergunta+'&opcao='+texto,457,340);
     }
     else{
//       window.open('../SendEnquete.asp?Enquete='+wenq+'&RespostaEnquete='+voto+'&pergunta='+pergunta+'&opcao='+texto,'Enquete','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=448,height=310');
       abreJanelaenquete('../SendEnquete.asp?Enquete='+wenq+'&RespostaEnquete='+voto+'&pergunta='+pergunta+'&opcao='+texto,457,340);
     }

     }
   else
     alert('Selecione alguma opção para votar.');
  }

  function setavoto(opt,s)
  {
     voto=opt;
     texto=s;
  }

  function linkambiental()
  {
    var base = document.getElementsByTagName('BASE');
    if(base != null){
      calllink(base[0].href+'inhaltnav.asp?N=070801;0;nil&=');
    }
    else{
      calllink('../../inhaltnav.asp?N=070801;0;nil&=');
    }
  }

  function mostraresultado(wenq,pergunta)
  {
    var base = document.getElementsByTagName('BASE');
    if(base != null){
//      window.open(base[0].href+'enquete.asp?codenquete='+wenq+'&id=0&pergunta='+pergunta,'Enquete','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=468,height=320');
        abreJanelaenquete(base[0].href+'enquete.asp?codenquete='+wenq+'&id=0&pergunta='+pergunta,457,340)
    }
    else{
//      window.open('../enquete.asp?codenquete='+wenq+'&id=0&pergunta='+pergunta,'Enquete','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=468,height=320');
      abreJanelaenquete('../enquete.asp?codenquete='+wenq+'&id=0&pergunta='+pergunta,457,340)
    }
  }

  var bpassou = false;
  function calllink(pagina,target)
  {
//        alert(target);
    if(bpassou){
     // return false;
//        pagina='#';
    }
    if(pagina.indexOf("#") == -1){

      bpassou=true;
      var caminho;

      if (browser.isIE){
//        alert(target);
        if(target == null || target == ''){
          document.location.href=pagina;
        }
        else if(target.toLowerCase() == '_blank'){
          window.open(pagina);
        }
        else{
          document.location.href=pagina;
        }
      }else if (browser.isNS){
          //caminho = pagina.slice(pagina.indexOf('i'),pagina.length);
          caminho = pagina;

          if(target == null || target == ''){
            document.location.href=caminho;
          }
          else if(target.toLowerCase() == '_blank'){
            window.open(caminho);
          }
          else{
            document.location.href=caminho;
          }

      }else{
        
          //caminho = pagina.slice(pagina.indexOf('i'),pagina.length)
          caminho = pagina;

          if(target == null || target == ''){
            document.location.href=caminho;
          }
          else if(target.toLowerCase() == '_blank'){
            window.open(caminho);
          }
          else{
            document.location.href=caminho;
          }
      }


    }
  }

  function buscar(txtbusca,secao){
    if(txtbusca == null){
      txtbusca = document.forms[0].editsearch;
    }
    if(txtbusca.value == ''){
      alert('Campo de busca vazio.');
      txtbusca.focus();
    }else{
      var base = document.getElementsByTagName('BASE');
      if(secao != null){
        document.location.href=base[0].href+'Resultados.asp?secao='+secao.value+'&texto='+txtbusca.value;
      }
      else{
        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();


function getPonto(){
	var ponto='';
	var base = document.getElementsByTagName('BASE')[0].href.toString();
	var url = document.location.href;
	url=url.slice(base.length,url.length);
	var cont=0;
	for(var i=0;i<url.length;i++) {
		if(url.slice(i,i+1) == '/') {
			cont++;
		}
	}
	for(var i=1;i<=cont;i++) {
		ponto+='../';
	}
	return ponto;
}

function abreJanelaenquete(janela, largura, altura)
{
		winwidth = largura; // width of the new window 
		winheight = altura; // height of the new window 
		winleft   = 200; // just dummie values (nao alterar)
		wintop    = 200; // just dummie values (nao alterar)
  
		if (parseInt(navigator.appVersion)>=4){
			winleft = (screen.width / 2) - (winwidth / 2); // center the window right to left 
			wintop = (screen.height / 2) - (winheight / 2); // center the window top to bottom 
			// the values get inserted into the features parameter of the window.open command... 
		}
		window.open(janela, '_blank', 'scrollbars=yes,top=' + wintop + ',left=' + winleft + ',height=' + winheight + ',width=' + winwidth);  
}

