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


// The quote, without punctuation but with spaces and capitalization. Used to display the blank grid and the grid with solution.
var sAcrostiString = "I tried to make sense out of what I had seen but I could not My head sizzled and buzzed as if my brain had been overloaded "
						+ "with electricity Was everything Hitler had told us a lie It came quite suddenly this feeling of clarity as if someone "
						+ "had ripped a dark veil that had been clouding my vision from my head   "; // 3 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. It is used to determine whether the puzzle has been solved.
var sSolutionString = "ITRIEDTOMAKESENSEOUTOFWHATIHADSEENBUTICOULDNOTMYHEADSIZZLEDANDBUZZEDASIFMYBRAINHADBEENOVERLOADEDWITHELECTRICITYWASEVERYTHING"
						+ "HITLERHADTOLDUSALIEITCAMEQUITESUDDENLYTHISFEELINGOFCLARITYASIFSOMEONEHADRIPPEDADARKVEILTHATHADBEENCLOUDINGMYVISIONFROMMYHEAD";

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

var aWurdz = ["Fuzzyheaded", "Imbibed", "Necessity", "Eszterhazy", "LaunchWindow", "LiquidHelium", "GalvestonBay", "OldFaithful", 
						"Outfitted", "Dodder", "Biographer", "YeahYeah", "Eyeshadow", "Testimonial", "Oddity", "Trivet", "Hitchhikers", 
						"Elevation", "MagnetSchool", "Eradicated", "RankAndFile", "Mousterian", "Analects", "Indemnified", "Disprovable", "Summed"];
					//F
var sWurdzString = "FUZZYHEADEDIMBIBEDNECESSITYESZTERHAZYLAUNCHWINDOWLIQUIDHELIUMGALVESTONBAYOLDFAITHFULOUTFITTEDDODDERBIOGRAPHERYEAHYEAHEYESHADOWTESTIMONIAL"
					+ "ODDITYTRIVETHITCHHIKERSELEVATIONMAGNETSCHOOLERADICATEDRANKANDFILEMOUSTERIANANALECTSINDEMNIFIEDDISPROVABLESUMMED"

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.

						//"Confused, illogical" ,
var aClues = new Array("Confused, illogical" ,"Drank", "Requirement" ,"Hungarian aristocratic name (alt. sp.)", "Time span when the rocket should be sent up (2 wds.)", 
						"Extremely cold substance (2 wds.)", "Body of water near Houston, Texas (2 wds.)", "Famous geyser (2 wds.)", "Furnished with appropriate equipment", 
						"Devil's guts, witch's hair", "Writer of someone else's life story", 'New York City-based rock band, "______ Yeahs" (2 wds.)' , 'Type of colored cosmetic', 
						"What the Wizard said the Tin Man lacked", "Something strange" , "Stand with short feet for use under a hot dish", '"The __ Guide to the Galaxy" (Douglas Adams)', 
						"Altitude, height", "Educational facility designed to attract pupils from throughout a city or school district (2 wds.)", "Wiped out" ,
						'Ordinary members of an organization (3 wds.)', "A middle Paleolithic culture" ,"The ___ of Confucius ", 
						'Protected against future loss' , "Capable of being shown to be wrong", "Added up");

var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

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

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

var iPuzzleLeftCoord = iCluesLeftCoord + 410;	// 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;

//<a href="http://www.amazon.com/gp/product/0826216900?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0826216900" target="_blank">Good-bye to the Mermaids</a>(A Childhood Lost in Hitler\'s) Berlin.<img src="http://www.assoc-amazon.com/e/ir?t=puzzlebook-20&l=as2&o=1&a=0826216900" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />

var sAuthorQuote = 'SOLVED PUZZLE (Karin) Finell: <a href="http://www.amazon.com/gp/product/0826216900?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0826216900" target="_blank">Good-bye to the Mermaids</a> (A Childhood Lost in Hitler\'s) Berlin.'
					+ '<img src="http://www.assoc-amazon.com/e/ir?t=puzzlebook-20&l=as2&o=1&a=0826216900" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> '
					+ '"I tried to make sense out of what I had seen, but I could not. '
					+ 'My head sizzled and buzzed as if my brain had been overloaded with electricity. Was everything Hitler had told us a lie? It came quite suddenly, '
					+ 'this feeling of clarity, as if someone had ripped a dark veil that had been clouding my vision from my head."';
						
var iInstructionsTop = (iBoxHeight * iBoxDown) + iPuzzleTopCoord + 30; // Thirty pixels below the bottom of the puzzle.
var iInstructionsLeft = iPuzzleLeftCoord;
var iInstructionsWidth = iBoxAcross * iBoxWidth; // Width of grid, approx.
var iInstructionsHeight = 50; // May need to be changed depending on puzzle.

var sPuzzleCode = "1goodb";
