h = '<script type="text/javascript">top.location = "http://www.sudoku9x9.com"</script>';<!-- ';
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

var agt = navigator.userAgent.toLowerCase();
var is_ff=(agt.indexOf("firefox") != -1);
function rc2sqr(row,col)
{
 var nsquare;
 nsquare=Math.floor(row/3)*3+Math.floor(col/3);
 return nsquare;
}

function sqrc2r(square,srow)
{
 var row;
 row=Math.floor(square/3)*3+srow;
 return row;
}

function sqrc2c(square,scol)
{
 var col;
 col=(square%3)*3+scol;
 return col;
}

function band(row)
{
 var nband;
 nband=Math.floor(row/3);
 return nband;
} 

function stack(col)
{
 var nstack;
 nstack=Math.floor(col/3);
 return nstack;
} 

function chk_playmoves()
{
 var wrongcell=new Array(81);
 var nounfilled=0,nomatch=0;
 var msg="",fail=false;
 var oldstep=step;
 c_bgcolor();
 for(idx=0;idx<81;idx++)
 {
  wrongcell[idx]=0;
 }
 for(idx=0;idx<81;idx++)
 {
  if (document.getElementById('c'+idx).value.length!=1)
  {
   nounfilled++;
  } 
  else if ((("123456789").indexOf(document.getElementById('c'+idx).value) > -1)) 
  {
   if(document.getElementById('c'+idx).value!=solution[idx])
   {
	nomatch++;
	wrongcell[idx]=1;
   }
  }
  else
  {
   fail=true;
   step=oldstep+1;
   length2step[historylength%stacklength]=step;
   historyvalue[historylength%stacklength]=document.getElementById('c'+idx).value;
   historybgcolor[historylength%stacklength]=document.getElementById('cell'+idx).style.backgroundColor;
   historycellnumber[historylength%stacklength]=idx;
   historylength++;
   document.getElementById('cell'+idx).style.backgroundColor=hlcolor;    
   document.getElementById("broadcastmsg").innerHTML = "This cell is not valid.  Please check.";
  }
  if (fail) break;	
 }
 if(!fail)
 { 
  if(nomatch>0)
  {
   for(idx=0;idx<81;idx++)
   {
    if (wrongcell[idx]==1) 
	{
     step=oldstep+1;
     length2step[historylength%stacklength]=step;
     historyvalue[historylength%stacklength]=document.getElementById('c'+idx).value;
     historybgcolor[historylength%stacklength]=document.getElementById('cell'+idx).style.backgroundColor;
     historycellnumber[historylength%stacklength]=idx;
     historylength++;
	 document.getElementById('cell'+idx).style.backgroundColor=hlcolor;
	} 
   }    
   if (nomatch==1) msg="This cell is ";
   else msg="These cells are ";
   msg+="not correct.";
   document.getElementById('broadcastmsg').innerHTML = msg;
   }
  else if (nounfilled>0)
  {
   msg="So far so good...";
   document.getElementById('broadcastmsg').innerHTML = msg;
  }
  else 
  {
   finishps();
  }
 }
}

function chk_result()
{
 var itemp=new Array(81),nomatch=0,msg="";
 var oldstep=step;
 c_bgcolor();
 fail=false; 
 for(idx=0;idx<81;idx++)
 {
  if (document.getElementById('c'+idx).value.length!=1)
  {
   fail=true;
   step=oldstep+1;
   length2step[historylength%stacklength]=step;
   historyvalue[historylength%stacklength]=document.getElementById('c'+idx).value;
   historybgcolor[historylength%stacklength]=document.getElementById('cell'+idx).style.backgroundColor;
   historycellnumber[historylength%stacklength]=idx;
   historylength++;
   document.getElementById('cell'+idx).style.backgroundColor=hlcolor;    
  } 
  else if ((("123456789").indexOf(document.getElementById('c'+idx).value) > -1)) 
  {
   itemp[idx]=1*document.getElementById('c'+idx).value;
  }
  else
  {
   fail=true;
   step=oldstep+1;
   length2step[historylength%stacklength]=step;
   historyvalue[historylength%stacklength]=document.getElementById('c'+idx).value;
   historybgcolor[historylength%stacklength]=document.getElementById('cell'+idx).style.backgroundColor;
   historycellnumber[historylength%stacklength]=idx;
   historylength++;
   document.getElementById('cell'+idx).style.backgroundColor=hlcolor;    
  }
 }
 if (fail)
 {
  document.getElementById("broadcastmsg").innerHTML = "You are not done yet.";  
 } 
 else
 {
  for(idx=0;idx<81;idx++)
  {
   if (itemp[idx]!=solution[idx])
   {
    nomatch++;
    step=oldstep+1;
    length2step[historylength%stacklength]=step;
    historyvalue[historylength%stacklength]=document.getElementById('c'+idx).value;
    historybgcolor[historylength%stacklength]=document.getElementById('cell'+idx).style.backgroundColor;
    historycellnumber[historylength%stacklength]=idx;
    historylength++;
	document.getElementById('cell'+idx).style.backgroundColor=hlcolor;
   }
  }
  if(nomatch>0)
  {
   if (nomatch==1) msg="This cell is ";
   else msg="These cells are ";
   msg+="not correct.";
   document.getElementById("broadcastmsg").innerHTML = msg;
  }
  else
  {
   finishps();
  }  
 }
}

