<center id="mb"></center>
<script>
function SetShips (ev)
{
var E = ev || window.event, D = E.srcElement || E.target; if (D.tagName != 'DIV' || D.lang) return;
var O = document.getElementById ('mb'), T = O.firstChild, K = O.getElementsByTagName ('DIV'),
fc = function (x) {var x = x.toString (); return ((x.length < 2) ? x : x.charAt (1)) * 1},
fr = function (x) {var x = x.toString (); return ((x.length < 2) ? 0 : x.charAt (0)) * 1},
fk = function (x, y) {with (x) lang = (y) ? 'p' : 't', style.backgroundColor = '#eee', style.cursor = 'default'},
c = D.parentNode.cellIndex, r = D.parentNode.parentNode.rowIndex, j = 10 * r + c, l = T.lang.split ('-'),
m = l [0].charAt (0) * 1, n = l [1] * 1 + 1;
D.lang = 's'; with (D.style) {backgroundColor = 'blue'; cursor = 'default'}
for (var q = 0, lq = K.length; q < lq; q++) if (K [q].lang == 't')
with (K [q]) lang = '', style.backgroundColor = '#fff', style.cursor = 'pointer';
if (r && c) fk (K [j - 11], 1); if (r && (c - 9)) fk (K [j - 9], 1);
if ((r - 9) && c) fk (K [j + 9], 1); if ((r - 9) && (c - 9)) fk (K [j + 11], 1);
if (m > n) {var v = '-'; if (n == 1)
{var go = ve = 1; if (m == 3)
{
go = (((c && !(K [j - 1].lang)) && ((c - 1) && !(K [j - 2].lang))) || ((c && !(K [j - 1].lang)) && ((c - 9) && !(K [j + 1].lang)))
|| (((c - 9) && !(K [j + 1].lang)) && ((c - 8) && !(K [j + 2].lang)))) ? 1 : 0;
ve = (((r && !(K [j - 10].lang)) && ((r - 1) && !(K [j - 20].lang))) || ((r && !(K [j - 10].lang)) && ((r - 9) && !(K [j + 10].lang)))
|| (((r - 9) && !(K [j + 10].lang)) && ((r - 8) && !(K [j + 20].lang)))) ? 1 : 0;
}
if (c && go) v += (j - 1) + '-'; if ((c - 9) && go) v += (j + 1) + '-';
if (r && ve) v += (j - 10) + '-'; if ((r - 9) && ve) v += (j + 10) + '-';
}
else
{
if ((c && (K [j - 1].lang == 's')) || ((c - 9) && (K [j + 1].lang == 's')))
{
if (c && (K [j - 1].lang == 's'))
{if ((c - 9) && !(K [j + 1].lang)) v += (j + 1) + '-'; if (fc (j - n + 1) && !(K [j - n].lang)) v += (j - n) + '-'}
else
{if (c && !(K [j - 1].lang)) v += (j - 1) + '-'; if ((fc (j + n - 1) - 9) && !(K [j + n].lang)) v += (j + n) + '-'}
}
else
{
if (r && K [j - 10].lang == 's')
{if (r - 9 && !(K [j + 10].lang)) v += (j + 10) + '-'; if (fr (j - 10 * n + 10) && !(K [j - 10 * n].lang)) v += (j - 10 * n) + '-'}
else
{if (r && !(K [j - 10].lang)) v += (j - 10) + '-'; if ((fr (j + 10 * n - 10) - 9) && !(K [j + 10 * n].lang)) v += (j + 10 * n) + '-'}
}
}
for (var q = 0, lq = K.length; q < lq; q++) if (v.indexOf ('-' + q + '-') == -1 && !(K [q].lang)) fk (K [q], 0); T.lang = l [0] + '-' + n}
else
{
O.removeChild (O.getElementsByTagName ('SPAN') [0]); for (var q = 0, lq = K.length; q < lq; q++)
{
if (K [q].lang == 's')
{
K [q].style.backgroundColor = '#000';
if ((fc (q) > 0) && (K [q - 1].lang != 's')) fk (K [q - 1], 1); if ((fc (q) - 9) && (K [q + 1].lang != 's')) fk (K [q + 1], 1);
if ((q > 9) && (K [q - 10].lang != 's')) fk (K [q - 10], 1); if ((q < 90) && (K [q + 10].lang != 's')) fk (K [q + 10], 1);
}
}
if (l [0].length == 1)
{
for (var q = 0, lq = K.length; q < lq; q++)
if (K [q].lang != 's') with (K [q]) lang = '', style.backgroundColor = '#fff', style.cursor = 'default';
O.getElementsByTagName ('H4') [0].innerHTML = 'Играйте!'; T.onclick = null; return;
}
T.lang = l [0].substr (1) + '-0'; O.getElementsByTagName ('SPAN') [0].style.display = '';
var M = T.lang.charAt (0) - 1; if (M) for (var q = 0, lq = K.length; q < lq; q++)
{
if (!(K [q].lang))
{
var uL = ((fc (q) > 0) && !(K [q - 1].lang)), uR = ((fc (q) - 9) && !(K [q + 1].lang)),
uU = ((q > 9) && !(K [q - 10].lang)), uD = ((q < 90) && !(K [q + 10].lang));
if (!(uL || uR || uU || uD)) fk (K [q], 0);
else if (M > 1)
{
var uL2 = (uL && ((fc (q - 1) > 0) && !(K [q - 2].lang))), uR2 = (uR && ((fc (q + 1) - 9) && !(K [q + 2].lang))),
uU2 = (uU && ((q > 19) && !(K [q - 20].lang))), uD2 = (uD && ((q < 80) && !(K [q + 20].lang)));
if (!((uL && uR) || (uU && uD) || uL2 || uR2 || uU2 || uD2)) fk (K [q], 0);
}
}
}
}
}
(function ()
{
with (document) var o = getElementById ('mb'), t = createElement ('TABLE'), d = createElement ('DIV'), m = createElement ('H4'),
w = function (x, y) {with (document) {var a = createElement ('SPAN'); a.style.color = 'blue'; if (x) a.style.display = 'none';
a.appendChild (createTextNode (y)); getElementById ('mb').appendChild (a)}}
with (t) cellSpacing = cellPadding = 0, border = 1, style.borderCollapse = 'collapse';
d.style.cssText = 'width: 30px; height: 30px; cursor: pointer; background-color: #fff'; for (var j = 0; j < 10; j++)
for (var r = t.insertRow (-1), k = 0; k < 10; c.appendChild (d.cloneNode (1)), k++) var c = r.insertCell (-1);
t.onclick = SetShips; t.lang = '4332221111-0'; o.appendChild (t); m.appendChild (document.createTextNode ('Расставьте корабли:'));
o.appendChild (m); var a = 'четырёх', b = 'трёх', c = 'двух', d = 'одно', e = 'палубный', f = 'первый ', g = 'второй ',
h = 'третий ', i = 'четвёртый '; w (0, a + e); w (1, f + b + e); w (1, g + b + e); w (1, f + c + e); w (1, g + c + e);
w (1, h + c + e); w (1, f + d + e); w (1, g + d + e); w (1, h + d + e); w (1, i + d + e);
}) ();
</script>