//                             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 = "In comparison to today nature was vastly more abundant a perception that is key to understanding our modern "
					+ "relationship with the natural world From fisheries management to the history of modern societies the past abundance "
					+ "of nature turns out to be a crucial factor          "; // 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 = "INCOMPARISONTOTODAYNATUREWASVASTLYMOREABUNDANTAPERCEPTIONTHATISKEYTOUNDERSTANDINGOURMODERNRELATIONSHIPWITHTHENATURAL"
					+ "WORLDFROMFISHERIESMANAGEMENTTOTHEHISTORYOFMODERNSOCIETIESTHEPASTABUNDANCEOFNATURETURNSOUTTOBEACRUCIALFACTOR";

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 ("Steinway", "TasmanSea", "Endpoint", "Vintner", "Encumber", "NorthDakota", "Interacts", "Counseled", "Headache", 
					"OnYourOwn", "Laundromat", "Loftiest", "Siberian", "Prentiss", "Aeroflot", "RubyThroated", "Algeria", "Dartmouth", 
					"Intimates", "Stomach", "Egyptian", "FortWorth", "Octothorp", "Usufruct", "Nefarious", "Dopamine");

var sWurdzString = "STEINWAYTASMANSEAENDPOINTVINTNERENCUMBERNORTHDAKOTAINTERACTSCOUNSELEDHEADACHEONYOUROWNLAUNDROMATLOFTIESTSIBERIAN"
					+ "PRENTISSAEROFLOTRUBYTHROATEDALGERIADARTMOUTHINTIMATESSTOMACHEGYPTIANFORTWORTHOCTOTHORPUSUFRUCTNEFARIOUSDOPAMINE";

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("Famous piano-maker", "Body of water between Australia and New Zealand (2 wds.)", "Terminus", "Winemaker", 
					"Weigh down, burden, restrict", "State containing the geographical center of North America (2 wds.)", 
					"Communicates, reciprocates", "Gave advice to", "Kopfschmerzen, mal de tête, dolor de cabeza", 
					"\"How does it feel/ To be ____\" (Bob Dylan; 3 wds.)", "Berwyn, Ill. apparently has the world's largest of these", 
					"Most high or noble", "____ Husky", "Actress Paula (Where the Boys Are, Catch-22)", "Russian airline", 
					"Adjective for type of bulbul, diamond piranha, or hummingbird (hyph.)", 
					"Once occupied by Berbers, Romans, Fatimids, Spanish, Ottoman, and French", "College in Hanover, NH", 
					"Hints, makes known; confidants, close friends", "Organ an army marches on, according to Napoleon", 
					"Walk like one of these, exhort The Bangles", "Cowtown, Panther City (2 wds.)", "Another name for the pound sign (#)", 
					"Legal right to use and derive benefit from property that belongs to another", "Heinous, despicable", 
					"Neurotransmitter and neurohormone");
					
					
var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

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

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

var iPuzzleLeftCoord = iCluesLeftCoord + 500;	// 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 = 'Steve Nicholls: <a href="http://www.amazon.com/gp/product/0226583406?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0226583406" target="_blank">Paradise Found</a> (Nature in America at the Time of Discovery). '
					+'"In comparison to today, nature was vastly, (almost unimaginably,) more abundant, a perception that is key to understanding our modern relationship with the natural world. From fisheries management to the history of modern societies, the past abundance of nature turns out to be a crucial factor."';
					
						
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 = "68para";

