var url = self.location.href.replace(/\\/, "/").split("/");
var pg = url[url.length-1];
var pgatual = parseInt(pg.replace(".htm", ""), 10);
var idioma = url[url.length-3];
var pasta = url[url.length-2];

var appVer = navigator.appVersion.toLowerCase();
var iePos  = appVer.indexOf('msie');
var ffPos  = navigator.userAgent.toLowerCase().indexOf('firefox');
var ieVer = 0;
var podefscommand = "nao";
var iebug = false;
var ffbug = false;
var tipo_topo = "sub";
if (iePos !=-1) {
	ieVer = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
	if(ieVer < 7) iebug = true;
	if(ieVer > 5.5) podefscommand = "sim";
}

function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  }
}


/*if(ferramenta!="sim"){
	addEvent(window, "load", function(){ ConfiguraGRI(); enableTooltips(); }, false);
}*/

if(isNaN(pgatual)) pgatual = 0;


var toposwf = pgatual==0? pg.replace(".htm", "").replace(".asp", "").split("?")[0] : z(pgatual);

if(pasta=="ra"){
	if(toposwf >= 7 && toposwf <= 10) toposwf = "07";
	if(toposwf >= 11 && toposwf <= 12) toposwf = "08";
	if(toposwf >= 13 && toposwf <= 17) toposwf = "09";
	if(toposwf >= 18 && toposwf <= 23) toposwf = "10";
	if(toposwf >= 24 && toposwf <= 27) toposwf = "11";
	if(toposwf >= 28 && toposwf <= 34) toposwf = "12";
	if(toposwf >= 35 && toposwf <= 38) toposwf = "13";
	if(toposwf >= 39 && toposwf <= 43) toposwf = "14";
	if(toposwf >= 44 && toposwf <= 44) toposwf = "15";
	if(toposwf >= 45 && toposwf <= 45) toposwf = "16";
	if(toposwf >= 46 && toposwf <= 46) toposwf = "17";

}
if(pasta=="df"){	
		if(toposwf >= 1 && toposwf <= 12) toposwf = "01";
		if(toposwf >= 13 && toposwf <= 13) toposwf = "02";
		if(toposwf >= 14 && toposwf <= 14) toposwf = "03";
		if(toposwf >= 15 && toposwf <= 15) toposwf = "04";
		if(toposwf >= 16 && toposwf <= 16) toposwf = "05";
		if(toposwf >= 17 && toposwf <= 17) toposwf = "06";
	if(idioma=="port"){
		if(toposwf >= 18 && toposwf <= 43) toposwf = "07";
		if(toposwf >= 44 && toposwf <= 44) toposwf = "08";
		}
		
		if(toposwf >= 18 && toposwf <= 44) toposwf = "07";
		if(toposwf >= 45 && toposwf <= 45) toposwf = "08";

	

}

if(idioma=="port"){
	var pgtotal = [];
	pgtotal["df"] = 44;
}

if(idioma=="eng"){
	var pgtotal = [];
	pgtotal["df"] = 45;
}

var pgtotal = [];
	pgtotal["ra"] = 46;


if(podefscommand) document.write('<scr' + 'ipt for="menu_flash" event="FSCommand(funcao)">eval(funcao);</sc' + 'ript>');

var apagou = [];

function vai(x){
	temppg = pgatual + x;
	
	if(temppg<=0 || temppg > pgtotal[pasta]) location = "index.htm";
	else location = z(temppg) + ".htm";
}

function z(numero){
	return numero<10? ("0"+numero) : numero;
}

function pdf(){
	//alert("Aguardando PDF Final.")
	window.open("../downloads/PDFs/" + (pasta) + "_" + z(pgatual) + ".pdf");
}

function avisoeng(){
	
	alert("Coming Soon");
}

function avisoesp(){
	
	alert("Coming Soon");
}


/*////////  FLASH   //////////// */

function flash(movie, flashvars, width, height, retorna){
	swfid = movie.split("/");
	swfid = swfid[swfid.length-1].replace(".swf", "");
	flashvars += "&podefscommand=" + podefscommand;
	if(podefscommand=="sim" && !retorna) document.write('<scr' + 'ipt for="' + swfid + '" event="FSCommand(funcao)">eval(funcao);</sc' + 'ript>');
	strSWF= '<object id="' + swfid + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '">'+
			'<param name="movie" value="' + movie + '">'+
			'<param name="quality" value="high">'+
			'<param name="wmode" value="transparent">'+
			'<param name="FlashVars" value="' + flashvars + '">'+
			'<embed name="' + swfid + '" src="' + movie + '" width="' + width + '" height="' + height + '" flashvars="' + flashvars + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'+
			'</object>';
	if(!retorna) this.document.write(strSWF);
	else return(strSWF);
}

function TheFlash(moviename) {
    if(document.all) return document.all[moviename];
	else return document.embeds[moviename];
}

tit = document.title.split(String.fromCharCode(187));
try { titulo = trim(tit[2]).replace("&", "%26");
}
catch(e){}

var titulo_topo = tit[2];

tit_dois = document.title.split(String.fromCharCode(187));
try { titulo = trim(tit_dois[3]).replace("&", "%26");
}
catch(e){}

var subtitulo_topo = tit_dois[3];



/*///////////////////////   ABRE FECHA MENU   /////////////////////*/

var tempo;

addEvent(window, "load", function()
{
	tempo = setTimeout(fechamenu, 100);
	
}, false);


function abremenu(){
	try 
	{	
		if(tempo) clearTimeout(tempo);
		document.getElementById("div_menu").style.clip = "rect(0 510px 530px 0)";
	}
	catch(e){}
}

function fechamenu(){
	tempo = setTimeout(fechamenuAgora, 100);
}

function fechamenuAgora(){
	try 
	{
		document.getElementById("div_menu").style.clip = "rect(0 240px 520px 0)";
	}
	catch(e){}
}


/*////////  FERRAMENTAS HOME   //////////// */

function $(id){
	return document.all? document.all[id] : document.getElementById(id);
}

function msgceo(){
	$("div_fundao_home").innerHTML = flash("../imagens/msg_ceo.swf", "", "100%", "100%", true);
	$("div_fundao_home").style.display = "block";	
	$("div_fundao_home").style.visibility = "";
}

function apagamsgceo(){
	setTimeout(function()
	{
		$("div_fundao_home").style.display = "block";
		$("div_fundao_home").style.visibility = "hidden";
		$("div_fundao_home").innerHTML = "";
	}, 300);
}

