/* _____________________________________________________________________________________________________

    Class: ArbolVertical
    ________________________________________________________________________________________________________

    Creación de un árbol vertical.

    Parametros:

        datos_arb            - Array con los datos de montage del arbol (ver <Anexo I>).
        IMAGENES             - Array con las imágenes (como objetos) que usará el sistema.
        CLASES               - Array con los nombres de las clases de estilo que afectarán al sistema.
        functionclick        - Función a ejecutar en el elemento onclick de cada nodo. Null si no aplica.
        indentacion          - Valor numérico que será el valor en pixel de la indentación entre niveles.
        	Por defecto toma valor 5. Null si no aplica.
        separador            - Carácter separador para cada registro de *datos_arb*. Por defecto toma valor ":".
        	Null si no aplica.

    Uso:
    
	var foo = new ObjArbol (datos_arb, IMAGENES, CLASES, functionclick, indentacion, separador);
        
     Pormenores de implantación:
		
	    - El conjunto de datos para el sistema ha de poseer un formato adecuado (ver <Anexo I>);
	    - Se utiliza un módulo javascript externo para definir algunos elementos intrínsecos
	    al funcionamiento del sistema (ver <Anexo II>).
		    
		    
>     <script src="ModConfArbVer.js"></script> <!-- Módulo de configuración -->
>     <script src="ModArbVer.js"></script>     <!-- Módulo de sistema       -->   
>
>	<script>
>	var datos_arb=new Array(
>	 "General                      |ZZZZZZ|1||http://www.google.com|"
>	,"Activo                       |IZZZZZ|2||http://www.google.com|"
>	,"Cartera                      |IKZZZZ|3||http://www.google.com|"
>        ................................
>	,"Cartera-Comercial            |IK1ZZZ|4||http://www.google.com|"
>	,"Cartera-Comercial-Descuento  |IK11ZZ|5||http://www.google.com|"
>     );
>	function inicio()
>	{
>		obj_arbol=new ObjArbol (datos_arb, IMAGENES, CLASES, functionclick, 15, “|”);
>	}
>	</script>
>	<body onload=”inicio();”>
>	<div id=”cctene”></div>
>	</body>
*/	

function ArbolVertical(v_nodos,imagenes,clases,functionclick,indentacion,separador)
{
	this.ie=navigator.appName=="Netscape"?false:true;
	this.BLOCK=this.ie?"block":"table";
	this.tipo_base="ArbolVertical";
	/*
		Property: contenedor
		
		Referencia al contenedor del sistema. 
	*/
	this.contenedor       =null;
	this.area_arbol       =null;
	this.nodo_favoritos   =null;
	this.cabecera	      =null;
	/*
		Property: i_mod_AA
		
		Referencia a la imagen de desplegar el arbol.
		
		Puede hacerse:
		
		foo.i_mod_AA.style.display="none";
	*/
	this.i_mod_AA	      =null;	
	/*
		Property: i_mod_CA
		
		Referencia a la imagen de plegar el arbol.
		
		Puede hacerse:
		
		foo.i_mod_CA.style.display="none";
	*/
	this.i_mod_CA	      =null;	
	/*
		Property: i_mod_BU
		
		Referencia a la imagen de buscar.
		
		Puede hacerse:
		
		foo.i_mod_BU.style.display="none";
	*/
	this.i_mod_BU	      =null;	
	this.imagenes	      =imagenes;
	this.clases	      =clases;
	this.ult_span	      =null;
	this.v_nodos	      =v_nodos;
	/*
		Property: functionclick
		
		Referencia a la función que se ejecuta al clicar en un nodo.
		
		Puede hacerse:
		
		foo.functionclick=function (){alert("Nueva función");};
	*/
	this.functionclick    =functionclick;
	this.indentacion      =(indentacion)?indentacion:5;
	this.separador	      =(separador)?separador:":";
	this.funcion_click    =null;
	this.suma_altos       =null;
	this.caja_busqueda    =null;
	this.pixel_dif=0;
	this.crea_Cabecera(); 
	this.crea_obj_Arbol(v_nodos); 
};

