<!---
 
function puzzle(initial, solution, date, comment, source)
{
  var initialStr      = initial;  //string
  var solutionStr     = solution; //string
  var dateStr         = date;     //string: dd Mon year
  var commentStr      = comment;
  var sourceStr       = source;
  var archived        = true;
 
  this.isArchived     = _isArchived;
  this.setArchived    = _setArchived;
  this.getDateStr     = _getDateStr;
  this.getSolutionStr = _getSolutionStr;
  this.getCommentStr  = _getCommentStr;
  this.getSourceStr   = _getSourceStr;
  this.writeBoard     = _writeBoard;
 
  function _isArchived()
  {
    return archived;
  }
 
  function _setArchived(value)
  {
    archived = value;
  }
 
  function _getDateStr()
  {
    return dateStr;
  }
 
  function _getSolutionStr()
  {
    if (archived)
      return solutionStr;
    else
      return "Look tomorrow.";
  }
 
  function _getCommentStr()
  {
    return commentStr;
  }
 
  function _getSourceStr()
  {
    return sourceStr;
  }
 
  function _parseGif(pCode)
  {
    document.write("<IMG SRC=\'..\\pics\\pview\\" + pCode + ".gif" +"\' border=0 >");
  }
  
  function _doSquare(file, rank, rankStr, sz)
  {
    //parses the initial string to pull out the sub string 
    //giving the piece info for a rank
    var index = file -1;
    var piece = rankStr.charAt(index);
    var white = (1+ rank + file) % 2; //odd sum gives white to true (1,1 lower left is false or black)
    if (piece == '-')   //empty square
      _parseGif("i"+ sz );
    else if (piece == 'P') //white pawn
      _parseGif("wp"+ sz );
    else if (piece == 'p') //black pawn
      _parseGif("bp"+ sz );
    else if (piece == 'R') //white rook
      _parseGif("wr"+ sz );
    else if (piece == 'r') //black rook
      _parseGif("br"+ sz );
    else if (piece == 'N') //white knight
      _parseGif("wn"+ sz );
    else if (piece == 'n') //black knight
      _parseGif("bn"+ sz );
    else if (piece == 'B') //white bishop
      _parseGif("wb"+ sz );
    else if (piece == 'b') //black bishop
      _parseGif("bb"+ sz );
    else if (piece == 'Q') //white queen
      _parseGif("wq"+ sz );
    else if (piece == 'q') //black queen
      _parseGif("bq"+ sz );
    else if (piece == 'K') //white king
      _parseGif("wk"+ sz );
    else if (piece == 'k') //black king
      _parseGif("bk"+ sz );
  }
 
  function _doRank(rank, sz)
  {
    //parses the initial string to pull out the sub string 
    //giving the piece info for a rank
    var begin = (rank - 1)*8;
    var end   = begin + 8;
    rankStr = initial.substring(begin, end)
    _doSquare(1, rank, rankStr, sz);
    _doSquare(2, rank, rankStr, sz);
    _doSquare(3, rank, rankStr, sz);
    _doSquare(4, rank, rankStr, sz);
    _doSquare(5, rank, rankStr, sz);
    _doSquare(6, rank, rankStr, sz);
    _doSquare(7, rank, rankStr, sz);
    _doSquare(8, rank, rankStr, sz);
    document.write("<BR>");
  }
 
  function _writeBoard(sz)
  {
    //document.write("<CENTER><TABLE BORDER=1 BGCOLOR= \'#C0C0C0\'>");
    document.write("<center><TABLE CELLSPACING=\'0\' CELLPADDING=\'0\'");
    document.write("class=\'pgbb\'>"); 
    //document.write("style=\'border-color : midnightblue; ");
    //document.write("border-style : double;");
    //document.write("border-width : 10px;\' >");
    document.write("<TR><TD>");
    document.write("<CENTER><TABLE BACKGROUND=\'../pics/pview/brdgraystone" + sz +".jpg\'");
    document.write("CELLSPACING=\'0\' CELLPADDING=\'0\'>");
    document.write("<TR>");
    document.write("<TD>");
    _doRank(1, sz);
    _doRank(2, sz);
    _doRank(3, sz);
    _doRank(4, sz);
    _doRank(5, sz);
    _doRank(6, sz);
    _doRank(7, sz);
    _doRank(8, sz);
    document.write("</TD>");
    document.write("</TR>");
    document.write("</TABLE>");
    document.write("</center>");
    document.write("</TD>");
    document.write("</TR>");
    document.write("</TABLE>");
    document.write("</center>");
  }
}
 
 
/*
rbnqkbnr
pppppppp
--------
--------
--------
--------
PPPPPPPP
RBNQKBNR
 
<IMG SRC=\'../pics/slnP.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'../pics/slnR.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'../pics/slnN.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'../pics/slnB.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'../pics/slnQ.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'../pics/slnK.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
 */
  
