//**********************************************************
// 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
//**********************************************************
var ventana=null;
function abrirVentanaEmergente() {
    var args=abrirVentanaEmergente.arguments;
    if(args.length==0)
        ventana=window.open('');
    else if(args.length==1)
        ventana=window.open(args[0]);
    else if(args.length==2)
        ventana=window.open(args[0],args[1]);
    else if(args.length==3)
        ventana=window.open(args[0],args[1],args[2]);
    chequearVentanaCerrada();
}
function chequearVentanaCerrada() {
    if(window.closed)
        ventana=null;
    else
        setTimeout('chequearVentanaCerrada()','3000');
}
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();
}
function verFeto(selObj,restore) {
    if(selObj.options[selObj.selectedIndex].value!=0){
        if(screen.width){
            var winl = (screen.width-605)/2;
            var wint = (screen.height-320)/2;
        } else {
            winl = 0;wint =0;
        }
        if (winl < 0) winl = 0;
        if (wint < 0) wint = 0;
        var settings = 'height=320';
        settings += 'width=605,';
        settings += 'top=' + wint + ',';
        settings += 'left=' + winl + ',';
        settings += 'scrollbars=yes';
        win = window.open('informacionFeto.jsp','ventana',settings);
        win.window.focus();
        if (restore) selObj.selectedIndex=0;
    }
}
//**********************************************************
// FULL SCREEN POPUP WINDOW
//**********************************************************
function fullScreen() {
    window.open('main/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();
}
//**********************************************************
// 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;
    }
}
//**********************************************************
// FORM TEXT FIELD CLEANER
//**********************************************************
function borrar() {
    document.contacto.nombres.value = "";
    document.contacto.apellidos.value = "";
    document.contacto.empresa.value = "";
    document.contacto.telefono.value = "";
    document.contacto.email.value = "";
    document.contacto.mensaje.value = "";
}
//***********************************************************
//FORMATO DE FECHA
//*************************************************************
<!-- Original:  Richard Gorremans(RichardG@spiritwolfx.com) -->
<!-- Web Site:  http://www.spiritwolfx.com -->
    
    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->
        
        <!-- Begin
        // Check browser version
        var isNav4 = false, isNav5 = false, isIE4 = false
        var strSeperator = "/"; 
