var i,s,w,my={};var gsize,ghrow,ghcol,gtime,gmoves,gintervalid=-1,gshuffling;function arrangeMain(){my.version=0.7;var s='';s+='';s+='
';s+='

' s+='Choose Level: ';s+='';s+=' ';s+='';s+='

' s+='

';s+='
';s+='
';s+='
';s+='
';s+='

 

';s+='
';s+='Instructions:';s+='
    ';s+='
  1. Choose a Level (3 to 10).
  2. ';s+='
  3. The game board has blocks with numbers in it. Also there is a single "hole" that can be used for moving the blocks.
  4. ';s+='
  5. The objective of the game is to order the numbers using the "hole" for temporary movement.
  6. ';s+='
  7. Move blocks in a row by clicking on them. A block can be moved only if it is in the same row or column as the "hole".
  8. ';s+='
  9. You can move multiple blocks (in the same row or column as the "hole") by clicking the farthest block that you need to be moved.
  10. ';s+='
';s+='

 

';s+='
';s+=optPopHTML();document.write(s);loadBoard(parseInt(document.getElementById('level').value));startGame();} function toggleHelp(){if(butHelp.value=="Hide Help"){help.style.display="none";butHelp.value="Show Help";}else{help.style.display="";butHelp.value="Hide Help";}} function r(low,hi){return Math.floor((hi-low)*Math.random()+low);} function r1(hi){return Math.floor((hi-1)*Math.random()+1);} function r0(hi){return Math.floor((hi)*Math.random());} function startGame(){shuffle();gtime=0;gmoves=0;window.clearInterval(gintervalid);tickTime();gintervalid=window.setInterval("tickTime()",1000);} function stopGame(){if(gintervalid==-1)return;window.clearInterval(gintervalid);var f=document.getElementById("fldStatus");f.innerHTML="";gintervalid=-1;} function tickTime(){showStatus();gtime++;} function checkWin(){var i,j,s;if(gintervalid==-1)return;if(!isHole(gsize-1,gsize-1))return;for(i=0;i";s+="Your speed is "+Math.round(1000*gmoves/gtime)/1000+" moves/sec";s+="";var f=document.getElementById("fldStatus");f.innerHTML=s;window.clearInterval(gintervalid);} function showStatus(){var f=document.getElementById("fldStatus");f.innerHTML="Time: "+gtime+" secs   Moves: "+gmoves} function brdGet(){var i,j,s;stopGame();s='';for(i=0;i';} s+='
';} return s;} function getCell(row,col){var s;s="a_"+row+"_"+col;return document.getElementById(s);} function setValue(row,col,val){var v=getCell(row,col);v.value=val;v.className="cell";} function getValue(row,col){var v=getCell(row,col);return v.value;} function setHole(row,col){var v=getCell(row,col);v.value=" ";v.className="hole";ghrow=row;ghcol=col;} function getRow(obj){var a=obj.id.split("_");return a[1];} function getCol(obj){var a=obj.id.split("_");return a[2];} function isHole(row,col){return(row==ghrow&&col==ghcol)?true:false;} function getHoleInRow(row){var i;return(row==ghrow)?ghcol:-1;} function getHoleInCol(col){var i;return(col==ghcol)?ghrow:-1;} function shiftHoleRow(src,dest,row){var i;src=parseInt(src);dest=parseInt(dest);if(srcdest;i--){setValue(row,i,getValue(row,i-1));setHole(row,i-1);}}} function shiftHoleCol(src,dest,col){var i;src=parseInt(src);dest=parseInt(dest);if(srcdest;i--){setValue(i,col,getValue(i-1,col));setHole(i-1,col);}}} function move(obj){var r,c,hr,hc;if(gintervalid==-1&&!gshuffling){alert('Please press the "Start Game" button to start.') return;} r=getRow(obj);c=getCol(obj);if(isHole(r,c))return;hc=getHoleInRow(r);if(hc!=-1){shiftHoleRow(hc,c,r);gmoves++;checkWin();return;} hr=getHoleInCol(c);if(hr!=-1){shiftHoleCol(hr,r,c);gmoves++;checkWin();return;}} function shuffle(){var t,i,j,s,frac;gshuffling=true;frac=100.0/(gsize*(gsize+10));for(i=0;i