function rc2id(row,col) {
  return 10 * row + col;
}
function set_a_sn(row,col,a,sn) {
	var id=rc2id(row,col);
	var el=document.getElementById(id);
	el.setAttribute('a',a);
	el.setAttribute('sn',sn);
}
function get_a(r,c) {
	var id=rc2id(r,c);
	var el=document.getElementById(id);
	return el.getAttribute('a');
}
function reset() {
	for (var id=0;id<100;id++) {
		var el=document.getElementById(id);
		el.setAttribute('a',0);
		el.src='images/0.png';
	}
}
function test() {
	for (id=0;id<100;id++) {
		var el=document.getElementById(id);
		var a=el.getAttribute('a');
		el.src='images/right/'+a+'.png';
		el.setAttribute('v',a);
	}
}
function check() {
	var parts=[0,1,1,2,2,3,3,4,4];
	var counts=[];
	for (var i=0;i<9;i++) counts[i]=0;
	for (var id=0;id<100;id++) {
		var el=document.getElementById(id);
		var sn=el.getAttribute('sn');
		if (sn>0) {
			var a=el.getAttribute('a');
			var v=el.getAttribute('v');
			if (a==v) counts[sn]++;
		}
	}
	var n=0;
	for (var i=1;i<9;i++) {
		if (counts[i]==parts[i]) {
			n++;
			var el=document.getElementById('s'+i);
			el.style.opacity=1;
		}
	}
	g_ships=n;
}