ArbolVertical.prototype.crea_Cabecera=function ()
{
	var td,tr,tabll,tbody,div,img,tdp,txt,bot;
	var pad_bus=5;
	this.contenedor=document.createElement("DIV");
	this.contenedor=document.body.appendChild(this.contenedor);
	//this.contenedor.style.border=this.pixel_dif+"px solid #000000";
	this.area_arbol=document.createElement("DIV");
	this.area_arbol=this.contenedor.appendChild(this.area_arbol);
	//this.area_arbol.style.border=this.pixel_dif+"px solid #00cc00";
	this.contenedor.oz=this;
	div=document.createElement("DIV");
	//div.style.border=this.pixel_dif+"px solid #ff0000";
	div.className=this.clases[6];
	tabll=document.createElement("TABLE");
	tabll.margin="auto";
	tbody=document.createElement("TBODY");
	tr=document.createElement("TR");
	tabll.border=0;
	tabll.cellPadding=0;
	tabll.cellSpacing=0;
	tabll.width="100%";
	tabll.height="100%";
	tr.oz=this;
	td=document.createElement("TD");
	td.oz=this;
	td.className=this.clases[7];
	td=tr.appendChild(td);
	img=new Image();
	img.src=this.imagenes[0].src;
	img.name=this.imagenes[0].name;
	img.alt=this.imagenes[0].alt;
	img.style.width=this.imagenes[0].width;
	img.style.height=this.imagenes[0].height;
	img.op ="CA";
	img.oz =this;
	img.onclick=this.Accion_administracion;
	img.style.cursor="pointer";
	img=td.appendChild(img);
	this.i_mod_CA=img;
	
	td=document.createElement("TD");
	td.oz=this;
	td.className=this.clases[8];
	td=tr.appendChild(td);
	img=new Image();
	img.src=this.imagenes[1].src;
	img.name=this.imagenes[1].name;
	img.alt=this.imagenes[1].alt;
	img.style.width=this.imagenes[1].width;
	img.style.height=this.imagenes[1].height;
	img.op ="AA";
	img.oz =this;
	img.onclick=this.Accion_administracion;	
	img.style.cursor="pointer";
	img=td.appendChild(img);
	this.i_mod_AA=img;
	
	td=document.createElement("TD");
	td.oz=this;
	td.style.paddingLeft=pad_bus;
	td.style.paddingRight=3;
	td=tr.appendChild(td);
	img=new Image();
	img.src=this.imagenes[3].src;
	img.name=this.imagenes[3].name;
	img.alt=this.imagenes[3].alt;   
	img.style.width=this.imagenes[3].width;
	img.style.height=this.imagenes[3].height;
	img.op ="BU";
	img.ox =null;
	img.oz =this;
	img.onclick=this.Accion_administracion;	
	img.style.cursor="pointer";
	img=td.appendChild(img);
	this.i_mod_BU=img;
	
	td=document.createElement("TD");
	td.style.visibility="visible";
	td.style.width=500;
	td=tr.appendChild(td);

	tr=tbody.appendChild(tr);
	tr=document.createElement("TR");

	spa=document.createElement("SPAN");	
	txt=document.createElement("INPUT");
	bot=document.createElement("INPUT");
	td=document.createElement("TD");
	td.oz=this;
	td.colSpan=4;
	spa.oz=this;
	spa.style.display="none";
	spa=td.appendChild(spa);
	td=tr.appendChild(td);
	img.ox=spa;
	
	bot.type="button";
	bot.className=this.clases[4];
	bot.value="Buscar";
	bot.tag_bus=this.area_arbol;
	bot.id="tag_bus";
	bot.onclick=this.Busqueda_Nodo;
	txt.type="text";
	txt.className=this.clases[5];
	txt.onkeypress=this.Press_Enter_Bus;
	

	txt=spa.appendChild(txt);
	this.caja_busqueda=txt;
	bot=spa.appendChild(bot);
	
	
	tr=tbody.appendChild(tr);
	tbody=tabll.appendChild(tbody);
	tabll=div.appendChild(tabll);	
	this.cabecera=this.area_arbol.parentNode.insertBefore(div,this.area_arbol);
	
	this.cabecera.style.display  =this.BLOCK;
	this.contenedor.style.display=this.BLOCK;
	
	
	this.area_arbol.className=this.clases[0];
	this.area_arbol.lgr_arbol=true;
	this.area_arbol.found_span=null;
	this.area_arbol.found_span_x=null;
	this.area_arbol.style.overflowY="auto";
	this.area_arbol.style.overflowX="auto";
	this.suma_altos=this.cabecera.offsetHeight+this.area_arbol.offsetHeight;
	this.cabecera.style.width=this.ie?this.area_arbol.offsetWidth:this.area_arbol.clientWidth;
};
/*
	Function: redimensionar
	
	Cambia el tamaño del contenedor del árbol.
	
	Parámetros:
	
	ancho  - Nuevo ancho para el área del árbol.
	alto   - Nuevo alto para el área del árbol.
	
	Uso:
	
	foo.redimensionar(ancho, alto);
*/
ArbolVertical.prototype.redimensionar=function (ancho,alto)
{
	this.area_arbol.style.height=alto;
	this.area_arbol.style.width=ancho;
	this.cabecera.style.height=3;
	this.cabecera.style.width=this.ie?this.area_arbol.offsetWidth:this.area_arbol.clientWidth;
	this.suma_altos=this.cabecera.offsetHeight+this.area_arbol.offsetHeight;
};