var strSeparatorHour = ":";
// If you are using any Java validation on the back side you will want to use the / because 
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 3; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy
var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.
var err = 0; // Set the error code to a default of zero
if(navigator.appName == "Netscape") {
    if (navigator.appVersion < "5") {
        isNav4 = true;
        isNav5 = false;
    }
    else
        if (navigator.appVersion > "4") {
            isNav4 = false;
            isNav5 = true;
        }
}
else {
    isIE4 = true;
}
function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {
    vDateType = dateType;
    // vDateName = object name
    // vDateValue = value in the field being checked
    // e = event
    // dateCheck 
    // True  = Verify that the vDateValue is a valid date
    // False = Format values being entered into vDateValue only
    // vDateType
    // 1 = mm/dd/yyyy
    // 2 = yyyy/mm/dd
    // 3 = dd/mm/yyyy
    //Enter a tilde sign for the first number and you can check the variable information.
    if (vDateValue == "~") {
        alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
        vDateName.value = "";
        vDateName.focus();
        return true;
    }
    var whichCode = (window.Event) ? e.which : e.keyCode;
    // Check to see if a seperator is already present.
    // bypass the date if a seperator is present and the length greater than 8
    if (vDateValue.length > 8 && isNav4) {
        if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
            return true;
    }
    //Eliminate all the ASCII codes that are not valid
    var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
    if (alphaCheck.indexOf(vDateValue) >= 1) {
        if (isNav4) {
            vDateName.value = "";
            vDateName.focus();
            vDateName.select();
            return false;
        }
        else {
            vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
            return false;
        }
    }
    if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
        return false;
    else {
        //Create numeric string values for 0123456789/
        //The codes provided include both keyboard and keypad values
        var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
        if (strCheck.indexOf(whichCode) != -1) {
            if (isNav4) {
                if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {
                    alert("Fecha inválida\nPor favor digitarla de nuevo.");
                    vDateName.value = "";
                    vDateName.focus();
                    vDateName.select();
                    return false;
                }
                if (vDateValue.length == 6 && dateCheck) {
                    var mDay = vDateName.value.substr(2,2);
                    var mMonth = vDateName.value.substr(0,2);
                    var mYear = vDateName.value.substr(4,4)
                    //Turn a two digit year into a 4 digit year
                    if (mYear.length == 2 && vYearType == 4) {
                        var mToday = new Date();
                        //If the year is greater than 30 years from now use 19, otherwise use 20
                        var checkYear = mToday.getFullYear() + 30; 
                        var mCheckYear = '20' + mYear;
                        if (mCheckYear >= checkYear)
                            mYear = '19' + mYear;
                        else
                            mYear = '20' + mYear;
                    }
                    var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
                    if (!dateValid(vDateValueCheck)) {
                        alert("Fecha inválida\nPor favor digitarla de nuevo.");
                        vDateName.value = "";
                        vDateName.focus();
                        vDateName.select();
                        return false;
                    }
                    return true;
                }
                else {
                    // Reformat the date for validation and set date type to a 1
                    if (vDateValue.length >= 8  && dateCheck) {
                        if (vDateType == 1) // mmddyyyy
                        {
                            var mDay = vDateName.value.substr(2,2);
                            var mMonth = vDateName.value.substr(0,2);
                            var mYear = vDateName.value.substr(4,4)
                            vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
                        }
                        if (vDateType == 2) // yyyymmdd
                        {
                            var mYear = vDateName.value.substr(0,4)
                            var mMonth = vDateName.value.substr(4,2);
                            var mDay = vDateName.value.substr(6,2);
                            vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
                        }
                        if (vDateType == 3) // ddmmyyyy
                        {
                            var mMonth = vDateName.value.substr(2,2);
                            var mDay = vDateName.value.substr(0,2);
                            var mYear = vDateName.value.substr(4,4)
                            vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
                        }
                        //Create a temporary variable for storing the DateType and change
                        //the DateType to a 1 for validation.
                        var vDateTypeTemp = vDateType;
                        vDateType = 1;
                        var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
                        if (!dateValid(vDateValueCheck)) {
                            alert("Fecha inválida\nPor favor digitarla de nuevo.");
                            vDateType = vDateTypeTemp;
                            vDateName.value = "";
                            vDateName.focus();
                            vDateName.select();
                            return false;
                        }
                        vDateType = vDateTypeTemp;
                        return true;
                    }
                    else {
                        if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
                            alert("Fecha inválida\nPor favor digitarla de nuevo.");
                            vDateName.value = "";
                            vDateName.focus();
                            vDateName.select();
                            return false;
                        }
                    }
                }
            }
            else {
                // Non isNav Check
                if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
                    alert("Fecha inválida\nPor favor digitarla de nuevo.");
                    vDateName.value = "";
                    vDateName.focus();
                    return true;
                }
                // Reformat date to format that can be validated. mm/dd/yyyy
                if (vDateValue.length >= 8 && dateCheck) {
                    // Additional date formats can be entered here and parsed out to
                    // a valid date format that the validation routine will recognize.
                    if (vDateType == 1) // mm/dd/yyyy
                    {
                        var mMonth = vDateName.value.substr(0,2);
                        var mDay = vDateName.value.substr(3,2);
                        var mYear = vDateName.value.substr(6,4)
                    }
                    if (vDateType == 2) // yyyy/mm/dd
                    {
                        var mYear = vDateName.value.substr(0,4)
                        var mMonth = vDateName.value.substr(5,2);
                        var mDay = vDateName.value.substr(8,2);
                    }
                    if (vDateType == 3) // dd/mm/yyyy
                    {
                        var mDay = vDateName.value.substr(0,2);
                        var mMonth = vDateName.value.substr(3,2);
                        var mYear = vDateName.value.substr(6,4)
                    }
                    if (vYearLength == 4) {
                        if (mYear.length < 4) {
                            alert("Fecha inválida\nPor favor digitarla de nuevo.");
                            vDateName.value = "";
                            vDateName.focus();
                            return true;
                        }
                    }
                    // Create temp. variable for storing the current vDateType
                    var vDateTypeTemp = vDateType;
                    // Change vDateType to a 1 for standard date format for validation
                    // Type will be changed back when validation is completed.
                    vDateType = 1;
                    // Store reformatted date to new variable for validation.
                    var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
                    if (mYear.length == 2 && vYearType == 4 && dateCheck) {
                        //Turn a two digit year into a 4 digit year
                        var mToday = new Date();
                        //If the year is greater than 30 years from now use 19, otherwise use 20
                        var checkYear = mToday.getFullYear() + 30; 
                        var mCheckYear = '20' + mYear;
                        if (mCheckYear >= checkYear)
                            mYear = '19' + mYear;
                        else
                            mYear = '20' + mYear;
                        vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
                        // Store the new value back to the field.  This function will
                        // not work with date type of 2 since the year is entered first.
                        if (vDateTypeTemp == 1) // mm/dd/yyyy
                            vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
                        if (vDateTypeTemp == 3) // dd/mm/yyyy
                            vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
                    } 
                    if (!dateValid(vDateValueCheck)) {
                        alert("Fecha inválida\nPor favor digitarla de nuevo.");
                        vDateType = vDateTypeTemp;
                        vDateName.value = "";
                        vDateName.focus();
                        return true;
                    }
                    vDateType = vDateTypeTemp;
                    return true;
                }
                else {
                    if (vDateType == 1) {
                        if (vDateValue.length == 2) {
                            vDateName.value = vDateValue+strSeperator;
                        }
                        if (vDateValue.length == 5) {
                            vDateName.value = vDateValue+strSeperator;
                        }
                    }
                    if (vDateType == 2) {
                        if (vDateValue.length == 4) {
                            vDateName.value = vDateValue+strSeperator;
                        }
                        if (vDateValue.length == 7) {
                            vDateName.value = vDateValue+strSeperator;
                        }
                    } 
                    if (vDateType == 3) {
                        if (vDateValue.length == 2) {
                            vDateName.value = vDateValue+strSeperator;
                        }
                        if (vDateValue.length == 5) {
                            vDateName.value = vDateValue+strSeperator;
                        }
                    }
                    return true;
                }
            }
            if (vDateValue.length == 10&& dateCheck) {
                if (!dateValid(vDateName)) {
                    // Un-comment the next line of code for debugging the dateValid() function error messages
                    //alert(err);  
                    alert("Fecha inválida\nPor favor digitarla de nuevo.");
                    vDateName.focus();
                    vDateName.select();
                }
            }
            return false;
        }
        else {
            // If the value is not in the string return the string minus the last
            // key entered.
            if (isNav4) {
                vDateName.value = "";
                vDateName.focus();
                vDateName.select();
                return false;
            }
            else {
                vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
                return false;
            }
        }
    }
}
//*******************
function HourFormat(vHourName, vHourValue, e, hourCheck) {
    
    // vHourName = object name
    // vHourValue = value in the field being checked
    // e = event
    // hourCheck 
    // True  = Verify that the vHourValue is a valid date
    // False = Format values being entered into vHourValue only
    //Enter a tilde sign for the first number and you can check the variable information.
    
    if (vHourValue == "~") {
        //alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nSeparator = "+strSeperatorHour);
        vHourName.value = "";
        vHourName.focus();
        return true;
    }
    
    var whichCode = (window.Event) ? e.which : e.keyCode;
    
    // Check to see if a seperator is already present.
    // bypass the hour if a seperator is present and the length greater than 5
    if (vHourValue.length > 4 && isNav4) {
        //if (vHourValue.indexOf(":") >= 0)
        //return true;
    }
    //Eliminate all the ASCII codes that are not valid
    var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-:";
    if (alphaCheck.indexOf(vHourValue) >= 1) {
        if (isNav4) {
            vHourName.value = "";
            vHourName.focus();
            vHourName.select();
            return false;
        }
        else {
            vHourName.value = vHourName.value.substr(0, (vHourValue.length-1));
            return false;
        }
    }
    
    if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
        return false;
    else {
        //Create numeric string values for 0123456789/
        //The codes provided include both keyboard and keypad values
        var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
        if (strCheck.indexOf(whichCode) != -1) {
            if (isNav4) {
                if ((vHourValue.length != 5 && hourCheck) && (vHourValue.length >=1)) {
                    alert("Hora inválida\nPor favor digitarla de nuevo.");
                    vHourName.value = "";
                    vHourName.focus();
                    vHourName.select();
                    return false;
                }
            }
            else {
                // Non isNav Check
                if (((vHourValue.length < 3 && hourCheck) || (vHourValue.length == 4 && hourCheck)) && (vHourValue.length >=1)) {
                    alert("Hora inválida\nPor favor digitarla de nuevo.");
                    vHourName.value = "";
                    vHourName.focus();
                    return false;
                }
                
                else{
                    
                    if (vHourValue.length == 2) {
                        vHourName.value = vHourValue+strSeparatorHour;
                    }
                    
                }
                // alert("Despues de último HourValue.length == 2");
            }
            
            
        }
        else {
            // If the value is not in the string return the string minus the last
            // key entered.
            if (isNav4) {
                vHourName.value = "";
                vHourName.focus();
                vHourName.select();
                return false;
            }
            else {
                vHourName.value = vHourName.value.substr(0, (vHourValue.length-1));
                return false;
            }
        }
    }
    
    //alert("Antes de último hourCheck");
    if ((hourCheck) && (vHourValue.length > 0)){
        if (!esHora(vHourValue)) {
            // Un-comment the next line of code for debugging the dateValid() function error messages
            //alert(err);  
            vHourName.value = "";
            alert("Hora inválida\nPor favor digitarla de nuevo.");
            vHourName.focus();
            vHourName.select();
            return false;
        }
        else {
            return true;
        }
        
    }
    else{
        return false;
    }
    return true;
}
//*******************
function dateValid(objName) {
    var strDate;
    var strDateArray;
    var strDay;
    var strMonth;
    var strYear;
    var intday;
    var intMonth;
    var intYear;
    var booFound = false;
    var datefield = objName;
    var strSeparatorArray = new Array("-"," ","/",".");
    var intElementNr;
    // var err = 0;
    var strMonthArray = new Array(12);
    strMonthArray[0] = "Jan";
    strMonthArray[1] = "Feb";
    strMonthArray[2] = "Mar";
    strMonthArray[3] = "Apr";
    strMonthArray[4] = "May";
    strMonthArray[5] = "Jun";
    strMonthArray[6] = "Jul";
    strMonthArray[7] = "Aug";
    strMonthArray[8] = "Sep";
    strMonthArray[9] = "Oct";
    strMonthArray[10] = "Nov";
    strMonthArray[11] = "Dec";
    //strDate = datefield.value;
    strDate = objName;
    if (strDate.length < 1) {
        return true;
    }
    for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
        if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
            strDateArray = strDate.split(strSeparatorArray[intElementNr]);
            if (strDateArray.length != 3) {
                err = 1;
                return false;
            }
            else {
                strDay = strDateArray[0];
                strMonth = strDateArray[1];
                strYear = strDateArray[2];
            }
            booFound = true;
        }
    }
    if (booFound == false) {
        if (strDate.length>5) {
            strDay = strDate.substr(0, 2);
            strMonth = strDate.substr(2, 2);
            strYear = strDate.substr(4);
        }
    }
    //Adjustment for short years entered
    if (strYear.length == 2) {
        strYear = '20' + strYear;
    }
    strTemp = strDay;
    strDay = strMonth;
    strMonth = strTemp;
    intday = parseInt(strDay, 10);
    if (isNaN(intday)) {
        err = 2;
        return false;
    }
    intMonth = parseInt(strMonth, 10);
    if (isNaN(intMonth)) {
        for (i = 0;i<12;i++) {
            if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
                intMonth = i+1;
                strMonth = strMonthArray[i];
                i = 12;
            }
        }
        if (isNaN(intMonth)) {
            err = 3;
            return false;
        }
    }
    intYear = parseInt(strYear, 10);
    if (isNaN(intYear)) {
        err = 4;
        return false;
    }
    if (intMonth>12 || intMonth<1) {
        err = 5;
        return false;
    }
    if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
        err = 6;
        return false;
    }
    if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
        err = 7;
        return false;
    }
    if (intMonth == 2) {
        if (intday < 1) {
            err = 8;
            return false;
        }
        if (LeapYear(intYear) == true) {
            if (intday > 29) {
                err = 9;
                return false;
            }
        }
        else {
            if (intday > 28) {
                err = 10;
                return false;
            }
        }
    }
    return true;
}
function LeapYear(intYear) {
    if (intYear % 100 == 0) {
        if (intYear % 400 == 0) { return true; }
    }
    else {
        if ((intYear % 4) == 0) { return true; }
    }
    return false;
}
function EstaVacio(Dato){
    for (var i=0;i<Dato.length;i++){
        if (Dato.substring(i,i+1)!= " ")
            return(false);
    }
    return(true);
}
function posicionCursor(nombreCampo) {
    var tb = document.getElementById(nombreCampo)
    var cursor = -1;
    // IE
    if (document.selection && (document.selection != 'undefined')){
        var _range = document.selection.createRange();
        var contador = 0;
        while (_range.move('character', -1))
            contador++;
        cursor = contador;
    }
    // FF
    else if (tb.selectionStart >= 0){
        cursor = tb.selectionStart;
    }
    return cursor;
}
//***********************************************************
//   CONSULTA DE INFORMACION EXISTENTE
//***********************************************************
function consultaSolicitada(valor,restore){
    if(valor.options[valor.selectedIndex].value!=0){
        var valores = eval(valor.options[valor.selectedIndex].value);
        if (restore) valor.selectedIndex=0;
        alert(valores);
    }
    
}
//function consultaSolicitada(pagina,clase){
//alert("entro "+pagina+" "+clase);
//     document.menu.action="../servlet/co.com.sirdec.utilidades.presentation.controller.SirdecController";
//     alert("entro 1");
//     document.menu.accionSolicitada.value=clase;  
//     alert("entro 2");
//     document.menu.paginaRespuesta.value=pagina;
//     alert("entro 3");
//     document.menu.submit();
//     alert("entro 4");
//}       
function menuAcceso(selObj,restore){
    if(selObj.options[selObj.selectedIndex].value!=0){
        eval("parent.parent.contenido.location.href='"+selObj.options[selObj.selectedIndex].value+"'");
        
    }
}
//alert("variables "+pagina+" "+clase);
//  document.forma.action="../servlet/co.com.sirdec.utilidades.presentation.controller.SirdecController?paginaRespuesta="+pagina;
//  document.forma.accionSolicitada.value=clase;    
//  document.forma.submit();
//}  
//*************************************************************
// COMPARAR FECHAS
// Verificar que la fecha hasta sea mayor o igual a  la desde
//*************************************************************
function compararFechas(fechaDesde,fechaHasta){
    var a  = fechaDesde.substring(6,10);
    var mes = fechaDesde.substring(3,5);
    var dia = fechaDesde.substring(0,2);
    fechaDesde = a+mes+dia;
    var anoHasta = fechaHasta.substring(6,10);
    var mesHasta = fechaHasta.substring(3,5);
    var diaHasta = fechaHasta.substring(0,2);
    fechaHasta = anoHasta+mesHasta+diaHasta;
    if (fechaDesde<=fechaHasta){
        return(true);
    }else{
        return(false);
    }
}
//****************************************************************
//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
    }
    
}
//****************************************************************
// 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');
    }
}
//**************************************************************************
// 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;
}
//****************************************************************
// PERMITE RECARGA UNA JSP SEGUN PARAMETROS
//***************************************************************
function recarga(ruta, parametro) {
    var valorParametro = eval(parametro);
    window.location.href = ruta + valorParametro;
}
//****************************************************************
// 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 = '';
    }
}
//****************************************************************
// MUESTRA UN MENSAJE AL USUARIO
//**************************************************************
function mostrarMensaje(valor) {
    alert(valor);
}
//****************************************************************
// VALIDA EL INGRESO DE UNA DOCUMENTACION APORTADA CON O SIN IMAGEN ADJUNTA
//**************************************************************
function validarRegistro(tipoAccion) {     
    var entrar = confirm("¿No ha adjuntado la imagen, aún así desea registrar este documento?");
    if ( !entrar ){      
        indice=calcularIndice('DocumentacionAportadaForm', 'codigoTipoDocumento',-1);
        eval("document.DocumentacionAportadaForm.codigoTipoDocumento.value=-1");
        eval("document.DocumentacionAportadaForm.observacion.value='ND'");
        eval('document.DocumentacionAportadaForm.codigoTipoDocumento.options['+indice+'].selected=true');    
        history.forward();                          
    }else{            
        if (tipoAccion=="Adicionar"){               
            eval("document.DocumentacionAportadaForm.tipoAccion.value='Adicionar'");  
        }else{               
            eval("document.DocumentacionAportadaForm.tipoAccion.value='Actualizar'");  
        }         
        eval("document.DocumentacionAportadaForm.aceptaMensaje.value=true");
        eval("document.DocumentacionAportadaForm.submit()"); 
        history.forward();  
    }      
}
//****************************************************************
// VALIDA EL INGRESO DE UNA DOCUMENTACION APORTADA CON O SIN IMAGEN ADJUNTA
//**************************************************************
function copiarEvidencia() {
    cantidadCopia=prompt("Por favor ingrese la cantidad de copias que \n desea realizar de la evidencia, valores entre 1 y 50.","")    
    if(cantidadCopia!=null && cantidadCopia!=0){   
        var numeros=new Array();
        var mensajeNoNumerico;
        for(i=0;i<cantidadCopia.length;i++){
            numeros[i]=cantidadCopia.charCodeAt(i);   
            if ( numeros[i] > 31 && ( numeros[i] < 48 ||  numeros[i] > 57)) { // Chequeamos que sea un numero comparandolo con los valores ASCII      
                mensajeNoNumerico="La cantidad esta expesada en letras, por favor ingrese numeros"
            }       
        }
        if (mensajeNoNumerico!=null){
            alert(mensajeNoNumerico);
        }else{
            if(cantidadCopia <= 50){ 
                eval("document.EvidenciaCadaverForm.cantidadCopiaEvidencia.value=cantidadCopia");                 
                eval("document.EvidenciaCadaverForm.tipoAccion.value='CopiarEvidencia'");   
                eval("document.EvidenciaCadaverForm.mensajeCantidadCopias.value=true");
                eval("document.EvidenciaCadaverForm.submit()"); 
                history.forward();  
            }else{
                alert("La cantidad de copias es demasiado grande, por favor redusca la cantidad");
            }
        } 
    } else{
        history.forward();
    }     
}
//****************************************************************
// VALIDA EL INGRESO DE UNA DOCUMENTACION APORTADA CON O SIN IMAGEN ADJUNTA
//**************************************************************
function anularRegistro() {     
    var entrar = confirm("Se ha especificado que el cadáver ya no es Donante de Órganos o no presenta Signos de Maltrato. Los registros asociados se eliminarán. Esta seguro de realizar el cambio a la información? ");
    if ( !entrar ){      
        eval("document.NecropsiaForm.tipoAccion.value=''");    
        eval("document.DocumentacionAportadaForm.aceptaMensaje.value=false");
        eval("document.DocumentacionAportadaForm.submit()");                           
    }else{
        eval("document.NecropsiaForm.tipoAccion.value='Aceptar'");    
        eval("document.NecropsiaForm.aceptaMensaje.value=true");
        eval("document.NecropsiaForm.submit()");   
    }
}
//****************************************************************
// VALIDA LA MODIFICACION DE LA FECHA DEL HECHO (COSO MULTIPLE), PARA INDICARLKE AL USUARIO QUE SI 
// ES MODIFICADA SE MODIFICARAN LAS FEHCAS DE REGISTRO DE LOS CADÁVERES O DESAPRECIDOS QUE 
// ESTE ASOCIADOS A ESE CASO
//**************************************************************
function validarCambioCasoMultiple(){
    valor=confirm('Si modifica la fecha del hecho, automáticamente se modificará la fecha' +
    ' de desaparición de aquellos desaparecidos asosiados a este caso múltiple. ¿Desea continuar?');
    if(valor==true){
        eval("document.CasoMultipleForm.aceptaMensaje.value=true");
        eval("document.CasoMultipleForm.tipoAccion.value='Actualizar'"); 
        eval("document.CasoMultipleForm.submit()");           
    }
}   
//****************************************************************
// VALIDA EL CANCELAMIENTO DE UN DOCUMENTO APORTADO, ES DECIR PONE 
// EL CAMPO ACTIVO EN "N"
//**************************************************************
function documentoCancelado() {     
    var entrar = confirm("¿Esta seguro de realizar el proceso de cancelación del documento seleccionado?");
    if ( !entrar ){      
        history.forward();                          
    }else{               
        eval("document.DocumentacionAportadaForm.tipoAccion.value='CancelarDocumento'");                  
        eval("document.DocumentacionAportadaForm.aceptaMensajeCancelar.value=true");
        eval("document.DocumentacionAportadaForm.submit()"); 
        history.forward();  
    }      
}
//****************************************************************
// MUESTRA UNA AYUDA PARA EL INGRESO DE FECHAS
//***************************************************************
function show_calendar() {
        /* 
                p_month : 0-11 for Jan-Dec; 12 for All Months.
                p_year	: 4-digit year
                p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
                p_item	: Return Item.
         */
    
    p_item = arguments[0];
    if (arguments[1] == null)
        p_month = new String(gNow.getMonth());
    else
        p_month = arguments[1];
    if (arguments[2] == "" || arguments[2] == null)
        p_year = new String(gNow.getFullYear().toString());
    else
        p_year = arguments[2];
    if (arguments[3] == null)
        p_format = "DD/MM/YYYY";
    else
        p_format = arguments[3];
    
    Build(p_item, p_month, p_year, p_format);
}
//****************************************************************
// FUNCIONES PARA CONTROLAR EL TIEMPO DE INACTIVIDAD DE UNA SESSION
//***************************************************************
var numero;
var valor;
function tiempo(dato){
    dato1=(dato*1)+(120000*1);
    setTimeout("abreVentana(1);",dato);
    setTimeout("salir(1);",dato1);
}
function abreVentana(numero){
    if(numero==1){
        MM_openBrWindow('../main/avisoInactividad.jsp','Descripcion','width=300,height=162')
        numero=2;
    }
}
function salir(numero){
    if(numero==1){
        response.redirect("../main/sistema.jsp") 
        numero=2;
    }
}
function MM_openBrWindow(theURL,winName,features) { 
    window.open(theURL, winName, features);
}
//****************************************************************
// 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 CONTROLAR EL INGRESO DE LETRAS SOLO EN MAYUSCULAS
//***************************************************************
function upperCase(obj){
    obj.value=obj.value.toUpperCase()
}
//****************************************************************
// FUNCION PARA CONTROLAR EL INGRESO DE NUMEROS DECIMALES
//***************************************************************
function decimal(campo) {
    punto=false;
    val = campo.value
    var key=event.keyCode;//codigo de tecla.
    for(z=0;z<val.length;z++){
        if(val.charAt(z)=='.'){
            punto=true;
        }	
    }
    
    if ((key < 48 || key > 57) && key!=46) {//si no es numero 
        window.event.keyCode=0;//anula la entrada de texto.
    }
    
    // no deja introducir mas de una coma.
    if (key == 46) {
        if (punto==false) { 
            punto=true;
        } else {
            window.event.keyCode=0;
            return false;
        }
    }
}
//***************************************************************************
// FUNCION PARA CONTROLAR EL INGRESO DE NUMEROS DECIMALES CON UNA PRECISION
// ESPECIFICA
//**************************************************************************
var borrarCampo="false";
function decimal(campo,precision) {
    punto=false;
    if(borrarCampo=="true"){
        campo.value='';
        borrarCampo="false";
    }
    
    val = campo.value
    var key=event.keyCode;//codigo de tecla.
    
    for(z=0;z<val.length;z++){
        if(val.charAt(z)=='.'){
            punto=true;
        }	
    }
    
    if ((key < 48 || key > 57) && key!=46) {//si no es numero 
        window.event.keyCode=0;//anula la entrada de texto.
    }else if(key!=46){
        if(punto==true){
            index=val.lastIndexOf('.')
            val2=val.substring(index,val.length)  
            if((val2.length)>precision){
                window.event.keyCode=0;
                return false;
            }
        }
    }
    
    // no deja introducir mas de una coma.
    if (key == 46) {
        if (punto==false) { 
            punto=true;
        } else {
            window.event.keyCode=0;
            return false;
        }
    }
}
function limpiarCampo() {
    borrarCampo="true";
}
//****************************************************************
// FUNCION PARA CONTROLAR EL INGRESO DE NUMEROS
//***************************************************************
function entero(campo){
    var key=event.keyCode;//codigo de tecla.
    //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 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);
        alert(c);
        if(c=='.'){
            numeroPuntos++;
            if(numeroPuntos==2){
                return false;
            }
        }else if (caracteresValidos.indexOf(c) == -1) {
            return false;
        }
    }
    return true;
}
//****************************************************************
// FUNCION PARA ADICIONAR CEROS A LA IZQUIERDA DE UN VALOR
//***************************************************************
function cerosIzquierda(valor,maxlength){
    valor=valor.value
    var mlength=parseInt(maxlength);   
    if (valor.length>mlength) {  
        return campo.substring(0,mlength);
    }    
    while (valor.length<mlength)    
        valor="0"+valor;       
    return valor;
}
//  End -->
//****************************************************************
// FUNCION PARA PARA DIGITAR EN UN CAMPO LETRAS Y NUMERO
//***************************************************************
function alfanumerico(s) {   
    var i;
    var cadena="";
    var cadena1="";
    for (i = 0; i < s.length; i++){   
        var c = s.charCodeAt(i);
        if (!isCaracter(c)){
            cadena+=s.charAt(i);
        }
        cadena1=cadena;
    }
    return cadena1;
}
// valida que el texto no tenga caracter especial
function isCaracter(c){
    return ((c > 0 && c < 48) || (c > 57 && c < 65) || (c > 90 && c < 97) || c > 122)
}
//****************************************************************
// VALIDA QUE EL TEXTO NO TENGA CARACTERES ESPECIALES
//***************************************************************
function validarCaracteresEspeciales(texto, upperCase){
    valor=texto.value;
    if(upperCase=='true'){
        valor=valor.toUpperCase();
    }
    var cadena1="";
    var cadena="";
    for (i = 0; i < valor.length; i++){   
        var c = valor.charCodeAt(i);
        if ((c > 64 && c < 91) || (c > 96 && c < 123) || (c > 47 && c < 58) || c==32 || c==209 ){
            cadena+=valor.charAt(i);
        }
        cadena1=cadena;
    }
    texto.value=cadena1;
}
function validarTextoSinCaracteresEspeciales(texto, upperCase){
    valor=texto.value;
    if(upperCase=='true'){
        valor=valor.toUpperCase();
    }
    var cadena1="";
    var cadena="";
    for (i = 0; i < valor.length; i++){   
        var c = valor.charCodeAt(i);
        if ((c > 64 && c < 91) || (c > 96 && c < 123) || (c > 47 && c < 58) || c==32 || c==209 ){
            cadena+=valor.charAt(i);
        }
        cadena1=cadena;
    }
    texto.value=cadena1;
}
//****************************************************************
// VALIDA QUE EL TEXTO NO TENGA CARACTERES ESPECIALES
//***************************************************************
function validarCaracteresEspecialesSiipf(texto, upperCase){
    valor=texto.value;
    if(upperCase=='true'){
        valor=valor.toUpperCase();
    }
}
function esNumero(valor){
    var i;
    var cadena="";
    var cadena1="";
    for (i = 0; i < valor.length; i++){   
        var c = valor.charCodeAt(i);
        if (c >= 48 && c <= 57){
            cadena+=valor.charAt(i);
        }
        cadena1=cadena;
    }
    return cadena1;
}
//******************************************************************************
// FUNCIONES PARA FILTRAR LAS LISTAS DE VALORES MORFOLOGICOS DE LA PANTALLA DE 
// INFORMACION MORFOLOGICA
//******************************************************************************
var req; 
var valorMorfologico;
var codigoMorfologico;
function filtrarDescripcionMorfologica(codigoMorfologicoParam, codigoValorMorfologico){  
    valorMorfologico=codigoValorMorfologico;
    codigoMorfologico=codigoMorfologicoParam;
    
    url="../FiltrarDescripcionesMorfologicas.do?codigoMorfologico="+codigoMorfologicoParam+"&codigoValorMorfologico="+codigoValorMorfologico;
    if(codigoMorfologico=='5' || codigoMorfologico== '20' || codigoMorfologico=='15'){
        if (window.XMLHttpRequest) { // Non-IE browsers
            req = new XMLHttpRequest();
            req.onreadystatechange = procesarRespuesta;
            try {
                req.open("GET", url, true);
            } catch (e) {
                alert(e);
            }
            req.send(null);
        }else if (window.ActiveXObject) { // IE
            req = new ActiveXObject("Microsoft.XMLHTTP");
            if (req) {
                req.onreadystatechange = procesarRespuesta;
                req.open("GET", url, true);
                req.send();
            }
        }
    }
}
function procesarRespuesta() {
    if (req.readyState == 4) { // Complete
        if (req.status == 200) { // OK response
            anexarOptions();
        }
    }
}
function anexarOptions() {
    xml = req.responseXML.documentElement;
    i = 0;
    borrar=xml.getElementsByTagName('item').length;
    anexar=xml.getElementsByTagName('itemAgregar').length;               
    if(anexar==0){        
        for (i = 0; i < xml.getElementsByTagName('item').length; i++){ 
            var item = xml.getElementsByTagName('item')[i]; 
            var codigo = item.getElementsByTagName('codigo')[0].firstChild.data; //Obtengo el codigo de la lista a desabilitar              
            var html="<SELECT ID='valorMorfologico' class='campo' value='"+codigo+"' disabled='true'>";
            html+="<OPTION VALUE='-1' >SIN INFORMACIÓN</OPTION> </SELECT>";               
            document.getElementById(codigo).innerHTML = html;
        }
    }else{             
        var codigoPrincipal="";
        for (i = 0; i < xml.getElementsByTagName('itemAgregar').length; i++){ 
            var itemAgregar = xml.getElementsByTagName('itemAgregar')[i]; 
            codigoPrincipal = itemAgregar.getElementsByTagName('codigo')[0].firstChild.data;                 
            var html="<select name='propertyDescripcionMorfologica("+codigoPrincipal+")' class='campo'>";  
            
            for (j = 0; j < itemAgregar.getElementsByTagName('descripciones').length; j++){ 
                var descripciones = itemAgregar.getElementsByTagName('descripciones')[j]; 
                var codigo = descripciones.getElementsByTagName('codigo')[0].firstChild.data;
                var nombre = descripciones.getElementsByTagName('nombre')[0].firstChild.data;                     
                html+="<option value='"+ codigo +"' >"+ nombre +"</option> ";                     
            }
            html+=" </select> ";
            document.getElementById(codigoPrincipal).innerHTML = html;
        }
    }
}
//******************************************************************************
// FUNCIONES PARA FILTRAR LAS LISTAS DE VALORES MORFOLOGICOS DE LA PANTALLA DE 
// INFORMACION MORFOLOGICA Y DESACTIVAR LAS LISTAS QUE NO SE DEBEN MOSTRAR
//******************************************************************************
var descripcionDependientesCalvicie=new Array('6','7','8');
var descripcionDependientesBarba=new Array('16','17','18','19');
var descripcionDependientesBigote=new Array('21','22','23');
function inhabilitarDescMorfologicas(codigoMorfologico) {
    
    if(codigoMorfologico=='5'){
        for (i=0;i<descripcionDependientesCalvicie.length;i++){
            var html="<SELECT ID='valorMorfologico' class='campo' value='"+descripcionDependientesCalvicie[i]+"' disabled='true'>";
            html+="<OPTION VALUE='-1' >SIN INFORMACIÓN</OPTION> </SELECT>";
            document.getElementById(descripcionDependientesCalvicie[i]).innerHTML = html;
        }
    }else if(codigoMorfologico=='15'){
        for (i=0;i<descripcionDependientesBarba.length;i++){
            var html="<SELECT ID='valorMorfologico' class='campo' value='"+descripcionDependientesBarba[i]+"' disabled='true'>";
            html+="<OPTION VALUE='-1' >SIN INFORMACIÓN</OPTION> </SELECT>";
            document.getElementById(descripcionDependientesBarba[i]).innerHTML = html;
        }
    }else if(codigoMorfologico=='20'){
        for (i=0;i<descripcionDependientesBigote.length;i++){
            var html="<SELECT ID='valorMorfologico' class='campo' value='"+descripcionDependientesBigote[i]+"' disabled='true'>";
            html+="<OPTION VALUE='-1' >SIN INFORMACIÓN</OPTION> </SELECT>";
            document.getElementById(descripcionDependientesBigote[i]).innerHTML = html;
        }
    }
}
//*****************************************************************************************
// FUNCIONES PARA MOFIFICAR  LA PANTALLA DE REGISTRO INICIAL CUANDO SE SELECCIONA
// QUE NO SE CONOCE LA HORA DE DESAPARECION, ESTO HARÁ QUE SE CAMBIE LA MASCARA DEL CONTROL
// DE TEXTO, POR UNO QUE NO INCLUYA HORA PERO EL VALOR QUE TIENE EL CAMPO SE
// CONSERVARÁ.
//*****************************************************************************************
function seDeterminaHoraDesaparicion(conocidaHora,fechaDesaparicion){
    var html="<input type='text' name='fechaDesaparicion' size='14' class='campo' ";
    if(conocidaHora=='S'){
        accion="mascaraFecha(this,\"/\",formatoFecha,false)";
        html+=" maxlength='16' onkeyup="+accion+" value='"+fechaDesaparicion+"'>";
    }else{
        accion="mascara(this,\"/\",formato,false)";
        fechaDesaparicion=fechaDesaparicion.substr(0,10);
        html+=" maxlength='10' onkeyup="+accion+" value='"+fechaDesaparicion+"'>";
    }
    document.getElementById("fechaDesaparicion").innerHTML = html;
}
//*****************************************************************************************
// FUNCIONES PARA MOFIFICAR  LA PANTALLA DE CONCLUSION PERICIAL CUANDO SE SELECCIONA
// QUE NO SE CONOCE LA HORA DE MUERTE, ESTO HARÁ QUE SE CAMBIE LA MASCARA DEL CONTROL
// DE TEXTO, POR UNO QUE NO INCLUYA HORA PERO EL VALOR QUE TIENE EL CAMPO SE
// CONSERVARÁ.
//*****************************************************************************************
function cambiarFormatoHoraMuerte(conocidaHora,fechaMuerte){
    var html="<input type='text' name='fechaMuerte' size='14' class='campo' ";
    if(conocidaHora=='S'){
        accion="mascaraFecha(this,\"/\",formatoFecha,false)";
        accion2="calcularTiempoMuerte(this.value,document.ConclusionPericialForm.fechaHecho.value,document.ConclusionPericialForm.consecutivoRadicado.value,document.ConclusionPericialForm.diasTiempoCausaYMuerte.value,document.ConclusionPericialForm.horasTiempoCausaYMuerte.value,document.ConclusionPericialForm.minutosTiempoCausaYMuerte.value)";
        html+=" maxlength='16' onkeyup="+accion+" onblur="+accion2+" value='"+fechaMuerte+"'>";
    }else if(conocidaHora=='N' || conocidaHora=='-1'){
        accion="mascara(this,\"/\",formato,false)";
        fechaMuerte=fechaMuerte.substr(0,10);
        html+=" maxlength='10' onkeyup="+accion+" value='"+fechaMuerte+"'>";
    }
    document.getElementById("fechaMuerte").innerHTML = html;
}
//*****************************************************************************************
// FUNCIONES PARA MOFIFICAR  LA PANTALLA DE CONCLUSION PERICIAL CUANDO SE SELECCIONA
// QUE NO SE CONOCE LA HORA DE MUERTE, ESTO HARÁ QUE SE CAMBIE LA MASCARA DEL CONTROL
// DE TEXTO, POR UNO QUE NO INCLUYA HORA PERO EL VALOR QUE TIENE EL CAMPO SE
// CONSERVARÁ.
//*****************************************************************************************
function seConoceFechaMuerteCD(){ 
        document.ConclusionPericialForm.fechaMuerteCD.value=document.ConclusionPericialForm.fechaMuerte.value.substring(0,10);
        eval("document.ConclusionPericialForm.fechaMuerteCD.value=document.ConclusionPericialForm.fechaMuerte.value.substring(0,10)");
}
function seConoceFechaMuerte(conocidaFecha){
    var html="<a href=\"javascript:show_calendar('ConclusionPericialForm.fechaMuerte');\" onmouseover=\"window.status='Date Picker';return true;\" onblur=\"seConoceFechaMuerteCD(this.value);\" onmouseout=\"window.status='';return true;\"><img src=\"../imagenes/icoCalendario.gif\"  border='0'></a>";
    var htmlCD="<a href=\"javascript:show_calendar('ConclusionPericialForm.fechaMuerteCD');\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"../imagenes/icoCalendario.gif\"  border='0'></a>";
    if(conocidaFecha=='S'){
        eval("document.ConclusionPericialForm.fechaMuerte.value=''");
        eval("document.ConclusionPericialForm.seDeterminaHoraMuerte.value=''");
        eval("document.ConclusionPericialForm.fechaMuerte.disabled=false");
        eval("document.ConclusionPericialForm.fechaMuerteCD.disabled=true");
        eval("document.ConclusionPericialForm.seDeterminaHoraMuerte.disabled=false");
        indice=calcularIndiceHoraMuerte();
        eval('document.ConclusionPericialForm.seDeterminaHoraMuerte.options['+indice+'].selected=true');
        document.getElementById("linkCalendario").innerHTML = html;
        document.getElementById("linkCalendarioCD").innerHTML = '';
    }else if(conocidaFecha=='N'){
        eval("document.ConclusionPericialForm.fechaMuerte.value=''");
        eval("document.ConclusionPericialForm.seDeterminaHoraMuerte.value=''");
        eval("document.ConclusionPericialForm.fechaMuerte.disabled=true");
        eval("document.ConclusionPericialForm.fechaMuerteCD.disabled=false");
        eval("document.ConclusionPericialForm.seDeterminaHoraMuerte.disabled=true");
        indice=calcularIndiceHoraMuerte();
        eval('document.ConclusionPericialForm.seDeterminaHoraMuerte.options['+indice+'].selected=true');
        document.getElementById("linkCalendario").innerHTML = '';
        document.getElementById("linkCalendarioCD").innerHTML = htmlCD;
    }
}

