function filearma(me)
{	document.getElementById('xchan').value = me;
	$("#chivos").animate({ opacity: "hide" }, "fast");
	yaxpa('bibliojax.php?filearma&rama='+me+'&','intercambiador2',200);
}

function listarma()
{	vec = document.getElementById('intercambiador2').innerHTML.split(':::');
	peine = vec[0].split('-_-');
	cerda = new Array(); laforma=''; tira='';
	for(k=0; k<peine.length; k++)
	{	una=peine[k].split('.-.');
		cerda[k] = '<a href="javascript:filearma(\''+una[1]+'\')" class="visi'+una[2]+'">'+una[0]+'</a>'; 
		if(k==peine.length-1) 
		{ laforma=una[1]; 
		  tira='<h1>'+una[0];
		  if(document.getElementById('ademe').value=='1') { tira+='<img src="imgs/upload.png" alt="" title="Subir Archivos a esta categoría" align="top" id="subirfiles">'; }
		  tira+='</h1><div id="panel">'+armaformaup(laforma)+'</div>'; 
		}
	}
	tira+=armalista(vec[1],'0');
	document.getElementById('chivos').innerHTML = '<div id="peine">'+cerda.join(' &raquo; ')+'</div>'+tira+'<div id="detallearchivo"></div>';
	$("#subirfiles").click(function(){
		// $("#detallearchivo").hide();
		$("#panel").slideToggle("slow");		//$(this).toggleClass("active"); 
		document.getElementById('elfram').src='biblioup.php?idtree='+laforma;
		return false;
	});
	if(document.getElementById("listarchivos") && document.getElementById("listarchivos").rows[0].cells.length==8)
	{	$("#listarchivos").tablesorter({ headers: { /*0:{sorter:false}, */ 3:{sorter:false}, 7:{sorter:false}},  widgets: ['zebra']  });
	}
	else if(document.getElementById("listarchivos") && document.getElementById("listarchivos").rows[0].cells.length==4)
	{	$("#listarchivos").tablesorter({ headers: { /*0:{sorter:false}, */ 3:{sorter:false}},  widgets: ['zebra']  });
	}
	 $("#detallearchivo").hide();
	 $("#chivos").animate({ opacity: "show" }, "fast");
}

function armaformaup(me)
{	mafor='<iframe frameborder="0" hspace="0" vspace="0" width="315" height="383" id="elfram" name="elfram" src="biblioup.php?idtree='+me+'"></iframe>';
	return mafor;
}

function armalista(conesto, para)
{	tira0='<div id="listaarchivos">';
	if(conesto=='')
	{	if(para=='' || para=='0') 			{ tira0+=' Esta categoría no tiene archivos'; 		}
		else if(para =='1' || para=='2')	{ tira0+=' <i>No se encontraron resultados</i> '; 	}
	}
	else
	{	archi = conesto.split('-_-'); teo=0;
		tira2=''; colus=0;
		for(k=0; k<archi.length; k++)	//$vec[] = $row_tal['id_archivo'].'.-.'.$row_tal['titulo_original'].'.-.'.$row_tal['archivo'].'.-.'.$row_tal['fechapub'].'.-.'.$furu.'.-.'.$visi.'.-.'.$vefi;
		{	elem=archi[k].split('.-.');	if(colus==0) { colus=elem.length; }
			if(elem.length==4 || elem.length==7);
			{	furu=getforo(elem[4]);teo++;	
				cola='<td>'+furu+'</td><td>'+elem[5]+'</td><td>'+elem[6]+'</td>'; cola = cola.replace(/1/g,'<img src="imgs/chulito.gif">');
				laext=getex(elem[2]);
				tira2 += '<tr valign="top" align="center"><td><div class="ext_'+laext+'"></div></td><td align="left">'
						+'<a href="javascript:armadet(\''+elem[0]+'\', \''+para+'\')" title="Detalles de archivo">'+elem[1]+'</a></td>'
						+'<td>'+elem[3]+'</td>'
						+'<td><a href="docs/'+elem[2]+'" title="Descargar Archivo"><img src="imgs/download.png"  border="0"></a></td>';
				if(elem.length==7)
				{	tira2+=cola +'<td><img src="imgs/bullet_delete.png" title="Borrar Archivo" onclick="borrafile(\''+elem[0]+'\',\''+elem[2]+'\')"></td>'; }
				tira2+='</tr>';
			}
		}
		tira1 = '<table id="listarchivos" style="margin-top:5px" class="tablesorter"><thead><tr><th>Tipo&nbsp;</th><th>Titulo</th><th>Fecha</th><th>&nbsp;</th>';
		if(colus==7)
		{	tira1+='<th>Foro&nbsp;</th><th>Visible</th><th>Nuevo</th><th>&nbsp;</th>';
		}
		tira1+='</tr></thead><tbody>'+tira2+'</tbody></table>';
		if(para=='' || para=='0')
		{	tira0+='<img src="imgs/arrow_refresh.png" title="Refresar listado" align="top" onclick="filearma('+laforma+')"><b class="deesta"> Archivos de esta categoría</b><br>Se encontraron '+ teo +' documentos.<br>'+tira1;	}
		else if(para=='1' || para=='2')
		{	tira0+=' Se encontraron '+ teo +' documentos.<br>'+tira1;	}
	}
	tira0+='</div>';
	return tira0;
}
function borrafile(me,fi)
{	//$("#chivos").animate({ opacity: "hide" }, "fast");
	if(confirm('¿EStá seguro que desea borrar este documento?')) { yaxpa('bibliojax.php?fileborra&docu='+me+'&arch='+fi,'intercambiador3',400); }
}