ArbolVertical.prototype.Press_Enter_Bus=function (ev)
{
	var elem=ev?ev.originalTarget:this;
	var event=ev?ev:window.event;
//	window.event.cancelBubble=true;	
	if(event.keyCode==13)
		elem.parentNode.oz.Busqueda_Nodo(elem.parentNode.childNodes[1]);
	else
		elem.parentNode.childNodes[1].tag_bus.ult_match=0;
};

ArbolVertical.prototype.crea_obj_Arbol=function (array_rec)
{
	var i;
	var reg;
	var reg_sig;
	var sw=true;
	var tabll,tbody,tbody_sup,tr,td,spa,img,aux;
	var spa_txt,img_a,img_r,input_txt;
	
	tabll=document.createElement("TABLE");
	tbody=document.createElement("TBODY");
	tbody=tabll.appendChild(tbody);
	tabll=this.area_arbol.appendChild(tabll);	
	tabll.border=0;
	tabll.cellPadding=0;
	tabll.cellSpacing=0;
	
	for (i=0;i<array_rec.length-1;i++)
	{
		sw=true;
		reg=array_rec[i].split(this.separador);                           
		reg_sig=array_rec[i+1].split(this.separador); 
		if(reg[1].indexOf("#-#")==-1)
		{
			tr=document.createElement("TR");
			td=document.createElement("TD");
			spa=document.createElement("SPAN");	
			
			img=new Image();	
			img.name=this.imagenes[2].name;
			img.src=this.imagenes[2].src;
			img.style.cursor="default";
			img.style.width=this.imagenes[2].width;
			img.style.height=this.imagenes[2].height;
			img.onclick=this.Mostrar_Hijos;
			
			
			td.despliegue  = "H";
			td.clave_nodo  = reg[1];   
			td.nombre_nodo = reg[0];      
			td.nivel_nodo  = parseInt(reg[2]); 
			td.indice_nodo = i; 
			if(reg[4])td.valor_auxiliar_4= reg[4];
			if(reg[5])td.valor_auxiliar_5= reg[5];
			td.oncontextmenu = function(){return false;};             
			td.style.paddingLeft=this.indentacion;
			td.style.whiteSpace="nowrap";
			td.oz	       = this;
			
			//spa.innerText   = this.quitEsp(reg[0]);  
			spa.innerHTML   = this.quitEsp(reg[0]);  
			spa.onclick     = this.Click_En_Span;
			spa.onmouseover = function(){this.style.textDecoration="underline";};    
			spa.onmouseout  = function(){this.style.textDecoration="none";};
			spa.title	= this.quitEsp(reg[0]);  
			spa.className	= this.clases[2];
			spa.clsVieja	= this.clases[2];
			                   	
			img=td.appendChild(img);
			spa=td.appendChild(spa);
			
			td=tr.appendChild(td);
			tr=tbody.appendChild(tr);	
			
			if(reg[2]<reg_sig[2])
			{
				td.despliegue="P";
				spa.className	= this.clases[1];
				spa.clsVieja	= this.clases[1];
				img.src=this.imagenes[0].src;
				img.name=this.imagenes[0].name;
				img.style.cursor="pointer";
				img.style.width=this.imagenes[0].width;
				img.style.height=this.imagenes[0].height;
				tabll=document.createElement("TABLE");
				tbody=document.createElement("TBODY");
				tbody=tabll.appendChild(tbody);		
				tabll.style.display="none";    
				tabll.border=0;
				tabll.cellPadding=0;
				tabll.cellSpacing=0;
				tabll=td.appendChild(tabll);
				if(i==0)this.nodo_favoritos=td;
			}
			else
			{
				if(reg[2]>reg_sig[2]  )
				{		
		//DIV	DIV DIVDIV
					aux=td;
					while(sw==true)
					{
						aux=aux.parentNode;
						if(aux.tagName=="DIV")
						{
							aux=aux.firstChild.firstChild.firstChild.firstChild;
							sw=false;	
						}
						if(aux.tagName=="TD" && aux.nivel_nodo <= reg_sig[2])
						{
								sw=false;						
						}
					}
					if(reg[3].indexOf("P")!=-1)			
					{
						td.despliegue="P";
						spa.className	= this.clases[1];
						spa.clsVieja	= this.clases[1];
						img.src=this.imagenes[0].src;
						img.name=this.imagenes[0].name;
						img.style.cursor="pointer";
						img.style.width=this.imagenes[0].width;
						img.style.height=this.imagenes[0].height;
						tabll=document.createElement("TABLE");
						tbody=document.createElement("TBODY");
						tbody=tabll.appendChild(tbody);		
						tabll.style.display="none";    
						tabll.border=0;
						tabll.cellPadding=0;
						tabll.cellSpacing=0;
						tabll=td.appendChild(tabll);
					}
					tabll=aux.parentNode.parentNode.parentNode;
					tbody=tabll.firstChild;
				}
				else
				{
		// ESTO ES LO NUEVOOOOOOOOOOOO::: CONDICIÓN (PENDIENTE DE REDUCCIÓN DE CÓDIGO)				
					if(reg[3].indexOf("P")!=-1)		
					{
						td.despliegue="P";
						spa.className	= this.clases[1];
						spa.clsVieja	= this.clases[1];
						img.src=this.imagenes[0].src;
						img.name=this.imagenes[0].name;
						img.style.cursor="pointer";
						img.style.width=this.imagenes[0].width;
						img.style.height=this.imagenes[0].height;
						tabll=document.createElement("TABLE");
						tbody=document.createElement("TBODY");
						tbody=tabll.appendChild(tbody);		
						tabll.style.display="none";    
						tabll.border=0;
						tabll.cellPadding=0;
						tabll.cellSpacing=0;
						tabll=td.appendChild(tabll);
						
						tabll=td.parentNode.parentNode.parentNode;
						tbody=tabll.firstChild;
					}
				}
			}
		}
				
	}
	if(array_rec.length > 0)	
	{
		reg=array_rec[array_rec.length-1].split(this.separador);                           
		
		tr=document.createElement("TR");
		td=document.createElement("TD");
		spa=document.createElement("SPAN");
		
		td.despliegue  = "H";
		td.clave_nodo  = reg[1];                 
		td.nombre_nodo = reg[0];      
		td.nivel_nodo  = parseInt(reg[2]); 
		td.indice_nodo = i; 
		if(reg[4])td.valor_auxiliar_4= reg[4];
		if(reg[5])td.valor_auxiliar_5= reg[5];
		td.oncontextmenu = function(){return false;};             
		td.style.paddingLeft=this.indentacion;
		td.style.whiteSpace="nowrap";
		td.oz	       = this;
		
		img=new Image();	
		img.name=this.imagenes[2].name;
		img.src=this.imagenes[2].src;
		img.style.cursor="default";
		img.style.width=this.imagenes[2].width;
		img.style.height=this.imagenes[2].height;
		img.onclick=this.Mostrar_Hijos;
		
		spa.onclick     = this.Click_En_Span;
		spa.onmouseover = function(){this.style.textDecoration="underline";};    
		spa.onmouseout  = function(){this.style.textDecoration="none";};
		spa.className	= this.clases[2];
		spa.clsVieja	= this.clases[2];
		//spa.innerText   = reg[0]; 
		spa.innerHTML = reg[0];    
		spa.title	= this.quitEsp(reg[0]);   
		
		img=td.appendChild(img);
		spa=td.appendChild(spa);
		
		td=tr.appendChild(td);
		tr=tbody.appendChild(tr);
// CONDICION PARA CREAR CARPETA VACÍA AL FINAL DEL ARBOL (CASO DE SER NECESARIO)
		if(reg[3].indexOf("P")!=-1)			
		{
			td.despliegue="P";
			spa.className	= this.clases[1];
			spa.clsVieja	= this.clases[1];
			img.src=this.imagenes[0].src;
			img.name=this.imagenes[0].name;
			img.style.cursor="pointer";
			img.style.width=this.imagenes[0].width;
			img.style.height=this.imagenes[0].height;
			tabll=document.createElement("TABLE");
			tbody=document.createElement("TBODY");
			tbody=tabll.appendChild(tbody);		
			tabll.style.display="none";    
			tabll.border=0;
			tabll.cellPadding=0;
			tabll.cellSpacing=0;
			tabll=td.appendChild(tabll);
		}				
	}       	
	//this.area_arbol.firstChild.firstChild.firstChild.firstChild.childNodes[2].firstChild.firstChild.removeNode(true);
};

