//                             This file is copyright 2008 by Michael H. Dickman. All rights reserved.
// Puzzle-specific globals

// The quote, without punctuation but with spaces and capitalization. Used to display the blank grid and the grid with solution.
var sAcrostiString = "Human freedom is real as real as language music and money so it can be studied objectively from a no-nonsense scientific point of view But like language"
						+ " music money and other products of society its persistence is affected by what we believe about it  "; // 2 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 = "HUMANFREEDOMISREALASREALASLANGUAGEMUSICANDMONEYSOITCANBESTUDIEDOBJECTIVELYFROMANONONSENSESCIENTIFICPOINTOFVIEWBUTLIKELANGUAGEMUSICMONEYANDOTHERPRODUCTS"
						+ "OFSOCIETYITSPERSISTENCEISAFFECTEDBYWHATWEBELIEVEABOUTIT";

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

var aWurdz = new Array ( "Deuteron",   "Absolution",   "Nimbus",  "Impacts",   "Enjoin",   "Leadoff",  "Diction" ,  "Ebbtide" ,  "Nemeses" ,  "Nostalgic",   "Esculent",
						"Tractable", "TheWayOf",   "Formicary",   "Ripsaw",   "Easygoing",   "Educator",  "Destiny",   "Ophiuchus",  "Maurine",   "Effected",   "VanWyck",
						"Ominous",   "Leafnose",  "Vestige",   "Evitable" , "Siamese");
var sWurdzString =	"DEUTERONABSOLUTIONNIMBUSIMPACTSENJOINLEADOFFDICTIONEBBTIDENEMESESNOSTALGICESCULENTTRACTABLETHEWAYOFFORMICARYRIPSAWEASYGOINGEDUCATORDESTINYOPHIUCHUSMAURINE"
					+ "EFFECTEDVANWYCKOMINOUSLEAFNOSEVESTIGEEVITABLESIAMESE";
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("Combination of one proton and one neutron" ,"Remission of sins", "Cloud or halo" ,"Strikes",
						"Prohibit by judicial order", "First batter (hyph.)", "Pronunciation and enunciation", "Low water (2 wds.)", 
						"Betes noirs" ,"Wistful for the past", "Suitable for food", "Easily handled or managed" ,
						"___ the World, Congreve play (3 wds.)", "Ant nest", "Tool for cutting with the grain of the wood", "Tolerant, relaxed", 
						"Teacher" ,"Fate" ,"Serpent Holder", "___ Dallas Watkins (wrote the play 'Chicago')" ,"Caused", "Pulitzer Prize winner Brooks (1886-1963; 2 wds.)" ,
						"Foreshadowing evil or disaster", "Type of bat", "Remnant", "Capable of being avoided", "Blue-eyed cat");

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

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/0142003840?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0142003840" target="_blank">Freedom Evolves</a>.<img src="http://www.assoc-amazon.com/e/ir?t=puzzlebook-20&l=as2&o=1&a=0142003840" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />


var sAuthorQuote = 'Daniel (C.) Dennett: <a href="http://www.amazon.com/gp/product/0142003840?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0142003840" target="_blank">Freedom Evolves</a>.'
					+'<img src="http://www.assoc-amazon.com/e/ir?t=puzzlebook-20&l=as2&o=1&a=0142003840" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />'
 					+ '"Human freedom is real -- as real as language, music, and money -- so it can be studied objectively from a no-nonsense, '
					+ 'scientific point of view. But like language, music, money, and other products of society, its persistence is affected by what we believe about it."';
						
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 = "1freed";