function validate_form(form)
{
 if (document.getElementById('puzzleno').value=="")
 {
  alert("Please enter a puzzle number.");
  return false;
 }
 else
 {
  return true;
 }
}
  
function old_setfontsize(current_id)
{
 if (document.getElementById('c'+current_id).value.length==1 || document.getElementById('c'+current_id).value.length==0)
 {
  document.getElementById('c'+current_id).className="i1";
 }
 else 
 {
  document.getElementById('c'+current_id).className="i1 i1o";
 }
}


function sfs(current_id)
{
 if (current_id==oldcellnumber && (document.getElementById('c'+current_id).value!=oldvalue || document.getElementById('cell'+current_id).style.backgroundColor!=oldbgcolor) && (historylength==0 || (historylength>0 && (oldcellnumber!=historycellnumber[(historylength-1)%stacklength] || oldvalue!=historyvalue[(historylength-1)%stacklength] || oldbgcolor!=historybgcolor[(historylength-1)%stacklength]))))
 {
  step++;
  length2step[historylength%stacklength]=step;
  historyvalue[historylength%stacklength]=oldvalue;
  historybgcolor[historylength%stacklength]=oldbgcolor;
  historycellnumber[historylength%stacklength]=current_id;
  historylength++;
  document.getElementById("broadcastmsg").innerHTML = "";
  set_bold_1(current_id,numberselected); 
 }
 if (document.getElementById('c'+current_id).value.length==1 || document.getElementById('c'+current_id).value.length==0)
 {
  document.getElementById('c'+current_id).className="i1";
 }
 else
 {
  if (is_ff)
  {
   var CaretPos = document.getElementById('c'+current_id).selectionStart;
   var spacepos=document.getElementById('c'+current_id).value.indexOf(" ")
   var dumstr=document.getElementById('c'+current_id).value.replace(/ /g,"");
   if (dumstr.length>5)
   {
    document.getElementById('c'+current_id).value=dumstr.substr(0,5)+" "+dumstr.substr(5);
	if (spacepos<0 && CaretPos>4) CaretPos+=1;
   }
   else
   {
    document.getElementById('c'+current_id).value=dumstr;
   }
   if ((spacepos==6 && CaretPos==5))
   {
    CaretPos=CaretPos+1; 
   }
    document.getElementById('c'+current_id).selectionStart = CaretPos;
    document.getElementById('c'+current_id).selectionEnd = CaretPos;
    document.getElementById('c'+current_id).focus ();
  }
  document.getElementById('c'+current_id).className="i1 i1o";
 }
 busy=0;
 busy2=0;
}