ArbolVertical.prototype.Mostrar_Hijos=function (elem)
{
	var visi;
	try{
		if(elem.originalTarget.toString()=="undefined");
		elem=elem.originalTarget;
		if(elem.parentNode.despliegue=="H")
			return;
		visi=(elem.parentNode.childNodes[2].style.display==elem.parentNode.oz.BLOCK) ? "none" : elem.parentNode.oz.BLOCK;	
	}
	catch(o){
		if(!elem)
		{
			elem=this;
			if(elem.parentNode.despliegue=="H")
				return;
			visi=(elem.parentNode.childNodes[2].style.display==elem.parentNode.oz.BLOCK) ? "none" : elem.parentNode.oz.BLOCK;
		}
		else
		{
			if(elem.tagName=="SPAN")
			{
				elem=elem.parentNode.firstChild;
				visi=(elem.parentNode.childNodes[2].style.display==elem.parentNode.oz.BLOCK) ? "none" : elem.parentNode.oz.BLOCK;
			}
			else
			{
				visi=elem.parentNode.oz.BLOCK;
			}
		}	
	};
	
	if(elem.parentNode.oz.ult_span!=null)
	{
		if(elem.parentNode.oz.ult_span.parentNode.despliegue=="H")
			elem.parentNode.oz.ult_span.className=elem.parentNode.oz.clases[2];
		else				
			elem.parentNode.oz.ult_span.className=elem.parentNode.oz.clases[1];
	}
	elem.parentNode.oz.ult_span=elem.parentNode.childNodes[1];
	if(elem.parentNode.despliegue=="H")
	{
		elem.parentNode.childNodes[1].className=elem.parentNode.oz.clases[2];
		return;
	}
	elem.parentNode.childNodes[1].className=elem.parentNode.oz.clases[1];
	elem.parentNode.childNodes[2].style.display=visi;
	elem.src=(elem.parentNode.childNodes[2].style.display==elem.parentNode.oz.BLOCK) ? elem.parentNode.oz.imagenes[1].src : elem.parentNode.oz.imagenes[0].src ;
	if(elem.parentNode.oz.caja_busqueda.parentNode.style.display==elem.parentNode.oz.BLOCK)
		elem.parentNode.oz.caja_busqueda.focus();
};


