var d=document;d.write('');function opendiv(){
document.dv.visibility='visible';
}
function closediv(){
document.dv.visibility='hidden';
}
var diff='2';
var cheat='875642931426319758193587264964173582731825649258496317517268493682934175349751826';
var puz = '875#4#93####3####8##358#264####7##82#3#825#4#25##9####517#684##6####4####49#5#826';
var t_o=0;
function key(t){
document.onkeydown=nav;
if(t>=0){
d=new Date();
t_o=d.getTime()/1000-t;
tim();
}
}
function tim(){
if(document.getElementById('timer'))if(t_o>0){
d=new Date();
t=Math.round(d.getTime()/1000-t_o);
m=Math.floor(t/60);
s=t%60;
document.getElementById('timer').innerHTML=''+m+':'+((s<10)?'0':'')+s+'';
setTimeout('tim()',1000);
}
}
function nav(e){
if(!e)e=window.event;
t=e.target?e.target:e.srcElement;
if(t){
k=e.keyCode;
i=t.id;
if((i.charAt(0)=='f')&&(k>=37)&&(k<=40)){ //37=left, 38=up, 39=right, 40=down
g=true;
if(k%2){ //up-down and left-right
dx=k-38;
l=t.value.length;
if(l>0){
if(t.selectionStart||t.selectionStart=='0'){
sp=t.selectionStart;
ep=t.selectionEnd;
}else if(document.selection&&document.selection.createRange){
r=document.selection.createRange();
sl=r.text.length;
r.moveStart('character',-l);
ep=r.text.length;
sp=ep-sl;
}else g=false;
if((dx<0)&&(ep>0))g=false;
if((dx>0)&&(sp<1))g=false;
}
}
if(g){
x=parseInt(i.charAt(1));
y=parseInt(i.charAt(2));
for(r=1;r<9;r++){
if(k%2)y=(9+y+k-38)%9;
else x=(9+x+k-39)%9;
n=document.getElementById('f'+x+y);
if(n&&(!n.readOnly)){
n.select();
if (window.event){
window.event.cancelBubble=true;
// window.event.returnValue=false;
}
// if(e.preventDefault)e.preventDefault();
if(e.stopPropagation)e.stopPropagation();
break;
}
}
}
}
}
}
function ft(f){
if(f.value.length>3)f.className='v'+f.className.substr(1,10);
else if(f.value.length>1)f.className='w'+f.className.substr(1,10);
else f.className='d'+f.className.substr(1,10);
if(document.form.help.checked==true)if(f.value.length==1){
var num;
if(f.id=='f08')num=8;
else num=parseInt(f.id.substring(1))-parseInt(f.id.charAt(1));
if(f.value!=cheat.charAt((num)))f.className=f.className.charAt(0)+'1';
else f.className=f.className.charAt(0)+'0';
}
for(x=0;x1)empty++;
if(document.form.elements[x].value!=cheat.charAt(x)&&document.form.elements[x].value!=''&&document.form.elements[x].value.length==1){
if(document.form.help.checked==true)document.form.elements[x].className=document.form.elements[x].className.charAt(0)+'1';
errors++;
}
if(errors==0&&empty==0)document.form.text.value='Congratulations, you have solved level '+diff+' !';
else if(errors==0)document.form.text.value='Everything is OK, you still have '+empty+' to go!';
else document.form.text.value='Something is not quite right in '+errors+' of the cells!';
}
}
function err(){
if(document.form.help.checked==true)for(x=0;x<81;x++){
if(document.form.elements[x].value!=cheat.charAt(x)&&document.form.elements[x].value!=''&&document.form.elements[x].value.length==1){
document.form.elements[x].value='';
document.form.elements[x].className=document.form.elements[x].className.charAt(0)+'0';
}
}else document.form.text.value='Check the help box to remove all erroneous entries';
}
function cbx(){
if(document.form.help.checked==true)document.form.text.value='Click \'How am I doing?\' to see the errors';
else document.form.text.value='Check the help box to see how you are doing';
}
function clr(){
if(document.form.help.checked==true)for(x=0;x<81;x++){
if(puz.charAt(x)=='#')document.form.elements[x].value='';
else document.form.elements[x].value=puz.charAt(x);
document.form.elements[x].className=document.form.elements[x].className.charAt(0)+'0';
}else document.form.text.value='Check the help box first and then restart this puzzle';
}
function fil(){
if(document.form.help.checked==true)for(x=0;x<81;x++){
document.form.elements[x].value=cheat.charAt(x);
document.form.elements[x].className=document.form.elements[x].className.charAt(0)+'0';
}else document.form.text.value='Check the help box to see the solution of this puzzle';
}
var j=1;
function eks(){
var msg=new Array();
msg[1]="There are only a few, easy rules for playing Sudoku";
msg[2]="Enter every number from 1 to 9 into the blank spaces";
msg[3]="In such a way that every row, column and 3x3 square";
msg[4]="Contains only one of each number";
msg[5]="More info on http://gheos.org/s/sudoku/help.php";
msg[6]="Each Sudoku is solvable logically, without guessing";
msg[7]="Click help to see the rules for playing Sudoka";
msg[8]="S u d o k a";
var tm=setTimeout('eks()',3000);
document.form.text.value=msg[j];
j++;
if(j>8)clearTimeout(tm);
}
d.write('');
//d.write('');
key(0);