//                             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 = "The theft of Franz Joseph Haydns skull was by no means an isolated incident interest in phrenology sparked a bizarre "
					+ "and intense fascination with the human skull and in particular with the skulls of great men        "; // 8 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 = "THETHEFTOFFRANZJOSEPHHAYDNSSKULLWASBYNOMEANSANISOLATEDINCIDENTINTERESTINPHRENOLOGYSPARKEDABIZARREANDINTENSEFASCINATION"
					+ "WITHTHEHUMANSKULLANDINPARTICULARWITHTHESKULLSOFGREATMEN";

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 ("Chutzpah", "Othello", "LeftHand", "Instant", "Nairobi", "Drifted", "Infinite", "Carlson", "Kazakhstan", "Edelweiss", 
					"Ypres", "Canary", "Riotous", "Athens", "Neptune", "IsleOfWight", "Owlish", "Kirsten", "Lambeth", "Endgame", "Panjandrum", 
					"Thankfulness", "Yarn");

var sWurdzString = "CHUTZPAHOTHELLOLEFTHANDINSTANTNAIROBIDRIFTEDINFINITECARLSONKAZAKHSTANEDELWEISSYPRESCANARYRIOTOUSATHENSNEPTUNEISLEOFWIGHT"
					+ "OWLISHKIRSTENLAMBETHENDGAMEPANJANDRUMTHANKFULNESSYARN";

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("Shameless audacity, temerity", "Shakespeare tragedy (ca. 1603)", "\"The ___ of Darkness\" (Le Guin; 2 wds.)", 
					"\"Thy letters have transported me beyond/ This ignorant present, and I feel now/ The future in the __\" (Macbeth, act 1, sc. 5)", 
					"The U.S. Embassy in this city was bombed in 1998 by Al-Quaida", "Moved about aimlessly", "Without end", 
					"Station manager in \"WKRP in Cincinnati\"", "The capital is Astana, its currency the Tenge", 
					"Mountain flower; song title from \"The Sound of Music\"", "City containing the In Flanders Fields Museum", "Twittering pet", 
					"Disorderly, wild; hilariously funny", "This city contains Omonia Square, Kolonaki Square, and Syntagma Square", 
					"Outermost planet, now that Pluto has been demoted", "Location of Queen Victoria's Osborne House (3 wds.)", "Wise, solemn", 
					"Actress Dunst", "London borough containing the main residence of the Archbishop of Canterbury", "Final stage", 
					"\"The Great ___\" (Samuel Foote, 1755)", "Gratitude, appreciation", "Story, anecdote; continuous length of interlocked fibers");
					
					
var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

						
var aClueLines = new Array (1, 1, 1, 3, 2,   1, 1, 1, 2, 2,   2, 1, 1, 2, 2,   2, 1, 1, 3, 1,  1, 1, 2   ); // 23 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 (110, 125, 159, 120, 92, 19, 97, 155, 8, 154, 123, 167, 30, 147, 79, 133, 103, 10, 122, 21, 89, 63, 137, 144, 25, 
							157, 114, 135, 104, 51, 129, 22, 138, 85, 77, 35, 62, 88, 142, 115, 164, 3, 75, 53, 119, 98, 6, 151, 112, 91, 143, 
							2, 145, 84, 11, 78, 105, 163, 71, 28, 33, 14, 93, 131, 153, 109, 69, 44, 101, 59, 24, 5, 134, 32, 40, 54, 162, 130, 
							81, 140, 94, 52, 43, 56, 50, 13, 148, 166, 36, 95, 57, 38, 7, 16, 126, 34, 141, 169, 4, 67, 37, 82, 55, 106, 72, 64, 
							132, 139, 171, 70, 26, 31, 156, 116, 9, 150, 46, 80, 121, 0, 48, 118, 161, 100, 68, 1, 158, 111, 74, 17, 61, 124, 117, 
							49, 12, 170, 90, 96, 152, 20, 65, 172, 58, 165, 108, 39, 87, 83, 168, 45, 15, 41, 76, 99, 149, 29, 127, 102, 73, 128, 
							42, 86, 107, 146, 160, 60, 18, 47, 27, 23, 113, 66, 136);
								
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 + 420;	// 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 = 'Colin Dickey: <a href="http://www.amazon.com/gp/product/1932961860?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=1932961860" target="_blank">Cranioklepty</a> (Grave Robbing and the Search for Genius). '
					+'"The theft of Franz Joseph Haydn\'s skull (in 1809) was by no means an isolated incident. (From the 1790s to the mid-nineteenth century,) interest in phrenology sparked a bizarre and intense fascination with the human skull, and in particular with the skulls of great men."';
					
						
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 = 170; // May need to be changed depending on puzzle.

var sPuzzleCode = "73cran";

