/*
    Descripción: Clase para manejar el objeto Event.
*/

// Constructor
function mpvEvent() {
}

// objeto Event
mpvEvent.prototype.getEvent = function (e) {
    if (window.event) 
        return window.event;
    else
        return e.which;
}

// carga el keycode
mpvEvent.prototype.getKeycode = function (e) {
    if (window.event) 
        return window.event.keyCode;
    else if (e) 
        return e.which;
}

// Bloquea el ENTER
mpvEvent.prototype.lockEnter = function (e) {
    if (this.getKeycode(e) == 13) {
        if (this.getEvent(e).returnValue) thist.getEvent(e).returnValue = false;
        return false;
    } else {
        if (this.getEvent(e).returnValue) this.getEvent(e).returnValue = true;
        return true;
    }
}

// lanza el submit del boton con el enter del input
mpvEvent.prototype.inputOnEnter = function (e, idButton) {
    var keycode = this.getKeycode(e);
    var oButton = document.getElementById(idButton);
    
    // Hace el click
    if (keycode == 13 && oButton) oButton.onclick();
    
    // bloque el enter para que no haga el submit
    if (this.getEvent(e).returnValue) this.getEvent(e).returnValue = false;
    
    return false;
}


// Crea una instancia por defecto.
$Event = new mpvEvent();
