function highlight(id) {
  var el=document.getElementById(g_square_id);
  el.style.backgroundColor='white';
  var el=document.getElementById(id);
  el.style.backgroundColor='palegreen';
  g_square_id=id;
}
function move_on(id) {
	if (g_found<g_letters) {
	  var row=parseInt(id/10);
	  var col=id%10;
	  col+=2;
	  if (col>9) {
	    row++; col=0;
	    if (row>9) row=0;
	  }
	  var id=rc2id(row,col);
	  var square=document.getElementById(id);
	  if (square.style.visibility=='hidden') {
	    move_on(id);
	  } else {
	    var a=square.getAttribute('a');
	    var v=square.textContent;
	    if (a==v) { // already found
	      move_on(id);
	    } else {
	      highlight(id);
	    }
	  }
	} else {
		finale();
	}
}
function finale() {
  var el=document.getElementById(g_square_id);
  el.style.backgroundColor='white';
  var id=0;
  for (var row=0;row<10;row++) {
  	var el=document.getElementById(id);
  	if (el.style.visibility=='hidden') break;
  	el.style.backgroundColor='lightblue';
  	id+=10;
  }
}
function go() {
	g_letters=0;
	load_squares(g_sets[g_pick]);
	g_pick++;
	g_found=0;
	for (var id=0;id<100;id++) {
		var el=document.getElementById(id);
		el.style.backgroundColor='white';
	}
	highlight(0);
}


