//                             This file is copyright 2008 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 = "Indonesian has the word pembonceng to describe someone who likes to use other peoples facilities "
						+ "but the Pascuense language of Easter Island has gone one step further in showing how the truly "
						+ "unscrupulous exploit friends and family Tingo is to borrow things from a friends house one by one until theres nothing left         "; // 9 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 = "INDONESIANHASTHEWORDPEMBONCENGTODESCRIBESOMEONEWHOLIKESTOUSEOTHERPEOPLESFACILITIESBUTTHEPASCUENSE"
						+ "LANGUAGEOFEASTERISLANDHASGONEONESTEPFURTHERINSHOWINGHOWTHETRULYUNSCRUPULOUSEXPLOITFRIENDSANDFAMILY"
						+ "TINGOISTOBORROWTHINGSFROMAFRIENDSHOUSEONEBYONEUNTILTHERESNOTHINGLEFT";

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

var aWurdz = new Array ("Daffiness",  "Exponential", "Bilbao",  "OnTheHouse",  "Indoportuguese", "Neurologists",  "OneHorseTown", "Disguise",  "Thoughtfulness",  "HighRoller",
						"Entrepreneurs",  "MineOfWealth",  "Eucalyptus", "Acreage",  "Nanoseconds",   "IrishWhiskey",  "NumberTheory",  "GinAndTonic",  "Oenophobes",  "Footprint",
						"Twobase",  "Intertwines",  "Numismatics", "Goldplated", "OffTheShelf");

var sWurdzString = "DAFFINESSEXPONENTIALBILBAOONTHEHOUSEINDOPORTUGUESENEUROLOGISTSONEHORSETOWNDISGUISETHOUGHTFULNESSHIGHROLLER"
					+ "ENTREPRENEURSMINEOFWEALTHEUCALYPTUSACREAGENANOSECONDSIRISHWHISKEYNUMBERTHEORYGINANDTONICOENOPHOBESFOOTPRINT"
					+ "TWOBASEINTERTWINESNUMISMATICSGOLDPLATEDOFFTHESHELF";

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("Silliness, foolishness, craziness" ,"Expressed as a power", "Home of Gehry's Guggenheim" ,"Bartender's treat (3 wds.)",
						"Architectural style in Goa (hyph.)", "Oliver Sacks and colleagues", "Whistle stop (hyph., 3 wds.)", "Camouflage", "Consideration",
						"A whale, in Vegas (2 wds.)", "Business starters" ,"\"Industry is the natural ___\" (Adam Smith, \"Wealth of Nations\"; 3 wds.)", "Koala food", 
						"Area of land", "Short time periods", "Fuisce or Uisce beatha (2 wds.)", "\"The higher arithmetic\" (2 wds.)", 
						"Bertie Wooster's usual libation (3 wds.)", "Wine avoiders", "Area occupied by a structure or device" ,
						"Type of hit in baseball (hyph.)" ,"Twists together", "Coin collecting", "Gilt (hyph.)", "Not custom-made (3 wds.)");

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

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

var iPuzzleLeftCoord = iCluesLeftCoord + 430;	// 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 = '(Adam Jacot) de Boinod: <a href="http://www.amazon.com/gp/product/B000GUJHBC?ie=UTF8&tag=puzzlebook-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B000GUJHBC" target="_blank">The Meaning of Tingo</a><img src="http://www.assoc-amazon.com/e/ir?t=puzzlebook-20&l=as2&o=1&a=B000GUJHBC" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> (And Other Extraordinary Words from Around the World). '
					+'"Indonesian has the word \'pembonceng\' to describe someone who likes to use other people\'s facilities, but the Pascuense language of Easter Island has gone one step further in showing how the truly unscrupulous exploit friends and family. \'Tingo\' is to borrow things from a friend\'s house, one by one, until there\'s nothing left..."';
					
						
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 = "7extra";

