window.onerror = function(){
					return true;
				};
				
var bRet = true; 
if(document.all) document.onkeydown = onKeyPress;
else if (document.layers || document.getElementById) document.onkeypress = onKeyPress;

function onKeyPress(evt) {
	var oEvent = (window.event) ? window.event : evt;

	var nKeyCode = oEvent.keyCode ? oEvent.keyCode :
	oEvent.which ? oEvent.which : 
	void 0;
	
	if(oEvent.charCode == null || oEvent.charCode == 0){ 
		if(nKeyCode == 116){
			bRet = false;
			try {
				oEvent.returnValue = false;
				oEvent.cancelBubble = true;

				if(document.all){
					oEvent.keyCode = 0;
				}
				else {
					oEvent.preventDefault();
					oEvent.stopPropagation();
				}
				location = "home.asp";
			}
			catch(ex){ }
		}
	}
	return bRet;
}

function MostraApaga(objeto, display){
	if(document.getElementById(objeto)) document.getElementById(objeto).style.display = display;
}

function EstadoDisplay(objeto){
	return document.getElementById(objeto).style.display;
}

function abreMenu(){
	document.getElementById("div_conteudo").style.zIndex = 4;
	document.getElementById("div_home").style.zIndex = 3;	
	if(!document.all) document.getElementById("div_conteudo").style.overflow = "hidden";	
}

function fechaMenu(){
	document.getElementById("div_conteudo").style.zIndex = 200;
	document.getElementById("div_home").style.zIndex = 199;	
	if(!document.all) document.getElementById("div_conteudo").style.overflow = "auto";
}

var url = self.location.href.replace("home.asp", "");

var http = url.substring(0,4)=="http"? true : false;

var tempo, arquivo, ferramenta = titulorao = titulo = "", pasta, pastaatual, pgatual, frame, tempo_carregando, setaVarsmenu;
var oscases = [, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8,];

function setaVars(){
	try{
		if(setaVarsmenu) clearTimeout(setaVarsmenu);
		theMovie('topo').AS_setaVars();
	}
	catch(e){ 
		setaVarsmenu = setTimeout("setaVars()", 100); 
	}
}

function retornaVars(){
	return { 
				"pgatual" : isNaN(parseInt(pgatual, 10))? 40 : pgatual,
				"titulo"  : (titulo==null||titulo=="null"||titulo=="")? "" : titulo
		   }
}

function pagina(pg, pgancora){
	
	if(!pgancora) ancora = false;
	else ancora = pgancora;

	pgatual = pg;
	titulo = "";	

	carrega();
}

function configura(){

	frame = "home";
	pgatual = 0;

	carrega();
}

function carrega(){
	
	setaVars();

	MostraApaga("div_cases", "none"); 

	document.getElementById("div_conteudo").innerHTML = "";
	
	if(pgatual==0){
		MostraApaga("div_busca", "block");
		MostraApaga("div_home", "block");
		MostraApaga("div_conteudo", "none");
		MostraApaga("div_sub_menu", "none");
		theMovie('topo').AS_vaiHome();
		frame = "home";
	} 
	else {

		if(frame=="home"){
			
			MostraApaga("div_home", "none");
			MostraApaga("div_conteudo", "block");
			MostraApaga("div_sub_menu", "block");
			if(!isNaN(parseInt(pgatual, 10))){
				MostraApaga("div_busca", "none");
				theMovie('topo').AS_vaiInterna();
				frame = "interna";
			}
		}

		if(oscases[pgatual]){
			setTimeout(function(){ MostraApaga("div_sub_menu", "block"); document.getElementById("div_sub_menu").innerHTML = flash("sub_menu_" + oscases[pgatual] + ".swf", "", 240, 178) }, 800);
		}
		else document.getElementById("div_sub_menu").innerHTML = "";
		
		pgcarregou = false;
		tempo_carregando = setTimeout("carregando()", 100);

		frames["buffer"].location.href = url + z(pgatual) + ".htm";
	}
}