ArbolVertical.prototype.Mostrar_Todos_Hijos=function (elem,visi)
{
	var i;
	for(i=0;i<elem.oz.area_arbol.getElementsByTagName("TD").length;i++)
	{
		if(elem.oz.area_arbol.getElementsByTagName("TD")[i].childNodes[2])
		{
			elem.oz.area_arbol.getElementsByTagName("TD")[i].childNodes[2].style.display=visi;
			elem.oz.area_arbol.getElementsByTagName("TD")[i].firstChild.src=(visi==elem.oz.BLOCK) ? elem.oz.imagenes[1].src : elem.oz.imagenes[0].src;
		}
	}
};

ArbolVertical.prototype.Visualizar_Scroll_V=function ()
{
	if(this.area_arbol.scrollHeight > document.body.clientHeight-35)
		return "scroll";
	else
		return "visible";
};

ArbolVertical.prototype.Click_En_Span=function ()
{
	if(document.getElementById("tag_bus").tag_bus.found_span)
	{
		document.getElementById("tag_bus").tag_bus.found_span.className=document.getElementById("tag_bus").tag_bus.found_span.clsVieja;
		document.getElementById("tag_bus").tag_bus.ult_match=0;
		document.getElementById("tag_bus").tag_bus.found_span=null;
		document.getElementById("tag_bus").tag_bus.found_span_x=null;
	}
	this.className=this.parentNode.oz.clases[3];
	if(this.parentNode.oz.ult_span)
		this.parentNode.oz.ult_span.className=this.parentNode.oz.ult_span.clsVieja;
	this.parentNode.oz.ult_span=this;
	this.parentNode.oz.functionclick(this);
};

