//## INICIO MODIFICACION

function checkCuentaCliente(f){
	f.cc.value=limpiarCC(f.cc.value);
	if(checkVacio(f.nombres,"Ingrese el (los) nombre(s) del cliente."))return;
	if(checkVacio(f.apellidos,"Ingrese el (los) apellidos(s) del cliente."))return;
	if(checkVacio(f.cc,"Ingrese la Cédula de Ciudadanía del cliente."))return;
	if(checkNselect(f.id_ciudad,"Seleccione la ciudad de operaciones del cliente."))return;
	if(checkVacio(f.compannia_cliente,"Especifique la compañia a la cual pertenece el cliente."))return;
	if(checkVacio(f.cargo,"Ingrese el cargo del cliente en la empresa."))return;
	if(checkVacio(f.dir_oficina,"Ingrese la dirección de la oficina en la que labora el cliente."))return;
	if(checkVacio(f.tel_oficina1,"Ingrese el teléfono principal de la oficina en la que labora el cliente."))return;
	if(checkVacio(f.e_mail,"Ingrese el eMail del cliente."))return;
	if(checkNmail(f.e_mail,"Ingrese correctamente el eMail del cliente."))return;
	//if(f.login.disabled==false) if(checkVacio(f.login,"Ingrese un login o nombre de usuario para el cliente."))return;
	if(f.pass_new.disabled==false){
		if(f.pass_new.value=="" || f.pass_new.value.length<5) {
			alert("Debe especificar una contraseña de mínimo cinco carácteres.");
			f.pass_new.focus();
		}
		if(f.pass_new.value!=f.pass.value) {
			f.pass.value=f.pass_new.value;
			alert("Se ha actualizado la contraseña del usuario.");
		}
	}
	f.activo.value=f.activo.checked?'t':'f';
	f.submit();
}

function checkAsignacionFuncionario(f){
	if(checkNselect(f.id_funcionario,"Seleccione el funcionario al cual escalarle el ticket actual."))return;
	
	f.submit();	
}

function checkNuevoTicket(f){
	if(checkVacio(f.asunto,"Ingrese el asunto para el ticket actual."))	return;
	if(checkVacio(f.detalle,"Ingrese el detalle para el ticket actual.")) return;
	f.submit();
}

function activarCampo(f,index){
	if(f.id_ticket_estado.selectedIndex==0){	//NADA
		document.all(f.id_ticket_estado.sourceIndex-2).style.color="#d42b00";
		f.id_ticket_estado.disabled=false;
		document.all(f.info_cliente.sourceIndex-3).style.color="#000000";
		f.info_cliente.value="";
		document.all(f.info_interna.sourceIndex-3).style.color="#000000";
		f.info_interna.value="";
		f.id_funcionario.disabled=true;
		f.id_funcionario.selectedIndex=0;
		document.all(f.id_funcionario.sourceIndex-2).style.color="#000000";
		f.solucion.readOnly=true;
		f.solucion.value="";
		document.all(f.solucion.sourceIndex-2).style.color="#000000";
		f.motivo_cancelacion.readOnly=true;
		f.motivo_cancelacion.value="";
		document.all(f.motivo_cancelacion.sourceIndex-3).style.color="#000000";
		f.aceptar.disabled=true;
		return;
	} 
	
	if(index==6){	//CANCELADO
		//ACTIVAR MOTIVO_CANCELACION, HISTORICO_CLIENTE E HISTORICO_INTERNO
		if(f.historico_info_cliente.value=="")
			document.all(f.info_cliente.sourceIndex-3).style.color="#d42b00";
		if(f.historico_info_interna.value=="")
			document.all(f.info_interna.sourceIndex-3).style.color="#d42b00";
		f.motivo_cancelacion.readOnly=false;
		document.all(f.motivo_cancelacion.sourceIndex-3).style.color="#d42b00";
		
		//DESACTIVAR Y LIMPIAR FUNCIONARIO Y SOLUCION
		f.id_funcionario.disabled=true;
		f.id_funcionario.selectedIndex=0;
		document.all(f.id_funcionario.sourceIndex-2).style.color="#000000";
		f.solucion.readOnly=true;
		f.solucion.value="";
		document.all(f.solucion.sourceIndex-2).style.color="#000000";
		document.all(f.id_ticket_estado.sourceIndex-2).style.color="#000000";
		f.aceptar.disabled=false;
		return;
	}
	
	if(index==5){	//ESCALADO
		//ACTIVAR HISTORICO_CLIENTE, HISTORICO_INTERNO, FUNCIONARIO
		if(f.historico_info_cliente.value=="")
			document.all(f.info_cliente.sourceIndex-3).style.color="#d42b00";
		if(f.historico_info_interna.value=="")
			document.all(f.info_interna.sourceIndex-3).style.color="#d42b00";
		f.id_funcionario.disabled=false;
		document.all(f.id_funcionario.sourceIndex-2).style.color="#d42b00";
		
		//DESACTIVAR SOLUCION, MOTIVO_CANCELACION
		f.motivo_cancelacion.readOnly=true;
		f.motivo_cancelacion.value="";
		document.all(f.motivo_cancelacion.sourceIndex-3).style.color="#000000";
		f.solucion.readOnly=true;
		f.solucion.value="";
		document.all(f.solucion.sourceIndex-2).style.color="#000000";
		document.all(f.id_ticket_estado.sourceIndex-2).style.color="#000000";
		f.aceptar.disabled=false;
		return;
	}
	
	if(index==4){	//CERRADO
		//ACTIVAR SOLUCION, HISTORICO_CLIENTE, HISTORICO_INTERNO
		if(f.historico_info_cliente.value=="")
			document.all(f.info_cliente.sourceIndex-3).style.color="#d42b00";
		if(f.historico_info_interna.value=="")
			document.all(f.info_interna.sourceIndex-3).style.color="#d42b00";
		f.solucion.readOnly=false;
		document.all(f.solucion.sourceIndex-2).style.color="#d42b00";
		
		//DESACTIVAR MOTIVO_CANCELACION, FUNCIONARIO
		f.motivo_cancelacion.readOnly=true;
		f.motivo_cancelacion.value="";
		document.all(f.motivo_cancelacion.sourceIndex-3).style.color="#000000";
		f.id_funcionario.disabled=true;
		f.id_funcionario.selectedIndex=0;
		document.all(f.id_funcionario.sourceIndex-2).style.color="#000000";
		document.all(f.id_ticket_estado.sourceIndex-2).style.color="#000000";
		f.aceptar.disabled=false;
		return;
	}
	
	if(index==3){	//EN PROCESO
		//ACTIVAR HISTORICO_CLIENTE, HISTORICO_INTERNO
		if(f.historico_info_cliente.value=="")
			document.all(f.info_cliente.sourceIndex-3).style.color="#d42b00";
		if(f.historico_info_interna.value=="")
			document.all(f.info_interna.sourceIndex-3).style.color="#d42b00";
		
		//DESACTIVAR SOLUCION, MOTIVO_CANCELACION, FUNCIONARIO
		f.motivo_cancelacion.readOnly=true;
		f.motivo_cancelacion.value="";
		document.all(f.motivo_cancelacion.sourceIndex-3).style.color="#000000";
		f.id_funcionario.disabled=true;
		f.id_funcionario.selectedIndex=0;
		document.all(f.id_funcionario.sourceIndex-2).style.color="#000000";
		f.solucion.readOnly=true;
		f.solucion.value="";
		document.all(f.solucion.sourceIndex-2).style.color="#000000";
		document.all(f.id_ticket_estado.sourceIndex-2).style.color="#000000";
		f.aceptar.disabled=false;
		return;
	}
}

function establecerEstadoTicket(f,estado){
	if(estado==2 || estado==5){		//ESCALADO O ASIGNADO
		document.all(f.id_ticket_estado.sourceIndex-2).style.color="#d42b00";
		f.id_ticket_estado.disabled=false;
		document.all(f.info_cliente.sourceIndex-3).style.color="#000000";
		document.all(f.info_interna.sourceIndex-3).style.color="#000000";
		f.aceptar.disabled=true;
		if(estado==5) alert("INFORMACION:\n Este ticket ha sido asignado (Escalado) a usted por otro funcionario.");
		return;
	} 
	
	setOption(f.id_ticket_estado,estado);
	if(estado==6){	//CANCELADO
		//ACTIVAR MOTIVO_CANCELACION
		f.motivo_cancelacion.readOnly=false;
		document.all(f.motivo_cancelacion.sourceIndex-3).style.color="#d42b00";
		
		//DESACTIVAR FUNCIONARIO, SOLUCION, HISTORICO_CLIENTE E HISTORICO_INTERNO
		document.all(f.info_cliente.sourceIndex-3).style.color="#000000";
		f.info_cliente.disabled=true;
		document.all(f.info_interna.sourceIndex-3).style.color="#000000";
		f.info_interna.disabled=true;
		f.id_funcionario.disabled=true;
		f.id_funcionario.selectedIndex=0;
		document.all(f.id_funcionario.sourceIndex-2).style.color="#000000";
		f.solucion.readOnly=true;
		f.solucion.value="";
		document.all(f.solucion.sourceIndex-2).style.color="#000000";
		return;
	}
	
	if(estado==4){	//CERRADO
		//ACTIVAR SOLUCION
		f.solucion.readOnly=false;
		document.all(f.solucion.sourceIndex-2).style.color="#d42b00";
		
		//DESACTIVAR MOTIVO_CANCELACION, FUNCIONARIO, HISTORICO_CLIENTE, HISTORICO_INTERNO
		document.all(f.info_cliente.sourceIndex-3).style.color="#000000";
		document.all(f.info_interna.sourceIndex-3).style.color="#000000";
		f.id_funcionario.disabled=true;
		f.id_funcionario.selectedIndex=0;
		document.all(f.id_funcionario.sourceIndex-2).style.color="#000000";
		f.motivo_cancelacion.readOnly=true;
		f.motivo_cancelacion.value="";
		document.all(f.motivo_cancelacion.sourceIndex-3).style.color="#000000";
		return;
	}
	
	if(estado==3){	//EN PROCESO
		setOption(f.id_ticket_estado,estado);
		return;
	}
}

function agregarInfoCliente(f){
	if(f.info_cliente.value=="")return;
	datos = f.historico_info_cliente.value;
	nuevo = f.info_cliente.value;
	if(datos.length==0)
		nuevo = "* "+f.fecha_actual.value+": "+nuevo;
	else
		nuevo = "* "+f.fecha_actual.value+": "+nuevo+"\n";
		
	datos = nuevo + datos;
	f.historico_info_cliente.value = datos;
	f.info_cliente.value="";
}

function agregarInfoInterna(f){
	if(f.info_interna.value=="")return;
	datos = f.historico_info_interna.value;
	nuevo = f.info_interna.value;
	if(datos.length==0)
		nuevo = "* "+f.fecha_actual.value+": "+nuevo;
	else
		nuevo = "* "+f.fecha_actual.value+": "+nuevo+"\n";
		
	datos = nuevo + datos;
	f.historico_info_interna.value = datos;
	f.info_interna.value="";
}

function checkInfoTicket(f,estado_nuevo){
	if(checkNselect(f.id_ticket_estado,"Seleccione un estado válido para el ticket."))return;
	
	if(estado_nuevo==6){	//CANCELADO
		if(checkVacio(f.motivo_cancelacion,"Especifique el motivo de la cancelación del ticket."))	return;
		if(f.historico_info_cliente.value=="" && f.info_cliente.value==""){
			alert("Debe especificar al menos un detalle para el histórico del cliente.");
			f.info_cliente.focus();
			return;
		}
		if(f.historico_info_interna.value=="" && f.info_interna.value==""){
			alert("Debe especificar al menos un detalle para el histórico interno.");
			f.info_interna.focus();
			return;
		}
		
		agregarInfoCliente(f);
		agregarInfoInterna(f);
		
		if(confirm("Desea cancelar el ticket?"))
			f.submit();
		else
			return;
	}
	
	if(estado_nuevo==5){	//ESCALADO
		if(checkNselect(f.id_funcionario,"Seleccione un funcionario al cual asignarle el ticket."))return;
		if(f.historico_info_cliente.value=="" && f.info_cliente.value==""){
			alert("Debe especificar al menos un detalle para el histórico del cliente.");
			f.info_cliente.focus();
			return;
		}
		if(f.historico_info_interna.value=="" && f.info_interna.value==""){
			alert("Debe especificar al menos un detalle para el histórico interno.");
			f.info_interna.focus();
			return;
		}
		
		agregarInfoCliente(f);
		agregarInfoInterna(f);
		
		if(confirm("Confirma escalar el ticket al funcionario\n"+f.id_funcionario.options[f.id_funcionario.selectedIndex].text)+"?")
			f.submit();
		else
			return;
	}
	
	if(estado_nuevo==4){	//CERRADO
		if(checkVacio(f.solucion,"Debe especificar la solución al ticket."))	return;
		if(f.historico_info_cliente.value=="" && f.info_cliente.value==""){
			alert("Debe especificar al menos un detalle para el histórico del cliente.");
			f.info_cliente.focus();
			return;
		}
		if(f.historico_info_interna.value=="" && f.info_interna.value==""){
			alert("Debe especificar al menos un detalle para el histórico interno.");
			f.info_interna.focus();
			return;
		}
		
		agregarInfoCliente(f);
		agregarInfoInterna(f);
		
		f.submit();
	}
	
	if(estado_nuevo==3){	//EN PROCESO
		if(f.historico_info_cliente.value=="" && f.info_cliente.value==""){
			alert("Debe especificar al menos un detalle para el histórico del cliente.");
			f.info_cliente.focus();
			return;
		}
		if(f.historico_info_interna.value=="" && f.info_interna.value==""){
			alert("Debe especificar al menos un detalle para el histórico interno.");
			f.info_interna.focus();
			return;
		}
	
		agregarInfoCliente(f);
		agregarInfoInterna(f);
	
		f.submit();
	}
}

function activarCampoBusqueda(o){
	if(o.checked){
		document.consulta_asignaciones.fecha_ini.disabled=false;
		document.consulta_asignaciones.fecha_fin.disabled=false;
		document.all(document.consulta_asignaciones.fecha_ini.sourceIndex-2).style.color="#d42b00";
		document.all(document.consulta_asignaciones.fecha_fin.sourceIndex-2).style.color="#d42b00";
		
		document.consulta_asignaciones.keywords.disabled=true;
		document.consulta_asignaciones.keywords.value="";
		document.all(document.consulta_asignaciones.keywords.sourceIndex-2).style.color="#000000";
	}else{
		document.consulta_asignaciones.keywords.disabled=false;
		document.all(document.consulta_asignaciones.keywords.sourceIndex-2).style.color="#d42b00";
		
		document.consulta_asignaciones.fecha_ini.disabled=true;
		document.consulta_asignaciones.fecha_fin.disabled=true;
		document.consulta_asignaciones.fecha_ini.value="";
		document.consulta_asignaciones.fecha_fin.value="";
		document.all(document.consulta_asignaciones.fecha_ini.sourceIndex-2).style.color="#000000";
		document.all(document.consulta_asignaciones.fecha_fin.sourceIndex-2).style.color="#000000";
	}
}

function isStrUpper(str){
	var upperCase="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	for(j=0;j<str.toString().length;j++)
		if(upperCase.toString().indexOf(str.toString().charAt(j))<0) return false;
	
	return true;
}

