//                             This file is copyright 2009 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 = "Until just a few generations ago shadows were always moving Candles and hearths project shaky agitated shadows "
					+ "on the walls of a room Outdoors all you have to do is trace an outline and then come back to it a few minutes "
					+ "later to see the movement of apparently static shadows cast by bodies in sunlight          "; // 10 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 = "UNTILJUSTAFEWGENERATIONSAGOSHADOWSWEREALWAYSMOVINGCANDLESANDHEARTHSPROJECTSHAKYAGITATEDSHADOWSONTHEWALLSOFAROOMOUTDOORS"
					+ "ALLYOUHAVETODOISTRACEANOUTLINEANDTHENCOMEBACKTOITAFEWMINUTESLATERTOSEETHEMOVEMENTOFAPPARENTLYSTATICSHADOWSCASTBYBODIESINSUNLIGHT";

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 ("Rottweiler", "OnFootback", "Ballasted", "Ejectamenta", "Rumfustian", "Tautonym", "Otheoscope", "Cascades", 
					"Antitussives", "Swarthmore", "Alternator", "TimonOfAthens", "Incavated", "TidalWaves", "Hoosegow", "EightfoldWay", 
					"Splashed", "HighWines", "Admittee", "Dodsworth", "OneHossShay", "Wapakoneta", "Catslide", "LongJenny", "Uruguay", "Balloons");

var sWurdzString = "ROTTWEILERONFOOTBACKBALLASTEDEJECTAMENTARUMFUSTIANTAUTONYMOTHEOSCOPECASCADESANTITUSSIVESSWARTHMOREALTERNATORTIMONOFATHENS"
				+ "INCAVATEDTIDALWAVESHOOSEGOWEIGHTFOLDWAYSPLASHEDHIGHWINESADMITTEEDODSWORTHONEHOSSSHAYWAPAKONETACATSLIDELONGJENNYURUGUAYBALLOONS";

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("Dog breed named for city in southwestern Germany", "Using shank\'s mare (2 wds.)", "Stabilized, weighted", 
					"Tephra, e.g.", "Hot drink with egg yolk, beer, gin and sherry", "\"Gorilla gorilla,\" e.g.", "Radiometer variant", 
					"Waterfalls", "Cough remedies", "Pennsylvania town and college", "Type of generator", "Shakespeare play (3 wds.)", 
					"Hollowed out", "Tsunamis (2 wds.)", "Slammer", "Buddhism/quark intersection (2 wds.)", "Propelled about in flying drops", 
					"First distillation product in making liquor (2 wds.)", "One who has been granted entrance", "Sinclair Lewis novel", 
					"Oliver Wendell Holmes\' Deacon\'s Masterpiece (hyph., 2 wds.)", "Ohio town where Neil Armstrong graduated from high school", 
					"Steep roof ending close to the ground", "Type of losing hazard in snooker (2 wds.)", "Seceded from Brazil in 1828", 
					"Swells, puffs up");
					
					
var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

						
var aClueLines = new Array (2, 1, 1, 1, 1,   1, 1, 1, 1, 1,   1, 1, 1, 1, 1,   1, 1, 2, 1, 1,  2, 2, 1, 1, 1,  1   ); // 26 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 (136, 123, 84, 73, 34, 11, 216, 54, 170, 183, 185, 52, 169, 222, 193, 64, 229, 106, 138, 163, 160, 62, 210, 
							39, 149, 239, 135, 55, 221, 148, 70, 37, 217, 213, 161, 44, 14, 155, 184, 137, 117, 175, 110, 201, 143, 212, 
							246, 166, 100, 58, 113, 76, 124, 189, 232, 48, 42, 172, 91, 199, 125, 188, 142, 134, 225, 111, 67, 98, 72, 
							205, 186, 50, 126, 90, 195, 66, 180, 174, 228, 146, 152, 240, 56, 87, 3, 127, 187, 43, 33, 40, 9, 107, 129, 
							97, 158, 116, 63, 191, 119, 242, 2, 139, 36, 150, 220, 82, 115, 68, 181, 20, 196, 45, 15, 108, 10, 24, 167, 
							65, 154, 208, 103, 234, 241, 156, 41, 46, 57, 19, 207, 53, 96, 237, 114, 79, 101, 92, 226, 194, 71, 178, 219, 
							21, 132, 93, 35, 25, 200, 12, 16, 133, 244, 88, 164, 105, 109, 145, 59, 99, 140, 211, 27, 203, 4, 38, 218, 75, 
							177, 233, 28, 243, 80, 190, 32, 173, 238, 128, 23, 214, 30, 192, 47, 144, 176, 61, 197, 151, 130, 86, 118, 223, 
							94, 17, 215, 245, 165, 95, 85, 60, 157, 224, 74, 7, 153, 29, 78, 171, 83, 204, 89, 77, 31, 147, 235, 8, 51, 162, 
							168, 209, 236, 121, 81, 131, 182, 120, 104, 198, 13, 5, 159, 141, 1, 230, 6, 206, 0, 49, 112, 202, 122, 231, 18, 
							102, 179, 69, 26, 22, 227);
								
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 = 30; 
var iCluesTopCoord = 270;

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

var iPuzzleLeftCoord = iCluesLeftCoord + 490;	// Distance of puzzle grid from left side. 
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 = 'Roberto Casati: <a href="http://www.amazon.com/gp/product/0375407278?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0375407278" target="_blank">The Shadow Club</a> (The Greatest Mystery in the Universe--Shadows--and the Thinkers Who Unlocked Their Secrets). '
					+'"Until just a few generations ago, shadows were always moving... Candles and hearths project shaky, agitated shadows on the walls of a room. Outdoors, all you have to do is trace an outline and then come back to it a few minutes later to see the movement of apparently static shadows cast by bodies in sunlight."';
					
						
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 = "47shad";
