<!---
 
function puzzle(initial, solution, date, comment, source)
{
  var initialStr = new String(initial);
  //attributes
  var solutionStr     = solution; //string
  var dateStr         = date;     //string: dd Mon year
  var commentStr      = comment;
  var sourceStr       = source; 
  var archived        = true;
 
  // method mapping
  this.isArchived          = _isArchived;
  this.setArchived         = _setArchived;
  this.getDateStr          = _getDateStr;
  this.getSolutionStr      = _getSolutionStr;
  this.getCommentStr       = _getCommentStr;
  this.getSourceStr        = _getSourceStr;
  this.getInitialStr       = _getInitialString;
  this.popupLargeBoard     = _popupLargeBoard;
  this.writeBoard          = _writeBoard;
  this.writePuzzle         = _writePuzzle;
  this.writeMate           = _writeMate;
  this.writeSolutionBoard2 = _writeSolutionBoard2;
  this.writeSolution2      = _writeSolution;
  this.writeSolutonBoard   = _writeSolutionBoard;
  this.writeSolution       = _writeSolution;
  this.writeSolutionSmall  = _writeSolutionSmall;

  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 _getInitialString()
  {
    return initialStr;
  }

  function _parseGif(pCode, myDoc)
  {
    myDoc.write("<IMG SRC=\'http://knightwatchman.netfirms.com/pics/pview/" + pCode + ".gif" +"\' border=0 >");
  }
  
  function _doSquare(file, rank, sz, myDoc)
  {
    //parses the initial string to pull out the sub string 
    //giving the piece info for a rank
    var index = (rank-1)*8 + file-1;
    var white = (1+ rank + file) % 2; //odd sum gives white to true (1,1 lower left is false or black)
    var code = new String();
    var piece = initialStr.charAt(index);
    if (piece == '-')   //empty square
      code = "i";     
    else if (piece == 'P') //white pawn
      code = "wp";
    else if (piece == 'p') //black pawn
      code = "bp";
    else if (piece == 'R') //white rook
      code = "wr";
    else if (piece == 'r') //black rook
      code = "br";
    else if (piece == 'N') //white knight
      code = "wn";
    else if (piece == 'n') //black knight
      code = "bn";
    else if (piece == 'B') //white bishop
      code = "wb";
    else if (piece == 'b') //black bishop
      code = "bb";
    else if (piece == 'Q') //white queen
      code = "wq";
    else if (piece == 'q') //black queen
      code = "bq";
    else if (piece == 'K') //white king
      code = "wk";
    else if (piece == 'k') //black king
      code = "bk";  
    var param = code + sz;
    _parseGif(param, myDoc);
  }
 
  function _doRank(rank, sz, myDoc)
  {
    //parses the initial string to pull out the sub string 
    //giving the piece info for a rank
    _doSquare(1, rank, sz, myDoc);
    _doSquare(2, rank, sz, myDoc);
    _doSquare(3, rank, sz, myDoc);
    _doSquare(4, rank, sz, myDoc);
    _doSquare(5, rank, sz, myDoc);
    _doSquare(6, rank, sz, myDoc);
    _doSquare(7, rank, sz, myDoc);
    _doSquare(8, rank, sz, myDoc);
    myDoc.write("<BR>");
  }
 
  function _writeBoardToDoc(sz, myDoc)
  {
    if (myDoc == 0)
    {
      myDoc = this.document;
    }
    myDoc.write("<center><TABLE CELLSPACING=\'0\' CELLPADDING=\'0\'");
    myDoc.write("class=\'pgbb\'>"); 
    myDoc.write("<TR><TD>");
    myDoc.write("<CENTER><TABLE BACKGROUND=\'http://knightwatchman.netfirms.com/pics/pview/brdred" + sz +".gif\'");
    myDoc.write("CELLSPACING=\'0\' CELLPADDING=\'0\'>");
    myDoc.write("<TR>");
    myDoc.write("<TD>");
    _doRank(1, sz, myDoc);
    _doRank(2, sz, myDoc);
    _doRank(3, sz, myDoc);
    _doRank(4, sz, myDoc);
    _doRank(5, sz, myDoc);
    _doRank(6, sz, myDoc);
    _doRank(7, sz, myDoc);
    _doRank(8, sz, myDoc);
    myDoc.write("</TD>");
    myDoc.write("</TR>");
    myDoc.write("</TABLE>");
    myDoc.write("</center>");
    myDoc.write("</TD>");
    myDoc.write("</TR>");
    myDoc.write("</TABLE>");
    myDoc.write("</center>");
  }

  function _popupLargeBoard(title) 
  {
    height=35*8+48;
    width=35*8+48;
    popup=window.open ("", "largeboard", 
	config="height="+height+", width="+width+", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");

    var myDoc = popup.document;
    myDoc.write("<HEAD><TITLE>"+title);
    myDoc.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    myDoc.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    myDoc.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    myDoc.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    myDoc.write("</TITLE></HEAD>");
    myDoc.write("<LINK REL=\'stylesheet\' HREF=\'http://knightwatchman.netfirms.com/croslink.css\'>");
    myDoc.write("<LINK REL=\'stylesheet\' HREF=\'http://knightwatchman.netfirms.com/kw2.css\'>");
    myDoc.write("<LINK REL=\'stylesheet\' HREF=\'kw2.css\'>");
    _writeBoardToDoc(35, myDoc);
    popup.document.close()
  }
 
  function _writeBoard(size)
  {
    var myDoc = document;
    _writeBoardToDoc(size, myDoc);
  }

  function _writePuzzle(size)
  {
    document.write("<table width=100% border=0><tr><td><center>");
    _writeBoard(size);
    document.write("<p>");
    document.write("<font size=4 color=\'#000000\'>");
    document.write( _getCommentStr());
    document.write("<br>");
    document.write("<font size=3 color=\'#000000\'>(");
    document.write( _getDateStr());
    document.write(")</font>");
    document.write("</CENTER>");
    document.write("<p>&nbsp;</p>");
    document.write("</center></td></tr></table>");
  }
 
  function _writeMate(size)
  {
    document.write("<table width=100% border=0><tr><td><center>");
    _writeBoard(size);
    document.write("<p>");
    document.write("<font size=4 color=\'#000000\'>White to Mate</font>");
    document.write("</center></td></tr></table>");
  }
 
  function _writeSolutionBoard2(size)
  {
    document.write("<center><font size=4 color='#000000'>Mate in 2 Solution</font><br>");
    document.write("<font size=3 color='#000000'>(");
    document.write( _getDateStr());
    document.write(")</font><br>&nbsp;<br>");
    _writeBoard(size);
    document.write("<br>&nbsp;<br><font size=4 color='#000000'>");
    document.write( _getSolutionStr());
    document.write("</font>");
    document.write("</center>");
  }
 
  function _writeSolution2(current)
  {
    document.write("<center><font size=4 color='#000000'>Mate in 2 Solution</font><br>");
    document.write("<font size=3 color='#000000'>(");
    document.write( _getDateStr());
    document.write(")</font><br>");
    document.write("<font size=4 color='#000000'>");
    document.write( _getSolutionStr());
    document.write("</font>");
    document.write("</center>");
  }
 
  function _writeSolutionBoard(size)
  {
    document.write("<center><font size=4 color='#000000'>Mate Solution</font><br>");
    document.write("<font size=3 color='#000000'>(");
    document.write(+_getDateStr());
    document.write(")</font><br>&nbsp;<br>");
    _writeBoard(size);
    document.write("<br>&nbsp;<br><font size=4 color='#000000'>");
    document.write(_getSolutionStr());
    document.write("</font>");
    document.write("</center>");
  }
 
  function _writeSolution()
  {
    document.write("<center><font size=4 color='#000000'>Mate Solution</font><br>");
    document.write("<font size=3 color='#000000'>(");
    document.write( _getDateStr());
    document.write(")</font><br>");
    document.write("<font size=4 color='#000000'>");
    document.write( _getSolutionStr());
    document.write("</font></center>");
  }
 
  function _writeSolutionSmall()
  {
    document.write("<center><font size=3 color='#000000'><b>Mate Solution</font></b><br>");
    document.write( _getSolutionStr());
    document.write("</font></center>");
  }

}


