<!-- Inicio Menú

var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

function getRef(id) {
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id]; 
}

function getSty(id) {
 return (isNS4 ? getRef(id) : getRef(id).style);
} 

// Tiempo hasta ocultar el menu.
var popTimer = 0;

// Array que muestra los items resaltados.
var litNow = new Array();

function popOver(menuNum, itemNum) {
  clearTimeout(popTimer);
  hideAllBut(menuNum);
  litNow = getTree(menuNum, itemNum);
  changeCol(litNow, true);
  targetNum = menu[menuNum][itemNum].target;
  if (targetNum > 0) {
   thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
   thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
   with (menu[targetNum][0].ref) {
    left = parseInt(thisX + menu[targetNum][0].x);
    top = parseInt(thisY + menu[targetNum][0].y);
    visibility = 'visible';
    }
   }
}

function popOut(menuNum, itemNum) {
  if ((menuNum == 0) && !menu[menuNum][itemNum].target)
    hideAllBut(0)
  else
    popTimer = setTimeout('hideAllBut(0)', 500);
}


function getTree(menuNum, itemNum) {

 // El indice del Array es el numero de menu. El contenido es null (si el menu no es un padre)
 // o el numero del item en el menu que es un antepasado (para resaltarlo).
 itemArray = new Array(menu.length);

 while(1) {
  itemArray[menuNum] = itemNum;
  // Si hemos llegado al tope de la jerarquia, return.
  if (menuNum == 0) 
     return itemArray;
  itemNum = menu[menuNum][0].parentItem;
  menuNum = menu[menuNum][0].parentMenu;
   }
}

// Le pasamos un array y un boolean para especificar el color de cambio, true = color resaltado.
function changeCol(changeArray, isOver) {
  for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
    if (changeArray[menuCount]) {
      newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
      // Change the colours of the div/layer background.
     with (menu[menuCount][changeArray[menuCount]].ref) {
       if (isNS4) 
	     bgColor = newCol;
       else backgroundColor = newCol;
     }//Fin with
    }//Fin if
   }//Fin for
}//Fin changeCol

function hideAllBut(menuNum) {
 var keepMenus = getTree(menuNum, 1);
 for (count = 0; count < menu.length; count++)
 if (!keepMenus[count])
   menu[count][0].ref.visibility = 'hidden';
 changeCol(litNow, false);
}

// *** FUNCIONES DE CONSTRUCCION DEL MENU ***

function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {
// True or false - horizontal o vertical menu?
this.isVert = isVert;
// The popout indicator used (if any) for this menu.
this.popInd = popInd
// Posicion y tamaño.
this.x = x;
this.y = y;
this.width = width;
// Color del menu y los items.
this.overCol = overCol;
this.backCol = backCol;
// La clase de estilo usada por el borde de los items y el texto de los items.
this.borderClass = borderClass;
this.textClass = textClass;
// Parent menu and item numbers, indexed later.
this.parentMenu = null;
this.parentItem = null;
// Reference to the object's style properties (set later).
this.ref = null;
}

function Item(text, href, frame, length, spacing, target) {
this.text = text;
this.href = href;
this.frame = frame;
this.length = length;
this.spacing = spacing;
this.target = target;
// Reference to the object's style properties (set later).
this.ref = null;
}

