 // Menu colapsable
var actual = "no";
var ratonX = 0;
var ratonY = 0;
evt = null;
isDHTML = 1;
categoriaActiva = '';
estaDentro = 0;
function cambiaMenu ( objectID ) {
	if ( actual != "no" && actual != objectID ) {
		toggleClamShellMenu ( actual );
	}
	if ( actual == objectID ) {
		actual = "no";
	} else {
		actual = objectID;
	}
	toggleClamShellMenu ( objectID );
	if ( categoriaActiva != '' ) {
		setClass( categoriaActiva, 'categoria_normal' );
	}
}

function toggleClamShellMenu( objectID ) {
	// Añadido especificamente para el site porque los menus 2 y 7 no tienen subopciones
	if ( isAll || isID ) {
		domStyle = findDOM( objectID, 1 );
		if ( domStyle.display == 'block' ) {
			domStyle.display = 'none';
		} else {
			domStyle.display = 'block';
		}
	} else {
		//no ponemos alternativa si nos da igual los navegadores sin capacidad de scripting
		}
	return;
}

function setVisibility(objectID,state) {
	var dom = findDOM(objectID,1);
	dom.visibility = state;
}

function toggleVisibility(objectID) {
	var dom = findDOM(objectID,1);
	state = dom.visibility;
	if (state == 'hidden' || state == 'hide' )
		dom.visibility = 'visible';
	else {
		if (state == 'visible' || state=='show')
			dom.visibility = 'hidden';
	else dom.visibility = 'visible';
	}
}

function muestraGrupos ( categoria, fichero, nombre, idSpan, idEnlace ) {
	capa = findDOM( 'ventanaGrupos', 0 );
	capa2 = findDOM( 'ventanaGrupos', 1 );
	enlaces = '';
	seguir = true;
	indice = 0;
	if ( capa.visibility = "visible" ) {
		capa2.visibility="hidden";
	}
	enlaces += '<h2 style="color:#ff7f2b;display: block;">' + nombre + '</h2>';
	if ( fichero == "resultados" ) {
		pretitulo = "Resultados y clasificación: ";
	}
	if ( fichero == "proxima" ) {
		pretitulo = "Próxima jornada: ";
	}
		if ( fichero == "calendario" ) {
		pretitulo = "Calendario: ";
	}
	while ( seguir ) {
		while ((indice < jsMenu_grupos.length )&& (jsMenu_grupos[ indice][ 0 ] == categoria )) {
			enlaces += '<a href="index.php?id=' + fichero + '.php&grupo=' + jsMenu_grupos[ indice][ 1 ];
			enlaces += '">' + jsMenu_grupos[ indice][ 2 ] + '</a>';
			indice++;
			seguir = false;
		}
		indice++;
	}
	capa.innerHTML = enlaces;
	posX = findLeft( 'menu' + idSpan + 'a' + idEnlace ) + 140;
	posY = findTop( 'menu' + idSpan + 'a' + idEnlace ) + 200;
	moveObjectTo( 'ventanaGrupos', posX, posY );
	toggleVisibility( 'ventanaGrupos' );
	if ( categoriaActiva != '' ) {
		setClass( categoriaActiva, 'categoria_normal' );
	}
	categoriaActiva = 'menu' + idSpan + 'a' + idEnlace;
	setClass( categoriaActiva, 'categoria_activa' );
}
function escondeGrupos() {
		setVisibility( 'ventanaGrupos', 'hidden' );
		/*setClass( categoriaActiva, 'categoria_normal' );
		categoriaActivaRara = categoriaActiva;
		categoriaActiva = '';
		setClass( categoriaActivaRara, 'categoria_normal' );*/
}
function meteDentro() {
	setVisibility( 'ventanaGrupos', 'visible' );
	/*setClass( categoriaActivaRara, 'categoria_activa' );*/
}
function defaultEvents( evt ) {
	if (isDHTML) {
		document.onmousemove = dummy;
	}
}
function dummy(evt) {
	if (event.pageX != null) {
		ratonX = event.pageX;
		ratonY = event.pageY;
		return;
	}
	else {
		ratonX = event.x;
		ratonY = event.y;
		return;
	}
}

function findLeft(objectID) {
	var domStyle = findDOM(objectID,1);
	var dom = findDOM(objectID,0);
	if (domStyle.left)
		return domStyle.left;
	if (domStyle.pixelLeft)
		return domStyle.pixelLeft;
	if (dom.offsetLeft)
		return dom.offsetLeft;
	return (null);
}
function findTop(objectID) {
	var domStyle = findDOM(objectID,1);
	var dom = findDOM(objectID,0);
	if (domStyle.top)
		return domStyle.top;
	if (domStyle.pixelTop)
		return domStyle.pixelTop;
	if (dom.offsetTop)
		return dom.offsetTop;
	return (null);
}
function moveObjectTo(objectID,x,y) {
	var domStyle = findDOM(objectID,1);
		domStyle.left = x + 'px';
		domStyle.top = y + 'px';
}
function setClass( objectID, newClass ) {
	var dom = findDOM( objectID, 0 );
	dom.className = newClass;
}
function abrePopUp ( enlace, w, h ) {
	parametros = "width=" + w + ",height=" + h + ",toolbar=no,scrollbars=no,";
	parametros += "location=no,directories=no,menubar=no,resizable=no";
	ventana = window.open( 'foto_pop_up.php?enlace=' + enlace, "PopUp", parametros);
	ventana.focus();
}
function abreGPopUp( enlace, w, h ) {
	parametros = "width=" + w + ",height=" + h + ",toolbar=no,scrollbars=no,";
	parametros += "location=no,directories=no,menubar=no,resizable=no";
	ventana = window.open( 'galeria_popup.php?id=' + enlace, "GPopUp", parametros);
	ventana.focus();
}
