function menu_item(form_x,obj_x,par_x,modo_x,accion_x,pag_x){
	if (typeof(form_x)=="object")
		f = form_x
	else
		if (form_x=="" || form_x == null)
			f = document.forms[0]
		else
			f = document.forms[form_x]
		// end if
	// end if
	f.cfg_objeto_aux.value = obj_x
	f.cfg_parametro_aux.value = par_x
	f.cfg_modo_aux.value = modo_x
	f.cfg_accion_aux.value = accion_x
	f.cfg_pagina_aux.value = pag_x
	//f.submit()
}// end function
function get_form(form_x){
	if (typeof(form_x)=="object")
		if (form_x.type=="form"){
			return form_x
		}else{
			return form_x.form
		}// end if
	else
		if (form_x=="" || form_x == null)
			return document.forms[0]
		else
			return document.forms[form_x]
		// end if
	// end if
}// end function
function eval_pagina(control_x,pagina_y){
	switch(parseInt(control_x.value,10)){
	case -4:
		control_x.value = pagina_y - 1
		if(control_x.value==0){
			control_x.value = 1
		}// end if
		break
	case -2:
		control_x.value = pagina_y + 1
		break
	}// end switch	
}// end if
function menu(form_x,para_x,pre_x,post_x,volver_x){
	if (para_x=="" || para_x == null)
		return false
	// end if
	f = get_form(form_x)
	if (pre_x == null)
		pre_x = ""
	if (post_x == null)
		post_x = ""
	var_x = para_x.split(";")
	pagina_x = parseInt(f.cfg_pagina_aux.value,10)
	pagina_z = parseInt(f.cfg_pag_form_aux.value,10)
	for (i=0;i<var_x.length;i++){
		var2_x = var_x[i].split(":")
		if (var2_x[0]!= null && var2_x[0]!= "" && var2_x[1]!= "-1"){
			cad_x = "f."+pre_x+var2_x[0]+post_x+".value='"+var2_x[1]+"'"	
			eval(cad_x)
		}
	}// next
	eval_pagina(f.cfg_pagina_aux,pagina_x)
	eval_pagina(f.cfg_pag_form_aux,pagina_z)
	/*
	if(f.cfg_accion_aux.value=="-1")
		f.cfg_accion_aux.value = ""
	if(f.cfg_modo_aux.value == -1)
		f.cfg_modo_aux.value = ""
		*/
	if(f.cfg_sw_aux.value==f.cfg_sw2_aux.value){
		if (f.cfg_sw_aux.value!="1"){
			f.cfg_sw_aux.value = "1"
		}else{
			f.cfg_sw_aux.value = "0"
		}// end if
		//((f.cfg_sw_aux.value)%2)+1
	}// end if
	return true
}// end if
function menu_aux(para_x,form_x){
	menu(form_x,para_x,'cfg_','_aux')
	f.submit()
}// end function
function boton_aux(para_x,form_x,valid_x,volver_x){
	//validar_reg() || 
	if (valid_x && (!val.ejecutar(get_form(form_x))))
		return false
	return menu(form_x,para_x,'cfg_','_aux',volver_x)
}// end function
function alert_m(m){
	if (m!=null && m!=""){
		return (true)
		
	}
	return (false)
}// end if

function abrir_vinculo(enlace_x,target){
	if (target!="_self" && target != "" && target != null) {
  		window.open(enlace_x,target)
		}
  	else{
		document.location.href = enlace_x
	}// end if
}// end function


// funciones de controles

function seleccionar_lista(control_x,nombre_x){
	n_ele = control_x.length
	sel = ""
	for(i=0;i<n_ele;i++){
		if(control_x.options[i].selected){
			sel += ((sel!="")?",":"")+control_x.options[i].text
		}// end if
	}// next
	control_x.form.elements[nombre_x].value = sel
}// end if
function seleccionar_todo(control_x,nombre_x){
	f = control_x.form
	n_ele = f.elements.length
	sel = ""
	valor_x = control_x.checked
	for(i=0;i<n_ele;i++){
		ele_x = f.elements[i]
		tipo_x = ele_x.type
		nombre = ele_x.name
		if (tipo_x=="checkbox" && nombre.substr(0,nombre_x.length) == nombre_x ){
			ele_x.checked = valor_x
		}// end if
	}// next
	seleccionar_set(control_x,nombre_x)
}// end if
function seleccionar_set(control_x,nombre_x){
	f = control_x.form
	n_ele = f.elements.length
	sel = ""
	for(i=0;i<n_ele;i++){
		ele_x = f.elements[i]
		tipo_x = ele_x.type
		nombre = ele_x.name
		if (tipo_x=="checkbox" && nombre.substr(0,nombre_x.length) == nombre_x ){	
			if(ele_x.checked){
				sel += ((sel!="")?";":"")+ele_x.value
			}// end if
		}// end if
	}// next
	
	f.elements[nombre_x].value = sel
}// end function
function validar_reg(control_x){
	f = get_form(control_x)
	ele_x = f.elements["cfg_reg_aux"]
	if(ele_x.value != null && ele_x.value != ""){
		return (true)
	}else{
		return (false)
	}// end if
}// end if
// fin funciones de controles



