function save(){
var str=makeCookieString();
setCookie("sudoku_fingerprint",str);
alert("Game saved.");
}
function load(){
clearer();
var str=getCookie("sudoku_fingerprint");
if(str==""||str==null){
alert("No saved games found!")
return false;
}
compleated=0;
var index=0;
var puzzle_cells=str.split(";");
for(var a=0;a<9;a++){
for(var b=0;b<9;b++){
number=puzzle_cells[index];
if(number.charAt(0)=="."){
number=number.charAt(1);
cells[a][b].disabled=true;
}
cells[a][b].value=number;
index++;
}
}
}
function toggleTimer(){
if(!timer_paused){
clearTimeout(timer_clock);
timer_element.style.color="#f00";
$("timer_control").value="Continue";
timer_paused=1;
var edit_mask=$("pause-hider");
edit_mask.style.display="block";
if(!timer_seconds)timer_seconds=0;
var secs=timer_seconds%60;
var mins=Math.floor(timer_seconds/60);
if(secs<10)secs="0"+secs;
if(mins<10)mins="0"+mins;
edit_mask.innerHTML="<br /><strong>Game Paused at "+mins+":"+secs+"</strong><br />"+
"<a onclick='toggleTimer()' style='CURSOR:pointer'>Click to Continue...</a><br />"+
"<IFRAME FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=300 HEIGHT=250 ALLOWTRANSPARENCY=TRUE SRC='../ad.html'></IFRAME>";
}else{
$("timer_control").value="Pause";
timer_element.style.color="#000";
timer_paused=0;
timer();
var edit_mask=$("pause-hider");
edit_mask.style.display="none";
}
}
function checker(){
var found=0;
show("Checking game...","#a84efa");
loop:
for(var a=0;a<9;a++){
for(var b=0;b<9;b++){
var ele=cells[a][b];
var id="c"+(a+1)+(b+1);
var value=ele.value
if(isNaN(value)||value<1||value>9){
if(value==""){
show("Empty cells found.","#d78601");
}else{
show("Invalid entries found.","#d78601");
}
found=1;
ele.style.background="red";
setTimeout("discolorCells('"+id+"')",2000);
break loop;
}
else if(value){
if(!checkForUnique(a,b,false)){
ele.style.background="red";
document.getElementById(repeated_at).style.background="red";
show("Repeated numbers were found.","#d78601");
setTimeout("discolorCells('"+repeated_at+"','"+id+"')",2000);
found++;
break loop;
}
}else{
show("Empty cells were found. Please complete the puzzle.","#d78601");
ele.style.background="red";
setTimeout("discolorCells('"+id+"')",2000);
found=1;
break loop;
}
}
}
if(!found){
if(compleated)
alert("Sorry - you can't win after giving up. But it is solved.");
else
alert("Congratulations - You have completed the puzzle.");
stopTimer();
show("Game Over! Let's try with another level! :p","#000000");
}
}
function reloadGame(){
if(confirm("This will empty all cells.\nAre you sure you want to do this?\n")){
str2pos(orginal_game);
}
}
function solve(){
show("Finding the solution to the game...");
if(confirm("This will automaticaly solve the puzzle for you.\nAre you sure you want to do this?\n")){
str2pos(this_puzzle);
compleated=1;
show("Solved the puzzle.");
stopTimer();
}
}
function checkStatus(){
var invalid_cells=0;
var empty_cells=0;
for(var a=0;a<9;a++){
for(var b=0;b<9;b++){
var ele=cells[a][b];
var value=ele.value
if(isNaN(value)||value<1||value>9){
if(value==""){
empty_cells++;
}else{
invalid_cells++;
}
}
else if(value){
if(!checkForUnique(a,b,true)){
ele.style.background="red";
var id="c"+(a+1)+(b+1);
$(repeated_at).style.background="red";
setTimeout("discolorCells('"+repeated_at+"','"+id+"')",2000);
return;
}
}else{
empty_cells++;
}
}
}
show("You are doing fine so far. You have "+(invalid_cells+empty_cells)+" more cells to fill.","#006600");
fadeColor("display_area","#ffff00","#ffffff",30,100,"b");
}
function BnewGame(){
if(confirm("This will start a whole new puzzle for you.\nAre you sure you want to do this?\n"))
newGame();
}