function getex(me)
{	laex='';
	if(typeof me != 'undefined' && me!='')	{	laex=me.lastIndexOf('.'); laex=me.substring(laex+1, me.length);	}
	return laex;
}
function getforo(me)
{	stdo='';
	if(me=='' || me=='0') { stdo='No visible'; } else if(me=='1') { stdo='Disponible'; }	else if(me=='2') { stdo='Cerrado'; }
	return stdo;
}

function armadet(me, par)
{	document.getElementById('viendo').value=me;	document.getElementById('desdepara').value=par;
	if(document.getElementById('detallearchivo').style.display!='none')
	{	$("#detallearchivo").animate({ opacity: "hide" }, "fast");	}
	if(document.getElementById('listaarchivos').style.display!='none')
	{	$("#listaarchivos").animate({ opacity: "hide" }, "fast");	}
	yaxpa('bibliojax.php?ida='+me+'&oper=d','intercambiador',300);
}


function detaarma()
{	if(document.getElementById('desdepara').value=='0')
	{	tira='<a href="javascript:filearma('+document.getElementById('xchan').value+')">Regresar</a><br><br>';
	}
	else if(document.getElementById('desdepara').value=='1')
	{	tira='<a href="javascript:valibus1_1()">Regresar</a><br><br>';
	}
	else if(document.getElementById('desdepara').value=='2')
	{	tira='<a href="javascript:valibus2_1()">Regresar</a><br><br>';
	}
	minda = document.getElementById('lgd').value;
	//0-id_archivo	1-titulo_original		2-titulo_sp		3-archivo		4-fechapub		5-autor		6-sugeridor		7-ubi_fisica	
	//8-abstract	9-palabrasclaves		10-foro			11-visible		12-versionfinal				13-nuevo		14-tamaño		15-categosrias
	//16- califica  17-votos
	if(document.getElementById('intercambiador').innerHTML!='' && document.getElementById('intercambiador').innerHTML.length>4)
	{	elem = document.getElementById('intercambiador').innerHTML.split('.-.');
		if(elem.length>0)
		{	titucla=''; titusino=''; tituta='';
			if(minda=='1') { titucla=' title="Click para editar" class="editafile"' ; titusino=' title="Click para editar" class="editafile_sino" '; tituta=' title="Click para editar" class="editafile_ta" '; }
			tira+='<dl><dt style="margin-top:2px">Documento:</dt><dd><b><span '+titucla+' id="'+elem[0]+'-'+'titulo_original">'+elem[1]+'</span></b>';
			if(elem[3]!='') 
			{	tira+='<div style="margin:5px 3px 3px 0"><a href="docs/'+elem[3]+'"><img src="imgs/download.png" title="Descargar Archivo" border=0 align=top></a> <a href="docs/'+elem[3]+'" style="text-decoration:none">Descargar Archivo</a></div>';
				if(minda=='1') 
				{	tira+= '<fieldset><legend><a href="javascript:shocul(\'cambiafile\')">Cambiar archivo</a></legend>'
						+ '<div id="cambiafile"><input id="remplazar" name="remplazar" type="file" align="left" /><input type="Button" value="subir archivo" onclick="$(\'#remplazar\').uploadifyUpload()"></div></fieldset>'; 
				}
			}
			tira+='</dd>';
			document.getElementById('viendofile').value = elem[3];
			if(elem[3]!='')  { laext = getex(elem[3]);	tira+='<dt>Formato:</dt><dd><div class="ext_'+laext+'"></div> &nbsp; '+laext+'</dd>'; 	tira+='<dt>Tamaño:</dt><dd>'+elem[14]+'</dd>'; 		}
			if(elem[17]=='1') { elem[17]='1 voto'; } else { elem[17]=elem[17]+ ' votos'; }
			tira+='<dt>Calificaci&oacute;n:</dt><dd><div id="areavotos" ida="'+elem[0]+'"></div><span class="peq" id="areavotoshow">'+elem[17]+'</span><span class="peq"><br>Haga click en la estrella que considere su calificación.</span>&nbsp;</dd>';
			tira+='<dt>Titulo en español:</dt><dd><span '+titucla+' id="'+elem[0]+'-'+'titulo_sp">'+elem[2]+'</span>&nbsp;</dd>';
			tira+='<dt>Fecha de Publicación:</dt><dd><span '+titucla+' id="'+elem[0]+'-'+'fechapub">'+elem[4]+'</span>&nbsp;</dd>';
			tira+='<dt>Autor:</dt><dd><span '+titucla+' id="'+elem[0]+'-'+'autor">'+elem[5]+'</span>&nbsp;</dd>';
			tira+='<dt>Sugerido por:</dt><dd><span '+titucla+' id="'+elem[0]+'-'+'sugeridor">'+elem[6]+'</span>&nbsp;</dd>';
			tira+='<dt>Ubicación Física:</dt><dd><span '+titucla+' id="'+elem[0]+'-'+'ubi_fisica">'+elem[7]+'</span>&nbsp;</dd>';
			tira+='<dt>Abstract:</dt><dd><span '+tituta+' id="'+elem[0]+'-'+'abstract">'+elem[8]+'</span>&nbsp;</dd>';
			tira+='<dt>Palabras claves:</dt><dd><span '+tituta+' id="'+elem[0]+'-'+'palabrasclaves">'+elem[9]+'</span>&nbsp;</dd>';
			if(minda=='1') { tira+='<dt>Visible:</dt><dd><span style="width:50px" '+titusino+' id="'+elem[0]+'-'+'visible">';			if(elem[11]=='1'){ tira+='<img src="imgs/chulito.gif">'; } else {tira+='No';} tira+='</span></dd>'; }
			tira+='<dt>Versión Final:</dt><dd><span style="width:50px"  '+titusino+' id="'+elem[0]+'-'+'versionfinal">';if(elem[12]=='1'){ tira+='<img src="imgs/chulito.gif">'; } else {tira+='No';} tira+='</span></dd>';
			tira+='<dt>Nuevo:</dt><dd><span style="width:50px" '+titusino+' id="'+elem[0]+'-'+'nuevo">';				if(elem[13]=='1'){ tira+='<img src="imgs/chulito.gif">'; } else {tira+='No';} tira+='</span></dd>';
			tira+='<dt>Categorías:</dt><dd>'+elem[15]+'</dd>'; 
			if(minda=='1') { tira+='<dt>Foro:</dt><dd><span title="Click para editar" class="editafile_se" id="'+elem[0]+'-'+'foro">'+getforo(elem[10])+'</span></dd>'; }
			tira+='</dl><br clear="all"><h2>Foro</h2><div id="esteforo"><img src="imgs/indicator.gif" width="16" height="16" alt=""></div>';
			if(minda=='1' || elem[10]=='1') // meter formulario del foro
			{	tira+='Hacer comentario<br><textarea cols="70" rows="5" id="hacercom" name="hacercom"></textarea><br><input type="Button" value="Enviar" onclick="enviacom()">'
			}
		}
	}
	document.getElementById('detallearchivo').innerHTML = tira;
	$("#detallearchivo").animate({ opacity: "show" }, "fast");
	$(".editafile").editable("bibliojax.php", { 
	      indicator : "<img src='imgs/indicator.gif'>",
	      tooltip   : "Click para editar...",
		  submitdata: { _method: "post" },
		  width  : "300px",
		  id   : 'campo',
	      name : 'vale'
	  });
	$(".editafile_ta").editable("bibliojax.php", { 
		indicator : "<img src='imgs/indicator.gif'>",
		tooltip   : "Click para editar...",
		type   : 'textarea',
		submitdata: { _method: "put" },
		select : true,
		submit : 'OK',
		cancel : 'cancel',
		width  : "300px",
		height : "50px",
		id   : 'campo',
	    name : 'vale'
	});
	$(".editafile_se").editable("bibliojax.php", { 
		indicator : '<img src="imgs/indicator.gif">',
		tooltip   : "Click para editar...",
		data   : "{'0':'No visible','1':'Disponible','2':'Cerrado'}",
		type   : "select",
		submit : "OK",
		id   : 'campo',
	    name : 'vale'
  });
  $(".editafile_sino").editable("bibliojax.php", { 
		indicator : '<img src="imgs/indicator.gif">',
		tooltip   : "Click para editar...",
		data   : "{'0':'No','1':'Sí'}",
		type   : "select",
		submit : "OK",
		id   : 'campo',
	    name : 'vale'
  });
	$('#remplazar').uploadify({
		'uploader': 'uploadify.swf',
		'script': 'bibliojax.php',
		'folder': 'docs/',
		'scriptData': {'campo': document.getElementById('viendo').value, 'antes':document.getElementById('viendofile').value },
		'cancelImg': 'imgs/cancel.png',
		'buttonImg': 'imgs/examinar.gif',
		//'width':'71','height':'19',
		'hideButton': 'true',
		onComplete: function(event, queueID, fileObj, reposnse, data) 
		{	//alert(reposnse);
			armadet(document.getElementById('viendo').value);
		},
		onSelect: function(event, queueID, fileObj) 
		{ 	laext=fileObj.type.substring(1,fileObj.type.length);
			tensi = /(gif|png|jpg|jpeg|pdf|zip|rar|html|htm|txt|swf|flv|doc|docx|ppt|pptx|xls|xlsx)/;
			if(!tensi.test(laext))	{	alert('Tipo de archivo no permito');	$('#remplazar').uploadifyCancel(queueID); return false; }
		}
	});
	$("#cambiafile").hide();
	if(elem[16]!=''){	$('#areavotos').rater('bibliojax.php?voto&ida='+elem[0], {style: 'small', curvalue:elem[16]});  }
	else			{	$('#areavotos').rater('bibliojax.php?voto&ida='+elem[0], {style: 'small' });  }
	traeforo();
}

