// config da barra
var BarraNumero = 24;
var BarraCor1 = '#7F8DA8'; // cor clara
var BarraCor2 = '#667077'; // cor escura

/* scripts.js */
var UFCorrente="";
var idcidade="";
var turno1=((location.href.indexOf("1turno")>=0)?1:0);
var uf="";
var letra="";

/*Pega o estado corrente*/
if(turno1==1) UFCorrente=location.href.replace(/index\.jhtm/g,"").replace(/.*?\/2006\/placar\/1turno\/(..).*?$/g,"$1");
else UFCorrente=location.href.replace(/index\.jhtm/g,"").replace(/.*?\/2006\/placar\/(..).*?$/g,"$1");
if(UFCorrente.length>2)
  UFCorrente="";

// GetMethodParserJS ::: fermads @ uol ////
var L=location.href;
var d=L.substring(L.indexOf("?")+1);
var c=v=new Array(); c=d.split("&");
for(i=0;i<c.length&&c.length>0;i++) {
v=c[i].split("="); if(v.length>1)
eval(v[0]+"=unescape('"+v[1].replace(/\+/g," ")+"')");}

if(location.href.indexOf("cidades.jhtm")>=0) UFCorrente=uf;

function regiaoNome(codigo){
  r="";
  if(codigo=="CO") r="CENTRO-OESTE";
  else if(codigo=="NE") r="NORDESTE";
  else if(codigo=="N") r="NORTE";
  else if(codigo=="SE") r="SUDESTE";
  else if(codigo=="S") r="SUL";
  return "REGIÃO "+r;
}

/*Retorna nome dos estados apartir da sigla*/
function nomeUF(uf){
r="";
if(uf=="ac") r="Acre";
else if(uf=="al") r="Alagoas";
else if(uf=="ap") r="Amapá";
else if(uf=="am") r="Amazonas";
else if(uf=="ba") r="Bahia";
else if(uf=="ce") r="Ceará";
else if(uf=="df") r="Distrito Federal";
else if(uf=="es") r="Espírito Santo";
else if(uf=="go") r="Goiás";
else if(uf=="ma") r="Maranhão";
else if(uf=="mt") r="Mato Grosso";
else if(uf=="ms") r="Mato Grosso do Sul";
else if(uf=="mg") r="Minas Gerais";
else if(uf=="pa") r="Pará";
else if(uf=="pb") r="Paraíba";
else if(uf=="pr") r="Paraná";
else if(uf=="pe") r="Pernambuco";
else if(uf=="pi") r="Piauí";
else if(uf=="rj") r="Rio de Janeiro";
else if(uf=="rn") r="Rio Grande do Norte";
else if(uf=="rs") r="Rio Grande do Sul";
else if(uf=="ro") r="Rondônia";
else if(uf=="rr") r="Roraima";
else if(uf=="sc") r="Santa Catarina";
else if(uf=="sp") r="São Paulo";
else if(uf=="se") r="Sergipe";
else if(uf=="to") r="Tocantins";
return r;
}

/* Função para remover caracteres especiais */
function removerCaracteresEspeciais(s){
  reg = new RegExp("[!@#$%¨&*()´`^~{}º,<>:;?|'\"\\-=_+\\[\\]/\\\\]","g");
  s.value=s.value.replace(reg,"");
}

/* Lista de objetos XML por Cargo */
function retornaObjXml(cargo){
  r="";
  if(cargo==1) r="xmlPresidentes";
  else if(cargo==3) r="xmlGovernadores";
  else if(cargo==5) r="xmlSenadores";
  else if(cargo==6) r="xmlDepFederal";
  else if(cargo==7) r="xmlDepEstadual";
  else if(cargo==8) r="xmlDepDistrital";
  return r;
}