ArbolVertical.prototype.Accion_administracion=function ()
{
	switch (this.op)
	{
		case "AA":
			this.oz.Mostrar_Todos_Hijos(this,this.oz.BLOCK);
			break;	
		case "CA":
			this.oz.Mostrar_Todos_Hijos(this,"none");
			break;	
		case "BU":
			this.ox.style.display=(this.ox.style.display==this.oz.BLOCK)?"none":this.oz.BLOCK;
			this.src=(this.ox.style.display==this.oz.BLOCK) ? this.oz.imagenes[4].src:this.oz.imagenes[3].src;
			this.oz.area_arbol.style.height = this.oz.suma_altos - this.oz.cabecera.offsetHeight;
			break;				
	}
	if(this.oz.caja_busqueda.parentNode.style.display==this.oz.BLOCK)
		this.oz.caja_busqueda.focus();
};
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
ArbolVertical.prototype.Busqueda_Nodo=function (elem)
{
	var elem=elem?elem:this;		
	if(elem.originalTarget)elem=elem.originalTarget;
	elem.tag_bus=elem.parentNode.oz.area_arbol;
	var texto=(!elem.tag_bus.found_span)?"No se encontraron coincidencias":"No se encontraron más coincidencias";
	var k=(!elem.tag_bus.found_span)?0:1;
	var i,j,aux;

	var tope=(elem.tag_bus.found_span)?elem.tag_bus.ult_match:0;
	if(elem.tag_bus.found_span_x)
	{
		elem.tag_bus.found_span_x.className=elem.tag_bus.found_span_x.clsVieja;	
		elem.tag_bus.found_span_x=null;
	}
	if(elem.tag_bus.found_span)
		elem.tag_bus.found_span.className=elem.tag_bus.found_span.clsVieja;
	if(elem.parentNode.firstChild.value.replace(/\s/g,"").length==0)
		return;		
	for(i=(tope+k);i<elem.tag_bus.getElementsByTagName("SPAN").length;i++)
	{
		if(elem.tag_bus.getElementsByTagName("SPAN")[i].innerHTML.toUpperCase().indexOf(elem.parentNode.firstChild.value.toUpperCase())!=(-1))	
		{
			elem.tag_bus.ult_match=i;
			elem.tag_bus.found_span=elem.tag_bus.getElementsByTagName("SPAN")[i];
			elem.tag_bus.found_span_x=elem.tag_bus.getElementsByTagName("SPAN")[i];
			elem.tag_bus.getElementsByTagName("SPAN")[i].className=elem.tag_bus.getElementsByTagName("SPAN")[i].parentNode.oz.clases[3];
			aux=elem.tag_bus.getElementsByTagName("SPAN")[i].parentNode.parentNode;
			while(!aux.lgr_arbol)
			{
				aux=aux.parentNode;
				if(aux.tagName=="TD")
					aux.oz.Mostrar_Hijos(aux.firstChild);
			}
			elem.tag_bus.getElementsByTagName("SPAN")[i].parentNode.focus();
			break;
		}
	}
	if(i==elem.tag_bus.getElementsByTagName("SPAN").length)
	{
		alert(texto);	
		elem.tag_bus.ult_match=0;
		elem.tag_bus.found_span=null;
	}
	elem.parentNode.oz.caja_busqueda.focus();
};
/*
	Function: getContainer
	
	Devuelve una referencia al contenedor del sistema.
	
	Uso:
	
	var container=foo.getContainer();
	container.style.width=30;
*/
ArbolVertical.prototype.getContainer=function ()
{
	return this.contenedor;	
};
/*
	Function: getNodes
	
	Devuelve una array de objetos de tipo TD que serán todos los nodos del árbol.
	
	Uso:
	
	var nodos=foo.getNodes();
	
	Observaciones:
	
	Cada elemento del array nodos cuenta con una serie de propiedades tomadas de cada registro 
	de los datos para el sistema (ver <Anexo I>):

		nodos[i].nombre_nodo: - Texto que aparece para cada nodo.
		nodos[i].clave_nodo:  - Identificador del nodo en la BD.
		nodos[i].nivel_nodo:  - Nivel o piso en el que se encuentra el nodo.
		nodos[i].despliegue:  - Toma uno de los dos siguientes valores:
		*Valor “H”* -> significa que es un nodo básico que no tiene dependientes. ||
		*Valor “P”* -> significa que este nodo puede poseer o no nodos dependientes. En cualquier caso se mostrará en el árbol como un elemento de agrupamiento.
		nodos[i].indice_nodo:       - ordinal del nodo dentro del árbol. 
		nodos[i]. valor_auxiliar_4: - Corresponde al trozo cuatro (ver <Anexo I>) de cada registro. Puede ubicarse aquí, por ejemplo, una url a la que navegar al hacer clic en el nodo. Es un valor opcional que no interviene en la creación del árbol.
		nodos[i]. valor_auxiliar_5: - Corresponde al trozo cinco (ver <Anexo I>) de cada registro. Se puede almacenar otra información útil para el programador. Es otro valor opcional que no interviene en la creación del árbol.

*/
ArbolVertical.prototype.getNodes=function ()
{
	return this.contenedor.getElementsByTagName("TD");	
};
/*
	Function: appendSystem
	
	Coloca el sistema en el objeto enviado como target.
	
	Parámetros:
	
	target - Es el objeto en el que se agregará el sistema.
	
	Uso:
	
	foo.appendSystem(document.body);
*/
ArbolVertical.prototype.appendSystem=function (target)
{
	target.appendChild(this.contenedor);	
};
ArbolVertical.prototype.quitEsp=function (cad)
  {
    var sw=0;
    var t=cad.length;
    t--;
    while(sw==0 && t>=0)
    {
      if(cad.charAt(t)!=" ")
        sw=1;
      t--;
    }
    t+=2;
    cad=cad.substring(0,t);
    sw=0;
    t=0;
    while(sw==0 && t<=cad.length)
    {
      if(cad.charAt(t)!=" ")
        sw=1;
      t++;
    }
    t--;
    cad=cad.substring(t,cad.length);
    return cad;
  }