function writeBoard(current,size)
{
  puzzles[current].writeBoard(size);
}

/*
rbnqkbnr
pppppppp
--------
--------
--------
--------
PPPPPPPP
RBNQKBNR
 
<IMG SRC=\'http://knightwatchman.netfirms.com/pics/slnP.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'http://knightwatchman.netfirms.com/pics/slnR.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'http://knightwatchman.netfirms.com/pics/slnN.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'http://knightwatchman.netfirms.com/ics/slnB.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'http://knightwatchman.netfirms.com/pics/slnQ.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
<IMG SRC=\'http://knightwatchman.netfirms.com/pics/slnK.gif\' WIDTH=19 HEIGHT=19 BORDER=0><b>
 */
  
function writePuzzle(current,size)
{
  document.write("<table width=100% border=0><tr><td><center>");
  writeBoard(current,size);
  document.write("<p>");
  document.write("<font size=4 color=\'#000000\'>");
  document.write(puzzles[current].getCommentStr());
  document.write("<br>");
  document.write("<font size=3 color=\'#000000\'>(");
  document.write(puzzles[current].getDateStr());
  document.write(")</font>");
  document.write("</CENTER>");
  document.write("<p>&nbsp;</p>");
  document.write("</center></td></tr></table>");
}
 
function writeMate(current,size)
{
  document.write("<table width=100% border=0><tr><td><center>");
  writeBoard(current,size);
  document.write("<p>");
  document.write("<font size=4 color=\'#000000\'>White to Mate</font>");
  document.write("</center></td></tr></table>");
}
 
