text: /**
   * Nippo is the japanese kana alphabets training machine
   * implemented with JavaScript and RightJS
   *
   * It is freely distrubuted under the terms of the MIT license
   *
   * See the http://stcamp.net/games/nippo for the live demo
   *
   * Copyright 2009 Nikolay V. Nemshilov aka St.
   */
  if (!RightJS || !Fx) { throw "Gimme RightJS with Fx" }
  var Nippo=new Class(Observer,{initialize:function(e){this.alphabet=new Nippo.Alphabet();this.desk=new Nippo.Desk();this.stats=new Nippo.Stats();this.controls=new Nippo.Controls();this.element=$E('div',{id:'nippo'}).insertTo(e).insert([this.alphabet.element,this.desk.element,this.stats.element,this.controls.element]);this.controls.buildLevels(this.alphabet.getBasics(),this.alphabet.getCombinations());this.controls.onLevelchange(this.setLevel.bind(this)).levelChange();this.controls.onDirectionchange(this.setDirection.bind(this)).directionChange();this.alphabet.onChoose(this.choose.bind(this))},setLevel:function(l){this.alphabet.setLevel(l);return this.showNext()},setDirection:function(d){var p=d.split('-');this.alphabet.showChars(p.last());this.charSet=p.first();return this.showNext()},showNext:function(){var c=this.alphabet.activeChars.random();this.desk.update(this.charSet=='ro'?c[0]:this.charSet=='ka'?c[2]:c[1]);this.currentKey=c[0];return this},choose:function(k){var c=k==this.currentKey;this.stats.count(c);if(this.stats.levelsUp())this.controls.levelUp();else if(this.stats.levelsDown())this.controls.levelDown();this.desk.block.highlight(c?'#AFA':'#FAA');this.showNext.bind(this).delay(200);return this}});Nippo.Alphabet=new Class(Observer,{extend:{EVENTS:$w('choose'),BASIC:[' a: 42    i: 44    u: 46   e: 48   o: 4A','ka: 4B   ki: 4D   ku: 4F  ke: 51  ko: 53','ga: 4C   gi: 4E   gu: 50  ge: 52  go: 54','sa: 55  shi: 57   su: 59  se: 5B  so: 5D','za: 56   ji: 58   zu: 5A  ze: 5C  zo: 5E','ta: 5F  chi: 61  tsu: 64  te: 66  to: 68','da: 60   di: 62   du: 65  de: 67  do: 69','na: 6A   ni: 6B   nu: 6C  ne: 6D  no: 6E','ha: 6F   hi: 72   fu: 75  he: 78  ho: 7B','ba: 70   bi: 73   bu: 76  be: 79  bo: 7C','pa: 71   pi: 74   pu: 77  pe: 7A  po: 7D','ma: 7E   mi: 7F   mu: 80  me: 81  mo: 82','ya: 84            yu: 86          yo: 88','ra: 89   ri: 8A   ru: 8B  re: 8C  ro: 8D','wa: 8F             n: 93          wo: 92'],COMBINATIONS:['kya: 4D,83    kyu: 4D,85    kyo: 4D,87','gya: 4E,83    gyu: 4E,85    gyo: 4E,87','sha: 57,83    shu: 57,85    sho: 57,87','ja:  58,83    ju:  58,85    jo:  58,87','cha: 61,83    chu: 61,85    cho: 61,87','nya: 6B,83    nyu: 6B,85    nyo: 6B,87','hya: 72,83    hyu: 72,85    hyo: 72,87','bya: 73,83    byu: 73,85    byo: 73,87','pya: 74,83    pyu: 74,85    pyo: 74,87','mya: 7E,83    myu: 7E,85    myo: 7E,87','rya: 8A,83    ryu: 8A,85    ryo: 8A,87']},initialize:function(o){this.$super(o);this.element=$E('div',{id:'nippo-alphabet'});this.build().showHiragana()},setLevel:function(l){var p=false;this.activeLevel=l.split(' ').last();this.activeChars=[];this.cells.each(function(c){c[p?'addClass':'removeClass']('disabled');if(!p)this.activeChars.push(c.chars);p=p | c.key==this.activeLevel},this)},showChars:function(n){switch(n){case 'ro':return this.showRomaji();case 'ka':return this.showKatakana();default:return this.showHiragana()}},showRomaji:function(){this.cells.each('showRomaji');this.element.setClass('romaji');return this},showHiragana:function(){this.cells.each('showHiragana');this.element.setClass('hiragana');return this},showKatakana:function(){this.cells.each('showKatakana');this.element.setClass('katakana');return this},getBasics:function(){this.basics=this.basicChars||this.constructor.BASIC.map(this.parseLine);return this.basics},getCombinations:function(){this.combinations=this.combinations||this.constructor.COMBINATIONS.map(this.parseLine);return this.combinations},parseLine:function(l){return l.trim().split(/\s+(?=[a-z]+:)/).map('split',/:\s*/).map(function(p){return[p[0],p[1].split(',').map(function(c){return '&#'+('30'+c).toInt(16)+';'}).join(''),p[1].split(',').map(function(c){return '&#'+(('30'+c).toInt(16)+96)+';'}).join('')]})},build:function(){var d=$E('fieldset',{id:'nippo-alphabet-basic'}).insertTo(this.element);var e=$E('fieldset',{id:'nippo-alphabet-combinations'}).insertTo(this.element);d.insert($E('legend',{html:'Basics'}));e.insert($E('legend',{html:'Combinations'}));this.cells=[];[['getBasics',d],['getCombinations',e]].each(function(p){this[p[0]]().each(function(l){var r=$E('div',{'class':'nippo-alphabet-row'}).insertTo(p[1]);l.each(function(a,b){var c=$ext($E('div').insertTo(r),{key:a[0],chars:a,showRomaji:function(){this.innerHTML=a[0]},showHiragana:function(){this.innerHTML=a[1]},showKatakana:function(){this.innerHTML=a[2]}});c.onClick(function(){if(!c.hasClass('disabled'))this.choose(c.key,c)}.bind(this));this.cells.push(c);if(l.length==3&&(b==0||b==1))r.insert($E('div',{'class':'nippo-alphabet-blank'}))},this)},this)},this);return this}});Nippo.Desk=new Class({initialize:function(){this.element=$E('div',{id:'nippo-desk'});this.block=$E('div');this.element.insert($E('fieldset').insert([$E('legend',{html:'Current Symbol'}),this.block]))},update:function(s){this.block.update(s);return this}});Nippo.Stats=new Class({LEVEL_CHANGE_STRIKE:8,initialize:function(){this.element=$E('div',{id:'nippo-stats'});this.errors=$E('span');this.attempts=$E('span');this.percent=$E('span');this.element.insert($E('fieldset').insert([$E('legend',{html:'Statistics'}),$E('div').insert([$E('label',{html:'Errors:'}),this.errors]),$E('div').insert([$E('label',{html:'Attempts:'}),this.attempts]),$E('div').insert([$E('label',{html:'Percent:'}),this.percent]),$E('input',{type:'button',value:'Reset'}).onClick(this.reset.bind(this))]));this.setValues.apply(this,(Cookie.get('nippo-stats')||'').split(',').map('toInt'));this.resetStrikes()},reset:function(){return this.resetStrikes().setValues(0,0)},count:function(c){var o=this.attempts.innerHTML.toInt()+1;var e=this.errors.innerHTML.toInt();if(c){this.errorsStrike=0;this.correctStrike++}else{e++;this.errorStrike++;this.correctStrike=0}return this.setValues(e,o)},levelsUp:function(){var t=this.correctStrike==this.LEVEL_CHANGE_STRIKE;if(t)this.resetStrikes();return t},levelsDown:function(){var t=this.errorStrike==this.LEVEL_CHANGE_STRIKE;if(t)this.resetStrikes();return t},setValues:function(e,a){e=e||0;a=a||0;percent=a?100-parseInt(e/a*100):0;this.errors.innerHTML=''+e;this.attempts.innerHTML=''+a;this.percent.innerHTML=''+percent+'%';Cookie.set('nippo-stats',e+","+a,{duration:888});return this},resetStrikes:function(){this.errorStrike=0;this.correctStrike=0;return this}});Nippo.Controls=new Class(Observer,{EVENTS:$w('levelchange directionchange'),initialize:function(){this.$super();this.element=$E('div',{id:'nippo-controls'});this.levelSelect=$E('select');this.directionSelect=$E('select').insert([$E('option',{value:'ro-hi',html:'Romaji &rarr; Hiragana'}),$E('option',{value:'hi-ro',html:'Hiragana &rarr; Romaji'}),$E('option',{value:'ro-ka',html:'Romaji &rarr; Katakana'}),$E('option',{value:'ka-ro',html:'Katakana &rarr; Romaji'}),$E('option',{value:'hi-ka',html:'Hiragana &rarr; Katakana'}),$E('option',{value:'ka-hi',html:'Katakana &rarr; Hiragana'})]).setValue(Cookie.get('nippo-direction'));this.element.insert($E('fieldset').insert([$E('legend',{html:'Controls'}),$E('div',{id:'nippo-controls-level'}).insert([$E('label',{html:'Level:'}),this.levelSelect]),$E('div',{id:'nippo-controls-direction'}).insert([$E('label',{html:'Direction:'}),this.directionSelect])]));this.levelSelect.on('change',this.levelChange.bind(this));this.directionSelect.on('change',this.directionChange.bind(this))},levelChange:function(){Cookie.set('nippo-level',this.levelSelect.value,{duration:888});return this.fire('levelchange',this.levelSelect.value)},directionChange:function(){Cookie.set('nippo-direction',this.directionSelect.value,{duration:888});return this.fire('directionchange',this.directionSelect.value)},levelUp:function(){var o=$A(this.levelSelect.getElementsByTagName('option'));var c=o.first(function(a){return a.selected});if(c&&c!=o.last()){this.levelSelect.value=o[o.indexOf(c)+1].value;this.levelChange()}},levelDown:function(){var o=$A(this.levelSelect.getElementsByTagName('option'));var c=o.first(function(a){return a.selected});if(c&&c!=o.first()){this.levelSelect.value=o[o.indexOf(c)-1].value;this.levelChange()}},buildLevels:function(c,d){[["Basics",c],["Combinations",d]].each(function(p){this.levelSelect.insert($E('optgroup',{label:p[0]}).insert(p[1].map(function(b){var r=b.map('first').join(' ');var h=b.map('first','match',/[^a-z]+/).join(' ');var k=b.map('last').join(' ');if(p[1]==c&&b.length==3){r=r.split(' ').join(' &nbsp;&nbsp;&nbsp; ');h=h.split(' ').join(' &nbsp;&nbsp;&nbsp; ');k=k.split(' ').join(' &nbsp;&nbsp;&nbsp; ')}return $ext($E('option',{value:r,html:h}),{showRomaji:function(){this.innerHTML=r},showHiragana:function(){this.innerHTML=h},showKatakana:function(){this.innerHTML=k}})})))},this);this.levelSelect.value=Cookie.get('nippo-level');return this}});document.write("<style type=\"text/css\">div#nippo{font-family:'Lucida Grande','Hiragino Kaku Gothic Pro','ヒラギノ角ゴ Pro W3',Osaka,'ＭＳ Ｐゴシック',sans-serif;position:relative;height:35.5em;min-width:55.5em}div#nippo fieldset{border:none;border-top:1px solid gray;padding:.5em;padding-top:.2em}div#nippo fieldset legend{font-family:Verdana;font-weight:bold;font-size:120%;color:#888}div#nippo label{display:inline-block;*display:inline;*zoom:1;font-weight:bold;color:#666}div.nippo-alphabet-row{height:1.4em;line-height:1.4em;font-size:160%}div.nippo-alphabet-row div{float:left;cursor:pointer;width:1.4em;height:1.4em;line-height:1.4em;text-align:center;color:#733;margin-right:.2em}div.nippo-alphabet-row div:hover{color:brown;background:#DED;text-shadow:#888 3px 3px 3px}div.nippo-alphabet-blank{visibility:hidden}div.nippo-alphabet-row div.disabled,div.nippo-alphabet-row div.disabled:hover{color:#BBB;background:transparent;text-shadow:none;cursor:default}div.romaji div.nippo-alphabet-row div{font-family:Arial}#nippo-alphabet-combinations div.nippo-alphabet-row div{width:2.4em}#nippo-alphabet-combinations div.nippo-alphabet-blank{display:none}#nippo-alphabet{position:relative;z-index:100}#nippo-alphabet-basic{position:absolute;*width:12.8em;left:0px;top:0px}#nippo-alphabet-combinations{position:absolute;*width:12.9em;right:0px;top:0px}#nippo-desk{margin:0 14em}#nippo-desk div{height:2.6em;line-height:2.6em;text-align:center;font-size:11em;text-shadow:#888 .04em .04em .08em}#nippo-stats{position:absolute;right:0px;bottom:0px;width:12.8em;z-index:100}#nippo-stats label{width:9em}#nippo-stats input{float:right;margin-top:1em;text-transform:lowercase}#nippo-controls{position:absolute;bottom:0;left:0;width:100%;z-index:1}#nippo-controls fieldset{margin:0 14em}#nippo-controls div#nippo-controls-level{float:left;margin-right:1em}#nippo-controls label{margin-right:.3em}#nippo-controls label,#nippo-controls select,#nippo-controls input{vertical-align:middle}</style>");