/*
	Section: Anexo I
	
	Datos Para El Sistema:
		
	Formato del array de entrada con los datos del sistema.
	
>	var lsx_vector=new Array(
>	 "General                      |ZZZZZZ|1||http://www.google.com|"
>	,"Activo                       |IZZZZZ|2||http://www.google.com|"
>	,"Cartera                      |IKZZZZ|3||http://www.google.com|"
>	,"Cartera-Comercial            |IK1ZZZ|4||http://www.google.com|"
>	,"Cartera-Comercial-Descuento  |IK11ZZ|5||http://www.google.com|"
>	,"Cartera-Comercial-Anticipos  |IK12ZZ|5||http://www.google.com|"
>	,"Cartera-Financiera           |IK2ZZZ|4||http://www.google.com|"
>	,"Cartera-Financiera-Anticipo  |IK22ZZ|5||http://www.google.com|"
>	,"Cartera-Financiera-Descuento |IK21ZZ|5||http://www.google.com|"
>	,"Préstamos                    |IPZZZZ|3||http://www.google.com|"
>	,"Préstamos-Hipotecarios       |IP1ZZZ|4||http://www.google.com|"
>	,"Préstamos-Hipot-Promotor     |IP11ZZ|5||http://www.google.com|"
>	,"Préstamos-Hipot-Subrogados   |IP12ZZ|5||http://www.google.com|"
>	,"Préstamos-Hipot-Otros        |IP1OZZ|5||http://www.google.com|"
>	,"Préstamos-Personales         |IP2ZZZ|4||http://www.google.com|"
>	,"Préstamos-Pers-Consumo       |IP21ZZ|5||http://www.google.com|"
>	,"Préstamos-Pers-Mapa          |IP22ZZ|5||http://www.google.com|"
>	,"Préstamos-Pers-Otros         |IP2OZZ|5||http://www.google.com|"
>	);

Obsérvese uno de estos registros con detenimiento.

>   "General                      |ZZZZZZ|1||http://www.google.com|"

Cada registro consta de trozos separados por el separador definido en la inicialización del objeto. 
Cada trozo se ubicará en una propiedad de los anteriormente mencionados nodos. 

 - Trozo 0 -> Contiene el texto del nodo a mostrar. Se ubica en la propiedad nodo.nombre_nodo.
 - Trozo 1 -> Contiene la clave en la base de datos del elemento o bien otro dato de interés 
      para el programador. Se ubica en la propiedad nodo.clave_nodo.
 - Trozo 2 -> Nivel en el que se posicionará cada nodo. IMPORTANTE: Si los valores correlativos de este apartado 
      no son correctos es muy posible que el árbol no pueda montarse y por tanto de error. No podrá existir un elemento 
      por ejemplo de nivel tres seguido de uno de nivel cinco. Para este caso el nivel del elemento siguiente, 
      o es igual, o es menor (puede ser uno o dos), o es cuatro.
 - Trozo 3 -> Indica si el nodo tiene o puede tener dependientes, o se trata de un elemento básico.  
		Si este valor viene vacío, se asignará de forma automática en función de si el nodo tiene dependientes o no. 
		*CUIDADO:* en este caso los nodos que debieran comportarse como padre aunque no tengan dependientes se 
		mostrarán como elementos de nivel básico. Posibles valores: "P" || "H"
 - Trozo 4 -> En este caso almacena una url de destino pero puede almacenar cualquier valor que el programador considere necesario para el funcionamiento de su aplicación.
 - Trozo 5 -> En este caso viene vacío pero puede almacenar cualquier valor que el programador considere necesario para el funcionamiento de su aplicación.

IMPORTANTE: 

Si en uno de los trozos aparece como carácter el que se definió en su momento como separador, se generará 
un error en el montaje, puesto que el módulo utiliza dicho separador para su gestión interna. 

	
*/
	
