
function GWAKeyboardEventManager()
{var DEBUG=true;var regExpDefaults=/^(9|35|36|37|39)$/;var regExpSpecials=/^(3[2-9]|4[0-7]|5[8-9]|6[0-4]|9[1-6]|12[3-6])$/;var regExpAccents=/^(3[2,9]|9[4,6]|126])$/;this.isDefaultKeys=function(e)
{var isDefault=false;var charCode=this.getCharCode(e);if(charCode==null)
charCode=this.getKeyCode(e);if(!regExpSpecials.test(charCode))
isDefault=regExpDefaults.test(charCode);return isDefault;}
this.isSpecialChar=function(e)
{var isSpecial=false;var charCode=this.getCharCode(e);var keyCode=this.getKeyCode(e);if(charCode==null)
charCode=keyCode;isSpecial=regExpSpecials.test(charCode);return isSpecial;}
this.ajustValueByObject=function(obj)
{var isSpecial=false;if(obj.value!=null&&obj.value!="")
{var valueAjust="";var exist=false;for(var i=0;i<obj.value.length;i++)
{isSpecial=regExpSpecials.test(obj.value.charCodeAt(i));if(isSpecial)
{exist=true;}
else
valueAjust+=obj.value.charAt(i);}
if(exist)
obj.value=valueAjust;}}
this.isAccent=function(e)
{var isA=false;var keyCode=this.getKeyCode(e);var charCode=this.getCharCode(e);var keyChar=String.fromCharCode(keyCode).toUpperCase();isA=regExpAccents.test(keyCode);return isA;}
this.debug=function(text)
{if(DEBUG)
alert(text)}
this.getKeyCode=function(e)
{try
{var keynum;if(e.keyCode!=null)
{keynum=e.keyCode;}
else if(e.which!=null)
{keynum=e.which;}
return keynum;}
catch(e)
{this.debug("IS NOT EVENT ["+e+"]");}}
this.getCharCode=function(e)
{try
{var keynum;if(e.charCode!=null)
{keynum=e.charCode;}
return keynum;}
catch(e)
{this.debug("IS NOT EVENT ["+e+"]");}}
this.isNumber=function(e)
{try
{var test=false;var keyCode=this.getKeyCode(e);var charCode=this.getCharCode(e);if(charCode==null)
charCode=keyCode;var keychar=String.fromCharCode(charCode);var numcheck=/\d/;test=numcheck.test(keychar);if(!test)
test=this.isDefaultKeys(e);if(charCode==0||charCode==8||charCode==9||charCode==13)
test=true;return test;}
catch(e)
{this.debug("IS NOT EVENT ["+e+"]");}}
this.isChar=function(e)
{try
{var test=false;var keyCode=this.getKeyCode(e);var charCode=this.getCharCode(e);if(charCode==null)
charCode=keyCode;var keychar=String.fromCharCode(charCode);var numcheck=/\D/;test=numcheck.test(keychar);if(test)
test=!this.isSpecialChar(e);if(charCode==0||charCode==8||charCode==9||charCode==13)
test=true;return test;}
catch(e)
{this.debug("IS NOT EVENT ["+e+"]");}}
this.forceValidation=function(e)
{try
{var obj=this.getElementByEvent(e);this.ajustValueByObject(obj);}
catch(e)
{this.debug("IS NOT EVENT ["+e+"]");}}
this.getElementByEvent=function(e)
{var element;if(navigator.appName=="Netscape")
element=e.target;else if(navigator.appName=="Microsoft Internet Explorer")
element=window.event.srcElement;return element;}}
gwaKeyboardEventManager=new GWAKeyboardEventManager();