function writeMenus() {
if (!isDOM && !isIE4 && !isNS4) return;

for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
// Variable for holding HTML for items and positions of next item.
var str = '', itemX = 0, itemY = 0;

// Remember, items start from 1 in the array (0 is menu object itself, above).
// Also use properties of each item nested in the other with() for construction.
for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
var itemID = 'menu' + currMenu + 'item' + currItem;

// El width y el height de los items del menu dependen de la orientacion del mismo!
var w = (isVert ? width : length);
var h = (isVert ? length : width);

// Crear un div o layer con el estilo o propiedades del texto.
// En IE4, aparentemente el width tiene que ser como minimo de 3 para que funcione en el navegador.
if (isDOM || isIE4) {
str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
if (backCol) str += 'background: ' + backCol + '; ';
str += '" ';
}
if (isNS4) {
str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
if (backCol) str += 'bgcolor="' + backCol + '" ';
}
if (borderClass) str += 'class="' + borderClass + '" ';

// Add mouseover handlers and finish div/layer.
str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';

// Add contents of item (default: table with link inside).
// In IE/NS6+, add padding if there's a border to emulate NS4's layer padding.
// If a target frame is specified, also add that to the <a> tag.

str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + '<a class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>') + text + '</a></td>';
if (target > 0) {

// Set target's parents to this menu item.
menu[target][0].parentMenu = currMenu;
menu[target][0].parentItem = currItem;

// Add a popout indicator.
if (popInd) str += '<td class="' + textClass + '" align="right">' + popInd + '</td>';
}
str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');
if (isVert) itemY += length + spacing;
else itemX += length + spacing;
}
if (isDOM) {
var newDiv = document.createElement('div');
document.getElementsByTagName('body').item(0).appendChild(newDiv);
newDiv.innerHTML = str;
ref = newDiv.style;
ref.position = 'absolute';
ref.visibility = 'hidden';
}

// Inserta una etiqueta div para el final del BODY con menu HTML en el lugar para IE4.
if (isIE4) {
document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
ref = getSty('menu' + currMenu + 'div');
}

// En NS4, se crea una referencia a una nueva layer y se escriben los items en ella.
if (isNS4) {
ref = new Layer(0);
ref.document.write(str);
ref.document.close();
}

for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
itemName = 'menu' + currMenu + 'item' + currItem;
if (isDOM || isIE4) menu[currMenu][currItem].ref = getSty(itemName);
if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];
   }
}
with(menu[0][0]) {
ref.left = x;
ref.top = y;
ref.visibility = 'visible';
   }
}

// Sintaxis: 
//
// menu[NumeroMenu][0] = new Menu(Vertical menu? (true/false), 'indicador de que tiene un menu lateral', left, top,
// width, 'mouseover colour', 'background colour', 'border stylesheet', 'text stylesheet');
//
// Left and Top hacen referencia a la esquina superior izquierda de la pagina.
//
// menu[NumeroMenu][itemNumero] = new Item('Text', 'URL', 'target frame', longitud del item del menu,
//  espacio adicional hasta el siguiente item del menu, numero del menu lateral a mostrar);
//
// Si no se necesita el menu lateral establecer a 0 este valor. Ademas, si no se usan frames
// colocar una cadena vacia en 'target frame '.
//
// La 'longitud' indica el tamaño del item en la direccion del menu (vertical en este caso)
// y 'width' indica la dimension lateral del menu. 

var menu = new Array();
//Colores del submenu
var submenuOver = '#00f817';//color item del submenu resaltado 
var submenuBack = '#33cc33';//color de las opciones del submenu
var menuOver ='#00f817';//color item del menu resaltado
var menuBack='';// color de las opciones del menu

// Longitud por defecto para los items:
//   altura del item  si el menú es vertical 
//   ancho si es horizontal.
var defLength = 20;


// MENU principal a partir del cual se visualizan todas las opciones existentes.
menu[0] = new Array();
//Posicion del menu: 130 pixels desde el tope de la ventana y 0 pixels desde el borde izquierdo.
//El menu tiene de ancho 135 pixels.
menu[0][0] = new Menu(true, '>>', 0, 120, 138, menuOver, menuBack,  'itemBordert', 'itemText');
menu[0][1] = new Item(' CNPOURENSE ', '#', '', defLength , 1, 5);
menu[0][2] = new Item(' Calendario ', 'calendario.html', '', defLength , 1, 0);
menu[0][3] = new Item(' Mejores Marcas ', '#', '', 34 , 1, 1);
menu[0][4] = new Item(' Records', '#', '', defLength , 1, 2);
menu[0][5] = new Item(' Resultados', 'resultados.html', '', defLength , 1, 0);
menu[0][14] = new Item(' Album de Fotos', 'http://cnpourense.es/pabellonourense "TARGET="_blank"', '', defLength, 1, 0);
menu[0][7] = new Item(' Travesias', 'travesias.html', '', defLength , 1, 0);
menu[0][8] = new Item(' Convocatorias', 'convocatorias.html', '', defLength , 1, 0);
menu[0][9] = new Item(' Marcas Mínimas', '#', '', 34 , 1, 3);
menu[0][10] = new Item(' Normativa', '#', '', defLength , 1, 4);
menu[0][11] = new Item(' Trofeo Pedro Escudero ', 'pedroescudero.html', '', 34, 1, 0);
menu[0][12] = new Item(' Enlaces', 'enlaces.html', '', defLength , 1, 0);
menu[0][13] = new Item(' Contacta', 'contacta.html', '', defLength , 2, 0);
menu[0][6] = new Item(' Clasificación Nadadores Club', 'clasificacionclub.html', '', 34 , 1, 0);
menu[0][15] = new Item(' Videos', 'videos.html', '', defLength, 1, 0);
menu[0][16] = new Item(' Chat', 'http://cnpourense.es/pabellon/chat "TARGET="_blank"', '', defLength, 1, 0);
menu[0][17] = new Item(' Nuevo', 'nuevo.html', '', defLength, 1, 0);


