﻿function ConfirmarBorrar() {
    if(confirm("¿Estás seguro de borrar el registro?")==true) {
        return true;
    } else {
       return false;
    }
}
function EjecutarBoton(ctrl) {
    var tecla = window.event.keyCode;
    if(tecla==13) {
        document.getElementById(ctrl).focus();
    }   
}
function sololetras() {
    var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
    var tecla = window.event.keyCode;
    var caracter = String.fromCharCode(tecla);
    var pos= checkOK.indexOf(caracter);
    if(pos==-1) {
        window.event.keyCode=0;
    }
}
function solonumeros() {
    var checkOK = "0123456789"; 
    var tecla = window.event.keyCode;
    var caracter = String.fromCharCode(tecla);
    var pos= checkOK.indexOf(caracter);
    if(pos==-1) {
        window.event.keyCode=0;
    }
}

function fecha(tipo,control) {
    if (!document.getElementById) {
        if (document.all)
            document.getElementById = function() {
                if (typeof document.all[arguments[0]] != "undefined")
                    return document.all[arguments[0]]
                else
                    return null
            }
        else if (document.layers)
            document.getElementById = function() {
                if (typeof document[arguments[0]] != "undefined")
                    return document[arguments[0]]
                else
                    return null
            }
    }
    var resultado, valor
    if (tipo == "I")
        //valor = document.getElementById('ctl00$ContentPlaceHolder1$txtFec_inicial').value;
        valor = document.getElementById(control).value;
    if (tipo == "F")
        //valor = document.getElementById('ctl00$ContentPlaceHolder1$txtFec_final').value;
        valor = document.getElementById(control).value;

    resultado = window.showModalDialog('calendario.aspx?valor=' + valor, '', 'dialogHeight:240px; dialogWidth:290px; center: Yes; help: no; resizable: yes; status: no; scroll:yes;');
    //resultado= window.showModalDialog('calendario.aspx?valor=' + valor, '', 'dialogwidth=100, dialogheigth=100, status:off;help:yes;scroll:yes');
    if (resultado != null) {
        if (tipo == "I")
            //document.getElementById('ctl00$ContentPlaceHolder1$txtFec_inicial').value = resultado;
            document.getElementById(control).value = resultado;
        if (tipo == "F")
            //document.getElementById('ctl00$ContentPlaceHolder1$txtFec_final').value = resultado;
            document.getElementById(control).value = resultado;
    }
}

function ayuda(pTabla, pCodigo) {
    var valor
    
    //valor = window.showModalDialog('help.aspx?id_cliente=' + document.getElementById('ctl00$ContentPlaceHolder1$cboCliente').value, '', 'width=500, height=400, status:off;help:yes;scroll:yes');
    valor = window.showModalDialog('help.aspx?tabla=' + pTabla, '', 'width=500, height=400, status:off;help:yes;scroll:yes');
    if (valor != null) {
        document.getElementById(pCodigo).value = valor;
        //document.getElementById('ctl00$ContentPlaceHolder1$' + pCodigo).value = valor;
        //document.getElementById('ctl00$ContentPlaceHolder1$btnValidar').click();
        //document.getElementById('ctl00$ContentPlaceHolder1$txtCantidad').focus();
    }
}