// Copyright (C) ゆうゆうプラネット All rights reserved.

/* ////////////////////////////////////////////////////////////////////////////////////////////////
【製作・著作権者】ゆうゆうプラネット
【Webサイト】http://www.yuyu-p.info/
【諸注意】
　・ソフトを実行する自由を認めます。
　・ソースコードを読む事、複製する事、改変する事、再配布する事は、認めません。
　・本ソフトのご利用による一切のトラブルについて「ゆうゆうプラネット」は責任を負いません。
//////////////////////////////////////////////////////////////////////////////////////////////// */

var QAry=new Array(20);var AAry=new Array(100);var FAry=new Array(100);var timerID;var timeStamp=0;var calcType=0;var tableBlinkTimes=6;var tableTimerID;var color01='#ffff00';var color02='#dddddd';var color03='#ffffff';var color04='#000000';var color05='#000000';var color06='#0000ff';var color07='#0000ff';var color08='#ffffff';var color09='#ffffff';var color10='#ffffff';var color11='#000000';var color12='#ffff00';function myStop(){clearInterval(timerID);timeStamp=0;clearTimeout(tableTimerID);myShowTable();}function myStart(){myStop();var m=0;var ary=new Array();for(var i=0;i<2;i++){ary=["0","1","2","3","4","5","6","7","8","9"];var n=ary.length;for(var j=n;j>0;j--){var r=Math.floor(Math.random()*j);QAry[('Q'+m++)]=ary[r];ary.splice(r,1);}}for(i=0;i<=99;i++){j=Math.floor(i/10);if(calcType==1){AAry[('A'+i)]=QAry[('Q'+'1'+j)]*QAry[('Q'+(i%10))];}else{AAry[('A'+i)]=parseInt(QAry[('Q'+'1'+j)],10)+parseInt(QAry[('Q'+(i%10))],10);}FAry[('A'+i)]=false;}for(i=0;i<QAry.length;i++){document.getElementById(('Q'+i)).innerHTML=QAry[('Q'+i)];}timerID=setInterval("myShowTimer()",200);}function myShowTimer(){if(timeStamp==0){timeStamp=Math.floor((new Date()).getTime()/1000);}var time=Math.floor(((new Date()).getTime()/1000))-timeStamp;var s=time%60;var m=Math.floor(time/60)%60;var h=Math.floor(time/(60*60));if(s<10)s='0'+s;if(m<10)m='0'+m;if(h<10)h='0'+h;document.getElementById('timer').innerHTML='&nbsp;'+h+':'+m+':'+s+'&nbsp;';}function myThStyle(id,type){var c='Q';var r='Q1';var str=id.substr(1);if(str<10){c+=str;r+=0;}else{c+=str.charAt(1);r+=str.charAt(0);}if(type==1){document.getElementById(c).style.backgroundColor=color01;document.getElementById(r).style.backgroundColor=color01;}else{document.getElementById(c).style.backgroundColor=color02;document.getElementById(r).style.backgroundColor=color02;}}function myInput(id){with(document.getElementById(id)){value='';style.backgroundColor=color03;style.borderColor=color04;style.color=color05;}FAry[id]=false;myThStyle(id,1);}function myAnswerCheck(id){myThStyle(id,0);var elm=document.getElementById(id);if((elm.value!=null)&&(elm.value!='')&&(elm.value==AAry[id])){FAry[id]=true;with(elm){style.backgroundColor=color06;style.borderColor=color07;style.color=color08;}}else{FAry[id]=false;with(elm){style.backgroundColor=color09;style.borderColor=color10;style.color=color11;}}var flg=false;for(var i=0;i<=99;i++){if(FAry[('A'+i)]==false){flg=true;break;}}if(flg==false){clearInterval(timerID);timeStamp=0;document.getElementById('timer').style.backgroundColor=color12;myTableWink(tableBlinkTimes);}}function myTableWink(num){var i=0;if(num%2==0){for(i=0;i<=99;i++){with(document.getElementById(('A'+i)).style){backgroundColor=color06;borderColor=color07;color=color08;}}}else{for(i=0;i<=99;i++){with(document.getElementById(('A'+i)).style){backgroundColor=color09;borderColor=color10;color=color11;}}}if(num==0){clearTimeout(tableTimerID);}else{num-=1;tableTimerID=setTimeout("myTableWink('"+num+"')",500);}}function myCalculationType(){if(document.getElementsByName('calcType')[1].checked==true){calcType=1;}else{calcType=0;}}function myShowTable(){var html='';html+=' <table border="0" cellspacing="0" cellpadding="0" id="table100">'+"\n";html+='  <tr align="center" valign="middle">'+"\n";html+='   <th class="thRoot">&nbsp;</th>'+"\n";for(var i=0;i<=9;i++){html+='   <th class="thTop" id="Q'+i+'">&nbsp;</th>'+"\n";}html+='  </tr>'+"\n";var k='';for(i=0;i<=9;i++){html+='  <tr align="center" valign="middle">'+"\n";html+='   <th class="thLeft" id="Q1'+i+'">&nbsp;</th>'+"\n";if(i!=0)k=i;for(var j=0;j<=9;j++){html+='   <td><input type="text" name="" value="" size="2" maxlength="2" id="A'+k+j+'" class="cell" onFocus="myInput(\'A'+k+j+'\');" onBlur="myAnswerCheck(\'A'+k+j+'\');" /></td>'+"\n";}html+='  </tr>'+"\n";}html+=' </table>'+"\n";html+=' <div id="control"><input type="radio" name="calcType" value="0" onChange="myCalculationType();" />'+unescape("%uFF0B%uFF08%u305F%u3057%u3056%u3093%uFF09")+'&nbsp;<input type="radio" name="calcType" value="1" onChange="myCalculationType();" />'+unescape("%D7%uFF08%u304B%u3051%u3056%u3093%uFF09")+'&nbsp;&nbsp;<button type="button" name="" value="1" onClick="myStart();">'+unescape("%u25B6%20%u30B9%u30BF%u30FC%u30C8")+'</button>&nbsp;<button type="button" name="" value="2" onClick="myStop();">'+unescape("%u25A0%20%u30AF%u30EA%u30A2")+'</button>&nbsp;&nbsp;<span id="timer">&nbsp;00:00:00&nbsp;</span></div>'+"\n";document.getElementById('contents').innerHTML=html;if(calcType==1){document.getElementsByName('calcType')[0].checked=false;document.getElementsByName('calcType')[1].checked=true;}else{document.getElementsByName('calcType')[0].checked=true;document.getElementsByName('calcType')[1].checked=false;}}function myShowHelp(){if(document.getElementById('help').style.display=='block'){document.getElementById('help').style.display='none';}else{document.getElementById('help').style.display='block';}}

