numero="012345678"
back= new Array("white","AliceBlue", "PaleTurquoise", "LightYellow","MistyRose","LightCyan","AntiqueWhite","Lavender","Oldlace","LavenderBlush");
nero="black"
function colora(questo) {
questo.style.backgroundColor=sfondo
questo.value=base
conta_cas()
}

function Genera(){
 x = document.forms['MioForm'].elements;
for ( i=0;i<x.length-1;i++) {
		if (x[i].className != "bottone1") {
    x[i].style.backgroundColor = back[0]
    x[i].value=''
    }
 }
 conta_cas()
}
var solSudo=new Array
function conta_cas() {
 x = document.forms['MioForm'].elements;
 quante = 0
for ( i=0;i<x.length-1;i++) {
		if (x[i].value != ''){
    solSudo[i]=x[i].value
			 quante=quante+1
    }
	}
  quante = 81 - quante
 document.scelta.caselle.value =  'CASELLE DA COMPLETARE ' + quante
if (quante == 0) {
 confronta()
 }
}

 function confronta() {
fatto = true
x = document.forms['SolForm'].elements;
for (i=0; i<81; i++){
        num=x[i].value
        if (solSudo[i] != num) {
            fatto=false
            break
            }
    }
  if (fatto == true){
  document.scelta.caselle.style.color='red'
  document.scelta.caselle.value = 'COMPLIMENTI, SUDOKU RISOLTO!'}
  else {
  document.scelta.caselle.style.color='navy'
  document.scelta.caselle.value = 'LA SOLUZIONE NON E\' CORRETTA'}
}

function aiuto(qui) {
qui=eval(qui)-1
y = document.forms['SolForm'].elements;
appo=y[qui].value
x = document.forms['MioForm'].elements;
x[qui].value = appo
x[qui].style.backgroundColor = back[appo]
    conta_cas()
}

function vedi(){
x = document.forms['SolForm'].elements;
if(document.SolForm.tasto.value == "VEDI"){
for (i=0; i<81; i++){
     x[i].style.display="block";
     x[i].style.color = nero;
   }
document.SolForm.tasto.value="CHIUDI"
}
else{
  for (i=0; i<81; i++){
   x[i].style.color="#ecf0ee"
 }
 document.SolForm.tasto.value="VEDI"
 }
}

