if(navigator.language=='pl'){text=['Zwiększ wartość liczbową w aktualnej komórce','Zmniejsz wartość liczbową w aktualnej komórce','Przejdź do następnej komórki','Przejdź do poprzedniej komórki','Wczytaj liczbę z wejścia standardowego','Wyświetl znak ASCII o liczbie z aktualnej komórki','Rozpocznij pętlę - powtarzaj kod między [] do momentu, gdy przed ] wartość komórki wyniesie 0','Zaznacz, że tutaj kończy się pętla','Kliknij START, aby uruchomić program lub DEBUG, by iść krok po kroku.','Wehikuł czasu - to byłby cud!','Podaj wartość liczbową dla komórki ','Ciemno wszędzie, pusto wszędzie [...]']}else{text=['Increase the number value in current cell','Decrease the number value in current cell','Go to next cell','Go to previous cell','Load a number value from standard input','Display ASCII character at specified location\n(number in current cell)','Start a loop - repeat code between [] until the value in current cell before ] reaches 0','Mark that a loop finishes here','Click START to run your program or DEGUG to go step by step.','Time vehicle - it would be a wonder!','Enter a number for cell ','First enter your code, then start it!']}onkeypress=function(e){e=e||event;var x=e.charCode||e.keyCode;window.keyBox.innerHTML=x;switch(x){case 119:lang.start();break;case 120:lang.start(1);break;case 27:lang.stop();hint(9);break;case 19:if(lang.debug){lang.next();build()}break}};function hint(x){hintBox.innerHTML=text[x];hintBox.style.top=(document.documentElement.clientHeight-40)+'px';hintBox.style.display='block'}function hide(){hintBox.style.display='none'}function insert(x){if(inBox.selectionStart!=undefined){var a=inBox.selectionStart,end=inBox.selectionEnd,scroll=inBox.scrollTop,before=inBox.value.substring(0,a),after=inBox.value.substring(end,inBox.textLength),inside=lang.syntax[x];inBox.value=before+inside+after;inBox.selectionEnd=inBox.selectionStart=before.length+inside.length;inBox.scrollTop=scroll;inBox.focus()}else if(document.selection){inBox.focus();document.selection.createRange().text=lang.syntax[x]}}function lock(x){f[12].disabled=x;f[13].disabled=x;f[14].disabled=!x;f[15].disabled=!x;f[16].disabled=!x}function setlang(a){f[14].className='';f[15].className='';f[16].className='';f[a].className='on';inBox.focus()}function build(){for(var a=1,l=lang.memory.length;a<l;a++){cell=a-1;if(cellBox.rows[a]==undefined){var b=cellBox.insertRow(a);b.insertCell(-1).innerHTML=a;b.insertCell(-1).innerHTML=String.fromCharCode(lang.memory[cell]);b.insertCell(-1).innerHTML=lang.memory[cell]}else{cellBox.rows[a].cells[1].innerHTML=String.fromCharCode(lang.memory[cell]);cellBox.rows[a].cells[2].innerHTML=lang.memory[cell]}}if(cellBox.rows.length>a){for(i=cellBox.rows.length-1;i>a;i--){cellBox.deleteRow(i)}}}f=document.forms[0];f.onsubmit=function(){return false};f[0].onclick=function(){insert(0)};f[1].onclick=function(){insert(1)};f[2].onclick=function(){insert(2)};f[3].onclick=function(){insert(3)};f[4].onclick=function(){insert(4)};f[5].onclick=function(){insert(5)};f[6].onclick=function(){insert(6)};f[7].onclick=function(){insert(7)};f[8].onclick=function(){insert(8)};f[10].onclick=function(){if(inBox.value){lang.start();build()}else hint(11)};f[11].onclick=function(){if(inBox.value){lang.start(1);build()}else hint(11)};f[12].onclick=function(){lang.next();build()};f[13].onclick=function(){lang.stop()};f[14].onclick=function(){lang=Brainfuck;setlang(14)};f[15].onclick=function(){lang=Ook;setlang(15)};f[16].onclick=function(){lang=A;setlang(16)};f[14].className='on';f[0].onmouseover=function(){hint(0)};f[1].onmouseover=function(){hint(1)};f[2].onmouseover=function(){hint(2)};f[3].onmouseover=function(){hint(3)};f[4].onmouseover=function(){hint(4)};f[5].onmouseover=function(){hint(5)};f[6].onmouseover=function(){hint(6)};f[7].onmouseover=function(){hint(7)};hintBox=document.getElementById('hint');document.getElementById('editor').onmouseout=hide;outBox=document.getElementById('out');outBox.innerHTML=text[8];inBox=f[9];keyBox=document.getElementById('key');cellBox=document.getElementById('cells');Brainfuck={syntax:['+','-','<','>',',','.','[',']','\t'],start:function(a){if(a)lock(0);this.memory=[0,0,0,0,0];this.cell=0;this.loopAt=[];this.repeated=0;this.depth=-1;this.cursor=0;this.out='';this.last='';this.debug=a;this.next()},next:function(){var a=inBox.value.length,repeated=0;start:for(var i=this.cursor;i<a;i++){if(this.memory[this.cell]==undefined){this.memory[this.cell]=0}switch(inBox.value[i]){case'+':this.memory[this.cell]++;break;case'-':this.memory[this.cell]--;break;case'>':this.cell++;break;case'<':this.cell--;break;case',':var x=prompt(text[10]+this.cell,0);if(!x||x==0)break start;this.memory[this.cell]=x.charCodeAt(0);break;case'.':this.out+=String.fromCharCode(this.memory[this.cell]);break;case'[':this.depth++;this.loopAt[this.depth]=i;repeated++;break;case']':if(this.memory[this.cell]!=0&&repeated<5000)i=this.loopAt[this.depth];break}if(this.debug){if(i+1==a){this.debug=0;lock(1)}else if(inBox.value[i]!=this.last){inBox.selectionStart=i;inBox.selectionEnd=++i;inBox.focus();this.last=inBox.value[i];this.cursor=i;break start}}}outBox.innerHTML=this.out},stop:function(){lock(1);this.debug=0}};Ook={syntax:['Ook. Ook. ','Ook! Ook! ','Ook? Ook. ','Ook? Ook. ','Ook. Ook! ','Ook! Ook. ','Ook! Ook? ','Ook? Ook! '],start:function(a){if(a)lock(0);this.memory=[0,0,0,0,0];this.cell=0;this.loopAt=[];this.repeated=0;this.depth=-1;this.cursor=0;this.out='';this.last='';this.debug=a;this.next()},next:function(){var a=inBox.value.length,repeated=0;start:for(var i=this.cursor;i<a;i+=9){if(this.memory[this.cell]==undefined){this.memory[this.cell]=0}i=inBox.value.indexOf('Ook',i);var b=inBox.value.substr(i,9);switch(b){case'Ook. Ook.':this.memory[this.cell]++;break;case'Ook! Ook!':this.memory[this.cell]--;break;case'Ook. Ook?':this.cell++;break;case'Ook? Ook.':this.cell--;break;case'Ook. Ook!':var x=prompt(text[10]+this.cell,0);if(!x)break start;this.memory[this.cell]=x.charCodeAt(0);break;case'Ook! Ook.':this.out+=String.fromCharCode(this.memory[this.cell]);break;case'Ook! Ook?':this.depth++;this.loopAt[this.depth]=i;repeated++;break;case'Ook? Ook!':if(this.memory[this.cell]!=0&&repeated<5000)i=this.loopAt[this.depth];break}if(this.debug){if(i+9==a){this.debug=0;lock(1)}else if(b!=this.last){inBox.selectionStart=i;inBox.selectionEnd=i+9;inBox.focus();this.last=b;this.cursor=i+9;break start}}}outBox.innerHTML=this.out},stop:function(){lock(1);this.debug=0}};A={syntax:['A','U','C','G','?','.','(',')','\t'],start:function(a){if(a)lock(0);this.memory=[0,0,0,0,0];this.cell=0;this.loopAt=[];this.repeated=0;this.depth=-1;this.cursor=0;this.out='';this.last='';this.debug=a;this.next()},next:function(){var a=inBox.value.length,repeated=0;start:for(var i=this.cursor;i<a;i++){if(this.memory[this.cell]==undefined){this.memory[this.cell]=0}switch(inBox.value[i]){case'A':this.memory[this.cell]++;break;case'U':this.memory[this.cell]--;break;case'G':this.cell++;break;case'C':this.cell--;break;case'?':var x=prompt(text[10]+this.cell,0);if(!x)break start;this.memory[this.cell]=x.charCodeAt(0);break;case'.':this.out+=String.fromCharCode(this.memory[this.cell]);break;case'(':this.depth++;this.loopAt[this.depth]=i;repeated++;break;case')':if(this.memory[this.cell]!=0&&repeated<5000)i=this.loopAt[this.depth];break}if(this.debug){if(i+1==a){this.debug=0;lock(1)}else if(inBox.value[i]!=this.last){inBox.selectionStart=i;inBox.selectionEnd=++i;inBox.focus();this.last=inBox.value[i];this.cursor=i;break start}}}outBox.innerHTML=this.out},stop:function(){lock(1);this.debug=0}};lang=Brainfuck;lock(1);