//VARIAVEL QUE GUARDA O NOME DAS PASTAS NA URL
var pastas = location.href.split("/");

// MENU LATERAL 
function mostraMenu(nome){
	try{
		//varialvel que guarda a identidade das uls na id passada por parametro
		identidade = document.getElementById(nome).getElementsByTagName('ul');
		
		for(var i=3; i < pastas.length; i++){
			for(var a=0; a < identidade.length; a++){
				links = identidade[a].getElementsByTagName('a');
				for(var b=0; b < links.length; b++){
					if(i==pastas.length-2) {
						if(pastas[i]=='investidores') {
							if(links[b].id == "rede_energia"){
								links[b].className = "marcado";
							}
						}
						if(pastas[i] == links[b].id){
							links[b].className = "marcado";
							if(pastas[i] == "pesquisadores_estudantes"){
								links.pesquisadores_estudantes.className = "ultimomarcado";
							}
						}
					}
				}
				if(pastas[i] == identidade[a].id){
					identidade[a].className = "mostra";
				}
				// exibir menus abertos na home
				else if(pastas[i] == "" || pastas[i] == "index.asp"){
					document.getElementById('consultas').className = "mostra";
					document.getElementById('servicos').className = "mostra";
					document.getElementById('utilidades').className = "mostra";
					document.getElementById('agenciaVirtual').className = "mostra";
					// mostrar data e esconder ferramentas
					document.getElementById('data').className = "mostra";
					document.getElementById('ferramentas').className = "esconde";
					// mostrar pesquisadores e estudantes
					//document.getElementById('pesquisadores_estudantes').className = "mostra";
				}	
				if((pastas[i] == "empresa") && (identidade[a].id == "cross_empresa")){
					identidade[a].className = "mostra";					
				}	
			}	
		}
	}
	catch(e){}
}

//ABRE
var anterior = "0"

function abre(id){
	try{
		document.getElementById(anterior).className = "esconde";
	}	
	catch(e){}		
	document.getElementById(id).className = "mostra";
	anterior = id;
}

//FECHA
function fecha(id){
	document.getElementById(id).className = "esconde";
}

//FECHA DIV
function fechaDiv(id){
	document.getElementById(id).style.display = "none";
} 


/* Retira a borda dos flashes
Copyright 2006 Adobe Systems, Inc. All rights reserved.
Versão compacta, alterada por Renato Herculano
	- src, width e height são obrigatórios
	- os demais parametros são opcionais
*/
function flash(src, width, height, id, flashVars, wmode, menu, scale){
	var ret = GetArguments(src, width, height, id, flashVars, wmode, menu, scale);
	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){
	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';
	
	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;
}

//FUNCAO POPUP SEM NOVA PAGINA
function mostraPopUp(nome,largura,altura,imagem,scroll){
	var janela = window.open('','popUp','scrollbars='+ scroll +',width='+ largura +',height='+ altura +'');
	janela.document.write('<html><head><title>Enersul - Energias do Brasil - Geração, Comercialização e Distribuição de Energia Elétrica</title></head><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"><img src="' + imagem + '" border="0"></body></html>');	
}

//abrirPopup(): abre uma popup
//	- url: caminho da janela a abrir
//	- width: width da popup
//	- height: height da popup
//  - scroll(opcional): se a pop-up terá scroll
function abrirPopup(url, width, height,scroll){
	var parametro = 'width=' + width + ', height=' + height;
	if(scroll)
		parametro += ', scrollbars =' + scroll;	
	window.open(url, '', parametro);
}	


var guarda = "";

//exibir e esconder conteúdo de uma div
function mostraDiv(idDiv){							
	
	var definicao = document.getElementById(idDiv);		
	
	if(guarda == definicao){
		definicao.className = "esconde";
		guarda = "";
	}
		
	else{
		guarda.className = "esconde";
		definicao.className = "mostra";	
		guarda = definicao;	
	}
			
}    

/* funcoes para linkar e sinalizar combos */
function envieTopo(){	
	if (document.title.indexOf('#') > - 1){
		document.envieAmigo.linkNome.value = document.title.substring(document.title.lastIndexOf("- ") + 1, document.title.indexOf('#'));
	}
	else{			
		document.envieAmigo.linkNome.value = document.title.substring(document.title.lastIndexOf("- ") + 1);
		
	}	
	
	document.envieAmigo.linkNome.value = 'Clique aqui'
	document.envieAmigo.url.value = location.href;
	document.envieAmigo.submit();
}

//SUBMETE LOGIN
function doKey($key) {
  if ($key == 13) {
     form1.submit();
   }
 }
 
//FAVORITOS
function favoritos(){	
	url="http://www.enersul.com.br"
	title="enersul - energias do brasil"	
	if (document.all)	
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
} 


function btAt(){
	try{
		 //MUDA O 0800
 		var caminho = location.search;
		caminho = caminho.split('=')[2];
		caminho = caminho.split('&')[0];
		
		
		var telefone = document.getElementById('topoIframe');
		var parametros = ['loginat','consdeb','consfat','histcons','histdem','acertocadat','altdemat','endentregat','vertensaoat','altarifat']
	
	
	//alert(telefone)
	
		for(var a=0; a<parametros.length; a++){
			if(caminho == parametros[a]){
				telefone.src = "http://www.enersul.com.br/includes/topo_iclass_at.asp"
			}
		}
	}
	catch(e){}
}

window.onload = function(){
	btAt();
}



// LISTA ESTADO
function faq(idFaq, idMostrar) {
	asDuvidas = document.getElementById(idFaq).getElementsByTagName("dd").length;

	for(i=0; i<asDuvidas; i++) {
		
		if(document.getElementById(idFaq).getElementsByTagName("dd")[i].id != 'lst_' + idMostrar) {
			document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'none';
			document.getElementById(idFaq).getElementsByTagName("dt")[i].className = '';
		}
		else {
		
			if(document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display != 'block') {
				document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'block';
				document.getElementById(idFaq).getElementsByTagName("dt")[i].getElementsByTagName("a")[0].className = 'hoverDt';
			}
			else {
				document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'none';
				document.getElementById(idFaq).getElementsByTagName("dt")[i].getElementsByTagName("a")[0].className = '';
			}
			
		}
	}
}


