//**********************************************************
// TIME AND YEAR DISPLAY
//**********************************************************
function showYear() {
    var myYear = new Date;
    document.write(myYear.getFullYear());
}
function showDate() {
    var stampmonths = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Deciembre");
    var stampdays = new Array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado");
    var thedate = new Date();
    document.write(stampdays[thedate.getDay()] + ", " + thedate.getDate() + " de " + stampmonths[ thedate.getMonth()] + " de "  + thedate.getFullYear() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
}
//**********************************************************
// POPUP WINDOW
//**********************************************************
function popup(mypage,myname,w,h,features) {
    if(screen.width){
        var winl = (screen.width-w)/2;
        var wint = (screen.height-h)/2;
    } else {
        winl = 0;wint =0;
    }
    if (winl < 0) winl = 0;
    if (wint < 0) wint = 0;
    var settings = 'height=' + h + ',';
    settings += 'width=' + w + ',';
    settings += 'top=' + wint + ',';
    settings += 'left=' + winl + ',';
    settings += features;
    win = window.open(mypage,myname,settings);
    win.window.focus();
}
//****************************************************************
// FUNCION PARA CONTROLAR EL INGRESO DE NUMEROS
//***************************************************************
function entero(event){
    var key=(document.all) ? event.keyCode : event.which; // Se obtiene el valor ASCII de la tecla pulsada.
    //solo se puede introducir números y puntos    
    if (key < 48 || key > 57) {//si no es numero 
        window.event.keyCode=0;//anula la entrada de texto.
    }
}
//****************************************************************
// FUNCION PARA CONTROLAR EL DE SOLO LETRAS
//***************************************************************
function validarSoloLetras(e) { 
    tecla = (document.all) ? e.keyCode : e.which; // Se obtiene el valor ASCII de la tecla pulsada.
    if (tecla==8) return true; // 
    patron =/[A-Za-zñÑ\s]/; // 4
    te = String.fromCharCode(tecla); // 5
    return patron.test(te); // 6
} 
//****************************************************************
// FUNCION QUE SE INVOCA PARA REALIZAR LAS CONSULTAS EN LOS CAMPOS TIPO SELECT
//***************************************************************
function realizarConsulta(e, forma, accion){
    tecla = (document.all) ? e.keyCode : e.which; // Se obtiene el valor ASCII de la tecla pulsada.
    if (tecla==13){
        eval("document."+forma+".tipoAccion.value='"+accion+"'");
        eval("document."+forma+".submit()");
    } 
}
//**********************************************************
// FULL SCREEN POPUP WINDOW
//**********************************************************
function fullScreenSIFMELCO() {
    window.open('../main2/sistema.jsp','sistema','width='+screen.width*0.99+',height='+screen.height*0.93+',top=0,left=0,resizable=yes');
}
//**********************************************************
// ACTUALIZAR INFORMACIÓN DESAPARECIDO
//**********************************************************
function actualizarInfo(mypage,myname) {
    window.open(mypage,myname);
    window.close();
}
//****************************************************************
// FUNCION PARA CONTROLAR EL INGRESO DE LETRAS SOLO EN MAYUSCULAS
//***************************************************************
function upperCase(obj){
    obj.value=obj.value.toUpperCase();
}
//**********************************************************
// MENU DE ACCESO DIRECTO
//**********************************************************
function menuAcceso(selObj,restore){
    if(selObj.options[selObj.selectedIndex].value!=0){
        eval("parent.parent.contenido.location.href='"+selObj.options[selObj.selectedIndex].value+"'");
        if (restore) selObj.selectedIndex=0;
    }
}
//**************************************************************************
// FUNCION QUE PERMITE CONTROLAR QUE SIEMPRE QUE SE GENERE SUBMIT, EL VALOR 
// TIPO ACCION SEA DIFERENTE DE NULL
//**************************************************************************
function generarSubmit(forma) {
    var tipoAccion;    
    tipoAccion=eval('document.' + forma + '.tipoAccion.value');
    if(tipoAccion!=''){
        return true;
    }
    return false;
}
//****************************************************************
// CONTROLAR LA EJECUCION 1 SOLO CLIC
//***************************************************************
var dobleClick = 0;
function controlTipoAccion(objeto, forma, accion) {
    dobleClick++;
    //alert('El proceso está en ejecución ' + dobleClick);
    if (dobleClick == 1) {
        objeto.disabled=true;
        eval('document.' + forma + '.tipoAccion.value = "' + accion + '"');
        eval('document.' + forma + '.submit();');
    } else {
        alert('El proceso está en ejecución');
    }
}
//*****************************************************************************
// FUNCIÓN UTILIZADA PARA ELIMINAR ESPACIOS EN BLANCO A LA IZQUIERDA
//*****************************************************************************
function trimLeft( str ) {
    var resultStr = "";
    var i = len = 0;
    
    if (str+"" == "undefined" || str == null)	
        return null;
    
    str += "";
    
    if (str.length == 0) 
        resultStr = "";
    else {	
        // ciclo que se repite mientras existan espacios en blanco
        len = str.length;
        
        while ((i <= len) && (str.charAt(i) == " ")){
            i++;
        }
        
        //Se reemplaza la cadena original por la cadena sin espacios
        resultStr = str.substring(i, len);
    }
    return resultStr;
}
//*****************************************************************************
// FUNCIÓN UTILIZADA PARA ELIMINAR ESPACIOS EN BLANCO A LA DERECHA
//*****************************************************************************
function trimRight( str ) {
    var resultStr = "";
    var i = 0;
    
    if (str+"" == "undefined" || str == null)	
        return null;
    
    str += "";
    
    if (str.length == 0) 
        resultStr = "";
    else {
        // ciclo que se repite mientras existan espacios en blanco
        i = str.length - 1;
        while ((i >= 0) && (str.charAt(i) == " "))
            i--;
        
        //Se reemplaza la cadena original por la cadena sin espacios
        resultStr = str.substring(0, i + 1);
    }
    
    return resultStr;  	
}
//*****************************************************************************
// FUNCIÓN UTILIZADA PARA ELIMINAR ESPACIOS EN BLANCO A LA IZQUIERDA Y LA DERECHA
//*****************************************************************************
function trim( str ) {
    var resultStr = "";
    
    resultStr = trimLeft(str);
    resultStr = trimRight(resultStr);
    
    return resultStr;
}
//*****************************************************************************
//
//*****************************************************************************
function validarAlelo(alelo){
    valor=alelo.value.toUpperCase();
    cadena=valor;
    tamano=valor.length;
    for(z=0;z<valor.length;z++){
        if(isNaN(valor.charAt(z))){
            letra = valor.charAt(z);
            if(z==0){
                if(letra!='N'){
                    cadena = valor.replace(letra,"")
                }
            }else if(z==1){
                if(letra!='D' && letra!='A'){
                    cadena = valor.replace(letra,"")
                }
            }else{
                anterior=valor.substr(0,2);
                if(anterior=='NA' || anterior=='ND'){
                    cadena=anterior;
                }else{
                    anterior=valor.substr(0,z-1);
                    if(!isNaN(anterior)){
                        cadena = parseInt(valor);
                    }else{
                        cadena='';
                    }
                }
            }
        }else{
            if(tamano==2){
                letra = valor.charAt(0);
                if(letra=='N'){
                    letra = valor.charAt(1);
                    cadena = valor.replace(letra,"")
                }
            }else if(tamano>2){
                letra=valor.substr(0,2)
                if(letra=='ND' || letra=='NA'){
                    cadena = letra;
                }
            }
        }
    }
    alelo.value=cadena;
}
//****************************************************************
// VALIDA EL PROCESO DE COPIA DE ELEMENTOS
//**************************************************************
function copiarElementoGenetica(forma) {
    
    control= eval('document.'+forma+'.consecutivoEvidenciaModificar'); 
    consecutivoEvidencia=obtenerRadioButtonSeleccionado(forma, control);
    
    if(consecutivoEvidencia==0){
        alert('Debe seleccionar un elemento para poder realizar el proceso.');
    }else{    
        cantidadCopia=prompt("Por favor ingrese la cantidad de copias que \n desea realizar del elemento, valores entre 1 y 50.","")    
        if(cantidadCopia!=null && cantidadCopia!=0){   
            
            var mensajeNoNumerico;
            for(i=0;i<cantidadCopia.length;i++){
                numeros=cantidadCopia.charCodeAt(i);   
                if ( numeros > 31 && ( numeros < 48 ||  numeros > 57)) { // Chequeamos que sea un numero comparandolo con los valores ASCII      
                    mensajeNoNumerico="Debe ingresar un valor númerico para el número de copias"
                    break;
                }       
            }
            if (mensajeNoNumerico!=null){
                alert(mensajeNoNumerico);
            }else{
                if(cantidadCopia <= 50){ 
                    eval("document."+forma+".cantidadCopiaEvidencia.value=cantidadCopia");                 
                    eval("document."+forma+".tipoAccion.value='CopiarEvidencia'");                   
                    eval("document."+forma+".submit()"); 
                    history.forward();  
                }else{
                    alert("La cantidad de copias es demasiado grande, por favor reduzca la cantidad");
                }
            } 
        } else{
            history.forward();
        }     
    }
}
//**************************************************************************
// FUNCION QUE PERMITE ASIGNAR UNA ACCION AL CAMPO TIPOACCION
//**************************************************************************
function asignarAccion(forma, valor) {
    eval("document." + forma + ".tipoAccion.value='"+valor+"'");
}
//****************************************************************
// VALIDA QUE EL TEXTO NO TENGA CARACTERES ESPECIALES
//***************************************************************
function validarValoresAlelos(texto, upperCase){
    valor=texto.value;
    if(upperCase=='true'){
        valor=valor.toUpperCase();
    }
    var cadena1="";
    var cadena="";
    var numeroPuntos=0;
    for (i = 0; i < valor.length; i++){   
        var c = valor.charCodeAt(i);
        //      Mayusculas             Minusculas              Numeros         Espacio    
        if ((c > 64 && c < 91) || (c > 96 && c < 123) || (c > 47 && c < 58) || c==32 ){
            cadena+=valor.charAt(i);
        }else if(c==44){ //se valida la (,) coma y se reemplaza por el . (punto) 
            if(numeroPuntos==0){
                cadena+="."
                numeroPuntos++;
            }
        }else if(c==46){ //Se valida el punto (.), sólo se permite uno 
            if(numeroPuntos==0){
                cadena+=valor.charAt(i);
                numeroPuntos++;
            }
        }
        cadena1=cadena;
    }
    texto.value = cadena1
    texto.valant = cadena1
}
//****************************************************************
// FUNCION PARA CONTROLAR EL MAXIMO NUMERO DE CARACTERES QUE SE PUEDE
// DIGITAR EN UN CONTROL TEXTAREA
//***************************************************************
function ismaxlength(obj,maxlength){
    var mlength=parseInt(maxlength)
    if (obj.value.length>mlength)
        obj.value=obj.value.substring(0,mlength)
}
//****************************************************************
// FUNCION PARA VALIDAR QUE LOS NUMEROS DECIMALES INGRESADOS SEAN VALIDOS
//***************************************************************
function esNumeroConParteDecimal(numero) {
    var caracteresValidos = "0123456789.";
    var numeroPuntos=0;
    for (i = 0; i < numero.length; i++) {
        var c = numero.charAt(i);
        if(c=='.'){
            numeroPuntos++;
            if(numeroPuntos==2){
                return false;
            }
        }else if (caracteresValidos.indexOf(c) == -1) {
            return false;
        }
    }
    return true;
}
function formatoPantallaCarga(numero){
    numero=trim(numero);
    if(esNumeroConParteDecimal(numero)){
        document.write(numero);
    }else{
        document.write("<span class='aviso'>"+numero+"</span>");
    }  
}
function formatoMayuscula(texto){
    document.write(texto.toUpperCase());
}
function formatoPantallaCargaAmel(valorAlelo){
    if(valorAlelo=='X' || valorAlelo=='Y'){
        document.write(valorAlelo);
    }else{
        document.write("<span class='aviso'>"+valorAlelo+"</span>");
    }   
}
function formatoEspaciosBlancos(cantidadBlancos){
    for (i=0;i<cantidadBlancos;i++){
        document.write("&nbsp;");
    }
}
function formatoPantallaCalculosProbabilidadY(valorAlelo){
    numero=trim(valorAlelo);
    if(numero!='0,0100'){
        document.write(valorAlelo);
    }else{
        document.write("<strong><span class='aviso'>"+valorAlelo+"</span></strong>");
    }   
}
//****************************************************************
// CONTROLA EL USO DE FORMATO EN EL CAMPO
//***************************************************************
function campoFormato(campo, formato) {
    if (campo.value == '') {
        campo.value = formato;
    }
}
//****************************************************************
//PONER FORMATO DE FECHA
//***************************************************************
var formato = new Array(2,2,4)
function mascara(d,sep,pat,nums){
    if(d.valant != d.value){
        val = d.value
        largo = val.length
        val = val.split(sep)
        val2 = ''
        for(r=0;r<val.length;r++){
            val2 += val[r]	
        }
        if(nums){
            for(z=0;z<val2.length;z++){
                if(isNaN(val2.charAt(z))){
                    letra = new RegExp(val2.charAt(z),"g")
                    val2 = val2.replace(letra,"")
                }
            }
        }
        val = ''
        val3 = new Array()
        for(s=0; s<pat.length; s++){
            val3[s] = val2.substring(0,pat[s])
            val2 = val2.substr(pat[s])
        }
        for(q=0;q<val3.length; q++){
            if(q ==0){
                val = val3[q]
            }
            else{
                if(val3[q] != ""){
                    val += sep + val3[q]
                }
            }
        }
        d.value = val
        d.valant = val
    }
}
var formatoFecha = new Array(2,2,4,2,2)
function mascaraFecha(d,sep,pat){
    if(d.valant != d.value){
        val = d.value
        val2 = ''
        letra=''
        for(z=0;z<val.length;z++){
            if(!isNaN(val.charAt(z))){
                if(val.charAt(z)!=' '){
                    val2+=val.charAt(z)
                }	
            }
        }
        val = ''
        val3 = new Array()
        
        for(s=0; s<pat.length; s++){
            val3[s] = val2.substring(0,pat[s])
            val2 = val2.substr(pat[s])
        }
        for(q=0;q<val3.length; q++){
            if(q ==0){
                val = val3[q]
            }
            else if((q==1 || q==2) && val3[q]!=''){
                val += sep + val3[q]
            }else if(q==3 && val3[q]!=''){
                val += " "+ val3[q]
            }else if(q==4 && val3[4]!=''){
                val += ":"+ val3[q]		
                
            }
        }
        d.value = val
        d.valant = val
    }
    
}
//****************************************************************
//PONER FORMATO DE HORA
//***************************************************************
var formatoHora = new Array(2,2)
function mascaraHora(d,sep,pat){
    if(d.valant != d.value){
        val = d.value
        val2 = ''
        letra=''
        for(z=0;z<val.length;z++){
            if(!isNaN(val.charAt(z))){
                if(val.charAt(z)!=' '){
                    val2+=val.charAt(z)
                }	
            }
        }
        val = ''
        val3 = new Array()
        
        for(s=0; s<pat.length; s++){
            val3[s] = val2.substring(0,pat[s])
            val2 = val2.substr(pat[s])
        }
        for(q=0;q<val3.length; q++){
            if(q ==0){
                val = val3[q]
            }
            else if((q==1 || q==2) && val3[q]!=''){
                val += ":" + val3[q]
            }
        }
        d.value = val
        d.valant = val
    }    
}
//*******************************************************************************************
// OBTENEMOS EL VALOR SELECCIONADO DE UN CONJUNTO DE VALORES RADIO BUTTON
//*****************************************************************************
function obtenerRadioButtonSeleccionado(forma, control) {
    for(i=0;i<control.length;i++){
        if(control[i].checked){ 
            return control[i].value;
        }
    }
    if(eval('document.'+forma+'.consecutivoEvidenciaModificar.checked')){
        return eval('document.'+forma+'.consecutivoEvidenciaModificar.value');
    }
    return 0;
}
//*******************************************************************************************
// OBTENEMOS EL VALOR SELECCIONADO DE UN CONJUNTO DE VALORES RADIO BUTTON
//*****************************************************************************
function consultarPorNumeroDocumento(numeroDocumento, form) {
    if(numeroDocumento!=''){       
        eval('document.' + form + '.submit();');   
    }
}
//*******************************************************************************************
// CONSULTAR POR NÚMERO CASO PARA CASO GENÉTICA, SI ESTA O NO YA REGISTRADO ESE NÚMERO CASO
//*****************************************************************************
function consultarPorNumeroCaso(numeroCaso) {
    if(numeroCaso!=''){
        eval('document.CasoGeneticaForm.submit()');
    }
}
//*******************************************************************************************
// PARAMETRO DE CONSULTA DE DIRECCIONPOR CODIGO PERSONA
//*****************************************************************************
function consultarPorCodigoPersona(codigoPersona) {
    if(codigoPersona!=-1){
        eval('document.GeneticaCitaTomaMuestraForm.submit()');
    }
}
//*******************************************************************************************
//FUNCION QUE PERMITE DESABILITAR O HABILITAR EL CAMPO FECHARETIRO EN LA PANTALLA DE 
//INFORMACION LABORAL DEPENDIENDO DEL VALOR DEL CAMPO OCUPACION ACTUAL
//*****************************************************************************
function seConoceUsuarioRemite(esUsuarioSistema, codigoEntidad, personaRemite, codigoUsuarioRemite, forma){
    var html="";
    if(esUsuarioSistema=='S'){
        html="<strong>Datos persona remite</strong><br />";
        html+=" <select name='codigoUsuarioRemite' class='campo'>";
        html+="<option>- Seleccione -</option>";
        html+="</select>";
        document.getElementById("personaRemite").innerHTML = html;
        consultarUsuariosUnidadBasicaPorEntidadCorrespondencia(codigoEntidad, forma, 'codigoUsuarioRemite', codigoUsuarioRemite);
    }else if(esUsuarioSistema=='N'){
        html="<strong>Datos persona remite</strong><br />";
        html+=" <input name='personaRemite' type='text' class='campo' id='nombrePersonaRemite' size='60' maxlength='200' onkeyup='upperCase(this);' value='"+personaRemite+"' />";
        document.getElementById("personaRemite").innerHTML =html;
    }else{
        document.getElementById("personaRemite").innerHTML = "<strong class='aviso'>Debe indicar si la persona remitente es usuario del sistema</strong><br/>";
    }   
}
//*******************************************************************************************
//FUNCION QUE PERMITE DESABILITAR O HABILITAR EL CAMPO FECHARETIRO EN LA PANTALLA DE 
//INFORMACION LABORAL DEPENDIENDO DEL VALOR DEL CAMPO OCUPACION ACTUAL
//*****************************************************************************
function seConoceUsuarioDestino(esUsuarioSistema, codigoEntidad, personaDestino, codigoUsuarioDestino, forma){
    var html="";
    if(esUsuarioSistema=='S'){
        html="<strong>Datos persona destino</strong><br />";
        html+=" <select name='codigoUsuarioDestino' class='campo'>";
        html+="<option>- Seleccione -</option>";
        html+="</select>";
        document.getElementById("personaDestino").innerHTML = html;
        consultarUsuariosUnidadBasicaPorEntidadCorrespondencia(codigoEntidad, forma, 'codigoUsuarioDestino', codigoUsuarioDestino);
    }else if(esUsuarioSistema=='N'){
        html="<strong>Datos persona destino</strong><br />";
        html+=" <input name='personaDestino' type='text' class='campo' id='nombrePersonaDestino' size='60' maxlength='200' onkeyup='upperCase(this);' value='"+personaDestino+"' />";
        document.getElementById("personaDestino").innerHTML =html;
    }else{
        document.getElementById("personaDestino").innerHTML = "<strong class='aviso'>Debe indicar si la persona destino es usuario del sistema</strong><br/>";
    }   
}
//******************************************************************************
//FUNCION QUE PERMITE MOSTRAR EN LOS CAMPOS FECHA EL FORMATO DE INGRESO DE ESTAS
//*****************************************************************************
function agregarFormatoFecha(campo, mascara){
    valorCampo=campo.value;
    if(valorCampo==''){
        if(mascara=='dd/mm/aaaa hh:mm'){
            campo.value='dd/mm/aaaa hh:mm';
        }else{
            campo.value='dd/mm/aaaa';
        }
    }
}
//******************************************************************************
//FUNCION QUE PERMITE BORRAR EL FORMATO DE INGRESO DE FECHAS
//*****************************************************************************
function borrarMascaraFecha(campo){
    valorCampo=campo.value;
    if(valorCampo!=''){
        if(valorCampo=='dd/mm/aaaa hh:mm' || valorCampo=='dd/mm/aaaa'){
            campo.value='';
        }
    }
}
//******************************************************************************
//FUNCION QUE MOSTRAR LOS CAMPOS DE DETALLE TIPO ENVIO EN LA JSP
//DE MAESTRO CORESPONDENCIA
//*****************************************************************************
function mostrarFilas(Fila) {
    var elementos = document.getElementsByName(Fila);
    for (i = 0; i< elementos.length; i++) {
        if(navigator.appName.indexOf("Microsoft") > -1){
            var visible = 'block'
        } else {
            var visible = 'table-row';
        }
        elementos[i].style.display = visible;
    }
}
//******************************************************************************
//FUNCION QUE OCULTAR LOS CAMPOS DE DETALLE TIPO ENVIO EN LA JSP
//DE MAESTRO CORESPONDENCIA
//*****************************************************************************
function ocultarFilas(Fila) {
    var elementos = document.getElementsByName(Fila);
    for (k = 0; k< elementos.length; k++) {
        elementos[k].style.display = "none";
    }
}
//******************************************************************************
//FUNCION QUE MUESTRA LOS CAMPOS DE DETALLE TIPO ENVIO EN LA JSP
//DE MAESTRO CORESPONDENCIA
//*****************************************************************************
function ocultarFilasTipoEnvio(tipoEnvio) {
    
    if(tipoEnvio=='V'){
        ocultarFilas('correo');
        ocultarFilas('fax');
        mostrarFilas('ventanilla');
    }else if(tipoEnvio=='C'){
        ocultarFilas('ventanilla');
        ocultarFilas('fax');
        mostrarFilas('correo');
    }else if(tipoEnvio=='F'){
        ocultarFilas('correo');
        ocultarFilas('ventanilla');
        mostrarFilas('fax');
    }else{
        ocultarFilas('correo');
        ocultarFilas('fax');
        ocultarFilas('ventanilla');
    }   
}
//******************************************************************************
//FUNCION QUE MUESTRA LOS CAMPOS DE DETALLE TIPO ENVIO EN LA JSP
//DE MAESTRO CORESPONDENCIA
//*****************************************************************************
function ocultarFilasTipoRemite(tipoRemitente, forma) {
    if(tipoRemitente=='E'){
        ocultarFilas('filaPersonaRemite');
        mostrarFilas('filaEntidadRemite');        
    }else if(tipoRemitente=='P'){
        ocultarFilas('filaEntidadRemite');
        mostrarFilas('filaPersonaRemite');
        eval('document.'+forma+'.codigoTipoDocumentoPersonaRemite.focus()');  
    }
}
function ocultarFilasTipoDestino(tipoDestino) {
    if(tipoDestino=='E'){
        ocultarFilas('filaPersonaDestino');
        mostrarFilas('filaEntidadDestino');
        document.getElementById('filaFechaLimite').className='';
    }else if(tipoDestino=='P'){
        ocultarFilas('filaEntidadDestino');
        mostrarFilas('filaPersonaDestino');
        document.getElementById('filaFechaLimite').className='banding';
    }
}
var usuarioSistemaDestino;
var codigoEntidadDestino;
var personaDestino;
var codigoUsuarioDestino;
var formularioPpal;
function ocultarFilasTipoDestinoYRemite(tipoDestino, tipoRemitente, usuarioSistemaRemite, usuarioSistemaDestinoP, codigoEntidadRemite, codigoEntidadDestinoP, personaRemite, personaDestinoP, codigoUsuarioRemite, codigoUsuarioDestinoP, formulario) {
    if(tipoRemitente=='E'){
        ocultarFilas('filaPersonaRemite');
        mostrarFilas('filaEntidadRemite');
    }else if(tipoRemitente=='P'){
        ocultarFilas('filaEntidadRemite');
        mostrarFilas('filaPersonaRemite');
    }
    if (tipoDestino!=null){
        if(tipoDestino=='E'){
            ocultarFilas('filaPersonaDestino');
            mostrarFilas('filaEntidadDestino');
        }else if(tipoDestino=='P'){
            ocultarFilas('filaEntidadDestino');
            mostrarFilas('filaPersonaDestino');
        }
    }
    seConoceUsuarioRemite(usuarioSistemaRemite, codigoEntidadRemite, personaRemite, codigoUsuarioRemite, formulario);
    usuarioSistemaDestino=usuarioSistemaDestinoP;
    codigoEntidadDestino=codigoEntidadDestinoP;
    personaDestino=personaDestinoP;
    codigoUsuarioDestino=codigoUsuarioDestinoP;
    formularioPpal=formulario;
    
    if (tipoDestino!=null){
        self.setTimeout("seConoceUsuarioDestinoPrincipal()", 2000);
    }    
}
//******************************************************************************
//FUNCION QUE MUESTRA LOS CAMPOS DE HORA DE LLEGADA Y HORA DE SALIDA EN LA PANTALLA
//DE CITACIONES
//*****************************************************************************
function ocultarFilasHoraCitacion(estadoCitacion) {
    
    if(estadoCitacion=='A' || estadoCitacion=='T'){        
        mostrarFilas('filaHoraCita');
        document.getElementById('filaHoraCita').className='banding';
        document.getElementById('filaHoraObservacion').className='';
    }else{
        ocultarFilas('filaHoraCita');
    }  
}
//****************************************************************
// FUNCION QUE SE INVOCA PARA REALIZAR LAS CONSULTAS EN LOS CAMPOS TIPO SELECT
//***************************************************************
function cargarRotulo(forma, campoSeleccionado, campo){
    
    var indice = eval("document."+forma+"."+campoSeleccionado+".selectedIndex")
    var textoEscogido = eval("document."+forma+"."+campoSeleccionado+".options["+indice+"].text ") 
    textoEscogido=(textoEscogido.substr(0, textoEscogido.indexOf("(")))
    
    eval("document."+forma+"."+campo+".value='"+textoEscogido+"'");
}
//*******************************************************************************************
//FUNCION QUE PERMITE DESABILITAR O HABILITAR EL CAMPO FECHARETIRO EN LA PANTALLA DE 
//INFORMACION LABORAL DEPENDIENDO DEL VALOR DEL CAMPO OCUPACION ACTUAL
//*****************************************************************************
function seConoceUsuarioDestinoPrincipal(){
    var html="";
    if(usuarioSistemaDestino=='S'){
        html="<strong>Datos persona destino</strong><br />";
        html+=" <select name='codigoUsuarioDestino' class='campo'>";
        html+="<option>- Seleccione -</option>";
        html+="</select>";
        document.getElementById("personaDestino").innerHTML = html;
        consultarUsuariosPorEntidadCorrespondenciaDestino(codigoEntidadDestino, formularioPpal, 'codigoUsuarioDestino', codigoUsuarioDestino);
    }else if(usuarioSistemaDestino=='N'){
        html="<strong>Datos persona destino</strong><br />";
        html+=" <input name='personaDestino' type='text' class='campo' id='nombrePersonaDestino' size='60' maxlength='200' onkeyup='upperCase(this);' value='"+personaDestino+"' />";
        document.getElementById("personaDestino").innerHTML =html;
    }else{
        document.getElementById("personaDestino").innerHTML = "<strong class='aviso'>Debe indicar si la persona destino es usuario del sistema</strong><br/>";
    }   
}
//******************************************************************************
//FUNCION UTILIZADA PARA HACER SUBMIT EN LA PANTALLA DE CASOGENETICAPERSONA
//AL MOMENTO DE PRESIONAR EL LINK COPIAR DIRECCION
//*****************************************************************************
function copiarDireccion(consecutivoDireccion){
    document.CasoGeneticaPersonaForm.tipoAccion.value = 'CopiarDireccion'; 
    document.CasoGeneticaPersonaForm.consecutivoDireccion.value=consecutivoDireccion;
    document.CasoGeneticaPersonaForm.submit();
}
function imprimirRadicado(idCorrespondencia, contextPath){
    popup(contextPath+'/formatos/imprimirRadicado.jsp?idCorrespondencia='+idCorrespondencia,'windowRadicado',300,165,'scrollbars=yes');  
}
function generarSobre(idCorrespondencia, contextPath){
    popup(contextPath+'/correspondencia/generarSobre.jsp?idCorrespondencia='+idCorrespondencia,'windowRadicado',880,300,'scrollbars=yes');  
}
function registrarDevolucion(idCorrespondencia, contextPath){
    var tamano=0;
    popup(contextPath+'/correspondencia/registrarDevolucion.jsp?idCorrespondencia='+idCorrespondencia,'windowRadicado',770,395,'scrollbars=yes');
}
//******************************************************************************
//FUNCION UTILIZADA PARA VALIDAR EL EMAIL INGRESADO
//*****************************************************************************
function validarEmail(email, requerido) {
    if(requerido==false){
        if(trim(email)!=''){
            if (!isValidEmail(email)) {
                alert("Debe ingresar una dirección de email valida");
                return false;
            }
        }
    }else{
        if (!isValidEmail(email)) {
            alert("Debe ingresar una dirección de email valida");
            return false;
        }
    }
    return true;
}
function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
        return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
        return false;
    }
    return true;
}
function allValidChars(email) {
    var parsed = true;
    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
    for (var i=0; i < email.length; i++) {
        var letter = email.charAt(i).toLowerCase();
        if (validchars.indexOf(letter) != -1)
            continue;
        parsed = false;
        break;
    }
    return parsed;
}
//*****************************************************************************
//FUNCION QUE VALIDAR EL SEXO DE LA PERSONA ASOCIADA
//*****************************************************************************
function validarSexoPersonaAsociada(codigoRolGenetica){
    if(codigoRolGenetica==1 || codigoRolGenetica==16 || codigoRolGenetica==17){      
        indice=calcularIndiceValorSelect('CasoGeneticaPersonaForm', 'sexo', 'M');
        eval('document.CasoGeneticaPersonaForm.sexo.options['+indice+'].selected=true');   
    }else if(codigoRolGenetica==2 || codigoRolGenetica==21 || codigoRolGenetica==24){
        indice=calcularIndiceValorSelect('CasoGeneticaPersonaForm', 'sexo', 'F');
        eval('document.CasoGeneticaPersonaForm.sexo.options['+indice+'].selected=true');   
    }else{
        indice=calcularIndiceValorSelect('CasoGeneticaPersonaForm', 'sexo', '-1');
        eval('document.CasoGeneticaPersonaForm.sexo.options['+indice+'].selected=true'); 
    }
}
//*****************************************************************************
//FUNCION  QUE REALIZA UN RECORRIDO POR TODOS LOS ELEMENTOS DEL FORMULARIO,
//EN EL RECORRIDO COMPRUEBA SI EL ELEMENTO ACTUAL ES DE TIPO CHECKBOX Y EN ESTE CASO,
//SIMPLEMENTE SE ACTUALIZA EL ATRIBUTO CHECKED AL VALOR 1, CON LO QUE EL CHECKBOX SE
//MARCARÁ
//*****************************************************************************
function seleccionarCasosExtraccion(forma, campo){
    
    if(campo.checked==true){
        seleccionar_todo(forma);
    }else{
        deseleccionar_todo(forma);
    }
}
function seleccionar_todo(forma){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "checkbox"){
            eval('document.'+forma+'.elements[i].checked=1');
        }
    }
}
//*****************************************************************************
//FUNCION  QUE REALIZA UN RECORRIDO POR TODOS LOS ELEMENTOS DEL FORMULARIO,
//EN EL RECORRIDO COMPRUEBA SI EL ELEMENTO ACTUAL ES DE TIPO CHECKBOX Y EN ESTE CASO,
//SIMPLEMENTE SE ACTUALIZA EL ATRIBUTO CHECKED AL VALOR 0, CON LO QUE EL CHECKBOX SE
//DESMARCARÁ
//*****************************************************************************
function deseleccionar_todo(forma){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "checkbox"){
            eval('document.'+forma+'.elements[i].checked=0');
        }
    }
} 
//*****************************************************************************
//FUNCION  QUE REALIZA UN RECORRIDO POR TODOS LOS ELEMENTOS DEL FORMULARIO,
//EN EL RECORRIDO COMPRUEBA SI EL ELEMENTO ACTUAL ES DE TIPO CHECKBOX Y EN ESTE CASO,
//SIMPLEMENTE SE ACTUALIZA EL ATRIBUTO CHECKED AL VALOR 1, CON LO QUE EL CHECKBOX SE
//MARCARÁ
//*****************************************************************************
function seleccionarCasosYMuestrasAsignados(forma, campo, control){
    
    if(campo.checked==true){
        seleccionar_todo_planilla(forma, control);
    }else{
        deseleccionar_todo_planilla(forma, control);
    }
}
function seleccionar_todo_planilla(forma, control){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "checkbox"){
            var nombreCampo=(eval('document.'+forma+'.elements[i].name'))
            if(control=='E' && nombreCampo.indexOf('propertyRecibirEMP')!=-1){
                eval('document.'+forma+'.elements[i].checked=1');
            }else if(control=='C' && nombreCampo.indexOf('propertyRecibirCaso')!=-1){
                eval('document.'+forma+'.elements[i].checked=1');
            }
        }
    }
}
function deseleccionar_todo_planilla(forma, control){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "checkbox"){
            var nombreCampo=(eval('document.'+forma+'.elements[i].name'))
            if(control=='E' && nombreCampo.indexOf('propertyRecibirEMP')!=-1){
                eval('document.'+forma+'.elements[i].checked=0');
            }else if(control=='C' && nombreCampo.indexOf('propertyRecibirCaso')!=-1){
                eval('document.'+forma+'.elements[i].checked=0');
            }
        }
    }
} 
//*****************************************************************************
//FUNCION  QUE REALIZA UN RECORRIDO POR TODOS LOS ELEMENTOS DEL FORMULARIO,
//EN EL RECORRIDO COMPRUEBA SI EL ELEMENTO ACTUAL ES DE TIPO CHECKBOX Y EN ESTE CASO,
//SIMPLEMENTE SE ACTUALIZA EL ATRIBUTO CHECKED AL VALOR 1, CON LO QUE EL CHECKBOX SE
//MARCARÁ
//*****************************************************************************
function seleccionarPaquetesADesanotar(forma, campo){
    
    if(campo.checked==true){
        seleccionar_todos_desanotar(forma);
    }else{
        deseleccionar_todos_desanotar(forma);
    }
}
function seleccionar_todos_desanotar(forma){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "checkbox"){
            var nombreCampo=(eval('document.'+forma+'.elements[i].name'))
            if(nombreCampo.indexOf('propertyPaquetes')!=-1){
                eval('document.'+forma+'.elements[i].checked=1');
            }
        }
    }
}
function deseleccionar_todos_desanotar(forma){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "checkbox"){
            var nombreCampo=(eval('document.'+forma+'.elements[i].name'))
            if(nombreCampo.indexOf('propertyPaquetes')!=-1){
                eval('document.'+forma+'.elements[i].checked=0');
            }
        }
    }
} 
//*****************************************************************************
//FUNCION  QUE REALIZA UN RECORRIDO POR TODOS LOS ELEMENTOS DEL FORMULARIO,
//EN EL RECORRIDO COMPRUEBA SI EL ELEMENTO ACTUAL ES DE TIPO CHECKBOX Y EN ESTE CASO,
//SIMPLEMENTE SE ACTUALIZA EL ATRIBUTO CHECKED AL VALOR 1, CON LO QUE EL CHECKBOX SE
//MARCARÁ
//*****************************************************************************
function seleccionarElementosPlanilla(forma, campo){
    
    if(campo.checked==true){
        seleccionar_todos_ElePlanilla(forma);
    }else{
        deseleccionar_todos_ElePlanilla(forma);
    }
}
function seleccionar_todos_ElePlanilla(forma){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "checkbox"){
            var nombreCampo=(eval('document.'+forma+'.elements[i].name'))
            if(nombreCampo.indexOf('propertyElementosPlanilla')!=-1){
                eval('document.'+forma+'.elements[i].checked=1');
            }
        }
    }
}
function deseleccionar_todos_ElePlanilla(forma){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "checkbox"){
            var nombreCampo=(eval('document.'+forma+'.elements[i].name'))
            if(nombreCampo.indexOf('propertyElementosPlanilla')!=-1){
                eval('document.'+forma+'.elements[i].checked=0');
            }
        }
    }
} 
//****************************************************************
// VALIDA EL INGRESO DE UNA DOCUMENTACION APORTADA CON O SIN IMAGEN ADJUNTA
//**************************************************************
function   validarArchivoTxt(){     
    var entrar = confirm("¿Desea generar el archivo txt para telecom mail?");
    if ( !entrar ){     
        history.forward();                          
    }else{            
        eval("document.CitacionTelecomMailPendientesForm.tipoAccion.value='GenerarTxt'");  
        eval("document.CitacionTelecomMailPendientesForm.submit()"); 
        history.forward();  
    }      
}
//*******************************************************************************************
// PARAMETRO DE CONSULTA DE DIRECCIONPOR CODIGO PERSONA
//*****************************************************************************
function validarDatosDireccion(medioCitacion) {
    
    if (medioCitacion=='1'){        
        eval('document.GeneticaCitaTomaMuestraForm.submit()');
    }
    //Se comentan estas lineas porque en la jsp no existen estos campos
    /*else{
        eval("document.GeneticaCitaTomaMuestraForm.estadoCitadoAux.value='P'");
        eval("document.GeneticaCitaTomaMuestraForm.estadoCitado.value='P'"); 
    }*/
}
//*******************************************************************************************
// MÉTODO QUE PERMITE MOSTRAR EN LA JSP EL * DE REQUERIDO PARA EL CAMPO DE ROTULO ELEMENTO
// CUANDO SE PROCESA UN EMP
//*****************************************************************************
function validarRotuloElemento(clasificacion, forma, borrarCampo) {
    if (clasificacion=='E'){        
        eval("document."+forma+".rotuloElemento.disabled=false");
        document.getElementById("requeridoRotulo").innerHTML = '*';      
    }else{
        if(borrarCampo=='true'){
            eval("document."+forma+".rotuloElemento.value=''");
        }
        eval("document."+forma+".rotuloElemento.disabled=true");
        document.getElementById("requeridoRotulo").innerHTML = '';
    }
}
//****************************************************************
// ENVIA A IMPRIMIR EL ROTULO DEL ELEMENTO
//***************************************************************
function imprimirRotulo(consecutivoEvidenciaRotulo, forma, accion) {        
    eval('document.' + forma + '.consecutivoEvidenciaRotulo.value="' + consecutivoEvidenciaRotulo + '"');
    eval('document.' + forma + '.tipoAccion.value = "' + accion + '"');
    eval('document.' + forma + '.submit();');   
}
//*******************************************************************************************
// FUNCION JAVASCRIPT PARA PERMITIR LA IMPRESION DE LA HOJA DE TRABAJO
//*****************************************************************************
function imprimirHojaTrabajo(control, contextPath) {
    var idProcesoLab=0;
    for(i=0;i<control.length;i++){
        if(control[i].checked){ 
            idProcesoLab=control[i].value;
        }
    }
    
    if(idProcesoLab==0){
        if(eval('document.BusquedaProcesoLaboratorioForm.idProcesoLaboratorioModificar.checked')){
            idProcesoLab=eval('document.BusquedaProcesoLaboratorioForm.idProcesoLaboratorioModificar.value');
        }
    }
    if(idProcesoLab==0){
        alert('Debe seleccionar el proceso al cúal desea imprimirle la hoja de trabajo.')
    }else{
        popup(contextPath+'/formatos/hojaTrabajoGenetica.jsp?idProcesoLaboratorio='+idProcesoLab,'HojaTrabajo',770,800,'scrollbars=yes');
    }
}
//*******************************************************************************************
// FUNCION JAVASCRIPT PARA CONTROLAR EL INGRESO DEL NÚMERO DOCUMENTO POR MEDIO DEL TIPO
// DOCUMENTO
//********************************************************************************************
function controlNumeroDocumentoPorTipoDocumento(tipoDocumento, form) {
    if (tipoDocumento==3 || tipoDocumento==6){
        eval("document." + form + ".numeroDocumento.value='NA'");
        eval('document.' + form + '.numeroDocumento.disabled=true');
        if(form=='InasistenciaCitacionPersonaForm'){
            eval('document.' + form + '.nombres.focus()');
        }
    }else{             
        eval("document." + form + ".numeroDocumento.value=''");
        eval('document.' + form + '.numeroDocumento.disabled=false');
        eval("document." + form + ".numeroDocumento.focus()");
    }
}
//*******************************************************************************************
// FUNCION JAVASCRIPT PARA CONTROLAR EL REGISTRO DE CITACIONES A TODO EL GRUPO DE PERSONAS
// ASOCIADAS AL CASO
//********************************************************************************************
function citarGrupoCompleto(tipoAccion, citarGrupoFamiliar) {
    if ( citarGrupoFamiliar=='N' ){              
        if (tipoAccion=="Guardar"){               
            eval("window.opener.document.forms[0].tipoAccion.value='Guardar'");  
        }else{               
            eval("window.opener.document.forms[0].tipoAccion.value='GuardarContinuar'");  
        }      
        eval("window.opener.document.forms[0].aceptaMensajeCancelar.value=true");
        window.setTimeout("window.opener.document.forms[0].submit();self.close();", 0);
    }else{            
        if (tipoAccion=="Guardar"){               
            eval("window.opener.document.forms[0].tipoAccion.value='Guardar'");  
        }else{               
            eval("window.opener.document.forms[0].tipoAccion.value='GuardarContinuar'");  
        }         
        eval("window.opener.document.forms[0].aceptaMensaje.value=true");
        window.setTimeout("window.opener.document.forms[0].submit();self.close();", 0);
    }
}
//******************************************************************************
//FUNCION QUE MUESTRA LOS CAMPOS DE DETALLE PARA LOS ELEMENTOS CUYA CLASIFICACION ES 
//EMP (ELEMENTO MATERIAL PROBATORIO)
//*****************************************************************************
function ocultarFilasElementoCasoGenetica(clasificacion, fechaCreaEvidencia, formulario) {
    if(clasificacion=='E'){
        mostrarFilas('filaEMP');
        mostrarFilas('filaFechaCreacion');  
        document.getElementById('filaEMP1').className='';
        document.getElementById('filaEMP2').className='';
        document.getElementById('filaEMP3').className='banding';
        document.getElementById('filaFechaCreacion').className='banding';
        
        var consecutivoRadicado=eval('document.'+formulario+'.consecutivoRadicado.value');
        var codigoPersona=eval('document.'+formulario+'.codigoPersona.value');
        
        consultarFechaCitaTomaMuestra(consecutivoRadicado,codigoPersona, formulario, 'fechaCreaEvidencia', fechaCreaEvidencia);
        
    }else{
        ocultarFilas('filaFechaCreacion');
        
        document.getElementById('filaEMP1').className='';
        document.getElementById('filaEMP2').className='';
        document.getElementById('filaEMP3').className='';
    }
}
//******************************************************************************
//FUNCION QUE PERMITE CARGAR EL NOMBRE DE UN ARCHIVO DE CARGA
//*****************************************************************************
function cargarNombreArchivo(nombreArchivo) {
    indice=nombreArchivo.lastIndexOf('\\');
    if(indice!=-1){
        document.CargaResultadoGeneticoForm.nombreArchivo.value=nombreArchivo.substr(indice+1);
        document.CargaResultadoGeneticoForm.nombreArchivoAux.value=nombreArchivo.substr(indice+1);
    }
}
//****************************************************************
// CONTROLA EL USO DE FORMATO EN EL CAMPO
//***************************************************************
function campoFormato(campo, formato) {
    if (campo.value == '') {
        campo.value = formato;
    }
}
function limpiaFormato(campo, formato) {
    if (campo.value == formato) {
        campo.value = '';
    }
}
//******************************************************************************
//FUNCION QUE MUESTRA LOS CAMPOS DE DETALLE PARA LA CRACION DE PLANILLAS
//*****************************************************************************
function ocultarFilasTipoPlanilla(tipoPlanilla, tipoEntrega) {
    if(tipoPlanilla!='EI' && tipoPlanilla!='ED' && tipoPlanilla!='-1'){
        mostrarFilas('filaTipoPlanilla');
        ocultarFilas('filaTipoPlanillaInterna');
        if(tipoEntrega!='E' && tipoEntrega!='P'){
            document.forms[0].tipoEntrega.value="-1";
        }else{
            document.forms[0].tipoEntrega.value=tipoEntrega;
        }
    }else{
        tipoEntrega="-1";
        document.forms[0].tipoEntrega.value=tipoEntrega;
        ocultarFilas('filaTipoPlanilla');
        mostrarFilas('filaTipoPlanillaInterna');
    }
    
    ocultarFilasTipoEntregaPlanilla(tipoEntrega);
}
function ocultarFilasTipoEntregaPlanilla(tipoEntrega) {
    if(tipoEntrega=='P'){
        mostrarFilas('filaEntregaPersonal');
        document.getElementById('filaEntregaPersonal').className='banding';
        ocultarFilas('filaEntregaEmpresa');
    }else if(tipoEntrega=='E'){
        ocultarFilas('filaEntregaPersonal');
        mostrarFilas('filaEntregaEmpresa');
    }else{
        ocultarFilas('filaEntregaPersonal');
        ocultarFilas('filaEntregaEmpresa');
    }
}
//******************************************************************************
//FUNCION QUE MUESTRA LOS CAMPOS DEL CONVENIO EN LA PANTALLA DE REGISTO DEL CASO DE GENETICA
//*****************************************************************************
function ocultarFilasConvenio(clasificacion, tipoCaso) {
    if(clasificacion=='F'){
        mostrarFilas('filaDatosConvenio');
    }else{
        ocultarFilas('filaDatosConvenio');
    }
}
//******************************************************************************
//FUNCION QUE MUESTRA LOS CAMPOS DE LA FECHA DE LA TOMA DE MUESTRA
//*****************************************************************************
function ocultarFilasFechaTomaMuestra(clasificacion, codigoPersona, forma, fechaCreaEvidencia, consecutivoEvidencia) {
            
    if(clasificacion=='E' && codigoPersona!=-1){
        mostrarFilas('filaFechaCreacion');
        document.getElementById('filaFechaCreacion').className='banding';
        document.getElementById('filaEMP3').className='';
        
        var consecutivoRadicado=eval('document.'+forma+'.consecutivoRadicado.value');
        consultarFechaCitaTomaMuestra(consecutivoRadicado,codigoPersona, 'ElementoCasoGeneticaForm', 'fechaCreaEvidencia', fechaCreaEvidencia); 
        
    }else if(clasificacion=='E'){
        document.getElementById('filaEMP3').className='';
    }else{
        ocultarFilas('filaFechaCreacion');
        
        document.getElementById('filaEMP3').className='banding';
        if(codigoPersona!=-1){            
            document.getElementById('filaEMP1').className='';
        }
    }
    
    if(clasificacion=='E'){
        if(consecutivoEvidencia==0){
            eval("document."+forma+".nivelSeguridad.value='Embalado y Rotulado'");
            indice=calcularIndiceValorSelect(forma, 'tieneCadenaCustodia', 'S');
            eval("document."+forma+".nivelSeguridad.value='Embalado y Rotulado'");
            eval('document.'+forma+'.tieneCadenaCustodia.options['+indice+'].selected=true');   
            
        }
    }else{
        if(clasificacion=='C' && consecutivoEvidencia==0){
            indice=calcularIndiceValorSelect(forma, 'tieneCadenaCustodia', 'N');
            eval("document."+forma+".nivelSeguridad.value='SIN'");
            eval('document.'+forma+'.tieneCadenaCustodia.options['+indice+'].selected=true');        
        }
    }
}
//******************************************************************************
//FUNCION QUE CONTROLA EL TIPO DE PRIORIDAD, SI ES "N" SE PONE EN NORMAL = 0
// Y SE BLOQUEA, SI ES "S" SE PONE EN SELECCIONE = -1 PARA QUE EL USUARIO ESCOJA LA PRIORIDAD
//*****************************************************************************
function controlCasoPrioridad(casoPrioritario, forma) {
    if(casoPrioritario=='S'){       
        eval('document.'+forma+'.codigoTipoPrioridad.value=-1');   
        eval('document.'+forma+'.codigoTipoPrioridad.disabled=false');  
        document.getElementById("prioridadRequerida").innerHTML ='*';
    }else{
        eval('document.'+forma+'.codigoTipoPrioridad.value=0');   
        eval('document.'+forma+'.codigoTipoPrioridad.disabled=true');   
        document.getElementById("prioridadRequerida").innerHTML ='';
    }    
}
//******************************************************************************
//FUNCION QUE CONTROLA LA SELECCION DE TIPO DE ENTREGA EN LAS PLANILLAS DE ENVIO 
//EXTERNO POR EMPRESA DE CORREO
//*****************************************************************************
function seleccionarTipoEntregaTodos(forma, tipoEntrega) {
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements['+i+'].type') == "select-one"){
            var nombreCampo=(eval('document.'+forma+'.elements['+i+'].name'))
            if(nombreCampo.indexOf('propertyTipoTarifa')!=-1){
                if(tipoEntrega=='N'){
                    eval('document.'+forma+'.elements['+i+'].options[0].selected=true');         
                }else if(tipoEntrega=='E'){
                    eval('document.'+forma+'.elements['+i+'].options[1].selected=true'); 
                }            
            }
        }
    }
}
function calcularIndiceValorSelect(nombreForma, nombreCampo, valorIndice){
    var tamano = eval('document.'+nombreForma+'.'+nombreCampo+'.length');
    if (tamano>0) {
        for (j=0; j<= tamano-1; j++){
            opcion= eval('document.'+nombreForma+'.'+nombreCampo+'.options['+j+'].value');
            if(opcion==valorIndice){ 
                return j;       
            }
        }
    }
    return 0;
}
//******************************************************************************
//FUNCION QUE CONTROLA LA SELECCION DEL SEGUNDO PERITO ANALISTA EN CONCLUSION GENETICA
//*****************************************************************************
function seleccionarSegundoPeritoAnalista(campo){  
    
    if(campo.checked==true){            
        mostrarFilas('filaInterpretacion');   
        mostrarFilas('filaConclusion');   
        mostrarFilas('filaMetodologia');   
        mostrarFilas('filaSegundoPeritoAnalista');   
        document.getElementById('filaSegundoPeritoAnalista').className=''; 
        document.getElementById('filaInterpretacion').className='banding';     
        document.getElementById('filaConclusion').className='';   
        document.getElementById('filaMetodologia').className='banding';         
    }else  if(campo.checked==false){   
        ocultarFilas('filaSegundoPeritoAnalista');
        mostrarFilas('filaInterpretacion');   
        mostrarFilas('filaConclusion');   
        mostrarFilas('filaMetodologia'); 
        document.getElementById('filaSegundoPeritoAnalista').className=''; 
        document.getElementById('filaInterpretacion').className='';     
        document.getElementById('filaConclusion').className='banding';   
        document.getElementById('filaMetodologia').className='';   
    }  
}
function ocultarFilasRevisorTutor(checkSegundoRevisor) {
    
    if(checkSegundoRevisor==true){            
        mostrarFilas('filaInterpretacion');   
        mostrarFilas('filaConclusion');   
        mostrarFilas('filaMetodologia');   
        mostrarFilas('filaSegundoPeritoAnalista');   
        document.getElementById('filaSegundoPeritoAnalista').className=''; 
        document.getElementById('filaInterpretacion').className='banding';     
        document.getElementById('filaConclusion').className='';   
        document.getElementById('filaMetodologia').className='banding';         
    }else if(checkSegundoRevisor==false){     
        ocultarFilas('filaSegundoPeritoAnalista');
        mostrarFilas('filaInterpretacion');   
        mostrarFilas('filaConclusion');   
        mostrarFilas('filaMetodologia'); 
        document.getElementById('filaInterpretacion').className='';     
        document.getElementById('filaConclusion').className='banding';   
        document.getElementById('filaMetodologia').className='';   
        document.getElementById('filaSegundoPeritoAnalista').className='banding'; 
    }     
}
//************************************************************************************
//FUNCION QUE CONTROLA LA IMAGEN DE CARGA DEL ARCHIVO TXT
//************************************************************************************
function CargarFoto(fecha,analizador,kit,sistemaGenotyper,sistemaGenemapper,sistemaYFiler,sistemaYplex,observacion,nombreArchivo){
    
    if(fecha!='dd/mm/aaaa hh:mm' && analizador!='-1' && kit!='-1' && (sistemaGenotyper!=false || sistemaGenemapper!=false || sistemaYFiler!=false || sistemaYplex!=false) && observacion!=""){          
        mostrarFilas('waitDiv');      
        document.CargaResultadoGeneticoForm.nombreArchivoAux.value=nombreArchivo;  
        document.CargaResultadoGeneticoForm.tipoAccion.value="Guardar";  
        document.CargaResultadoGeneticoForm.submit();   
    }else{    
        ocultarFilas('waitDiv');      
        document.CargaResultadoGeneticoForm.tipoAccion.value="Guardar";  
        document.CargaResultadoGeneticoForm.submit();  
    }              
}
function ocultarImagenCargaArchivo(control) {  
    if(control==true ){
        ocultarFilas('waitDiv');   
    }
}
//**********************************************************************
//FUNCION QUE PERMITE CREAR EL CONSECUTIVO DEL NÚMERO ELEMENTO PARA SER
//AGREGADO AL ROTULO E IDENTIFICAR EL NUMERO DEL ELEMENTO 
//**********************************************************************
function numeroElementoAsistenteRegistro(numeroEvidencia, codigoPersona) {     
    document.AsistenteRegistroForm.numeroEvidencia.value=numeroEvidencia;  
    document.AsistenteRegistroForm.tipoAccion.value="Filtrar";  
    document.AsistenteRegistroForm.submit();
}
//*****************************************************************************
//FUNCION  QUE REALIZA UN RECORRIDO POR TODOS LOS ELEMENTOS DEL FORMULARIO,
//EN EL RECORRIDO COMPRUEBA SI EL ELEMENTO ACTUAL ES DE TIPO RADIOBUTTON Y EN ESTE CASO,
//SIMPLEMENTE SE ACTUALIZA EL ATRIBUTO CHECKED AL VALOR 1, CON LO QUE EL CHECKBOX SE
//MARCARÁ
//*****************************************************************************
function seleccionarCriteriosRevision(forma, campo, valor){
    
    if(campo.checked==true){
        seleccionar_todo_radio(forma, valor);
    }else{
        deseleccionar_todo_radio(forma, valor);
    }
}
function seleccionar_todo_radio(forma, valor){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        if(eval('document.'+forma+'.elements[i].type') == "radio"){
            var valorRadio=eval('document.'+forma+'.elements[i].value')
            if(valorRadio==valor){
                eval('document.'+forma+'.elements[i].checked=1');
            }
        }
    }
}
function deseleccionar_todo_radio(forma, valor){
    var numeroElementos=eval('document.'+forma+'.elements.length'); 
    for (i=0;i<numeroElementos;i++){
        var valorRadio=eval('document.'+forma+'.elements[i].value')
        if(valorRadio==valor){
            eval('document.'+forma+'.elements[i].checked=1');
        }
    }
} 