//                             This file is copyright 2010 by Michael H. Dickman. All rights reserved.


// The quote, without punctuation but with spaces, hyphens, and capitalization. Used to display the blank grid and the grid with solution.
var sAcrostiString = "Hardings games while in office were for fun and relaxation not profit or political advantage and the rumor that he "
					+ "lost the White House china in one of them is merely a bit of embroidery      "; // 6 spaces have been added to the end.
						
var iASLen = sAcrostiString.length; // Length of quote including spaces and padding at end.

// This is the sAcrostiString, but all uppercase and without spaces (or hyphens). It is used to determine whether the puzzle has been solved. 
var sSolutionString = "HARDINGSGAMESWHILEINOFFICEWEREFORFUNANDRELAXATIONNOTPROFITORPOLITICALADVANTAGEANDTHERUMORTHATHELOSTTHEWHITEHOUSECHINA"
					+ "INONEOFTHEMISMERELYABITOFEMBROIDERY";

var iTotalLetters = sSolutionString.length; // Total number of letters (no spaces) in quote (and therefore Wurdz).

// Answers to clues, first letter of each word capitalized but no spaces or hyphens (letters and numbers only).
var aWurdz = new Array ("Mithridate", "Chieftain", "Mainsheet", "Aurelio", "NewFrontier", "Untimely", "Stroganoff", "Cathode", "Overthrow", 
					"Weathered", "BonaFide", "Oxblood", "Yipes", "Scalene", "Framingham", "Upharsin", "Lightfoot", "Lionheart");

var sWurdzString = "MITHRIDATECHIEFTAINMAINSHEETAURELIONEWFRONTIERUNTIMELYSTROGANOFFCATHODEOVERTHROWWEATHEREDBONAFIDEOXBLOODYIPESSCALENE"
					+ "FRAMINGHAMUPHARSINLIGHTFOOTLIONHEART";

var aWhichClue = new Array (iTotalLetters);
// Given a position in the aWurdzAttempt array, which clue is it in? Zero-based counting. Used for keyboard navigation.

var aWhichLetter = new Array (iTotalLetters);
// Given a position in the aWurdzAttempt array, which letter of the wurd is it? ***One-based*** counting. Used for keyboard navigation.

						
var aClues = new Array("Racine tragedy (1673); semi-mythical all-purpose antidote", "Leader of a people, clan, or tribe", 
					"Line used to control the principal sail on a ship", "Michael Dibden's fictional Italian detective, ___ Zen", 
					"Term for JFK's programs (2 wds.)", "Premature; at an inopportune moment", "Beef dish with sour cream", "Battery end", 
					"Remove forcibly from power", "Changed as a result of being outside; survived, endured", "Genuine, sincere (2 wds.)", 
					"Moderate to deep brownish-red color", "Exclamation of surprise", "Triangle type", "Mass. town 20 miles from Boston", 
					"\"Mene, mene, tekel, ___\"", "Canadian singer-songwriter Gordon", "Epithet for Richard I");
					
					
var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

						
var aClueLines = new Array (2, 1, 2, 2, 1,   1, 1, 1, 1, 2,   1, 1, 1, 1, 1,   1, 1, 1  ); // 18 total
// How many lines each clue uses, given the current parameters. Must find by experiment at present. Used to dimension the clue text boxes.

var aGridAttempt = new Array(iTotalLetters);	// Holds letters for attempted solution. Blanks are represented by spaces.
var aWurdzAttempt = new Array(iTotalLetters);	// Ditto, except blanks are represented by underscores.

