function hidcHanldeOnKeyPress(objInput, strGroupSep, strDecimalSep, intNumDecimals, event) {
    var arrAllowed = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", strGroupSep);
    var arrAllowedOne = new Array("-", strDecimalSep);
    var arrEdition = new Array(8, 27, 46);
    var arrNeutral = new Array(9, 13, 16, 17, 35, 36, 37, 38, 39, 40);
    var intKey = ((event.keyCode) ? event.keyCode : event.charCode);
    var strValue;

    if (hasValue(arrAllowed, String.fromCharCode(intKey))) {
        //Get current value
        if (typeof(objInput.selectionStart) == 'number') {
            strValue = objInput.value.substring(0, objInput.selectionStart) + String.fromCharCode(intKey) + objInput.value.substring(objInput.selectionEnd, objInput.value.length);
        } else if (document.selection) {
            var objSelection = document.selection.createRange();
            objSelection.select();
            objSelection.text = String.fromCharCode(intKey);

            strValue = objInput.value;
        } else {
            alert("Incompatible browser");
            return true;
        }

        //Set current value
        hidcValidateSetNumberFormatted(strValue, objInput, strGroupSep, strDecimalSep, intNumDecimals, true);

        //Cancel event
        event.cancelBubble = true;
        event.returnValue = false;
        return false;

    } else if (hasValue(arrAllowedOne, String.fromCharCode(intKey))) {
        if (objInput.value.indexOf(String.fromCharCode(intKey)) > -1) {
            //Cancel event
            event.cancelBubble = true;
            event.returnValue = false;
            return false;
        } else if (String.fromCharCode(intKey) == "-" && getSelectionStart(objInput) > 0) {
            //Cancel event
            event.cancelBubble = true;
            event.returnValue = false;
            return false;
        }

    } else if (hasValue(arrEdition, intKey) || hasValue(arrNeutral, intKey)) {
        //nothing

    } else {
        //Cancel event
        event.cancelBubble = true;
        event.returnValue = false;
        return false;
    }
}

function hidcHanldeOnKeyUp(objInput, strGroupSep, strDecimalSep, intNumDecimals, event) {
    var arrEdition = new Array(8, 27, 46);
    var intKey = ((event.keyCode) ? event.keyCode : event.wich);
    var strValue;

    if (hasValue(arrEdition, intKey)) {
        //Get current value
        strValue = objInput.value;

        //Set current value
        hidcValidateSetNumberFormatted(strValue, objInput, strGroupSep, strDecimalSep, intNumDecimals, false);
    }
}

function hidcValidateSetNumberFormatted(strValue, objInput, strGroupSep, strDecimalSep, intNumDecimals, blnIncPos) {
    var strInteger, strDecimal;
    var intPos, intPosInc;
    var blnNegative = false;

    //Current position
    intPos = getSelectionStart(objInput) + (blnIncPos ? 1 : 0);
    intPosInc = 0;

    for (var i = 0; i <= (intPos - 1); i++) {
        if (strValue.substring(i, i + 1) == strGroupSep) {
            intPosInc--;
        }
    }

    //Unformat
    strValue = replaceAll(strValue, strGroupSep, "");

    //Validate value
    if (strValue.indexOf(strDecimalSep) > -1) {
        strInteger = strValue.substring(0, strValue.indexOf(strDecimalSep));
        strDecimal = strValue.substring(strValue.indexOf(strDecimalSep) + 1);
    } else {
        strInteger = strValue;
        strDecimal = null;
    }

    //Format integer value
    strValue = "";

    if (strInteger < 0) {
        blnNegative = true;
        strInteger = strInteger.substring(1);
    }

    for (var i = strInteger.length - 1; i >= 0; i--) {
        if ((strInteger.length - 1 - i) > 0 && ((strInteger.length - 1 - i) % 3) == 0) {
            strValue = "" + strGroupSep + strValue;

            if (i <= (intPos - 1 + intPosInc)) {
                intPosInc++;
            }
        }

        strValue = "" + strInteger.substring(i, i + 1) + strValue;
    }

    if (blnNegative) {
        strValue = "-" + strValue;
    }

    //Format decimal value
    if (strDecimal) {
        if (strDecimal.length > intNumDecimals) {
            strDecimal = strDecimal.substring(0, intNumDecimals);
        }

        strValue = strValue + "." + strDecimal;
    }

    //Set new formatted value
    objInput.value = strValue;

    //Set new cursor position
    setSelectionRange(objInput, (intPos + intPosInc), (intPos + intPosInc));
}