//                             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 = "Travel Therapy helps you pick the right vacation depending on what youre going through in life If youre looking for an " + 
					"adventure a romantic escape a way to reconnect with your kids a girlfriend getaway a volunteer vacation or just a " + 
					"blissed-out spa trip Travel Therapy has you covered    "; // 4 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 = "TRAVELTHERAPYHELPSYOUPICKTHERIGHTVACATIONDEPENDINGONWHATYOUREGOINGTHROUGHINLIFEIFYOURELOOKINGFORANADVENTUREAROMANTIC" + 
						"ESCAPEAWAYTORECONNECTWITHYOURKIDSAGIRLFRIENDGETAWAYAVOLUNTEERVACATIONORJUSTABLISSEDOUTSPATRIPTRAVELTHERAPYHASYOUCOVERED";

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 ("Kittiwake", "Aggravation", "RioDeJaneiro", "Ethnography", "NorthDakota", "Section", "Clemens", "HeavyDuty", "Affidavit", 
					"Leprechaun", "EyeCatching", "Reclusive", "TopsyTurvy", "RightAway", "Apollinaire", "Vancouver", "Effulgent", "Loanwords", 
					"Turpitude", "Hawthorne", "Euripides", "Rosalie", "Acrobat", "Pogonotrophy", "Youngster");

var sWurdzString = "KITTIWAKEAGGRAVATIONRIODEJANEIROETHNOGRAPHYNORTHDAKOTASECTIONCLEMENSHEAVYDUTYAFFIDAVITLEPRECHAUNEYECATCHINGRECLUSIVETOPSYTURVY" + 
					"RIGHTAWAYAPOLLINAIREVANCOUVEREFFULGENTLOANWORDSTURPITUDEHAWTHORNEEURIPIDESROSALIEACROBATPOGONOTROPHYYOUNGSTER";

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("Small gull that nests in colonies on sea cliffs", "Frustration, annoyance; worsening of a condition or symptom", 
						"Location of Ipanema, Corcovado, and the 2016 Summer Olympics (3 wds.)", "Scientific description of cultures and customs", 
						"State containing the <a href=\"http://en.wikipedia.org/wiki/Enchanted_Highway\" target=\"_blank\">Enchanted Highway</a> (2 wds.)", 
						"Distinct part; one square mile", "Twain", "Designed to withstand demanding use (hyph.)", 
						"Factual statement that is written, sworn, signed and witnessed", "Magical being associated with a pot of gold", 
						"Visually attractive or noticeable (hyph.)", "Seeking solitude", "Film (1999) about Gilbert and Sullivan (hyph.)", 
						"Immediately, without further ado (2 wds.)", "French poet (1880-1918) credited with coining the word <i>Surrealism</i>", 
						"Location of the 2010 Winter Olympics", "Bright, as if glowing; shining brilliantly", "Aardvark, smorgasbord, chutney, billabong, sauna", 
						"Wickedness, depravity; often preceded by \"moral\"", "American author (1804-1864)", "Greek playwright (<i>Medea</i>, <i>Electra</i>)", 
						"Broadway (1928) and film (1937) musical involving both Gershwins and Cole Porter", "Trapeze artist, e.g.", "Fancy word for growing a beard", 
						"Child, whippersnapper, juvenile");
					
					
var iCluNum = aClues.length;	// Number of Clues (and therefore, Wurdz).

						
var aClueLines = new Array (2, 2, 2, 2, 2,   1, 1, 2, 2, 2,   1, 1, 2, 1, 2,   1, 1, 2, 2, 1,  1, 3, 1, 1, 1 ); // 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 (145, 156, 136, 215, 194, 52, 111, 89, 14, 223, 150, 65, 218, 167, 33, 107, 55, 73, 131, 97, 84, 76, 94, 159, 44, 187, 2, 133, 175, 
							29, 108, 127, 8, 139, 53, 64, 226, 30, 1, 180, 208, 72, 221, 40, 185, 28, 173, 222, 234, 54, 24, 169, 126, 165, 195, 85, 23, 205, 79, 
							199, 74, 179, 153, 157, 110, 174, 102, 202, 13, 213, 178, 100, 81, 198, 188, 37, 125, 163, 154, 77, 207, 147, 122, 230, 90, 181, 86, 
							197, 43, 59, 116, 35, 216, 96, 171, 184, 233, 12, 78, 118, 204, 32, 130, 67, 146, 112, 61, 9, 60, 115, 214, 200, 224, 22, 168, 121, 
							103, 82, 21, 148, 166, 0, 143, 128, 177, 56, 176, 38, 160, 26, 190, 149, 123, 98, 141, 191, 203, 229, 5, 75, 63, 48, 10, 114, 186, 129, 
							212, 119, 51, 228, 39, 104, 3, 134, 95, 42, 93, 80, 58, 170, 71, 101, 132, 209, 193, 50, 219, 172, 164, 19, 206, 46, 189, 66, 20, 152, 
							220, 47, 25, 227, 41, 161, 7, 36, 137, 201, 31, 62, 105, 45, 231, 106, 83, 155, 182, 120, 151, 99, 4, 17, 68, 88, 117, 34, 15, 138, 217, 
							124, 135, 144, 109, 192, 211, 162, 11, 183, 92, 87, 158, 57, 113, 210, 69, 16, 140, 225, 18, 142, 70, 91, 49, 196, 6, 27, 232);
								
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://www.amazon.com/Karen-Schaler/e/B001JRTMZM/ref=ntt_dp_epwbk_0" target="_blank">Karen Schaler</a>: <a href="http://www.amazon.com/gp/product/158005269X?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=158005269X" target="_blank">Travel Therapy</a> (Where Do You Need to Go?). ' +
					'"Travel Therapy helps you pick the right vacation depending on what you\'re going through in life. If you\'re looking for an adventure, a romantic escape, a way to reconnect with your kids, a girlfriend getaway, a volunteer vacation, or just a blissed-out spa trip, Travel Therapy has you covered."';
					
						
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 = 150; // May need to be changed depending on puzzle.

var sPuzzleCode = "89trav";