function actualizavotos(tales)
{	elid = document.getElementById('areavotos').getAttribute('ida');
	vots = tales.split('.-.');
	if(vots[1]=='1') { vots[1]='1 voto'; } else { vots[1]=vots[1] + ' votos'; }
	document.getElementById('areavotoshow').innerHTML=vots[1];
	document.getElementById('areavotos').innerHTML='';
	if(vots[0]!=''){	$('#areavotos').rater('bibliojax.php?voto&ida='+elid, {style: 'small', curvalue:vots[0]});  }
	else			{	$('#areavotos').rater('bibliojax.php?voto&ida='+elid, {style: 'small' });  }
	
}

function enviacom()
{	mensa = document.getElementById('hacercom').value;
	if(mensa=='')
	{	alert('Por favor ingrese su comentario'); document.getElementById('hacercom').focus();
	}
	else
	{	dequien = document.getElementById('viendo').value;
		if(document.getElementById('esteforo') && dequien!='')
		{	document.getElementById('hacercom').value = '';
			yaxpa('bibliojax.php?addcom='+mensa+'&forode='+dequien,'intercambiador4',700);
		}
	}
}

function borraforo(dequ, mensa)
{	if(confirm('¿Está seguro de quere borrar este comentario del foro?'))
	{	yaxpa('bibliojax.php?delcom='+mensa+'&forode='+dequ,'intercambiador4',700);
	}
}

