
init_slideshows = function() {

	if (document.getElementById('banner-destaque-slideshow')) {
				
		var palavra = window.location.pathname;
		var letras = palavra.substring(palavra.indexOf("/informe") + 1, palavra.length).split("");
		var niveis = "";
		var xml_sufixo = "";
		
		for (var i=0; i<letras.length; i++) {
			if (letras[i] == "/") {
				niveis += "../";
			}
		}		 
		
		xml_sufixo = (niveis == "../") ? "_home" : "_internas";
		
		var banner1 = '';
		
		banner1 += '<object id="obj-banner-destaque-slideshow" type="application/x-shockwave-flash" data="' + niveis + '_slideshow/app/slideshow.swf" width="240" height="70">';
		banner1 += '<param name="flashvars" value="pathtoxml=' + niveis + '_slideshow/xml/informe_destaque' + xml_sufixo + '&pathtoslideshow=' + niveis + '_slideshow/app"/>';
		banner1 += '<param name="movie" value="' + niveis + '_slideshow/app/slideshow.swf"/>';
		banner1 += '</object>';	
		
		document.getElementById('banner-destaque-slideshow').innerHTML = banner1;
	}	
}

posicionarRodape = function() {
	
	var elemento_rodape = '';
	var ativar_rodape = true;
	var rodapeH = 0;
	var rodapeL = 0;
	var rodapeW = 0;
	var minW = 1000;
		
	try {		
		
		var div1H = document.getElementById('navegacao-primaria').scrollHeight;
		var div2H = document.getElementById('conteudo').scrollHeight;
		var div3H = document.getElementById('navegacao-secundaria').scrollHeight;
		
		var div1W = document.getElementById('navegacao-primaria').offsetWidth;
		var div2W = document.getElementById('navegacao-secundaria').offsetWidth;
				
		elemento_rodape = document.getElementById('rodape');
		
		var w = document.body.clientWidth;		
		
		if (w < 1000) {
			rodapeW = minW - (div1W + div2W);
			rodapeL = Math.ceil((minW-rodapeW) / 2);
		} else {
			rodapeW = w - (div1W + div2W);
			rodapeL = Math.ceil((w-rodapeW) / 2);
		}
		
		rodapeH = div1H;
		 		
		if (div2H > rodapeH) {
			rodapeH = div2H;
		}
		
		if (div3H > rodapeH) {
			rodapeH = div3H;
		}
			
		rodapeH += 200;
			
	} catch(err) {
		
		ativar_rodape = false;	
	}

	if (ativar_rodape && rodapeH != 0 && rodapeL !=0 && elemento_rodape != '') {		
		elemento_rodape.style.width = rodapeW + 'px';
		elemento_rodape.style.top = rodapeH + 'px';
		elemento_rodape.style.left = rodapeL + 'px';
		elemento_rodape.style.display = 'block';
	} else if (elemento_rodape != '' && elemento_rodape != null) {		
		elemento_rodape.style.display = 'none';
	}
}

init_rodape = function() {
	
	posicionarRodape();	
	
	addEvent(window, "resize", posicionarRodape);		
	addEvent(document, "click", posicionarRodape);	
}

// controleDoTamanhoDaLetra

var letra = 'menor';
var tamanhoDaLetraMaior = '120%';
var tamanhoDaLetraMenor = '100%';
var controleDoTamanhoDaLetra;

init_controleDoTamanhoDaLetra = function() {
	
	try {
		controleDoTamanhoDaLetra = document.getElementById('tamanho-da-letra');			
		addEvent(controleDoTamanhoDaLetra, "click", alterarTamanhoDaLetra);			
	} catch(err) {
	}	
}

alterarTamanhoDaLetra = function() {
	
	var novaLetra;
	
	if (letra == 'menor') {
		letra = 'maior';
		novaLetra =	tamanhoDaLetraMaior;
		controleDoTamanhoDaLetra.className = 'bg-letra-menor';
	} else if (letra == 'maior') {
		letra = 'menor';
		novaLetra =	tamanhoDaLetraMenor;
		controleDoTamanhoDaLetra.className = 'bg-letra-maior';
	}	
	
	document.getElementById('conteudo').style.fontSize = novaLetra;
}

// init

init = function() {
	
	init_slideshows();	
	init_rodape();
	init_controleDoTamanhoDaLetra();
}

addEvent = function(obj, evType, fn) {
	
	if (obj.addEventListener)
		obj.addEventListener(evType, fn, false);
	
	if (obj.attachEvent)
		obj.attachEvent("on" + evType, fn);
}

addEvent(window, "load", init);