function consultarTickets(f,lista){
	if(f.keywords.value=="" && (f.fecha_ini.value=="" && f.fecha_fin.value=="")){
		alert("Debe especificar algún parámetro para la búqueda.");
		f.keywords.focus();
		return;
	}
	if(f.fecha_ini.value=="" && f.fecha_fin.value!=""){
		alert("Debe especificar la fecha inicial para la búsqueda.");
		f.fecha_ini.focus();
		return;
	}
	if(f.fecha_ini.value!="" && f.fecha_fin.value==""){
		alert("Debe especificar la fecha final para la búsqueda.");
		f.fecha_fin.focus();
		return;
	}
	
	if(f.keywords.value.toString().length>0 && (f.fecha_ini.value.toString().length>0 && f.fecha_fin.value.toString().length>0)){	
		var initial_keys=new Array();
		var keys=new Array();
		initial_keys=f.keywords.value.toString().split(" ");
		var k=0;
		for(i=0 ; i<initial_keys.length ; i++){
			if(initial_keys[i].toString().length<=3 && initial_keys[i].toString().indexOf(".")<0 && !isStrUpper(initial_keys[i].toString()))
				i+=0;
			else{
				keys[k]=initial_keys[i];
				k++;
			}
		}
		
		if(keys.length==0){
			alert("Las palabras clave ingresadas no son válidas.");
			f.keywords.focus();
			return;
		}else{
			str_keywords=keys.join("_");
			f.keywords.value=str_keywords;
							
			fia=new Array();
			fia=f.fecha_ini.value.split("-");
			fi=new Date(fia[0],(fia[1]-1),fia[2],0,0,0);
			ffa=new Array();
			ffa=f.fecha_fin.value.split("-");
			ff=new Date(ffa[0],(ffa[1]-1),ffa[2],0,0,0);
			if (ff<fi){
				alert("La fecha final debe ser mayor a la fecha incial.");
				f.fecha_fin.focus();
				return;
			}else
				str_dates=f.fecha_ini.value.toString()+"_"+f.fecha_fin.value.toString();
		}	
		lista.location.href="listas.php?data=lista_tickets&id="+f.id.value+"&tipo_busqueda=3&keys="+str_keywords+"&dates="+str_dates;
	}else{
		if(f.keywords.value.toString().length>0 && (f.fecha_ini.value.toString().length==0 && f.fecha_fin.value.toString().length==0)){
			var initial_keys=new Array();
			var keys=new Array();
			initial_keys=f.keywords.value.toString().split(" ");
			var k=0;
			for(i=0 ; i<initial_keys.length ; i++){
				if(initial_keys[i].toString().length<=3 && initial_keys[i].toString().indexOf(".")<0 && !isStrUpper(initial_keys[i].toString()))
					i+=0;
				else{
					keys[k]=initial_keys[i];
					k++;
				}
			}
			
			if(keys.length==0){
				alert("Las palabras clave ingresadas no son válidas.");
				f.keywords.focus();
				return;
			}else{
				str=keys.join("_");
				f.keywords.value=str;
				lista.location.href="listas.php?data=lista_tickets&id="+f.id.value+"&tipo_busqueda=1&keys="+str;
			}
		}else{
			if(f.keywords.value.toString().length==0 && (f.fecha_ini.value.toString().length>0 && f.fecha_fin.value.toString().length>0)){
				fia=new Array();
				fia=f.fecha_ini.value.split("-");
				fi=new Date(fia[0],(fia[1]-1),fia[2],0,0,0);
				ffa=new Array();
				ffa=f.fecha_fin.value.split("-");
				ff=new Date(ffa[0],(ffa[1]-1),ffa[2],0,0,0);
				if (ff<fi){
					alert("La fecha final debe ser mayor a la fecha incial.");
					f.fecha_fin.focus();
					return;
				}
				str=f.fecha_ini.value.toString()+"_"+f.fecha_fin.value.toString();
				lista.location.href="listas.php?data=lista_tickets&id="+f.id.value+"&tipo_busqueda=2&keys="+str;
			}
		}
	}
}

//## FIN MODIFICACION

/************************************************************************************
FUNCIONES DE CHEQUEO DE ENTRADA DE DATOS EN FORMULARIOS ATHENEA
************************************************************************************/

