
function listboxArbol(name){this.name=name;this.etiqueta=null;this.value=null;this.texto=""
this.xmlObj=null;this.objhtml=null;this.ample=130;this.onChange=function(){return;}
this.onOpen=function(){return;}
this.acabaDeClickar=false;this.click=lba_click;this.nomNodo="";this.nomAtNivel="";this.nomAtNom="";this.nomAtCod="";this.setValue=lba_setValue;this.urlimgselector="/images/icono_desplegable_selector.gif";this.urlimgmas="/images/icono_desplegable_mas.gif";this.urlimgmenos="/images/icono_desplegable_menos.gif";this.imgmas=new Image();this.imgmenos=new Image();this.imgmas.src=this.urlimgmas;this.imgmenos.src=this.urlimgmenos;this.divDesplegable=null;this.mostrarAmagarArbre=function(){this.divDesplegable.style.display=(this.divDesplegable.style.display=="")?"none":"";if(this.divDesplegable.style.display=="")eval(this.name+".onOpen()");}
this.close=function(){this.divDesplegable.style.display='none';}
this.crearElements=function(){var subtaula=document.createElement('TABLE');subtaula.cellSpacing='0';subtaula.cellPadding='0';subtaula.setAttribute('width',this.ample);subtaula.setAttribute('border','0');subtaula.style.cursor='hand';var subcos=document.createElement("TBODY");var fila=document.createElement('TR');fila.setAttribute('height','11px');var cella=document.createElement('TD');cella.style.fontFamily='Verdana, Arial, Helvetica, sans-serif';cella.style.fontSize='9px';cella.style.color='#000000';cella.setAttribute('width',this.ample-10);cella.onclick=new Function(this.name+".mostrarAmagarArbre()");cella.arbre=this;this.etiqueta=cella;cella.innerHTML=this.texto;fila.appendChild(cella);cella=document.createElement('TD');cella.vAlign="bottom";cella.innerHTML="<img src='"+this.urlimgselector+"' border=0 />";cella.onclick=new Function(this.name+".mostrarAmagarArbre()");cella.arbre=this;fila.appendChild(cella);subcos.appendChild(fila);subtaula.appendChild(subcos);var subtaula2=document.createElement('TABLE');subtaula2.cellSpacing='0';subtaula2.cellPadding='0';subtaula2.setAttribute('border','0');var subcos=document.createElement("TBODY");var fila=document.createElement('TR');var cella=document.createElement('TD');cella.style.borderLeft='2px solid #000000';cella.style.borderTop='2px solid #000000';cella.style.borderRight='1px solid #cecece';cella.style.borderBottom='1px solid #cecece';cella.style.backgroundColor='#ffffff';cella.style.paddingLeft=5;cella.appendChild(subtaula);fila.appendChild(cella);subcos.appendChild(fila);subtaula2.appendChild(subcos);var taula=document.createElement('TABLE');taula.cellSpacing='0';taula.cellPadding='0';taula.setAttribute('border','0');var cos=document.createElement("TBODY");var fila=document.createElement('TR');var cella=document.createElement('TD');cella.style.fontFamily='Verdana, Arial, Helvetica, sans-serif';cella.style.fontSize='9px';cella.style.color='#000000';cella.appendChild(subtaula2);fila.appendChild(cella);cos.appendChild(fila);var fila=document.createElement('TR');fila.setAttribute('height','1px');var cella=document.createElement('TD');fila.appendChild(cella);cos.appendChild(fila);var fila=document.createElement('TR');var cella=document.createElement('TD');this.divDesplegable=document.createElement('DIV');this.divDesplegable.style.position='absolute';this.divDesplegable.style.display='none';this.divDesplegable.style.zIndex='1000';this.divDesplegable.innerHTML="<iframe frameborder=0 width="+(this.ample+24)+" height=186 id=ifDesp"+this.name+"></iframe>";cella.appendChild(this.divDesplegable);var iframe=this.divDesplegable.getElementsByTagName('IFRAME').item(0);this.divDesplegable.appendChild(iframe);fila.appendChild(cella);cos.appendChild(fila);taula.appendChild(cos);this.objhtml.innerHTML="";this.objhtml.appendChild(taula);var iframedoc=null;if(iframe.contentDocument){iframedoc=iframe.contentDocument;}else if(iframe.contentWindow){iframedoc=iframe.contentWindow.document;}else if(iframe.document){iframedoc=iframe.document;}
iframedoc.open();var html='<html><head><title>bbb</title>';html+="</head><body style='padding:0 0 0 0; margin:0 0 0 0; border:1px solid #000000; background-color: #ffffff;'><div id=midiv"+this.name+"></div></body></html>";iframedoc.write(html);iframedoc.close();eval(this.name+".crearElementsArbre(iframedoc,iframedoc.getElementById('midiv"+this.name+"'));");}
this.crearElementsArbre=function(doc,on){var nodes=this.xmlObj.getElementsByTagName(this.nomNodo)
var index=0;for(var i=0;i<nodes.length;i++)
{index++;var node=nodes(i);var midiv=doc.createElement("DIV");midiv.esDivArbre=true;midiv.valor=node.getAttribute(this.nomAtCod);if(node.nextSibling!=null)
{midiv.innerHTML="<img src='"+this.urlimgmas+"' ID='IMG_"+node.getAttribute(this.nomAtCod)+"' />"+node.getAttribute(this.nomAtNom);midiv.onmouseup=new Function(this.name+".openclose('"+node.getAttribute(this.nomAtCod)+"')");}
else
midiv.innerHTML=node.getAttribute(this.nomAtNom);midiv.style.fontFamily='Verdana, Arial, Helvetica, sans-serif';midiv.style.fontSize='9px';midiv.style.cursor='hand';midiv.style.color='#000000';midiv.style.backgroundColor=((index%2==0))?'#efefef':'#ffffff';if(node.nextSibling!=null)
if(node.getAttribute(this.nomAtNivel)<node.nextSibling.getAttribute(this.nomAtNivel))
{midiv.divfills=doc.createElement("DIVfills"+node.getAttribute(this.nomAtCod));midiv.divfills.style.display="none";var sortir=false
var index2=index+1;for(var j=i+1;j<nodes.length&&!sortir;j++)
{index2+=1;i+=1;var nodef=nodes(i);var midiv2=doc.createElement("DIV");midiv2.esDivArbre=true;midiv2.valor=nodef.getAttribute(this.nomAtCod);midiv2.texto=nodef.getAttribute(this.nomAtNom);midiv2.innerHTML=nodef.getAttribute(this.nomAtNom);midiv2.style.fontFamily='Verdana, Arial, Helvetica, sans-serif';midiv2.style.fontSize='9px';midiv2.style.cursor='hand';midiv2.style.color='#000000';midiv2.onmouseup=new Function(this.name+".click('"+nodef.getAttribute(this.nomAtCod)+"','"+nodef.getAttribute(this.nomAtNom).replace("'","\'")+"')");;midiv2.style.paddingLeft=30;midiv2.arbre=this;midiv.divfills.appendChild(midiv2);midiv2.style.backgroundColor=((index2%2==0))?'#ffffff':'#efefef';if(nodef.nextSibling!=null)
if(nodef.getAttribute(this.nomAtNivel)>nodef.nextSibling.getAttribute(this.nomAtNivel))
sortir=true;}
midiv.appendChild(midiv.divfills);}
on.appendChild(midiv);}}
this.load=lba_load;this.loadXML=lba_loadXML;this.loaded=lba_loaded;this.openclose=lba_openclose;}
function lba_load(url)
{this.xmlObj=new ActiveXObject("Microsoft.XMLDOM");this.xmlObj.async=true;this.xmlObj.onreadystatechange=new Function(this.name+".loaded()");this.xmlObj.load(url);}
function lba_loadXML(strXML)
{this.xmlObj=new ActiveXObject("Microsoft.XMLDOM");this.xmlObj.loadXML(strXML);eval(this.name+".crearElements();");}
function lba_loaded()
{var xmlOb=eval(this.name+".xmlObj;");if(this.xmlObj.readyState!=4||this.xmlObj.xml=="")return;eval(this.name+".crearElements();");eval(this.name+".setValue('"+this.value+"');");}
function lba_openclose(cod)
{if(!this.acabaDeClickar)
{ifObj=eval("ifDesp"+this.name)
var img=ifObj.document.images["IMG_"+cod]
img.src=(img.src.indexOf(this.urlimgmas)>0)?this.urlimgmenos:this.urlimgmas
var divF=ifObj.document.getElementsByTagName("DIVfills"+cod).item(0)
divF.style.display=(divF.style.display=="none")?"":"none"}
this.acabaDeClickar=false;}
function lba_click(cod,nom)
{this.acabaDeClickar=true;this.etiqueta.innerHTML=nom;this.value=cod;eval(this.name+".mostrarAmagarArbre()")
eval(this.name+".onChange()")}
function lba_setValue(cod)
{this.value=cod
if(this.value!=null&&this.xmlObj.xml!="")
{var nod=this.xmlObj.getElementsByTagName(this.nomNodo+"[@"+this.nomAtCod+"='"+cod+"']")(0)
if(nod!=null)
{this.etiqueta.innerHTML=nod.getAttribute(this.nomAtNom);}}}