function traeforo()
{	dequien = document.getElementById('viendo').value;
	if(document.getElementById('esteforo') && dequien!='')
	{	yaxpa('bibliojax.php?forode='+dequien,'intercambiador4',700);
	}
}

function armaforo()
{	//document.getElementById('esteforo').innerHTML = 'ya te armo el foro'+document.getElementById('intercambiador4').innerHTML;
	mesgs = document.getElementById('intercambiador4').innerHTML.split('-_-'); tira='';
	tronp = document.getElementById('lgd').value;
	dequien = document.getElementById('viendo').value;
	if(mesgs.length==0 ) {  tira='No hay comenarios en el foro'; }
	else
	{	alter='1';
		for(k=0; k<mesgs.length; k++)
		{	elem=mesgs[k].split('.-.');
			if(elem.length==4) //$vec[] = $row_comes['id_msg'].'.-.'.$fe[0].'.-.'.$row_comes['nombre'].'.-.'.$row_comes['comentario'];
			{	fecha = ajustefecha(elem[1]); del='';
				if(tronp=='1') { del='<img src="imgs/cancel.png" width="16" height="16" class="comebor" title="Borrar este comentario" onclick="borraforo('+dequien+','+elem[0]+')">'; }
				tira+='<div class="comentario">'+del
					+	'<div class="comcom'+alter+'">'+elem[3]+'</div>'
					+	'<div class="comautor">'+elem[2]+'<u class="sez'+alter+'"></u></div>'
					+	'<div class="comfecha">'+fecha+'</div></div>';
				
				if(alter=='1') { alter='2'; } else { alter='1'; }
			}
		}
	}
	document.getElementById('esteforo').innerHTML = tira;
}



