/*
Fichero de funciones JavaScript para arbol de menu despelegable vertical
Autores: Bernardo y Jaime Alemany (2006)
*/ 
/*
hay dos clases de capas a recolocar las Menu y las SubMenu   
Las Menu tienen desplazamientos verticales para que quepan las SubMenu que estan ocultas
Cada vez que activamos una función se reposicionan todas las capas
*/
var HsubmenuA = 0;
var HsubmenuB = 0;
var HsubmenuC = 0;
var HsubmenuD = 0;
var PosReposoA = 0;
var PosReposoB = 0;
var PosReposoC = 0;
var PosReposoD = 0;
var PosReposoE = 0;
var PosReposoF = 0;
var HMenu = 25;
var Click = ' ';


//esta función captura la posición top de una imagen y atribuye su valor a las variables de posicionamiento
function capturar(){
HsubmenuA= imgB.offsetParent.offsetTop - imgA.offsetParent.offsetTop - HMenu;
HsubmenuB= imgC.offsetParent.offsetTop - imgB.offsetParent.offsetTop - HMenu;
HsubmenuC= imgD.offsetParent.offsetTop - imgC.offsetParent.offsetTop - HMenu;
HsubmenuD= imgE.offsetParent.offsetTop - imgD.offsetParent.offsetTop - HMenu;
//HsubmenuE= imgD.offsetParent.offsetTop;
PosReposoA = 0;
PosReposoB = PosReposoA - HsubmenuA;
PosReposoC = PosReposoB - HsubmenuB;
PosReposoD = PosReposoC - HsubmenuC;
PosReposoE = PosReposoD - HsubmenuD;
PosReposoF = PosReposoE ;
}
//esta función recoloca todas las capas Menu para que vuelvan a su posición inicial
function posicion0(){
document.getElementById("capasubmenuA").style.visibility="hidden";
document.getElementById("capasubmenuB").style.visibility="hidden";
document.getElementById("capasubmenuC").style.visibility="hidden";
document.getElementById("capasubmenuD").style.visibility="hidden";
document.getElementById("capamenuA").style.top= PosReposoA;
document.getElementById("capamenuB").style.top= PosReposoB;
document.getElementById("capamenuC").style.top= PosReposoC;
document.getElementById("capamenuD").style.top= PosReposoD;
document.getElementById("capamenuE").style.top= PosReposoE;
document.getElementById("capamenuF").style.top= PosReposoF;
}
//esta función recoloca todas las capas Menu cuando abrimos el Menu A
function posicionA()
{
if ( Click == 'A' )
{
	posicion0();
	Click = ' ';
	return;
}
document.getElementById("capasubmenuA").style.visibility="visible";
document.getElementById("capasubmenuB").style.visibility="hidden";
document.getElementById("capasubmenuC").style.visibility="hidden";
document.getElementById("capasubmenuD").style.visibility="hidden";
document.getElementById("capasubmenuA").style.top= PosReposoA;
document.getElementById("capamenuA").style.top= PosReposoA;
document.getElementById("capamenuB").style.top= PosReposoB + HsubmenuA;
document.getElementById("capamenuC").style.top= PosReposoC + HsubmenuA;
document.getElementById("capamenuD").style.top= PosReposoD + HsubmenuA;
document.getElementById("capamenuE").style.top= PosReposoE + HsubmenuA;
document.getElementById("capamenuF").style.top= PosReposoF + HsubmenuA;
Click = 'A';
}
//esta función recoloca todas las capas Menu cuando abrimos el Menu B
function posicionB(){
if ( Click == 'B' )
{
	posicion0();
	Click = ' ';
	return;
}
document.getElementById("capasubmenuA").style.visibility="hidden";
document.getElementById("capasubmenuB").style.visibility="visible";
document.getElementById("capasubmenuC").style.visibility="hidden";
document.getElementById("capasubmenuD").style.visibility="hidden";
document.getElementById("capasubmenuB").style.top= PosReposoB;
document.getElementById("capamenuA").style.top= PosReposoA;
document.getElementById("capamenuB").style.top= PosReposoB;
document.getElementById("capamenuC").style.top= PosReposoC + HsubmenuB;
document.getElementById("capamenuD").style.top= PosReposoD + HsubmenuB;
document.getElementById("capamenuE").style.top= PosReposoE + HsubmenuB;
document.getElementById("capamenuF").style.top= PosReposoF + HsubmenuB;
Click = 'B';
}
//esta función recoloca todas las capas Menu cuando abrimos el Menu C
function posicionC(){
if ( Click == 'C' )
{
	posicion0();
	Click = ' ';
	return;
}
document.getElementById("capasubmenuA").style.visibility="hidden";
document.getElementById("capasubmenuB").style.visibility="hidden";
document.getElementById("capasubmenuC").style.visibility="visible";
document.getElementById("capasubmenuD").style.visibility="hidden";
document.getElementById("capasubmenuC").style.top= PosReposoC;
document.getElementById("capamenuA").style.top= PosReposoA;
document.getElementById("capamenuB").style.top= PosReposoB;
document.getElementById("capamenuC").style.top= PosReposoC;
document.getElementById("capamenuD").style.top= PosReposoD + HsubmenuC;
document.getElementById("capamenuE").style.top= PosReposoE + HsubmenuC;
document.getElementById("capamenuF").style.top= PosReposoF + HsubmenuC;
Click = 'C';
}

