var kbdList=Array();kbdDefinition=function(b,a,c){this.Name=b;this.ShortName=a;this.Definition=c;};kbdList.push(new kbdDefinition("Simple","smpl",[["1","2","3","4","5","6","7","8","9","0"],["a","b","c","d","e","f","g","h","i","j"],["k","l","m","n","o","p","q","r","s","t"],["u","v","w","x","y","z"," ","h1","i1","CLR"]]));kbdList.push(new kbdDefinition("Letters","abc",[["a","b","c","d","e","f","g","h","i","j"],["k","l","m","n","o","p","q","r","s","t"],["u","v","w","x","y","z"," ","h1","i1","CLR"]]));kbdList.push(new kbdDefinition("Digits","123",[["1","2","3","4","5","6","7","8","9","0"]]));kbdList.kbdDefault=kbdList[0];kbdLanguages=["smpl","num","","","","","","","","",""];target.kbdActivateImpl=function(b,a){this.bubble("tracelog","kbdActivateImpl:"+a);if(a==this.bActive){return;}this.bActive=a;if(a){this.orig_from=b;b._kbdDriver=this;this.orig_drivers=new Object();this.installDriver(b,"doCenter");this.installDriver(b,"doMark");this.installDriver(b,"doMarkMenu");this.installDriver(b,"doMenu");this.installDriver(b,"doDigit");this.buffer="";this.input.setValue("");this.fstDigit=-1;this.setKeyboard(kbdList.kbdDefault);}else{if(!("orig_from" in this)){throw"Keyboard was not active";}for(drv in this.orig_drivers){if(this.orig_drivers[drv]==undefined){delete this.orig_from[drv];}else{this.orig_from[drv]=this.orig_drivers[drv];}}delete this.orig_from._kbdDriver;delete this.orig_drivers;delete this.orig_from;}this.bubble("kbdShow",a);this.bubble("tracelog","kbdActivateImpl done");};target.setKeyboard=function(h){this.actKeyboard=h;for(var d=0;d<10;d++){var f=this["line"+this.arr2ndx(d)];if(d in h.Definition){f.show(true);this.setKeyboardLine(f,d+1,h.Definition[d]);}else{f.show(false);}}var a=h.Definition.length;var c=this["line"+this.arr2ndx(a)];c.show(true);c.kbdLine.KBD_LINE_GROUP.lineName.setValue("0");for(var e=0;e<10;e++){var b=this.arr2ndx(e);var g=c.kbdLine.KBD_LINE_GROUP["col"+b];if(e in kbdList){g.setText(kbdList[e].ShortName);g.kbdLangDef=kbdList[e];}else{g.setText("");delete g.kbdLangDef;}}};target.setKeyboardLine=function(b,e,a){b.kbdLine.KBD_LINE_GROUP.lineName.setValue(e);for(var c=0;c<10;c++){var d=b.kbdLine.KBD_LINE_GROUP["col"+this.arr2ndx(c)];d.setText(a[c]);}};target.arr2ndx=function(a){return(a+1)%10;};target.ndx2arr=function(a){if(a==0){return 9;}return a-1;};target.installDriver=function(b,a){this.orig_drivers[a]=b[a];b[a]=this["_"+a];};target.testFn=function(){this.makeDump(x1,"",2);};target.makeDump=function(c,d,a){this.bubble("tracelog",d);for(var b in c){this.bubble("tracelog",d+"."+b+" => "+c[b]);if(a>1){this.makeDump(c[b],d+"."+b,a-1);}}};target._doCenter=function(){this.bubble("doKbdInput",this._kbdDriver.buffer);};target._doMenu=function(){this.bubble("doKbdCancel");};target._doMarkMenu=function(){this._kbdDriver.buffer="";this._kbdDriver.reportProgress("CLR",undefined);};target._doMark=function(){this._kbdDriver.buffer=this._kbdDriver.buffer.slice(0,-1);this._kbdDriver.reportProgress("BS",undefined);};target._doDigit=function(a){this.bubble("tracelog","k+:doDigit="+a.key);this._kbdDriver.processDigit(a.key);};target.processDigit=function(d){var a=this.ndx2arr(d);if(this.fstDigit==-1){if(a==9){this.stat.setValue("kbdSwitch");this.fstDigit=9;}else{if(!(a in this.actKeyboard.Definition)){this.stat.setValue("too big fstDigit");}else{this.fstDigit=a;this.stat.setValue("fstDigit="+this.fstDigit);}}}else{if(this.fstDigit==9){var c=kbdList[a];if(c!=undefined){this.setKeyboard(c);}}else{var b=this.actKeyboard.Definition[this.fstDigit][a];this.buffer+=b;this.stat.setValue("");this.reportProgress(b,b);}this.fstDigit=-1;}};target.reportProgress=function(b,a){this.input.setValue(this.buffer);this.bubble("doKbdProgress",b,a,this.buffer);};