function ajustefecha(me)
{	lafe = me; mes='';
	fech = me.split('-'); 
	if(fech.length==3)
	{		 if(fech[1]=='01') { mes='Ene'; } else if(fech[1]=='02') { mes='Feb'; } else if(fech[1]=='03') { mes='Mar'; } else if(fech[1]=='04') { mes='Abr'; } else if(fech[1]=='05') { mes='May'; } else if(fech[1]=='06') { mes='Jun'; }
	 	else if(fech[1]=='07') { mes='Jul'; } else if(fech[1]=='08') { mes='Ago'; } else if(fech[1]=='09') { mes='Sep'; } else if(fech[1]=='10') { mes='Oct'; } else if(fech[1]=='11') { mes='Nov'; } else if(fech[1]=='12') { mes='Dec'; }
		lafe = fech[2]+'/'+mes+'/'+fech[0];
	}	return lafe;
}

function validafile()
{	//$(\'#remplazar\').uploadifyUpload();
}



function tales()
{	alert('hola');
}

$(document).ready(
	function()
	{	$('#resizeMe').Resizable(
			{	minWidth: 100,
				minHeight: 50,
				maxWidth: 900,
				maxHeight: 700,
				handlers: {					e: '#resizeE'				},
				onResize: function(size)
				{	$('#elarbol', this).css('width', size.width - 6 + 'px');
					$('#buscadores', this).css('width', size.width - 20 + 'px');
				}
			}
		);
		$("#buscadores").hide();
	}
	
);


