/*------------------------------------------------------------------- 
Author's Statement:
This script is based on ideas of the author.
You may copy, modify and use it for any purpose. The only condition is that if you publish web pages that use this script you point to its author at a suitable place and don't remove this Statement from it.
It's your responsibility to handle possible bugs even if you didn't modify anything. I cannot promise any support.
Dieter Bungers
GMD (www.gmd.de) and infovation (www.infovation.de)
--------------------------------------------------------------------*/

var
	showNumbers = false, 		// indicar numeros del arbol: yes=true | no=false
	backColor = "#FFFFFF",	// color background del  ToC 
	normalColor = "#5E778F",	// color texto de las headlines ToC
	currentColor = "#666699",	// color text de la linea activa (clickeada)
	titleColor = "#5E778F",		// color text del título
	mLevel = 0,				// numero de niveles menos 1 presentados con fuente grande y bold
	textSizes = new Array(0.8, 0.8, 0.7, 0.7, 0.7),			// font-size factors for: [0] titulo, [1] fuentes grandes y bold para IE [2] fuentes pequeñas para IE [3] fuentes grandes y bold para Netscape [4] fuentes pequeñas para Netscape.
	fontTitle = "Arial,Helvetica", // font-family of the title "Table of Contents"
	fontLines = "Arial,Helvetica"; // font-family of the headlines  

if (navigator.appName.toLowerCase().indexOf("explorer") > -1) {
	var mdi=textSizes[1], sml=textSizes[2];
}
else {
	var mdi=textSizes[3], sml=textSizes[4];
}

function reDisplay2(currentNumber,currentIsExpanded) {
	var arbol_codigo = '';
	
	arbol_codigo = arbol_codigo + ("<table border='0' cellspacing=1 cellpadding=0>\n<tr>");
	var currentNumArray = currentNumber.split(".");
	var currentLevel = currentNumArray.length-1;
	var scrollY=0, addScroll=true, theHref="";
	for (i=0; i<tocTab.length; i++) {
		thisNumber = tocTab[i][0];
		var isCurrentNumber = (thisNumber == currentNumber);
		if (isCurrentNumber) theHref=tocTab[i][2];
		var thisNumArray = thisNumber.split(".");
		var thisLevel = thisNumArray.length-1;
		var toDisplay = true;
		if (thisLevel > 0) {
			for (j=0; j<thisLevel; j++) {
				toDisplay = (j>currentLevel)?false:toDisplay && (thisNumArray[j] == currentNumArray[j]);
			}
		}
		thisIsExpanded = toDisplay && (thisNumArray[thisLevel] == currentNumArray[thisLevel])
		if (currentIsExpanded) {
			toDisplay = toDisplay && (thisLevel<=currentLevel);
			if (isCurrentNumber) thisIsExpanded = false;
		}
		
		if (toDisplay) {
			if (i==0) {
				arbol_codigo = arbol_codigo + ("\n<td colspan=" + (nCols+1) + "><a href=\"javaScript:\parent.reDisplay2('" + thisNumber + "'," + thisIsExpanded + ")\" style=\"font-family: " + fontTitle + "; font-size:" + textSizes[0] + "em; color: " + titleColor + "; text-decoration:none\">" + tocTab[i][1] + "</a></td></tr>");
				for (k=0; k<nCols; k++) {
					arbol_codigo = arbol_codigo + ("<td></td>");
				}
				arbol_codigo = arbol_codigo + ("<td width=240></td></tr>");
				}
			else {
				if (addScroll) scrollY+=((thisLevel<2)?mdi:sml)*25;
				if (isCurrentNumber) addScroll=false;
				var isLeaf = (i==tocTab.length-1) || (thisLevel >= tocTab[i+1][0].split(".").length-1);
				img = (isLeaf)?"leaf":(thisIsExpanded)?"minus":"plus";
				arbol_codigo =  arbol_codigo + ("<tr>");
				for (k=1; k<=thisLevel; k++) {
					arbol_codigo = arbol_codigo + ("<td>&nbsp;</td>");
				}
				arbol_codigo = arbol_codigo + ("<td valign=top><a href=\"javaScript:parent.reDisplay2('" + thisNumber + "'," + thisIsExpanded + ");\"><img src=\"imagen/varios/" + img + ".gif\" width=13 height=12 border=0></a></td> <td colspan=" + (nCols-thisLevel) + "><a href=\"javaScript:\parent.reDisplay2('" + thisNumber + "'," + thisIsExpanded + ")\" style=\"font-family: " + fontLines + ";" + ((thisLevel<=mLevel)?"font-weight:":"") +  "; font-size:" + ((thisLevel<=mLevel)?mdi:sml) + "em; color: " + ((isCurrentNumber)?currentColor:normalColor) + "; text-decoration:none\">" + ((showNumbers)?(thisNumber+" "):"") + tocTab[i][1] + "</a></td></tr>");
			}
		}
	}
	arbol_codigo = arbol_codigo + ("</table>");
	//toc.document.close();
	//toc.scroll(0,scrollY);
	
	var theHrefArray = theHref.split("#");
	if (theHref != "") document.location.href = theHrefArray[0] + '&barra_menu_apertura=' + currentNumber + '#' + theHrefArray[1];
	
	//window.document.arbol_producto.innerHTML = arbol_codigo;
	$('arbol_producto').innerHTML = arbol_codigo;
}