function cambiar_item(control_x,direccion){
	if (control_x.length <=1){
		return false
	}// end if
	indice = control_x.selectedIndex
	f = control_x.form
	valor_x = control_x.value 
	texto_x = control_x.options[control_x.selectedIndex].text
	if(direccion == 's'){
		if (indice >0){
			dir = -1
		}else{
			return false
		}// end if
	}else{
		if ((indice+1)<(control_x.length)){
			dir = 1
		}else{
			return false
		}// end if
	}// end if
	control_x.options[control_x.selectedIndex].value = control_x.options[control_x.selectedIndex+dir].value
	control_x.options[control_x.selectedIndex].text = control_x.options[control_x.selectedIndex+dir].text
	control_x.options[control_x.selectedIndex+dir].value = valor_x
	control_x.options[control_x.selectedIndex+dir].text = texto_x
	control_x.selectedIndex = indice + dir
}// end function

function copiar_item (control_x,control_y,tipo_x){
	if (control_x.length <1){
		return false
	}// end if
	indice = control_x.selectedIndex
	l = control_x.length
	if (indice<0){
		return false
	}// end if
	f = control_x.form
	var opcion = document.createElement("OPTION")
	valor_x = control_x.value
	texto_x = control_x.options[control_x.selectedIndex].text
	opcion.value = valor_x
	opcion.text = texto_x
	control_y.options.add(opcion)
	if (tipo_x=="u"){
		control_x.options[control_x.selectedIndex] = null
		if ((indice+1)==l){
			control_x.selectedIndex = indice -1
		}else{
			control_x.selectedIndex = indice
		}// end if
	}// end if
	
}// end function
function eliminar_item (control_x,todo){
	if (control_x.length <1){
		return false
	}// end if
	l = control_x.length
	indice = control_x.selectedIndex
	control_x.options[indice] = null
	if ((indice+1)==l){
		control_x.selectedIndex = indice -1
	}else{
		control_x.selectedIndex = indice
	}// end if
	
}// end function

function sel_item(control_x,control_y){

	l = control_x.length
	aux = ""
	for(i=0;i<l;i++){
		aux += ((aux!="")?";":"")+control_x.options[i].value
	}// next
	control_y.value = aux
}// end function
function ajustar_grid(id_x){
	if(ele_x = document.getElementById(id_x)){
		if (navigator.appName.substring(0,4)=="Micr"){
			if(ele_x.offsetWidth>466){
				ele_x.style.overflowX="auto"
				ele_x.style.height = ele_x.offsetHeight+20
			}// end if
		}else{
			ele_x.style.overflow="auto"
		}// end if
	}// end if
}// end function
function ajustar_capa(id_x){
	if(ele_x = document.getElementById(id_x)){
		if (navigator.appName.substring(0,4)=="Micr"){
			ctlTag = ele_x
			do {
				ctlTag = ctlTag.offsetParent;
			} while(ctlTag.tagName!="TD");
			if(ele_x.offsetWidth>= ctlTag.width){
				ele_x.style.width = ctlTag.width	
				ele_x.style.overflowX="auto"
				ele_x.style.height = ele_x.offsetHeight+18
			}// end if
		}else{
			ele_x.style.overflow="auto"
		}// end if	
	}// end if	
	
}// end function
function sel_reg(opcion_x,consulta_x){
	f = opcion_x.form
	reg = opcion_x.value
	f["cfg_reg_aux"].value = f[consulta_x+"_reG_"+reg].value
	
	
	
}// end function