function shocultab(nodo)
{	sepa = nodo.split('-');
	le=Number(sepa[0]); ri=Number(sepa[1]);
	ivel = document.getElementById('tabla'+le).getAttribute('nivel'); ivel++;
	izq=document.getElementById('izquierdas').value.split(',');
	tal =document.getElementById('ima'+nodo);	ima = tal.src.lastIndexOf('/');	ima = tal.src.substring(ima+1,tal.src.length); 
	if(ima=='mas.png') 	
	{	tal.src='imgs/menos.png'; 	// hacia adelante visible el siguiente nivel, más arriba ocultos
		for(k=0; k<izq.length; k++)
		{	if(izq[k]>le && izq[k]<ri)
			{	if(document.getElementById('tabla'+izq[k]).getAttribute('nivel')==ivel )	
				{	document.getElementById('tabla'+izq[k]).style.display='block';	maso=document.getElementsByName('imas'+izq[k])[0]; if(maso) { maso.src='imgs/mas.png'; } }
				if(document.getElementById('tabla'+izq[k]).getAttribute('nivel')>ivel )
				{	document.getElementById('tabla'+izq[k]).style.display='none';
				}
			}
		}
	} 
	else 
	{ 	tal.src='imgs/mas.png'; 
		for(k=0; k<izq.length; k++)
		{	if(izq[k]>le && izq[k]<ri)
			{	if(document.getElementById('tabla'+izq[k]).getAttribute('nivel')==ivel )	
				{	document.getElementById('tabla'+izq[k]).style.display='none';	maso=document.getElementsByName('imas'+izq[k])[0]; if(maso) { maso.src='imgs/mas.png'; } }
				if(document.getElementById('tabla'+izq[k]).getAttribute('nivel')>ivel )
				{	document.getElementById('tabla'+izq[k]).style.display='none';
				}
			}
		}
	}
}

function shocul(me)
{	este=document.getElementById(me);
	if(este)
	{	if(este.style.display=='none') { este.style.display='block'} else {este.style.display='none'}
	}
}

function treearma()
{	yaxpa('bibliojax.php?armatree','elarbol',100);
}

function treeditable() 
{	$(".click").editable("bibliojax.php", { 
      indicator : "<img src='imgs/indicator.gif'>",
      tooltip   : "Click para editar...",
	  width  : "200px",
	  id   : 'elemid',
      name : 'lorva'
  });
	if(document.getElementById('ider').value != '')
	{	delafoto=document.getElementById('ider').value.split(',');
		for(k=0; k<delafoto.length; k++)
		{	navi = delafoto[k].split('-');
			if(document.getElementsByName('tab'+navi[0])[0])
			{	document.getElementsByName('tab'+navi[0])[0].style.display=navi[1];
			}
		}
		losid=document.getElementById('ides').value.split(',');
		losid = losid.sort(sortNumber); nuevo=losid[losid.length-1];
		document.getElementsByName('tab'+nuevo)[0].style.display='block';
		filearma('1')
	}  
}
function sortNumber(a,b)
{	return a - b;
}

function tree_ops(me, op)
{	foto();
	if(op=='del') 
	{	if(confirm('¿Está seguro de querer borrar este nodo?\n(Los documentos de este nodo y de los nodos internos pasaran al nodo padre)')) 
		{	yaxpa('bibliojax.php?node='+me+'&act='+op,'intercambiador',101);	//document.arbol.submit(); 
		} 
	}
	else	
	{	yaxpa('bibliojax.php?node='+me+'&act='+op,'intercambiador',101);		}
}

function tree_vis(nodo, op)
{	yaxpa('bibliojax.php?n='+nodo+'&v='+op,'ojo_'+nodo,'0');	
}

function foto()
{	losid=document.getElementById('ides').value.split(',');
	insta=new Array();
	for(k=0; k<losid.length; k++)
	{	visi=document.getElementsByName('tab'+losid[k])[0].style.display;
		insta[k] = losid[k]+'-'+visi;
	}
	document.getElementById('ider').value = insta.join(',');
}

function pestana(me)
{	if(me.id=='pest_categ')
	{	document.getElementById('pest_categ').className = 'acti';
		document.getElementById('pest_busca').className = 'noac';
		$("#buscadores").animate({ opacity: "hide" }, "fast");
		$("#elarbol").animate({ opacity: "show" }, "fast");
	}
	else if(me.id=='pest_busca')
	{	document.getElementById('pest_busca').className = 'acti';
		document.getElementById('pest_categ').className = 'noac';
		$("#elarbol").animate({ opacity: "hide" }, "fast");
		$("#buscadores").animate({ opacity: "show" }, "fast");
		$('#fechapubdesdeb2').simpleDatepicker({  startdate: '1/1/1970' });
		$('#fechapubhastab2').simpleDatepicker({  startdate: '1/1/1970' });
	}
}