// The array below shows which grid square to go to from a given wurdz space, starting at zero.
var aWurdzToGrid = new Array (10, 117, 92, 14, 132, 65, 80, 36, 105, 142, 112, 82, 147, 126, 33, 89, 116, 18, 120, 143, 136, 56, 37, 7, 90, 101, 
							27, 45, 78, 109, 59, 121, 16, 46, 96, 35, 131, 26, 141, 53, 20, 79, 99, 104, 149, 84, 85, 5, 124, 138, 130, 94, 41, 
							151, 110, 139, 88, 54, 6, 1, 73, 50, 30, 123, 66, 44, 74, 125, 108, 3, 11, 47, 71, 83, 39, 57, 107, 28, 61, 102, 13, 
							25, 75, 64, 0, 40, 32, 133, 148, 137, 146, 48, 91, 21, 128, 70, 111, 87, 43, 144, 95, 122, 58, 38, 135, 63, 52, 29, 
							12, 97, 24, 67, 134, 106, 115, 17, 55, 2, 9, 86, 23, 118, 76, 100, 42, 127, 34, 60, 103, 72, 150, 129, 15, 19, 68, 4, 
							8, 113, 98, 22, 31, 119, 51, 62, 114, 140, 49, 93, 77, 69, 145, 81);
								
var aGridToWurdz = new Array (aWurdzToGrid.length); //This will map the grid squares (not counting spaces, as in aGridNumbers below) to the aWurdzAttempt array.
													// Initialized in initPuzzle(). Zero-based array.

var aGridNumbers = new Array (iASLen);	// This would be the way the grid is numbered in print. The spaces (and padding) will be represented by zero.
										//  Initialized in initPuzzle(). 
var aGridAttemptToGaps = new Array (iASLen);	// This maps the attempt string -without spaces- to the grid -with spaces-.
								
//****** The variables below are associated with placement of graphic items.
var iBoxAcross = 12;	// Taken from width of acrostic pdf, for example. Number of columns in acrostic.
var iBoxWidth = 25;
var iBoxHeight = 24;
var iBoxDown = Math.ceil(iASLen/iBoxAcross); // Calculates number of rows in puzzle grid.


var iCluesLeftCoord = 50; 
var iCluesTopCoord = 100;


var iCluWidth = 240;
var iLineHeight = 23;
var iTotalCluesHeight = 0; // Calculated in initPuzzle.
var iPadFactor = 8;

var iPuzzleLeftCoord = iCluesLeftCoord + 470;	// Distance of puzzle grid from left side. (500)
var iPuzzleTopCoord = iCluesTopCoord + 5;	// Distance of puzzle grid (and cluse and wurdz) from top.

var iMaxWurdzLength = 0;
var iUnderscoreWidth = 14;
var iWurdzHeight = 20;
var iWurdzLeftCoord = iCluesLeftCoord + iCluWidth + 10;
var iWurdzWidth = iPuzzleLeftCoord - iWurdzLeftCoord - 5; 
var iWurdzRightCoord = iWurdzLeftCoord + iWurdzWidth;
var iWurdzTop = iCluesTopCoord;
var iWurdzBottom = iWurdzTop + iTotalCluesHeight * iCluNum; // Will be recalculated later.

var iBoxSelected = 0;	// Which grid square(underscore) is selected?
var iGridLeft = iPuzzleLeftCoord + 2;
var iGridRight = iGridLeft + iBoxWidth * iBoxAcross;
var iGridTop = iPuzzleTopCoord + 4;
var iGridBottom = iGridTop + iBoxHeight * iBoxDown;
							
var sAuthorQuote = '(James) McManus: <a href="http://www.amazon.com/gp/product/0285638718?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0285638718" target="_blank">Cowboys Full</a> (the Story of Poker). '
					+'"Harding\'s games while in office were for fun and relaxation, not profit or political advantage, and the rumor that he lost the White House china in one of them is merely a bit of embroidery. (The more significant charges are that Harding took poker, alcohol, and his affairs with at least two women more seriously than his responsibilities as president and that he fostered a spirit of corruption.)"';
					
						
var iInstructionsTop = (iBoxHeight * iBoxDown) + iPuzzleTopCoord + 30; // Thirty pixels below the bottom of the puzzle.
var iInstructionsLeft = iPuzzleLeftCoord + 5;
var iInstructionsWidth = iBoxAcross * iBoxWidth; // Width of grid, approx.
var iInstructionsHeight = 50; // May need to be changed depending on puzzle.

var sPuzzleCode = "76hard";

