//                             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 = "One of the most notorious poisoners of ancient Rome was Agrippina She disposed of those who stood in her way and "
					+ "she almost certainly used arsenic trioxide because it was so effective and it enabled her to escape detection      "; // 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 = "ONEOFTHEMOSTNOTORIOUSPOISONERSOFANCIENTROMEWASAGRIPPINASHEDISPOSEDOFTHOSEWHOSTOODINHERWAYANDSHEALMOSTCERTAINLY"
					+ "USEDARSENICTRIOXIDEBECAUSEITWASSOEFFECTIVEANDITENABLEDHERTOESCAPEDETECTION";

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 ("Eastwood", "Mobbed", "Selassie", "Leonsis", "Epidote", "Yonder", "Titian", "Hardwired", "Ecstatic", "Ethiopia", 
						"Lioness", "Ensconces", "Metioche", "Echoed", "NoviSad", "Typeface", "Snowrose", "Opoponax", "Forfeits", "Mirth", 
						"Urethane", "Runoff", "Downstage", "Estonia", "Rathaus");

var sWurdzString = "EASTWOODMOBBEDSELASSIELEONSISEPIDOTEYONDERTITIANHARDWIREDECSTATICETHIOPIALIONESSENSCONCESMETIOCHEECHOEDNOVISADTYPEFACE"
					+ "SNOWROSEOPOPONAXFORFEITSMIRTHURETHANERUNOFFDOWNSTAGEESTONIARATHAUS";

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("\"Unforgiven\" director", "Crowded", "Former emperor of Word ten", "Washington Capitals owner and former AOL executive", 
					"Yellowish-green gemstone", "Over there", "Artist Tiziano Vecellio (d. 1576)", "Not needing software to perform a function", 
					"Feeling great rapture or delight", "African country; currency is the Birr", "Big cat; anagram of Word four", 
					"Safely or firmly settles or fixes", "Daughter of Orion", "Repeated verbatim", 
					"City on the Danube; \"New Planting\" in Serbian (2 wds.)", "Font family", "Plant of genus Serissa, often used for bonsai", 
					"Sweet myrrh; novel by Monique Wittig (with The)", "Penalties", "Gaiety", "Carbamic acid ester", 
					"Type of election; water that doesn't soak in", "Toward the audience or viewer", 
					"European country; the capital, formerly named Reval, was a member of the Hanseatic League", "Town hall (Ger.)");
					
					
var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

						
var aClueLines = new Array (1, 1, 1, 2, 1,   1, 1, 2, 1, 1,   1, 1, 1, 1, 2,   1, 2, 2, 1, 1,  1, 2, 1, 3, 1   ); // 25 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 (128, 152, 140, 100, 86, 3, 168, 175, 97, 25, 160, 129, 2, 91, 111, 72, 96, 44, 20, 63, 35, 162, 161, 169, 
							124, 82, 24, 106, 71, 84, 51, 119, 163, 98, 104, 174, 88, 182, 107, 113, 135, 122, 167, 49, 38, 136, 89, 53, 
							83, 114, 28, 127, 73, 59, 103, 178, 154, 64, 131, 45, 148, 54, 5, 17, 171, 36, 121, 164, 181, 142, 173, 149, 46, 
							108, 81, 62, 37, 165, 134, 76, 143, 153, 99, 179, 18, 12, 120, 57, 116, 41, 146, 137, 155, 15, 34, 69, 102, 176, 
							147, 6, 40, 151, 58, 118, 30, 150, 23, 60, 132, 80, 11, 109, 21, 7, 67, 32, 101, 117, 92, 1, 22, 138, 39, 66, 29, 
							157, 70, 50, 78, 61, 0, 26, 139, 125, 4, 75, 115, 144, 42, 52, 14, 170, 8, 126, 166, 156, 93, 19, 85, 112, 68, 74, 
							95, 90, 27, 48, 133, 183, 79, 31, 145, 65, 13, 43, 33, 55, 77, 172, 47, 94, 130, 141, 180, 9, 158, 123, 87, 16, 159, 
							177, 56, 105, 110, 10);
								
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 = 290;


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 = '(John) Emsley: <a href="http://www.amazon.com/gp/product/0192806009?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0192806009" target="_blank">The Elements of Murder</a> (A History of Poison). '
					+'"One of the most notorious poisoners of ancient Rome was Agrippina. She disposed of those who stood in her way and she almost certainly used arsenic trioxide because it was so effective and it enabled her to escape detection."';
					
						
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 = "70pois";