function valibus1()
{	if(document.getElementById('buspor').value=='')
	{	alert('Por favor digite su criterio de búsqueda'); 
		document.getElementById('buspor').focus();
	}
	else
	{	document.getElementById('buspor2').value=document.getElementById('buspor').value;
		$("#chivos").animate({ opacity: "hide" }, "fast");
		yaxpa('bibliojax.php?busbas&bp='+document.getElementById('buspor').value,'intercambiador2',500);
	}
	return false;
}

function valibus1_1()
{	$("#chivos").animate({ opacity: "hide" }, "fast");
	yaxpa('bibliojax.php?busbas&bp='+document.getElementById('buspor2').value,'intercambiador2',500);
}

function listarmabus()
{	vec  = document.getElementById('intercambiador2').innerHTML; 
	vec2 = vec.replace(/\s/g,'');
	tira='<h2>Resultado de la búsqueda</h2>Buscando por <b>'+document.getElementById('buspor').value+'</b><br><br>';
	if(vec2=='')
	{	tira+='<i>No se encontraron resultados</i>';
		document.getElementById('chivos').innerHTML = tira; document.getElementById('buspor').focus();
	}
	else
	{	tira+=armalista(vec,'1');
		document.getElementById('chivos').innerHTML = tira+'<div id="detallearchivo"></div>';
		if(document.getElementById("listarchivos") && document.getElementById("listarchivos").rows[0].cells.length==8)
		{	$("#listarchivos").tablesorter({ headers: { /*0:{sorter:false}, */ 3:{sorter:false}, 7:{sorter:false}},  widgets: ['zebra']  });
		}
		else if(document.getElementById("listarchivos") && document.getElementById("listarchivos").rows[0].cells.length==4)
		{	$("#listarchivos").tablesorter({ headers: { /*0:{sorter:false}, */ 3:{sorter:false}},  widgets: ['zebra']  });
		}
		$("#detallearchivo").hide();
	}
	$("#chivos").animate({ opacity: "show" }, "fast");
}

function valibus2_1()
{	$("#chivos").animate({ opacity: "hide" }, "fast");
	yaxpa(document.getElementById('buspor3').value,'intercambiador2',600);
}

function listarmabusadv()
{	vec  = document.getElementById('intercambiador2').innerHTML; 
	vec2 = vec.replace(/\s/g,'');
	tira='<h2>Resultado de la búsqueda avanzada</h2>';
	if(document.getElementById('buspor4').value=='rec') { tira='<h2>Archivos subidos en los 2 meses anteriores</h2>'; }
	if(vec2=='')
	{	tira+='<i>No se encontraron resultados</i>';
		document.getElementById('chivos').innerHTML = tira; document.getElementById('titulo_originalb2').focus();
	}
	else
	{	tira+=armalista(vec,'2');
		document.getElementById('chivos').innerHTML = tira+'<div id="detallearchivo"></div>';
		if(document.getElementById("listarchivos") && document.getElementById("listarchivos").rows[0].cells.length==8)
		{	$("#listarchivos").tablesorter({ headers: { /*0:{sorter:false}, */ 3:{sorter:false}, 7:{sorter:false}},  widgets: ['zebra']  });
		}
		else if(document.getElementById("listarchivos") && document.getElementById("listarchivos").rows[0].cells.length==4)
		{	$("#listarchivos").tablesorter({ headers: { /*0:{sorter:false}, */ 3:{sorter:false}},  widgets: ['zebra']  });
		}
		$("#detallearchivo").hide();
	}
	$("#chivos").animate({ opacity: "show" }, "fast");
}