function calcularIndiceHoraMuerte(){
    var tamano = eval('document.ConclusionPericialForm.seDeterminaHoraMuerte.length');
    if (tamano>0) {
        for (j=0; j< tamano-1; j++){
            opcion= eval('document.ConclusionPericialForm.seDeterminaHoraMuerte.options['+j+'].value');
            if(opcion=='-1'){             
                return j;       
            }
        }
    }
    return 1;
}
//*****************************************************************************************
// FUNCIONES PARA MOFIFICAR  LA PANTALLA DE DATOS LUGAR DE LOS HECHOS CUANDO SE SELECCIONA
// QUE NO SE CONOCE LA HORA DEL HECHO.
//*****************************************************************************************
function existeFechaHecho(conocidaFecha){
    if(conocidaFecha=='S'){
        
        eval("document.DatosLugarHechosForm.fechaHecho.value=''");
        eval("document.DatosLugarHechosForm.fechaHecho.disabled=true");
        eval("document.DatosLugarHechosForm.seConoceHoraHecho.disabled=false");
        indice=calcularIndice('DatosLugarHechosForm', 'seConoceHoraHecho');
        eval('document.DatosLugarHechosForm.seConoceHoraHecho.options['+indice+'].selected=true');    
        document.getElementById("linkCalendario").innerHTML = '';
    }else if(conocidaFecha=='N' || conocidaFecha=='-1'){
        eval("document.DatosLugarHechosForm.fechaHecho.value=''");
        eval("document.DatosLugarHechosForm.fechaHecho.disabled=true");
        eval("document.DatosLugarHechosForm.seConoceHoraHecho.disabled=true");
        indice=calcularIndice('DatosLugarHechosForm', 'seConoceHoraHecho');
        eval('document.DatosLugarHechosForm.seConoceHoraHecho.options['+indice+'].selected=true');    
        
        document.getElementById("linkCalendario").innerHTML = '';
    }
    document.getElementById("tituloFechaHecho").innerHTML = "Fecha del hecho:";
}
//*****************************************************************************************
// FUNCIONES PARA MODIFICAR  LA PANTALLA DE DATOS LUGAR DE LOS HECHOS CUANDO SE SELECCIONA
// QUE NO SE CONOCE LA HORA DEL HECHO, ESTO HARÁ QUE SE CAMBIE LA MASCARA DEL CONTROL
// DE TEXTO, POR UNO QUE NO INCLUYA HORA PERO EL VALOR QUE TIENE EL CAMPO SE
// CONSERVE.
//*****************************************************************************************
function cambiarFormatoHoraHecho(conocidaHora,fechaHecho){
    var link="<a href=\"javascript:show_calendar('DatosLugarHechosForm.fechaHecho');\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"../imagenes/icoCalendario.gif\"  border='0'></a>";
    var html="<input type='text' name='fechaHecho' size='14' class='campo' ";
    if(conocidaHora=='S'){
        accion="mascaraFecha(this,\"/\",formatoFecha,true)";
        html+=" maxlength='16' onkeyup="+accion+" value='"+fechaHecho+"'>";
        document.getElementById("linkCalendario").innerHTML = link;
        document.getElementById("tituloFechaHecho").innerHTML = "Fecha y hora del hecho:";
    }else if(conocidaHora=='N'){
        fechaHecho=fechaHecho.substr(0,10);
        accion="mascara(this,\"/\",formato,true)";
        html+=" maxlength='10' onkeyup="+accion+" value='"+fechaHecho+"'>";
        document.getElementById("linkCalendario").innerHTML = link;
        document.getElementById("tituloFechaHecho").innerHTML = "Fecha del hecho:";
    }else{
        eval("document.DatosLugarHechosForm.fechaHecho.value=''");
        html+=" maxlength='16' onkeyup="+accion+" value='' disabled='true'>";
        document.getElementById("linkCalendario").innerHTML = '';
        document.getElementById("tituloFechaHecho").innerHTML = "Fecha del hecho:";
    }
    document.getElementById("fechaHecho").innerHTML = html;
}
//*****************************************************************************
//FUNCION QUE PERMITE OBTENER EL INDICE DE UN OPTION DENTRO DE UN CAMPO SELECT
//*****************************************************************************
function calcularIndice(nombreForma, nombreCampo){
    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=='-1'){ 
                return j;       
            }
        }
    }
    return 0;
}
function calcularIndiceValor(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 VALIDAR LA INFORMACION DE LA TABLA TIPOSEGURIDADSOCIAL Y TIPOADMSALUD,
// ESTO PORQUE CUANDO SE SELECCIONA EL VALOR "NO ASEGURADO" DE LA TABLA TIPOSEGURIDAD
// SOCIAL, SE DEBE DESACTIVAR LA LISTA TIPOADMSALUD
//*****************************************************************************
function validarTipoEntregaCadaver(codigoTipoEntrega, contexto, valorProcesoIdentificacion){
    var linkPersona="<a href=\"javascript:popup('"+contexto+"/persona/datosPersonales.jsp?codigoPersona=0&ventanaPopup=true&tipoDocumento=0&numeroDocumento=&envioDesde=validarCadaver','window',780,425,'scrollbars=yes');\"><img src=\"../imagenes/btnIngresar.gif\" border=\"0\"></a>";
    var linkDireccion="<a href=\"javascript:alert('Debe ingresar la información de la persona antes de ingresar la dirección.');\"><img src=\"../imagenes/btnIngresar.gif\" border=\"0\"></a>";
    if (codigoTipoEntrega==1 && valorProcesoIdentificacion==false)    {
        alert("Debe cerrar el Proceso de Identificación para poder hacer la entrega al familiar");
    }else if(codigoTipoEntrega==4){
        indice=calcularIndiceValor('EntregaCadaverForm','codigoTipoParentesco','20');
        eval("document.EntregaCadaverForm.codigoTipoParentesco.disabled=true");
        eval('document.EntregaCadaverForm.codigoTipoParentesco.options['+indice+'].selected=true');  
        eval('document.EntregaCadaverForm.codigoPersonaReclama.value='+0);  
        eval('document.EntregaCadaverForm.consecutivoDireccionPersonaReclama.value='+0);  
        eval("document.EntregaCadaverForm.detalleDireccion.value=''");  
        eval("document.EntregaCadaverForm.detallePersonaReclama.value=''");  
        
        document.getElementById("linkPersona").innerHTML = "<a href=\"javascript:alert('Cuando la entrega del cadáver es Inhumación Estatal, la información \n de la persona que reclama no es necesaria.');\"><img src=\"../imagenes/btnIngresar.gif\" border=\"0\"></a>";
        document.getElementById("linkDireccion").innerHTML = '';
    }else{
        eval("document.EntregaCadaverForm.codigoTipoParentesco.disabled=false");
        document.getElementById("linkPersona").innerHTML = linkPersona;
        document.getElementById("linkDireccion").innerHTML = linkDireccion;
    }
}
//*****************************************************************************
//FUNCION QUE VALIDAR LA INFORMACION DE LAS LITAS DE LA TABLA DETALLEACCIDENTETRANSITO
//*****************************************************************************
function validarTipoCandicionVictima(codigoCondicionVictima, contexto){
    if(codigoCondicionVictima==1){                 
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoClaseAccTransito','3');
        eval("document.DetalleAccidenteTransporteForm.codigoClaseAccTransito.disabled=true");
        eval('document.DetalleAccidenteTransporteForm.codigoClaseAccTransito.options['+indice+'].selected=true');  
        
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoVehiculo','0');
        eval("document.DetalleAccidenteTransporteForm.codigoVehiculo.disabled=true");
        eval('document.DetalleAccidenteTransporteForm.codigoVehiculo.options['+indice+'].selected=true'); 
        
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoServicio','0');
        eval("document.DetalleAccidenteTransporteForm.codigoServicio.disabled=true");
        eval('document.DetalleAccidenteTransporteForm.codigoServicio.options['+indice+'].selected=true'); 
        
        eval("document.DetalleAccidenteTransporteForm.codigoObjeto.value='-1'");
        eval("document.DetalleAccidenteTransporteForm.codigoObjeto.disabled=false");
        eval("document.DetalleAccidenteTransporteForm.codigoServicioObjeto.value='-1'");    
        eval("document.DetalleAccidenteTransporteForm.codigoServicioObjeto.disabled=false");  
        eval("document.DetalleAccidenteTransporteForm.codigoCondicionLugar.value='-1'");   
        eval("document.DetalleAccidenteTransporteForm.codigoCondicionLugar.disabled=false");
        eval("document.DetalleAccidenteTransporteForm.codigoEstadoVia.value='-1'");  
        eval("document.DetalleAccidenteTransporteForm.codigoEstadoVia.disabled=false");
    }else if(codigoCondicionVictima==2 || codigoCondicionVictima==3){
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoObjeto','0');
        eval("document.DetalleAccidenteTransporteForm.codigoObjeto.disabled=true");
        eval('document.DetalleAccidenteTransporteForm.codigoObjeto.options['+indice+'].selected=true');  
        
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoServicioObjeto','0');
        eval("document.DetalleAccidenteTransporteForm.codigoServicioObjeto.disabled=true");
        eval('document.DetalleAccidenteTransporteForm.codigoServicioObjeto.options['+indice+'].selected=true');
        
        eval("document.DetalleAccidenteTransporteForm.codigoVehiculo.value='-1'");
        eval("document.DetalleAccidenteTransporteForm.codigoVehiculo.disabled=false");
        eval("document.DetalleAccidenteTransporteForm.codigoServicio.value='-1'");   
        eval("document.DetalleAccidenteTransporteForm.codigoServicio.disabled=false");
        eval("document.DetalleAccidenteTransporteForm.codigoClaseAccTransito.value='-1'");  
        eval("document.DetalleAccidenteTransporteForm.codigoClaseAccTransito.disabled=false");
        
        eval("document.DetalleAccidenteTransporteForm.codigoCondicionLugar.value='-1'");   
        eval("document.DetalleAccidenteTransporteForm.codigoCondicionLugar.disabled=false");      
        eval("document.DetalleAccidenteTransporteForm.codigoEstadoVia.value='-1'");  
        eval("document.DetalleAccidenteTransporteForm.codigoEstadoVia.disabled=false");       
    }else if(codigoCondicionVictima==-1){
        eval("document.DetalleAccidenteTransporteForm.codigoClaseAccTransito.value='-1'");  
        eval("document.DetalleAccidenteTransporteForm.codigoClaseAccTransito.disabled=false");
        
        eval("document.DetalleAccidenteTransporteForm.codigoVehiculo.value='-1'");
        eval("document.DetalleAccidenteTransporteForm.codigoVehiculo.disabled=false");
        
        eval("document.DetalleAccidenteTransporteForm.codigoServicio.value='-1'");   
        eval("document.DetalleAccidenteTransporteForm.codigoServicio.disabled=false");
        
        eval("document.DetalleAccidenteTransporteForm.codigoObjeto.value='-1'");   
        eval("document.DetalleAccidenteTransporteForm.codigoObjeto.disabled=false");
        
        eval("document.DetalleAccidenteTransporteForm.codigoServicioObjeto.value='-1'");   
        eval("document.DetalleAccidenteTransporteForm.codigoServicioObjeto.disabled=false");
        
        eval("document.DetalleAccidenteTransporteForm.codigoCondicionLugar.value='-1'");   
        eval("document.DetalleAccidenteTransporteForm.codigoCondicionLugar.disabled=false");    
        
        eval("document.DetalleAccidenteTransporteForm.codigoEstadoVia.value='-1'");  
        eval("document.DetalleAccidenteTransporteForm.codigoEstadoVia.disabled=false");  
    }  
}
//*****************************************************************************
//FUNCION QUE VALIDAR LA INFORMACION DE LAS LITAS DE LA TABLA DETALLEACCIDENTETRANSITO
//*****************************************************************************
function validarTipoClaseAccidente(codigoClaseAccTransito, contexto){
    if(codigoClaseAccTransito==2 || codigoClaseAccTransito==4){   
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoObjeto','0');
        eval("document.DetalleAccidenteTransporteForm.codigoObjeto.disabled=false");
        eval('document.DetalleAccidenteTransporteForm.codigoObjeto.options['+indice+'].selected=true');  
        
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoServicioObjeto','0');
        eval("document.DetalleAccidenteTransporteForm.codigoServicioObjeto.disabled=false");
        eval('document.DetalleAccidenteTransporteForm.codigoServicioObjeto.options['+indice+'].selected=true');
    }else{
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoObjeto','0');
        eval("document.DetalleAccidenteTransporteForm.codigoObjeto.disabled=true");
        eval('document.DetalleAccidenteTransporteForm.codigoObjeto.options['+indice+'].selected=true');  
        
        indice=calcularIndiceValor('DetalleAccidenteTransporteForm','codigoServicioObjeto','0');
        eval("document.DetalleAccidenteTransporteForm.codigoServicioObjeto.disabled=true");
        eval('document.DetalleAccidenteTransporteForm.codigoServicioObjeto.options['+indice+'].selected=true');
    }
}
//*****************************************************************************
//FUNCION QUE VALIDAR EN CONCLUSION PERICIAL SI SE CONOCE O NO EL TIEMPO
//ENTRE LA CAUSA Y LA MUERTE
//*****************************************************************************
function validarTiempoCausaYMuerte(seConoceTiempo, dias, horas, minutos){
   
    if(seConoceTiempo=='N'){
        if(dias=='0' && horas=='0' && minutos=='0'){
            eval("document.ConclusionPericialForm.diasTiempoCausaYMuerte.value=0");
            eval("document.ConclusionPericialForm.horasTiempoCausaYMuerte.value=0");
            eval("document.ConclusionPericialForm.minutosTiempoCausaYMuerte.value=0");
            eval("document.ConclusionPericialForm.diasTiempoCausaYMuerte.disabled=true");
            eval("document.ConclusionPericialForm.horasTiempoCausaYMuerte.disabled=true");
            eval("document.ConclusionPericialForm.minutosTiempoCausaYMuerte.disabled=true");
        }else{
            var resultado=window.confirm("Anteriormente se habia calculado el tiempo entre la causa y la muerte. Está seguro que este no se determina?")
            if (resultado){
                eval("document.ConclusionPericialForm.diasTiempoCausaYMuerte.value=0");
                eval("document.ConclusionPericialForm.horasTiempoCausaYMuerte.value=0");
                eval("document.ConclusionPericialForm.minutosTiempoCausaYMuerte.value=0");
                eval("document.ConclusionPericialForm.diasTiempoCausaYMuerte.disabled=true");
                eval("document.ConclusionPericialForm.horasTiempoCausaYMuerte.disabled=true");
                eval("document.ConclusionPericialForm.minutosTiempoCausaYMuerte.disabled=true");
            }else{
                var indice=calcularIndiceValor('ConclusionPericialForm', 'seDeterminaTiempoCausaYMuerte', 'S');
                eval('document.ConclusionPericialForm.seDeterminaTiempoCausaYMuerte.options['+indice+'].selected=true'); 
            }
        }
    }else if(seConoceTiempo=='S'){
        eval("document.ConclusionPericialForm.diasTiempoCausaYMuerte.disabled=false");
        eval("document.ConclusionPericialForm.horasTiempoCausaYMuerte.disabled=false");
        eval("document.ConclusionPericialForm.minutosTiempoCausaYMuerte.disabled=false");
    }
}
//*****************************************************************************
//FUNCION QUE VALIDAR EN LA PANTALLA DE DATOS PERSONALES EL INGRESO DE NN
//Y LA INHABLITACION DE LOS CAMPOS DE APELLIDO2 Y NOMBRES
//*****************************************************************************
function validarIngresoNN(apellido1, radicadoCadaver){
    
    if(radicadoCadaver==true){
        if(apellido1=='NN'){
            eval("document.PersonaForm.apellido2.value=''");
            eval("document.PersonaForm.apellido2.disabled=true");
            eval("document.PersonaForm.nombres.value=''");
            eval("document.PersonaForm.nombres.disabled=true");
            eval("document.PersonaForm.alias.focus()");
        }else{
            cadena=verificarFormatoIngresoNN(apellido1);
            if(cadena=='NN'){
                eval("document.PersonaForm.apellido1.value='NN'");
                eval("document.PersonaForm.apellido2.value=''");
                eval("document.PersonaForm.apellido2.disabled=true");
                eval("document.PersonaForm.nombres.value=''");
                eval("document.PersonaForm.nombres.disabled=true");
                eval("document.PersonaForm.alias.focus()");
            }else{
                eval("document.PersonaForm.apellido2.disabled=false");
                eval("document.PersonaForm.nombres.disabled=false");
                eval("document.PersonaForm.apellido2.focus()");
            }
        }
    }
}
//*****************************************************************************
//FUNCION QUE VALIDAR EL INGRESO DE CADAVERES NN
//*****************************************************************************
function verificarFormatoIngresoNN(apellido1){
    var cadena1='';
    for(q=0;q<apellido1.length; q++){
        letra=apellido1.charAt(q); 
        if(letra!='.' && letra!='' && letra!=' '){
            cadena1+=letra;
        }
    }  
    if(cadena1=='NN'){
        alert('Recuerde que si va a registrar un cadáver NN debe ingresar en apellido1 NN, apellido2 y nombres quedan en blanco.')
        return cadena1;
    }
}
//*******************************************************************************************
//FUNCION QUE VALIDAR LA INFORMACION DE LA TABLA TIPOSENNALPARTICULAR Y TIPOPARTEANATOMICA,
// ESTO PORQUE CUANDO SE SELECCIONA EL VALOR "NINGUNA" O "SIN INFORMACION "DE LA TABLA 
// TIPOSENNALPARTICULAR, SE DEBE DESACTIVAR LA LISTA TIPOPARTEANATOMICA Y PONER POR DEFECTO
// LA PARTE ANATOMICA "NINGUNA"
//*****************************************************************************
function validarTipoSennalParticular(codigoSennal){
    if(codigoSennal==29 || codigoSennal==0){
        indice=calcularIndiceValor('SennalesParticularesForm','codigoParteAnatomica',262);
        eval("document.SennalesParticularesForm.codigoParteAnatomica.disabled=true");
        eval('document.SennalesParticularesForm.codigoParteAnatomica.options['+indice+'].selected=true');    
    }else{
        eval("document.SennalesParticularesForm.codigoParteAnatomica.disabled=false");
    }
}
//*******************************************************************************************
//FUNCION QUE VALIDAR LA BUSQUEDA DE PERSONAS POR TIPO DE DOCUMENTO, SE DEBE EVITAR BUSCAR CUANDO EL
//TIPO DE DOCUMENTO SEA INDOCUMENTADO Y SIN INFORMACION, ADEMAS SE DEBE INHABILITAR EL CAMPO NUMERO DE
//DOCUMENTO CUANDO ESTOS VALORES SE SELECCIONEN
//*****************************************************************************
function validarBusquedaPorDocumento(codigoDocumento){
    if(codigoDocumento==3 || codigoDocumento==6){
        eval("document.PersonaForm.numeroDocumento.value='NA'");
        eval('document.PersonaForm.numeroDocumento.disabled=true');    
        eval("document.PersonaForm.fechaExpedicion.value=''");
        eval('document.PersonaForm.fechaExpedicion.disabled=true');     
        
        eval("document.PersonaForm.apellido1.value=''");
        eval('document.PersonaForm.controlNombre.value=true');
        
        document.getElementById("linkCalendario").innerHTML = '';
        
        //Se inactiva las lista de paises
        indicePais=calcularIndiceValor('PersonaForm','codigoPaisExpedicion',-1);
        eval("document.PersonaForm.codigoPaisExpedicion.disabled=true");
        eval('document.PersonaForm.codigoPaisExpedicion.options['+indicePais+'].selected=true'); 
        
        //Se inactiva las lista de departamentos
        indiceDepto=calcularIndiceValor('PersonaForm','codigoDepartamentoExpedicion',-1);
        eval("document.PersonaForm.codigoDepartamentoExpedicion.disabled=true");
        eval('document.PersonaForm.codigoDepartamentoExpedicion.options['+indiceDepto+'].selected=true'); 
        
        //Se inactiva las lista de municipio
        indiceMunicipio=calcularIndiceValor('PersonaForm','codigoMunicipioExpedicion',-1);
        eval("document.PersonaForm.codigoMunicipioExpedicion.disabled=true");
        eval('document.PersonaForm.codigoMunicipioExpedicion.options['+indiceMunicipio+'].selected=true'); 
    }else{
        eval('document.PersonaForm.numeroDocumento.disabled=false');
        numero=eval('document.PersonaForm.numeroDocumento.value');
        if(numero=='NA'){
            eval("document.PersonaForm.numeroDocumento.value=''");
        }
        eval('document.PersonaForm.fechaExpedicion.disabled=false');
        document.getElementById("linkCalendario").innerHTML = "<a href=\"javascript:show_calendar('PersonaForm.fechaExpedicion');\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"../imagenes/icoCalendario.gif\" border=0></a>";
        eval("document.PersonaForm.codigoPaisExpedicion.disabled=false");
        eval("document.PersonaForm.codigoDepartamentoExpedicion.disabled=false");
        eval("document.PersonaForm.codigoMunicipioExpedicion.disabled=false");
        eval('document.PersonaForm.controlNombre.value=false');
        eval("document.PersonaForm.apellido1.value=''");
        
    }
}
function validarNumeroDocumento(tipoDocumento, numeroDocumento){
    valor = numeroDocumento.value
    val2 = ''
    if(tipoDocumento!=4){
        numeroDocumento.value=esNumero(valor);
    }else{
        numeroDocumento.value=alfanumerico(valor);
    }
    return;
}
//*******************************************************************************************
//FUNCION QUE ES LLAMADA DESDE LA PANTALLA DE DATOS PERSONALES CUANDO EL CAMPO TIPODOCUMENTO RECIBE
//EL EVENTO ONCHANGE, SI EL TIPO DE DOCUMENTO ES INDOCUMENTADO, ENTONCES A LOS CAMPOS DE LUGAR DE 
//NACIMIENTO SE LE OBLIGA EL INGRESO, POR ESTA RAZON SE PONE EL ASTERISCO (*)
//*****************************************************************************
function exigirLugarNacimiento(tipoDocumento, modulo){
    var html="";
    if(tipoDocumento==3){
        var html="*";
    }
    if(modulo=='identificacionCadaver'){
        document.getElementById("exigirLugarNacimiento1").innerHTML = html;
        document.getElementById("exigirLugarNacimiento2").innerHTML = html;
        document.getElementById("exigirLugarNacimiento3").innerHTML = html;
    }
}
//*******************************************************************************************
//FUNCION QUE PERMITE DESABILITAR O HABILITAR EL CAMPO FECHARETIRO EN LA PANTALLA DE 
//INFORMACION LABORAL DEPENDIENDO DEL VALOR DEL CAMPO OCUPACION ACTUAL
//*****************************************************************************
function validarFechaRetiro(ocupacionActual){
    var html="<a href=\"javascript:show_calendar('InformacionLaboralForm.fechaRetiro');\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"../imagenes/icoCalendario.gif\"  border='0'></a>";
    if(ocupacionActual=='S'){
        eval("document.InformacionLaboralForm.fechaRetiro.disabled=true");
        eval("document.InformacionLaboralForm.fechaRetiro.value=''");
        document.getElementById("linkCalendario").innerHTML ='';
    }else{
        eval("document.InformacionLaboralForm.fechaRetiro.disabled=false");
        eval("document.InformacionLaboralForm.fechaRetiro.value='dd/mm/aaaa'");
        document.getElementById("linkCalendario").innerHTML = html;
    }
    
}
//*******************************************************************************************
//FUNCION QUE VALIDAR LA INFORMACION DE LA JSP DE ACCESORIOS DE USO PERSONAL,
// ESTO PORQUE CUANDO SE SELECCIONA EL VALOR "NINGUNO" DE LA TABLA 
// TIPOACCESORIO, SE DEBE DESACTIVAR LA LISTA TIPOCOLOR Y PONER POR DEFECTO
// EL COLOR "SIN INFORMACION"
//*****************************************************************************
function validarTipoAccesorio(codigoAccesorio){
    if(codigoAccesorio==25){
        indice=calcularIndiceValor('AccesorioPersonaForm','codigoColor',0);
        eval("document.AccesorioPersonaForm.codigoColor.disabled=true");
        eval('document.AccesorioPersonaForm.codigoColor.options['+indice+'].selected=true');    
    }else{
        eval("document.AccesorioPersonaForm.codigoColor.disabled=false");
    }
}
//*****************************************************************************
//FUNCION QUE VALIDAR LA INFORMACION DE LA JSP DE EVIDENCIAS Y EXAMENES,
//PARA NO PERMITIR CANCELAR LA EVIDENCIA CADAVER Y ADEMAS PEDIR CONFIRMACION
//ANTES DE REALIZAR EL PROCESO DE CANCELACION
//*****************************************************************************
function validarCancelacionEvidencia(tipoEvidencia, boton){
    if(tipoEvidencia==1){
        alert('No puede cancelar la evidencia cadáver asociada a este caso.');
    }else{
        valor=confirm('Está seguro de realizar el proceso de cancelación de la evidencia seleccionada?');
        if(valor==true){
            controlTipoAccion(botonCancelar, 'EvidenciaCadaverForm', 'CancelarEvidencia');
            eval('document.EvidenciaCadaverForm.submit()'); 
        }
    }
}
//*******************************************************************************************
// OBTENEMOS EL VALOR SELECCIONADO DE UN CONJUNTO DE VALORES RADIO BUTTON
//*****************************************************************************
function obtenerRadioButtonSeleccionado(control) {
    for(i=0;i<control.length;i++){
        if(control[i].checked){ 
            return control[i].value;
        }
    }
    if(eval('document.EvidenciaCadaverForm.consecutivoEvidenciaModificar.checked')){
        return eval('document.EvidenciaCadaverForm.consecutivoEvidenciaModificar.value');
    }
    return 0;
}
//*****************************************************************************
//
//*****************************************************************************
function validarPeso(peso){
    valor=peso.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;
                }
            }
        }
    }
    peso.value=cadena;
}
//**************************************************************************************
// VALIDAR TIEMPO DE ATENCION MEDICA, ESTA FUNCION ES LLAMADA DESDE LA JSP DE
// DATOSGENERALESNECROPSIA POR MEDIO DEL EVENTO ONCHANGE DEL CAMPO SECONOCETIEMPOATENCION
// Y TIENE POR FINALIDAD INACTIVAR O ACTIVAR LOS CAMPOS DE TIEMPO DE ATENCION MEDICA
// EN LA JSP
//**************************************************************************************
function validarTiempoAtencionMedica(seConoceTiempo) {
    if(seConoceTiempo=='S'){
        eval("document.NecropsiaForm.tiempoAtencionMedicaAnios.disabled=false");
        eval("document.NecropsiaForm.tiempoAtencionMedicaMeses.disabled=false");
        eval("document.NecropsiaForm.tiempoAtencionMedicaDias.disabled=false");
        eval("document.NecropsiaForm.tiempoAtencionMedicaHoras.disabled=false");
    }else{
        eval("document.NecropsiaForm.tiempoAtencionMedicaAnios.disabled=true");
        eval("document.NecropsiaForm.tiempoAtencionMedicaMeses.disabled=true");
        eval("document.NecropsiaForm.tiempoAtencionMedicaDias.disabled=true");
        eval("document.NecropsiaForm.tiempoAtencionMedicaHoras.disabled=true");
        eval("document.NecropsiaForm.tiempoAtencionMedicaAnios.value=0");
        eval("document.NecropsiaForm.tiempoAtencionMedicaMeses.value=0");
        eval("document.NecropsiaForm.tiempoAtencionMedicaDias.value=0");
        eval("document.NecropsiaForm.tiempoAtencionMedicaHoras.value=0.0");
    }
    
}
//**************************************************************************************
// HOMOLOGAR FORMATO A IMPRIMIR PARA EVIDENCIAS Y EXAMENES
//**************************************************************************************
function homologarFormatoAImprimir(formatoAImprimir) { 
    indice=calcularIndiceValor('EvidenciaCadaverForm', 'formatoImprimirAux',formatoAImprimir);
    eval('document.EvidenciaCadaverForm.formatoImprimirAux.options['+indice+'].selected=true');    
    indice=calcularIndiceValor('EvidenciaCadaverForm', 'formatoImprimir',formatoAImprimir);
    eval('document.EvidenciaCadaverForm.formatoImprimir.options['+indice+'].selected=true');     
}
//*******************************************************************************************
// FUNCION QUE INACTIVA LOS CAMPOS DE LA JSP DE PRENDAS DE VESTIR CUANDO LA PRENDA
// SELECCIONADA ES NINGUNA
//*****************************************************************************
function validarTipoPrendaVestir(codigoPrenda){
    if(codigoPrenda==0){
        indice=calcularIndiceValor('PrendaVestirForm','codigoMaterialPrenda',0);
        eval("document.PrendaVestirForm.codigoMaterialPrenda.disabled=true");
        eval('document.PrendaVestirForm.codigoMaterialPrenda.options['+indice+'].selected=true');  
        
        indice=calcularIndiceValor('PrendaVestirForm','codigoColor',0);
        eval("document.PrendaVestirForm.codigoColor.disabled=true");
        eval('document.PrendaVestirForm.codigoColor.options['+indice+'].selected=true');  
        
        eval("document.PrendaVestirForm.tipoTalla.value='ND'");
        eval("document.PrendaVestirForm.tipoTalla.disabled=true");
        
        eval("document.PrendaVestirForm.marca.value='ND'");
        eval("document.PrendaVestirForm.marca.disabled=true");
        
        eval("document.PrendaVestirForm.observacion.value='ND'");
        eval("document.PrendaVestirForm.observacion.disabled=true");
    }else{
        indice=calcularIndiceValor('PrendaVestirForm','codigoMaterialPrenda',0);
        eval('document.PrendaVestirForm.codigoMaterialPrenda.options['+indice+'].selected=true');  
        eval("document.PrendaVestirForm.codigoMaterialPrenda.disabled=false");
        
        indice=calcularIndiceValor('PrendaVestirForm','codigoColor',0);
        eval('document.PrendaVestirForm.codigoColor.options['+indice+'].selected=true'); 
        eval("document.PrendaVestirForm.codigoColor.disabled=false");
        
        eval("document.PrendaVestirForm.tipoTalla.value='ND'");
        eval("document.PrendaVestirForm.tipoTalla.disabled=false");
        
        eval("document.PrendaVestirForm.marca.value='ND'");
        eval("document.PrendaVestirForm.marca.disabled=false");
        
        eval("document.PrendaVestirForm.observacion.value='ND'");
        eval("document.PrendaVestirForm.observacion.disabled=false");
    }
}
//*******************************************************************************************
//FUNCION QUE INACTIVA LA LISTA DE CANTIDAD DE AGRESORES EN LA PANTALLA DE DATOS LUGAR DE LOS HECHOS
//CUANDO EL TIPO DE AGRESOR NO APLICA
//*****************************************************************************
function validarTipoAgresorDetalleLugarHechos(codigoTipoAgresor){
    if(codigoTipoAgresor==30){
        indice=calcularIndiceValor('DatosLugarHechosForm','cantidadAgresores',-1);
        eval("document.DatosLugarHechosForm.cantidadAgresores.disabled=true");
        eval('document.DatosLugarHechosForm.cantidadAgresores.options['+indice+'].selected=true');  
    }else{
        eval("document.DatosLugarHechosForm.cantidadAgresores.disabled=false");
    }
}
//*******************************************************************************************
//FUNCION QUE INACTIVA LA LISTA DE CANTIDAD DE TIPO AUTORIZACION Y NOTIFICA FAMILIA 
//CUANDO EL TIPO DE EXTRACCION ES DOCENCIA
//*****************************************************************************
function validarTipoExtraccionOrganos(tipoExtraccion){
    if(tipoExtraccion=='C'){
        indice=calcularIndiceValor('ExtraccionOrganosForm','tipoAutorizacion','D');
        
        if(indice==0){
            tamanoOption=eval('document.ExtraccionOrganosForm.tipoAutorizacion.options.length');
            eval('document.ExtraccionOrganosForm.tipoAutorizacion.options['+(tamanoOption)+']=new Option("No Determinado","D")');
            indice=calcularIndiceValor('ExtraccionOrganosForm','tipoAutorizacion','D');
        }
        
        eval("document.ExtraccionOrganosForm.tipoAutorizacion.disabled=true");
        eval('document.ExtraccionOrganosForm.tipoAutorizacion.options['+indice+'].selected=true');  
        
        indice=calcularIndiceValor('ExtraccionOrganosForm','notificaFamilia','S');
        eval("document.ExtraccionOrganosForm.notificaFamilia.disabled=true");
        eval('document.ExtraccionOrganosForm.notificaFamilia.options['+indice+'].selected=true'); 
        
        eval("document.ExtraccionOrganosForm.tipoAutorizacionAux.value='D'");
        eval("document.ExtraccionOrganosForm.notificaFamiliaAux.value='S'");        
    }else{
        indice=calcularIndiceValor('ExtraccionOrganosForm','tipoAutorizacion','D');
        
        if(indice!=0){
            tamanoOption=eval('document.ExtraccionOrganosForm.tipoAutorizacion.options.length');
            eval('document.ExtraccionOrganosForm.tipoAutorizacion.options['+(indice)+']=null');
        }
        
        eval("document.ExtraccionOrganosForm.tipoAutorizacion.disabled=false");
        
        eval("document.ExtraccionOrganosForm.notificaFamilia.disabled=false");
    }
}

