<!-- BeComunes.js

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);

		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) {

	registros = xmlobj.getElementsByTagName('Registro');

	numregistros=registros.length;
	
	if (ordinalreg > numregistros)
		return "";

	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');
				
				varCodAut = codigotipo[0].firstChild.nodeValue;
				varParam1  = param1;
	
				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])
				return fechaini[0].firstChild.nodeValue;		
		} else if (tag == 'FFin') {
			var i = 0;
			fechafin = registros[ordinalreg].getElementsByTagName('FechaFin');
			
			if (fechafin[0])
				return fechafin[0].firstChild.nodeValue;		
		} else if (tag == 'URL') {
			var i = 0;
			url = registros[ordinalreg].getElementsByTagName('Url');
			
			if (url[0])
				return url[0].firstChild.nodeValue;		
		} else if (tag == 'HIni') {
			var i = 0;
			horaini = registros[ordinalreg].getElementsByTagName('HoraIni');
			
			if (horaini[0])
				return horaini[0].firstChild.nodeValue;		
		} else if (tag == 'HFin') {
			var i = 0;
			horafin = registros[ordinalreg].getElementsByTagName('HoraFin');
			
			if (horafin[0])
				return horafin[0].firstChild.nodeValue;		
		} else if (tag == 'Nota') {
			var i = 0;
			nota = registros[ordinalreg].getElementsByTagName('Nota');
			
			if (nota[0])
				return nota[0].firstChild.nodeValue;		
		} else if (tag == 'Resu') {
			var i = 0;
			resumen = registros[ordinalreg].getElementsByTagName('Resumen');
			
			if (resumen[0])
				return resumen[0].firstChild.nodeValue;		
		} else if (tag == 'Acce') {
			var i = 0;
			
			acceso = registros[ordinalreg].getElementsByTagName('Acceso');
			
			if (acceso[0])
				return acceso[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 == '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;
	}

	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;
}


// BeComunes.js --> 