// JavaScript Document
var squarenum=0;
var curnum=0;
curcol="#fbde55";
document.write('<table style=cursor:pointer;cursor:hand bgcolor='+curcol+' border=0 cellpadding=1 cellspacing=1>')
for(var count1=0; count1<8; count1++){
document.write('<tr>')
if(curcol=="#fbde55") {curcol="#ff6600"} else curcol="#fbde55";
for(var count=0; count<8; count++){
if(curcol=="#fbde55") {curcol="#ff6600"} else curcol="#fbde55";
document.write('<td bgcolor='+curcol+' id='+curnum+' name='+squarenum+' width=35 height=35 onclick=\"moveto(this);\"> </td>');
curnum++;
squarenum++
}
document.write('</tr>')
curnum+=20;
}
document.write('</table>')
document.getElementById(0).innerHTML="<img src=cavallo.gif>";
document.getElementById(0).bgColor="#660066";

var squares=new Array(true);
var score=0;
var where;
var oldwhere=0;

function moveto(square){
	where=square.id;
	if ((oldwhere==where-26 || oldwhere==where-30 || oldwhere==where-55 || oldwhere==where-57 || oldwhere-26==where || oldwhere-30==where || oldwhere-55==where || oldwhere-57==where))
	{
	score++;
	document.getElementById("scorey").innerHTML=score;
	document.getElementById(oldwhere).innerHTML=" ";
	document.getElementById(where).innerHTML="<img src=cavallo.gif width=32 height=32>";
	document.getElementById(where).bgColor="#660066";
	oldwhere=where;
	squares[square.name]=true;
	}
	for (var i=0; i<63; i++) if (squares[i]!=true) var stuffed=true
	if (stuffed!=true) {alert("Hai vinto in "+score+" mosse!");window.location.href=window.location.href;}
}