function carregou(conteudo){ 

	if(pgcarregou){
 
		clearTimeout(tempo_carregando);
	
		document.getElementById("div_conteudo").innerHTML = frames["buffer"].document.title;
		titulo = document.getElementById("div_conteudo").innerHTML;

		if(document.all){
			flas = frames["buffer"].document.body.all.tags("OBJECT");
			for(x = 0; x < flas.length; x++){
				flasn = flas[x].outerHTML;
				flasn.match(/flashvars="((.|\n)*?)"/);
				flasn = flasn.replace(/\.swf/gi, ".swf?" + RegExp.$1);
				flas[x].outerHTML = flasn;
			}
			conteudo = frames["buffer"].document.body.innerHTML;
		}

		document.getElementById("div_conteudo").style.display = "block";
	
		if(isNaN(parseInt(pgatual, 10))){
			conteudo = flash("../includes/titulo.swf", "titulo="+titulo, 502, 31)+ "<br><br>" + conteudo;
		}
		document.getElementById("div_conteudo").innerHTML = conteudo;

		if(ancora){
			self.location.hash = ancora;
			ancora = false;
		}
		else document.getElementById("div_conteudo").scrollTop = 0;
		
		setaVars();
		
		switch(idioma){
			case "port" :
				oidioma = "Português";
				break;
			case "eng" :
				oidioma = "Inglês";
				break;
		}
		pageTracker._trackPageview(oidioma + " - " + titulo); 
	}
	else {
		clearTimeout(tempo_carregando);
		tempo_carregando = setTimeout(function(){ carregou(conteudo); }, 100);
	}
}

function cases(qual){
	pgcarregou = false;
	setTimeout("document.getElementById('div_cases_texto').style.display='block'", 800);
	frames["buffer_case"].location.href = url + "cases/" + z(qual) + ".htm";
	MostraApaga("div_sub_menu", "none");
	document.getElementById("div_cases").innerHTML = flash("../includes/cases.swf", "", 660, 350) + "<div id=div_cases_texto></div>";
	MostraApaga("div_cases", "block"); 
}

function carregou_case(conteudo){ 
	if(pgcarregou){
		clearTimeout(tempo_carregando);
		conteudo = conteudo.replace("../imagens/", "imagens/");
		document.getElementById("div_cases_texto").innerHTML = conteudo;
	}
	else {
		clearTimeout(tempo_carregando);
		tempo_carregando = setTimeout(function(){ carregou(conteudo); }, 100);
	}
}

function fechaCase(){
	MostraApaga("div_cases_texto", "none");
	setTimeout(function(){ MostraApaga("div_cases", "none"); MostraApaga("div_sub_menu", "block"); }, 500);
}

function carregando(){ 
	if(!pgcarregou){
		clearTimeout(tempo_carregando);
		document.getElementById("div_conteudo").innerHTML = '<div><br><br><br>' + flash("carregador.swf", "", 250, 25) + '</div>';
		document.getElementById("div_conteudo").style.display = "block";
	}
	else {
		clearTimeout(tempo_carregando);
		tempo_carregando = setTimeout("carregando()", 100);
	}
}

function flash(movie, flashvars, width, height){
	return '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,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 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>';
}

function janelao(url){
	w = screen.availWidth-10;
	h = screen.availHeight-50;
	open(url, "popupbusca", "width=" + w + ",height=" + h + ",left=0,top=0");
}

function z(n){
	return n<10?("0"+n):n;
}

function flashloaded(){
	loaded = 1;
}

function theMovie(moviename) {
    if(document.all) return document.all[moviename];
	else return document.embeds[moviename];
}

function busca(oque){
	if(oque!="null"&&oque!="undefined"){
		document.getElementById("div_conteudo").innerHTML = "";
		if(frame=="home"){
			MostraApaga("div_busca", "none");
			MostraApaga("div_home", "none");
			MostraApaga("div_conteudo", "block");
			MostraApaga("div_sub_menu", "block");
			theMovie('topo').AS_vaiInterna();
			frame = "interna";
		}
		frames["buffer"].location.href = url + "busca.asp?busca=" + oque;
	}
}

function imprimir(){
	if(pgatual==0) window.print();
	else {
		MostraApaga("iframe_buffer", "block");
		frames["buffer"].focus();
		frames["buffer"].print();
		MostraApaga("iframe_buffer", "none");
	}
}

// FALE CONOSCO

function fale(){

	var d = document.formulario;

	self.focus();
	
	if(d.grupo.value==""){ 
		alert(idioma=="port"? "Por favor escolha um grupo." : "Please type your name.");
		d.grupo.focus();
		return;
	}
	
	if(!d.inf[0].checked && !d.inf[1].checked){ 
		alert(idioma=="port"? "Por favor responda a pergunta 1" : "Please type your name.");
		return;
	}		
	
	if(!d.nivel[0].checked && !d.nivel[1].checked){ 
		alert(idioma=="port"? "Por favor responda a pergunta 2" : "Please type your name.");
		return;
	}			

	d.submit();
}