//                             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 = "Although the eighteenth century was dominated by discussions of the question its fair to say that Rousseau was the " + 
					"first to treat the problem of evil as a philosophical problem as well as to offer the first thing approaching a solution to it           "; // 11 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 = "ALTHOUGHTHEEIGHTEENTHCENTURYWASDOMINATEDBYDISCUSSIONSOFTHEQUESTIONITSFAIRTOSAYTHATROUSSEAUWASTHEFIRSTTOTREATTHEPROBLEM" + 
						"OFEVILASAPHILOSOPHICALPROBLEMASWELLASTOOFFERTHEFIRSTTHINGAPPROACHINGASOLUTIONTOIT";

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 ("Nosotrophy", "Eschatology", "Itself", "MessWith", "Anteaters", "Nitrate", "Establish", "Verbicide", "Iphitus", 
						"LargeWhite", "Innsmouth", "Northeast", "Methods", "Outquaffs", "Doone", "Elliot", "Rutabaga", "NotHalfOf", "Traipse", 
						"HulaHoop", "Ossify", "Uplifts", "Graphite", "HotWires", "Toccata");

var sWurdzString = "NOSOTROPHYESCHATOLOGYITSELFMESSWITHANTEATERSNITRATEESTABLISHVERBICIDEIPHITUSLARGEWHITEINNSMOUTHNORTHEASTMETHODSOUTQUAFFS" + 
					"DOONEELLIOTRUTABAGANOTHALFOFTRAIPSEHULAHOOPOSSIFYUPLIFTSGRAPHITEHOTWIRESTOCCATA";

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("Nursing care and feeding of the sick (rare)", "System of doctrines concerned with last or final things", 
					"\"It is shaped, sir, like ___\" (Anthony and Cleopatra, act 2)", "\"Don't ___ Texas\" (2 wds.)", 
					"Sports team name for University of California at Irvine", "Type of movie film or fertilizer", 
					"Show to be true by determining the facts", "Willful distortion of the meaning of a word", 
					"A man (eventually) killed by <a href=\"http://en.wikipedia.org/wiki/Heracles\">Heracles</a>", 
					"Type of pig or butterfly (2 wds.)", 
					"<a href=\"http://en.wikipedia.org/wiki/H._P._Lovecraft\">H. P. Lovecraft's</a> fictional Massachusetts fishing port", "Compass direction", 
					"Systematic procedures", "Drinks more than", "Blackmoor's Lorna", "2000 dance movie \"Billy ___\"", 
					"<a href=\http://en.wikipedia.org/wiki/Cabbage_family\">Cabbage relative</a> with large edible round, yellow-fleshed root ", 
					"\"___ that city’s bright glory/ To mortals has ever been told.\" (hymn; 3 wds.)", "Walk wearily, or casually", 
					"<a href=\http://en.wikipedia.org/wiki/Category:1950s_fads_and_trends\">1950s fad</a> (2 wds.)", 
					"Convert into bone", "Elevates", "Carbon allotrope", "Short-circuits the ignition (hyph.)", 
					"Keyboard composition intended to exhibit the player's technique");
					
					
var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

						
var aClueLines = new Array (2, 2, 2, 1, 2,   1, 1, 2, 1, 1,   2, 1, 1, 1, 1,   1, 2, 2, 1, 1,  1, 1, 1, 1, 2 ); // 25 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 (194, 32, 75, 4, 170, 161, 102, 127, 182, 27, 17, 52, 181, 163, 29, 103, 188, 115, 156, 6, 77, 129, 195, 86, 110, 123, 
							159, 33, 105, 68, 92, 28, 12, 19, 109, 70, 35, 100, 150, 175, 155, 116, 112, 48, 23, 97, 62, 167, 186, 73, 11, 87, 168, 
							78, 106, 143, 151, 63, 132, 128, 121, 16, 104, 114, 43, 137, 66, 31, 145, 166, 134, 94, 49, 55, 59, 148, 152, 124, 26, 
							185, 120, 90, 171, 197, 81, 164, 34, 173, 51, 44, 146, 64, 190, 93, 14, 18, 179, 72, 8, 56, 22, 76, 85, 37, 117, 38, 
							169, 135, 157, 42, 30, 133, 5, 162, 58, 89, 153, 54, 158, 47, 39, 118, 142, 65, 10, 95, 144, 130, 122, 50, 198, 98, 25, 
							107, 88, 40, 36, 13, 80, 184, 113, 24, 20, 147, 1, 96, 53, 119, 191, 82, 91, 71, 111, 99, 160, 79, 46, 189, 138, 3, 196, 
							131, 177, 74, 125, 187, 192, 165, 41, 84, 176, 139, 172, 69, 2, 61, 174, 178, 0, 140, 7, 183, 15, 60, 9, 83, 101, 149, 
							136, 141, 57, 154, 108, 193, 21, 45, 180, 67, 126);
								
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 + 500;	// 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 = '<a href="http://en.wikipedia.org/wiki/Susan_Neiman" target="_blank">(Susan) Neiman</a>: <a href="http://www.amazon.com/gp/product/0691117926?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0691117926" target="_blank">Evil in Modern Thought</a> (An Alternative History of Philosophy). '
					+'"Although the eighteenth century was dominated by discussions of the question, it\'s fair to say that Rousseau was the first to treat the problem of evil as a philosophical problem -- as well as to offer the first thing approaching a solution to it."';
					
						
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 = 200; // May need to be changed depending on puzzle.

var sPuzzleCode = "88devi";