/* httprequest.js */
function loadXMLDoc(url){
  url = url.replace(/\/2006\//g,"/2006/placar/");
	var obj=this;
  var re = new RegExp("&","g");
	this.runFunctions="";
	
	function load(){
		obj.complete=0;
		if (window.XMLHttpRequest) obj.xmlhttp=new XMLHttpRequest();
		else if (window.ActiveXObject) obj.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		if(obj.xmlhttp){
			obj.xmlhttp.onreadystatechange=function(){
				if (obj.xmlhttp.readyState==4){
          if (obj.xmlhttp.status==200){
  					obj.complete=1;
            if(obj.runFunctions!=""){
          		
              /* Checa XML caso seja inválido  */
              returnError=false;
              if (window.XMLHttpRequest){
                try{
                  returnError=new XMLSerializer().serializeToString(obj.xmlhttp.responseXML);
                  if(returnError.indexOf("parsererror")>=0) returnError=true;
                }
                catch (er) {}
              }else if (window.ActiveXObject){
                returnError=obj.xmlhttp.responseXML.parseError.errorCode;
                if(returnError!=0) returnError=true;
              }

              if(returnError==true) eval("Error"+unescape((obj.runFunctions.replace(re,"; Error"))));
              else eval(unescape((obj.runFunctions.replace(re,";"))));

  					}
				  }else{
            eval("Error"+unescape((obj.runFunctions.replace(re,"; Error"))));
          }
				}
			};
            d=new Date();

			//obj.xmlhttp.open("GET",url+((url.indexOf("?")>=0)?"&rtimestampobj="+d.getTime():"?rtimestampobj="+d.getTime()),true);
			obj.xmlhttp.open("GET",url,true);
			obj.xmlhttp.send(null);
		}
	}
	
	/*Metodo para executar funções especificas do XML*/
	this.run=runF;
	function runF(x){
		if (obj.complete==1){
			eval(x.replace(re,";"));
		}
		obj.runFunctions+=((obj.runFunctions!="")?"&":"")+escape(x);
	}
	
	/*Metodo para reload do XML*/
	this.reload=load;
	this.reload();

    //Metodo para exibir loading de XML
    
    this.showLoadingXML=loading;
    function loading(ob,id){
        var H_DIV_load=document.createElement("div");
        H_DIV_load.appendChild(document.createTextNode("loading..."));
        H_DIV_load.id=ob+"h_loading";
        H_DIV_load.className="XMLload";
        if(eval(ob+".xmlhttp.readyState")<4) {
            //quando descomentado o loading pisca
            eval("setTimeout(\""+ob+".showLoadingXML('"+ob+"','"+id+"');\",300);");
            if(document.getElementById(H_DIV_load.id)) document.getElementById(id).removeChild(document.getElementById(H_DIV_load.id));
            else document.getElementById(id).appendChild(H_DIV_load);
        }else {
            if(document.getElementById(H_DIV_load.id)) document.getElementById(id).removeChild(document.getElementById(H_DIV_load.id));
        }
    }
}

///////////////////////////////////////

/* readxml.js */

/* Parte do script para exibir os candidatos presidentes */
function ErrorexibirPresidentes(){
  document.getElementById('presidenteLoad').style.display="none";
  document.getElementById('pres').getElementsByTagName('div')[1].innerHTML="<span class='mensagem-erro'>Informação não disponível</span>";
}

function exibirPresidentes(){
  document.getElementById('localizacao').innerHTML="Brasil";

  if(xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('comparecimento')=="0"){
    ErrorexibirPresidentes();
    return false;
  }

  document.getElementById('dataAtualizacao').innerHTML=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('tse')[0].getAttribute('dataGeracao')+" - "+xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('tse')[0].getAttribute('horaGeracao');
  document.getElementById('VotosApuradosNumero').innerHTML=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('comparecimento');
  document.getElementById('VotosApuradosPorcentagem').innerHTML=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('votosApuradosPorcentagem')+"%";
  document.getElementById('barraVotosApurados').style.width=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('votosApuradosGrafico')+"%";
  document.getElementById('UrnasApuradasNumero').innerHTML=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('secoesApuradas');
  document.getElementById('UrnasApuradasPorcentagem').innerHTML=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('secoesApuradasPorcentagem')+"%";
  document.getElementById('barraUrnasApuradas').style.width=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('secoesApuradasGrafico')+"%";
  document.getElementById('AbstencoesPorcentagem').innerHTML=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('abstencoesPorcentagem')+"%";
  document.getElementById('AbestencoesNumero').innerHTML=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('abstencoes');

    HTMLpresidentes=""+
      "		  <table cellspacing=\"0\">"+
      "			  <thead>"+
      "			  	<tr><td colspan=\"3\">PRESIDENTE</td></tr>"+
      "			  </thead>"+
      "				<tbody>";
    Presidente=xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('presidente')[0];
    PresidenteCandidato=Presidente.getElementsByTagName('candidato');
    PresidentesCount=PresidenteCandidato.length;
    for(var i=0;i<2;i++){
      if((i==0 && PresidenteCandidato[i].getAttribute('posicao')=="1") || (i==1 && PresidenteCandidato[i].getAttribute('posicao')=="2")){
        situacaoCandidato="";
        situacaoCandidato=eleitoMatematicamente(Presidente.getAttribute('votosValidos'),Presidente.getAttribute('votosApurados'),Presidente.getAttribute('votosApuradosPorcentagem'),Presidente.getAttribute('abstencoes'),PresidenteCandidato[i].getAttribute('votos'),"BR",PresidenteCandidato[i].getAttribute('id'));
      }
      HTMLpresidentes+="<tr><td class=\"col1 nome\" colspan=\"3\">"+
        "<img src=\"http://el.i.uol.com.br/2006/placarapuracao/candidatos/c1-"+PresidenteCandidato[i].getAttribute('id')+".jpg\" class=\"foto-candidato\" border=\"0\">"+
        "<span class=\"candidato-posicao\">"+PresidenteCandidato[i].getAttribute('posicao')+".</span>"+
        "<span class=\"candidato-nome\"> "+PresidenteCandidato[i].getAttribute('nomeUrna').toLowerCase()+"</span>"+
        "<span class=\"candidato-partido\">("+PresidenteCandidato[i].getAttribute('partido')+")</span>"+
        //(((i==0 && PresidenteCandidato[i].getAttribute('situacao')=="") || (i==1 && PresidenteCandidato[i].getAttribute('situacao')==""))?situacaoCandidato:situacaoImg(PresidenteCandidato[i].getAttribute('situacao')))+
        situacaoCandidato+
        "<div class=\"candidato-votos\">"+PresidenteCandidato[i].getAttribute('votos')+" votos</div>"+
        "<div class=\"candidato-porcentagem\">"+PresidenteCandidato[i].getAttribute('votosPorcentagem')+"%</div>"+
      "</td></tr>";
    }
    HTMLpresidentes+=""+
      "			</tbody>"+
    	"			<tfoot>"+
      "  			<tr class=\"espaco\"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>"+
      "				<tr><th class=\"col1\"></th><th nowrap>Nº de votos</th><th nowrap>(em %)</th></tr>"+
      "       <tr><td class=\"col1\">Votos válidos apurados</td><td>"+Presidente.getAttribute('votosValidos')+"</td><td></td></tr>"+
    	"				<tr><td class=\"col1\">Brancos</td><td>"+Presidente.getAttribute('votosBranco')+"</td><td>"+Presidente.getAttribute('votosBrancoPorcentagem')+"</td></tr>"+
    	"				<tr><td class=\"col1\">Nulos</td><td>"+Presidente.getAttribute('votosNulo')+"</td><td>"+Presidente.getAttribute('votosNuloPorcentagem')+"</td></tr>"+
      "  			<tr class=\"validos\"><td class=\"col1\">Total de votos apurados</td><td>"+xmlPresidentes.xmlhttp.responseXML.getElementsByTagName('total')[0].getAttribute('votosApurados')+"</td><td>"+Presidente.getAttribute('votosApuradosPorcentagem')+"</td></tr>"+
    	"				<tr><td class=\"col1\">Abstenções</td><td>"+Presidente.getAttribute('abstencoes')+"</td><td>"+Presidente.getAttribute('abstencoesPorcentagem')+"</td></tr>"+
    	"			</tfoot>"+
    	"		</table>";

  document.getElementById('pres').getElementsByTagName('div')[1].innerHTML=HTMLpresidentes;
  
  document.getElementById('presidenteLoad').style.display="none";
}

/* Parte do script para exibir os candidatos a governador */
function ErrorexibirGovernadores(){
  document.getElementById('governadorLoad').style.display="none";
  document.getElementById('regioes').getElementsByTagName('div')[1].innerHTML="<span class='mensagem-erro'>Informação não disponível</span>";
}

function exibirGovernadores(){
  regioesXML=xmlGovernadores.xmlhttp.responseXML.getElementsByTagName('regiao');
  for(var i=0;i<regioesXML.length;i++){
    HTMLgovernadores="";
    HTMLgovernadores+=""+
  		"<table cellspacing=\"1\">"+
  		"<thead>"+
  		"	<tr><th class=\"amEscuro\">"+regiaoNome(regioesXML[i].getAttribute('codigo'))+"</th><th class=\"col2\">Classificação</th><th class=\"col3\">Nº de votos *</th><th class=\"col4\">(em %)</th></tr>"+
  		"</thead>"+
  		"<tbody>";
      estados=regioesXML[i].getElementsByTagName('estado');
      if(estados.length==0){
        HTMLgovernadores+="<tr><td class=\"cor1\" colspan=\"4\"><span class='mensagem-erro'>Informação não disponível</span></td></tr>";
      }else{
        for(var j=0;j<estados.length;j++){
          if(estados[j].getAttribute('votosApuradosPorcentagem')=="0,00" || estados[j].getAttribute('votosApuradosPorcentagem')=="00,00"){
            HTMLgovernadores+="<tr class=\"cor"+((j%2==0)?1:2)+"\"><td class=\"nomeEstado\"><h3>"+nomeUF(estados[j].getAttribute('codigo').toLowerCase())+"</h3></td><td colspan=\"3\"><span class='mensagem-erro'>Informação não disponível</span></td></tr>";
          }else{
            HTMLgovernadores+="<tr class=\"cor"+((j%2==0)?1:2)+"\"><td rowspan=\""+((turno1==1)?3:2)+"\" class=\"nomeEstado\"><div class=\"nomeEstadoConteudo\"><h3><a href=\""+estados[j].getAttribute('codigo').toLowerCase()+"/index.jhtm\">"+nomeUF(estados[j].getAttribute('codigo').toLowerCase())+"</a></h3><div class=\"barraPorcentagem\"><div class=\"barraBorda\"></div><div id=\"barraVotosApurados\" class=\"barraBg\" style=\"width:"+estados[j].getAttribute('votosApuradosGrafico')+"%\"></div></div><div class=\"porcentagem\">"+estados[j].getAttribute('votosApuradosPorcentagem')+"% dos votos apurados</div></div></td>";
            candidatos=estados[j].getElementsByTagName('candidato');
            for(var k=0;k<((turno1==1)?candidatos.length:2);k++){
              if((k==0 && candidatos[k].getAttribute('posicao')=="1") || (k==1 && candidatos[k].getAttribute('posicao')=="2")){
                situacaoCandidato="";
                situacaoCandidato=eleitoMatematicamente(estados[j].getAttribute('votosValidos'),estados[j].getAttribute('votosApurados'),estados[j].getAttribute('votosApuradosPorcentagem'),estados[j].getAttribute('abstencoes'),candidatos[k].getAttribute('votos'),estados[j].getAttribute('codigo'),candidatos[k].getAttribute('id'));
              }
              HTMLgovernadores+=((k>0)?"<tr class=\"cor"+((j%2==0)?1:2)+"\">":"")+"<td class=\"nome\"><strong>"+candidatos[k].getAttribute('posicao')+"</strong> - "+candidatos[k].getAttribute('nomeUrna').toLowerCase()+" - "+candidatos[k].getAttribute('partido')+
              //(((k==0 && candidatos[k].getAttribute('situacao')=="") || (k==1 && candidatos[k].getAttribute('situacao')==""))?situacaoCandidato:situacaoImg(candidatos[k].getAttribute('situacao')))+
              situacaoCandidato+
              "</td><td class=\"col3\">"+candidatos[k].getAttribute('votos')+"</td><td class=\"col4\">"+candidatos[k].getAttribute('votosPorcentagem')+"</td></tr>";
            }
          }
        }
      }
    HTMLgovernadores+="</tbody></table>";
    eval("regiao"+regioesXML[i].getAttribute('codigo')+"=HTMLgovernadores;");
  }
  document.getElementById('governadorLoad').style.display="none";
  document.getElementById('regioes').style.height="";
  document.getElementById('regioes').getElementsByTagName('div')[1].innerHTML=regiaoSE+regiaoS+regiaoNE+regiaoCO+regiaoN;

  if(typeof(setHeight)!="undefined"){
    document.getElementById('corpo').style.height="auto";
    setHeight('corpo');
  }

}

/*readxml-estados.js*/

/*Função para exibir regua das letras das cidades e lista de cidades de uma letra*/
function ErrorexibirxmlCidades(){

}

function exibirxmlCidades(){

  outrasCidades=xmlCidades.xmlhttp.responseXML;
  letras=outrasCidades.getElementsByTagName('outras')[0].getAttribute('letras');
  HTMLletras="<table id=\"regua\" cellspacing=\"0\" cellpadding=\"4\"><tr>";
  LetraAtual=0;
  for(var i=0;i<letras.length;i++){
    if(letras.substring(i,i+1)>letra && LetraAtual==0){
      LetraAtual=1;
      HTMLletras+="<td id=\"sel\"><a href=\"/2006/placar/"+((turno1==1)?"1turno/":"")+"cidades.jhtm?uf="+uf+"&letra="+letra+"\">"+letra+"</a></td>";
    }
    HTMLletras+="<td"+((letras.substring(i,i+1)==letra)?" id=\"sel\"":"")+"><a href=\"/2006/placar/"+((turno1==1)?"1turno/":"")+"cidades.jhtm?uf="+uf+"&letra="+letras.substring(i,i+1)+"\">"+letras.substring(i,i+1)+"</a></td>";
  }
  if(LetraAtual==0) HTMLletras+="<td id=\"sel\"><a href=\"/2006/placar/"+((turno1==1)?"1turno/":"")+"cidades.jhtm?uf="+uf+"&letra="+letra+"\">"+letra+"</a></td>";
  HTMLletras+="</tr></table>";
  document.getElementById('letrasReguas').innerHTML=HTMLletras;

  cidadesLista=outrasCidades.getElementsByTagName('cidade');
  cidadesQtPorColuna=Math.floor(cidadesLista.length/3)+((cidadesLista.length%3>0)?1:0);
  
  HTMLcidades="<ul>";
  for(var i=0;i<cidadesLista.length;i++){
    if(i%cidadesQtPorColuna==0) HTMLcidades+="</ul>\n\n<ul>";
    HTMLcidades+="<li"+((i%2==0)?" class=\"cinza\"":"")+"><a href=\"/2006/placar/"+((turno1==1)?"1turno/":"")+uf+"/index.jhtm?idcidade="+cidadesLista[i].getAttribute('id')+"\">"+(cidadesLista[i].getAttribute('nome').toLowerCase())+"</a></li>";
  }
  HTMLcidades+="</ul><br clear=\"all\">";
  
  document.getElementById('listaOutrasCidades').innerHTML=HTMLcidades;

}

/* Função para selecionar cidade */
function nivelCidade(id){
  if(id=='estado'){
    document.location="/2006/placar/"+((turno1==1)?"1turno/":"")+UFCorrente.toLowerCase()+"/index.jhtm";
  }else if(id.length>1){
    document.location="?idcidade="+id;
  }else if(id.length==1){
    document.location="/2006/placar/"+((turno1==1)?"1turno/":"")+"cidades.jhtm?uf="+UFCorrente+"&letra="+id;
  }
}

///////////////////////////////////////////////////////////////////////////////////////////////
/* Parte do script para exibir os candidatos a governador */
///////////////////////////////////////////////////////////////////////////////////////////////

function ErrorexibirxmlGovernadores(){
if(UFCorrente=="es" || 
UFCorrente=="ac" || 
UFCorrente=="pi" || 
UFCorrente=="ap" || 
UFCorrente=="ro" || 
UFCorrente=="se" || 
UFCorrente=="to" || 
UFCorrente=="ba" || 
UFCorrente=="ce" || 
UFCorrente=="mg" || 
UFCorrente=="mt" || 
UFCorrente=="ms" || 
UFCorrente=="df" || 
UFCorrente=="rr" || 
UFCorrente=="am" || 
UFCorrente=="sp" || 
UFCorrente=="al") texto="Não há 2º turno para governador neste Estado";
else texto="Informação não disponível";


  document.getElementById('governadorLoad').style.display="none";
  document.getElementById('boxGov').getElementsByTagName('div')[1].innerHTML="<table cellspacing=\"1\"><thead><tr><td colspan=\"3\">GOVERNADOR</td></tr><tr><th class=\"col1\">Candidato</th><th>Votos</th><th>% válidos</th></tr></thead><tbody><tr><td class=\"col1\" colspan=\"3\" style=\"width:auto\">"+
  "<span class='mensagem-erro'>"+texto+"</span>"+
  "</td></tr></tbody></table>";

  if(typeof(setHeight)!="undefined"){
    document.getElementById('corpo').style.height="auto";
    setHeight('corpo');
  }
}

function exibirxmlGovernadores(){
  XG=xmlGovernadores.xmlhttp.responseXML;
  if(XG.getElementsByTagName('total')[0].getAttribute('comparecimento')=="0"){
    ErrorexibirxmlGovernadores();
    return false;
  }
  document.getElementById('localizacao').innerHTML="<a href=\"/2006/"+UFCorrente+"/index.jhtm\">"+nomeUF(UFCorrente)+"</a>"+((idcidade!="")?" &gt; "+XG.getElementsByTagName('tse')[0].getAttribute('cidade').toLowerCase():"");
  document.getElementById('dataAtualizacao').innerHTML=XG.getElementsByTagName('tse')[0].getAttribute('dataGeracao')+" - "+XG.getElementsByTagName('tse')[0].getAttribute('horaGeracao');
  document.getElementById('VotosApuradosNumero').innerHTML=XG.getElementsByTagName('total')[0].getAttribute('comparecimento');
  document.getElementById('VotosApuradosPorcentagem').innerHTML=XG.getElementsByTagName('total')[0].getAttribute('votosApuradosPorcentagem')+"%";
  document.getElementById('barraVotosApurados').style.width=XG.getElementsByTagName('total')[0].getAttribute('votosApuradosGrafico')+"%";
  document.getElementById('UrnasApuradasNumero').innerHTML=XG.getElementsByTagName('total')[0].getAttribute('secoesApuradas');
  document.getElementById('UrnasApuradasPorcentagem').innerHTML=XG.getElementsByTagName('total')[0].getAttribute('secoesApuradasPorcentagem')+"%";
  document.getElementById('barraUrnasApuradas').style.width=XG.getElementsByTagName('total')[0].getAttribute('secoesApuradasGrafico')+"%";
  document.getElementById('AbstencoesPorcentagem').innerHTML=XG.getElementsByTagName('total')[0].getAttribute('abstencoesPorcentagem')+"%";
  document.getElementById('AbestencoesNumero').innerHTML=XG.getElementsByTagName('total')[0].getAttribute('abstencoes');

    HTMLgovernadores=""+
    	"  <table cellspacing=\"1\">"+
  		"	  <thead>"+
  		"	  	<tr><td colspan=\"3\">GOVERNADOR</td></tr>"+
  		"	  </thead>"+
  		"		<tbody>";
      governadores=XG.getElementsByTagName('governadores')[0].getElementsByTagName('candidato');
      votosAnterior=0;
      for(var i=0;i<2;i++){
        if((i==0 && governadores[i].getAttribute('posicao')=="1") || (i==1 && governadores[i].getAttribute('posicao')=="2")){
          situacaoCandidato="";
          situacaoCandidato=eleitoMatematicamente(XG.getElementsByTagName('total')[0].getAttribute('votosValidos'),XG.getElementsByTagName('total')[0].getAttribute('votosApurados'),XG.getElementsByTagName('total')[0].getAttribute('votosApuradosPorcentagem'),XG.getElementsByTagName('total')[0].getAttribute('abstencoes'),governadores[i].getAttribute('votos'),UFCorrente.toUpperCase(),governadores[i].getAttribute('id'));
        }

        HTMLgovernadores+="<tr><td class=\"col1 nome\" colspan=\"3\">"+
          "<img src=\"http://el.i.uol.com.br/2006/placarapuracao/candidatos/c3-"+UFCorrente+"-"+governadores[i].getAttribute('id')+".jpg\" class=\"foto-candidato\" border=\"0\">"+
          "<span class=\"candidato-posicao\">"+governadores[i].getAttribute('posicao')+".</span>"+
          "<span class=\"candidato-nome\"> "+governadores[i].getAttribute('nomeUrna').toLowerCase()+"</span>"+
          "<span class=\"candidato-partido\">("+governadores[i].getAttribute('partido')+")</span>"+
          //(((i==0 && governadores[i].getAttribute('situacao')=="") || (i==1 && governadores[i].getAttribute('situacao')==""))?situacaoCandidato:situacaoImg(governadores[i].getAttribute('situacao')))+
          situacaoCandidato+
          "<div class=\"candidato-votos\">"+governadores[i].getAttribute('votos')+" votos</div>"+
          "<div class=\"candidato-porcentagem\">"+governadores[i].getAttribute('votosPorcentagem')+"%</div>"+
        "</td></tr>";
  
      }
  
  		HTMLgovernadores+=""+
      	"	<tfoot>"+
        "		<tr><td class=\"paginacao\" colspan=\"3\">&nbsp;</td></tr>"+
  			"		<tr><th>&nbsp;</th><th>Votos</th><th>%</th></tr>"+
  			"		<tr><td class=\"col1\">Brancos</td><td>"+XG.getElementsByTagName('total')[0].getAttribute('votosBranco')+"</td><td>"+XG.getElementsByTagName('total')[0].getAttribute('votosBrancoPorcentagem')+"</td></tr>"+
  			"		<tr><td class=\"col1\">Nulos</td><td>"+XG.getElementsByTagName('total')[0].getAttribute('votosNulo')+"</td><td>"+XG.getElementsByTagName('total')[0].getAttribute('votosNuloPorcentagem')+"</td></tr>"+
  			"	</tfoot></table>";

  document.getElementById('governadorLoad').style.display="none";
  document.getElementById('boxGov').getElementsByTagName('div')[1].innerHTML=HTMLgovernadores;
  document.getElementById('boxGov').style.height="auto";

  if(typeof(setHeight)!="undefined"){
    document.getElementById('corpo').style.height="auto";
    setHeight('corpo');
  }
}


///////////////////////////////////////////////////////////////////////////////////////////////
/* Parte do script para exibir os Presidentes */
///////////////////////////////////////////////////////////////////////////////////////////////

function ErrorexibirxmlPresidentes(){
  document.getElementById('presidenteLoad').style.display="none";
  document.getElementById('boxPre').getElementsByTagName('div')[1].innerHTML="<table cellspacing=\"1\"><thead><tr><td colspan=\"3\">PRESIDENTE</td></tr><tr><th class=\"col1\">Candidato</th><th>Votos</th><th>% válidos</th></tr></thead><tbody><tr><td class=\"col1\" colspan=\"3\">"+
  "<span class='mensagem-erro'>Informação não disponível</span>"+
  "</td></tr></tbody></table>";

  if(typeof(setHeight)!="undefined"){
    document.getElementById('corpo').style.height="auto";
    setHeight('corpo');
  }
}

function exibirxmlPresidentes(){
  XP=xmlPresidentes.xmlhttp.responseXML;

  if(XP.getElementsByTagName('total')[0].getAttribute('votosApurados')=="0"){
    ErrorexibirxmlPresidentes();
    return false;
  }

  if(UFCorrente=="es" || 
  UFCorrente=="ac" || 
  UFCorrente=="pi" || 
  UFCorrente=="ap" || 
  UFCorrente=="ro" || 
  UFCorrente=="se" || 
  UFCorrente=="to" || 
  UFCorrente=="ba" || 
  UFCorrente=="ce" || 
  UFCorrente=="mg" || 
  UFCorrente=="mt" || 
  UFCorrente=="ms" || 
  UFCorrente=="df" || 
  UFCorrente=="rr" || 
  UFCorrente=="am" || 
  UFCorrente=="sp" || 
  UFCorrente=="al"){
    document.getElementById('localizacao').innerHTML="<a href=\"/2006/"+UFCorrente+"/index.jhtm\">"+nomeUF(UFCorrente)+"</a>"+((idcidade!="")?" &gt; "+XP.getElementsByTagName('tse')[0].getAttribute('cidade').toLowerCase():"");
    //document.getElementById('localizacao').innerHTML="<a href=\"/2006/"+UFCorrente+"/index.jhtm\">"+nomeUF(UFCorrente)+"</a>";
    document.getElementById('dataAtualizacao').innerHTML=XP.getElementsByTagName('tse')[0].getAttribute('dataGeracao')+" - "+XP.getElementsByTagName('tse')[0].getAttribute('horaGeracao');
    document.getElementById('VotosApuradosNumero').innerHTML=XP.getElementsByTagName('total')[0].getAttribute('comparecimento');
    document.getElementById('VotosApuradosPorcentagem').innerHTML=XP.getElementsByTagName('total')[0].getAttribute('votosApuradosPorcentagem')+"%";
    document.getElementById('barraVotosApurados').style.width=XP.getElementsByTagName('total')[0].getAttribute('votosApuradosGrafico')+"%";
    document.getElementById('UrnasApuradasNumero').innerHTML=XP.getElementsByTagName('total')[0].getAttribute('secoesApuradas');
    document.getElementById('UrnasApuradasPorcentagem').innerHTML=XP.getElementsByTagName('total')[0].getAttribute('secoesApuradasPorcentagem')+"%";
    document.getElementById('barraUrnasApuradas').style.width=XP.getElementsByTagName('total')[0].getAttribute('secoesApuradasGrafico')+"%";
    document.getElementById('AbstencoesPorcentagem').innerHTML=XP.getElementsByTagName('total')[0].getAttribute('abstencoesPorcentagem')+"%";
    document.getElementById('AbestencoesNumero').innerHTML=XP.getElementsByTagName('total')[0].getAttribute('abstencoes');
  }
    HTMLpresidente=""+
  		"  <table cellspacing=\"1\">"+
  		"	  <thead>"+
  		"	  	<tr><td colspan=\"3\">PRESIDENTE</td></tr>"+
  		"			<tr><th class=\"col1\">Candidato</th><th>Brasil(%)</th><th>"+((idcidade=="")?UFCorrente.toUpperCase():"Município")+"(%)</th></tr>"+
  		"	  </thead>"+
  		"		<tbody>";
    presidentes=XP.getElementsByTagName('presidente')[0].getElementsByTagName('candidato');
    votosAnterior=0;
    for(var i=0;i<2;i++){
      if((i==0 && presidentes[i].getAttribute('posicao')=="1") || (i==1 && presidentes[i].getAttribute('posicao')=="2")){
        situacaoCandidato="";
        situacaoCandidato=eleitoMatematicamente(XP.getElementsByTagName('presidente')[0].getAttribute('votosValidos'),XP.getElementsByTagName('presidente')[0].getAttribute('votosApurados'),XP.getElementsByTagName('presidente')[0].getAttribute('votosApuradosPorcentagem'),XP.getElementsByTagName('presidente')[0].getAttribute('abstencoes'),presidentes[i].getAttribute('votos'),"BR",presidentes[i].getAttribute('id'));
      }
      HTMLpresidente+="<tr><td class=\"col1 nome\">"+
        "<span class=\"candidato-nome\"> "+presidentes[i].getAttribute('posicao')+". "+presidentes[i].getAttribute('nomeUrna').toLowerCase()+"</span><br />"+
        "<span class=\"candidato-partido\">("+presidentes[i].getAttribute('partido')+")</span>"+
        //(((i==0 && presidentes[i].getAttribute('situacao')=="") || (i==1 && presidentes[i].getAttribute('situacao')==""))?situacaoCandidato:situacaoImg(presidentes[i].getAttribute('situacao')))+
        situacaoCandidato+
        "</td>"+
        "<td class=\"candidato-porcentagem\"><span>"+presidentes[i].getAttribute('votosBrasilPorcentagem')+"</span></td>"+
        "<td class=\"candidato-porcentagem\"><span>"+presidentes[i].getAttribute('votosPorcentagem')+"</span></td>"+
      "</td></tr>";
    }
  
  	HTMLpresidente+=""+
      "	<tfoot>"+
      "		<tr><td class=\"paginacao\" colspan=\"3\">&nbsp;</div></td></tr>"+
      "		<tr><th>&nbsp;</th><th>Votos</th><th>%</th></tr>"+
      "		<tr><td class=\"col1\">Brancos</td><td>"+XP.getElementsByTagName('presidente')[0].getAttribute('votosBranco')+"</td><td>"+XP.getElementsByTagName('presidente')[0].getAttribute('votosBrancoPorcentagem')+"</td></tr>"+
      "		<tr><td class=\"col1\">Nulos</td><td>"+XP.getElementsByTagName('presidente')[0].getAttribute('votosNulo')+"</td><td>"+XP.getElementsByTagName('presidente')[0].getAttribute('votosNuloPorcentagem')+"</td></tr>"+
      "	</tfoot></table>";

  document.getElementById('presidenteLoad').style.display="none";
  document.getElementById('boxPre').getElementsByTagName('div')[1].innerHTML=HTMLpresidente;
  document.getElementById('boxPre').style.height="auto";

  if(typeof(setHeight)!="undefined"){
    document.getElementById('corpo').style.height="auto";
    setHeight('corpo');
  }
}

/*scripts-postload.js*/

// posiciona elementos na tela
function placePos(bId, pos, sum) {
	if(bFs != 0) document.getElementById(bId).style.top = (sum+pos)/bFs+'em';		
}

// mostra banners //
if(typeof(DErand)=="undefined") {
	var DEt=new Date(); DEt=DEt.getTime(); DErand=Math.floor(DEt*1000*Math.random());
}
var scw=0,sch=0; if(screen.height){scw=screen.width;sch=screen.height;}
function DEshow(ad,pos,sum){
	if(typeof(sum)=='undefined') sum=0;
	if(document.getElementById('banner-'+ad+'-area')) {
	document.write('<'+'scr'+'ipt type="text/javascript" src="http://bn.uol.com.br/js.ng/site='+DEsite+'&amp;chan='+DEchan+'&amp;subchan='+DEsubc+'&amp;affiliate='+DEsite+DEchan+'&amp;size='+ad+'&amp;page='+pos+'&amp;conntype='+DEconn+'&amp;expble='+Expble+'&amp;reso='+scw+'x'+sch+'&amp;tile='+DErand+'?"><\/scr'+'ipt>');
		if(ad!='1x1'&&ad!='300x250') placePos('banner-'+ad, findPos('banner-'+ad+'-area'), sum); // se não é popup, posiciona na tela
		}
}