/*
	Title: Anexo II
		
	Ejemplo de módulo de configuración:
	
	Elementos a definir obligatoriamente para el funcionamiento del árbol.
	
>    //----------------------------------------------------------------------------------------------
>    //  Modulo de configuracion para los parametros que recibirá el constructor del 
>    //				objeto ArbolVertical.
>    //----------------------------------------------------------------------------------------------
>    //----------------------------------------------------------------------------------------------
>    // IMAGENES QUE SE IMPLEMENTARÁN EN LOS DISTINTOS MÓDULOS EN FUNCION DE LAS CIRCUNSTANCIAS	
>    //	IMPORTANTE: Se solicitarán en el constructor por el índice. Es por esto que el orden 	
>    //		de las mismas ha de ser riguroso.						
>    //	IPORTANTE: Por razones que desconozco es necesario para algunos navegadores especificar 
>    //		el tamaño de las imagenes de forma esplícita tras la descarga. Si no se reliza 	
>    //		dicha operacion el tamaño de las mismas resulta aleatorio en el resultado. 	
>    //----------------------------------------------------------------------------------------------
>    var IMAGENESAV=new Array();
>    IMAGENESAV[0 ]=new Image();
>    IMAGENESAV[1 ]=new Image();
>    IMAGENESAV[2 ]=new Image();
>    IMAGENESAV[3 ]=new Image();
>    IMAGENESAV[4 ]=new Image();
>    
>    IMAGENESAV[0 ].src="../g/scxg170.gif";		//Carpetas 
>    IMAGENESAV[1 ].src="../g/scxg170u.gif";		//Carpetas Abierta
>    IMAGENESAV[2 ].src="../g/cofg051.gif";		//Archivo		
>    IMAGENESAV[3 ].src="../g/scxg900.gif";		//Mostrar Busqueda (standby)
>    IMAGENESAV[4 ].src="../g/scxg900u.gif";		//Mostrar Busqueda (activado)
>    
>    IMAGENESAV[0 ].alt="Plegar todo el árbol";		
>    IMAGENESAV[1 ].alt="Desplegar todo el árbol";		
>    IMAGENESAV[2 ].alt="Otras Opciones";
>    IMAGENESAV[3 ].alt="Buscar";
>    IMAGENESAV[4 ].alt="Buscar";
>    
>    //----------------------------------------------------------------------------------------------
>    // CLASESAV CSS PARA ALGUNOS COMPONENTES QUE SE CREARÁN CON CIERTOS MÓDULOS			
>    //	IMPORTANTE: Se solicitarán en el constructor por el índice. Es por esto que el orden 	
>    //		de las mismas ha de ser riguroso.						
>    //----------------------------------------------------------------------------------------------
>    var CLASESAV=new Array();
>    CLASESAV[0]="prop_conte_arbol";     //  0 - Propiedades Generales del Contenedor del Arbol
>    CLASESAV[1]="menu";                 //  1 - Para spanes de Carpeta
>    CLASESAV[2]="menu_arch";		     //  3 - Para spanes de Informe
>    CLASESAV[3]="menu_find";		     //  5 - Para span encontrado por búsqueda
>    CLASESAV[4]="botonEjecutar";	     //  7 - Para Botones
>    CLASESAV[5]="gestionCampos";	     //  8 - Para Cajas de Texto
>    CLASESAV[6]="prop_conte_cabe";	     // 10 - Propiedades Generales de la cabecera del Arbol
>    CLASESAV[7]="ab_ce_ar";		     // 11 - Cabecera: Celda de cerrar arbol
>    CLASESAV[8]="ab_ce_ar_dcha";	     // 12 - Cabecera: Celda de abrir arbol
*/
