// Title: tigra menu MODIFICADISIMO
// Description: See the demo at url
// URL: http://www.softcomplex.com/products/tigra_menu/
// Version: 1.0
// Date: 01-09-2002 (mm-dd-yyyy)
// Contact: feedback@softcomplex.com (specify product title in the subject)
// Notes: Registration needed to use this script on your web site.
// 	Registration for this version (1.0) is free of charge.
//	See official site for details

// Modificado para hacer un indice sencillo

var menus = [];
var nivel=0;
var inicio='ERROR';
var final='ERROR';

// --- menu class ---
function indice (entradas, nombre) {
	// browser check
	this.entradas = entradas;
	this.id = menus.length;
	this.items = [];
	this.children = [];
	this.add_item = menu_add_item;
	
	var i;
		document.write ('<H2>'+nombre+'</H2>');
	for (i = 0; i < this.entradas.length; i++)
		new menu_item(i, this, this);
	var j;
	for (j = 0; nivel>0; nivel--) 
		document.write ('</UL>');

	menus[this.id] = this;
}
function menu_add_item (item) {
	var id = this.items.length;
	this.items[id] = item;
	return (id);
}
// --- menu item Class ---
function menu_item (path, parent, container) {
	this.path = new String (path);
	this.parent = parent;
	this.container = container;
	this.arrpath = this.path.split('_');
	this.depth = this.arrpath.length - 1;
	// get pointer to item's data in the structure
	var struct_path = '', i;
	for (i = 0; i <= this.depth; i++)
		struct_path += '[' + (Number(this.arrpath[i]) + (i ? 2 : 0)) + ']';
	eval('this.fields = this.container.entradas' + struct_path);
	if (!this.fields) return;
	
	// these methods may be different for different browsers (i.e. non DOM compatible)
	this.init = mitem_init;
	
	// register in the collections
	this.id = this.container.add_item(this);
	parent.children[parent.children.length] = this;
	
	// init recursively
	this.init();
	this.children = [];
	var child_count = this.fields.length - 2;
	for (i = 0; i < child_count; i++)
		new menu_item (this.path + '_' + i, this, this.container);
	
}
function mitem_init() {

	var enlace = this.fields[1];
	inicio='<LI>';
	final='</LI>';
	if (this.depth==0) 
		{
		inicio='<H4>';
		final='</H4>';
		};
	if (this.depth>nivel) {inicio='<UL>'+inicio};
	if (this.depth<nivel) 
		{
		for (j = 0; this.depth<nivel; nivel--) 
			inicio='</UL>'+inicio;
	};
	
	if (enlace == null) 
		{
		document.write (inicio +'<a name="#'+this.fields[0]+'" href="#'+this.fields[0]+'"><B>'+ this.fields[0]+ "</B></a>\n" + final)
		}
	else 
		{
		document.write (inicio + '<a href="' + enlace + '"> ' + this.fields[0]+"</a>\n" + final)
		}
 
	
	nivel=this.depth;

}

