

var iMenus=0;
var ichild=0;
var isubChild=0;

var sArrowSelecionado;

// --------------------------------------------------------------------------------------------
// Style for hiding and showing elements.
// These styles are both IE and Netscape 6 compatible.
// Using these styles will make Netscape collapse all div elements. :)
// --------------------------------------------------------------------------------------------
//HIDE
// oElement.style.visibility="hidden";
// oElement.style.display = "none";

//SHOW
//oElement.style.visibility="visible";
//oElement.style.display="block";
// --------------------------------------------------------------------------------------------


// --------------------------------------------------------------------------------------------
// This function will hide all child and subchild elements in the page, as soon as the page opens.
// --------------------------------------------------------------------------------------------
function InitPage(){
	tempColl = document.getElementsByTagName("div");
	for(i=0;i<tempColl.length;i++){
		if((tempColl[i].className=="child")||(tempColl[i].className=="subChild")){
			tempColl[i].style.visibility="hidden";
			tempColl[i].style.display="none";
		}
		else {
			tempColl[i].style.visibility="visible";
			//tempColl[i].style.display="inline";
			tempColl[i].style.display="block";
		}
	}
}

// --------------------------------------------------------------------------------------------
// This function is called whenever an outer menu is selected.
// Parameters:
//	el - An object representing the element clicked on. Typically passed as "this" by the caller.
//
// Note:
//  numMenus is a global variable representing the number of first-level menu entries. It is
// 		calculated during ASP execution. (See navigation template for details).
// --------------------------------------------------------------------------------------------
function expandMenu(el){
	var ncc; 	//representa SubChild Menus (nível 3)
	var nc;		//representa Child Menus (nível 2)
	var n;		//nº de filhos que cada menu nível 1 tem
	
	try{
	
	//esconde todos os menus (nível 2) excepto os do menu que é seleccionado
	for(i=1 ; i<=numMenus ; i++){
		
		// for each child level 2 sub-menu...
		for(j=1 ; document.getElementById("el"+i+"Child"+(j)) != null ; j++){
			
			// get a pointer to the sub-menu
			nc = document.getElementById("el"+i+"Child"+j);
			
			// if the sub-menu exists...
			if ( nc != null )
			{
				// hide it if it's being shown and if it's not a child of the expanded menu
				if( (nc.style.display=="block") && (nc != document.getElementById(el.id+"Child"+j)) ) 
				{
					nc.style.visibility="hidden";
					nc.style.display="none";
				}
			}

			// para recolher os menus de nível 3 - não aplicável para menus de profundidade 2
			// hide the div containing all subchildren.
			ncc = document.getElementById(nc.id+"SubChild");
			if (ncc != null)
			{
				ncc.style.visibility="hidden";
				ncc.style.display="none";				
			}
		}
	}
	
	
	
	//Comuta o valor do style.display dos Child Menus do menu seleccionado
	
	// for each child of the clicked menu
	
 	for(j=1 ; document.getElementById(el.id + "Child"+(j)) != null ; j++){
 	
 		// get a pointer to the menu 		
		n=document.getElementById(el.id+"Child"+j);
		
		// if the menu exists...
		if(n!=null) {
		
			// if it's shown...
			if(n.style.display=="block")			
			{
				// hide it!
				n.style.visibility="hidden";
				n.style.display="none";
			}
			else
			{
				// show it!
				n.style.visibility="visible";
				n.style.display="block";
			}
		}
	}
	}
	catch(err) {
		alert("Javascrit error: " + err)
	}
}

// --------------------------------------------------------------------------------------------
// This function is called whenever an outer menu is selected.
// Parameters:
//	el - An object representing the element clicked on. Typically passed as "this" by the caller.
//
// --------------------------------------------------------------------------------------------
function expandSubMenu(el){
	var nc;
	var menus;

	//obtem referência para o Parent Menu (nível 1)
	nc=new String(el.id);
	menus =nc.slice(0,3);

	//percorre e recolhe todos os menus de nível 2
	tempColl = document.getElementsByTagName("div");
	for( j=0 ; j<tempColl.length ; j++){
		if (tempColl[j].id==menus){
			for(i=1;i<=(tempColl[j].childNodes.length);i++){

				nc=document.getElementById(menus+"Child"+i+"SubChild");
				if((nc!=null) && (nc.style.display=="block")&&(nc!=document.getElementById(el.id+"SubChild"))){
				
				//if((nc!=null) && (nc.style.display=="inline")&&(nc!=document.getElementById(el.id+"SubChild"))){
					nc.style.visibility="hidden";
					nc.style.display="none";
					}

			}
		}
	}
	//Comuta o valor do style.display dos Child Menus do menu (nível 2) que foi seleccionado.
	n=document.getElementById(el.id+"SubChild");
	
	if(n!=null)
	{
		if(n.style.display=="block")
		{	
			n.style.visibility="hidden";
			n.style.display="none";
		}
		else {
			n.style.visibility="visible";
			n.style.display="block";
		}
	}
}

function mudaConteudo(url){
	var tempColl;
	tempColl=document.getElementsByTagName("iframe");
	
	for (i=0;i<tempColl.length;i++){
		if (tempColl[i].id=="conteudo"){
			tempColl[i].src=url; 
		}
	}
}

function ChangeSourceOnMousseOver(id,cmsResource){
var inq = document.getElementById(id).src.indexOf('redArrow.gif');
	if(inq > 0){
		sArrowSelecionado = document.getElementById(id).id;
		return;
	}
	document.getElementById(id).src = cmsResource;
}

function ChangeSourceOnMousseOut(id,cmsResource){
if(sArrowSelecionado == document.getElementById(id).id) return;
document.getElementById(id).src = cmsResource;
}
