var IE = (navigator.userAgent.indexOf('MSIE') > -1);

var pastas = location.pathname;
pastas = pastas.split('/')

//marco o menu do topo
function marcaMenu(nome){
	var imgs = document.getElementById(nome).getElementsByTagName('img');
	var marcador = "";
	
	for(var a=2; a<pastas.length; a++){
		for(var i=0; i<imgs.length; i++){
			
			if(pastas[a] == "" || pastas[a] == "index.asp"){
				imgs[i].onmouseover = function(){
					if(this.src.split("/")[this.src.split("/").length - 1] == "rodape_menu.gif" || this.src.split("/")[this.src.split("/").length - 1] == "topo_menu.gif")
						return;
					this.src = this.src.substring(0, this.src.lastIndexOf('.')) + "_over.gif";
				}
				imgs[i].onmouseout = function(){
					if(this.src.split("/")[this.src.split("/").length - 1] == "rodape_menu.gif" || this.src.split("/")[this.src.split("/").length - 1] == "topo_menu.gif")
						return;
					this.src = this.src.substring(0, this.src.lastIndexOf('_')) + ".gif";
				}
			}
			else{
				if(pastas[a] == imgs[i].id){
					imgs[i].src = imgs[i].src.substring(0, imgs[i].src.lastIndexOf('.')) + "_over.gif";
					var marcador = i;
				}
				
				if(marcador != i){
					imgs[i].onmouseover = function(){
						if(this.src.split("/")[this.src.split("/").length - 1] == "rodape_menu.gif" || this.src.split("/")[this.src.split("/").length - 1] == "topo_menu.gif")
							return;
						this.src = this.src.substring(0, this.src.lastIndexOf('.')) + "_over.gif";
					}
					imgs[i].onmouseout = function(){
						if(this.src.split("/")[this.src.split("/").length - 1] == "rodape_menu.gif" || this.src.split("/")[this.src.split("/").length - 1] == "topo_menu.gif")
							return;
						this.src = this.src.substring(0, this.src.lastIndexOf('_')) + ".gif";
					}
				}
			}	
		}
	}
}

function mostrarMenuDinamico(){
	$("#menuInfeior li").hover(function(){
		$(this).find("div:first").show();
	},
		function(){
			$(this).find("div:first").hide();
		}
	);
}

var marcador = "";

//seleciona o menu lateral
function menuLateral(){
	try{
		// guardo os links do menu lateral
		var lista = document.getElementById('menu').getElementsByTagName('a');
		
		//faço um laço para encontrar cada uma das pastas
		for(var a=1; a<pastas.length; a++){
			//faço um laço para encontrar cada um dos links do menu
			for(var i = 0; i <lista.length; i++){
				//se a altura do link for maior que 20 pixels
				if(lista[i].offsetHeight > 20){
					//se o nome da pasta for igual ao id do link
					if(pastas[a] == lista[i].id){
						//o link recebe a class
						lista[i].className = "grandeOver";
						//o marcador recebe o valor de i
						marcador = i;
					}
					// se o marcador for diferente de i
					if(marcador != i){
						//o link recebe a class
						lista[i].className="grande";
						
						//crio uma variavel indice que recebe o valor de i
						lista[i].indice = i;
						
						//caso eu passe o mouse
						lista[i].onmouseover = function(){
							this.className = "grandeOver"
						}
						
						//caso eu tire o mouse
						lista[i].onmouseout = function(){
							if(this.indice != marcador)
								this.className = "grande"
						}
					}
				}
				
				//se a atura do item do menu for menor que 20px
				else{
					// se a pasta tiver o mesmo id do link
					if(pastas[a] == lista[i].id){
						// o link recebe a class
						lista[i].className="pequenoOver";
						//a variavel pai recebe o pai do intem clicado
						var pai = lista[i].parentNode
						// a ul do pai clicado aparece
						pai.getElementsByTagName('ul')[0].style.display = "block"
						//o marcador recebe i
						marcador = i;
					}
					
					// se marcador for diferente de i
					if((marcador != i) && (lista[i].className != "pequenoOver")){
						// o link recebe a class
						lista[i].className="pequeno";
						//crio uma variavel que recebe o valor de i
						lista[i].indice2 = i;
						//caso passe o mouse
						lista[i].onmouseover = function(){
							this.className = "pequenoOver";
						}
						//caso tire o mouse
						lista[i].onmouseout = function(){
							//se o indice for diferente do marcador
							if(this.indice2 != marcador)
								this.className = "pequeno";
						}
					}
				}
			}
		}
	}
	catch(e){};
		
}

//mostrarConteudo(): torna um conteudo visível
//	- id: id do conteudo a monstrar
//  - id: id da pergunta
function mostrarConteudo(id, pergunta){			
	document.getElementById(id).style.display = 'block';
	document.getElementById(pergunta).className = 'selecionado';
}

//esconderConteudo(): esconde um conteudo
//	- id: id do conteudo a esconder
function esconderConteudo(id, pergunta){
	document.getElementById(id).style.display = 'none';
	document.getElementById(pergunta).className = 'boxPergunta';
}

//trocarConteudo(): troca um conteudo visível por outro
//	-id: id do conteudo a trocar
var visivel = '';
var selecionado = '';
function trocarConteudo(id, pergunta){
	if(visivel.length > 0 && selecionado.length > 0) 
		esconderConteudo(visivel, selecionado);
	mostrarConteudo(id, pergunta);
	visivel = id;
	selecionado = pergunta;
}

function flashSemBorda(src, width, height, id, flashVars, wmode, menu, scale, Class){
	var ret = GetArguments(src, width, height, id, flashVars, wmode, menu, scale, Class);
	var str = '<object ';
	for (var i in ret.objAttrs)
		str += i + '="' + ret.objAttrs[i] + '" ';
	str += '>';
	for (var i in ret.params)
		str += '<param name="' + i + '" value="' + ret.params[i] + '" /> ';
	str += '</object>';
	document.write(str);
}


//GetArguments(): função auxiliar para retirar a borda dos flashes
//	- retorna os argumentos da tag object e os parametros
function GetArguments(src, w, h, id, flashVars, wmode, menu, scale, Class){
	var ret = new Object();
	ret.params = new Object();
	ret.objAttrs = new Object();

	ret.objAttrs['data'] = ret.params['movie'] = src;
	ret.objAttrs['width'] = w;
	ret.objAttrs['height'] = h;
	ret.params['quality'] = 'high';
	ret.objAttrs['type'] = 'application/x-shockwave-flash';
	ret.params['menu'] = 'false';
	ret.objAttrs['class'] = Class;
	
	if(id) ret.objAttrs['id'] = id;

	if(flashVars) ret.params['flashVars'] = flashVars;
	
	ret.params['wmode'] = (wmode)? wmode : 'transparent';
	ret.params['scale'] = (scale)? scale : 'exactfit';
	ret.params['menu'] = (menu)? menu : 'false';
	
	return ret;
}

function zebrado(pTabela){			
	var linhas = document.getElementById(pTabela).getElementsByTagName('li');	

	for(var i=0; i < linhas.length; i++){
		if(i % 2)
			linhas[i].className = 'linha_branca';
		else
			linhas[i].className = 'linha_cinza';
	}						
}


function favoritos(){
	url= location.href;
	title= document.title;
	
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "");
}

