var EventUtil = new Object;
var TextUtil = new Object;
EventUtil.formatEvent = function (oEvent) {
   ///if (isIE && isWin) {
       oEvent.charCode = (oEvent.type == "keypress") ? oEvent.keyCode : 0;
       oEvent.eventPhase = 2;
       oEvent.isChar = (oEvent.charCode > 0);
       oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
       oEvent.pageY = oEvent.clientY + document.body.scrollTop;
       oEvent.preventDefault = function () {
           this.returnValue = false;
       };

       if (oEvent.type == "mouseout") {
           oEvent.relatedTarget = oEvent.toElement;
       } else if (oEvent.type == "mouseover") {
           oEvent.relatedTarget = oEvent.fromElement;
       }

       oEvent.stopPropagation = function () {
           this.cancelBubble = true;
       };

       oEvent.target = oEvent.srcElement;
       oEvent.time = (new Date).getTime();
   ///}
   return oEvent;
};

TextUtil.allowChars = function (oTextbox, oEvent, bBlockPaste) {
    oEvent = EventUtil.formatEvent(oEvent);         
    var sValidChars = oTextbox.getAttribute("validchars");
    var sChar = String.fromCharCode(oEvent.charCode);    
    var bIsValidChar = sValidChars.indexOf(sChar) > -1;    
    if (bBlockPaste) {
        return bIsValidChar && !(oEvent.ctrlKey && sChar == "v");
    } else {
        return bIsValidChar || oEvent.ctrlKey;
    }
};
