banner = false;

function restringeDigitacao(exp,event){
	
	codigo = obterTecla(event);
	var valor = String.fromCharCode(codigo); 
	
	if(exp.test(valor)){ 	
	 	
	 }else{
		 if(event.keyCode)
		 	event.keyCode=0;
		 if(event.keyCode == 0 && event.preventDefault)
		 	event.preventDefault();
	 }
}

function abrenew(url,nwindow,style) {
	window.open(url,nwindow,style);
}

function abremenu(){
	document.getElementById("menu").style.clip = "rect(0px 400px 400px 0px)";
	if(!document.all) { // para resolver problema de bug com FF
		try { document.getElementById("texto").style.overflow = "hidden"; } catch(e){ }
		try { document.getElementById("texto_peq").style.overflow = "hidden"; } catch(e){}
	}
}

function fechamenu(){
	document.getElementById("menu").style.clip = "rect(0px 200px 400px 0px)";
	if(!document.all) { // para resolver problema de bug com FF
		try { document.getElementById("texto").style.overflow = "auto"; } catch(e){}
		try { document.getElementById("texto_peq").style.overflow = "auto";	} catch(e){}
	}
}


function MostraApaga(objeto, display){
	if(document.getElementById(objeto)) document.getElementById(objeto).style.display = display;
}

function EstadoDisplay(objeto){
	return document.getElementById(objeto).style.display;
}

function altura(obj){

	// função para calcular a altura da DIV do conteudo do texto
	ct = 0;
	
	// calcula o distancia até o topo
	while(obj.tagName!="BODY"&&obj.tagName!="HTML"){
		ct += obj.offsetTop;
		obj = obj.offsetParent;
	}
	
	// altura final = altura da página - distancia até o topo - 29px do rodape
	ct = document.documentElement.clientHeight - ct - 29;
	
	try {
		// limita para no minimo o tamanho do submenu, se houver
		h = document.getElementById("submenu").style.height;
		if(ct < h) ct = h;
	}
	catch(e){}

	ctmin = (banner? 200 : 300);
	
	if(ct<ctmin) ct = ctmin;

	return ct;
}


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;
  }
}

function setaAltura(){

	// seta a altura da DIV do conteudo do texto
	try {
		// tenta na DIV normal
		t = document.getElementById("texto");
		t.style.height = altura(t) + "px";
	}
	catch(e){
		try {
			// tenta na DIV pequena (com sub-menu)
			t = document.getElementById("texto_peq");
			t.style.height = altura(t) + "px";
		}
		catch(e){}
	}
}

function alturaIframe(){ 

	try {
		// tenta arruma a altura do IFRAME de RI, se houver
		t = document.getElementById("ri"); 
		t.style.height = altura(t) + "px"; 
	}
	catch(e){}
}

function abrir(url){
	window.open(url, "_blank");
}

function janela(url, w, h){
	open(url, "", "width=" + w + ",height=" + h + ",left=" + ((screen.availWidth-w)/2) + ",top=" + ((screen.availHeight-h)/2));
}

var atual = false;
function mostra(objeto){
	if (objeto != atual){
		MostraApaga(objeto, "block");
		if(atual) MostraApaga(atual, "none");
		atual = objeto;
	}
}

otitulo = document.title;

addEvent(window, "load", function(){ 
							setaAltura();
							alturaIframe(); 
							if(location.hash!=""){
								location = location.hash;
								document.title = otitulo;
							}

							divs = document.getElementsByTagName("DIV");
							
							for(x = 0; x < divs.length; x++){
								if(divs[x].className=="secao"){
									link = divs[x].firstChild;
									link.x = x;
									link.onclick = function(){
										if(divs[this.x].className=="secao"){
											for(i = 0; i < divs.length; i++){ 
												if(divs[i].className=="secao"||divs[i].className=="secao_active"){
													divs[i].className = (this.x==i? "secao_active" : "secao");
												}
											}
										}
										else divs[this.x].className = "secao";
									};
								}
							}
							
						  }, false);

addEvent(window, "resize", function(){ 
							setaAltura(); 
							alturaIframe(); 
						   }, false);