//esta función recoloca todas las capas Menu cuando abrimos el Menu D
function posicionD(){
if ( Click == 'D' )
{
	posicion0();
	Click = ' ';
	return;
}
document.getElementById("capasubmenuA").style.visibility="hidden";
document.getElementById("capasubmenuB").style.visibility="hidden";
document.getElementById("capasubmenuC").style.visibility="hidden";
document.getElementById("capasubmenuD").style.visibility="visible";
document.getElementById("capasubmenuD").style.top= PosReposoD;
document.getElementById("capamenuA").style.top= PosReposoA;
document.getElementById("capamenuB").style.top= PosReposoB;
document.getElementById("capamenuC").style.top= PosReposoC;
document.getElementById("capamenuD").style.top= PosReposoD;
document.getElementById("capamenuE").style.top= PosReposoE + HsubmenuD;
document.getElementById("capamenuF").style.top= PosReposoF + HsubmenuD;
Click = 'D';
}

//esta función recoloca todas las capas Menu cuando abrimos el Menu E
function posicionE(){
if ( Click == 'E' )
{
	posicion0();
	Click = ' ';
	return;
}
document.getElementById("capasubmenuA").style.visibility="hidden";
document.getElementById("capasubmenuB").style.visibility="hidden";
document.getElementById("capasubmenuC").style.visibility="hidden";
document.getElementById("capasubmenuD").style.visibility="hidden";
document.getElementById("capamenuA").style.top= PosReposoA;
document.getElementById("capamenuB").style.top= PosReposoB;
document.getElementById("capamenuC").style.top= PosReposoC;
document.getElementById("capamenuD").style.top= PosReposoD;
document.getElementById("capamenuE").style.top= PosReposoE;
document.getElementById("capamenuF").style.top= PosReposoF;
Click = 'E';
}

//esta función recoloca todas las capas Menu cuando abrimos el Menu F
function posicionF(){
if ( Click == 'F' )
{
	posicion0();
	Click = ' ';
	return;
}
document.getElementById("capasubmenuA").style.visibility="hidden";
document.getElementById("capasubmenuB").style.visibility="hidden";
document.getElementById("capasubmenuC").style.visibility="hidden";
document.getElementById("capasubmenuD").style.visibility="hidden";
document.getElementById("capamenuA").style.top= PosReposoA;
document.getElementById("capamenuB").style.top= PosReposoB;
document.getElementById("capamenuC").style.top= PosReposoC;
document.getElementById("capamenuD").style.top= PosReposoD;
document.getElementById("capamenuE").style.top= PosReposoE;
document.getElementById("capamenuF").style.top= PosReposoF;
Click = 'F';
}

//esta función muestra la capa del submenu
function transic(nombreCapa){
tra=document.getElementById(nombreCapa);
tra.filters.alpha.opacity=0;
inFun=setInterval("fade(tra)",100);
setTimeout("clearInterval("+inFun+")", 1150 );
}
//esta función es para incrementar la opacidad
function fade(wtf){
wtf.filters.alpha.opacity+=10;
}

/*
function transic(){
textcontainerobj=document.getElementById("capasubmenuA");
textcontainerobj.style.visibility="visible";
textcontainerobj.filters.alpha.opacity=0;
highlighting=setInterval("fade(textcontainerobj)",200);
}
function fade(){
textcontainerobj.filters.alpha.opacity+=20
}
/*




//esta función muestra las subcapas asignando la posición xy a la subcapa escogida considerando las variables de posicionamiento
function mostrar(nombreCapa){
document.getElementById(nombreCapa).style.left=valorLeft + 20;
document.getElementById(nombreCapa).style.top=valorTop + 20;
document.getElementById(nombreCapa).style.visibility="visible";
}
//esta función oculta las subcapas asignando la posición xy a la subcapa escogida considerando las variables de posicionamiento
function ocultar(nombreCapa){
document.getElementById(nombreCapa).style.left=valorLeft - 30;
document.getElementById(nombreCapa).style.top=valorTop + 20;
document.getElementById(nombreCapa).style.visibility="visible";
}
//estas 2 funcionen muestran u ocultan la capa escogida 
function mostrar(nombreCapa){ 
document.getElementById(nombreCapa).style.visibility="visible"; 
} 
function ocultar(nombreCapa){ 
document.getElementById(nombreCapa).style.visibility="hidden"; 
}
/*
Fin del fichero
*/