function alertar(alerta){
	switch(alerta){
		case "seguimientos":
			top.verCaja('dbox_0','Seguimientos a mis planes de acción',800,450,'forms.php?f=seguimiento_');
			break;
	}
}
function checkParametrosSeguimiento(f){
	if(checkNselect(f.max_plan_accion_area,"Seleccione la cantidad máximia de planes de acción permitidos por área."))return;
	if(checkNselect(f.max_meses_seguimiento,"Seleccione el el máximo plazo en meses para la realización de un seguimiento a un plan de acción."))return;
	if(checkNselect(f.dias_antes_alerta_seguimiento,"Seleccione a cuantos días antes de cumplirse un seguimiento se alertará del mismo."))return;
	f.submit();
	verProcesando();
}
function checkPlanAccionClima(f){
	if(checkVacio(f.items_bajos,"Ingrese los ítems bajos para el plan de acción."))return;
	if(checkVacio(f.accion,"Ingrese la acción a seguir."))return;
	if(checkVacio(f.obs,"Ingrese las observaciones del plan de acción."))return;
	if(checkNselect(f.id_responsable,"Seleccione el responsable del plan de acción."))return;
	if(f.id_formacion_categoria[f.id_formacion_categoria.selectedIndex].value!="none"){
		if(checkNselect(f.id_formacion_subcategoria,"Seleccione la subcategoría de la necesidad de formación."))return;
		if(checkNselect(f.id_formacion_tipo,"Seleccione el tipo de la necesidad de formación."))return;
		if(checkVacio(f.formacion_detalle,"Ingrese el detalle de la necesidad de formación."))return;
	}
	f.submit();
	verProcesando();
}
function checkFormacionCategoria(f){
	if(checkVacio(f.nombre,"Ingrese el nombre de la categoría de formación."))return;
	f.submit();
	verProcesando();
}
function checkFormacionSubcategoria(f){
	if(checkNselect(f.id_formacion_categoria,"Seleccione la categoría de formación."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre de la subcategoría de formación."))return;
	f.submit();
	verProcesando();
}
function checkFormacionTipo(f){
	if(checkNselect(f.id_formacion_subcategoria,"Seleccione la subcategoría de formación."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre del tipo específico formación."))return;
	f.submit();
	verProcesando();
}
function checkConcejoSabiduria(f){
	if(checkVacio(f.items_bajos,"Ingrese los ítems bajos tratados en el concejo de sabiduría."))return;
	if(checkVacio(f.situacion_desencadenante,"Ingrese la(s) situacion(es) desencadenantes de los ítems bajos."))return;
	if(checkVacio(f.plan_accion_sugerido,"Ingrese un plan de acción sugerido para mejorar los ítems bajos."))return;
	if(checkVacio(f.obs,"Ingrese las observaciones del caso."))return;
	if(checkVacio(f.data_file,"Seleccione correctamente el archivo de informe del concejo realizado."))return;
	f.submit();
	verProcesando();
}
function checkEvaluacionSCV(f){
	if(checkNselect(f.eval_objetivos,"Seleccione el % de cumplimiento de objetivos para la persona seleccionada."))return;
	f.submit();
	verProcesando();
}
function compararFechas(fin, ini){
	var f=fin.split("-");
	var i=ini.split("-");
	if(parseInt(f[1])<10) f[1]=parseInt(f[1].replace("0",""));
	if(parseInt(f[2])<10) f[2]=parseInt(f[2].replace("0",""));
	if(parseInt(i[1])<10) i[1]=parseInt(i[1].replace("0",""));
	if(parseInt(i[2])<10) i[2]=parseInt(i[2].replace("0",""));
	if (parseInt(f[0])>parseInt(i[0])) com=true;
	else if (parseInt(f[0])<parseInt(i[0])) com=false;
	else if (parseInt(f[1])>parseInt(i[1])) com=true;
	else if (parseInt(f[1])<parseInt(i[1])) com=false;
	else if (parseInt(f[2])>parseInt(i[2])) com=true;
	else if (parseInt(f[2])<parseInt(i[2])) com=false;
	else com=true;
	return com;
} 
function activarPlanesAccion(id_funcionario){
	if(id_funcionario!="none"){
		top.dbox_0.contenido.plan_accion.location='listas.php?data=plan_accion&id_funcionario='+id_funcionario;
		top.dbox_0.contenido.fortalecer_competencia.disabled=false;
		top.dbox_0.contenido.necesidad_formacion.disabled=false;
	} else {
		top.dbox_0.contenido.plan_accion.location='listas.php?data=plan_accion&id_funcionario=0';
		top.dbox_0.contenido.fortalecer_competencia.disabled=true;
		top.dbox_0.contenido.necesidad_formacion.disabled=true;
	}
}
function checkEvalIndEvaluacion(evaluacion, f){
	switch(evaluacion){
		case "Objetivos":
			f.anio_ini.disabled=f.anio_fin.disabled=false;
			f.anio_ini.focus();
			break;
		case "Competencias":
			f.anio_ini.disabled=f.anio_fin.disabled=true;
			break;
		default: break;
	}
}
function checkImportarCompetencia(f){
	if(checkVacio(f.data_file,"Seleccione correctamente el archivo de resultados de competencias."))return;
	f.submit();
	f.aceptar.value="Cargando...";
	f.aceptar.disabled=true;
	verProcesando();
}
function habilitarConfiguracion1(consolidado, f){
	if(consolidado.checked==true){
		f.id_unidad_negocio.disabled=true;
		f.id_seccion.disabled=true;
		f.id_cargo.disabled=true;
		f.id_competencia_propia.disabled=true;
	} else {
		f.id_unidad_negocio.disabled=false;
		f.id_seccion.disabled=true;
		f.id_cargo.disabled=false;
		f.id_competencia_propia.disabled=true;
		f.id_competencia_tipo.focus();
	}
}
function checkReporteConsolidadoConfiguracion(f){
	if(checkNselect(f.id_unidad_negocio,"Seleccione la unidad de negocio."))return;
	f.submit();
	verProcesando();
}

function checkReporeConfiguracion(f){
	if(checkNselect(f.id_anio,"Seleccione el año para elaborar el reporte."))return;
	if(f.fecha_ingreso_ini.value!="") {
		if(checkNdate(f.fecha_ingreso_ini,"Ingrese correctamente la fecha inicial de ingreso para elaborar el reporte."))return;
		if(checkNdate(f.fecha_ingreso_fin,"Ingrese correctamente la fecha final de ingreso para elaborar el reporte."))return;
	}
	if(f.fecha_nacimiento_ini.value!="") {
		if(checkNdate(f.fecha_nacimiento_ini,"Ingrese correctamente la fecha inicial de nacimiento para elaborar el reporte."))return;
		if(checkNdate(f.fecha_nacimiento_fin,"Ingrese correctamente la fecha final de nacimiento para elaborar el reporte."))return;
	}
	if(f.edad_ini.options[f.edad_ini.selectedIndex].value!="none") {
		if(checkNselect(f.edad_fin,"Seleccione el límite de edad para elaborar el reporte."))return;
		if(parseInt(f.edad_ini.options[f.edad_ini.selectedIndex].value)>parseInt(f.edad_fin.options[f.edad_fin.selectedIndex].value)){
			alert("El límite mínimo de edad no debe ser mayor al límite máximo. Verifique los valores ingresados");
			f.edad_fin.focus();
			return;
		}
	}
	if(f.antiguedad_ini.options[f.antiguedad_ini.selectedIndex].value!="none") {
		if(checkNselect(f.antiguedad_fin,"Seleccione el límite de antigüedad para elaborar el reporte."))return;
		if(parseInt(f.antiguedad_ini.options[f.antiguedad_ini.selectedIndex].value)>parseInt(f.antiguedad_fin.options[f.antiguedad_fin.selectedIndex].value)){
			alert("El límite mínimo de antigüedad no debe ser mayor al límite máximo. Verifique los valores ingresados");
			f.antiguedad_fin.focus();
			return;
		}
	}
	f.submit();
	verProcesando();
}
function checkReporteExpInd(f){
	if(checkNselect(f.id_unidad_negocio,"Seleccione la unidad de negocio a la que pertenece el colaborador buscado."))return;
	if(checkNselect(f.id_seccion,"Seleccione la sección  a la que pertenece el colaborador buscado."))return;
	if(checkNselect(f.id_funcionario,"Seleccione el colaborador."))return;
	if(checkNselect(f.evaluacion,"Seleccione la evaluación a consultar."))return;
	if(f.evaluacion[f.evaluacion.selectedIndex].value=="Objetivos"){
		if(checkNselect(f.anio_ini,"Seleccione el año inicial de la consulta."))return;
		if(checkNselect(f.anio_fin,"Seleccione el año final de la consulta."))return;
		top.dbox_0.contenido.reporte.location='listas.php?data=reporte_exp_ind&id_funcionario='+f.id_funcionario.options[f.id_funcionario.selectedIndex].value+'&id_unidad_negocio='+f.id_unidad_negocio.options[f.id_unidad_negocio.selectedIndex].value+'&id_seccion='+f.id_seccion.options[f.id_seccion.selectedIndex].value+'&ini='+f.anio_ini.options[f.anio_ini.selectedIndex].value+'&fin='+f.anio_fin.options[f.anio_fin.selectedIndex].value;
	}
	if(f.evaluacion[f.evaluacion.selectedIndex].value=="Competencias"){
		top.arreglos.location.href="arreglos.php?p=evaluacion_individual_competencia&id_funcionario="+f.id_funcionario[f.id_funcionario.selectedIndex].value;
	}
}
function checkReporteCapacitacion(f){
	if(checkNselect(f.consulta,"Seleccione la variable a consultar."))return;
	if(checkNselect(f.id_unidad_negocio,"Seleccione la unidad de negocio."))return;
	if(checkNselect(f.anio_ini,"Seleccione el año inicial de la consulta."))return;
	if(checkNselect(f.anio_fin,"Seleccione el año final de la consulta."))return;
	top.dbox_0.contenido.reporte.location='listas.php?data=reporte_capacitacion&consulta='+f.consulta.options[f.consulta.selectedIndex].value+'&id_unidad_negocio='+f.id_unidad_negocio.options[f.id_unidad_negocio.selectedIndex].value+'&id_seccion='+f.id_seccion.options[f.id_seccion.selectedIndex].value+'&ini='+f.anio_ini.options[f.anio_ini.selectedIndex].value+'&fin='+f.anio_fin.options[f.anio_fin.selectedIndex].value;
}
function verificarAnios(ini, fin){
	i=parseInt(fin.options[ini.selectedIndex].value);
	f=parseInt(fin.options[fin.selectedIndex].value);
	if(i!='none' && f!='none' && i<f){
		alert('El año final no puede er menor al año inicial. Por favor, verifique los años seleciconados'); 
		ini.focus();
		return;
	}
}
function checkSeguimiento(f){
	if(checkNdate(f.fecha_real,"Ingrese correctamente la fecha de ejecución del seguimiento."))return;
	if(checkVacio(f.seguimiento,"Ingrese el resultado observado en el seguimiento."))return;
	if(checkNselect(f.estado,"Seleccione un estado de ejecución del seguimiento."))return;
	f.submit();
	verProcesando();
}
function checkPlanAccionFormacion(f){
	if(checkVacio(f.necesidad_1,"Ingrese al menos una necesidad de capacitación o de entrenamiento para el colaborador seleccionado."))return;
	if(checkVacio(f.fortaleza,"Ingrese las fortalezas a lograr mediante el cumplimiento de la necesidad planteada."))return;
	if(checkVacio(f.oportunidad_mejora,"Ingrese las oportunidades de mejorar en el cumplimiento de la necesidad planteada."))return;
	f.submit();
	verProcesando();
}
function checkPlanAccionSeguimiento(f, max_meses_seguimiento){
	if(checkNdate(f.fecha_prog,"Ingrese correctamente la fecha de seguimiento."))return;
	cero="0";
	en_cuantos_meses=max_meses_seguimiento;
	now=new Date();
	anio=now.getFullYear();
	mes=now.getMonth()+1;
	dia=now.getDate();
	if (mes<10) mes=cero.concat(mes);
	if (dia<10) dia=cero.concat(dia);
	hoy=anio+"-"+mes+"-"+dia;
	var fh=hoy.split("-");
	if(parseInt(fh[1])<10) fh[1]=parseInt(fh[1].replace("0",""));
	m_max=parseInt(fh[1])+en_cuantos_meses;
	if(m_max>12){
		m_max=m_max-12;
		a_max=parseInt(fh[0])+1;
	} else {
		a_max=fh[0];
	}
	d_max=fh[2];
	max=a_max+"-"+m_max+"-"+d_max;
	if(compararFechas(max, f.fecha_prog.value)==false){
		alert("El seguimiento debe programarse en una fecha dentro de los siguientes "+en_cuantos_meses+" meses apartir de hoy, por lo tanto no puede pasar del "+max+".");
		f.fecha_prog.focus();
		return;
	}
	
	if(checkVacio(f.obs,"Ingrese las observaciones de ejecución del seguimiento."))return;
	if(checkNselect(f.id_responsable,"Seleccione el responsable del seguimiento."))return;
	f.submit();
	verProcesando();
}
function checkPlanAccionCompetencia(f){
	if(checkNselect(f.id_competencia,"Seleccione la competencia a fortalecer."))return;
	if(checkVacio(f.accion,"Ingrese la acción de fortalecimiento de la competencia."))return;
	f.submit();
	verProcesando();
}
function checkEvaluacion(f, pasa, enviar){
	for(i=0; i<f.elements.length; i++){
		var c=f.elements[i];
		if(c.name.indexOf("objetivo_")>-1) if(checkNselect(c,"Seleccione la calificación para el objetivo."))return;
		if(c.name.indexOf("experticia_")>-1) if(checkNselect(c,"Seleccione la respuesta para la pregunta de experticia."))return;
	}
	calcularEvalObjetivos(f, pasa)
	calcularEvalExperticia(f, pasa)
	if(enviar==true){
		f.eval_objetivos.disabled=false;
		f.submit();
		verProcesando();
	}
}
function calcularEvalExperticia(f, pasa){
	f.acumulado.value=0;
	for(i=0; i<f.elements.length; i++){
		var c=f.elements[i];
		if(c.name.indexOf("experticia_")>-1){
			if(c[c.selectedIndex].value=="none") f.acumulado.value=parseInt(f.acumulado.value)+0;
			if(c[c.selectedIndex].value=="No") f.acumulado.value=parseInt(f.acumulado.value)+0;
			if(c[c.selectedIndex].value=="Si") f.acumulado.value=parseInt(f.acumulado.value)+100;
		}
	}
	f.eval_experticia.value=formatearPorcentaje(parseInt(f.acumulado.value)/parseInt(f.cantidad_preguntas_experticia.value));
	if(parseInt(f.eval_experticia.value)<pasa) f.eval_experticia.style.color='red'; else f.eval_experticia.style.color='green';
	calcularEvalTotal(f, pasa);
}
function calcularEvalObjetivos(f, pasa){
	f.acumulado.value=0;
	scv=true;
	for(i=0; i<f.elements.length; i++){
		var c=f.elements[i];
		if(c.name.indexOf("objetivo_")>-1){
			scv=false;
			if(!isNaN(parseInt(c[c.selectedIndex].value))){
				f.acumulado.value=parseInt(f.acumulado.value)+parseInt(c[c.selectedIndex].value);
			}
		}
	}
	if(scv==false) {
		f.eval_objetivos.value=formatearPorcentaje(parseInt(f.acumulado.value)/parseInt(f.cantidad_objetivos.value));
		if(parseInt(f.eval_objetivos.value)<pasa) f.eval_objetivos.style.color='red'; else f.eval_objetivos.style.color='green';
	}
	calcularEvalTotal(f, pasa);
}
function calcularEvalTotal(f, pasa){
	f.total.value=formatearPorcentaje((parseFloat(f.eval_objetivos.value)+parseFloat(f.eval_competencia.value)+parseFloat(f.eval_experticia.value))/3);
	if(parseInt(f.total.value)<pasa) f.total.style.color='red'; else f.total.style.color='green';
}
function checkImportarArchivo(f){
	if(checkNselect(f.id_evaluacion,"Seleccione el periodo de evaluación para el registro del archivo."))return;
	if(checkVacio(f.data_file,"Seleccione la ruta del archivo respectivo."))return;
	f.submit();
	verProcesando();
}
function checkVariableTipoResultante(f){
	if(checkVacio(f.nombre,"Ingrese un nombre para el tipo de variable resultante."))return;
	if(checkNselect(f.peso,"Seleccione un peso porcentual para el tipo de variable resultante."))return;
	f.submit();
	verProcesando();
}
function checkVariableResultante(f){
	if(checkNselect(f.id_variable_tipo_resultante,"Seleccione un tipo de variable resultante."))return;
	if(checkVacio(f.nombre,"Ingrese un nombre para la variable resultante."))return;
	if(checkNselect(f.peso,"Seleccione un peso porcentual para la variable resultante."))return;
	if(checkNselect(f.umbral,"Seleccione el umbral de paso para la variable resultante."))return;
	f.submit();
	verProcesando();
}
function checkVariablePreguntaResultante(f){
	if(checkVacio(f.id_evaluacion,"ERROR: el sistema no logró capturar la evalaucion."))return;
	if(checkVacio(f.id_variable_resultante,"ERROR: el sistema no logró capturar la variable resultante."))return;
	if(checkVacio(f.id_variable_pregunta,"Seleccione una de las preguntas para asignarla a la variable resultante."))return;
	f.submit();
	verProcesando();
}
function checkImportarObjetivos(f){
	if(checkNselect(f.id_anio,"Seleccione el año de los objetivos a registrar."))return;
	if(checkVacio(f.data_file,"Seleccione la ruta del archivo específico de objetivos a evaluar para el año seleccionado."))return;
	f.submit();
	verProcesando();
}
function checkEvaluacionPeriodo(f){
	if(checkVacio(f.periodo,"Ingrese el período que corresponde a la presente evaluación."))return;
	if(checkNselect(f.brecha_tolerable,"Seleccione el valor de brecha tolerable para el presente período de evaluación."))return;
	if(checkVacio(f.data_file,"Seleccione el archivo específico de datos de evaluación de clima."))return;
	if(checkVacio(f.jefe_file,"Seleccione el archivo de jefes para la evaluación de clima."))return;
	if(checkVacio(f.portada_file,"Seleccione el archivo HTML de portada de los informes a generar en la evaluación."))return;
	f.submit();
	verProcesando();
}
function elaborarRangos(f){
	if(checkNan(f.tope,"Ingrese el número tope de la escala de medición."))return;
	if(f.tope.value<=1){alert('El tope de la escala debe ser mayor a 1.'); f.num_rangos.value=''; f.tope.select(); return;}
	if(checkNan(f.num_rangos,"Ingrese el número de rangos de la escala de medición."))return;
	if(parseInt(f.num_rangos.value)<=1){alert('El número de rangos de la escala debe ser mayor a 1.'); f.num_rangos.select(); return;}
	if(parseInt(f.num_rangos.value) > parseInt(f.tope.value)) {alert('El número de rangos no debe ser mayor al tope.'); f.num_rangos.select(); return;}

	colores=new Array("#A60000","#FF0000","#FF8400","#FFFF00","#B6FF00","#00D400","#1FA777","#7FAFFF","#0060FF","#8200FF","none");
	str="<table width=100% border=0 cellspacing=0><tr bgcolor=Highlight style='color: CaptionText; font-weight: bold;'><td align=center>No.</td><td align=center>Nombre</td><td align=center>Descripción</td><td align=center>Lim Inf</td><td align=center>Lim Sup</td><td align=center>Color</td></tr>";
	for(i=1; i<parseInt(f.num_rangos.value)+1; i++){
		str+="<tr>";
		str+="<td align=center>"+i+"</td>";
		str+="<td><input type=text name=nombre_"+i+" value='' class=text onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 100px;'></td>";
		str+="<td><input type=text name=descripcion_"+i+" value='' class=text onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 150px;'></td>";
		str+="<td>de <input type=text name=lim_inferior_"+i+" value='' class=num onKeyUp='validarLimiteRango(this, "+i+", "+f.tope.value+");' onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 30px;'></td>";
		str+="<td>a <input type=text name=lim_superior_"+i+" value='' class=num onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 30px;' disabled></td>";
		str+="<td><select name=color_"+i+" class=select onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 50px;'>";
		for(j=colores.length-1; j>-1; j--){
			str+="<option value="+colores[j]+" style='background-color:"+colores[j]+";'></option>";
		}
		str+="</select></td>";
		str+="</tr>";
	}
	str+="</table>";
	top.dbox_1.contenido.document.getElementById('rangos').innerHTML=str;
	top.dbox_1.contenido.escala_medicion.lim_superior_1.value=f.tope.value;
	top.dbox_1.contenido.escala_medicion.lim_superior_1.disabled=true;
	eval("top.dbox_1.contenido.escala_medicion.lim_inferior_"+f.num_rangos.value+".value=1");
	eval("top.dbox_1.contenido.escala_medicion.lim_inferior_"+f.num_rangos.value+".disabled=true");
	top.dbox_1.contenido.escala_medicion.tope.disabled=true;
	top.dbox_1.contenido.escala_medicion.num_rangos.disabled=true;
	top.dbox_1.contenido.escala_medicion.nombre_1.focus();
}
function validarLimiteRango(actual, i, tope){
	if(checkNan(actual,"Ingrese el número para el límite inferior del rango."))return;
	if(parseInt(actual.value)>=tope){
		alert('El valor del límite inferior debe ser menor al valor del tope de la escala.');
		actual.select(); 
		return
	}
	if(i>1){
		lim_inf_anterior=parseInt(eval("top.dbox_1.contenido.escala_medicion.lim_inferior_"+(i-1)+".value"));
		if(parseInt(actual.value)>=lim_inf_anterior && lim_inf_anterior!=null && lim_inf_anterior!=undefined){
			alert('El valor del límite inferior actual debe ser menor al valor del límite inferior del rango superior ('+lim_inf_anterior+').'); 
			actual.select(); 
			return
		}
		lim_inf_siguiente=parseInt(eval("top.dbox_1.contenido.escala_medicion.lim_inferior_"+(i+1)+".value"));
		if(lim_inf_siguiente>0 && !(parseInt(actual.value)>lim_inf_siguiente && parseInt(actual.value)<lim_inf_anterior)){
			alert('El valor del límite inferior del actual rango debe estar entre '+lim_inf_anterior+' y '+lim_inf_siguiente);
			actual.select(); 
			return
		}
	}
	eval("top.dbox_1.contenido.escala_medicion.lim_superior_"+(i+1)+".value="+actual.value);
}
function checkEscalaMedicion(f){
	for(i=1; i<parseInt(f.num_rangos.value)+1; i++){
		if(checkVacio(eval("f.nombre_"+i),"Ingrese el nombre del rango # "+i+"."))return;
		if(checkVacio(eval("f.descripcion_"+i),"Ingrese la descripción del rango # "+i+"."))return;
		if(checkNan(eval("f.lim_inferior_"+i),"Ingrese el número para el límite inferior del rango # "+i+"."))return;
		if(checkNan(eval("f.lim_superior_"+i),"Ingrese el número para el límite superior del rango # "+i+"."))return;
		if(checkNselect(eval("f.color_"+i),"Seleccione el color que representa el rango # "+i+"."))return;
	}
	f.tope.disabled=false;
	f.num_rangos.disabled=false;
	for(i=1; i<parseInt(f.num_rangos.value)+1; i++){
		eval("f.lim_inferior_"+i+".disabled=false");
		eval("f.lim_superior_"+i+".disabled=false");
	}
	f.submit();
	verProcesando();
}
function elaborarRangosResultados(f){
	if(checkNan(f.num_rangos,"Ingrese el número de rangos de la escala de medición."))return;
	if(parseInt(f.num_rangos.value)<=1){alert('El número de rangos de la escala debe ser mayor a 1.'); f.num_rangos.select(); return;}
	if(parseInt(f.num_rangos.value)>10){alert('El número de rangos no debe ser mayor a 10.'); f.num_rangos.select(); return;}
	colores=new Array("#A60000","#FF0000","#FF8400","#FFFF00","#B6FF00","#00D400","#1FA777","#7FAFFF","#0060FF","#8200FF","none");
	str="<table width=100% border=0 cellspacing=0><tr bgcolor=Highlight style='color: CaptionText; font-weight: bold;'><td align=center>No.</td><td align=center>Nombre</td><td align=center>Descripción</td><td align=center>Lim Inf</td><td align=center>Lim Sup</td><td align=center>Color</td></tr>";
	for(i=1; i<parseInt(f.num_rangos.value)+1; i++){
		str+="<tr>";
		str+="<td align=center>"+i+"</td>";
		str+="<td><input type=text name=nombre_"+i+" value='' class=text onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 100px;'></td>";
		str+="<td><input type=text name=descripcion_"+i+" value='' class=text onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 150px;'></td>";
		str+="<td>de <select name=lim_inferior_"+i+" class=select onChange='validarLimiteRangoResultados(this, "+i+");' onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 50px;'>";
		for(j=100; j>-1; j=j-5){
			str+="<option value="+j+">"+j+"</option>";
		}
		str+="</select></td>";
		str+="<td>a <select name=lim_superior_"+i+" class=select onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 50px;' disabled>";
		for(j=100; j>-1; j=j-5){
			str+="<option value="+j+">"+j+"</option>";
		}
		str+="</select></td>";
		str+="<td><select name=color_"+i+" class=select onFocus='enfocarCampo(this,true)' onBlur='enfocarCampo(this,false)' style='width: 50px;'>";
		for(j=colores.length-1; j>-1; j--){
			str+="<option value="+colores[j]+" style='background-color:"+colores[j]+";'></option>";
		}
		str+="</select></td>";
		str+="</tr>";
	}
	str+="</table>";
	top.dbox_1.contenido.document.getElementById('rangos').innerHTML=str;
	setOption(top.dbox_1.contenido.escala_resultados.lim_superior_1, 100);
	setOption(top.dbox_1.contenido.escala_resultados.lim_inferior_1, 0);
	eval("setOption(top.dbox_1.contenido.escala_resultados.lim_inferior_"+f.num_rangos.value+", 0)");
	eval("top.dbox_1.contenido.escala_resultados.lim_inferior_"+f.num_rangos.value+".disabled=true");
	top.dbox_1.contenido.escala_resultados.num_rangos.disabled=true;
	top.dbox_1.contenido.escala_resultados.nombre_1.focus();
}
function validarLimiteRangoResultados(actual, i){
	if(checkNselect(actual,"Seleccione el número para el límite inferior del rango."))return;
	if(parseInt(actual[actual.selectedIndex].value)>=100){
		alert('El valor del límite inferior debe ser menor al valor 100%, que es el tope de la escala.');
		actual.select(); 
		return
	}
	if(i>1){
		lim_inf_anterior=parseInt(eval("top.dbox_1.contenido.escala_resultados.lim_inferior_"+(i-1)+"[escala_resultados.lim_inferior_"+(i-1)+".selectedIndex].value"));
		if(parseInt(actual.value)>=lim_inf_anterior && lim_inf_anterior!=0){
			alert('El valor del límite inferior actual debe ser menor al valor del límite inferior del rango superior ('+lim_inf_anterior+').'); 
			actual.select(); 
			return
		}
		lim_inf_siguiente=parseInt(eval("top.dbox_1.contenido.escala_resultados.lim_inferior_"+(i+1)+"[escala_resultados.lim_inferior_"+(i+1)+".selectedIndex].value"));
		if(lim_inf_siguiente<100 && !(parseInt(actual.value)>lim_inf_siguiente && parseInt(actual.value)<lim_inf_anterior)){
			alert('El valor del límite inferior del actual rango debe estar entre '+lim_inf_anterior+' y '+lim_inf_siguiente);
			actual.select(); 
			return
		}
	}
	eval("setOption(top.dbox_1.contenido.escala_resultados.lim_superior_"+(i+1)+", "+actual[actual.selectedIndex].value+")");
}
function checkEscalaResultados(f){
	for(i=1; i<parseInt(f.num_rangos.value)+1; i++){
		if(checkVacio(eval("f.nombre_"+i),"Ingrese el nombre del rango # "+i+"."))return;
		if(checkVacio(eval("f.descripcion_"+i),"Ingrese la descripción del rango # "+i+"."))return;
		if(checkNselect(eval("f.lim_inferior_"+i),"Ingrese el número para el límite inferior del rango # "+i+"."))return;
		if(checkNselect(eval("f.lim_superior_"+i),"Ingrese el número para el límite superior del rango # "+i+"."))return;
		if(checkNselect(eval("f.color_"+i),"Seleccione el color que representa el rango # "+i+"."))return;
	}
	f.tope.disabled=false;
	f.num_rangos.disabled=false;
	for(i=1; i<parseInt(f.num_rangos.value)+1; i++){
		eval("f.lim_inferior_"+i+".disabled=false");
		eval("f.lim_superior_"+i+".disabled=false");
	}
	f.submit();
	verProcesando();
}
function checkPrepararInformes(f){
	if(checkNselect(f.minima_unidad,"Seleccione la mínima unidad estructural de la empresa para la elaboración de informes."))return;
	if(checkNselect(f.min_cnt_evaluados,"Seleccione la mínima cantidad de evaluaciones para la realización de informes por unidad estructural de la empresa."))return;
	if(checkNselect(f.top_destacado,"Seleccione la cantidad de ítems destacados a presentar en los informes de resultados."))return;
	f.resultados_acumulativos.value=f.resultados_acumulativos.checked?'t':'f';
	f.informes_sobre_parciales.value=f.informes_sobre_parciales.checked?'t':'f';
	f.submit();
	verProcesando();
}
function checkInformeClima(f){
	if(checkNselect(f.id_evaluacion,"Seleccione el período del cual desea elaborar los informes de resultados de la evaluación de clima."))return;
	if(checkNselect(f.parametro,"Seleccione el parametro que consolida la información de los resultados."))return;
	f.submit();
	verProcesando();
}
function checkInformeClimaTodos(f){
	if(checkNselect(f.id_evaluacion,"Seleccione el período del cual desea elaborar los informes de resultados de la evaluaición de clima."))return;
	f.submit();
	verProcesando();
}
function checkInformeClimaAgrupado(f){
	if(checkNselect(f.id_evaluacion,"Seleccione el período del cual desea elaborar los informes de resultados de la evaluación de clima."))return;
	if(checkVacio(f.filtro,"Seleccione al menos un demográfico para la generación del informe."))return;
	if(f.ruta_informe.value!=""){
		if(confirm('El informe solicitado ya se ha generado previamente. \n\n¿Desea ver el informe previamente creado?\nHaga clic en ACEPTAR para ver informe ya generado o en CANCELAR para generarlo de nuevo')){
			window.open(f.ruta_informe.value, 'informe_individual', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=1024, height=710,top=0, left=0');
		} else {
			f.submit();
			verProcesando();
		}
	} else {
		f.submit();
		verProcesando();
	}
}


























var retefuente_porcen_original;
function aplicarRetencion(v,f){
	switch(v){
		case "SI":
			f.retefuente_porcen.value=retefuente_porcen_original;
			f.retefuente_porcen.disabled=true;
			break;
		case "NO":
			f.retefuente_porcen.value="0";
			f.retefuente_porcen.disabled=true;
			break;
		case "Cambiar %":
			f.retefuente_porcen.disabled=false;
			f.retefuente_porcen.focus();
			break;
		default: break;
	}
	calcularTotalOrdenCompra(f);
}
var iva_original;
function aplicarIVA(v,f){
	if(v==true){
		f.iva.value=iva_original;
	}else{
		f.iva.value="0";
	}
	calcularTotalOrdenCompra(f);
}
function calcularTotalOrdenCompra(f){
	f.iva.value=limpiarCC(f.iva.value);
	f.subtotal.value=limpiarCC(f.subtotal.value);
	f.iva.value=parseInt(f.iva.value);
	f.retefuente_valor.value=parseInt(parseFloat(f.retefuente_porcen.value)*parseInt(f.subtotal.value)/100);
	f.total.value=parseInt(parseFloat(parseInt(f.subtotal.value)-parseFloat(f.retefuente_valor.value))+parseFloat(f.iva.value));
	f.subtotal.value=formatearEntero('$',f.subtotal.value);
	f.retefuente_valor.value=formatearEntero('$',f.retefuente_valor.value);
	f.iva.value=formatearEntero('$',f.iva.value);
	f.total.value=formatearEntero('$',f.total.value);
}
function checkBodega(f) {
	if(checkVacio(f.nombre,"Ingrese correctamente el nombre de la bodega."))return;
	if(checkNselect(f.id_ciudad,"Seleccione la ciudad donde se ubica la bodega."))return;
	if(checkVacio(f.direccion,"Ingrese correctamente la dirección de la bodega."))return;
	if(checkVacio(f.descripcion,"Ingrese correctamente la descripción de la bodega."))return;
	f.submit();
}
function checkUbicacion(f) {
	if(checkNselect(f.id_bodega,"Seleccione la bodega."))return;
	if(checkVacio(f.nombre,"Ingrese correctamente el nombre de la ubicación en bodega."))return;
	f.submit();
}
function checkArea(f) {
	if(checkNselect(f.id_empresa,"Seleccione la empresa."))return;
	if(checkVacio(f.nombre,"Ingrese correctamente el nombre del área."))return;
	if(checkNselect(f.encargado,"Seleccione el encargado del área."))return;
	f.submit();
}
function checkFamilia(f) {
	if(checkVacio(f.nombre,"Ingrese correctamente el nombre de la familia de productos de inventario."))return;
	f.submit();
}
function checkCategoria(f) {
	if(checkNselect(f.id_familia,"Seleccione familia de productos a la que pertence la categoría a ingresar."))return;
	if(checkVacio(f.nombre,"Ingrese correctamente el nombre de la categoría de productos de inventario."))return;
	f.submit();
}
function checkProducto(f) {
	if(checkNselect(f.id_familia,"Seleccione la familia del producto."))return;
	if(checkNselect(f.id_categoria,"Seleccione la categoria del producto."))return;
	if(checkVacio(f.nombre,"Ingrese correctamente el nombre del producto."))return;
	if(checkNselect(f.id_ubicacion,"Seleccione la bodega y ubicación del producto."))return;
	if(checkNselect(f.id_medida,"Seleccione la medida del producto."))return;
	f.consumible.value=f.consumible.checked?'t':'f';
	f.existencia.value=limpiarCC(f.existencia.value);
	if(checkVacio(f.existencia,"Ingrese un número entero de existencias del producto, al menos 0."))return;
	if(f.iva!=null) if(checkNan(f.iva,"Ingrese el IVA aplicable al ítem de inventario."))return;
	f.submit();
}
function cargarCategorias(f, c) {
	c.disabled=false;
	c.options.length = 0;
	c.selectedIndex = -1;
	c.options[0] = new Option('Seleccione uno...', 'none');
	top.arreglos.location.href="arreglos.php?p=categoria&id="+f.options[f.selectedIndex].value;
}
function checkProveedor(f){
	if(checkNselect(f.id_regimen_tributario,"Seleccione el régimen tributario del proveedor."))return;
	if(checkNselect(f.id_ciudad,"Seleccione la ciudad del proveedor."))return;
	if(checkVacio(f.nombre,"Ingrese el (los) nombre(s) del proveedor."))return;
	f.nit.value=limpiarCC(f.nit.value);
	if(checkVacio(f.nit,"Ingrese el NIT del proveedor."))return;
	if(checkVacio(f.contacto,"Ingrese el nombre del contacto del proveedor."))return;
	if(checkVacio(f.retencion,"Ingrese la retención en % que e le aplica al proveedor."))return;
	if(f.retencion.value!="") f.retencion.value=limpiarDecimal(f.retencion.value);
	if(checkVacio(f.dir_oficina,"Ingrese la dirección de la oficina del proveedor."))return;
	if(checkVacio(f.tel_oficina1,"Ingrese el teléfono principal de la oficina del proveedor."))return;
	if(f.e_mail.value!="") if(checkNmail(f.e_mail,"Ingrese correctamente el email del proveedor."))return;
	f.activo.value=f.activo.checked?'t':'f';
	f.submit();
}
function crearFiltro(actual, f){
	str="";
	for(i=0; i<f.elements.length; i++){
		if(f.elements[i].name==actual.name){
			for(j=i+1; j<f.elements.length; j++){
				if(f.elements[j].name.indexOf("id_param")>-1){
					f.elements[j].selectedIndex=0;
					f.elements[j].disabled=true;
				}
			}
		}
	}
	for(i=0; i<f.elements.length; i++){
		if(f.elements[i].name.indexOf("id_param")>-1 && f.elements[i].disabled==false && f.elements[i][f.elements[i].selectedIndex].value!="none"){
			str+=" AND "+f.elements[i].name+"="+f.elements[i][f.elements[i].selectedIndex].value;
		}
	}
	return str;
}
function cargarDatos2(data,ini,campo,fin,extra) {
	switch(campo) {
		case "select":
			fin.disabled=false;
			fin.options.length = 0;
			fin.selectedIndex = -1;
			fin.options[0] = new Option('Cargando...', 'none');
			break;
		case "text":
			disabled_old=fin.disabled;
			fin.disabled=false;
			fin.value="Cargando...";
			fin.disabled=disabled_old;
			break;
		default: break;
	}
	top.arreglos.location.href="arreglos.php?p="+data+"&"+extra+"&id="+ini.options[ini.selectedIndex].value;
}
function cargarDatos(data,ini,campo,fin) {
	switch(campo) {
		case "select":
			fin.disabled=false;
			fin.options.length = 0;
			fin.selectedIndex = -1;
			fin.options[0] = new Option('Cargando...', 'none');
			break;
		case "text":
			disabled_old=fin.disabled;
			fin.disabled=false;
			fin.value="Cargando...";
			fin.disabled=disabled_old;
			break;
		default: break;
	}
	top.arreglos.location.href="arreglos.php?p="+data+"&id="+ini.options[ini.selectedIndex].value;
}
function cargarRotacion(data,ini,campo,fin,f_ini,f_fin) {
	switch(campo) {
		case "select":
			fin.disabled=false;
			fin.options.length = 0;
			fin.selectedIndex = -1;
			fin.options[0] = new Option('Seleccione uno...', 'none');
			break;
		case "text":
			disabled_old=fin.disabled;
			fin.disabled=false;
			fin.value="Cargando...";
			fin.disabled=disabled_old;
			break;
		default: break;
	}
	document.rotacion.entrada.value="Cargando...";document.rotacion.entrada.disabled=true;
	document.rotacion.salida.value="Cargando...";document.rotacion.salida.disabled=true;
	document.rotacion.devolucion.value="Cargando...";document.rotacion.devolucion.disabled=true;
	top.arreglos.location.href="arreglos.php?p="+data+"&id="+ini.options[ini.selectedIndex].value+"&f_ini="+f_ini+"&f_fin="+f_fin;
}
function cargarOrdenesCompra(id_producto) {
	top.dbox_0.contenido.ordenes_compra.location.href="listas.php?data=top20_orden_compra_rotacion&id_producto="+id_producto;
}
function cargarOrdenesCompraProveedor(id_proveedor) {
	top.dbox_0.contenido.ordenes_compra.location.href="listas.php?data=top20_orden_compra_proveedor&id_proveedor="+id_proveedor;
}
function cargarOrdenesCompraProyecto(proyecto) {
	top.dbox_0.contenido.ordenes_compra.location.href="listas.php?data=orden_compra_proyecto&proyecto="+proyecto;
}
function checkRequisicion(f, method) {
	if(checkNdate(f.fecha_registro,"Ingrese correctamente la fecha de registro de la requisición."))return;
	if(checkNdate(f.fecha_ent_prog,"Ingrese correctamente la fecha de entrega programada de la requisición."))return;
	if(checkNselect(f.id_area,"Seleccione el área solicitante de la requisición."))return;
	if(checkNselect(f.solicitante,"Seleccione el solicitante de la requisición."))return;
	if(checkNselect(f.id_proveedor,"Seleccione el proveedor para la requisición."))return;
	if(f.contacto!=null) if(checkVacio(f.contacto,"Ingrese el nombre del contacto del proveedor."))return;
	if(checkNselect(f.id_autoriza,"Seleccione el jefe de área que autoriza la requisición."))return;
	f.solicitante.disabled=false;
	f.fecha_registro.disabled=false;
	if(f.subtotal!=null) f.subtotal.disabled=false;
	if(f.retefuente_porcen!=null) f.retefuente_porcen.disabled=false;
	if(f.retefuente_valor!=null) f.retefuente_valor.disabled=false;
	if(f.iva!=null) f.iva.disabled=false;
	if(f.total!=null) f.total.disabled=false;
	switch(method) {
		case "get":
			top.arreglos.location.href="proc.php?opcion=requisicion&operacion=registrar_get&id_area="+f.id_area.options[f.id_area.selectedIndex].value+"&solicitante="+f.solicitante.options[f.solicitante.selectedIndex].value+"&fecha_registro="+f.fecha_registro.value+"&fecha_ent_prog="+f.fecha_ent_prog.value+"&proyecto="+f.proyecto.value+"&id_proveedor="+f.id_proveedor.options[f.id_proveedor.selectedIndex].value+"&id_autoriza="+f.id_autoriza.options[f.id_autoriza.selectedIndex].value+"&obs="+f.obs.value+"&condicion_pago="+f.condicion_pago.value;
			break;
		case "post":
			f.submit();
			break;
		default: break;
	}
}
function checkRequisicionDetalle(f) {
	f.id_producto.disabled=false;
	if(checkNselect(f.id_producto,"Seleccione el producto a requerir a partir de la selección de la familia y la correspondiente categoría."))return;
	if(checkNan(f.cantidad,"Ingrese la cantidad de producto a requerir."))return;
	if(f.cantidad.value==0) {alert("Ingrese una cantidad mayor a 0 de producto a requerir."); f.cantidad.value=""; f.cantidad.focus(); return;}
	if(f.fecha_ent_opcional.value!="") if(checkNdate(f.fecha_ent_opcional,"Ingrese correctamente la fecha de entrega opcional del ítem de requisición."))return;
	if(f.vlr_negociado.value!="") {
		f.vlr_negociado.value=limpiarCC(f.vlr_negociado.value);
		if(checkNan(f.vlr_negociado,"Ingrese el valor de compra negociado para el ítem de requisición."))return;
		formatear('$',f.vlr_negociado);
	}
	f.id_medida.disabled=false;
	f.vlr_negociado.value=limpiarCC(f.vlr_negociado.value);
	f.afecta_inventario.value=f.afecta_inventario.checked?'t':'f';
	f.submit();
}
function checkOrdenCompraDetalle(f) {
	f.id_producto.disabled=false;
	if(checkNselect(f.id_producto,"Seleccione el producto a requerir a partir de la selección de la familia y la correspondiente categoría."))return;
	if(checkNan(f.cantidad,"Ingrese la cantidad de producto a requerir."))return;
	if(f.cantidad.value==0) {alert("Ingrese una cantidad mayor a 0 de producto a requerir."); f.cantidad.value=""; f.cantidad.focus(); return;}
	if(f.vlr_negociado.value!="") {
		f.vlr_negociado.value=limpiarCC(f.vlr_negociado.value);
		if(checkNan(f.vlr_negociado,"Ingrese el valor de compra negociado para el ítem de requisición."))return;
		formatear('$',f.vlr_negociado);
	}
	if(checkNdate(f.fecha_ent_opcional,"Ingrese correctamente la fecha de de entrega del producto."))return;
	f.id_medida.disabled=false;
	f.vlr_negociado.value=limpiarCC(f.vlr_negociado.value);
	// f.afecta_inventario.value=f.afecta_inventario.checked?'t':'f';
	f.submit();
}
function checkOrdenCompra(f, method) {
	if(checkNselect(f.id_proveedor,"Seleccione el proveedor para realizar la orden de compra."))return;
	if(checkNdate(f.fecha_registro,"Ingrese correctamente la fecha de registro de la orden de compra."))return;
	if(checkNdate(f.fecha_ent_prog,"Ingrese correctamente la fecha de entrega programada de la compra."))return;
	switch(method) {
		case "get":
			top.arreglos.location.href="proc.php?opcion=orden_compra&operacion=registrar_get&id_proveedor="+f.id_proveedor.options[f.id_proveedor.selectedIndex].value+"&fecha_registro="+f.fecha_registro.value+"&fecha_ent_prog="+f.fecha_ent_prog.value;
			break;
		case "post":
			f.submit();
			break;
		default: break;
	}
}
function adicionarAOrdenCompra(id,id_orden_compra) {
	if(confirm("¿Desea adicionar el detalle de la requisición a la orden de compra?"))
		top.arreglos.location.href="proc.php?opcion=orden_compra_detalle&operacion=registrar_get&id_requisicion_detalle="+id+"&id_orden_compra="+id_orden_compra;
}
function quitarDeOrdenCompra(id,id_orden_compra) {
	if(confirm("¿Desea quitar el detalle de la requisición de la orden de compra?"))
		top.arreglos.location.href="proc.php?opcion=orden_compra_detalle&operacion=quitar_get&id_requisicion_detalle="+id+"&id_orden_compra="+id_orden_compra;
}
function checkRechazada(f){
	if(f.rechazada.checked==true) {
		f.fecha_remision.value=f.remision.value="";
		f.fecha_remision.disabled=true;
		f.remision.disabled=true;
		f.completa.checked=false;
		f.completa.disabled=true;
		f.obs.focus();
	} else {
		f.fecha_remision.disabled=false;
		f.remision.disabled=false;
		f.completa.disabled=false;
		f.completa.checked=true;
		f.fecha_remision.focus();
	}
}
function checkEntrada(f){
	if(checkNdate(f.fecha_ent_real,"Ingrese correctamente la fecha de entrada a inventario."))return;
	if(f.fecha_remision.disabled==false) if(checkNdate(f.fecha_remision,"Ingrese correctamente la fecha de remisión por parte del proveedor."))return;
	if(f.remision.disabled==false) if(checkVacio(f.remision,"Ingrese el número de remisión de entrega por parte del proveedor."))return;
	f.fecha_remision.disabled=false;
	f.remision.disabled=false;
	f.completa.disabled=false;
	f.fecha_ent_real.disabled=false;
	f.completa.value=f.completa.checked?'t':'f';
	f.rechazada.value=f.rechazada.checked?'t':'f';
	f.submit();
}
function checkEntradaDirecta(f) {
	f.id_producto.disabled=false;
	if(checkNselect(f.id_producto,"Seleccione el producto a requerir a partir de la selección de la familia y la correspondiente categoría."))return;
	if(checkNan(f.cantidad,"Ingrese la cantidad de producto a entrar a inventario."))return;
	if(f.cantidad.value==0) {alert("Ingrese una cantidad mayor a 0 de producto a entrar."); f.cantidad.value=""; f.cantidad.focus(); return;}
	f.id_medida.disabled=false;
	f.submit();
}
function checkEntradaIncompleta(f) {
	if(checkVacio(f.obs,"Ingrese la observación de la entrada incompleta."))return;
	f.completa.value=f.completa.checked?'t':'f';
	f.submit();
}
function checkOtraSalida(f) {
	f.id_producto.disabled=false;
	if(checkNselect(f.id_producto,"Seleccione el producto de la salida a partir de la selección de la familia y la correspondiente categoría."))return;
	if(checkNan(f.cantidad,"Ingrese la cantidad de producto a sacar."))return;
	if(f.cantidad.value==0) {alert("Ingrese una cantidad mayor a 0 de producto a sacar."); f.cantidad.value=""; f.cantidad.focus(); return;}
	f.id_funcionario.disabled=false;
	f.id_salida_tipo.disabled=false;
	f.existencia.value=limpiarCC(f.existencia.value);
	if(parseInt(f.cantidad.value)>parseInt(f.existencia.value)){alert("No se puede dar salida de cantidades mayores a las existentes. Corrija la cantidad a sacar."); f.cantidad.value=""; f.cantidad.focus(); return;}
	f.numero.value=top.dbox_1.contenido.salida_nueva.numero.value;
	f.submit();
}
function checkSalida(f) {
	if(checkNdate(f.fecha,"Ingrese correctamente la fecha de salida de inventario."))return;
	f.submit();
}
function checkDevolucion(f) {
	if(checkNan(f.cantidad,"Ingrese la cantidad de producto a devolver."))return;
	if(f.cantidad.value==0) {alert("Ingrese una cantidad mayor a 0 de producto a devolver."); f.cantidad.value=""; f.cantidad.focus(); return;}
	if(parseInt(f.id_requisicion_detalle_cantidad.value)<(parseInt(f.cantidad.value)+parseInt(f.devoluciones.value))) { alert('Ya ha devuelto '+f.devoluciones.value+' existencias. No puede devolver '+f.cantidad.value+' unidades mas las ya devueltas, que suman más de las '+f.id_requisicion_detalle_cantidad.value+' unidades entregadas.'); f.cantidad.value=""; f.cantidad.focus(); f.devoluciones.disabled=true; return;}
	if(checkNdate(f.fecha,"Ingrese correctamente la fecha de la devolución a inventario."))return;
	f.submit();
}
function checkHerramienta(f) {
	if(checkNselect(f.id_producto,"Seleccione la herramienta a prestar."))return;
	if(checkNselect(f.id_funcionario,"Seleccione el usuario de la herramienta."))return;
	if(checkNdate(f.fecha_prestamo,"Ingrese correctamente la fecha de préstamo de la herramienta."))return;
	if(f.fecha_devolucion.value!="") if(checkNdate(f.fecha_devolucion,"Ingrese correctamente la fecha de devolución de la herramienta."))return;
	if(f.aceptar.value=="Aceptar") {
		f.disponible.disabled=false;
		if(f.disponible.value<=0) {
			top.ocultarCaja('dbox_1',true);
			return alert("No se puede realizar el préstamo, ya que todas las existencias del ítem están en préstamo o su existencia es nula.");
		}
	}
	f.submit();
}
function checkHerramientaIntervalo(f) {
	if(checkNdate(f.fecha_prestamo_ini,"Ingrese correctamente la fecha inicial de préstamo de la herramienta."))return;
	if(checkNdate(f.fecha_prestamo_fin,"Ingrese correctamente la fecha final de préstamo de la herramienta."))return;
	top.dbox_0.contenido.herramienta.location.href="listas.php?data=herramienta&fecha_prestamo_ini="+f.fecha_prestamo_ini.value+"&fecha_prestamo_fin="+f.fecha_prestamo_fin.value;
}
function checkSalidaIntervalo(f) {
	if(checkNdate(f.fecha_salida_ini,"Ingrese correctamente la fecha inicial de la consulta de salidas de inventarios."))return;
	if(checkNdate(f.fecha_salida_fin,"Ingrese correctamente la fecha final de la consulta de salidas de inventarios."))return;
	top.dbox_0.contenido.salida_inventario.location.href="listas.php?data=salida_inventario&fecha_salida_ini="+f.fecha_salida_ini.value+"&fecha_salida_fin="+f.fecha_salida_fin.value;
}
function checkSalidaNueva(f, method) {
	if(checkNdate(f.fecha,"Ingrese correctamente la fecha de salida de inventario."))return;
	if(checkNselect(f.id_funcionario,"Seleccione el usuario responsable de la salida de inventario."))return;
	switch(method) {
		case "get":
			f.fecha.disabled=false;
			top.arreglos.location.href="proc.php?opcion=salida_nueva&operacion=registrar_get";
			//&id_funcionario="+f.id_funcionario.options[f.id_funcionario.selectedIndex].value+"&fecha="+f.fecha.value
			break;
		case "post":
			f.submit();
			break;
		default: break;
	}
}
function checkSalidaNuevoTipo(f) {
	if(checkNselect(f.id_salida_tipo,"Seleccione el tipo de salida."))return;
	top.arreglos.location.href="arreglos.php?p=salida_nueva_tipo&id_salida_tipo="+f.id_salida_tipo.options[f.id_salida_tipo.selectedIndex].value;
}
function confirmarSalidaRequisicionDetalle(id_requisicion_detalle) {
	if(confirm('¿Desea asignar el detalle actual de la requisión al registro de salida actual?'))
		top.arreglos.location.href="proc.php?opcion=salida_nueva_requisicion&id_requisicion_detalle="+id_requisicion_detalle+'&id_funcionario='+top.dbox_1.contenido.salida_nueva.id_funcionario.options[top.dbox_1.contenido.salida_nueva.id_funcionario.selectedIndex].value+'&numero='+top.dbox_1.contenido.salida_nueva.numero.value;
}
function imprimirSalida(numero) {
	top.dbox_0.contenido.salida_inventario.location.reload();
	window.open('listas.php?data=salida_imprimir&numero='+numero, 'Imprimir',"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=700, height=500,top=150, left=150");
}
function imprimirRequisicion(numero) {
	window.open('listas.php?data=requisicion_imprimir&id_requisicion='+numero, 'Imprimir',"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=700, height=500,top=150, left=150");
}
function imprimirOrdenCompra(numero){
	window.open('listas.php?data=orden_compra_imprimir&id_orden_compra='+numero, 'Imprimir',"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=700, height=500,top=150, left=150");
}
function confirmarOrdenCompra(id_requisicion) {
	top.arreglos.location.href="arreglos.php?p=requisicion_orden_compra_sepuede&id_requisicion="+id_requisicion;
}
function checkRotacion(f) {
	if(checkNdate(f.fecha_ini,"Ingrese correctamente la fecha inicial de la consulta."))return false;
	if(checkNdate(f.fecha_fin,"Ingrese correctamente la fecha final de la consulta."))return false;
	return true;
}
function prepararStockActual(tipo, f) {
	f.id_bodega.selectedIndex = 0;
	f.id_familia.selectedIndex = 0;
	f.id_categoria.selectedIndex = 0;
	switch(tipo) {
		case "none":
			f.id_bodega.disabled=true;
			f.id_familia.disabled=true;
			f.id_categoria.disabled=true;
			break;
		case "Total":
			f.id_bodega.disabled=true;
			f.id_familia.disabled=true;
			f.id_categoria.disabled=true;
			break;
		case "Por Bodega":
			f.id_bodega.disabled=false;
			f.id_familia.disabled=true;
			f.id_categoria.disabled=true;
			f.id_bodega.focus();
			break;
		case "Por Familia/Categoría":
			f.id_bodega.disabled=true;
			f.id_familia.disabled=false;
			f.id_categoria.disabled=true;
			f.id_familia.focus();
			break;
		default: break;
	}
}
function checkStockActual(f) {
	switch(f.reporte[f.reporte.selectedIndex].value) {
		case "none":
			if(checkNselect(f.reporte,"Seleccione un tipo de reporte para ver el stock actual."))return;
			break;
		case "Total":
			break;
		case "Por Bodega":
			if(checkNselect(f.id_bodega,"Seleccione la bodega de la cual desea ver el stock actual."))return;
			break;
		case "Por Familia/Categoría":
			if(checkNselect(f.id_familia,"Seleccione la familia de productos de la cual desea ver el stock actual."))return;
			break;
		default: break;
	}
	f.id_bodega.disabled=false;
	f.id_familia.disabled=false;
	f.id_categoria.disabled=false;
	window.open('listas.php?data=stock_actual_imprimir&reporte='+f.reporte[f.reporte.selectedIndex].value+'&id_bodega='+f.id_bodega[f.id_bodega.selectedIndex].value+'&id_familia='+f.id_familia[f.id_familia.selectedIndex].value+'&id_categoria='+f.id_categoria[f.id_categoria.selectedIndex].value, 'Imprimir',"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=700, height=500,top=150, left=150");
	top.ocultarCaja('dbox_0',true);
}



function checkEditarEmail(f) {
	if(checkVacio(f.from,"Ingrese correctamente el email del remitente del email."))return;
	if(checkVacio(f.to,"Ingrese correctamente el email del destinatario del email."))return;
	if(f.cc.value!="") if(checkNmail(f.cc,"Ingrese correctamente el email de la CC."))return;
	if(f.cco.value!="") if(checkNmail(f.cco,"Ingrese correctamente el email de la CCO."))return;
	if(checkVacio(f.asunto,"Ingrese el asunto del email."))return;
	if(checkVacio(f.msg,"Ingrese el mensaje del email."))return;
	f.submit();
}
function subirArchivo(f) {
	if(checkVacio(f.archivo,"Seleccione el archivo a cargar en el servidor."))return;
	f.submit();
}
function eliminarArchivo(archivo) {
	top.dbox_0.contenido.borrar.location.href="proc.php?opcion=eliminar_archivo&archivo="+archivo;
}
function checkProyectoBuscar(f) {
	if(checkNdate(f.fecha_registro_ini,"Ingrese correctamente la fecha inicial de búsqueda del proyecto."))return;
	if(checkNdate(f.fecha_registro_fin,"Ingrese correctamente la fecha final de búsqueda del proyecto."))return;
	f.submit();
}
function cargarDepartamentos(p, d) {
	d.disabled=false;
	d.options.length = 0;
	d.selectedIndex = -1;
	d.options[0] = new Option('Seleccione uno...', 'none');
	top.arreglos.location.href="arreglos.php?p=departamento&id="+p.options[p.selectedIndex].value;
}
function limpiarSelect(c) {
	if(c.disabled==false) {
		c.options.length = 0;
		c.selectedIndex = -1;
		c.options[0] = new Option('Seleccione uno...', 'none');
	}
}
function cargarCiudades(d, c){
	c.disabled=false;
	c.options.length = 0;
	c.selectedIndex = -1;
	c.options[0] = new Option('Seleccione uno...', 'none');
	top.arreglos.location.href="arreglos.php?p=ciudad&id="+d.options[d.selectedIndex].value;
}
function obtenerRegId(valor){
	var v=valor.split("_");
	return v[1];
}
function  abrir(page) {
	window.open(page, "LOGIN","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=370, height=300,top=150, left=300");
}
function  abrirImagen(img) {
	window.open(img, "IMAGEN","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=500, height=500,top=150, left=250");
}
function checkParametroEstandar(f){
	if(checkVacio(f.nombre,"Ingrese el nombre del parámetro."))return;
	f.submit();
}
function checkLoginCliente(f){
	if(checkVacio(f.codigo,"Ingrese su código de cliente."))return;
	f.submit();
}
function checkEncuesta(f){
	if(checkNradio(f.identidad,"Seleccione el puntaje de identidad."))return;
	if(checkNradio(f.innovacion,"Seleccione el puntaje de innovación."))return;
	if(checkNradio(f.armonia,"Seleccione el puntaje de armonía."))return;
	if(checkNradio(f.funcionalidad,"Seleccione el puntaje de funcionalidad."))return;
	if(checkNradio(f.claridad,"Seleccione el puntaje de claridad."))return;
	if(checkNradio(f.cumplimiento,"Seleccione el puntaje de cumplimiento."))return;
	f.submit();
}
function checkLogin(f){
	if(checkVacio(f.login,"Ingrese su nombre de Usuario."))return;
	if(checkVacio(f.pass,"Ingrese su Contraseña de acceso."))return;
	f.submit();
}
function checkEmpresa(f){
	if(checkVacio(f.nombre,"Ingrese la razón social de la empresa."))return;
	if(checkVacio(f.nit,"Ingrese el NIT de la empresa."))return;
	if(checkVacio(f.representante,"Ingrese el repreentante legal de la empresa."))return;
	if(checkVacio(f.dir_oficina,"Ingrese la dirección de la empresa."))return;
	if(checkVacio(f.tel_oficina1,"Ingrese el teléfono 1 de la empresa."))return;
	if(f.e_mail.value!="") if(checkNmail(f.e_mail,"Ingrese correctamente el email de la empresa."))return;
	f.submit();
	verProcesando();
}
function checkDepartamento(f){
	if(checkNselect(f.id_pais,"Seleccione el país al que pertenece el departamento."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre del departamento."))return;
	f.submit();
}
function checkComunicado(f){
	if(checkNselect(f.id_contacto,"Seleccione el contacto con el cual se realizó el comunicado."))return;
	if(checkNdate(f.fecha,"Ingrese correctamente la fecha del comunicado."))return;
	if(checkNselect(f.medio,"Seleccione el medio por el cual se realizó el comunicado."))return;
	if(checkVacio(f.detalle,"Ingrese el detalle del comunicado."))return;
	f.submit();
}
function checkEvaluacion_(f){
	if(checkNdate(f.desde,"Ingrese correctamente la fecha de inicio de la evaluación."))return;
	if(checkNdate(f.hasta,"Ingrese correctamente la fecha de finalización de la evaluación."))return;
	f.submit();
}
function checkActualizarPeriodo(periodo) {
	if(confirm("¿Está seguro que desea actualizar los movimientos de E/S del período "+periodo+"?")) {
		location.href="proc.php?opcion=importar_actualizar&periodo="+periodo;
	}
}
function checkExportar(f){
	f.todos.value=f.todos.checked?'t':'f';
	if(f.todos.value=='f')
		if(checkNselect(f.id_periodo,"Seleccione el periodo que desea exportar."))return;
	f.submit();
}
function checkLinea(f){
	if(checkVacio(f.nombre,"Ingrese el nombre de la Línea de Negocio."))return;
	f.submit();
}
function checkCiudad(f){
	if(checkNselect(f.id_departamento,"Seleccione el departamento al que pertenece la ciudad."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre de la ciudad."))return;
	f.submit();
}
function checkBanco(f){
	if(checkVacio(f.nombre,"Ingrese el nombre del banco."))return;
	f.submit();
}
function checkTipoFuncionario(f){
	if(checkVacio(f.nombre,"Ingrese el nombre del tipo o grupo de funcionarios."))return;
	f.submit();
}
function checkDocumento(f) {
	if(checkNselect(f.id_etapa,"Seleccione la etapa o proceso de negocio al cual pertenece el documento ISO."))return;
	if(checkNselect(f.directorio,"Seleccione el directorio en donde se almacenará el documento ISO."))return;
	if(checkVacio(f.nombre,"Seleccione el documento ISO para realizar a carga al servidor."))return;
	if(checkVacio(f.version,"Ingrese la versión del documento ISO."))return;
	if(checkNdate(f.fecha_registro,"Ingrese correctamente la fecha de registro del documento ISO."))return;
	f.submit();
}
function checkFuncionario(f){
	f.cc.value=limpiarCC(f.cc.value);
	if(checkNselect(f.id_tipo_funcionario,"Seleccione el tipo de funcionario a ingresar."))return;
	if(checkVacio(f.cc,"Ingrese la Cédula de Ciudadanía del funcionario."))return;
	if(checkVacio(f.nombres,"Ingrese el (los) nombre(s) del funcionario."))return;
	if(checkVacio(f.apellidos,"Ingrese el (los) apellidos(s) del funcionario."))return;
	if(checkNselect(f.id_ciudad,"Seleccione la ciudad de operaciones del funcionario."))return;
	if(checkVacio(f.cargo,"Ingrese el cargo del funcionario en la empresa."))return;
	if(checkVacio(f.dir_oficina,"Ingrese la dirección de la oficina en la que labora el funcionario."))return;
	if(checkVacio(f.tel_oficina1,"Ingrese el teléfono principal de la oficina en la que labora el funcionario."))return;
	if(checkVacio(f.dir_hogar,"Ingrese la dirección de residencia del funcionario."))return;
	if(checkVacio(f.e_mail,"Ingrese el eMail del funcionario."))return;
	if(checkNmail(f.e_mail,"Ingrese correctamente el email del funcionario."))return;
	if(f.login.disabled==false) if(checkVacio(f.login,"Ingrese un login o nombre de usuario para el funcionario."))return;
	if(f.pass_new.disabled==false) if(checkVacio(f.pass_new,"Ingrese una contraseña de acceso para el funcionario."))return;
	f.activo.value=f.activo.checked?'t':'f';
	if(f.pass_new.value!="" && f.pass_new.value!="Nueva contraseña") {
		f.pass.value=f.pass_new.value;
		alert("Se ha actualizado la contraseña del usuario.");
	}
	f.submit();
}

function checkEtapa(f){
	if(checkNselect(f.id_linea,"Seleccione la Línea de Negocio."))return;
	if(checkVacio(f.ordinal,"Ingrese el número ordinal que distingue a la etapa pre-operativa dentro de la línea de negocio."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre de la etapa pre-operativa de la línea de negocio."))return;
	f.submit();
}
function checkProyecto(f){
	if(checkNselect(f.id_contacto,"Seleccione el contacto líder del proyecto."))return;
	if(checkNselect(f.id_requerimiento,"Seleccione el requerimiento del cliente."))return;
	if(checkNselect(f.id_canal,"Seleccione el canal de distribución del cliente."))return;
	if(checkVacio(f.productos,"Ingrese los productos del cliente para el proyecto."))return;
	if(checkNselect(f.id_categoria_producto,"Seleccione la categoría de los productos."))return;
	if(checkNselect(f.id_target,"Seleccione el target de mercado de los productos del cliente."))return;
	if(checkNselect(f.id_ubicacion_en_pos,"Seleccione la ubicación en el punto de venta del requerimiento del cliente."))return;
	if(checkNdate(f.fecha_registro,"Ingrese correctamente la fecha de registro del proyecto."))return;
	if(checkNdate(f.fecha_entrega_propuesta,"Ingrese correctamente la fecha de la propuesta al cliente."))return;
	if(checkNselect(f.id_diseniador,"Seleccione el diseñador a cargo del proyecto."))return;
	if(checkNselect(f.id_funcionario,"Seleccione el funcionario encargado del presupuesto del proyecto."))return;
	f.proyecto_numero.disabled=false;
	f.id_asesor.disabled=false;
	if(checkNselect(f.id_asesor,"Seleccione el asesor comercial a cargo del proyecto."))return;
	f.submit();
}
function checkNovedad(f) {
	f.cambio.disabled=false;
	if(checkVacio(f.cambio,"Ingrese el consecutivo en letra de la novedad."))return;
	if(checkNdate(f.fecha_registro,"Ingrese correctamente la fecha de registro de la novedad."))return;
	if(checkVacio(f.detalle,"Ingrese el detalle de la novedad."))return;
	if(f.etapa!=null) if(checkNselect(f.etapa,"Seleccione la etapa en la que inicia la novedad."))return;
	if(f.fecha_ent_prog!=null) if(checkNdate(f.fecha_ent_prog,"Ingrese correctamente la fecha de entrega programada de la actividad según la etapa elegida."))return;
	f.cambio.disabled=false;
	f.submit();
}
function checkQueja(f){
	if(checkNselect(f.id_contacto,"Seleccione el contacto que ha interpuesto la queja."))return;
	if(checkNdate(f.fecha_registro,"Ingrese correctamente la fecha de registro de la queja."))return;
	if(checkVacio(f.detalle,"Ingrese el detalle de la queja."))return;
	if(f.resuelto.checked==true) if(checkNdate(f.fecha_resuelto,"Ingrese correctamente la fecha en la que se resuelve la queja."))return;
	f.resuelto.value=f.resuelto.checked?'t':'f';
	f.submit();
}
function checkDisenio(f){
	if(f.fecha_ent_prog.disabled==false) if(checkNdate(f.fecha_ent_prog,"Ingrese correctamente la fecha de entrega de la actividad."))return;
	if(checkNselect(f.id_diseniador,"Seleccione el diseñador a cargo de la actividad."))return;
	if(checkVacio(f.ruta_local,"Ingrese la ruta donde se encuentran los renders en el servidor local."))return;
	if(f.ent_planos_preliminares!=null) f.ent_planos_preliminares.value=f.ent_planos_preliminares.checked?'t':'f';
	if(f.ent_planos_tecnicos!=null) f.ent_planos_tecnicos.value=f.ent_planos_tecnicos.checked?'t':'f';
	if(f.ent_archivos_graficos!=null) f.ent_archivos_graficos.value=f.ent_archivos_graficos.checked?'t':'f';
	f.fecha_ent_prog.disabled=false;
	f.submit();
}
function checkRevisionActividad(f){
	if(checkNselect(f.id_diseniador,"Seleccione el diseñador a cargo de la actividad."))return;
	if(checkVacio(f.ruta_local,"Ingrese la ruta donde se encuentran los renders en el servidor local."))return;
	f.a_aprobacion.value=f.a_aprobacion.checked?'t':'f';
	f.submit();
}
function checkDisenioObs(f){
	if(checkVacio(f.observaciones,"Ingrese la observación de revisión de la actividad para el diseñador correspondiente."))return;
	f.submit();
}
function checkAprobacionActividad(f,aprobada) {
	if(checkVacio(f.ruta_local,"Ingrese la ruta donde se encuentran los renders en el servidor local."))return;
	f.aprobar.value=aprobada;
	f.destacado.value=f.destacado.checked?'t':'f';
	f.submit();
}
function checkArchivarPresupuestar(t, f) {
	t.checked=true;
	if(t==f.archivar) {
		f.a_presupuestar.checked=false;
		f.fecha_ent_spp.value="";
		f.presupuesto_fecha_ent_prog.value="";
		f.sol_planos_preliminares.checked=false;
		f.presupuesto_fecha_ent_prog.disabled=f.sol_planos_preliminares.disabled=f.fecha_ent_spp.disabled=true;
	}
	if(t==f.a_presupuestar) {
		f.archivar.checked=false;
		f.sol_planos_preliminares.disabled=false;
		f.fecha_ent_spp.disabled=true;
		f.presupuesto_fecha_ent_prog.disabled=false;
	}
}
function checkArchivarAprobar(t, f) {
	t.checked=true;
	if(t==f.archivar) {
		f.aprobado.checked=false;
		f.fecha_ent_ptag.value="";
		f.sol_planos_tecnicos.checked=false;
		f.sol_archivos_graficos.checked=false;
		f.entregas.disabled=f.sol_archivos_graficos.disabled=f.sol_planos_tecnicos.disabled=f.fecha_ent_ptag.disabled=true;
	}
	if(t==f.aprobado) {
		f.archivar.checked=false;
		f.sol_planos_tecnicos.disabled=false;
		f.sol_archivos_graficos.disabled=false;
		f.fecha_ent_ptag.disabled=true;
		f.entregas.disabled=false;
		f.sol_planos_tecnicos.focus();
	}
}
function checkFechaEntPtag(f) {
	if(f.sol_planos_tecnicos.checked==true || f.sol_archivos_graficos.checked==true) {
		f.fecha_ent_ptag.disabled=false; 
		f.fecha_ent_ptag.focus();
	} else {
		f.fecha_ent_ptag.value=''; 
		f.fecha_ent_ptag.disabled=true;
	}
}
function devolverApresupuesto(id_cotizacion) {
	if(confirm("Esta opción le permite devolver el presupuesto para su corrección \nen caso de no satisfacer las necesidades del cliente.\n\n¿Desea regresar el presupuesto para ser corregido?")) {
		devolver_motivo=prompt("Describa el motivo de devolución a presupuesto:","Ninguno");
		top.ocultarCaja('dbox_0',true);
		top.dbox_0.contenido.location.href="proc.php?opcion=devolver_apresupuesto&id_cotizacion="+id_cotizacion+"&motivo="+devolver_motivo;
	}
}
function crearEntregas(id_cotizacion) {
	top.verCaja('dbox_1','Programación de entregas',450,300,'forms.php?f=entrega_&id_cotizacion='+id_cotizacion);
}
function checkEntrega(f) {
	if(checkNdate(f.fecha_ent_prog,"Ingrese correctamente la fecha de entrega al cliente."))return;
	if(checkVacio(f.detalle,"Ingrese el detalle de la entrega: cantidad y especificaciones del producto y/o de envío."))return;
	f.fecha_ent_prog.disabled=false;
	f.detalle.disabled=false;
	f.submit();
}
function checkPresentacion(f){
	if(checkNdate(f.fecha_ent_prog,"Ingrese correctamente la fecha de entrega de la propuesta."))return;
	if(checkNselect(f.id_asesor,"Seleccione el asesor a cargo de la propuesta."))return;
	if(f.ejecutada!=null) f.ejecutada.value=f.ejecutada.checked?'t':'f';
	f.enviada.disabled=false;
	f.enviada.value=f.enviada.checked?'t':'f';
	if(f.reenviada!=null) f.reenviada.value=f.reenviada.checked?'t':'f';
	if(f.enviada.value=='t' && f.reenviada==null || f.enviada.value=='t' && f.reenviada.value=='t') f.enviar.value='t';
	if(f.enviar.value=='t') {
		cc=prompt("Adicione otros destinatarios para envíos CC, ingresando los correos electrónicos separados por comas:","Ninguno");
		f.cc.value=cc!="Ninguno" && cc!=null?cc:"none";
		cco=prompt("Adicione otros destinatarios para envíos CCO, ingresando los correos electrónicos separados por comas:","Ninguno");
		f.cco.value=cco!="Ninguno" && cco!=null?cco:"none";
		//alert("CC: "+f.cc.value+"\nCCO: "+f.cco.value);
	}
	if(f.sol_planos_preliminares.disabled==false && f.sol_planos_preliminares.checked==true) if(checkNdate(f.fecha_ent_spp,"Ingrese correctamente la fecha de entrega de la los Planos Preliminares."))return;
	if(f.presupuesto_fecha_ent_prog.disabled==false) if(checkNdate(f.presupuesto_fecha_ent_prog,"Ingrese correctamente la fecha de entrega del presupuesto."))return;
	f.fecha_ent_prog.disabled=false;
	f.presupuesto_fecha_ent_prog.disabled=false;
	f.archivar.disabled=false; f.archivar.value=f.archivar.checked?'t':'f';
	f.a_presupuestar.disabled=false; f.a_presupuestar.value=f.a_presupuestar.checked?'t':'f';
	f.sol_planos_preliminares.disabled=false; f.sol_planos_preliminares.value=f.sol_planos_preliminares.checked?'t':'f';
	f.submit();
}
function checkDesarchivarPresentacion(f) {
	if(checkNselect(f.id_proyecto,"Seleccione un proyecto para desarchivar la presentación."))return;
	if(checkVacio(f.cambio,"Ingrese el literal de la novedad de la cual desea desarchivar la presentación."))return;
	f.submit();
}
function verEntregas(prj) {
	if(prj=="none") return alert("Seleccione un proyecto para consultar las entregas realizadas.");
	else top.verCaja('dbox_0', 'Consulta de Entregas', 500, 330, 'proc.php?opcion=consulta_entrega&id_proyecto='+prj);
}
function checkPresupuesto(f){
	if(checkNselect(f.id_funcionario,"Seleccione el funcionario a cargo del presupuesto."))return;
	f.ent_planos_preliminares.value=f.ent_planos_preliminares.checked?'t':'f';
	f.ejecutada.value=f.ejecutada.checked?'t':'f';
	f.submit();
}
function checkCotizacion(f){
	if(checkNdate(f.fecha_ent_prog,"Ingrese correctamente la fecha de entrega de la cotización."))return;
	if(checkNselect(f.id_asesor,"Seleccione el asesor a cargo de la cotización."))return;
	f.enviar.disabled=false; f.enviar.value=f.enviar.checked?'t':'f';
	if(f.enviar.value=='t') {
		cc=prompt("Adicione otros destinatarios para envíos CC, ingresando los correos electrónicos separados por comas:","Ninguno");
		f.cc.value=cc!="Ninguno" && cc!=null?cc:"none";
		cco=prompt("Adicione otros destinatarios para envíos CCO, ingresando los correos electrónicos separados por comas:","Ninguno");
		f.cco.value=cco!="Ninguno" && cco!=null?cco:"none";
		//alert("CC: "+f.cc.value+"\nCCO: "+f.cco.value);
	}
	f.archivar.disabled=false; f.archivar.value=f.archivar.checked?'t':'f';
	f.aprobado.disabled=false; f.aprobado.value=f.aprobado.checked?'t':'f';
	f.sol_planos_tecnicos.disabled=false; f.sol_planos_tecnicos.value=f.sol_planos_tecnicos.checked?'t':'f';
	f.sol_archivos_graficos.disabled=false; f.sol_archivos_graficos.value=f.sol_archivos_graficos.checked?'t':'f';
	if(f.sol_planos_tecnicos.value=='t' || f.sol_archivos_graficos.value=='t') if(checkNdate(f.fecha_ent_ptag,"Ingrese correctamente la fecha de entrega de los planos técnicos y/o de los archvios gráficos."))return;
	f.fecha_ent_ptag.disabled=false;
	f.submit();
}
function checkEntregar(entregado, fecha) {
	if(entregado.checked==true) {
		fecha.disabled=false;
		fecha.focus();
	} else {
		fecha.value="";	
		fecha.disabled=true;
	}
}
function checkAProduccion(f) {
	if(checkNdate(f.fecha_ent_prog,"Ingrese correctamente la fecha programada de la entrega."))return;
	if(f.entregado.checked==true) if(checkNdate(f.fecha_ent_real,"Ingrese correctamente la fecha real de la entrega."))return;
	f.sol_planos_tecnicos.value=f.sol_planos_tecnicos.checked?'t':'f';
	f.ent_planos_tecnicos.value=f.ent_planos_tecnicos.checked?'t':'f';
	f.sol_archivos_graficos.value=f.sol_archivos_graficos.checked?'t':'f';
	f.ent_archivos_graficos.value=f.ent_archivos_graficos.checked?'t':'f';
	f.fecha_ent_prog.disabled=false;
	f.fecha_ent_real.disabled=false;
	f.submit();
}
function checkEjecucion(f){
	f.realizada.value=f.realizada.checked?'t':'f';
	f.submit();
}
function checkCaso(f){
	if(checkVacio(f.id_linea,"Error: no ha sido cargado el ID de la línea de negocio. \nConsulte con el administrador del sitema."))return;
	if(checkVacio(f.codigo,"Ingrese el CÓDIGO ÚNICO que identifica el caso de soporte técnico al cliente."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre distintivo para el caso de soporte técnico al cliente."))return;
	if(checkVacio(f.descripcion,"Ingrese la descripción para el caso de soporte técnico al cliente."))return;
	f.submit();
}
function checkCausa(f){
	if(checkVacio(f.id_caso,"Error: no ha sido cargado el ID del caso de soporte. \nConsulte con el administrador del sitema."))return;
	if(checkVacio(f.codigo,"Ingrese el CÓDIGO ÚNICO que identifica la causa para el caso de soporte técnico al cliente."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre distintivo para la causa del caso de soporte técnico al cliente."))return;
	if(checkVacio(f.descripcion,"Ingrese la descripción para la causa del caso de soporte técnico al cliente."))return;
	f.submit();
}
function checkSolucion(f){
	if(checkVacio(f.id_causa,"Error: no ha sido cargado el ID de la causa de soporte. \nConsulte con el administrador del sitema."))return;
	if(checkVacio(f.codigo,"Ingrese el CÓDIGO ÚNICO que identifica la solución para la causa del caso de soporte técnico al cliente."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre distintivo para la solución para la causa del caso de soporte técnico al cliente."))return;
	if(checkVacio(f.procedimiento,"Ingrese el procedimiento de solución para la causa del caso de soporte técnico al cliente."))return;
	f.submit();
}
function checkAsistenciaCliente(f) {
	//f.cc.value=limpiarCC(f.cc.value);
	if(checkVacio(f.id_linea,"Error: no ha sido cargado el ID de la Línea de Negocio. \nConsulte con el administrador del sitema."))return;
	if(checkVacio(f.cc,"Ingrese el número de identificación (CC o NIT) del cliente."))return;
	f.submit();
}
function checkAsistenciaPreoperativo(f){
	if(checkVacio(f.id_cliente,"Error: no ha sido cargado el ID del cliente. \nConsulte con el administrador del sitema."))return;
	if(checkNselect(f.id_linea,"Error: no ha sido cargado el ID de la Línea de Negocio. \nConsulte con el administrador del sitema."))return;
	if(checkNselect(f.id_etapa,"Seleccione la etapa pre-operativa de seguimiento al cliente."))return;
	if(checkNdate(f.fecha_ini,"Ingrese correctamente la fecha de la etapa pre-operativa del cliente."))return;
	if(checkVacio(f.observacion,"Ingrese las obervaciones relativas a la etapa pre-operativa del cliente."))return;
	if(checkNselect(f.id_funcionario,"Error: no ha sido cargado el ID del funcionario que (ha) registra(do) la etapa. \nConsulte con el administrador del sitema."))return;
	f.id_linea.disabled=false;
	f.id_etapa.disabled=false;
	f.id_funcionario.disabled=false;
	f.submit();
}
function checkAsistenciaOperativo(f){
	if(checkVacio(f.id_cliente,"Error: no ha sido cargado el ID del cliente. \nConsulte con el administrador del sitema."))return;
	if(checkNselect(f.id_linea,"Error: no ha sido cargado el ID de la Línea de Negocio. \nConsulte con el administrador del sitema."))return;
	if(checkNdate(f.fecha,"Ingrese correctamente la fecha de la nota de asistencia operativa del cliente."))return;
	if(checkVacio(f.observacion,"Ingrese las obervaciones relativas a la nota de asistencia operativa del cliente."))return;
	if(checkNselect(f.id_funcionario,"Error: no ha sido cargado el ID del funcionario que (ha) registra(do) la nota. \nConsulte con el administrador del sitema."))return;
	f.id_linea.disabled=false;
	f.id_funcionario.disabled=false;
	f.submit();
}
function checkAsistenciaSoporte(f){
	if(checkVacio(f.id_cliente,"Error: no ha sido cargado el ID del cliente. \nConsulte con el administrador del sitema."))return;
	if(checkNselect(f.id_linea,"Error: no ha sido cargado el ID de la Línea de Negocio. \nConsulte con el administrador del sitema."))return;
	if(checkNdate(f.fecha,"Ingrese correctamente la fecha de apertura del tiquete de soporte técnico al cliente."))return;
	if(checkVacio(f.observacion,"Ingrese las obervaciones relativas a la apertura del tiquete de soporte técnico al cliente."))return;
	if(checkNselect(f.id_funcionario_abre,"Error: no ha sido cargado el ID del funcionario que (ha) registra(do) el tiquete de soporte técnico. \nConsulte con el administrador del sitema."))return;
	if(checkNselect(f.id_funcionario_atiende,"Seleccione el funcionario de soporte que atenderá el tiquete de soporte técnico al cliente."))return;
	f.id_linea.disabled=false;
	f.id_funcionario_abre.disabled=false;
	f.submit();
}
function checkAsistenciaSeguimientoSoporte(f){
	if(checkVacio(f.id_tiquete,"Error: no ha sido cargado el ID del tiquete de soporte técnico. \nConsulte con el administrador del sitema."))return;
	if(checkNselect(f.id_funcionario_atiende,"Error: no ha sido cargado el ID del funcionario que atiende el tiquete de soporte técnico. \nConsulte con el administrador del sitema."))return;
	if(top.dbox_0.contenido.caso.fila_seleccionada==0) {
		alert("Seleccione el caso de soporte técnico para el tiquete actual.");
		return;
	}else {
		fila=top.dbox_0.contenido.caso.fila_seleccionada.split("_");
		f.id_caso.value=fila[1];
	}
	if(top.dbox_0.contenido.causa.fila_seleccionada==0) {
		alert("Seleccione la causa de soporte técnico para el tiquete actual.");
		return;
	}else {
		fila=top.dbox_0.contenido.causa.fila_seleccionada.split("_");
		f.id_causa.value=fila[1];
	}
	if(top.dbox_0.contenido.solucion.fila_seleccionada==0) {
		alert("Seleccione la solucion de soporte técnico para el tiquete actual.");
		return;
	}else {
		fila=top.dbox_0.contenido.solucion.fila_seleccionada.split("_");
		f.id_solucion.value=fila[1];
	}
	f.id_funcionario_atiende.disabled=false;
	f.fecha.disabled=false;
	escribirHoy(f.fecha);
	f.solucion.value=f.solucion.checked?'t':'f';
	f.submit();
}










function checkTribunal(f){
	if(checkVacio(f.nombre,"Ingrese el nombre del tribunal."))return;
	if(checkNselect(f.id_ciudad,"Seleccione la ciudad en la cual opera el tribunal."))return;
	if(checkVacio(f.dir_oficina,"Ingrese la dirección de la oficina del tribunal."))return;
	if(checkVacio(f.tel_oficina1,"Ingrese el teléfono principal de la oficina del tribunal."))return;
	if(checkNselect(f.id_banco,"Seleccione el banco de la cuenta del tribunal."))return;
	if(checkVacio(f.cuenta_numero,"Ingrese el número e cuenta del tribunal."))return;
	if(checkNselect(f.id_tipo_cuenta,"Seleccione el tipo de cuenta bancaria del tribunal."))return;
	if(checkVacio(f.cuenta_titular,"Ingrese el titular de la cuenta del tribunal."))return;
	if(f.e_mail.value!="") if(checkNmail(f.e_mail,"Ingrese correctamente el email del tribunal."))return;
	f.activo.value=f.activo.checked?'t':'f';
	f.submit();
}
function checkGrupo(f){
	if(checkVacio(f.nombre,"Ingrese el nombre del grupo de clientes."))return;
	if(checkVacio(f.descripcion,"Ingrese la descripción del grupo de clientes."))return;
	f.submit();
}
function checkTipoEntidad(f){
	if(checkVacio(f.nombre,"Ingrese el nombre del tipo de entidad."))return;
	f.submit();
}
function checkEntidad(f){
	if(checkNselect(f.id_tipo_entidad,"Seleccione el tipo de entidad."))return;
	if(checkVacio(f.codigo,"Ingrese un código o sigla distintivo de la entidad."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre de la entidad."))return;
	f.submit();
}
function checkFuerza(f){
	if(checkVacio(f.nombre,"Ingrese el nombre de la fuerza militar."))return;
	f.submit();
}
function checkGrado(f){
	if(checkVacio(f.codigo,"Ingrese una sigla o código para el grado militar."))return;
	if(checkVacio(f.nombre,"Ingrese el nombre del grado militar."))return;
	f.submit();
}
function checkClienteBuscar(f){
	if(checkVacio(f.nombre,"Ingrese el nombre o razón social del cliente."))return;
	f.submit();
}
function checkCliente(f){
	if(checkVacio(f.nombre,"Ingrese el nombre o razón social del cliente."))return;
	if(checkNselect(f.id_segmento,"Seleccione el segmento productivo en el que se clasifica el cliente."))return;
	if(checkNselect(f.id_ciudad,"Seleccione la ciudad en la que se ubica el cliente."))return;
	if(checkVacio(f.tel_oficina1,"Ingrese el número telefónico principal del cliente."))return;
	if(checkNselect(f.id_tipo_cliente,"Seleccione el tipo de cliente."))return;
	if(checkNdate(f.fecha_inscripcion,"Seleccione la fecha de inscripción del cliente."))return;
	if(f.email.value!="") if(checkNmail(f.email,"Ingrese correctamente el email del cliente."))return;
	f.submit();
}
function checkContacto(f){
	if(checkVacio(f.nombre,"Ingrese el nombre del contacto en la empresa cliente."))return;
	if(checkVacio(f.cargo,"Ingrese el cargo del contacto en la empresa cliente."))return;
	if(checkVacio(f.tel_oficina1,"Ingrese el número telefónico del contacto en la empresa cliente."))return;
	if(checkNmail(f.email,"Ingrese correctamente el email del contacto."))return;
	if(f.fecha_cumple.value!="") if(checkNdate(f.fecha_cumple,"Seleccione la fecha de cumpleaños del cliente."))return;
	f.codigo.disabled=false;
	f.submit();
}
function checkVia(f){
	if(checkNselect(f.id_caso,"Seleccione el caso al que pertenece el Ag. de Vía Gubernativa."))return;
	if(checkNselect(f.id_entidad_demandada,"Seleccione la entidad demandada para este caso."))return;
	if(f.rad_fecha_via.value!="") if(checkNdate(f.rad_fecha_via,"Ingrese correctamente la fecha de radicación del Ag. Via Gubernativa."))return;
	if(f.fecha_entrega_a_demanda.value!="") if(checkNdate(f.fecha_entrega_a_demanda,"Ingrese correctamente la fecha de entrega del caso a la sección de demanda."))return;
	f.rta_resol_asig_ret_pen.value=f.rta_resol_asig_ret_pen.checked?'t':'f';
	f.presento_poder_tribunal.value=f.presento_poder_tribunal.checked?'t':'f';
	f.desiste.value=f.desiste.checked?'t':'f';
	f.submit();
}
function checkViaObs(f){
	if(checkVacio(f.id_via,"Error: no ha sido cargado el ID del Ag. de Vía Gubernativa. \nConsulte con el administrador del sitema."))return;
	if(checkNdate(f.fecha,"Seleccione la fecha de registro de la observación."))return;
	if(checkVacio(f.obs,"Ingrese la observación para el proceso de Ag. de Vía Gubernativa actual."))return;
	f.publica.value=f.publica.checked?'t':'f';
	f.fecha.disabled=false;
	f.submit();
}
function checkDemanda(f){
	if(checkNselect(f.id_caso,"Seleccione el caso al que pertenece la demanda."))return;
	if(checkNselect(f.id_entidad_demandada1,"Seleccione la entidad demandada para este caso."))return;
	if(checkNselect(f.id_coordinador,"Seleccione el coordinador para este caso."))return;
	if(checkNselect(f.id_tribunal,"Seleccione el tribunal para este caso."))return;
	if(f.porcentaje.value!="") {
		f.porcentaje.value=limpiarNumero(f.porcentaje.value);
		if(checkVacio(f.porcentaje,"Ingrese correctamente en números el porcentaje."))return;
	}
	if(f.gastos_notificacion.value!="") {
		f.gastos_notificacion.value=limpiarNumero(f.gastos_notificacion.value);
		if(checkVacio(f.gastos_notificacion,"Ingrese correctamente en números los gastos de notificación."))return;
	}
	if(f.fecha_presentacion.value!="") if(checkNdate(f.fecha_presentacion,"Ingrese correctamente la fecha de presentación de la demanda."))return;
	if(f.fecha_admision.value!="") if(checkNdate(f.fecha_admision,"Ingrese correctamente la fecha de admisión de la demanda."))return;
	if(f.fecha_vence_pago_notificacion.value!="") if(checkNdate(f.fecha_vence_pago_notificacion,"Ingrese correctamente la fecha de vencimiento de pago de los gastos de notificación de la demanda."))return;
	if(f.fecha_not_pago.value!="") if(checkNdate(f.fecha_not_pago,"Ingrese correctamente la fecha de notificación del pago."))return;
	if(f.valor_reconocido_pago.value!="") {
		f.valor_reconocido_pago.value=limpiarNumero(f.valor_reconocido_pago.value);
		if(checkVacio(f.valor_reconocido_pago,"Ingrese correctamente en números el valor reconocido."))return;
	}
	if(f.fecha_pago_entidad.value!="") if(checkNdate(f.fecha_pago_entidad,"Ingrese correctamente la fecha de pago por parte de la entidad."))return;
	if(f.fecha_pago_cliente.value!="") if(checkNdate(f.fecha_pago_cliente,"Ingrese correctamente la fecha de pago al cliente."))return;
	f.pago_notificacion.value=f.pago_notificacion.checked?'t':'f';
	f.reembolso_pago_notificacion.value=f.reembolso_pago_notificacion.checked?'t':'f';
	f.fallo_apelado.value=f.fallo_apelado.checked?'t':'f';
	f.pruebas_presentadas.value=f.pruebas_presentadas.checked?'t':'f';
	f.alegatos_presentados.value=f.alegatos_presentados.checked?'t':'f';
	f.submit();
}
function checkChequePago(f){
	if(f.forma_pago_cliente[f.forma_pago_cliente.selectedIndex].value=="Cheque"){
		f.cheque_pago_cliente.disabled=false;
		f.cheque_pago_cliente.focus();
	} else {
		f.cheque_pago_cliente.value="";
		f.cheque_pago_cliente.disabled=true;
	}
}
function checkDemandaObs(f){
	if(checkVacio(f.id_demanda,"Error: no ha sido cargado el ID de la Demanda. \nConsulte con el administrador del sitema."))return;
	if(checkNselect(f.id_etapa,"Seleccione la etapa procesal a la que corresponde la observación."))return;
	if(checkNdate(f.fecha,"Seleccione la fecha de registro de la observación."))return;
	if(checkVacio(f.obs,"Ingrese la observación para el proceso de demanda actual."))return;
	f.publica.value=f.publica.checked?'t':'f';
	f.fecha.disabled=false;
	f.submit();
}
function checkDemandaActuacion(f){
	if(checkVacio(f.id_demanda,"Error: no ha sido cargado el ID de la Demanda. \nConsulte con el administrador del sitema."))return;
	if(checkNdate(f.fecha_registro,"Seleccione la fecha de registro de la actuación."))return;
	if(checkNselect(f.id_etapa,"Seleccione la etapa procesal a la que corresponde la actuación."))return;
	if(checkVacio(f.actuacion,"Ingrese la actuación para el proceso de demanda actual."))return;
	if(checkNdate(f.fecha_actuacion,"Seleccione la fecha de creación de la actuación."))return;
	if(checkNdate(f.fecha_notificacion,"Seleccione la fecha de notificación de la actuación."))return;
	f.publica.value=f.publica.checked?'t':'f';
	f.fecha_registro.disabled=false;
	f.submit();
}
function checkReliquidacion(f){
	if(checkNselect(f.id_caso,"Seleccione el caso al que pertenece la reliquidación."))return;
	if(checkVacio(f.tipo_prestacion,"Ingrese el tipo de prestación que corresponde a este caso."))return;
	if(checkNselect(f.id_coordinador,"Seleccione el coordinador para este caso."))return;
	if(checkNselect(f.id_tribunal,"Seleccione el tribunal para este caso."))return;
	if(checkNselect(f.id_entidad_condenada,"Seleccione la entidad condenada para este caso."))return;
	if(f.fecha_sentencia.value!="") if(checkNdate(f.fecha_sentencia,"Ingrese correctamente la fecha de sentencia."))return;
	if(f.fecha_ejecutoria.value!="") if(checkNdate(f.fecha_ejecutoria,"Ingrese correctamente la fecha de ejecutoria."))return;
	if(f.fecha_resol_cumplimiento.value!="") if(checkNdate(f.fecha_resol_cumplimiento,"Ingrese correctamente la fecha de resolución de cumplimiento."))return;
	if(f.vlr_reconocido_antes_mora.value!="") {
		f.vlr_reconocido_antes_mora.value=limpiarNumero(f.vlr_reconocido_antes_mora.value);
		if(checkVacio(f.vlr_reconocido_antes_mora,"Ingrese correctamente en números el valor reconocido antes de mora."))return;
	}
	if(f.reliquidacion.value!="") {
		f.reliquidacion.value=limpiarNumero(f.reliquidacion.value);
		if(checkVacio(f.reliquidacion,"Ingrese correctamente en números el valor de la reliquidación."))return;
	}
	f.poder_pres_pet_ante_demanda.value=f.poder_pres_pet_ante_demanda.checked?'t':'f';
	f.liquidacion_caja.value=f.liquidacion_caja.checked?'t':'f';
	f.sentencia_sello_prima_copia.value=f.sentencia_sello_prima_copia.checked?'t':'f';
	f.poder_demandar_juez_laboral.value=f.poder_demandar_juez_laboral.checked?'t':'f';
	f.demanda_ejec_lab_lista.value=f.demanda_ejec_lab_lista.checked?'t':'f';
	f.submit();
}
function checkReliquidacionObs(f){
	if(checkVacio(f.id_reliquidacion,"Error: no ha sido cargado el ID de la Reliquidación. \nConsulte con el administrador del sitema."))return;
	if(checkNdate(f.fecha,"Seleccione la fecha de registro de la observación."))return;
	if(checkVacio(f.obs,"Ingrese la observación para el proceso de Reliquidación."))return;
	f.publica.value=f.publica.checked?'t':'f';
	f.fecha.disabled=false;
	f.submit();
}
function checkReliquidacionActuacion(f){
	if(checkVacio(f.id_reliquidacion,"Error: no ha sido cargado el ID de la Reliquidación. \nConsulte con el administrador del sitema."))return;
	if(checkNdate(f.fecha_registro,"Seleccione la fecha de registro de la actuación."))return;
	if(checkNselect(f.id_etapa,"Seleccione la etapa procesal a la que corresponde la actuación."))return;
	if(checkVacio(f.actuacion,"Ingrese la actuación para el proceso de reliquidación actual."))return;
	if(checkNdate(f.fecha_actuacion,"Seleccione la fecha de creación de la actuación."))return;
	if(checkNdate(f.fecha_notificacion,"Seleccione la fecha de notificación de la actuación."))return;
	f.publica.value=f.publica.checked?'t':'f';
	f.fecha_registro.disabled=false;
	f.submit();
}
function checkNotificacion(f){
	f.pago_notificacion.value=f.pago_notificacion.checked?'t':'f';
	f.reembolso_pago_notificacion.value=f.reembolso_pago_notificacion.checked?'t':'f';
	f.submit();
}
function checkPendienteDemanda(f){
	f.tareas_pendientes.value=f.tareas_pendientes.checked?'t':'f';
	f.submit();
}
function checkPendienteReliquidacion(f){
	f.tareas_pendientes.value=f.tareas_pendientes.checked?'t':'f';
	f.submit();
}

//Función de ejemplo
function checkF(f){
	if(checkNselect(f.opcion,"Seleccione ALGO."))return;
	if(checkNdate(f.fecha,"Seleccione bien la FECHA."))return;
	if(checkVacio(f.texto,"Digite un TEXTO."))return;
	if(checkNan(f.num,"Digite un NUMERO"))return;
	if(checkNmail(f.email,"Digite bien su EMAIL."))return;
	f.submit();
}

/************************************************************************************
FUNCIONES DE CONTROL DE INTERFACE ATHENEA
************************************************************************************/
function limpiarFramesAsistencia() {
	top.preoperativo.location='blank.html';
	top.operativo.location='blank.html';
	top.soporte.location='blank.html';
	top.detalle.location='blank.html';
}








function limpiarFramesCaso() {
	top.cliente_buscar_caso.location.href='forms.php?f=cliente_buscar_caso';
	top.caso.location.href='blank.html';
	top.via.location.href='blank.html';
	top.demanda.location.href='blank.html';
	top.reliquidacion.location.href='blank.html';
	top.detalle.location.href='blank.html';
}
function limpiarFramesCasoRegional() {
	top.cliente_buscar_caso_regional.location.href='forms.php?f=cliente_buscar_caso_regional';
//	top.caso.location.href='blank.html';
	top.via.location.href='blank.html';
	top.demanda.location.href='blank.html';
	top.reliquidacion.location.href='blank.html';
	top.detalle.location.href='blank.html';
}
function inhabilitarFormulario(f){
	for(i=0;i<f.elements.length;i++){
		c=f.elements[i];
		c.disabled=true;
	}
}
function mostrarVencio(fecha_i,fecha_f){
	if(fecha_i=="" || fecha_f=="") return;
	fia=new Array();
	fia=fecha_i.split("-");
	fi=new Date(fia[0],(fia[1]-1),fia[2],0,0,0);
	ffa=new Array();
	ffa=fecha_f.split("-");
	ff=new Date(ffa[0],(ffa[1]-1),ffa[2],0,0,0);
	if (ff>fi) document.write("<img src='../img/no.gif' align=absmiddle>");
	else document.write("<img src='../img/si.gif' align=absmiddle>");
}


/*$sql="SELECT ticket.asunto, 
					ticket.fecha, 
					CONCAT(funcionario.nombres,' ',funcionario.apellidos), 
					ticket.detalle, 
					ticket.seguimiento_cliente, 
					ticket.seguimiento_interno, 
					ticket.id_ticket_estado, 
					ticket.detalle_cancelacion, 
					ticket.solucion 
					FROM ticket,funcionario 
					WHERE ticket.id_ticket=$id  
					AND funcionario.id_funcionario=ticket.id_funcionario";
				$con=$this->conectar();
				$rs = mysql_query($sql);
				$filas = mysql_num_rows($rs);
				if($filas>0){
					$asunto=mysql_result($rs,0,0);
					$fecha=mysql_result($rs,0,1);
					$cliente=mysql_result($rs,0,2);
					$detalle=mysql_result($rs,0,3);
					$seguimiento_cliente=mysql_result($rs,0,4);
					$seguimiento_interno=mysql_result($rs,0,5);
					$estado=mysql_result($rs,0,6);
					$detalle_cancelacion=mysql_result($rs,0,7);
					$solucion=mysql_result($rs,0,8);
				}
				mysql_free_result($rs);
				mysql_close($con);
			
				$str="\n".$this->crearFormIni("detalle_ticket","proc.php","post","center","").$this->crearFormSeparador();
				$str.=$this->crearFormCampo("hidden",false,"","opcion","","detalle_ticket",null,"",true,"");
				$str.=$this->crearFormCampo("hidden",false,"","operacion","","modificar",null,"",true,"");
				$str.=$this->crearFormCampo("hidden",false,"","id","",$id,null,"",true,"");
				
				$str.=$this->crearFormCampo("text",false,"Asunto","asunto","text",$asunto,null,"",false,"width:350px").$this->crearFormSeparador();
				$str.=$this->crearFormCampo("text",false,"Fecha","fecha","text",$fecha,null,"",false,"width:350px").$this->crearFormSeparador();
				$str.=$this->crearFormCampo("text",false,"Cliente","cliente","text",$cliente,null,"",false,"width:350px").$this->crearFormEspacio().$this->crearFormSeparador();
				$str.=$this->crearFormCampo("textarea",false,"Detalle","detalle","textarea",$detalle,null,"",true,"width=350px;height:60px").$this->crearFormEspacio().$this->crearFormSeparador();
				$str.=$this->crearFormHr(4).$this->crearFormSeparador();
				$str.=$this->crearFormCampo("text",false,"Información al Cliente","info_cliente","text","",null,"",true,"width:350px");
				$eventos=array("onClick"=>"agregarInfoCliente(document.detalle_ticket,'".date('Y-m-d')."');");
				$str.=$this->iniciarCelda(1,"right");
				$str.=$this->crearFormCampo("button",false,"","agregar_info_cliente","boton","Agregar",$eventos,"",true,"").$this->crearFormSeparador();
				$str.=$this->cerrarCelda();
				$str.=$this->crearFormCampo("textarea",false,"","historico_info_cliente","textarea",$seguimiento_cliente,null,"",true,"width:350px;height:60px").$this->crearFormSeparador();
				
				$str.=$this->crearFormHr(4).$this->crearFormSeparador();
				$str.=$this->crearFormCampo("text",false,"Información Interna","info_interna","text","",null,"",true,"width:350px");
				$eventos=array("onClick"=>"agregarInfoInterna(document.detalle_ticket,'".date('Y-m-d')."');");
				$str.=$this->iniciarCelda(1,"right");
				$str.=$this->crearFormCampo("button",false,"","agregar_info_interna","boton","Agregar",$eventos,"",true,"").$this->crearFormSeparador();
				$str.=$this->cerrarCelda();
				$str.=$this->crearFormCampo("textarea",false,"","historico_info_interna","textarea",$seguimiento_interno,null,"",true,"width:350px;height:60px").$this->crearFormSeparador();
				
				$str.=$this->crearFormHr(4).$this->crearFormSeparador();
				$eventos=array("onChange"=>"activarCampo(document.detalle_ticket,this.options[selectedIndex].value);");
				$sql="SELECT id_ticket_estado, nombre 
					FROM ticket_estado 
					WHERE id_ticket_estado>2 
					ORDER BY nombre";
				$str.=$this->crearFormCampo("select",false,"Estado","id_ticket_estado","select","",$eventos,$sql,true,"").$this->crearFormEspacio().$this->crearFormSeparador();
				$str.=$this->crearFormCampo("textarea",false,"Motivo Cancelacion","motivo_cancelacion","textarea",$detalle_cancelacion,null,"",true,"width:350px;height:60px").$this->crearFormSeparador();
				$eventos=null;
				$sql="SELECT funcionario.id_funcionario, CONCAT(funcionario.nombres,' ',funcionario.apellidos,' (',tipo_funcionario.nombre,')') 
					FROM funcionario, tipo_funcionario
					WHERE funcionario.id_tipo_funcionario<>3 
					AND funcionario.id_funcionario<>$_SESSION[id_funcionario_actual]  
					AND tipo_funcionario.id_tipo_funcionario=funcionario.id_tipo_funcionario 
					ORDER BY funcionario.nombres";
				$str.=$this->crearFormCampo("select",false,"Funcionario","id_funcionario","select","",$eventos,$sql,false,"width:350px");
				
				$str.=$this->crearFormHr(4).$this->crearFormSeparador();
				$str.=$this->crearFormCampo("textarea",false,"Solución","solucion","textarea",$solucion,null,"",true,"width:350px;height:60px").$this->crearFormSeparador();
				$str.=$this->crearFormSeparador();
				$str.=$this->iniciarCelda(4,"center");
				$eventos=array("onClick"=>"checkInfoTicket(document.detalle_ticket, document.detalle_ticket.id_ticket_estado.options[document.detalle_ticket.id_ticket_estado.selectedIndex].value);");
				$str.=$this->crearFormCampo("button",false,"","aceptar","boton","Guardar",$eventos,"",true,"");
				$eventos=array("onClick"=>"top.ocultarCaja(parent.titbar.document.caja.nombre.value,true);");
				$str.=$this->crearFormCampo("button",false,"","cerrar","boton","Cerrar",$eventos,"",true,"");
				$str.=$this->cerrarCelda().$this->crearFormFin();
				$str.="<script>
					document.detalle_ticket.solucion.readOnly=true;
					document.detalle_ticket.historico_info_cliente.readOnly=true;
					document.detalle_ticket.historico_info_interna.readOnly=true;
					document.detalle_ticket.detalle.readOnly=true;
					document.detalle_ticket.motivo_cancelacion.readOnly=true;
					establecerEstadoTicket(document.detalle_ticket,$estado);
					</script>";
				break;
	*/
