//                             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 = "Vampires inspire dread longing awe and admiration as much as they ever have  symbolizing the darker side of human "
					+ "feelings like nothing else can They are the most varied and the most humanlike of imaginary menaces and as a result "
					+ "the most vulnerable and seductive "; // 1 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 = "VAMPIRESINSPIREDREADLONGINGAWEANDADMIRATIONASMUCHASTHEYEVERHAVESYMBOLIZINGTHEDARKERSIDEOFHUMANFEELINGSLIKENOTHINGELSE"
					+ "CANTHEYARETHEMOSTVARIEDANDTHEMOSTHUMANLIKEOFIMAGINARYMENACESANDASARESULTTHEMOSTVULNERABLEANDSEDUCTIVE";

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 ("Smashed", "Tenzing", "Effusive", "Vaughan", "Estranged", "NewHaven", "Shakiest", "Omaha", "Nobility", "Immerse", 
					"Dolittle", "IvyLeague", "Oldman", "Toiled", "Smithers", "Gymkhana", "Uranus", "Itinerant", "Demeanor", "Embark", 
					"Thirsts", "Overleaf", "Vanished", "Antoine", "Marched", "Pirogue", "Iceland", "Rhymed", "Escape", "Scandal");

var sWurdzString = "SMASHEDTENZINGEFFUSIVEVAUGHANESTRANGEDNEWHAVENSHAKIESTOMAHANOBILITYIMMERSEDOLITTLEIVYLEAGUEOLDMANTOILEDSMITHERS"
					+ "GYMKHANAURANUSITINERANTDEMEANOREMBARKTHIRSTSOVERLEAFVANISHEDANTOINEMARCHEDPIROGUEICELANDRHYMEDESCAPESCANDAL";

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("Broke into bits; drunk", "Norgay, who accompanied Hillary up Mount Everest", "Extravagantly demonstrative", 
				"Sarah \"The Divine One\" (1924-1990)", "Alienated", "Roger Sherman was elected its first mayor in 1784 (2 wds.)", 
				"Most unsteady or dubious", "Nebraska's largest city", "Aristocrats", "Dip, soak, or plunge in liquid", 
				"Hugh Lofting's fictional doctor", "Harvard, Yale, Princeton, etc. (2 wds.)", "Gary who played the Count in \"Dracula\" (1992)", 
				"Worked hard", "Montgomery Burns's devoted executive assistant", "Equestrian event featuring competitive games", 
				"Seventh planet", "Like nomads or circuit judges", "Behavior, appearance", "Board ship", "Desires, longings; needs water", 
				"On the reverse side of the page (of paper)", "Disappeared completely", "First name of \"The Little Prince\" author de Saint Exupery", 
				"Walked, in a military way", "Long, narrow canoe; dugout", "The word \"geyser\" comes from this country", "Composed verse", 
				"Break out, flee", "Event causing public outrage");
					
					
var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

						
var aClueLines = new Array (1, 2, 1, 1, 1,   2, 1, 1, 1, 1,   1, 1, 2, 1, 2,   2, 1, 1, 1, 1,  1, 2, 1, 2, 1,  1, 2, 1, 1, 1   ); // 30 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 (209, 162, 92, 148, 128, 81, 179, 143, 55, 93, 70, 98, 119, 26, 191, 88, 94, 212, 115, 36, 0, 171, 134, 177, 46, 
							112, 150, 18, 25, 17, 181, 149, 201, 60, 22, 164, 53, 32, 199, 116, 28, 48, 182, 56, 86, 172, 132, 121, 30, 104, 
							84, 57, 176, 74, 147, 2, 124, 89, 167, 111, 131, 203, 103, 97, 24, 189, 169, 161, 146, 35, 62, 136, 101, 6, 15, 193, 
							204, 137, 188, 51, 20, 105, 12, 196, 54, 114, 138, 153, 23, 186, 200, 107, 187, 142, 45, 78, 9, 214, 67, 4, 102, 29, 
							85, 44, 192, 40, 108, 59, 217, 183, 10, 73, 123, 130, 80, 52, 173, 178, 206, 197, 13, 180, 42, 90, 50, 110, 120, 71, 
							154, 76, 5, 38, 141, 127, 34, 205, 170, 145, 1, 72, 159, 82, 210, 152, 66, 49, 37, 157, 39, 144, 69, 125, 83, 133, 7, 
							87, 61, 122, 79, 155, 96, 43, 160, 216, 27, 166, 8, 185, 109, 95, 208, 163, 31, 195, 41, 215, 99, 158, 65, 135, 168, 
							213, 190, 14, 77, 11, 156, 16, 21, 100, 151, 113, 165, 117, 184, 68, 140, 207, 211, 58, 75, 64, 91, 126, 139, 175, 194, 
							47, 33, 3, 129, 63, 174, 118, 106, 19, 202, 198);
								
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 + 470;	// 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 = '(Jay) Stevenson: <a href="http://www.amazon.com/gp/product/1592579434?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=1592579434" target="_blank">(The Complete) Idiot\'s Guide to Vampires</a>. '
					+'"Vampires inspire dread, longing, awe, and admiration as much as they ever have, (perhaps more so,) symbolizing the darker side of human feelings like nothing else can. They are the most varied and the most humanlike of imaginary menaces and, as a result, the most vulnerable and seductive."';
					
						
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 = "74vamp";