function writeSolutionBoard2(current, size)
{
  document.write("<center><font size=4 color='#000000'>Mate in 2 Solution</font><br>");
  document.write("<font size=3 color='#000000'>(");
  document.write(puzzles[current].getDateStr());
  document.write(")</font><br>&nbsp;<br>");
  writeBoard(current,size);
  document.write("<br>&nbsp;<br><font size=4 color='#000000'>");
  document.write(puzzles[current].getSolutionStr());
  document.write("</font>");
  document.write("</center>");
}
 
function writeSolution2(current)
{
  document.write("<center><font size=4 color='#000000'>Mate in 2 Solution</font><br>");
  document.write("<font size=3 color='#000000'>(");
  document.write(puzzles[current].getDateStr());
  document.write(")</font><br>");
  document.write("<font size=4 color='#000000'>");
  document.write(puzzles[current].getSolutionStr());
  document.write("</font>");
  document.write("</center>");
}
 
function writeSolutionBoard(current, size)
{
  document.write("<center><font size=4 color='#000000'>Mate Solution</font><br>");
  document.write("<font size=3 color='#000000'>(");
  document.write(puzzles[current].getDateStr());
  document.write(")</font><br>&nbsp;<br>");
  writeBoard(current,size);
  document.write("<br>&nbsp;<br><font size=4 color='#000000'>");
  document.write(puzzles[current].getSolutionStr());
  document.write("</font>");
  document.write("</center>");
}
 
function writeSolution(current)
{
  document.write("<center><font size=4 color='#000000'>Mate Solution</font><br>");
  document.write("<font size=3 color='#000000'>(");
  document.write(puzzles[current].getDateStr());
  document.write(")</font><br>");
  document.write("<font size=4 color='#000000'>");
  document.write(puzzles[current].getSolutionStr());
  document.write("</font></center>");
}
 
function writeSolutionSmall(current)
{
  document.write("<center><font size=3 color='#000000'><b>Mate Solution</font></b><br>");
  document.write("<font size=4 color='#000000'>");
  document.write(puzzles[current].getSolutionStr());
  document.write("</font></center>");
}
 
 
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";
  }
}
 
-->