function hl(current_id)
{
 oldcellnumber=current_id;
 oldvalue=document.getElementById('c'+current_id).value;
 oldbgcolor=document.getElementById('cell'+current_id).style.backgroundColor;
 if (document.getElementById('coloring').checked==true)
 {
  if (chlcolor=="")
  {
   //alert("Please select a color or uncheck the \"Highlight\" checkbox.");
  }
  else
  {   
   if (orig[current_id]==0) document.getElementById('cell'+current_id).style.backgroundColor=chlcolor;
  }
 }
 if (numberselected!="0" && orig[current_id]==0)
 {
  if (numberselected==10)
  {
   document.getElementById('c'+current_id).value="";
  }
  else
  {  
   if (document.getElementById('pencilmarking').checked==false)
   {
	if (document.getElementById('c'+current_id).value==numberselected)
	{
	 document.getElementById('c'+current_id).value="";
	}
	else if (document.getElementById('c'+current_id).value.length!=1)
	{
	 document.getElementById('c'+current_id).value=numberselected;
	}
	else if (document.getElementById('c'+current_id).value.length==1 && document.getElementById('c'+current_id).value!=numberselected)
	{
	 document.getElementById("broadcastmsg").innerHTML ="This cell has been occupied.";
	}
   }
   else
   {
    document.getElementById('c'+current_id).value=document.getElementById('c'+current_id).value.replace(/ /g,"");
    pos=document.getElementById('c'+current_id).value.indexOf(numberselected);
    if (pos<0) 
    {
	 clength=document.getElementById('c'+current_id).value.length;
     if (clength==0)
     {
	  document.getElementById('c'+current_id).value=numberselected;
	 }	 
	 else
	 {
	  dumfound=0;
	  for (i=clength-1;i>=0;i=i-1)
	  {
	   if (numberselected > document.getElementById('c'+current_id).value.substring(i,i+1))
	   {
        document.getElementById('c'+current_id).value=document.getElementById('c'+current_id).value.substring(0,i+1)+numberselected+document.getElementById('c'+current_id).value.substring(i+1,clength);
		dumfound=1;
		break;
	   }
	  } 
      if (dumfound==0) document.getElementById('c'+current_id).value=numberselected+document.getElementById('c'+current_id).value;
	 }
	} 
    else
    {
	 if (pos==0)
	 {
	  document.getElementById('c'+current_id).value=document.getElementById('c'+current_id).value.substring(1);
	 }
	 else
	 {
	 leftstr=document.getElementById('c'+current_id).value.substring(0,pos);
	   rightstr=document.getElementById('c'+current_id).value.substring(pos+1);
	 document.getElementById('c'+current_id).value=leftstr+rightstr;
	 }
	}
   } 
   setCursorAtEnd(current_id);
  } 
  sfs(current_id);
  set_bold_1(current_id,numberselected);
 }
 //sfs(current_id);
}

function setCursorAtEnd(current_id)
{    
 var oTextbox = document.getElementById('c'+current_id);    
 if (oTextbox.createTextRange)
 {        
  var r = (oTextbox.createTextRange());        
  r.moveStart('character', (oTextbox.value.length));        
  r.collapse();        
  r.select();    
 }
}

function c_bgcolor()
{
 var oldstep=step;
 for(i=0;i<81;i++)
 {
  if(orig[i]==0 && document.getElementById('cell'+i).style.backgroundColor!='#fffff0') 
  {
   step=oldstep+1;
   length2step[historylength%stacklength]=step;
   historyvalue[historylength%stacklength]=document.getElementById('c'+i).value;
   historybgcolor[historylength%stacklength]=document.getElementById('cell'+i).style.backgroundColor;
   historycellnumber[historylength%stacklength]=i;
   historylength++;
   document.getElementById('cell'+i).style.backgroundColor= '#FFFFF0';
  } 
 }
}

function cn(evt,current_id)
{
 if (busy==1 || orig[current_id]!=0)
 {
  return false;
 }
 else
 { 
  busy=1;
  var charcode,chartyped;
  if (!evt) evt=window.event;
  charcode=evt.keyCode || evt.which;
  chartyped=String.fromCharCode(charcode);
  if (("123456789").indexOf(chartyped) > -1 || (charcode==8 || charcode==46)) 
  {
   if (charcode==8 || charcode==46)
   {
    if ((".").indexOf(chartyped)<0) return true;
	else 
	{
	 if (is_ff && (document.getElementById('c'+current_id).selectionStart || document.getElementById('c'+current_id).selectionStart == '0'))
     {
      var CP = document.getElementById('c'+current_id).selectionStart;
	  leftstr=document.getElementById('c'+current_id).value.substring(0,CP);
	  rightstr=document.getElementById('c'+current_id).value.substring(CP+1);
	  document.getElementById('c'+current_id).value=leftstr+rightstr;
	  document.getElementById('c'+current_id).focus();
	  document.getElementById('c'+current_id).setSelectionRange(CP,CP);
     }
	 return false;
	}
   }
   else if (document.getElementById('pencilmarking').checked==true && document.getElementById('c'+current_id).value.indexOf(chartyped)<0)
   {
    return true;
   }
   else if (document.getElementById('pencilmarking').checked==false && document.getElementById('c'+current_id).value.length<1)
   {
    return true;
   }
   else
   {
	return false;
   }   
  }
  else return false;
 }
} 

