rel_aux = new Array()
valorg_aux = new Array()
valcomun_aux = new Array()
function actualizar_list(f,lista_org,par_ini){
	if (par_ini == null){
		//alert ("es nulo")
		par_ini = 0
	}// end if
	var m_lista = new Array()
	var campo_nombre = new Array()
	var campo_pos = new Array()
	var campo_padre = new Array()
	var padre_ant = new Array()
	k = 0
	n_elementos = f.elements.length
	for (i=0;i<=n_elementos-1;i++){
		e = f.elements[i]
		relacion_aux = rel_aux[e.name]
		if(e.type == "select-one" && relacion_aux !="" && relacion_aux != null){
			k = k + 1
			m_lista[k] = e
		}// end if
	}// next
	padre_aux = lista_org.name
	salir = "n"
	n_lista = k
	k = 0
	m = 0
	while (salir == "n" && n_lista > 0){
		salir = "s"
		band = 0
		for (i=1;i<=n_lista;i++){
			relacion_aux = rel_aux[m_lista[i].name]
			//relacion = m_lista[i].relacion
			aux = relacion_aux.split(":")
			if(aux[0] == padre_aux ){
				salir = "n"
				k = k + 1
				campo_nombre[k] = m_lista[i]
				campo_pos[k] = aux[1]
				campo_padre[k] = padre_aux
				if (band==0){
					m++
					band++
					padre_ant[m] = m_lista[i].name
				}// end if
			}// end if
		}// next
		if (k>0 && m>0){
			padre_aux = padre_ant[m]
		}// end if
	}// end while
	for (m=1;m<=k;m++){
		llenar_lista(f,campo_nombre[m],campo_pos[m],campo_padre[m],par_ini)
		//campo_nombre[m].onchange()
	}// next
}// end function
function agregar_opcion(lista_x,valor_x,texto_x){
	var opcion = document.createElement("OPTION")
	opcion.value = valor_x
	opcion.text = texto_x
	lista_x.options.add(opcion)
	lista_x.value = valor_x
}// end function

function habilitar_opcion(lista_x,valor_x,div_x){
	capa_div = document.getElementById(div_x)
	if(lista_x.options[lista_x.selectedIndex].value ==valor_x){
		capa_div.style.visibility = "visible";
	}else{
		capa_div.style.visibility = "hidden"
	}// end if
}// end function

function llenar_lista(f,lista_x,pos_x,valor_padre,valor_y){
	nombre_campo = lista_x.name
	lista_x.length = 0
	encontrado_x = 0
	valor_comun = valcomun_aux[lista_x.name]
	eval("matriz="+nombre_campo+"_xyz")
	valorg_x = valorg_aux[lista_x.name]
	for (i=1;i<matriz.length;i++){
		campo_aux = matriz[i].split(":")
		if (campo_aux[pos_x-1] == f.elements[valor_padre].value || campo_aux[0]==valor_comun){
			var opcion = document.createElement("OPTION")
			valor_x = campo_aux[0]
			texto_x = campo_aux[1]
			opcion.value = valor_x
			opcion.text = texto_x
			lista_x.options.add(opcion)
			if (valorg_x==valor_x){
				encontrado_x=1
			}// end if*/
		}// end if
	}// next
	
	if (encontrado_x==1 && valor_y == 1 && valorg_x !="" && valorg_x != null){
		lista_x.value = valorg_x
	}// endif
	if(f.cfg_modo_aux.value != "1" && valorg_x!="" && (lista_x.value==null || lista_x.value=="")){
		//agregar_opcion(lista_x,valorg_x,valorg_x)
	}// end if

}// end function
function ini_list(){
	n_form = document.forms.length
	for (ifomr=0;ifomr<n_form;ifomr++){
		f = document.forms[ifomr]
		n_ele = f.elements.length
		for (iele=0;iele<n_ele;iele++){
			control_s = f.elements[iele]
			//if(control_s.type == "select-one" && control_s.onchange!=null){
			if("".concat(control_s.onchange).indexOf("actualizar_list")>=0){
				actualizar_list(f,control_s,1)
			}// end if
		}// next
	}// next
}// end function
function ordenar_set(nombre_x,form_x){
	var formulario = document.forms[form_x]
	n_elementos = formulario.elements.length
	valor_x = ""
	formulario.elements[nombre_x].value = ""
	for (i=0;i<=n_elementos-1;i++){
		tipo = formulario.elements[i].type
		nombre_elem = formulario.elements[i].name
		if (tipo == "checkbox" && formulario.elements[i].checked && nombre_elem.substring(0,nombre_x.length)==nombre_x){
			valor_x += formulario.elements[i].value+","
		}// end if
	}// next
	valor_x = valor_x.substring(0,valor_x.length-1)
	formulario.elements[nombre_x].value = valor_x
}// end if

// función que abre una ventana con una url dada
var Ventana
function HacerVentana(MiURL) {
	if (!Ventana || Ventana.closed) {
		Ventana = window.open(MiURL,"Foto")}
	else{
	// bring existing subwindow to the front
	Ventana.focus()
	}// end if
}// end function
/// elemento div para mostrar los comentarios
var ele_div
ele_div = "\n\t<div id='coment' class='orion' style='position:absolute;"
ele_div += "width:150px;visibility:hidden;overflow: auto;z-Index:1000;'>"
ele_div += "</div>\n"
document.write(ele_div)

function HacerPopup(control_x,salida_x,nombre_x) {
	div_ele = document.getElementById("coment")
	ancho_x = 0
	aTag = control_x
	if (control_x.value == "Ocultar"){
		control_x.value =control_x.valueviejo}
	else{
		control_x.valueviejo = control_x.value
		control_x.value = "Ocultar"
	}// end if
	w=control_x.offsetWidth
	h=control_x.offsetHeight
	leftpos	= 0
	toppos = 0
	do {
		aTag = aTag.offsetParent;
		leftpos	+= aTag.offsetLeft;
		toppos += aTag.offsetTop;
	} while(aTag.tagName!="BODY");

	div_ele.innerHTML = salida_x
	div_ele.style.top = (toppos+control_x.offsetTop+h)+"px"
	div_ele.style.left = (leftpos+control_x.offsetLeft+w)+"px"
	if(div_ele.style.visibility=="visible"){
		div_ele.style.visibility="hidden"}
	else{
		div_ele.style.visibility = "visible"
	}// end if


	/*Ventana = window.open("",nombre_x,"HEIGHT=200,WIDTH=200,TOP="+(toppos+h)+",LEFT="+(leftpos+w))
	Ventana.document.write(salida_x)
	Ventana.document.close()*/
}// end function
function esconder_div(ele_x){
	div_ele = document.getElementById(ele_x)
	div_ele.style.visibility="hidden"
}// end if