<!-- BeComunes.js
/*document.write("<script src='/alexandr/scripts/prototype.js'></script>"); */

function Regresar() {
 history.go(-1);
}
function Avanzar() {
 history.go(+1);
}
function Estatus(txt) {
 window.status = txt;
 setTimeout("window.status = ''",5000);
}
function ColocaTituloPaginaWeb(winObj,titulo) {
	winObj.title = titulo;
}
function ObtieneTituloPaginaWeb(winObj) {
	return winObj.title;
}

function UpdateDlg(pCampo) {
	top.document.getElementById(pCampo).value = dlgModal.returnedValue;
	return false;
}

function AsignaValorCampoTexto(pCampo,pValor) {
	top.document.getElementById(pCampo).value = pValor;
	
	return;
}

function AsignaValorCampoLista(pCampo,pValor,pTexto) {
	var Valores;
	var Texto;
	var i;
	var Lista;
	
	if (!pCampo || !pValor)
		return;
		
	if (!pTexto)
		pTexto = pValor;

	if (pValor != "") {
		Valores = pValor.split(";");
	
		if (pTexto && pTexto != "")
			Texto = pTexto.split(";");
		else
			Texto = pValor.split(";");

		i = 0;	

		Lista = top.document.getElementById(pCampo);
		Lista.length = 0;
		
		while (i < Valores.length)  {

			Lista.options[i] = new Option(Texto[i],Valores[i]);	

			i++;
		}
	}
	return;
}	

function TextoSelecionado() { 
	var txt = '';
	var foundIn = '';
	if (window.getSelection) {
		txt = window.getSelection();
		foundIn = 'window.getSelection()';
	}
	else if (document.getSelection) {
		txt = document.getSelection();
		foundIn = 'document.getSelection()';
	}
	else if (document.selection) {
		txt = document.selection.createRange().text;
		foundIn = 'document.selection.createRange()';
	}
	
	return txt;
} 

function CargarForma() {
	iniciaMenu();
	if (top.opener && top.opener.blockEvents)
		top.opener.blockEvents();
}

function DescargarForma() {
 	if (top.opener && top.opener.unblockEvents) { 
		top.opener.unblockEvents();
	}
	if (this.CierraDependencias)
		this.CierraDependencias();
}

function CierraDependencias() {
  if (dlg.win && dlg.win.open && !dlg.win.closed)
  	dlg.win.close();
}

function iniciaMenu(){
	tunMenu = document.getElementById('LayerBusquedas');

	if (tunMenu) {
		tunMenu.style.top = posicionSup + "px";
		if(tunIex){
			tunMenu.style.position='absolute'
			onscroll = posicion;
		}
		else{tunMenu.style.position='fixed'} 
	}
}


function InfoExistencia() {Estatus("Información de existencias");}
function InfoEjemplares() {Estatus("Información del registro");}
function InfoDetalles() {Estatus("Información de detalles");}
function RefAutor() {Estatus("Referencias del mismo autor");}
function ResumenExistencia() {Estatus("Resumen o existencias");}
function SolicitudRemota() {Estatus("Solicitud remota");}
function MismaEditorial() {Estatus("Referencias de la misma editorial");}
function RefAnaliticas() {Estatus("Referencias Analíticas");}

function OcultarElemento(idElemento)
{
	if (document.getElementById(idElemento))
		document.getElementById(idElemento).style.display = "none";
}

function MostrarElemento(idElemento)
{
	if (document.getElementById(idElemento))
		document.getElementById(idElemento).style.display = "";
}

function MostrarOcultarElemento(idElemento)
{
	if (document.getElementById(idElemento)) {
		var estilo = document.getElementById(idElemento).style.display;

		if (estilo == 'none')
			MostrarElemento(idElemento);
		else
			OcultarElemento(idElemento);
	}
}

function DeshabilitarHabilitarCampo(idElemento,bDeshabilitar)
{
	vCampo = document.getElementById(idElemento);
	if (vCampo) {
		vCampo.disabled = bDeshabilitar;
	}
}

function OcultarCampo(idElemento)
{
	vCampo = document.getElementById(idElemento);
	if (vCampo) {
		vCampo.style.visibility='hidden';
	}
}

function ValidarListaConCaja(VariableAValidar) {
	Variable = document.getElementById(VariableAValidar);
	VariableCmb = eval("document.getElementById('" + VariableAValidar + "Cmb');");
	
	if (!Variable || !VariableCmb)
		return;

	if (Variable.value != '' && VariableCmb.value == '') {
		VariableCmb.value = 'Otro';
		Variable.style.visibility = 'visible';
	}
}