function writePuzzle(current,size)
{
  document.write("<table width=100% border=0><tr><td><center>");
  document.write("<font size=5>for&nbsp;");
  document.write(puzzles[current].getDateStr());
  document.write("</font>");
  document.write("<br>");
  document.write("<a href='credits.html' style='text-decoration=none';>");
  document.write("<font color='#000000' size=2>");
  document.write(puzzles[current].getSourceStr());
  document.write("</font>");
  document.write("</a>");
  puzzles[current].writeBoard(size);
  document.write("<p>");
  document.write("<font size=4 color=\'#000000\'>");
  document.write(puzzles[current].getCommentStr());
  document.write("</font>");
  document.write("</CENTER>");
  document.write("<p>&nbsp;</p>");
  document.write("</center></td></tr></table>");
}
 
function writeSolution(current)
{
  document.write("<table width=100% border=0><tr><td><center>");
  document.write("<font size=4 color='#AF0F0F'>Solution:</font><font size=4 color='#000000'>&nbsp;&nbsp;");
  document.write(puzzles[current].getSolutionStr());
  document.write("</font></center></td></tr></table>");
}
 
function showSolution()
{
  //show current solution...
  var id1 = "solution" + parseInt(currentPuzzle,10);
  document.all.item("solution").style.visibility = "hidden";
  document.all.item(id1).style.visibility = "visible";
}
 
function getNext()
{
  var oldValue = currentPuzzle;
  if (currentPuzzle > 0)
  {
    currentPuzzle -= 1;
  }
  else
  {
    currentPuzzle = 0;
  }
 
  if (oldValue != currentPuzzle)
  {
    var id1 = "puzzle"   + parseInt(oldValue,10);
    var id2 = "solution" + parseInt(oldValue,10);
    var id3 = "puzzle"   + parseInt(currentPuzzle,10);
    document.all.item(id1).style.visibility = "hidden";
    document.all.item(id2).style.visibility = "hidden";
    document.all.item(id3).style.visibility = "visible";
    document.all.item("solution").style.visibility = "visible";
  }
}
 
function getPrev()
{
  var oldValue = currentPuzzle; 
  if (currentPuzzle < numPuzzles - 1)
  {
    currentPuzzle += 1;
  }
  else
  {
    currentPuzzle = numPuzzles - 1;
  }
 
  if (oldValue != currentPuzzle)
  {
    var id1 = "puzzle"   + parseInt(oldValue,10);
    var id2 = "solution" + parseInt(oldValue,10);
    var id3 = "puzzle"   + parseInt(currentPuzzle,10);
    document.all.item(id1).style.visibility = "hidden";
    document.all.item(id2).style.visibility = "hidden";
    document.all.item(id3).style.visibility = "visible";
    document.all.item("solution").style.visibility = "visible";
  }
}
 
 
function setCurrent()
{
  currentPuzzle = 0;//numPuzzles - 1;  
  var id = "puzzle"   + parseInt(currentPuzzle,10);
  document.all.item(id).style.visibility = "visible";
  document.all.item("solution").style.visibility = "visible";
}
 
function loadPuzzle(offset)
{
  var oldValue = currentPuzzle;  
  currentPuzzle = numPuzzles - offset;
  if (oldValue != currentPuzzle)
  {
    var id1 = "puzzle"   + parseInt(oldValue,10);
    var id2 = "solution" + parseInt(oldValue,10);
    var id3 = "puzzle"   + parseInt(currentPuzzle,10);
    document.all.item(id1).style.visibility = "hidden";
    document.all.item(id2).style.visibility = "hidden";
    document.all.item(id3).style.visibility = "visible";
    document.all.item("solution").style.visibility = "visible";
  }
}
 
-->
