function shape_clicked(image) {
	var v=image.getAttribute('v');
	if (g_shape!='') {
		g_shape.style.borderColor='ivory';
	}
	g_shape=image; g_shape_v=v;
	g_shape.style.borderColor='orange';
}
function square_clicked(image) {
  if (g_shape=='') {
   alert('please choose a shape');
  } else {
    var v=g_shape.getAttribute('v');
    var answer=image.getAttribute('a');
    if (v==answer || v==8) {
      image.src=g_shape.src;      
    } else {
      image.src='images/wrong/'+v+'.png';
      g_misses++;
    }
    image.setAttribute('v',v);
    check();
    if (g_ships==8) alert('All ships found. Number of misses: '+g_misses+'.');
  }
}
function counter_clicked(el) {
	var id=el.id;
	var n=id.substring(1);
	if (n<10) {
		var row=n;
		for (var col=0;col<10;col++) fill(row,col);
	} else {
		var col=n-10;
		for (var row=0;row<10;row++) fill(row,col);
	}
}
function fill(row,col) {
	var id=rc2id(row,col);
	var el=document.getElementById(id);
	var v=el.getAttribute('v');
	if (v==0) {
		var a=get_a(row,col);
		if (a==7) {
			el.src='images/right/7.png';
		} else {
			el.src='images/wrong/7.png';
			g_misses++;
		}
	}
}