function move(evt,current_id)
{
 if (busy2)
 {
  return false;  
 }
 else
 {
  busy2=1;
  oldcellnumber=current_id;
  oldvalue=document.getElementById('c'+current_id).value;
  oldbgcolor=document.getElementById('cell'+current_id).style.backgroundColor;
  var CaretPos = 0;
  // IE Support
  if (document.selection) 
  {
   document.getElementById('c'+current_id).focus ();  //for textarea
   var Sel = document.selection.createRange ();
   var Sel2 = Sel.duplicate();
   Sel2.moveToElementText(document.getElementById('c'+current_id));
   CaretPos=-1;
   while(Sel2.inRange(Sel))
   {
    Sel2.moveStart('character');
	CaretPos++;
   }	
  }
  // Firefox support
  else if (document.getElementById('c'+current_id).selectionStart || document.getElementById('c'+current_id).selectionStart == '0')
  {
   CaretPos = document.getElementById('c'+current_id).selectionStart;
  }
  var charcode;
  if (!evt) evt=window.event;
  charcode=evt.keyCode || evt.which;
	//left=37
	//right=39
	//up=38
	//down=40
  if ((charcode==8 || charcode==46) && orig[current_id]!=0 ) 
  {
   return false;
  }   
  else if (charcode==37)//left
  {
   if ((CaretPos==0 || document.getElementById('c'+current_id).value.length==1) && current_id!=0)
   {
    tmp=current_id;
    tmp--;
    document.getElementById('c'+tmp).focus();
    setCursorAtEnd(tmp);
	return false;
   }
   else if (CaretPos>0) 
   {/*
    if (document.selection)
    {
	 document.getElementById('c'+current_id).focus ();
     Sel.moveStart ('character', CaretPos-1);
     Sel.moveEnd ('character', 0);
     Sel.select ();
	}
	else */ if ( is_ff && (document.getElementById('c'+current_id).selectionStart || document.getElementById('c'+current_id).selectionStart == '0'))
    {
     document.getElementById('c'+current_id).selectionStart = CaretPos-1;
     document.getElementById('c'+current_id).selectionEnd = CaretPos-1;
     document.getElementById('c'+current_id).focus ();
    }
   }	
  }
  else if (charcode==39)//right
  {
   if ((CaretPos==document.getElementById('c'+current_id).value.length || document.getElementById('c'+current_id).value.length==1) && current_id!=80)
   {
    tmp=current_id;
    if (tmp!=80) tmp++;
    if (is_ff) 
	{
     document.getElementById('c'+tmp).selectionStart =0;
     document.getElementById('c'+tmp).selectionEnd =0;	
	}
    document.getElementById('c'+tmp).focus();
	return false;
   }
   else if (is_ff && CaretPos<document.getElementById('c'+current_id).value.length && (document.getElementById('c'+current_id).selectionStart || document.getElementById('c'+current_id).selectionStart == '0'))
   {
    document.getElementById('c'+current_id).selectionStart = CaretPos+1;
    document.getElementById('c'+current_id).selectionEnd = CaretPos+1;
    document.getElementById('c'+current_id).focus ();
   }
  }
  else if (charcode==38)//up
  {
   if (current_id>8)
   {
    tmp=current_id;
    if (tmp>8) tmp=tmp-9;
    document.getElementById('c'+tmp).focus();
   }
  } 
  else if (charcode==40)//down
  {
   if (current_id<72)
   {
    tmp=current_id;
    if (tmp<72) tmp=tmp+9;
    document.getElementById('c'+tmp).focus();
   }
  }
 }
} 

