var NS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion, 10) >= 5)? true : false;
var IE = (navigator.appVersion.search(/MSIE/) != -1)? true : false;

function busquedaRegistro4(valor,valor2,valor3,valor4,url,posicionAsumar)
{
    // FUNCION QUE PERMITE BUSCAR UN VALOR DE ACUERDO AL IDENTIFICACOR QUE SE HAYA DIGITADO
    valor_forma = valor.value;
    if (valor_forma != "")
    {

        var i;
        if (posicionAsumar > 1)
        {
            i = obtenerPosicionElementoforma(valor)+posicionAsumar;
            //alert ("J diferente de 1, posCalculada= "+i);
        }
        else{// Igual a 1, para wincombos tradicionales
            i = obtenerPosicionElementoforma(valor)+1;
            //alert ("J igual de 1,posCalculada=  "+i);
        }


        url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor.value+"&posCalculada="+i;
        url = url+"&patron2="+valor2.value;
        url = url+"&patron3="+valor3.value;
        url = url+"&patron4="+valor4.value;

        wWidth = Math.round((screen.availWidth*2)/100);
        wHeight = Math.round((screen.availHeight*2)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        busqueda = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=no,status=no,scrollbars=no,top=" + wYPos + ",left=" + wXPos);
        if (busqueda.opener == null) busqueda.opener = window;
        busqueda.focus();
    }
}

function busquedaRegistro5(valor,valor2,valor3,valor4,valor5,url,posicionAsumar)
{
// FUNCION QUE PERMITE BUSCAR UN VALOR DE ACUERDO AL IDENTIFICACOR QUE SE HAYA DIGITADO
    valor_forma = valor.value;
    if (valor_forma != ""){

        var i;
        if (posicionAsumar > 1){
            i = obtenerPosicionElementoforma(valor)+posicionAsumar;
            //alert ("J diferente de 1, posCalculada= "+i);
        }
        else{// Igual a 1, para wincombos tradicionales
            i = obtenerPosicionElementoforma(valor)+1;
            //alert ("J igual de 1,posCalculada=  "+i);
        }


        url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor.value+"&posCalculada="+i;
        url = url+"&patron2="+valor2.value;
        url = url+"&patron3="+valor3.value;
        url = url+"&patron4="+valor4.value;
        url = url+"&patron5="+valor5.value;

        wWidth = Math.round((screen.availWidth*2)/100);
        wHeight = Math.round((screen.availHeight*2)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        busqueda = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=no,status=no,scrollbars=no,top=" + wYPos + ",left=" + wXPos);
        if (busqueda.opener == null) busqueda.opener = window;
        busqueda.focus();
    }
}

function validarFechaActual(campo){

    var today = new Date();

    var mesActual =  today.getMonth();
    mesActual++; //el mes esta entre 0 y 11

    var diaActual = today.getDate();
    cadena=campo.value;
    var longitud = cadena.length ;
    var anno= cadena.substring(0,4);
    var mes= cadena.substring(5,7);
    var dia= cadena.substring(8,longitud);
    if(anno!=2003){
        alert('Fecha Inválida: Verifique el AÑO del campo fecha');
        return false;
    }


    if(mes>mesActual)
    {
       alert('Fecha Inválida: Verifique el MES del campo fecha');
       return false;
    }
    if((mes==mesActual)&&(dia>diaActual)){
       alert('Fecha Inválida: Verifique el MES y DÍA del campo fecha');
       return false;
    }

    return true;
}



function wincombo4(valor, valor2, valor3, valor4,url,w,h,posicionArestar)
{
// FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
// RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
// EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
//    alert ('h '+h);
//    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else{// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }

        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;


    url = url+"&patron2="+valor2.value;
    url = url+"&patron3="+valor3.value;
    url = url+"&patron4="+valor4.value;
        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}


function wincombo5(valor, valor2, valor3, valor4, valor5, url,w,h,posicionArestar)
{
// FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
// RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
// EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
//    alert ('h '+h);
//    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1){
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else{// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }

    var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;




    url = url+"&patron2="+valor2.value;
    url = url+"&patron3="+valor3.value;
    url = url+"&patron4="+valor4.value;
    url = url+"&patron5="+valor5.value;

        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

function wincombo6(valor, valor2, valor3, valor4, valor5, valor6, url,w,h,posicionArestar)
{
// FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
// RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
// EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
//    alert ('h '+h);
//    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }

        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;




    url = url+"&patron2="+valor2.value;
    url = url+"&patron3="+valor3.value;
    url = url+"&patron4="+valor4.value;
    url = url+"&patron5="+valor5.value;
    url = url+"&patron6="+valor6.value;

        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}


function wincombo7(valor, valor2, valor3, valor4, valor5, valor6, valor7, url,w,h,posicionArestar)
{
// FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
// RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
// EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
//    alert ('h '+h);
//    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }

        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;




    url = url+"&patron2="+valor2.value;
    url = url+"&patron3="+valor3.value;
    url = url+"&patron4="+valor4.value;
    url = url+"&patron5="+valor5.value;
    url = url+"&patron6="+valor6.value;
    url = url+"&patron7="+valor7.value;

        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

function wincombo8(valor, valor2, valor3, valor4, valor5, valor6, valor7, valor8, url,w,h,posicionArestar)
{
// FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
// RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
// EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
//    alert ('h '+h);
//    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }

        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;



    url = url+"&patron2="+valor2.value;
    url = url+"&patron3="+valor3.value;
    url = url+"&patron4="+valor4.value;
    url = url+"&patron5="+valor5.value;
    url = url+"&patron6="+valor6.value;
    url = url+"&patron7="+valor7.value;
    url = url+"&patron8="+valor8.value;

        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

function wincombo9(valor, valor2, valor3, valor4, valor5, valor6, valor7, valor8, valor9, url,w,h,posicionArestar)
{
// FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
// RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
// EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
//    alert ('h '+h);
//    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }

        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;



    url = url+"&patron2="+valor2.value;
    url = url+"&patron3="+valor3.value;
    url = url+"&patron4="+valor4.value;
    url = url+"&patron5="+valor5.value;
    url = url+"&patron6="+valor6.value;
    url = url+"&patron7="+valor7.value;
    url = url+"&patron8="+valor8.value;
    url = url+"&patron9="+valor9.value;

        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

function wincombo10(valor, valor2, valor3, valor4, valor5, valor6, valor7, valor8, valor9, valor10, url,w,h,posicionArestar)
{
// FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
// RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
// EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
//    alert ('h '+h);
//    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }

        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;



    url = url+"&patron2="+valor2.value;
    url = url+"&patron3="+valor3.value;
    url = url+"&patron4="+valor4.value;
    url = url+"&patron5="+valor5.value;
    url = url+"&patron6="+valor6.value;
    url = url+"&patron7="+valor7.value;
    url = url+"&patron8="+valor8.value;
    url = url+"&patron9="+valor9.value;
    url = url+"&patron10="+valor10.value;

        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

function wincombo11(valor, valor2, valor3, valor4, valor5, valor6, valor7, valor8, valor9, valor10, valor11, url,w,h,posicionArestar)
{
// FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
// RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
// EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
//    alert ('h '+h);
//    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }

        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;



    url = url+"&patron2="+valor2.value;
    url = url+"&patron3="+valor3.value;
    url = url+"&patron4="+valor4.value;
    url = url+"&patron5="+valor5.value;
    url = url+"&patron6="+valor6.value;
    url = url+"&patron7="+valor7.value;
    url = url+"&patron8="+valor8.value;
    url = url+"&patron9="+valor9.value;
    url = url+"&patron10="+valor10.value;
    url = url+"&patron11="+valor11.value;

        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

function cambiar_tildes(valor)
{

    var tempo='';

    var holding = valor.value.length;

    var holding = valor.value.charAt(0);


    for(var j=0 ; j< valor.value.length ; j ++)
    {

    var char1 = valor.value.charAt(j);

    if ((char1=='á')||(char1=='Á')||(char1=='à'))
        char1='//aacute//';
    else
    if ((char1=='é')||(char1=='É')||(char1=='è'))
        char1='//eacute//';
    else
    if ((char1=='í')||(char1=='Í')||(char1=='ì'))
        char1='//iacute//';
    else
    if ((char1=='ó')||(char1=='Ó')||(char1=='ò'))
        char1='//oacute//';
    else
    if ((char1=='ú')||(char1=='Ú')||(char1=='ù'))
        char1='//uacute//';

    tempo = tempo + char1;

    }

    return tempo;
}


function wincombo2(valor, valor2, url,w,h,posicionArestar)
{
    // FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
    // RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
    // EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
    //    alert ('h '+h);
    //    url = url+"&patron="+valor.value;
    var i;

    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }


    var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;



    url = url+"&patron2="+valor2.value;
        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}


function wincombo3(valor, valor2, valor3, url,w,h,posicionArestar)
{
    // FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
    // RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
    // EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
    //    alert ('h '+h);
    //    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else{// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }


        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;



    url = url+"&patron2="+valor2.value+"&patron3="+valor3.value;
        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

//Modificacion para la segunda forma en la forma de doble maestro
function wincombo3_2_forma(valor, valor2, valor3, url,w,h,posicionArestar)
{
    // FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
    // RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
    // EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
    //    alert ('h '+h);
    //    url = url+"&patron="+valor.value;
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma_2(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma_2(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }


        var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;



    url = url+"&patron2="+valor2.value+"&patron3="+valor3.value;
        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

function obtenerPosicionElementoforma (Elemento)
{

 var i;
  for(i=0;i<document.forma.length;i++)
     if(document.forma.elements[i].name==Elemento.name)
     {
            return i;
     }

   alert("El elemento "+Elemento.name+" No se encuentra en la forma");
}

//Modificacion realizada para la forma con dos maestros
function obtenerPosicionElementoforma_2 (Elemento)
{

 var i;
  for(i=0;i<document.forma2.length;i++)
     if(document.forma2.elements[i].name==Elemento.name)
     {
            return i;
     }

   alert("El elemento "+Elemento.name+" No se encuentra en la forma");
}



function wincombo(valor, url,w,h,posicionArestar)
{
    // FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
    // RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
    // EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
    //    alert ('h '+h);
    var i;
    if (posicionArestar > 1)
    {
        i = obtenerPosicionElementoforma(valor)-posicionArestar;
        //alert ("J diferente de 1, variableCalculada= "+i);
    }
    else
    {// Igual a 1, para wincombos tradicionales
        i = obtenerPosicionElementoforma(valor)-1;
        //alert ("J igual de 1,variableCalculada=  "+i);
    }


    var valor_para_consulta=cambiar_tildes(valor);

    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor_para_consulta+"&variableCalculada="+i;



    wWidth = Math.round((screen.availWidth*w)/100);
    wHeight = Math.round((screen.availHeight*h)/100);
    wXPos = Math.round((screen.availWidth - wWidth) / 2);
    wYPos = Math.round((screen.availHeight - wHeight ) / 2);
    var miventana;
    miventana = window.open (url,"","width="+wWidth+",height="+wHeight+",resizable=yes,dependent=yes,status=no,scrollbars=yes,top="+wYPos+",left="+wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}




function abrirVentana(url,w,h)
{
    wWidth = Math.round((screen.availWidth*w)/100);
    wHeight = Math.round((screen.availHeight*h)/100);
    wXPos = Math.round((screen.availWidth - wWidth) / 2);
    wYPos = Math.round((screen.availHeight - wHeight ) / 2);
    var miventana;

    miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight +",resizable=1,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);

      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

// Esta ventana se coloca encima de la ventana padre
function abrirVentanaDialogo(url,w,h)
{
    wWidth = Math.round((screen.availWidth*w)/100);
    wHeight = Math.round((screen.availHeight*h)/100);
    wXPos = Math.round((screen.availWidth - wWidth) / 2);
    wYPos = Math.round((screen.availHeight - wHeight ) / 2);
    var miventana;

    miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight +",resizable=1,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);

      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}


function abrirUrl(url)
{
  window.location.href=url;
}


function imprimir()
{
     window.print();
}

function cerrar()
{
     window.close();
}

function bloquearElemento(campo)
{
  campo.blur();
}

function busquedaRegistro3(valor,valor2,valor3,url,posicionAsumar)
{
// FUNCION QUE PERMITE BUSCAR UN VALOR DE ACUERDO AL IDENTIFICACOR QUE SE HAYA DIGITADO
    valor_forma = valor.value;
    if (valor_forma != ""){

        var i;
        if (posicionAsumar > 1){
            i = obtenerPosicionElementoforma(valor)+posicionAsumar;
            //alert ("J diferente de 1, posCalculada= "+i);
        }
        else{// Igual a 1, para wincombos tradicionales
            i = obtenerPosicionElementoforma(valor)+1;
            //alert ("J igual de 1,posCalculada=  "+i);
        }


        url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor.value+"&posCalculada="+i;
        url = url+"&patron2="+valor2.value;
        url = url+"&patron3="+valor3.value;

        wWidth = Math.round((screen.availWidth*2)/100);
        wHeight = Math.round((screen.availHeight*2)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        busqueda = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=no,status=no,scrollbars=no,top=" + wYPos + ",left=" + wXPos);
        if (busqueda.opener == null) busqueda.opener = window;
        busqueda.focus();
    }
}

function busquedaRegistro(valor,url,posicionAsumar)
{
// FUNCION QUE PERMITE BUSCAR UN VALOR DE ACUERDO AL IDENTIFICACOR QUE SE HAYA DIGITADO
    valor_forma = valor.value;
    if (valor_forma != ""){

        var i;
        if (posicionAsumar > 1)
        {
            i = obtenerPosicionElementoforma(valor)+posicionAsumar;
            //alert ("J diferente de 1, posCalculada= "+i);
        }
        else{// Igual a 1, para wincombos tradicionales
            i = obtenerPosicionElementoforma(valor)+1;
            //alert ("J igual de 1,posCalculada=  "+i);
        }

        url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&patron="+valor.value+"&posCalculada="+i;



        wWidth = Math.round((screen.availWidth*2)/100);
        wHeight = Math.round((screen.availHeight*2)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;
        busqueda = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,status=no,scrollbars=no,top=" + wYPos + ",left=" + wXPos);
        if (busqueda.opener == null) busqueda.opener = window;
        busqueda.focus();
    }
}


function irA()
{
        location=document.informes.option.options[document.informes.option.selectedIndex].value
}


function cancelar()
{
     window.close();
}



var isIE=document.all?true:false;
var isDOM=document.getElementById?true:false;
var isNS4=document.layers?true:false;


/* _w : which ID (1) or (2) */
/* _h : (h)ide or (s)how */

function ocultandoElementosForma(_w1,_w2,_w3,_w4,_w5,_h) {
    if (isDOM){
        if (_h=='s')
        {
            if(_w1!='')
                document.getElementById(_w1).style.visibility='visible';
            if(_w2!='')
                document.getElementById(_w2).style.visibility='visible';
            if(_w3!='')
                document.getElementById(_w3).style.visibility='visible';
            if(_w4!='')
                document.getElementById(_w4).style.visibility='visible';
            if(_w5!='')
                document.getElementById(_w5).style.visibility='visible';

        }
        if (_h=='h'){
            if(_w1!='')
                document.getElementById(_w1).style.visibility='hidden';
            if(_w2!='')
                document.getElementById(_w2).style.visibility='hidden';
            if(_w3!='')
                document.getElementById(_w3).style.visibility='hidden';
            if(_w4!='')
                document.getElementById(_w4).style.visibility='hidden';
            if(_w5!='')
                document.getElementById(_w5).style.visibility='hidden';
        }
    }
    else if (isIE)
    {
        if (_h=='s')
        {
            eval("document.all."+_w1+".style.visibility='visible';");
            eval("document.all."+_w2+".style.visibility='visible';");
            eval("document.all."+_w3+".style.visibility='visible';");
            if(_w4!='')
                eval("document.all."+_w4+".style.visibility='visible';");
            if(_w5!='')
                eval("document.all."+_w5+".style.visibility='visible';");
        }
        if (_h=='h')
        {
            eval("document.all."+_w1+".style.visibility='hidden';");
            eval("document.all."+_w2+".style.visibility='hidden';");
            eval("document.all."+_w3+".style.visibility='hidden';");
            if(_w4!='')
                eval("document.all."+_w4+".style.visibility='hidden';");
            if(_w5!='')
                eval("document.all."+_w5+".style.visibility='hidden';");
        }
    }
    else if(isNS4)
    {
        if (_h=='s')
        {
            eval("document.layers['"+_w1+"'].visibility='show';");
            eval("document.layers['"+_w2+"'].visibility='show';");
            eval("document.layers['"+_w3+"'].visibility='show';");
            if(_w4!='')
                eval("document.layers['"+_w4+"'].visibility='show';");
            if(_w5!='')
                eval("document.layers['"+_w5+"'].visibility='show';");
        }
        if (_h=='h')
        {
            eval("document.layers['"+_w1+"'].visibility='hide';");
            eval("document.layers['"+_w2+"'].visibility='hide';");
            eval("document.layers['"+_w3+"'].visibility='hide';");
            if(_w4!='')
                eval("document.layers['"+_w4+"'].visibility='hide';");
            if(_w5!='')
                eval("document.layers['"+_w5+"'].visibility='hide';");
        }
    }
}


function estaVacio(valor,nombre)
{
    if(valor.value=="")
    {
        alert("El area "+nombre+" se encuentra vacia");

    }
}



function wincomboCriteriosBusquedaAdicional(valor, valor2, url,w,h)
{
        url = url+"&patron="+valor.value+"&coo_obj_nombre="+valor2.options[valor2.selectedIndex].value;
        alert('coo_obj_nombre '+valor2.options[valor2.selectedIndex].value);
        wWidth = Math.round((screen.availWidth*w)/100);
        wHeight = Math.round((screen.availHeight*h)/100);
        wXPos = Math.round((screen.availWidth - wWidth) / 2);
        wYPos = Math.round((screen.availHeight - wHeight ) / 2);
        var miventana;

        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
        if (miventana.opener == null) miventana.opener = window;
        miventana.focus();
}


function wincomboPrograma(valor, valor2, url,w,h)
{
    // FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
    // RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
    // EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
    //      alert ('h '+h);
    //(document.forma.tipcatid.options[0].selected == true)
    url = url+"&patron="+valor.value+"&patron2="+valor2.options[valor2.selectedIndex].value;
    // alert('sede '+valor2.options[valor2.selectedIndex].value);
    wWidth = Math.round((screen.availWidth*w)/100);
    wHeight = Math.round((screen.availHeight*h)/100);
    wXPos = Math.round((screen.availWidth - wWidth) / 2);
    wYPos = Math.round((screen.availHeight - wHeight ) / 2);
    var miventana;
    miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
    if (miventana.opener == null) miventana.opener = window;
    miventana.focus();
}


function wincomboPruebaadicional(valor,valor2,valor3,valor4,valor5,url,w,h)
{
    // FUNCION QUE PERMITE ABRIR LA VENTANA PARA EL WINCOMBO
    // RECIBE EL VALOR(CADENA) CON EL CUAL SE VA A HACER LA BUSQUEDA PARA MOSTRAR
    // EN EL WINCOMBO, Y LA URL(EL ARCHIVO QUE SE VA A ABRIR=wincombo.php)
    //      alert ('h '+h);
    //(document.forma.tipcatid.options[0].selected == true)
    url = url+"&patron="+valor.value+"&patron2="+valor2.options[valor2.selectedIndex].value+"&patron3="+valor3.value+"&patron4="+valor4.value+"&patron5="+valor5.value;
    // alert('sede '+valor2.options[valor2.selectedIndex].value);
    wWidth = Math.round((screen.availWidth*w)/100);
    wHeight = Math.round((screen.availHeight*h)/100);
    wXPos = Math.round((screen.availWidth - wWidth) / 2);
    wYPos = Math.round((screen.availHeight - wHeight ) / 2);
    var miventana;
    miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
    if (miventana.opener == null) miventana.opener = window;
    miventana.focus();
}


function buscarAtributos(estaticos,dinamicos,tabla,tipo,url)
{
    var w = 50;
    var h = 70;
    var i;
    i = obtenerPosicionElementoforma(dinamicos);
    url = "/"+aplicacion+"/paquetes/herramientas/"+url+"&valor="+i+"&estaticos="+estaticos.value+"&dinamicos="+dinamicos.value+"&tabla="+tabla.value+"&tipo="+tipo.value;

    wWidth = Math.round((screen.availWidth*w)/100);
    wHeight = Math.round((screen.availHeight*h)/100);
    wXPos = Math.round((screen.availWidth - wWidth) / 2);
    wYPos = Math.round((screen.availHeight - wHeight ) / 2);
    var miventana;
    miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}// END function buscarAtributos


function radioButton (forma,elemento,contador)
{
    var indice = 0;
    for(var i=0;i<forma.elements.length;i++)
    {
        if(forma.elements[i].name == elemento)
        {
            if(indice != contador){
                forma.elements[i].checked = false;
            }
            indice++;
        }
    }
}// END function radioButton


function chequearGrupo (forma,elemento,contador,tamano)
{
    var cadena;
    var indice = 0;
    flag = elemento.checked;
    for(var i=0;i<forma.elements.length;i++)
    {
        cadena = forma.elements[i].name;
        if(cadena.match('grupo_nuevo'))
        {
            if(indice != contador)
            {
                forma.elements[i].checked = false;
            }
            else
            {
                forma.elements[i].checked = flag;
            }
            indice++;
            if(indice == tamano)
            {
                indice = 0;
            }
        }
        else if(cadena != elemento.name)
        {
            forma.elements[i].checked = false;
        }
    }
}// END function chequearGrupo


function chequearAsignatura (forma,elemento,contador,tamano)
{
    var cadena;
    var indice = 0;
    flag = elemento.checked;
    for(var i=0;i<forma.elements.length;i++)
    {
        cadena = forma.elements[i].name;
        if(cadena.match('asignaturaVocacion'))
        {
            if(indice != contador)
            {
                forma.elements[i].checked = false;
            }
            else
            {
                forma.elements[i].checked = flag;
            }
            indice++;
            if(indice == tamano)
            {
                indice = 0;
            }
        }
        else if(cadena != elemento.name)
        {
            forma.elements[i].checked = false;
        }
    }
}// END function chequearAsignatura


function chequearPeriodo (forma,elemento,contador,tamano)
{
    var cadena;
    var indice = 0;
    flag = elemento.checked;
    for(var i=0;i<forma.elements.length;i++)
    {
        cadena = forma.elements[i].name;
        if(cadena.match('periodo'))
        {
            if(indice != contador)
            {
                forma.elements[i].checked = false;
            }
            else
            {
                forma.elements[i].checked = flag;
            }
            indice++;
            if(indice == tamano)
            {
                indice = 0;
            }
        }
        else if(cadena != elemento.name)
        {
            forma.elements[i].checked = false;
        }
    }
}// END function chequearPeriodo


function chequearColumna (forma,elemento)
{
    var cadena;
    var indice = 0;
    flag = elemento.checked;
    for(var i=0;i<forma.elements.length;i++)
    {
        cadena = forma.elements[i].name;
        if(cadena.match(elemento.name))
        {
            forma.elements[i].checked = flag;
        }
    }
}// END function chequearColumna




function limpiarWincomboUnaLlave (forma,elemento)
{
    for(var i=0;i<forma.elements.length;i++)
    {
        if(forma.elements[i].name == elemento)
        {
            forma.elements[i-1].value = "";
            forma.elements[i].value = "";
        }
    }
}// END function limpiarWincomboUnaLlave

function limpiarCampoEnParticular (forma,elemento)
{
    for(var i=0;i<forma.elements.length;i++)
    {
        if(forma.elements[i].name == elemento)
        {
            forma.elements[i].value = "";
        }
    }
}// END function limpiarCampoEnParticular


function limpiarWincomboDosLlaves (forma,elemento)
{
    for(var i=0;i<forma.elements.length;i++)
    {
        if(forma.elements[i].name == elemento)
        {
            forma.elements[i-2].value = "";
            forma.elements[i-1].value = "";
            forma.elements[i].value = "";
        }
    }
}// END function limpiarWincomboDosLlaves

function limpiarWincomboTresLlaves (forma,elemento)
{
    for(var i=0;i<forma.elements.length;i++)
    {
        if(forma.elements[i].name == elemento)
        {
            forma.elements[i-3].value = "";
            forma.elements[i-2].value = "";
            forma.elements[i-1].value = "";
            forma.elements[i].value = "";
        }
    }
}// END function limpiarWincomboDosLlaves

function limpiarWincomboGeneralizado (forma,elemento,num_a_limpiar)
{
    for(var i=0;i<forma.elements.length;i++)
    {
        if(forma.elements[i].name == elemento)
        {
            for(var j=0;j<=num_a_limpiar;j++)
            {
                forma.elements[i-j].value = "";
            }

        }
    }
}// END function limpiarWincomboDosLlaves


// Esta función abre en una ventana nueva la forma de inserción del maestro asociado elegido en
// el SELECT de maestros asocidos del maestro base sobre el que se está trabajando
function abrirMaestro()
{
    var w = 80;
    var h = 60;
    wWidth = Math.round((screen.availWidth*w)/100);
    wHeight = Math.round((screen.availHeight*h)/100);
    wXPos = Math.round((screen.availWidth - wWidth) / 2);
    wYPos = Math.round((screen.availHeight - wHeight ) / 2);
    var miventana;

    url = document.forma.maestro.options[document.forma.maestro.selectedIndex].value;

    if(url != ""){
        miventana = window.open (url,"","width=" + wWidth + ",height=" + wHeight + ",resizable=yes,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);
          if (miventana.opener == null) miventana.opener = window;
          miventana.focus();
    }// END if(url != "")
}// END function abrirMaestro


function abrirVentanaEdicion(nombre_boton,nombre_campo,nombre_archivo,cols,rows)
{

    if (!nombre_archivo)
    {
        nombre_archivo = "ventana_edicion.php";
    }

    url= "/"+aplicacion+"/paquetes/herramientas/"+nombre_archivo+"?nombre_boton=" + nombre_boton + "&" + "nombre_campo=" + nombre_campo + "&" + "cols=" + cols + "&" + "rows=" + rows;

    w = 50;
    h = 40;
    wWidth = Math.round((screen.availWidth*w)/100);
    wHeight = Math.round((screen.availHeight*h)/100);
    wXPos = Math.round((screen.availWidth - wWidth) / 2);
    wYPos = Math.round((screen.availHeight - wHeight ) / 2);
    var miventana;

    miventana = window.open (url,"Ventana","width=" + wWidth + ",height=" + wHeight +",resizable=1,dependent=yes,status=no,scrollbars=yes,top=" + wYPos + ",left=" + wXPos);

}

function remLink()
{
      if (window.sList && window.sList.open && !window.sList.closed)
      {
        window.sList.opener = null;
    }
}

//Iluminar elementos del formulario

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Tipos de Elementos a iluminiar
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Verificar el evento onClick
function checkel(which)
{
        if (which.style&&intended.test(which.tagName))
        {
        if (ns6&&eventobj.nodeType==3)
        eventobj=eventobj.parentNode.parentNode
        return true
        }
        else
        return false
        }

//Función Iluminar elemento del formulario
function iluminarElemento(e)
{
        eventobj=ns6? e.target : event.srcElement
        if (previous!=''){
        if (checkel(previous))
        previous.style.backgroundColor=''
        previous=eventobj
        if (checkel(eventobj))
        eventobj.style.backgroundColor=highlightcolor
        }
        else{
        if (checkel(eventobj))
        eventobj.style.backgroundColor=highlightcolor
        previous=eventobj
        }
}


function aparece(id)
{
  var objeto = document.getElementById(id);
  objeto.style.display = 'block';
  if(!document.all)
  {
     //window.resizeBy(-1,-1);
     //window.resizeBy(1,1);
  }
}

function desaparece(id)
{
  //alert ('id '+id)
  var objeto = document.getElementById(id);
  objeto.style.display = 'none';
  if(!document.getElementById)
  {
     window.resizeBy(-1,-1);
     window.resizeBy(1,1);
  }
}


function MM_findObj(n, d)
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage()
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore()
{ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages()
{ //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function confirmarCerrarSession()
{
    var respuesta=confirm("¿Está seguro que desea salir del SISTEMA?");
    if (respuesta)
    {
        url = "/"+aplicacion+"/paquetes/autenticacion/salir.php";
        window.location=url;
        return true ;
    }
    else
    {
        return false ;
    }
}


function confirmarBorrarRegistro()
{
    var respuesta=confirm("¿Está seguro de Borrar el Registro del SISTEMA?");
    if (respuesta)
    {
        return true ;
    }
    else
    {
        return false ;
    }
}


function oNumero(numero)
{
    //Propiedades
    this.valor = numero || 0
    this.dec = -1;
    //Métodos
    this.formato = numFormat;
    this.ponValor = ponValor;
    //Definición de los métodos
    function ponValor(cad)
    {
        if (cad == '-' || cad == '+')
            return
        if (cad.length == 0)
            return
        if (cad.indexOf('.') >= 0)
            this.valor = parseFloat(cad);
        else
            this.valor = parseInt(cad);
    }

    function numFormat(dec, miles)
    {
        var num = this.valor, signo=3, expr;
        var cad = ""+this.valor;
        var ceros = "", pos, pdec, i;
        for (i=0; i < dec; i++)
            ceros += '0';
        pos = cad.indexOf('.')
        if (pos < 0)
            cad = cad+"."+ceros;
        else
        {
            pdec = cad.length - pos -1;
            if (pdec <= dec)
            {
                for (i=0; i< (dec-pdec); i++)
                    cad += '0';
            }
            else
            {
                num = num*Math.pow(10, dec);
                num = Math.round(num);
                num = num/Math.pow(10, dec);
                cad = new String(num);
            }
        }
        pos = cad.indexOf('.')
        if (pos < 0)
            pos = cad.lentgh
        if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+')
           signo = 4;
        if (miles && pos > signo)
            do
            {
                expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
                cad.match(expr)
                cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
            }
        while (cad.indexOf(',') > signo)
            if (dec<0) cad = cad.replace(/\./,'')
                return cad;
    }

}//Fin del objeto oNumero:



function iniciarCambio(idForm, idCampo)
{
    var obj = document.getElementsByName(idForm);
    obj[0].minumero = new oNumero()
    obj[0].idCampo = idCampo;
    obj[0].posDec = 2;
    obj[0].miles = true;
    obj[0].onkeyup = procTecla;
}

function procTecla(ev)
{
    var cadena='';
    var pd , minum;
    var campo = this.idCampo
    if (!document.all) event=ev
    if (event.keyCode >36 && event.keyCode <41)
        return
    if ((event.keyCode != 110) && (event.keyCode < 96 || event.keyCode > 105))
        return
    if (event.keyCode < 96 || event.keyCode > 106)
        return
    if (this[campo].value=='0')
         this[campo].value = '';
    cadena = this[campo].value;
    if ((event.keyCode == 109 || event.keyCode == 107) &&    cadena.length >0)
             return
    if (event.keyCode == 110)
        if (pd < cadena.length-1 || pd==0)
        {
            cadena = cadena.substr(0, cadena.length-1)
            if (cadena.length==0) cadena ='0.'
                return
        }
    pd = cadena.indexOf('.')
    if (pd >= 0)
        pd = cadena.length - pd -1;
    else
        pd = -1
    if (pd > this.posDec )
    {
        cadena = cadena.substr(0, cadena.length-1)
        pd=this.posDec;
    }
    this.minumero.ponValor(cadena.replace(/\,/g,''))
    cadena = this.minumero.formato(pd, this.miles)
    if (cadena=='0')
         cadena =""
    this[campo].value = cadena
}


function cambiar(campo)
{
    var numero = new oNumero(campo.value);
    var cadena = numero.valor;
    numero.ponValor(cadena.replace(/\,/g,''));
    campo.value=numero.formato(2,true);
    return;
}
function cambiar2(campo)
{
    var numero = new oNumero(campo.value);
    var cadena = numero.valor;
    numero.ponValor(cadena.replace(/\,/g,''));
    campo.value=numero.formato(0,false);
    return;
}

function limpiarBarraEstado()
{
      window.status='';
}

function verificarNavegadorAUsar(navegador_preferido)
{
    var navegador_detectado = navigator.appName;
    if (navegador_preferido != navegador_detectado)
    {
        alert ('Su navegador NO es recomendado para el uso de este software, navegador detectado es='+navegador_detectado);
        //window.close();
        url = "/"+aplicacion+"/";
        window.location=url;

    }

}

function handleEnter (field, event)
{
  var keyCode = event.keyCode ? event.keyCode :
                event.which ? event.which : event.charCode;
  if (keyCode == 13) {
    var i;
    for (i = 0; i < field.form.elements.length; i++)
      if (field == field.form.elements[i])
        break;
    i = (i + 1) % field.form.elements.length;
    field.form.elements[i].focus();
    return false;
  }
  else
    return true;
}


function handleEnterNuevo (field, event, nextfield)
{
  var keyCode = event.keyCode ? event.keyCode :
                event.which ? event.which : event.charCode;
  if (keyCode == 13) 
  {
      eval('document.forma.' + nextfield + '.focus()');
    return false;
  }
  else
    return true;
}

function obtenerObjetoHTML(nombreObjeto)
{
    eval ('retornar = document.forma.elements["'+nombreObjeto+'"]');
    return retornar;
}


function obtenerObjetoHTMLDeOpener(nombreObjeto)
{
    for(var i=0;i<window.opener.document.forma.elements.length;i++)
    {
        objeto = window.opener.document.forma.elements[i];
        if(objeto.name==nombreObjeto)
        {
            return objeto;
        }
    }

    return null;
}


function colocarAvisoDeEspera()
{
    var Cadena = '<img src="/imagenes/ico_ocupado.gif" alt="Espere un momento por favor...">';
    var obj = document.getElementById("cargando");
    obj.innerHTML = Cadena;
}

function ConsultarAyuda(modulo,atributo)
{
    url = "/"+aplicacion+"/paquetes/herramientas/ayuda.php?modulo="+modulo+"&atributo="+atributo;
    abrirVentana(url,'35','35')
}

function abrirVentanaMaximizada(url)
{
    var miventana;

    miventana = window.open (url,"","resizable=1,status=no,scrollbars=yes");

    miventana.resizeTo(screen.availWidth, screen.availHeight);
    miventana.moveTo(0,0);

      if (miventana.opener == null) miventana.opener = window;
      miventana.focus();
}

function whichKey(km)
{
if (NS){
    //if ( (km.which==16) || (km.which==17) || (km.which==18) )
    if ( (km.which==17) || (km.which==18) )
       {  alert("Función Deshabilitada.");  }
}
else{
    //if ( (event.altLeft) || (event.altKey) || (event.ctrlKey) || (event.shiftKey) )
    if ( (event.altLeft) || (event.altKey) || (event.ctrlKey) )
       {  alert("Función Deshabilitada.");  }
}

}
//document.onkeydown = whichKey;

// rijarami 2005-08-18
// Está función permite desplegar la ventana de confirmación cuando el usuario ha marcado algún registro para eliminar en un
// formulario de maestroDetalle
function confirmarEliminacionRegistro (contador)
{
    eliminado = false;
    for(i=0;i<contador;i++)
    {
        eval('marcado = document.forma.eliminar'+i+'.checked');
        if(marcado)
        {
            eliminado = true;
            break;
        }
    }
    if(eliminado)
    {
        return confirm('¿Está seguro(a) que desea eliminar los registros seleccionados?');
    }
    return true;
}

var nav4 = window.Event ? true : false;
function acceptNum(evt)
{    
    // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57    
    var key = nav4 ? evt.which : evt.keyCode;    
    return (key <= 13 || (key >= 48 && key <= 57)); 
} 

/*
* INICIO: Funciones Para Busqueda Rápida en AJAX
*
*/
function createRequestObject() 
{
   var req;
   if(window.XMLHttpRequest){
      // Firefox, Safari, Opera...
      req = new XMLHttpRequest();
   } else if(window.ActiveXObject) {
      // Internet Explorer 5+
      req = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      // There is an error creating the object,
      // just as an old browser is being used.
      alert('Problema creando el Objeto XMLHttpRequest');
   }
   return req;
}//END: function createRequestObject() 


function executeScriptPost(httpRequestObject,url,handleResponse,option,params)
{
    // Open PHP script for requests
    // httpRequestObject.abort;
    httpRequestObject.open('POST', url);
    httpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

    // Función en JS que va a manejar los datos para colocarlos en la forma.
    httpRequestObject.onreadystatechange = handleResponse;
    httpRequestObject.send('option='+option+'&params='+params);

}//END: function executeScriptPost(httpRequestObject,url,handleResponse,option,params)


var http_desplegarbusquedaDePatronAjax = createRequestObject();

function busquedaDePatronAjax (campo_wincombo, event, campo_oculto, accion_php, ensamblar_wincombo_tradicional)
{
  var keyCode = event.keyCode ? event.keyCode :
                event.which ? event.which : event.charCode;


  if (keyCode == 13) 
  {

      var nombre_campo_oculto = campo_oculto.name;

      var valor_campo = campo_wincombo.value;
      var nombre_campo = campo_wincombo.name;

      /*
    alert ('valor_campo '+valor_campo);
      alert ('nombre_campo '+nombre_campo);
      alert ('accion_php '+accion_php);
    */
    executeScriptPost(http_desplegarbusquedaDePatronAjax,PATH_PAQUETE_WEB+'/herramientas/consultasAjax.php',colocarBusquedaDePatronAjaxEnFormulario,'realizarBusquedaDePatronAjax',valor_campo+','+nombre_campo+','+nombre_campo_oculto+','+accion_php+','+ensamblar_wincombo_tradicional);

    return false;

  }
  else
    return true;
}

function colocarBusquedaDePatronAjaxEnFormulario ()
{
    if(http_desplegarbusquedaDePatronAjax.readyState == 4 && http_desplegarbusquedaDePatronAjax.status == 200)
    {
        // Text returned FROM the PHP script
        var response = http_desplegarbusquedaDePatronAjax.responseText;

        // Nota 4: Análogo al EXPLOT en PHP
        var lista = response.split(/delimitadorKKK\s*/); 

        // Si retornó resultados la consulta
        if (lista != '')
        {
            var campo_oculto_codigo = lista[0];
            var Nuevoresponse = lista[1];


            //alert ('lista '+lista);
            //alert ('campo_oculto_codigo '+campo_oculto_codigo);
            //alert ('Nuevoresponse '+Nuevoresponse);

            if(response) 
            {
                // UPDATE periodo_codigo_estudiante content
                eval("document.getElementById(\"id_\"+campo_oculto_codigo).innerHTML = Nuevoresponse;");
            }
        }
        else
        {
            alert ('La consulta NO arrojó un solo resultado, utilice el botón: Buscar...');

        }

    }
    return;
}//END: function colocarDatosGrupoEnElFormulario (cadenaDatos)
/*
* FIN Funciones Para Busqueda Rápida en AJAX
*
*/


/*
 *
 * Funciones para el manejo del POP-BOX
 *
 */
var estadoCapaPop = false;
function controlarCapa (nombreCapa)
{
    if(!estadoCapaPop)
    {
        showpopbox(nombreCapa);
        this.estadoCapaPop = true;
    }
    else
    {
        hidepopbox(nombreCapa);
        this.estadoCapaPop = false;
    }
    return;
}

// Embedded Popups
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
function showpopbox(sName,offsetX,offsetY) {
    // fix burn through
    fixBurnThru(true);

    if (document.getElementById(sName+'_link') != null) {
        // get the position of the associated link
        var xPos = findPosX(document.getElementById(sName+'_link'));
        var yPos = findPosY(document.getElementById(sName+'_link'));
        // pad the position so the link will not be covered
        xPos = xPos + 5;
        yPos = yPos + 13;
    } else {
        // if there's no link to attach to, put the popup under the nav
        var xPos = 100;
        var yPos = 150;
    }
    // move elements if needed
    if (!isNaN(offsetX)) {
        xPos = xPos + offsetX;
    }
    if (!isNaN(offsetY)) {
        yPos = yPos + offsetY;
    }
    if (offsetX == 'abs') {
        xPos = 100;
    }
    // opens the embedded popups
    document.getElementById(sName).style.display = 'block';
    document.getElementById(sName).style.left = xPos + "px";
    document.getElementById(sName).style.top = yPos + "px";
    return;
}
function showpopboxnew(sName,sLink,offsetX,offsetY) {
    // fix burn through
    fixBurnThru(true);

    if (document.getElementById(sLink) != null) {
        // get the position of the associated link
        var xPos = findPosX(document.getElementById(sLink));
        var yPos = findPosY(document.getElementById(sLink));
        // pad the position so the link will not be covered
        xPos = xPos + 5;
        yPos = yPos + 13;
    } else {
        // if there's no link to attach to, put the popup under the nav
        var xPos = 100;
        var yPos = 150;
    }
    // move elements if needed
    if (!isNaN(offsetX)) {
        xPos = xPos + offsetX;
    }
    if (!isNaN(offsetY)) {
        yPos = yPos + offsetY;
    }
    if (offsetX == 'abs') {
        xPos = 100;
    }
    // opens the embedded popups
    document.getElementById(sName).style.display = 'block';
    document.getElementById(sName).style.left = xPos + "px";
    document.getElementById(sName).style.top = yPos + "px";
    return;
}
function showinlinepopbox(sName) {
    // fix burn through
    fixBurnThru(true);
    // opens the embedded popups
    document.getElementById(sName).style.display = 'block';
    return;
}
function hidepopbox(sName) {
    // Closes the embedded popups
    document.getElementById(sName).style.display = 'none';
    // fix burn through
    fixBurnThru(false);
    return;
}

function fixBurnThru(isHidden) {
    if (document.all) {
        var rows = document.getElementsByTagName('select');
        for( var i = 0, row; row = rows[i]; i++ ) {
            if (isHidden) {
                row.style.visibility = "hidden";
            } else {
                row.style.visibility = "visible";
            }
        }
    }
    return;
}

function TrimRight( str ) {
    var resultStr = '';
    var i = 0;

    // Return immediately if an invalid value was passed in
    if (str+'' == 'undefined' || str == null)    
        return null;

    // Make sure the argument is a string
    str += '';
    
    if (str.length == 0) 
        resultStr = '';
    else {
          // Loop through string starting at the end as long as there
          // are spaces.
          i = str.length - 1;
          while (
                (i >= 0) && 
                (
                  (str.charAt(i) == ' ')
                  ||(str.charAt(i) == '\\n')
                  ||(str.charAt(i) == '\\r')
                  ||(str.charAt(i) == '\\t')
                  ||(str.charAt(i) == '\\f')
                  ||(str.charAt(i) == '\\v')
                 )
              )
             i--;
         
        
        //alert(ascci(str.charAt(i)));
         // When the loop is done, we're sitting at the last non-space char,
         // so return that char plus all previous chars of the string.
          resultStr = str.substring(0, i + 1);
      }
      
      return resultStr;      
}

/**/

var http = createRequestObject();

function registrarVariableEnSession (variable, valor)
{
    //alert ('variable '+variable);
    //alert ('valor '+valor);
    executeScriptPost(http,PATH_PAQUETE_WEB+'/herramientas/consultasAjax.php',confirmarregistrarVariableEnSession,'registrarVariableEnSession',variable+','+valor);
}

function confirmarregistrarVariableEnSession ()
{

    if(http.readyState == 4 && http.status == 200)
    {
        // Text returned FROM the PHP script
        var response = http.responseText;
        if(response)
        {
            // Mecanismo de depuración
            //alert(response);
        }
    }
    return;


}

/*
 *
 * INICIO: Funciones para el manejo de las Ayudas Contextuales
 *
 */

function adicionarAyudaContext(texto, div_papa, pagina, posicion_y, posicion_x, id_ayuda, orienta, posie_x, posie_y){
   var pos_y;
   var pos_x;
      
   if(navigator.appName.indexOf("Microsoft")==-1) {
      pos_y = posicion_y;
      pos_x = posicion_x;
   }else{
      pos_y = posie_y;
      pos_x = posie_x;
   }
   
   var id_tdiv = "ayuda_nro_"+id_ayuda;
      
   //Validar si el usuario ya cerro las cajitas
  var cerro_cajita = getCookieCajita("ayudas_context");
  if(cerro_cajita){ 
  var encontre = cerro_cajita.toString();
  var todas_cajitas = encontre.search(id_tdiv);
  if(todas_cajitas==-1){
         //Instanciar el div que ya existe y hay que ponerle la ayuda contextual
         var divLink = document.getElementById(div_papa);
         //Crear el div de mentiras que permita ubicar la ayuda
         var divTemp = document.createElement('DIV');
         divTemp.setAttribute("style","position: absolute;");
         //Setear contenido de la ayuda contextual
         if(orienta=="IZQ")
            divTemp.innerHTML = "<div id='"+id_tdiv+"' style='position: absolute; top: "+pos_y+"px; left: "+pos_x+"px; z-index:100;'><div class='close'><a href='javascript:esconderAyudaContext(\""+id_tdiv+"\");'><img src='/imagenes/contextual/close.gif' border='0' /></a></div><div><img src='/imagenes/contextual/top.png' width='249px' height='20' /></div><div class='shadown'><p style=' font:normal 11px/15px Arial, Helvetica, sans-serif;    margin:0 0 0 10px; padding:5px 15px; width:170px; text-align:left; color:#000; '>"+texto+"</p></div><div class='pestana'></div><div><img src='/imagenes/contextual/bottom.png' width='249px' height='20' /></div></div>";
         else
            divTemp.innerHTML = "<div id='"+id_tdiv+"' style='position: absolute; top: "+pos_y+"px; left: "+pos_x+"px; z-index:100;'><div class='close'><a href='javascript:esconderAyudaContext(\""+id_tdiv+"\");'><img src='/imagenes/contextual/close.gif' border='0' /></a></div><div><img src='/imagenes/contextual/top.png' width='249px' height='20' /></div><div class='shadownLeft'><p style=' font:normal 11px/15px Arial, Helvetica, sans-serif;    margin:0 0 0 10px; padding:5px 15px; width:170px; text-align:left; color:#000; '>"+texto+"</p></div><div class='pestanaLeft'></div><div><img src='/imagenes/contextual/bottom.png' width='249px' height='20' /></div></div>";            
         //Agregar el dic de la ayuda al div de referencia
         
          divLink.appendChild(divTemp);
   }
   }else{
       //Instanciar el div que ya existe y hay que ponerle la ayuda contextual
         var divLink = document.getElementById(div_papa);
         //Crear el div de mentiras que permita ubicar la ayuda
         var divTemp = document.createElement('DIV');
         divTemp.setAttribute("style","position: absolute;");
         //Setear contenido de la ayuda contextual
         if(orienta=="IZQ"){
           /* if(navigator.appName.indexOf("Microsoft")!=-1){
               divTemp.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='/imagenes/contextual/top.gif');";
               
              // divTemp.innerHTML = "no puedo poner esto";
            }else   
             */  divTemp.innerHTML = "<div id='"+id_tdiv+"' style='position: absolute; top: "+pos_y+"px; left: "+pos_x+"px; z-index:100;'><div class='close'><a href='javascript:esconderAyudaContext(\""+id_tdiv+"\");'><img src='/imagenes/contextual/close.gif' border='0' /></a></div><div><img src='/imagenes/contextual/top.png' width='249px' height='20' /></div><div class='shadown'><p style=' font:normal 11px/15px Arial, Helvetica, sans-serif;    margin:0 0 0 10px; padding:5px 15px; width:170px; text-align:left; color:#000; '>"+texto+"</p></div><div class='pestana'></div><div><img src='/imagenes/contextual/bottom.png' width='249px' height='20' /></div></div>";
         
         }else{
         /*   if(navigator.appName.indexOf("Microsoft")!=-1){
               divTemp.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='/imagenes/contextual/bottom.gif');";
                     
            
            
            //   divTemp.innerHTML = "no puedo poner esto";
            }else
            */   divTemp.innerHTML = "<div id='"+id_tdiv+"' style='position: absolute; top: "+pos_y+"px; left: "+pos_x+"px; z-index:100;'><div class='close'><a href='javascript:esconderAyudaContext(\""+id_tdiv+"\");'><img src='/imagenes/contextual/close.gif' border='0' /></a></div><div><img src='/imagenes/contextual/top.png' width='249px' height='20' /></div><div class='shadownLeft'><p style=' font:normal 11px/15px Arial, Helvetica, sans-serif;    margin:0 0 0 10px; padding:5px 15px; width:170px; text-align:left; color:#000; '>"+texto+"</p></div><div class='pestanaLeft'></div><div><img src='/imagenes/contextual/bottom.png' width='249px' height='20' /></div></div>";            
         }
         //Agregar el dic de la ayuda al div de referencia
         divLink.appendChild(divTemp);
   }
   //var divLink = document.getElementById('primer_globo');
   //divLink.innerHTML = "<div style='position: absolute; top: 15px; left: 410px; z-index:100;'><div class='close'><a href='#'><img src='images/close.gif' border='0' /></a></div><div><img src='images/top.png' width='249px' height='20' /></div><div class='shadown'><p>Disparamos nuestras cámaras en los lugares más cool de Bogotá.</p></div><div class='pestana'></div><div><img src='images/bottom.png' width='249px' height='20' /></div></div>";
   activarIE();
}

function esconderAyudaContext(id_hdiv){
    //Ocultar
    var div_hint = document.getElementById(id_hdiv);
    div_hint.style.display="none";
    
    //Escribir cookie para que no vuelva a salir
    //incluirObjeto("COOKIE_AYUDAS_CONTEXT",id_hdiv,validEmail);
    determinarLasCookies(id_hdiv);
    
}
function validEmail(valor)
{
}

function activarIE()
{
//alert("ingreso");
//Activar el script para png en IE
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}
}

function getCookieCajita(name){var dc = document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);
if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}else{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1){end=dc.length;}
return unescape(dc.substring(begin+prefix.length,end)).split("\n");} 

function setCookieCajita (name, value, expires, path) {
   var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "");
   document.cookie = curCookie;
}

function determinarLasCookies(id_hdiv)
{
   
   var myCookie = getCookieCajita('ayudas_context');
   var tiempo = new Date("July 19, 2037 01:15:00");
   
   var cliqueado = id_hdiv+"|";
   var val_act = "";
   
   if(!myCookie) {
       setCookieCajita('ayudas_context',cliqueado,tiempo,'/');    
   }else{   
      val_act = cliqueado+""+myCookie;
      //isset($_COOKIE["ayudas_context"]);
      setCookieCajita('ayudas_context',val_act,tiempo,'/');
   }
   
}
/*
 *
 * FIN: Funciones para el manejo de las Ayudas Contextuales
 *
 */


function validarFormaCambiarContrasena ()
{
    var usu_anterior_contrasena = document.Autenticar.usu_anterior_contrasena.value;
    var usu_password = document.Autenticar.usu_password.value;
    var usu_confirmar_contrasena = document.Autenticar.usu_confirmar_contrasena.value;
    var per_email = document.Autenticar.per_email.value;
    
    if (usu_anterior_contrasena == "")
    {
        alert ('Suministre la CONTRASEÑA ACTUAL');
        document.Autenticar.usu_anterior_contrasena.focus();
        return false;
    }
    if (usu_password == "")
    {
        alert ('Suministre la NUEVA CONTRASEÑA');
        document.Autenticar.usu_password.focus();
        return false;
    }
    if (usu_confirmar_contrasena == "")
    {
        alert ('Confirme la NUEVA CONTRASEÑA');
        document.Autenticar.usu_confirmar_contrasena.focus();
        return false;
    }
    if (per_email == "")
    {
        alert ('Suministre su Correo Electrónico');
        document.Autenticar.per_email.focus();
        return false;
    }

    return true;


}


function agregarElementoNuevoAMaestro (tabla, atributo_nombre, nombre_div)
{
    //alert ('tabla '+tabla);   
    //alert ('atributo_nombre '+atributo_nombre);   
    var url = PATH_PAQUETE_WEB+'/herramientas/fm_IngresarMaestroConAjax.php?tabla='+tabla+'&atributo='+atributo_nombre+'&nombre_div='+nombre_div;
    Modalbox.show(url, {title: this.title, width: 500}); return false;
    
    return false;
}


function guardarMaestroConAjax (tabla, atributo, nombre_div)
{
    var valor = document.forma_maestro.valor.value;
    //alert ('valor '+valor);   
    //alert ('tabla '+tabla);   
    //alert ('atributo '+atributo);   
    
    if (valor != "" && tabla != "")
    {
        executeScriptPost(http,PATH_PAQUETE_WEB+'/herramientas/consultasAjax.php',confirmarguardarMaestroConAjax,'guardarMaestroConAjax',valor+','+tabla+','+atributo+','+nombre_div);
    }
    return false;
}


function confirmarguardarMaestroConAjax ()
{
    if(http.readyState == 4 && http.status == 200)
    {
        // Text returned FROM the PHP script
        var response = http.responseText;
        if(response)
        {
            // Mecanismo de depuración
            //alert(response);
            
            // Nota 4: Análogo al EXPLOT en PHP
            var lista = response.split(/delimitadorKKK\s*/); 
            // Si retornó resultados la consulta
            if (lista != '')
            {
                var campo_oculto_codigo = lista[0];
                var Nuevoresponse = lista[1];
                
                //alert ('lista '+lista);
                //alert ('campo_oculto_codigo '+campo_oculto_codigo);
                //alert ('Nuevoresponse '+Nuevoresponse);
                
                eval("document.getElementById(\"\"+campo_oculto_codigo).innerHTML = Nuevoresponse;");
                Modalbox.hide();
            }
            else
            {
                alert ('No Guardó el Registro, Intente cambiando el Nombre.');
            }
        }
    }
    return;
}

function abrirOpinionesConAjax ()
{
    var url = PATH_PAQUETE_WEB+'/herramientas/fm_OpinionesDelSistemaConAjax.php';
    Modalbox.show(url, {title: 'Opiniones recientes sobre el Sistema', width: 700}); return false;
    
    return false;
}