function HabilitarEdicionDescriptor(event,varForma,varCodigo,varTipo)
{
	varEdicionDescriptores = document.getElementById('EdicionDescriptores');
	varTipoValor = document.FEdtDescript.TipoValor;//getElementById('SubFuncion');
	varSubFuncion = document.FEdtDescript.Subfuncion;//getElementById('SubFuncion');

	if (varEdicionDescriptores) {
		var X = event.clientX;
		var Y = event.clientY + document.body.scrollTop + 15;
		varEdicionDescriptores.style.top = Y + "px";
		varEdicionDescriptores.style.left = X + "px";
		if (varEdicionDescriptores.style.display == "none")
			varEdicionDescriptores.style.display = "block";
		else {
			if (gCodDesc == varCodigo) {
				varEdicionDescriptores.style.display = "none";
			}
		}
		gCodDesc = varCodigo;
		varSubFuncion.value = varCodigo;
		varTipoValor.value = varTipo;
	}
}
		

function ObtenerValorTagXML(xmlobj,tag,param1,ordinalreg,ordinalcampo) {
	
	if (xmlobj) {	// 20100118
		var usuarios;
		var registros;
		var prestamo;
		var estructura;
		
		registros = xmlobj.getElementsByTagName('Registro');
		usuarios = xmlobj.getElementsByTagName('Usuario');
		prestamo = xmlobj.getElementsByTagName('Prestamo');
		estructura = xmlobj.getElementsByTagName('EstructuraAlejandria');

		numregistros=registros.length;

		if (registros[ordinalreg]) {
			if (tag == 'Titu') {
				var i = 0;
				titulos = registros[ordinalreg].getElementsByTagName('Titulo');
		
				if (param1 == '') {
					if (titulos[0])
						return titulos[0].firstChild.nodeValue;
				} else {
					for(var s=0;s<titulos.length;s++) {
						
						codigotipo = titulos[s].getElementsByTagName('CodigoTipo');
						nombre = titulos[s].getElementsByTagName('Nombre');
						
						varCodTit = codigotipo[0].firstChild.nodeValue;
						varParam1  = param1;
			
						if (varCodTit.toUpperCase() == varParam1.toUpperCase()) {
							if (i == ordinalcampo)
								return nombre[0].firstChild.nodeValue;
							i++;
						}
					}
				}
			} else if (tag == 'Auto') {
				var i = 0;
				autores = registros[ordinalreg].getElementsByTagName('Autor');
				
				for(var s=0;s<autores.length;s++) {
					
					codigotipo = autores[s].getElementsByTagName('CodigoTipo');
					nombre = autores[s].getElementsByTagName('Nombre');
				
					if (codigotipo.length == 0) {
						return autores[0].firstChild.nodeValue;
					}

					varCodAut = codigotipo[0].firstChild.nodeValue;
					varParam1  = param1;
		
					if (param1 == '') { //No se indicó tipo se devuelve el primero
						return nombre[0].firstChild.nodeValue;
					}
					
					if (varCodAut.toUpperCase() == varParam1.toUpperCase()) {
						if (i == ordinalcampo)
							return nombre[0].firstChild.nodeValue;
						i++;
					}
				}
			} else if (tag == 'FIni') {
				var i = 0;
				fechaini = registros[ordinalreg].getElementsByTagName('FechaIni');
				
				if (fechaini[0] && fechaini[0].firstChild)
					return fechaini[0].firstChild.nodeValue;		
			} else if (tag == 'FFin') {
				var i = 0;
				fechafin = registros[ordinalreg].getElementsByTagName('FechaFin');
				
				if (fechafin[0] && fechafin[0].firstChild)
					return fechafin[0].firstChild.nodeValue;		
			} else if (tag == 'URL') {
				var i = 0;
				url = registros[ordinalreg].getElementsByTagName('Url');
				
				if (url[0] && url[0].firstChild)
					return url[0].firstChild.nodeValue;		
			} else if (tag == 'HIni') {
				var i = 0;
				horaini = registros[ordinalreg].getElementsByTagName('HoraIni');
				
				if (horaini[0] && horaini[0].firstChild)
					return horaini[0].firstChild.nodeValue;		
			} else if (tag == 'HFin') {
				var i = 0;
				horafin = registros[ordinalreg].getElementsByTagName('HoraFin');
				
				if (horafin[0] && horafin[0].firstChild)
					return horafin[0].firstChild.nodeValue;		
			} else if (tag == 'Nota') {
				var i = 0;
				nota = registros[ordinalreg].getElementsByTagName('Nota');
				
				if (nota[0] && nota[0].firstChild)
					return nota[0].firstChild.nodeValue;		
			} else if (tag == 'Resu') {
				var i = 0;
				resumen = registros[ordinalreg].getElementsByTagName('Resumen');
				
				if (resumen[0] && resumen[0].firstChild)
					return resumen[0].firstChild.nodeValue;		
			} else if (tag == 'Acce') {
				var i = 0;
				
				acceso = registros[ordinalreg].getElementsByTagName('Acceso');
				
				if (acceso[0] && acceso[0].firstChild)
					return acceso[0].firstChild.nodeValue;		
			} else if (tag == 'Cota') {
				var i = 0;
				
				cota = registros[ordinalreg].getElementsByTagName('Cota');
				
				if (cota[0] && cota[0].firstChild)
					return cota[0].firstChild.nodeValue;		
			} else if (tag == 'Desc') {
				var i = 0;
				tipodescriptor = registros[ordinalreg].getElementsByTagName('TipoDescriptor');
				
				for(var s=0;s<tipodescriptor.length;s++) {
					
					codigotipo = tipodescriptor[s].getElementsByTagName('Codigo');
					nombre = tipodescriptor[s].getElementsByTagName('Descriptor');
					
					varCodDesc = codigotipo[0].firstChild.nodeValue;
					varParam1  = param1;
					
					varCodDesc = varCodDesc.toUpperCase();
					varParam1 = varParam1.toUpperCase();
		
					if (varCodDesc == varParam1) {
						if (i == ordinalcampo)
							return nombre[0].firstChild.nodeValue;
						i++;
					}
				}
				
			} else if (tag == 'VAdi') {
				var i = 0;
				variableadicional = registros[ordinalreg].getElementsByTagName('VariableAdicional');
				
				for(var s=0;s<variableadicional.length;s++) {
					
					codigotipo = variableadicional[s].getElementsByTagName('Codigo');
					valor = variableadicional[s].getElementsByTagName('Valor');
					
					if (codigotipo[0].firstChild.nodeValue == 'VAdi' + param1) {
						if (i == ordinalcampo)
							return valor[0].firstChild.nodeValue;
						i++;
					}
				}
				
			} else if (tag == 'TVerificacion') {
				var i = 0;
				tverificacion = registros[ordinalreg].getElementsByTagName('TituloVerificacion');
				
				if (tverificacion[0] && tverificacion[0].firstChild)
					return tverificacion[0].firstChild.nodeValue;		
			} else if (tag == 'RVerificacion') {
				var i = 0;
				rverificacion = registros[ordinalreg].getElementsByTagName('ResultadoVerificacion');
				
				if (rverificacion[0] && rverificacion[0].firstChild)
					return rverificacion[0].firstChild.nodeValue;		
			} else if (tag == 'REliminados') {
				var i = 0;
				reliminados = registros[ordinalreg].getElementsByTagName('RegistrosBorrados');
				
				if (reliminados[0] && reliminados[0].firstChild)
					return reliminados[0].firstChild.nodeValue;		
			} 
			else if (tag == 'Valor') {
				var i = 0;
				valor = registros[ordinalreg].getElementsByTagName('Valor');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
			else if ((tag == 'CoEj') ||
					 (tag == 'NoEj') ||
					 (tag == 'PrEj') ||
					 (tag == 'EPEj') ||
					 (tag == 'EdEj') ||
					 (tag == 'TPEj')){
				var i = 0;
				ejemplar = registros[ordinalreg].getElementsByTagName('Ejemplar');
				
				if (ordinalcampo <= ejemplar.length) {
					
					if (tag == 'CoEj') {
						codigo = ejemplar[ordinalcampo].getElementsByTagName('AccesoEj');
						
						if (codigo[0] && codigo[0].firstChild)
							return codigo[0].firstChild.nodeValue;
					}
					else if (tag == 'NoEj') {
						numero = ejemplar[ordinalcampo].getElementsByTagName('Numero');
						
						if (numero[0] && numero[0].firstChild)
							return numero[0].firstChild.nodeValue;
					}
					else if (tag == 'PrEj') {
						prestamoejemplar = ejemplar[ordinalcampo].getElementsByTagName('PrestamoEjemplar');
						
						if (prestamoejemplar[0] && prestamoejemplar[0].firstChild)
							return prestamoejemplar[0].firstChild.nodeValue;
					}
					else if (tag == 'EPEj') {
						estadoprestamo = ejemplar[ordinalcampo].getElementsByTagName('EstadoPrestamo');
						
						if (estadoprestamo[0] && estadoprestamo[0].firstChild)
							return estadoprestamo[0].firstChild.nodeValue;
					}
					else if (tag == 'EdEj') {
						estado = ejemplar[ordinalcampo].getElementsByTagName('Estado');
						
						if (estado[0] && estado[0].firstChild)
							return estado[0].firstChild.nodeValue;
					}
					else if (tag == 'TPEj') {
						tipoprestamo = ejemplar[ordinalcampo].getElementsByTagName('TipoPrestamo');
						
						if (tipoprestamo[0] && tipoprestamo[0].firstChild)
							return tipoprestamo[0].firstChild.nodeValue;
					}
				}
			} 
			else if (tag == 'RWeb' ||
					 tag == 'DesD' ||
					 tag == 'TamD' ||
					 tag == 'CodA') {
				var i = 0;
				refasociada = registros[ordinalreg].getElementsByTagName('ReferenciaAsociada');
					
				if (tag == 'RWeb') {
					var i = 0;
					valor = refasociada[ordinalreg].getElementsByTagName('ReferenciaWeb');
					
					if (valor[0] && valor[0].firstChild)
						return valor[0].firstChild.nodeValue;		
				} else if (tag == 'DesD') {
					var i = 0;
					valor = refasociada[ordinalreg].getElementsByTagName('Descripcion');
					
					if (valor[0] && valor[0].firstChild)
						return valor[0].firstChild.nodeValue;		
				} else if (tag == 'TamD') {
					var i = 0;
					valor = refasociada[ordinalreg].getElementsByTagName('EspacioDisco');
					
					if (valor[0] && valor[0].firstChild)
						return valor[0].firstChild.nodeValue;		
				} else if (tag == 'CodA') {
					var i = 0;
					valor = refasociada[ordinalreg].getElementsByTagName('CodigoAsocEdoc');
					
					if (valor[0] && valor[0].firstChild)
						return valor[0].firstChild.nodeValue;		
				}
			}
		} else if (usuarios[ordinalreg]) {
			var valor;
			if (tag == 'Codi') {
				var i = 0;
				valor = usuarios[ordinalreg].getElementsByTagName('Codigo');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			} else if (tag == 'Carn') {
				var i = 0;
				valor = usuarios[ordinalreg].getElementsByTagName('Carnet');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			} else if (tag == 'ApeU') {
				var i = 0;
				valor = usuarios[ordinalreg].getElementsByTagName('Apellidos');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			} else if (tag == 'NomU') {
				var i = 0;
				valor = usuarios[ordinalreg].getElementsByTagName('Nombres');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			} else if (tag == 'Cedu') {
				var i = 0;
				valor = usuarios[ordinalreg].getElementsByTagName('Cedula');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			} else if (tag == 'TUPr') {
				var i = 0;
				valor = usuarios[ordinalreg].getElementsByTagName('TipoUsrPrestamo');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			} else if (tag == 'Stat') {
				var i = 0;
				valor = usuarios[ordinalreg].getElementsByTagName('Status');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
		} else if (prestamo[ordinalreg]) {
			if (tag == 'FSol') {
				var i = 0;
				valor = prestamo[ordinalreg].getElementsByTagName('FechaSolicitud');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
			else if (tag == 'FPre') {
				var i = 0;
				valor = prestamo[ordinalreg].getElementsByTagName('FechaPrestamo');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
			else if (tag == 'FDev') {
				var i = 0;
				valor = prestamo[ordinalreg].getElementsByTagName('FechaDevolucion');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
			else if (tag == 'FExp') {
				var i = 0;
				valor = prestamo[ordinalreg].getElementsByTagName('FechaExpiracion');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
			else if (tag == 'Stat') {
				var i = 0;
				valor = prestamo[ordinalreg].getElementsByTagName('Status');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
			else if (tag == 'EdEj') {
				var i = 0;
				valor = prestamo[ordinalreg].getElementsByTagName('Estado');
				
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
			else if (tag == 'EPEj') {
				var i = 0;
				valor = prestamo[ordinalreg].getElementsByTagName('EstadoPrestamo');
			
				if (valor[0] && valor[0].firstChild)
					return valor[0].firstChild.nodeValue;		
			}
		}
		
		if (estructura[0]) {
			if (tag == 'TDoc') {
				var i = 0;
				tipodocumento = estructura[0].getElementsByTagName('TipoDocumento');
							
				for(var s=0;s<tipodocumento.length;s++) {
					
					codigotipo = tipodocumento[s].getElementsByTagName('Codigo');
					nombre = tipodocumento[s].getElementsByTagName('Nombre');
					
					varCodTipoDoc = codigotipo[0].firstChild.nodeValue;
					varParam1  = param1;
		
					if (param1 == '') { //No se indicó tipo se devuelve el primero
						return nombre[0].firstChild.nodeValue;
					}
					
					if (varCodTipoDoc.toUpperCase() == varParam1.toUpperCase()) {
						if (i == ordinalcampo)
							return nombre[0].firstChild.nodeValue;
						i++;
					}
				}
			}
		}
		if (tag == 'CamposObligatorios') {
			var i = 0;
			var ListaCampos = '';
			camposobligatorios = xmlobj.getElementsByTagName('CamposObligatorios');
			
			if (camposobligatorios[0] && camposobligatorios[0].firstChild) {
				
				Campos = camposobligatorios[0].getElementsByTagName('Campo');
				while (Campos[i] && Campos[i].firstChild) {
					if (ListaCampos != '')
						ListaCampos+= '\n';
					ListaCampos+= Campos[i].firstChild.nodeValue;
					i++;
				}
			}
			return ListaCampos;
		} 
		if (tag == 'Palabra') {
			var i = 0;
			var vpalabra = xmlobj.getElementsByTagName('Palabra');
			
			if (vpalabra[0] && vpalabra[0].firstChild)
				return vpalabra[0].firstChild.nodeValue;	
		}
		if (tag == 'Porcentaje') {
			var i = 0;
			var vporcentaje = xmlobj.getElementsByTagName('Porcentaje');
			
			if (vporcentaje[0] && vporcentaje[0].firstChild)
				return vporcentaje[0].firstChild.nodeValue;	
		}
		if (tag == 'Mensaje') {
			var i = 0;
			var vmensaje = xmlobj.getElementsByTagName('Mensaje');

			if (vmensaje[0] && vmensaje[0].firstChild)
				return vmensaje[0].firstChild.nodeValue;	
		}
		if (tag == 'Mensaje') {
			var i = 0;
			var vmensaje = xmlobj.getElementsByTagName('Mensaje');

			if (vmensaje[0] && vmensaje[0].firstChild)
				return vmensaje[0].firstChild.nodeValue;	
		}
		if (tag == 'Sesion') {
			var i = 0;
			var vsesion = xmlobj.getElementsByTagName('Sesion');

			if (vsesion[0] && vsesion[0].firstChild)
				return vsesion[0].firstChild.nodeValue;	
		}
		if (tag == 'UsuarioConectado') {
			var i = 0;
			var vcodigo = xmlobj.getElementsByTagName('UsuarioConectado');

			if (vcodigo[0] && vcodigo[0].firstChild)
				return vcodigo[0].firstChild.nodeValue;	
		}
	}
	return "";
}

// retrieve text of an XML document element, including
// elements using namespaces
function getElementTextNS(prefix, local, parentElem, index) {
    var result = "";
    if (prefix && isIE) {
        // IE/Windows way of handling namespaces
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        // the namespace versions of this method 
        // (getElementsByTagNameNS()) operate
        // differently in Safari and Mozilla, but both
        // return value with just local name, provided 
        // there aren't conflicts with non-namespace element
        // names
        result = parentElem.getElementsByTagName(local)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes 
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
            return result.firstChild.nodeValue;    		
        }
    } else {
        return "n/a";
    }
}

function UneCampoID(szTipo,szTexto,szCampo) {
	var vCeros = '';
	var vTipo = document.getElementById(szTipo);
	var vTexto = document.getElementById(szTexto);
	var vCampo = document.getElementById(szCampo);
	
	if (vTexto.value) {
		vCampo.value = vTipo.value + '-';
		vCampo.value+= vCeros+vTexto.value;
	}
	else
		vCampo.value = '';
	
	return;
}

function UneCampoHora(szTipo,szTexto,szCampo) {
	var vTipo = document.getElementById(szTipo);
	var vTexto = document.getElementById(szTexto);
	var vCampo = document.getElementById(szCampo);
	
	if (vTexto.value)
		vCampo.value = vTexto.value + vTipo.value;
	else
		vCampo.value = '';
	return;
}

function ManejoTecladoID(szCampoTipo,szCampoTexto) {
	
	var vCampoTipo = document.getElementById(szCampoTipo);
	var vCampoTexto = document.getElementById(szCampoTexto);

	if (vCampoTipo) {
		if (vCampoTipo.value == 'V' || vCampoTipo.value == 'E')
			SoloNumeros(vCampoTexto,vCampoTexto.value.charAt(vCampoTexto.value.length-1));
	}
}

function SoloNumeros(campo,caracter)
{
	valor = campo.value;
	
	for(i=0;i<valor.length;i++) {
		if (isNaN(valor.charAt(i))) {
			valor = valor.replace(valor.charAt(i),"")
			i = 0;
		}
	}
	
	campo.value = valor;
	return;
}

function InicializaSelect(tag,bSinSeleccione)
{
	tagobj = document.getElementById(tag);
	
	if (tagobj) {
		tagobj.options.length = 0;
	}
	
	if (!bSinSeleccione) {
		AgregarOpcionSelect(tag,'--Seleccione--');
	}
}

function InicializaCampo(tag)
{
	tagobj = document.getElementById(tag);
	
	if (tagobj) {
		tagobj.value = '';
	}	
}

function teclaEvento(evento) {
	if (evento.keyCode)
		return evento.keyCode;
	else
		return evento.which;
} 

function ObtenerNumeroElementrosXML(xmlobj,idobj) {
	var iNumero = -1;
	if (xmlobj) {	// EGC puede llegar en null
		elementos = xmlobj.getElementsByTagName(idobj);
		iNumero = elementos.length;
	}
	return iNumero;
}

function AsignarValorTagHTMLV2(xmlobj,tag,param1,ordinalreg,ordinalcampo,campo) {
	var tagobj;
	tagobj = document.getElementById(campo);

	if (tagobj && xmlobj) {
		var valor;
		valor = ObtenerValorTagXML(xmlobj,tag,param1,ordinalreg,ordinalcampo);

		if (valor)
			tagobj.value = valor;
	}

	return;
}

function AsignarValorTagHTML(tag,value) {
	tagobj = document.getElementById(tag);

	if (tagobj)
		tagobj.value = value;

	return;
}

function FFechaFormato(Fecha) {
	var sFecha = '';
	
	if (Fecha) {
		if (Fecha.length >= 4) {
			sFecha+= Fecha.substr(0,4);
			
			if (Fecha.length >= 6) {
				sFecha+= '-';
				sFecha+=Fecha.substr(4,2);
				
				if (Fecha.length == 8) {
					sFecha+= '-';
					sFecha+=Fecha.substr(6,2);
				}
			}
		}
	}
	
	return sFecha;
}


function ObtenerValorSeleccionadoRadioButton(ctrl)
{
    for(i=0;i<ctrl.length;i++)
        if(ctrl[i].checked) return ctrl[i].value;
}

function ObtenerValoresSeleccionadosCheckBox(ctrl)
{
	var vValor = '';
	
	if (ctrl.length) {
		for(i=0;i<ctrl.length;i++) {
			if(ctrl[i].checked) {
				if (vValor != '')
					vValor+= ',';
				vValor+= ctrl[i].value;
			}
		}
	} else {
		vValor = ctrl.value;
	}
	
	return vValor;
}

function ObtenerValorXMLConsultaGenerica(xmlobj,tag,ordinalreg)
{
	if (xmlobj) {
		registros_sql = xmlobj.getElementsByTagName('RegistroSql');

		numregistros=registros_sql.length;
		
		if (ordinalreg > numregistros)
			return "";

		if (registros_sql[ordinalreg]) {
			camposql = registros_sql[ordinalreg].getElementsByTagName('CampoSql');
			
			for(i=0;i<camposql.length;i++) {
				var nombre = camposql[i].getElementsByTagName('Nombre');
				var sznombre = '';
				
				if (nombre[0] && nombre[0].firstChild)
					sznombre = nombre[0].firstChild.nodeValue;
					
				if (tag == sznombre) {
					var valor = camposql[i].getElementsByTagName('Valor');

					if (valor[0] && valor[0].firstChild)
						return valor[0].firstChild.nodeValue;
				}
			}
		}
	}
	
	return "";
}

// ------------------------------------------------------- ColocaHTMLElemento
function ColocaHTMLElemento(id,sHTML) {
	var ctrl = document.getElementById(id);
	
	if (ctrl) {
		ctrl.innerHTML = sHTML;
	}
}
// fin ColocaHTMLElemento
// BeComunes.js --> 

// ------------------------------------------------------- ActualizarSesionFormulario
function ActualizarSesionFormulario(sForma,iCodSesion) {
	vSesion = document.forms[sForma].Sesion;
	
	if (vSesion) {
		vSesion.value = iCodSesion;
	}
}
// fin ActualizarSesionFormulario

//Esto deberia ir en un be_aalex.js
var vcheckBoxTodosSolRes = false;
// ------------------------------------------------------- onClickTodosSolRes
function onClickTodosSolRes() {

	vlstCtrl = document.getElementsByName('checkBoxSolRes[]');
	for (i=0;i< vlstCtrl.length;i++) {
		if (vcheckBoxTodosSolRes) {
			vlstCtrl[i].checked = false;
		} else {
			vlstCtrl[i].checked = true;
		}
	}
	vcheckBoxTodosSolRes = !vcheckBoxTodosSolRes;

}
//

//Esto deberia ir en un be_aalex.js
iTotalPeticiones = 0;
iTotalPeticionesEx = 0;
// ------------------------------------------------------- onClickProcesarBusquedaReservaciones
function onClickProcesarBusquedaReservaciones()
{
	var lstArray = Array();
	var chkEje = document.getElementsByName('checkBoxSolRes[]');
	var linEje = document.getElementsByName('LineaSolRes[]');
	
	for(ii=0;ii< chkEje.length;ii++) {
		if (chkEje[ii].checked) {
			sConsulta = linEje[ii].value;
			lstArray.push(codificaURL(sConsulta));
			iTotalPeticiones++;
		}
	}
	
	for(i=0;i< lstArray.length;i++) {
		cambiarEstadoEjemplar('/cgi-win/be_asf.exe',lstArray[i],'Bu','');
	}
}
//

function postCambioEstadoEjemplar(ajaxobj,filetype,parameters_callbackfunc) {  

	var myajax=ajaxobj
	var myfiletype=filetype
	var myParamatersEx=parameters_callbackfunc;
	var iCodSesion = '';
	
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
			if (myfiletype=="txt")
				alert(myajax.responseText);
			else {
			}
		}
	}
}

function cambiarEstadoEjemplar(be,url,state,sMostrador)
{
	new Ajax.Request(
		be,
		{queue: {position: 'end', scope: 'command'},
			method: 'post',
			postBody: url,
			onComplete: function(response)
				    {
						var vFormato = document.getElementById('FBSOLRES-SFmt');
						var sFormato = '';
						if (vFormato)
							sFormato = '&SFmt='+vFormato.value;
						iTotalPeticionesEx++;
						if (iTotalPeticionesEx == iTotalPeticiones) {
							if (state == 'Bu')
								window.location = '/cgi-win/be_aalex.exe?Forma=FADM&Funcion=Solicitudes+de+servicio+pendientes&valor=*Bu&Nombrebd='+document.getElementById('FBSOLRES-Nombrebd').value+'&Sesion='+document.getElementById('FBSOLRES-Sesion').value+sFormato;
							else if (state == 'Mo')
								window.location = '/cgi-win/be_aalex.exe?Forma=FADM&Funcion=Solicitudes+de+servicio+pendientes&valor='+sMostrador+'|*Vi&Nombrebd='+document.getElementById('FBSOLRES-Nombrebd').value+'&Sesion='+document.getElementById('FBSOLRES-Sesion').value+sFormato;
							else if (state == 'Vi')
								window.location = '/cgi-win/be_aalex.exe?Forma=FADM&Funcion=Solicitudes+de+servicio+pendientes&valor=*Bu&Nombrebd='+document.getElementById('FBSOLRES-Nombrebd').value+'&Sesion='+document.getElementById('FBSOLRES-Sesion').value+sFormato;
								//location.reload();
							else alert('Error, estado desconocido:'+state);
						}
				    }
		}
	);

}

function codificaURL(url) {
	
	var Consulta = '';
	ListaVariables = url.split("&");

	for (i=0;i < ListaVariables.length;i++) {
		VariableValor = ListaVariables[i].split("=");
		Variable = VariableValor[0];
		
		if (esFamiliaNavegador('firefox')) {
			Valor = encodeURIComponent(VariableValor[1]);
			//Valor = VariableValor[1];
		}
		else {
			Valor = encode(VariableValor[1]);
		}
		
		if (Valor == '' && VariableValor.length == 3)
			Valor = '=';

		if (Consulta != '')
			Consulta+= "&";

		Consulta+= Variable;
		
		if ((Valor != 'undefined') &&
			(typeof (Valor) != "undefined")) {
			Consulta+= "=";
			Consulta+= Valor;	
		}
	}
	
	return Consulta;
}

//Esto deberia ir en un be_aalex.js
// ----------------------------------------------------------------------------onKeyUpMarcarEjemplarBuscado
function onKeyUpMarcarEjemplarBuscado(evn) {
	
	if (teclaEvento(evn)== 13) {
		ctrl = document.getElementById('FBSOLRES-ctrlAccesoEj');
		
		if (ctrl) {
			modificarEstadoEjemplarAViaMostrador(ctrl.value);
		}
	}
}
//fin onKeyUpMarcarEjemplarBuscado

// ----------------------------------------------------------------------------onKeyUpMarcarEjemplarBuscado
function modificarEstadoEjemplarAViaMostrador(sAccesoEj) {
	
	var linEje = document.getElementById('FBSOLRES-LineaSolRes');
	
	if (linEje && sAccesoEj) {
		sConsulta = linEje.value+'&AccesoEj='+sAccesoEj;
		sConsultaURL = codificaURL(sConsulta)
		iTotalPeticiones = 1;
		cambiarEstadoEjemplar('/cgi-win/be_asf.exe',sConsultaURL,'Vi','');
	}
}
//fin 
// -------------------------------------------------------------------------- modificarEstadoEjemplarEnMostrador
function modificarEstadoEjemplarEnMostrador(sAccesoEj,sMostrador) {
	
	var linEje = document.getElementById('FBSOLRES-LineaSolRes');
	
	if (linEje && sAccesoEj && sMostrador) {
		sConsulta = linEje.value+'&AccesoEj='+sAccesoEj+'&valor='+sMostrador;
		sConsultaURL = codificaURL(sConsulta)
		iTotalPeticiones = 1;
		cambiarEstadoEjemplar('/cgi-win/be_asf.exe',sConsultaURL,'Mo',sMostrador);
	}
}
//fin
// -------------------------------------------------------------------------- onKeyUpMostrador
function onKeyUpMostrador(evn) {
	
	if (teclaEvento(evn)== 13) {
		ctrl = document.getElementById('FBSOLRES-valor');
		
		if (ctrl) {
			if (ctrl.value != '' && !isNaN(ctrl.value)) {
				ctrlaux = document.getElementById('FBSOLRES-ctrlAccesoEj');
				ctrlaux.focus();
			}
		}
	}
}
//fin onKeyUpMostrador

// ----------------------------------------------------------------------------onKeyUpMarcarEjemplarBuscado
function onKeyUpMarcarEjemplarEnMostrador(evn) {
	
	if (teclaEvento(evn)== 13) {
		ctrl = document.getElementById('FBSOLRES-ctrlAccesoEj');
		
		if (ctrl) {
			ctrlValor = document.getElementById('FBSOLRES-valor');
			modificarEstadoEjemplarEnMostrador(ctrl.value,ctrlValor.value);
		}
	}
}
//fin onKeyUpMarcarEjemplarBuscado

// ----------------------------------------------------------------------------onClickMarcarEjemplaresEnBusqueda
function onClickMarcarEjemplaresEnBusqueda()
{
	var sSoloChequeados = "";
	var chkEje = document.getElementsByName('checkBoxSolRes[]');
	var sEjemplar = document.getElementsByName('sEjemplares[]');
	var vFormato = document.getElementById('Fadm1-SFmt');
	var sFormato = '';
	if (vFormato)
		sFormato = '&SFmt='+vFormato.value;

	for(ii=0;ii< chkEje.length;ii++) {
		if (chkEje[ii].checked) {
			if (!sSoloChequeados)
				sSoloChequeados = sEjemplar[ii].value;
			else
				sSoloChequeados = sSoloChequeados+","+sEjemplar[ii].value;
		}
	}
	sSesion = document.forms['Fadm1'].Sesion.value;
	sLinea = '/cgi-win/be_aalex.exe?Forma=FADM&Nombrebd=bibcentral&Funcion=Solicitudes%20de%20servicio%20pendientes&valor=*Bu&Sesion='+sSesion+'&AccesoEj='+sSoloChequeados+sFormato;
	window.location = sLinea;
}
//fin 

// ----------------------------------------------------------------------------LlenaCajaEjemplar
function LlenaCajaEjemplar(sEjemplar)
{
	var vCajaEjemplar = document.getElementById('FBSOLRES-ctrlAccesoEj');
	if (vCajaEjemplar) {
		vCajaEjemplar.value = sEjemplar;
	}
}
//fin 