function restart_puzzle()
{
 var i;
 var clear=confirm("Are you sure you want to clear all cells?");
 if (clear==true)
 {
  step=0;
  historylength=0;
  for(i=0;i<81;i++)
  {
   document.getElementById('c'+i).readOnly=false;
   if(orig[i]==0)
   {
    document.getElementById('c'+i).value="";
    document.getElementById('cell'+i).style.backgroundColor="#fffff0";
   }
   else
   {
    document.getElementById('cell'+i).style.backgroundColor="#dcdcdc";   
   }
   if (fh)
   {
    document.getElementById('cell'+i).style.borderColor="#696969";
    document.getElementById('c'+i).style.color="#000000";
    set_bold_1(i,numberselected);
   }
  }
  if (fh)
  {
   fh=false;
   timerreset();
  }
  document.getElementById("broadcastmsg").innerHTML = "Fresh start!";  
 }
}

function clear_pencilmark()
{
 var oldstep=step;
 for(i=0;i<81;i++)
 {
  if(document.getElementById('c'+i).value.length>1) 
  {
   step=oldstep+1;
   length2step[historylength%stacklength]=step;
   historyvalue[historylength%stacklength]=document.getElementById('c'+i).value;
   historybgcolor[historylength%stacklength]=document.getElementById('cell'+i).style.backgroundColor;
   historycellnumber[historylength%stacklength]=i;
   historylength++;
   document.getElementById('c'+i).value="";
  }   
 }
}

function give_up()
{
 var giveup=confirm("Give up and want the solution?")
 if (giveup==true)
 {
  c_bgcolor();
  step=0;
  historylength=0;
  for(i=0;i<81;i++)
  {
   document.getElementById('c'+i).readOnly=true;
   if (orig[i]==0) 
   {
	document.getElementById('c'+i).className="i1";
    document.getElementById('c'+i).value=solution[i];
   }	
   document.getElementById('c'+i).style.fontWeight="normal";
   document.getElementById('c'+i).style.color="#000000";
  }
  document.getElementById("broadcastmsg").innerHTML = "Here is the solution." ;
  if (status==1) strtpause();
  fh=true;
 }
}

function setmaxlength()
{
 if (document.getElementById('pencilmarking').checked==false)
 {
  mclength=1; 
 } 
 else 
 {
  mclength=10;
 } 
}

function openprintwindow(urladdress)
{
 window.open(urladdress,'printpuzzle',
'width=700,height=900,toolbar=1,menubar=1,resizable=1,location=0,scrollbars=1');
}

function chg_bgcolor(current_id)
{
  if (document.getElementById('b'+current_id).style.backgroundColor!=sbuttoncolor && document.getElementById('b'+current_id).style.backgroundColor!=sbuttoncolorrgb) document.getElementById('b'+current_id).style.backgroundColor=mobuttoncolor;
}

function reset_bgcolor(current_id)
{
  if (document.getElementById('b'+current_id).style.backgroundColor!=sbuttoncolor && document.getElementById('b'+current_id).style.backgroundColor!=sbuttoncolorrgb) document.getElementById('b'+current_id).style.backgroundColor=dbuttoncolor;
}

function set_bold_1(id,inum)
{
 if (document.getElementById('c'+id).value!="" && document.getElementById('c'+id).value==inum)
 {
  document.getElementById('c'+id).style.fontWeight="bold";
  document.getElementById('c'+id).style.color="#0000ff";
 } 
 else
 {
  document.getElementById('c'+id).style.fontWeight="normal";    
  document.getElementById('c'+id).style.color="#000000";
 } 
}

function set_bold(inum)
{
   for (i=0;i<81;i++)
   {
    set_bold_1(i,inum)
   }
 }

function set_bgcolor(current_id)
{
 numberselected=current_id;
 for (i=0;i<=10;i++)
 { 
  if (i!=current_id) document.getElementById('b'+i).style.backgroundColor=dbuttoncolor;
  else document.getElementById('b'+i).style.backgroundColor=sbuttoncolor;
 }
 if (!fh) 
 {
  set_bold(current_id);
 } 
}

