/* 5x5 <http://www.davep.org/misc/5x5/> support code.
 * Dave Pearson <http://www.davep.org/>
 */
   
var moves = -1;

function toggleCell( cell )
{
   cell.className = cell.className == "cellOff" ? "cellOn" : "cellOff";
}

function refreshDisplay()
{
   document.getElementById( "moves" ).innerHTML = "<strong>Moves:</strong> " + moves;
}

function cellClick( cell, row, col )
{
   toggleCell( cell );
   if ( row > 0 ) toggleCell( document.getElementById( "cell" + ( row - 1 ) + col ) );
   if ( row < 4 ) toggleCell( document.getElementById( "cell" + ( row + 1 ) + col ) );
   if ( col > 0 ) toggleCell( document.getElementById( "cell" + row + ( col - 1 ) ) );
   if ( col < 4 ) toggleCell( document.getElementById( "cell" + row + ( col + 1 ) ) );
   moves++;
   refreshDisplay();
}

function initGame()
{
   cellClick( document.getElementById( "cell22" ), 2, 2 );
   refreshDisplay();
}