function valibus2()
{	if(document.getElementById('titulo_originalb2').value=='' && document.getElementById('titulo_spb2').value=='' 	&& document.getElementById('archivob2').value=='' 	&& document.getElementById('fechapubdesdeb2').value=='' && 
	   document.getElementById('fechapubhastab2').value==''   && document.getElementById('autorb2').value=='' 		&& document.getElementById('sugeridorb2').value=='' && document.getElementById('ubi_fisicab2').value=='' && 
	   document.getElementById('abstractb2').value=='' 		  && document.getElementById('palabrasclavesb2').value=='' && document.getElementById('forob2').value=='' 	&& document.getElementById('visibleb2').value=='' && 
	   document.getElementById('versionfinalb2').value=='' 	  && document.getElementById('nuevob2').value=='')
	{	alert('Por favor indique sus criterios de búsqueda'); 
		document.getElementById('titulo_originalb2').focus();
	}
	else
	{	qs = 'bibliojax.php?busadv&';
		if(document.getElementById('titulo_originalb2').value!='')		{	qs+='titor='+document.getElementById('titulo_originalb2').value+'&';	}	
		if(document.getElementById('titulo_spb2').value!='')			{	qs+='titsp='+document.getElementById('titulo_spb2').value+'&';			}
		if(document.getElementById('archivob2').value!='')				{	qs+='archi='+document.getElementById('archivob2').value+'&';			}
		if(document.getElementById('autorb2').value!='')				{	qs+='autor='+document.getElementById('autorb2').value+'&';				}
		if(document.getElementById('sugeridorb2').value!='')			{	qs+='suger='+document.getElementById('sugeridorb2').value+'&';			}
		if(document.getElementById('ubi_fisicab2').value!='')			{	qs+='ubifi='+document.getElementById('ubi_fisicab2').value+'&';			}
		if(document.getElementById('abstractb2').value!='')				{	qs+='abstr='+document.getElementById('abstractb2').value+'&';			}
		if(document.getElementById('palabrasclavesb2').value!='')		{	qs+='pacla='+document.getElementById('palabrasclavesb2').value+'&';		}
		if(document.getElementById('forob2').value!='')					{	qs+='foro='+document.getElementById('forob2').value+'&';				}
		if(document.getElementById('visibleb2').value!='')				{	qs+='visib='+document.getElementById('visibleb2').value+'&';			}
		if(document.getElementById('versionfinalb2').value!='')			{	qs+='vefin='+document.getElementById('versionfinalb2').value+'&';		}
		if(document.getElementById('nuevob2').value!='')				{	qs+='nuevo='+document.getElementById('nuevob2').value+'&';				}
		if(document.getElementById('fechapubdesdeb2').value!=''	)		{	qs+='desde='+document.getElementById('fechapubdesdeb2').value+'&';		}
		if(document.getElementById('fechapubhastab2').value!='')		{	qs+='hasta='+document.getElementById('fechapubhastab2').value;			}
		
		document.getElementById('buspor3').value=qs; document.getElementById('buspor4').value='';
		$("#chivos").animate({ opacity: "hide" }, "fast");
		yaxpa(qs,'intercambiador2',600);
	}
	return false;
}
/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects="";
var rootdomain="http://"+window.location.hostname;
var bustcacheparameter="";
var g_u_ere_ele=''; // sirve para saber qué documento se pidió a ajaxpage

function yaxpa(url, containerid, siga)
{	g_u_ere_ele=url; 
	filter=/^http:/;
	if(filter.test(url))
	{	document.getElementById(containerid).innerHTML='<iframe width="450" height="500" frameborder="0" hspace="0" marginheight="0"  marginwidth="0" src="'+url+'"></iframe>';
	}
	else
	{	var page_request = false
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
			page_request = new XMLHttpRequest()
		else if (window.ActiveXObject)
		{ // if IE
			try {	page_request = new ActiveXObject("Msxml2.XMLHTTP")	} 
			catch (e)
			{	try	{	page_request = new ActiveXObject("Microsoft.XMLHTTP")	
					}
				catch (e){}
			}
		}
		else	return false
		page_request.onreadystatechange=function(){	loadpage(page_request, containerid,siga)	}
		if (bustcachevar) //if bust caching of external page
		{	bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() }
		page_request.open('GET', url+bustcacheparameter, true);
		page_request.send(null);
	}
}

function loadpage(page_request, containerid, siga)
{	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	{	document.getElementById(containerid).innerHTML=page_request.responseText;
		if(siga==1)	{	uts(); 	}
		else if(siga==2)	{	detallesorden(); 	}
		else if(siga==100)	{	treeditable();	}
		else if(siga==101)	{	treearma();	}
		else if(siga==200)	{	listarma();	}
		else if(siga==300)	{	detaarma();	}
		else if(siga==400)	{	filearma(document.getElementById('xchan').value)	}
		
		else if(siga==500)	{	listarmabus();	}
		else if(siga==600)	{	listarmabusadv();	}
		else if(siga==700)	{	armaforo();	}
	
	}
}