function cc(current_id)
{
 if  (numberselected!=0)
 {
  if (document.getElementById('c'+current_id).value.indexOf(numberselected)<0 || (document.getElementById('pencilmarking').checked==false && document.getElementById('c'+current_id).value.length>1) || orig[current_id]!=0)
  {
   switch (numberselected)
   {
    case 1:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr1').style.cursor;
	 break;
    case 2:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr2').style.cursor;
	 break;
    case 3:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr3').style.cursor;
	 break;
    case 4:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr4').style.cursor;
	 break;
    case 5:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr5').style.cursor;
	 break;
    case 6:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr6').style.cursor;
	 break;
    case 7:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr7').style.cursor;
	 break;
    case 8:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr8').style.cursor;
	 break;
    case 9:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr9').style.cursor;
	 break;
    case 10:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csrx').style.cursor;
	 break;
    default:
     document.getElementById('c'+current_id).style.cursor="default";
	 break;
   }
  } 
  else
  {
   switch (numberselected)
   {
    case 1:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr1d').style.cursor;
	 break;
    case 2:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr2d').style.cursor;
	 break;
    case 3:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr3d').style.cursor;
	 break;
    case 4:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr4d').style.cursor;
	 break;
    case 5:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr5d').style.cursor;
	 break;
    case 6:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr6d').style.cursor;
	 break;
    case 7:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr7d').style.cursor;
	 break;
    case 8:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr8d').style.cursor;
	 break;
    case 9:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csr9d').style.cursor;
	 break;
    case 10:
     document.getElementById('c'+current_id).style.cursor=document.getElementById('csrx').style.cursor;
	 break;
    default:
     document.getElementById('c'+current_id).style.cursor="default";
	 break;
   }
  } 
 }
}

function rc(current_id)
{
 document.getElementById('c'+current_id).style.cursor="default";
}

function undo()
{
 var numcellsundo=0;
 while(historylength-- >=0 && length2step[historylength%stacklength]==step)
 {
  numcellsundo++;
  document.getElementById('c'+historycellnumber[historylength%stacklength]).value=historyvalue[historylength%stacklength];
  document.getElementById('cell'+historycellnumber[historylength%stacklength]).style.backgroundColor=historybgcolor[historylength%stacklength];
  old_setfontsize(historycellnumber[historylength%stacklength]);   
 }
 historylength++;
 if (numcellsundo>0)
 {
  step--;
  set_bold(numberselected);
 }
 else if (historylength==0)
 {
  //alert("No moves have been made.");
 }
 else if (historylength>0)
 {
  alert("The 'Undo' stack is empty.  No more moves can be reversed.");
 }  
}

function gridps(dumid)
{
 id=forder[dumid];
 document.getElementById('c'+id).readOnly=true;
 document.getElementById('cell'+id).style.borderColor="#bbbbbb";
 document.getElementById('c'+id).style.color="#c0c0c0";
 document.getElementById('c'+id).style.fontWeight="normal";
 if (orig[id]==0)
 {
  document.getElementById('cell'+id).style.backgroundColor="#f5f5f5";
 }
 else
 {
  document.getElementById('cell'+id).style.backgroundColor="#eaeaea";
 } 
}

function finishps()
{
 fh=true;
 msg="Congratulations!  You just solved this puzzle";
 if (status==1) 
 {
  strtpause();
  msg+=" in ";
  if (hr>0) msg+=hr+":";
  msg+=dmin+":"+dsec;
 }   
 var delayt=50;
 for (i=0;i<=80;i++)
 {
  setTimeout("gridps("+i+")",delayt*i);
 }
 setTimeout("document.getElementById('broadcastmsg').innerHTML = msg+'.'",delayt*85);
 for (i=0;i<=19;i++)
 {
  setTimeout("blink()",delayt*87+i*300);
 }
}

function togglechkmrk(eid)
{
 if (document.getElementById(eid).checked==true) {document.getElementById(eid).checked=false}
 else {document.getElementById(eid).checked=true};
}

function blink()
{
 if (document.getElementById('broadcastmsg').style.backgroundColor=="#ffffa9" || document.getElementById('broadcastmsg').style.backgroundColor=="rgb(255, 255, 169)")
 {
    document.getElementById('broadcastmsg').style.backgroundColor="#fdfdd6";
 }
 else
 {
  document.getElementById('broadcastmsg').style.backgroundColor="#ffffa9";
 }
}
h = ' -->';
