//                             This file is copyright 2009 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 = "In the nineteenth century the Kansas clergyman and author William Quayle who once wrote In a purely "
					+ "metaphorical sense I am a turnip traded his autograph for an acre of prairie and yesterday I thought "
					+ "him a thief but now seeing the paltriness of an acre I figure he was the one swindled  "; // 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 = "INTHENINETEENTHCENTURYTHEKANSASCLERGYMANANDAUTHORWILLIAMQUAYLEWHOONCEWROTEINAPURELYMETAPHORICALSENSE"
					+ "IAMATURNIPTRADEDHISAUTOGRAPHFORANACREOFPRAIRIEANDYESTERDAYITHOUGHTHIMATHIEFBUTNOWSEEINGTHEPALTRINESS"
					+ "OFANACREIFIGUREHEWASTHEONESWINDLED";

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

var aWurdz = new Array ("LeafStrewn", "Euterpe", "Athodyd", "Sheena", "TenCrimesOfQin", "Hainan", "Euphony", "Amicable", 
						"Tiresias", "MischiefReef", "Oduduwa", "Ostentatious", "NawangKhechog", "Parturition", 
						"RatherFightThanSwitch", "Anglophone", "Ichnography", "RailwayLines", "YunnanRedTea", "Eumenides", 
						"Ratatouille", "TreadWater", "Hypermiler");

var sWurdzString = "LEAFSTREWNEUTERPEATHODYDSHEENATENCRIMESOFQINHAINANEUPHONYAMICABLETIRESIASMISCHIEFREEFODUDUWAOSTENTATIOUS"
					+ "NAWANGKHECHOGPARTURITIONRATHERFIGHTTHANSWITCHANGLOPHONEICHNOGRAPHYRAILWAYLINESYUNNANREDTEAEUMENIDES"
					+ "RATATOUILLETREADWATERHYPERMILER";

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("\"...from over Bracknell  And Owlsmoor's ____ dells\" (Godfrey Elton, Six Poems Written in Foreign Countries, hyph.)", 
					"Muse of music, especially of the flute", "Ramjet", "____ is a punk rocker (Ramone's song)", 
					"Confucian list of the tyrannical actions of the emperor whose mausoleum housed the terra cotta army (4 wds.)", 
					"China's largest island (excluding Taiwan)", "Book on Indian classical music by L. Subramaniam; pleasing sounds", 
					"Said of a pair of numbers for which the divisors of each number add up to the sum of the pair", "Blind seer of Greek mythology", 
					"Spratly Islands feature, scene of a 1995 dispute between China and the Philippines (2 wds.)", "Traditional founder of the Yoruba", 
					"Conspicuous on purpose", "Tibetan-born flute player (2 wds.)", "Childbirth including labor and delivery", 
					"Words appropriated by Goldwater Girls from a cigarette ad slogan (4 wds.)", "English speaking (of a person or region)", 
					"Ground plan of a building drawn to scale", "Train routes (2 wds.)", "Dian Hong Cha (滇紅茶) (3 wds.)", 
					"Circumspect name for the Furies; drama by Aeschylus in his Orestean trilogy (with The)", 
					"Pixar movie; a dish with eggplant, zucchini and other vegetables", "Mark time (2 wds.)", "Driver who maximizes fuel economy");

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

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

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

var iPuzzleLeftCoord = iCluesLeftCoord + 620;	// 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 = '(William) Least Heat-Moon:  <a href="http://www.amazon.com/gp/product/039592569X?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=039592569X" target="_blank">PrairyErth (A Deep Map)</a> (An Epic History of the Tallgrass Prairie Country). '
					+'"In the nineteenth century, the Kansas clergyman and author William Quayle (who once wrote, <em>In a purely metaphorical sense I am a turnip</em>) traded his autograph for an acre of prairie, and, yesterday, I thought him a thief, but now, seeing the paltriness of an acre, I figure he was the one swindled."';
					
						
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 = "11gsig";
