document.write ('<script src="../_lgl.js"></script>');

Definir('Seccion', 'Novelas');

// -- Índice Nuevo
var Novelas = new Array();
var ndx = -1;
var ListaNovelas = '';

var Seccion = new Array ('Ciencia-Ficción'
	/*cami*/ ,'El camino sin fin', 'emf-030'
	/*dest*/ ,'Desterrados de la galaxia', 'lcde-594'
	/*homb*/ ,'¿Hombre o m&aacute;quina?', 'lcde-656'
	/*maqr*/ ,'Máquinas rebeldes', 'lcde-018'
	/*misi*/ ,'Misi&oacute;n 1/1000', 'lcde-504'
	/*nohu*/ ,'Los no humanos', 'hde-235'
	/*obje*/ ,'Objetivo: El hombre', 'bse-024'
	/*pais*/ ,'El pa&iacute;s de los robots', 'emf-087'
	/*plan*/ ,'El planeta hombre', 'lcde-511'
	/*quie*/ ,'¿Qui&eacute;n compra un planeta?', 'lcde-591'
	/*secr*/ ,'El secreto del doctor Tyne', 'lcde-028'
	/*unce*/ ,'Un cerebro de ida y vuelta', 'lcde-536'
);
Novelas[++ndx] = Seccion;
ListaNovelas = SeccionC(Seccion[0]);


var Seccion = new Array ('Bélico'
	/*capi*/ ,'El capit&aacute;n Malapata', 'rg-sn01'
	/*homr*/ ,'Hombro con hombro', 'hb-0572'
	/*muer*/ ,'Muerte en lo profundo', 'm-035'
	/*ultm*/ ,'La &uacute;ltima colina', 'rg-0304'
	/*unof*/ ,'Un oficio peligroso', 'hb-0512'
	/*tres*/ ,'Tres p&aacute;jaros de un tiro', 'rg-0320'
);
Novelas[++ndx] = Seccion;
ListaNovelas = ListaNovelas + ', ' + SeccionC(Seccion[0]);


var Seccion = new Array ('Terror'
	/*lobo*/ ,'¡Lobos!', 'st-0035'
	/*danz*/ ,'La danza de los fantasmas', 'st-0368'
);
Novelas[++ndx] = Seccion;
ListaNovelas = ListaNovelas + ', ' + SeccionC(Seccion[0]);


var Seccion = new Array ('Policiaco'
	/*sarg*/ ,'La sargento Brown, culpable de asesinato', 'ss-1658'
	/*unac*/ ,'Una chica con ganas de jaleo', 'pr-0960'
	/*vaca*/ ,'Vacaciones sin crimen, vacaciones perdidas', 'pr-1034'
);
Novelas[++ndx] = Seccion;
ListaNovelas = ListaNovelas + ', ' + SeccionC(Seccion[0]);

var Seccion = new Array ('Western'
	/*juic*/ ,'El juicio de Helen Cross', 'bsa-0727'
	/*prob*/ ,'Problemas resueltos a tiros', 'oeste-sn01'
);
Novelas[++ndx] = Seccion;
ListaNovelas = ListaNovelas + ', ' + SeccionC(Seccion[0]);

var Seccion = new Array ('Artes marciales'
	/*reclam*/ ,'El reclamo', 'kiai-0048'
);
Novelas[++ndx] = Seccion;
ListaNovelas = ListaNovelas + ', ' + SeccionC(Seccion[0]);


// --------------------------------------------------------------
function ConstruyeIndice() {
var c, l, n, EnlacesCapas

c = NombrePagina(0);
if (c == 'index' || c == '') { 	// presenta una sección aleatoria en el índice.
	n = Aleatorio(0, Novelas.length -1);
	l = Novelas[n][0];
} else { // Seccion del archivo
	for (n = 0; n < Novelas.length; n++) {
		if (DetectaSeccion(Novelas[n], c) == true) {
			l = Novelas[n][0];
			break;
		}
	}
}
Definir('LGLSeccion', SeccionC(l));

document.writeln ('<div>\n' + 
				'<a href="/autores/lgl/documentos/index.html" target="_top" class="rotuloC sinsub m20">Novelas</a>\n' +
			'<hr />\n');


// Indice secciones
document.write('<div id="capas">\n');
for(x = 0; x < Novelas.length; x++) {
	capa = SeccionC(Novelas[x][0]);
	clase="broj";
	estilo = "margin-left:0px; font-weight:normal;"
	if (capa == Obtener('LGLSeccion')) {
		clase="bver";
		estilo = "margin-left:20px; font-weight:bold;"
	}
	document.write('<a href="javascript:Mostrar(\'' + capa + '\');" id="enl_' + capa + '" '+
					'style="' + estilo + '" class="' + clase + '">' + Novelas[x][0] + '</a><br />\n');
}
document.write('</div>\n<hr />\n\n');

// Indice por sección
for (n = 0; n < Novelas.length; n++) {
	IndiceSeccion(Novelas[n]);
}

document.write('<hr />\n</div>');

}
// --------------------------------------------------------------

// --------------------------------------------------------------
function IndiceSeccion(mS) {

	CapaC = SeccionC(mS[0]); 
	CapaA = Obtener('LGLSeccion');

	document.write('<div style="display:' + (CapaC == CapaA ? "block" : "none") + ';" id="' + CapaC + '">\n' +
				'<div class="item"><b>' + mS[0] + '</b></div>\n'+
			'<hr />\n');

	for (n = 1; n < mS.length; n = n + 2) {
		document.write('\t<div class="item"' + (mS[n+1] == NombrePagina(0) ? ' style="font-weight:bold;"': '') + '>\n' +
				'\t\t<a href="' + vbLcase(mS[n+1]) + '.htm" class="bmar" target="_top">' + mS[n] + '</a>\n' +
			'\t</div>\n');
	}	

	document.write(	'</div>\n\n');

}
// --------------------------------------------------------------

// Muestra el indice de una sección (ocultando el resto) y además un archivo aleatorio
/* ---------------------------------------------------------- */
function Mostrar(CapaA) {
	
	var Ln = vbSplit(ListaNovelas, ',');
	
	for (m = 0; m < Ln.length; m++) {
		VerNoVer(Ln[m], 0);
	}
	VerNoVer(CapaA, 1); 

	Definir('LGLSeccion', CapaA);

	for (n = 0; n < Novelas.length; n++) {
		if (CapaA == SeccionC(Novelas[n][0])) { 
			l = (Novelas[n].length - 1) / 2;
			a = (Aleatorio(1, l) * 2);
			location.href = vbLcase(Novelas[n][a]) + '.htm';
			break;
		}
	}

	return false;

} /* ---------------------------------------------------------- */

// Depura el nombre de la sección para que pueda usarse como nombre de capa.
/* ---------------------------------------------------------- */
function SeccionC(Parametro) {
	return vbReplace(vbReplace(QuitarAcentos(vbLcase(Parametro)), ' ', ''), '-', '');
}
/* ---------------------------------------------------------- */

// Detecta la sección del archivo.
/* ---------------------------------------------------------- */
function DetectaSeccion(mS, Pagina) {

	var z = false;
	for (m = 1; m < mS.length; m = m + 2) {
		if (vbLcase(mS[m+1]) == Pagina) {
			z = true;
			break;
		}
	}	
	return z;
}
/* ---------------------------------------------------------- */