//itemBorderd:clase de la CSS que muestra el borde de las opciones en negro y de 1 pixel de ancho
//itemText:clase de la CSS que muestra el texto en blanco, con tipo de letra da la familia Arial y de tamaño 12.
//MEJORES MARCAS menu.
menu[1] = new Array();
menu[1][0] = new Menu(true, '', 140, 0, 100, submenuOver, submenuBack, 'itemBorderd', 'itemText');

menu[1][1] = new Item('Ourense', 'mejoresmarcaspro.html', '', defLength, 0, 0);
menu[1][2] = new Item('Galicia', 'mejoresmarcasgal.html', '', defLength, 0, 0);
menu[1][3] = new Item('España', 'mejoresmarcasnac.html', '', defLength, 0, 0);

//RECORDS menu.
menu[2] = new Array();
menu[2][0] = new Menu(true, '', 140, 0, 100, submenuOver, submenuBack, 'itemBorderd', 'itemText');
menu[2][1] = new Item('Provinciales', 'recordspro.html', '', defLength, 0, 0);
menu[2][2] = new Item('Gallegos', 'recordsgal.html', '', defLength, 0, 0);
menu[2][3] = new Item('Nacionales', 'recordsnac.html', '', defLength, 0, 0);

// MARCAS MÍNIMAS menu.
menu[3] = new Array();
menu[3][0] = new Menu(true, '', 140, 0, 100, submenuOver, submenuBack, 'itemBorderd', 'itemText');
menu[3][1] = new Item('Gallegas', 'minimasgallegas.html', '', defLength, 0, 0);
menu[3][2] = new Item('Nacionales', 'minimasnacionales.html', '', defLength, 0, 0);

// NORMATIVA menu.
menu[4] = new Array();
menu[4][0] = new Menu(true, '', 140, 0, 100, submenuOver, submenuBack, 'itemBorderd', 'itemText');
menu[4][1] = new Item('Gallega', 'normativagallega.html', '', defLength, 0, 0);
menu[4][2] = new Item('Nacional', 'normativanacional.html', '', defLength, 0, 0);

// CLUB menu.
menu[5] = new Array();
menu[5][0] = new Menu(true, '', 140, 0, 100, submenuOver, submenuBack, 'itemBorderd', 'itemText');
menu[5][1] = new Item('Directiva', 'directiva.html', '', defLength, 0, 0);
menu[5][2] = new Item('Nadadores', 'nadadores.html', '', defLength, 0, 0);

// Manejar el bug en NS4 para el cambio de tamaño de las ventanas.
var popOldWidth = window.innerWidth;
nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');

// Captura todos los clicks del documento y oculta los menus
// cada vez que se haga click en uno de ellos. 

if (isNS4) document.captureEvents(Event.CLICK);
document.onclick = clickHandle;

function clickHandle(evt)
{
 if (isNS4) document.routeEvent(evt);
 hideAllBut(0);
}

// Comando de mover para el ejemplo.

function moveRoot()
{
 with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);
}

//  Fin Menu -->
