/*
Javascript for "Escape from Simian Island" text adventure on www.GameEnglish.com
*/

var curScene = 1;
var msg = "";
var options = "";
var inventory = new Array();
var score = 0;

var justentered = true;


/*event global monitors - to get rid of these need an event handler function or object - next ver perhaps?*/

var enteredjunglebefore = false;  //jungle trails

var cutdownthornbush = false;    //beach
var lookedatthornbush = false;

var lightingfire = false;	//pebble beach
var fireburning = false;
var cookedpig = false;
var resolvedporkissue = false;

var lookedthroughwreckage = false;   //cliffs
var canleave = false;

var beentopilot = false;    //crashsite
var cutdownpilot = false;     
var lookedatskeleton = false;
var inpilottree = false;
var pushedparachute = false;
var lookedatcutdownpilot = false;

var beentofruittrees = false;  //fruit trees
var hitbananas = false;

var beentococonuttrees = false;  //coconut trees
var monkeyfallen = false;
var gotfallenrock = false;
var thrownrockatmonkey = false;
var monkeythrowncoconuts = false;
var gotcoconuts = false;

var beentowaterfall = false;    //waterfall
var pushedboulder = false;
var gotdeadpig = false;
var drunkwater = false;  //other locations (eg pebble beach) also access this


var beentovines = false;	//vines
var sowndiscord = false;
var climbedvinetree = false;
var cutdownvines = false;
var gotvines = false;

var beentoclearing = false;	//clearing









function setwordhelp(word)
	{
	
	var definition = "";

	switch (word)
		{
		case "aim":
			definition = "<em>Aim</em> is a verb that you use when you try to hit something. "
				+ "<p>For example:</p>"
				+ "<p>The "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'redbaron\')\">Red Baron</span>\'s "
				+ "aim was deadly as he shot at the French scout plane.</p>"
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'beckham\')\">David Beckham</span> "
				+ "aimed at the goal but missed because he was thinking about "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'poshspice\')\">Posh Spice</span> "
				+ "and a bowl of whipped cream.</p>";
			break;

		case "ak47":
			definition = "A type of gun.";
			break;

		case "amongst":
			definition = "<em>Amongst</em> equals <em>in</em>, <em>surrounded by</em>. "
				+ "You can also say <em>among</em>.";
			break;

		case "anaconda":
			definition = "A really big snake. You hope there aren\'t any on this island.";
			break;

		case "ape":
			definition = "A group of animals including gorillas, chimpanzees, orang-utans and gibbons."
			break; 
		
		case "bank":
			definition = "The side of a river. "
				+ "<p>Here, <em>bank</em> does NOT mean a place where you keep "
				+ "your money. That is another "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'definition\')\">definition</span>.</p>";
			break;
		
		case "bare":
			definition = "Naked, unclothed, unprotected.";
			break;

		case "bark":
			definition = "Bark is the \"skin\" of a tree.";
			break;

		case "beckham":
			definition = "A famous soccer player.";
			break;
		
		case "beneath":
			definition = "Underneath.";
			break;		

		case "boulder":
			definition = "A <em>boulder</em> is a <em>big rock</em>. Or a VERY big "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pebble\')\">pebble</span>. ";
			break;

		case "branch":
			definition = "The \"arm\" of a tree.";
			break;

		case "breeze":
			definition = "A light, gentle wind.";
			break;

		case "bury":
			definition = "<em>Bury</em> is a verb. Something that has been <em>buried</em> "
				+ "has been put underground and covered up."
				+ "<p>For example:</p> <p>A dog buried a bone in the garden</em>.</p>";
			break;

		case "carve":
			definition = "<em>Carve</em> is a verb you use when you cut something to write on it "
				+ "or change its shape."
				+ "<p>For example:</p>"
				+ "<p>The Rosetta Stone has three languages carved on it.</p>"
				+ "<p>The old man carved a beautiful bird out of wood.</p>";
			break;
				

		case "cliff":
			definition = "If you don't know what a <em>cliff</em> is, please try playing the "
				+ "text adventure "
				+ "<a href='../beach/beach.html' title='Text adventure game for learning beginner English'>"
				+ "A Day at the Beach</a>.";
			break;

		case "coil":
			definition = "The verb <em>coil</em> means to wrap around in a circular way. "
				+ "<p>For example:</p>"
				+ "<p>The "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'anaconda\')\">anaconda</span> "
				+ "coiled itself around the deer, slowly crushing it to death.</p>";
			break;

		case "compass":
			definition = "A <em>compass</em> looks a little bit like a watch. It has a small needle "
				+ "that always points north and helps people "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span>. ";
			break;

		case "constant":
			definition = "Never stops.";
			break;

		case "cord":
			definition = "A <em>cord</em> is a big string or a small rope. It can be made of plastic, "
				+ "metal or other things.";
			break;

		case "curved":
			definition = "Not straight.";
			break;

		case "definition":
			definition = "Meaning.";
			break;

		case "dense":
			definition = "Thick, heavy, solid. <em>Dense</em> means the parts of something are "
				+ "very close together.";
			break;

		case "desertisland":
			definition = "Yes I know, the island had a big, thick "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
				+ "all over it and was certainly not a desert. "
				+ "But in English we still say <em>desert island</em>. It means there are no "
				+ "people on it, not that it is dry and has no water.";
			break;

		case "driftwood":
			definition = "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">Stick</span>s "
				+ "and "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "
				+ "that have "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'washup\')\">washed up</span> "
				+ "on a beach or river "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bank\')\">bank</span>. ";
			break;


		case "equator":
			definition = "The imaginary line that runs around the middle of the Earth where it is "
				+ "always hot and there are no seasons.";
			break;

		case "expect":
			definition = "What you <em>expect</em> to happen is what you think has a high chance of "
				+ "happening."
				+ "<p>For example:</p>"
				+ "<p>Look at those clouds! I expect it will rain soon.</p>";
			break;

		case "fairly":
			definition = "<em>Fairly</em> is similar to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span>. "
				+ "It means <em>reasonably</em>. ";
			break;

		case "fiction":
			definition = "Imagined. Not true.";
			break;

		case "float":
			definition = "To be carried lightly on top of water or air. "
				+ "<p>For example:</p>"
				+ "<p>The boat floated down the river.</p>"
				+ "<p>The feather floated along in the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'breeze\')\">breeze</span>. ";
			break;

		case "firm":
			definition = "<em>Firm</em> is an adjective that means hard, strong or "
				+ "difficult to move. The adverb <em>firmly</em> means "
				+ "<em>with strength</em>.";
			break;

		case "flesh":
			definition = "In a person, flesh is the part of the body between the "
				+ "bone and the skin."
				+ "<p>Flesh can also be the \"body\" of a piece of fruit.</p>";
			break;

		case "foliage":
			definition = "Plant and tree leaves.";
			break;

		case "focus":
			definition = "To aim light at a point using a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lens\')\">lens</span>. ";
			break;

		case "fully":
			definition = "Completely, 100 percent.";
			break;

		case "givechase":
			definition = "To <em>follow</em>. To run after and try to catch something or someone.";
			break;

		case "giveway":
			definition = "A common meaning for <em>give way</em> is when you let a car pass or go in "
				+ "front of you on the road. <p>HERE <em>give way</em> means to <em>fail</em> or "
				+ "<em>break</em>.</p>";
			break;

		case "godwouldforgiveyou":
			definition = "After all, he forgave you for all that naughty stuff you did when you were "
				+ "a teenager, didn\'t he?";
			break;

		case "grab":
			definition = "Hold.";
			break;

		case "guinness":
			definition = "Guinness is a kind of strong, dark beer.";
			break;

		case "havegottogo":
			definition = "This means <em>must be removed</em>.";
			break;

		case "heavy2":
			definition = "Here, <em>heavy</em> means <em>a lot of</em>.";
			break;

		case "horizon":
			definition = "The distant place where it looks like the sky meets the land or sea.";
			break;

		case "impenetrable":
			definition = "You cannot make a hole in or pass through something that is <em>impenetrable</em>."
			break;

		case "intact":
			definition = "Not broken.";
			break;

		case "involuntary":
			definition = "If an action is <em>involuntary</em> you can\'t stop yourself from doing it.";
			break;

		case "jungle":
			definition = "A <em>jungle</em> is like a <em>forest</em> but "
				+ "hotter, wetter and often "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'dense\')\">dense</span>r. "
				+ "Found in "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tropical\')\">tropical</span> "
				+ "areas around the world.";
			break;

		case "lack":
			definition = "A <em>lack</em> of something means there isn\'t enough of it.";
			break;

		case "lens":
			definition = "A "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'curved\')\">curved</span> "
				+ "piece of glass used to make things look bigger.";
			break;

		case "machete":
			definition = "A very big knife.";
			break;

		case "navigate":
			definition = "To <em>navigate</em> is to find which direction you want to go in.";
			break;

		case "obscenities":
			definition = "Bad words you say when you are angry."
				+ "<p>For example:</p>"
				+ "<p>...sorry, I don\'t actually know any bad words. "
				+ "The people who write "
				+ "<a href='http://www.penny-arcade.com/comic/2008/8/4/' title='Penny Arcade web comic'>"
				+ "this</a> comic know a few though...</p>";
			break;

		case "parachute":
			definition = "Skydivers use parachutes to stop themselves dying when they jump out of "
				+ "aeroplanes.";
			break;

		case "pause":
			definition = "To <em>pause</em> is to <em>wait</em>. To <em>stop for a short time</em>. "
				+ "It can be a verb or a noun.";
			break;

		case "patient":
			definition = "The adverb <em>patiently</em> means <em>without becoming bored or angry.</em>"
				+ "The adjective is <em>patient</em>.";
			break;

		case "pebble":
			definition = "A <em>pebble</em> is a <em>small rock</em>.";
			break;

		case "pint":
			definition = "About 600 ml. This can be "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'slightly\')\">slightly</span> "
				+ "different depending on which country you are in.";
			break;

		case "plank":
			definition = "A <em>plank</em> is a long, flat piece of wood that has been cut from a tree "
				+ "in order to be used to build something.";
			break;

		case "poshspice":
			definition = "Victoria Beckham.";
			break;

		case "pour":
			definition = "<em>Pour</em> is a verb used when water (or any liquid) moves from a higher "
				+ "place to a lower one. "
				+ "<p>For example:</p>"
				+ "<p>Little Jimmy poured milk onto his breakfast cereal.</p>"
				+ "<p>Don Corleone poured cement over the person he didn\'t like "
				+ "very much.</p>";
			break;

		case "prepared":
			definition = "Ready.";
			break;

		case "pretty":
			definition = "<em>Pretty</em> means \"middle level\". It is stronger than \"a little\" "
				+ "but weaker than \"very\"."
				+ "<p>Pretty is often not as strong as "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> "
				+ "but it depends on the way you say it when speaking aloud.</p>";
			break;


		case "prod":
			definition = "To push something a little.";
			break;

		case "protein":
			definition = "Protein is an important part of food. It can be found in things like "
				+ "milk, eggs, nuts and meat.";
			break;

		case "punish":
			definition = "To <em>punish</em> is a verb that means to hurt for doing something wrong. "
				+ "The noun is <em>punishment</em>.";
			break;

		case "quite":
			definition = "<em>Quite</em> means \"middle level\". It is stronger than \"a little\" "
				+ "but weaker than \"very\"."
				+ "<p>Quite is often stronger than "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pretty\')\">pretty</span> "
				+ "but it depends on the way you say it when speaking aloud.</p>";
			break;

		case "raft":
			definition = "A small, flat boat. A <em>raft</em> is simple and easy to build.";
			break;

		case "raise":
			definition = "The people who <em>raise</em> you are the ones who "
				+ "look after you when you are growing up as a child. "
				+ "<p>For example:</p>"
				+ "<p>The loving parents raised a happy daughter.</p>"
				+ "<p>If "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'starwarschar\')\">Qui-Gon Jinn</span> "
				+ "hadn't taken over raising "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'starwarschar\')\">Anakin Skywalker</span> "
				+ "from his mother at an early age the boy might not have grown up to become "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'starwarschar\')\">Darth Vader</span>.</p>";
			break;

		case "rambo":
			definition = "A famous book and movie character. He was most popluar in the 1980s "
				+ "and was known for having big weapons, big muscles and killing lots of people.";
			break;

		case "reach":
			definition = "<em>Reach</em> is a verb that you use when you try to get to or touch "
				+ "something that isn\'t close to you.";
			break;

		case "refreshed":
			definition = "You feel <em>refreshed</em> when your energy and good feeling returns. "
				+ "It means <em>recharged</em> or <em>like new</em>.";
			break;

		case "rest":
			definition = "Here, <em>the rest</em> means <em>the other</em> (parts of the jungle)."
				+ "<p>It does NOT mean <em>take a break</em>.</p>";
			break;

		case "rest2":
			definition = "Here, <em>the rest</em> means <em>the other</em> (meat that you didn\'t eat)."
				+ "<p>It does NOT mean <em>take a break</em>.</p>";
			break;

		case "redbaron":
			definition = "The Red Baron was a famous German fighter pilot from World War I.";
			break;

		//case "rip" - see "tear" 

		case "ripe":
			definition = "Ripe fruit is ready to be eaten.";
			break;

		case "rot":
			definition = "When something <em>rots</em> it goes bad as time passes. "
				+ "<p>For example:</p>"
				+ "<p>Fruit falls from the tree then starts to rot.</p>"
				+ "<p>There was a hole in the bridge where the wood had rotted away.</p>";
			break;

		case "rust":
			definition = "<em>Rust</em> can be a noun or a verb. It is what happens when "
				+ "metal "
				+"<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rot\')\">rot</span>s. ";
			break;

		case "sail":
			definition = "The noun <em>sail</em> is something that catches the wind to move a boat. It can "
				+ "also be a verb.";
			break;

		case "scatter":
			definition = "<em>Scatter</em> is a verb used when things move or are put over a wide "
				+ "area in a flat, random pattern."
				+ "<p>For example:</p>"
				+ "<p>Sarah scattered small pieces of bread on the grass for the ducks to eat.</p>"
				+ "<p>The crowd scattered when the angry-looking man fired his "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'ak47\')\">AK-47</span> "				
				+ "into the air.</p>";
			break;

		case "screech":
			definition = "A <em>screech</em> is an angry, scary <em>scream</em>."
			break;

		case "several":
			definition = "<em>Several</em> is more than <em>a few</em> and less than <em>a lot</em>.";
			break;

		case "shake":
			definition = "To quickly move something forwards and backwards or up and down.";
			break; 

		case "shore":
			definition = "Where the sea meets the land."
				+ "<p>This word is also in the text adventure "
				+ "<a href='../beach/beach.html' title='Text adventure game for learning beginner English'>"
				+ "A Day at the Beach</a>.</p>";
			break;

		case "simian":
			definition = "An "
				+ "<em><span class=\"hardvoc\" onmouseover=\"setwordhelp(\'ape\')\">ape</span></em> "
				+ "or <em>monkey</em>. <em>Simian</em> can be an adjective "
				+ "or noun.";
			break;

		case "skeleton":
			definition = "The set of bones inside a person or animal.";
			break;

		case "skull":
			definition = "The <em>skull</em> is the \"head bone\".";
			break;

		case "slightly":
			definition = "A little.";
			break;

		case "slash":
			definition = "To <em>slash</em> means to <em>cut</em> with a big, often side-to-side, sweeping movement.";
			break;

		case "socket":
			definition = "A <em>hole</em> for attaching something.";
			break;

		case "solitary":
			definition = "<em>Solitary</em> is an adjective used when somebody (or something) is all on their own."
			break;

		case "spank":
			definition = "To repeatedly hit someone with the flat part of your open hand. "
				+ "This is usually a form of "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'punishment\')\">punish</span>ment. "
				+ "Usually. ";
			break;

		case "spark":
			definition = "A tiny piece of fire.";
			break;

		case "splash":
			definition = "The sound water makes when something falls into it.";
			break;

		case "starwarschar":
			definition = "A character from <em>Star Wars</em>. If you haven\'t watched these movies "
				+ "please go away now, watch all six episodes, then come back and continue "
				+ "at GameEnglish.com :)";
			break;

		case "stick":
			definition = "The noun <em>stick</em> means a long, usually thin, piece of wood.";
			break; 

		case "struggle":
			definition = "A <em>struggle</em> is a fight or something that takes a lot of work and effort.";
			break;

		case "survive":
			definition = "To <em>survive</em> means to <em>live</em>, to <em>not die</em>. <em>Survival</em> "
				+ "is the noun form.";
			break;

		case "tarzan":
			definition = "Tarzan is a man who was "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'raise\')\">raise</span>d "
				+ "by "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'ape\')\">ape</span>s " 
				+ "in the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
				+ "It is a famous "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'fiction\')\">fiction</span>al "
				+ "story."
			break;

		
		case "tear":
			definition = "The noun <em>tear</em> means water that comes from your eyes when you cry.";
			break;

		case "tear2":
			definition = "As a verb <em>rip</em> or <em>tear</em> means to pull a part of something "
				+ "away from the rest of it, breaking it. If the action is slow it is better to use "
				+ "<em>tear</em> rather than <em>rip</em>. "
				+ "Both words can also be nouns. "
				+ "Don\'t mistake <em>tear</em> for "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tear\')\">tear</span> "
				+ "which has a different pronunciation and meaning. "
				+ "<p>Examples:</p>"
				+ "<p>Anne ripped a page out of her diary because she thought it was "
				+ "embarrassing.</p>"
				+ "<p>Little Johnny had a big tear in his pants after playing in the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'thorn\')\">thorn</span> "
				+ "bushes.</p>";
			break; 

		case "thorn":
			definition = "A <em>thorn</em> is a sharp part of a plant that can cut or scratch you. Roses "
				+ "have thorns.";
			break;

		case "tinder":
			definition = "<em>Tinder</em> is anything fine and dry that easily catches fire. When it is "
				+ "burning it can be used to set fire to something larger that might not catch fire "
				+ "on its own. Very dry grass, leaves or paper are materials that make good tinder.";
			break; 

		case "trail":
			definition = "A path.";
			break;	
	
		case "tropical":
			definition = "Places in the hot area of the world near the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'equator\')\">equator</span>.";
			break;

		case "trunk":
			definition = "Here, the noun <em>trunk</em> means the \"body\" of a tree.";
			break;

		case "twitch":
			definition = "<em>Twitch</em> is a verb that means to make small, quick movements with "
				+ "parts of your body. Usually these movements are "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'involuntary\')\">involuntary</span>. "
				+ "<p>For example:</p>"
				+ "<p>Some people twitch in their sleep when they are dreaming.</p>"
				+ "<p>You twitch if you get an electric shock.</p>";
			break;

		case "unconscious":
			definition = "To be VERY asleep for a bad reason."
				+ "<p>For example:</p> "
				+ "<p>The boxer was hit so hard that he was unconscious for 2 minutes.</p>"
				+ "<p>Andy looked like he was unconscious after drinking 14 "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pint\')\">pint</span>s of "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'guinness\')\">Guinness</span>. "
				+ "</p>";
			break;

		case "usedto":
			definition = "You use <em>used to</em> for something that happened <em>before</em>, "
				+ "but <em>not now</em>."
				+ "<p>For example:</p>"
				+ "<p>Jim used to play tennis when he was a kid but now he doesn\'t have enough time.</p>"
				+ "<p>Computers used to be much more expensive.</p>";
			break;

		case "vine":
			definition = "A vine is a long, thin plant that hangs downwards and looks like "
				+ "a green rope. "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tarzan\')\">Tarzan</span> "
				+ "uses them to swing from tree to tree.";
			break;


		case "washup":
			definition = "In this case <em>wash up</em> is a verb for when something is carried to the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shore\')\">shore</span> "
				+ "by the sea."
				+ "<p>It does NOT mean <em>to clean dishes</em>, that is another "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'definition\')\">definition</span>.</p>";
			break;

		case "wreckage":
			definition = "<em>Wreckage</em> is the parts that are left when something has crashed, "
				+ "is broken, or has been destroyed.";
			break;
		}

	document.getElementById("wordhelp").innerHTML = definition;

	}	









//what happens when user clicks on startgame button
//it adjusts what control buttons are visible and enters game loop
function startGame() 
	{
	//alert("in startGame()");			
	document.getElementById("start").disabled = true;
	document.getElementById("reload").disabled = false;
	document.getElementById("look").disabled = false;	

	setupscene();
	}

function look()
	{
	//alert ("in look(), curScene = " + curScene);
	justentered = true;
	msg = "";
	setupscene();
	}



function replaceNodeText(id, newText) //unused
	{
	var node = document.getElementById(id);
	
	while (node.firstChild)
		{
		node.removeChild(node.firstChild);
		}
	node.appendChild(document.createTextNode(newText));
	}


function removeInventory(item)  //arg is item to be removed
	{
	var i = 0;

	while ((inventory[i] !== item) && (i < inventory.length))
		i += 1;


	//alert("indexed inventory item is number " + i + ": " + inventory[i]);

	inventory.splice(i, 1); //removes 1 element starting with i

	}


function showInventory()
	{
	var inventorytext = "<b>You have: </b>";

	for (var i = 0; i < inventory.length; i += 1)
		{
		inventorytext += "<p>" + inventory[i] + "</p>";
		}

	document.getElementById("inventorybox").innerHTML = inventorytext;

	}

function checkInventory(item)
	{
	for (var i = 0; i < inventory.length; i += 1)
		{
		if (inventory[i] === item)
			return true;
		}
	return false;
	}



function showpaths() //don't call this function with more than one instance of each path
	{
	//turn off all path buttons first
	document.getElementById("north").style.visibility = "hidden";
	document.getElementById("south").style.visibility = "hidden";
	document.getElementById("west").style.visibility = "hidden";
	document.getElementById("east").style.visibility = "hidden";
	document.getElementById("up").style.visibility = "hidden";
	document.getElementById("down").style.visibility = "hidden";


	var i;
	for (i=0; i < arguments.length; i += 1)
		{
		if (arguments[i] === "n")
			document.getElementById("north").style.visibility = "visible";
		if (arguments[i] === "s")
			document.getElementById("south").style.visibility = "visible";
		if (arguments[i] === "w")
			document.getElementById("west").style.visibility = "visible";
		if (arguments[i] === "e")
			document.getElementById("east").style.visibility = "visible";
		if (arguments[i] === "u")
			document.getElementById("up").style.visibility = "visible";
		if (arguments[i] === "d")
			document.getElementById("down").style.visibility = "visible";
		}
	}





function showmsg(id, textmsg) 
	{
	if (id === "maintext") //FLASH MAIN TEXTBOX to show something's happened even when text is same 
		{
		document.getElementById("maintext").style.backgroundColor = "#bdd494"; 
		setTimeout ('document.getElementById("maintext").style.backgroundColor = "#ebf3dc"', 50);
	        //waits X (second arg) milliseconds before changing colour back. The code execution does NOT pause! 
		}
		
	document.getElementById(id).innerHTML = textmsg;	
	}




function addoption(opttext, optname) //new ver now "options" is global
	{
	options += "<div id=\""
	+ optname
	+ "\" class=\"option\" onclick=\"interact(\'"
	+ optname
	+ "\')\" onmouseover=\"this.className = \'optionhover\'\""
	+ " onmouseout=\"this.className = \'option\'\">"
	+ opttext
	+ "</div>";
	}



function gotoBeach()  //this just adds the back to beach with compass option. Saves typing!
	{
	if (checkInventory("compass"))
		{
		addoption("Use your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span> to <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span> back to the beach.", "gotobeach");
		}
	}




function showEndScene()
	{
	msg = "You work long and hard building a "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'raft\')\">raft</span> "
		+ "from all the things you\'ve found around the beach and the "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
		+ "The "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
		+ "makes an excellent "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sail\')\">sail</span> "
		+ "as the wind carries you away from the "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shore\')\">shore</span> "
		+ "and out to sea."
		+ "<p>You don\'t know if you will find another "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'desertisland\')\">desert island</span>, "
		+ "a boat to rescue you or even a slow death as you run out of food and water. "
		+ "But you feel good about your chances of "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'survive\')\">survival</span>, "
		+ "knowing that you have already shown the luck and skill needed to "
		+ "ESCAPE FROM "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'simian\')\">SIMIAN</span> "
		+ "ISLAND.</p>"
		+ "<p>The End - Congratulations!</p>";



	showmsg("maintext", msg);
	
	options = "";
	
	showmsg("inputarea", options);

	showpaths("");

	document.getElementById("look").disabled = true;	

	}




function showVines()
	{
	//msg = "";

	beentovines = true;

	if(justentered)
		{
		msg = "This part of the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
			+ "has many "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s "
			+ "hanging down from the trees. "
		
		if(!sowndiscord)
			{
			msg += "<p>You can see monkeys playing around and climbing all over the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s. "
				+ "The trees are full of them making lots of noise, there must be hundreds!</p>";
			}

		if(cutdownvines && !gotvines)
			{
			msg += "<p>There are some "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'coil\')\">coil</span>ed "
				+ "up on the ground where they have fallen after being cut from the trees.</p>";
			}

		msg += "<p>From here the only way you can go is back to the south.</p>";
			
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	
	if (!climbedvinetree)
		{
		addoption("Look at the trees.", "lookattrees");
		addoption("Climb a tree.", "climbtree");
		
		if(checkInventory("bananas") && !sowndiscord)
			{
			addoption("Give a banana to the monkeys.", "givemonkeysbanana");
			}

		if(!gotvines && cutdownvines)
			{
			addoption("Pick up the fallen <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s.", "getvines");			
			}
		}

	if (climbedvinetree)
		{
		addoption("Look around.", "lookaround");

		if(checkInventory("machete") && !cutdownvines)
			{
			addoption("Cut some <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s down with your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span>.", "cutdownvines");
			}
		
		addoption("Climb down.", "climbdown");

		}

	if (!climbedvinetree)
		{
		gotoBeach();
		}



	showmsg("inputarea", options);



	//movement buttons
	if(!climbedvinetree)
		{
		showpaths("s", "w");
		}
	if(climbedvinetree)
		{
		showpaths("");
		}

	}






function vinesInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 23;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 27;
			break;

		case "gotobeach":
			justentered = true;
			curScene = 1;
			break;

		case "lookattrees":
			msg = "Some guy called \"Robinson Crusoe\" has "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'carve\')\">carve</span>d "			
			+ "his name into the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bark\')\">bark</span> "
			+ "of one of the trees. ";
			break;

		case "givemonkeysbanana":
			msg = "You throw a banana to the nearest monkey. He catches it eagerly but then stops "
				+ "as there is a sudden quiet. Fifty pairs of "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'simian\')\">simian</span> "
				+ "eyes turn towards the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'solitary\')\">solitary</span> "
				+ "monkey holding the banana. "
				+ "He "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pause\')\">pause</span>s "
				+ "for the second it takes him to realise what is about to happen, then "
				+ "runs off into the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
				+ "as fast as he can go. There is an explosion of noise as every single "
				+ "monkey in the area "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'givechase\')\">gives chase</span> "
				+ "at the same time. You stand "
				+ "back and watch them disappear into the trees.";
			sowndiscord = true;
			break;

		case "climbtree":
			if(!sowndiscord)
				{
				msg = "The trees here are easy enough to climb but there are monkeys "
					+ "in the way everywhere you try. As soon as you go to push past one "
					+ "they all start "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'screech\')\">screech</span>ing "
					+ "at you angrily. You don\'t feel like trying to fight them all off while "
					+ "climbing high up into the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foliage\')\">foliage</span>. ";
				}

			if(sowndiscord)
				{
				msg = "The climb is easy and you quickly find yourself high up in the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branches</span>. ";
				climbedvinetree = true;
				}

			break;

		case "lookaround":
			msg = 	"You are up "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'amongst\')\">amongst</span> "
				+ "the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "
				+ "of a tree. "
				+ "The "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foliage\')\">foliage</span> "
				+ "up here is too "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'dense\')\">dense</span> "
				+ "to see anything except for lots of "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s "
				+ "hanging down around you.";
			break;


		case "cutdownvines":
			msg = "You cut away "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'several\')\">several</span> "
				+ "of the longer and stronger "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s, "
				+ "watching them fall to the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
				+ "floor below.";
			cutdownvines = true;
			break;

		case "climbdown":
			msg = "You quickly climb back down to the forest floor.";
			climbedvinetree = false;
			break;

		case "getvines":
			msg = "These "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s "
				+ "could easily be used as rope. Just what you need to help you make a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'raft\')\">raft</span>.";
			inventory.push("vines")
			gotvines = true;
			break;
			
			 
					

		}

	setupscene();
	}




function showj27()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go south or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("s", "e");

	}






function j27Interact(input)
	{
	msg = "";

	switch (input)
		{

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 22;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 28;
			break;		

		}

	setupscene();
	}




function showj26()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go south or west.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("s", "w");

	}






function j26Interact(input)
	{
	msg = "";

	switch (input)
		{

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 21;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 25;
			break;

		}

	setupscene();
	}




function showj25()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go south, west or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("s", "w", "e");

	}






function j25Interact(input)
	{
	msg = "";

	switch (input)
		{

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 20;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 24;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 26;
			break;		

		}

	setupscene();
	}




function showClearing()
	{
	//alert ("in showX()");
	//msg = "";

	beentoclearing = true;

	if(justentered)
		{
		msg = "The path leads out of the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
			+ "and up to a clear area overlooking a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>. "
			+ "The "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
			+ "is a thick, green carpet covering the whole island below you. "
			+ "You can see the beach that you "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'washup\')\">washed up</span> "
			+ "on far away to the south. "
			+ "Far on the eastern "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'horizon\')\">horizon</span>, "
			+ "in the direction the wind is blowing, "
			+ "you think you can just see part of another landmass. "
			+ "However, it might only be your overly-hopeful imagination."
			+ "<p>Right on the edge  of the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span> "
			+ "is a small, "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'solitary\')\">solitary</span> "
			+ "tree that has no "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foliage\')\">foliage</span>. "
			+ "There is a lot of grass around and it is kept dry by a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lack\')\">lack</span> "			
			+ "of shade and a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'constant\')\">constant</span> "
			+ "wind.</p>";

		msg += "<p>There is nowhere to go from here except back east, down into the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>.</p> ";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");
	addoption("Look at the tree.", "lookattree");
	addoption("Climb the tree.", "climbtree")
	if(!checkInventory("dry grass"))
		{
		addoption("Pick up some grass.", "getgrass")
		}


	gotoBeach();

	showmsg("inputarea", options);



	//movement buttons
	showpaths("e");

	}






function clearingInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 25;
			break;

		case "gotobeach":
			justentered = true;
			curScene = 1;
			break;

		case "lookattree":
			msg = "In tiny words you can read \"Chuck Noland was here\" "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'carve\')\">carve</span>d "
				+ "into the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bark\')\">bark</span>. ";
			break;

		case "climbtree":
			msg = "It looks like it would break and then you\'d probably fall down the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>. ";
			break;

		case "getgrass":
			msg = "You pick up a handful of the dry grass.";
			inventory.push("dry grass");
			break;	
		}

	setupscene();
	}




function showj23()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north or west.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "w");

	}






function j23Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 28;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 22;
			break;		

		}

	setupscene();
	}




function showj22()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north, south, west or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "w", "e");

	}






function j22Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 27;
			break;

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 17;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 21;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 23;
			break;		

		}

	setupscene();
	}




function showj21()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north, south or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "e");

	}






function j21Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 26;
			break;

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 16;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 22;
			break;		

		}

	setupscene();
	}




function showj20()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north or west.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "w");

	}






function j20Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 25;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 19;
			break;		

		}

	setupscene();
	}




function showCoconutTrees()
	{

	beentococonuttrees = true;


	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>There are "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'several\')\">several</span> "
			+ "coconut trees here. "; 

		if(!monkeyfallen)
			{
			msg += "A monkey is high up in the trees playing around with the coconuts.<p>";
			}
		else
			{
			msg += "</p>";
			}

		if(monkeythrowncoconuts && !gotcoconuts)
			{
			msg += "<p>There are "
				+ "some "
				+ "coconuts lying on the ground.</p>";
			}
		
				
		if(monkeyfallen)
			{
			msg += "<p>An "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'unconscious\')\">unconscious</span> "
				+ "monkey is lying under one of the trees, "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'twitch\')\">twitch</span>ing "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'slightly\')\">slightly</span>. "
				+ "</p>";
			if(!gotfallenrock)
				{
				msg += "</p>There is a rock on the ground near the monkey. It looks like "
					+ "there is a little blood on it.</p>";
				}
			}

		if(thrownrockatmonkey && !gotfallenrock && !monkeyfallen)
			{
			msg += "The rock that you threw at the monkey is still lying on the ground.";
			}

		msg += "<p>You can leave this area by following paths south or east.</p>";

		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");

	addoption("Look at the coconut trees.", "lookatcoconuttrees");

	if(checkInventory("rock") && !monkeyfallen)
		{
		addoption("Throw your rock at the monkey.", "throwrock");
		}
	
	if(checkInventory("rotten mango") && !monkeyfallen)
		{
		addoption("Throw your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rot\')\">rot</span>ten mango at the monkey.", "throwmango");
		}

	if(checkInventory("stick") && !monkeyfallen)
		{
		addoption("Throw your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span> at the monkey.", "throwstick");
		}

	if(thrownrockatmonkey && !gotfallenrock)
		{
		addoption("Pick up the rock.", "getfallenrock");
		}

	if(monkeythrowncoconuts && !gotcoconuts)
		{
		addoption("Pick up the coconuts.", "getcoconuts");
		}

	if(monkeyfallen)
		{
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'prod\')\">Prod</span> the monkey.", "prodmonkey");
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shake\')\">Shake</span> the monkey.", "shakemonkey");
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'spank\')\">Spank</span> the monkey.", "spankmonkey");
		}



	gotoBeach();

	showmsg("inputarea", options);



	//movement buttons
	showpaths("s", "e");

	}






function coconutTreesInteract(input)
	{
	msg = "";

	switch (input)
		{

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 14;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 20;
			break;

		case "gotobeach":
			justentered = true;
			curScene = 1;
			break;	

		case "lookatcoconuttrees":
			msg = "Someone has "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'carve\')\">carved</span> "
				+ "their name into one of the trees."
				+ "<p>\"Alexander Selkirk\"<p>";
			break;

		case "throwstick":
			msg = "You throw the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span> "
				+ "hard at the monkey but it is much too diffcult to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'aim\')\">aim</span> "
				+ "with. Your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span> "
 				+ "flies into the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foliage\')\">foliage</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'several\')\">several</span> "
				+ "metres below the monkey. He doesn\'t even notice. "
				+ "<p>Great! You missed the monkey and now you\'ve lost your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span> "
				+ "too.</p>";
			removeInventory("stick");
			break;
		
		case "throwrock":
			msg = "You "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'aim\')\">aim</span> "
				+ "and throw your rock. It hits the monkey harder than you "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'expect\')\">expect</span> "
				+ "and you "
				+ "feel "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> "
				+ "bad as the monkey falls from the trees, hitting one or two "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "				
				+ "on the way "
				+ "down.";
			thrownrockatmonkey = true;
			monkeyfallen = true;
			removeInventory("rock");
			gotfallenrock = false;
			break;

		case "throwmango":
			if(monkeythrowncoconuts)
				{
				msg = "You don\'t want to play that game again. You were lucky the monkey missed "
					+ "you last time!";
				}
			else
				{
				msg = "You throw the mango at the monkey. Your "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'aim\')\">aim</span> "
					+ "is good and you hit the surprised "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'simian\')\">simian</span> "
					+ "right in the chest, covering him with pieces of "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rot\')\">rot</span>ten "
					+ "fruit. "
					+ "<p>The monkey isn\'t hurt by your attack. In fact, he seems to like this game! "
					+ "He doesn\'t have any mangos but you have to run and hide "
						+ "behind a tree as he throws "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'several\')\">several</span> "
					+ "coconuts down at you.</p>";
				monkeythrowncoconuts = true;
				removeInventory("rotten mango");
				}

			break;

		case "getcoconuts":
			msg += "You pick up the coconuts. You break one open with your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span> "
				+ "and drink the milk and eat the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'flesh\')\">flesh</span>. "
				+ "You\'re feeling a litte better about your chances of "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'survive\')\">survival</span> "
				+ "now.";
			inventory.push("coconuts");
			gotcoconuts = true;
			break;

		case "prodmonkey":
			msg = "You lean down and gently "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'prod\')\">prod</span> "
				+ "the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'unconscious\')\">unconscious</span> "
				+ "monkey. He doesn\'t get up, you must have hit him "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pretty\')\">pretty</span> "
				+ "hard. ";
			break;

		case "shakemonkey":
			msg = "You "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'grab\')\">grab</span> "
				+ "the monkey by the shoulders "
				+ "and give him a good "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shake\')\">shake</span>. "
				+ "Suddenly his eyes open. He gives you a quick, worried look then runs back up "
				+ "the coconut tree. He climbs much better than you could ever hope to.";
			monkeyfallen = false;
			break;

		case "spankmonkey":
			msg = "You have more important things to do right now!";
			break;

		case "getfallenrock":
			msg = "You pick up the rock you used to K.O. the monkey.";
			inventory.push("rock");
			gotfallenrock = true;
			break;

		}

	setupscene();
	}




function showj18()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go south or west.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("s", "w");

	}






function j18Interact(input)
	{
	msg = "";

	switch (input)
		{

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 13;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 17;
			break;		

		}

	setupscene();
	}




function showj17()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north, or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "e");

	}






function j17Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 22;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 18;
			break;		

		}

	setupscene();
	}




function showWaterfall()
	{
	//msg = "";

	//alert("in showwaterfall()");

	beentowaterfall = true;

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>Surrounded by the trees here is a waterfall "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pour\')\">pour</span>ing "
			+ "20 feet down a small, gentle "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span> "
			+ "into a clear pool of water. A path leads down and around to the bottom "
			+ "of the waterfall. It\'s easy enough to get down and back up again. "
			+ "It is  "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> "		
			+ "peaceful here, "
			+ "you feel calm and rested just listening to the soft "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'splash\')\">splash</span>ing "
			+ "of water. There are lots of rocks "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scatter\')\">scatter</span>ed "
			+ "around the bottom of the cliff near the pool.</p>";

		if(!pushedboulder)
			{
			msg += "<p>At the top of the waterfall you can see a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'boulder\')\">boulder</span> "
				+ "sitting dangerously close to the edge.<p>"
				+ "<p>At the bottom of the cliff a wild pig is drinking from the water.</p>";
			}

		if(!gotdeadpig && pushedboulder)
			{
			msg += "<p>At the bottom of the cliff is a dead pig. A big rock has fallen on its head.</p>";
			}
				

 
		msg += "<p>From here you can walk back to the north.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = ""

	addoption("Look at the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'boulder\')\">boulder</span>.", "lookatboulder");

	if(!pushedboulder)
		{
		addoption("Push the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'boulder\')\">boulder</span>.", "pushboulder");
		}

	if(checkInventory("coconuts") && !checkInventory("coconuts full of water"))
		{
		addoption("Cut a small hole in some coconuts and fill them up with water.", "fillcoconutswithwater");
		}

	if(!gotdeadpig && pushedboulder)
		{
		addoption("Pick up the dead pig", "getdeadpig");
		}

	if(!drunkwater)
		{
		addoption("Drink some water from the pool.", "drinkwater");
		}

	
	gotoBeach();


	showmsg("inputarea", options);



	//movement buttons
	showpaths("n");

	}






function waterfallInteract(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 21;
			break;

		case "gotobeach":
			justentered = true;
			curScene = 1;
			break;

		case "lookatboulder":
			msg = "\"Ralph was here\" is "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'carve\')\">carve</span>d "
				+ "into the rock. ";
			if(!pushedboulder)
				{
				msg += "The whole thing looks like it could easily fall over the edge.";
				}
			break;

		case "fillcoconutswithwater":
			msg = "You use your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span> "
				+ "to make a little hole in the top of some of the coconuts and fill them with water. "
				+ "This will definitely help you "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'survive\')\">survive</span> "
				+ "for longer when you sail away from this place on your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'raft\')\">raft</span>. ";
			inventory.push("coconuts full of water");
			break;

		case "pushboulder":
			msg = "You lean against the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'boulder\')\">boulder</span> "
				+ "and push. At first it doesn\'t move, then suddenly it falls over the edge. "
				+ "The pig hears something and looks up, just in time to catch a heavy rock "
				+ "to the face. The poor animal does not "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'survive\')\">survive</span>. ";
			pushedboulder = true;
			break;

		case "getdeadpig":
			msg = "You now have a dead pig. Great!";
			inventory.push("dead pig");
			gotdeadpig = true;
			break;

		case "drinkwater":
			msg = "You take a good, long drink of water and feel "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> " 
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'refreshed\')\">refreshed</span>.";
			if(!checkInventory("coconuts full of water"))
				{
				msg += "<p>You know you can come back here to drink whenever you want but it would "
					+ "be good if you had some way to take water with you.</p>";
				}
			drunkwater = true;
			break;

		}

	setupscene();
	}




function showj15()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go south or west.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("s", "w");

	}






function j15Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 10;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 14;
			break;	

		}

	setupscene();
	}




function showj14()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north, south or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "e");

	}






function j14Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 19;
			break;

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 9;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 15;
			break;		

		}

	setupscene();
	}




function showj13()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north, south, or west.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "w");

	}






function j13Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 18;
			break;

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 8;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 12;
			break;	

		}

	setupscene();
	}




function showCrashSite()
	{
	//alert ("in showX()");
	//msg = "";

	beentopilot = true;  //this is used to know which sites you can jump to when you have the compass

	if(justentered)
		{
		msg = "This part of the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
			+ "is a little darker than "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rest\')\">the rest</span>. "
			+ "It might only be your imagination but it also feels colder.";

		if(!lookedatskeleton)
			{
			msg += "<p>Looking up you see a  "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span> "
				+ "hanging high in the trees!</p>";
			}

		if(lookedatskeleton && !cutdownpilot) 
			{
			msg += "<p>The "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span> "
				+ "of the pilot hanging from a big tree reminds you that this island can be "
				+ "a dangerous place.</p>";
			}

		if(lookedatskeleton && cutdownpilot) 
			{
			msg += "<p>The broken "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span> "
				+ "of the pilot is lying across the path.</p>";
			}

		if(lookedatskeleton && pushedparachute && !checkInventory("parachute"))
			{
			msg += "<p>The pilot\'s "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
				+ "is on the ground a little way from the big tree.</p>";
			}

		if(lookedatskeleton && !checkInventory("compass"))
			{
			msg += "<p>There is a small object in the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'dirt\')\">dirt</span> "
				+ "and leaves under the big tree.</p>";
			}

		msg += "<p>From here you can go south, west or east.</p>";
		
			
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	
	if(!lookedatskeleton && !inpilottree)
		{
		addoption("Look at the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span>.", "lookatskeleton");
		}

	if(lookedatskeleton && !inpilottree)
		{
		addoption("Look at unlucky pilot.", "lookatpilot");
		addoption("Look at the big tree.", "lookattree");
		addoption("Climb the big tree.", "climbtree");
		}

	if(lookedatskeleton && !checkInventory("compass") && !inpilottree)
		{
		addoption("Pick up the small metal object on the ground underneath the unlucky pilot.", "getcompass");
		}
	
	if(inpilottree)
		{
		addoption("Look around.", "lookaround");
		if(!cutdownpilot)
			{
			addoption("Cut the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cord\')\">cord</span>s holding the pilot.", "cutcords");
			}
		if(!pushedparachute)
			{
			addoption("Push the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> out of the tree.", "pushparachute");
			}
		addoption("Climb down.", "climbdown");
		}

	if(!inpilottree && lookedatcutdownpilot && !checkInventory("glasses"))
		{
		addoption("Pick up the glasses.", "getglasses");
		}

	if(!inpilottree && pushedparachute && !checkInventory("parachute"))
		{
		addoption("Pick up the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span>.", "getparachute");
		}

	if(!inpilottree)
		{
		gotoBeach();
		}


	showmsg("inputarea", options);



	//movement buttons
	if(!inpilottree)
		{
		showpaths("s", "w", "e");
		}
	if(inpilottree)
		{
		showpaths("");
		}

	}






function crashSiteInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 7;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 11;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 13;
			break;
		
		case "gotobeach":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			break;

		case "lookatskeleton":
			msg = "The <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span> "
				+ "is hanging from a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
				+ "that is caught in the upper "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "
				+ "of a big tree. Some old, "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rot\')\">rot</span>ted "
				+ "clothes left hanging off the bones look like what "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'usedto\')\">used to</span> "				
				+ "be a pilot\'s uniform. "
				+ "It is difficult to see from here but you think the unlucky pilot is still wearing "
				+ "glasses."
				+ "<p>You don\'t know how long the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span> "
				+ "has been hanging there but while you are standing under it wondering how long it will "
				+ "be before you look the same, you notice something in the fallen leaves "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'beneath\')\">beneath</span>.";
			lookedatskeleton = true;
			break;

		case "lookatpilot":
			if(!cutdownpilot)
				{
				msg = "The <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span> "
					+ "of a pilot is hanging from a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
					+ "that is caught in the upper "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "
					+ "of a big tree. "
					+ "It is difficult to see from here but you think the he is still wearing "
					+ "glasses.";
				}
			if(cutdownpilot && !checkInventory("glasses"))
				{
				msg = "A pair of glasses is half hanging off the dead pilot's "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skull\')\">skull</span>. ";
				lookedatcutdownpilot = true;
				}

			if(cutdownpilot && checkInventory("glasses"))
				{
				msg = "There is nothing more of interest on the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span>. "
					+ "Looking down at the empty eye "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'socket\')\">socket</span>s "					
 					+ "just makes you feel uncomfortable.";
				}
			break;

		case "lookattree":
			msg = "There is writing "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'carve\')\">carve</span>d "
				+ "into the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bark\')\">bark</span>."
				+ "<p>\"Alex, Marty, Melman and Gloria were here.\"";
			break;


		case "getcompass":
			msg = "It seems to be made of metal and glass. You pick it up and as you clean off some mud and "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rust\')\">rust</span> "
				+ "you see that it is a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span>! "
				+ "It looks like it\'s still working OK. You hope it helps you "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span> "
				+ "better than it did its last owner. ";
			inventory.push("compass");
			break;

		case "climbtree":
			if(!checkInventory("vines"))
				{
				msg = "The lowest "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span> "
					+ "of the tree is too high for you to "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'reach\')\">reach</span>. "
					+ "Maybe if you had a rope or something...";
				}

			if(checkInventory("vines"))
				{
				msg = "You throw a long vine over the lowest "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span> "
					+ "and use it to pull yourself up. After that is "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'fairly\')\">fairly</span> "
					+ "easy to continue climbing up "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> "
					+ "a long way. ";
				inpilottree = true;
				}
				
			break;

		case "lookaround":
			msg = "You are high up in the big tree.";

			if(cutdownpilot && !pushedparachute)
				{
				msg += "<p>The pilot\'s "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
					+ "is "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'caught\')\">caught</span> "
					+ "in the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "
					+ "just above you. This is as high up as you can climb.</p>";
				}

			if(!cutdownpilot)
				{
				msg += "<p>From here you can almost "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'reach\')\">reach</span> "
					+ "out and touch the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cord\')\">cord</span>s "
					+ "holding up the pilot.</p>";
				}
			break;

		case "cutcords":
			msg = "You lean forward and "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'slash\')\">slash</span> "
				+ "at the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cord\')\">cord</span>s "
				+ "with your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span>. "
				+ "It looked like the job would take a long time but much sooner that you "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'expect\')\">expect</span> "
				+ "the old "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
				+ "lines "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'giveway\')\">give way</span> "
				+ "and the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span> "
				+ "falls to the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tropical\')\">tropical</span> "
				+ "forest floor. ";
			cutdownpilot = true;
			break;

		case "pushparachute":
			if(!cutdownpilot)
				{
				msg = "The weight of the pilot\'s skeleton holds the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'firm\')\">firm</span>ly "
					+ "in the tree. ";
				}

			if(cutdownpilot && checkInventory("stick"))
				{
				msg = "By "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'reach\')\">reach</span>ing "
					+ "out as far as you can with your "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span> "
					+ "you are able to lift the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
					+ "up a little as you push it off and away from the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es. "
					+ "It "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'float\')\">float</span>s " 
					+ "slowly down, far enough away from the tree that it doesn't get caught "
					+ "again. ";
				pushedparachute = true; 
				}

			if(cutdownpilot && !checkInventory("stick"))
				{
				msg = "You can\'t "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'reach\')\">reach</span> the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
					+ "from here and it is too difficult to climb any closer.";
				}

			break;

		case "climbdown":
			msg = "You climb down from the tree using your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span> "
				+ "rope to help you get from the last "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span> "
				+ "to the ground.";
			
			inpilottree = false;
			break;	

		case "getglasses":
			msg = "Carefully picking up the glasses you notice that one of the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lens\')\">lens</span>es "
				+ "is broken. Whether that just happened when the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'skeleton\')\">skeleton</span> "
				+ "fell to the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
				+ "floor or a long time ago, you do not know. The other "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lens\')\">lens</span> "
				+ "is perfectly "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'intact\')\">intact</span>. ";
			inventory.push("glasses");
			break;

		case "getparachute":
			msg = "The "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'parachute\')\">parachute</span> "
				+ "has a few "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tear2\')\">rip</span>s and "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tear2\')\">tear</span>s "
				+ "but is in surprisingly good condition so you fold it up and take it with you. ";
			inventory.push("parachute"); 		
			break;
	

		}

	setupscene();
	}




function showj11()
	{
	//msg = "";
	
	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go south, west or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("s", "w", "e");

	}






function j11Interact(input)
	{
	msg = "";

	switch (input)
		{

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 6;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 10;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 12;
			break;		

		}

	setupscene();
	}




function showj10()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north, south or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "e");

	}






function j10Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":
			justentered = true;
			curScene = 15;
			break;
		
		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 5;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 11;
			break;		

		}

	setupscene();
	}




function showj9()
	{
	//msg = "";

	if(justentered)
		{
	msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north, or south.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s");

	}






function j9Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 14;
			break;

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 4;
			break;
	

		}

	setupscene();
	}




function showj8()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can only go back north.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n");

	}






function j8Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 13;
			break;		

		}

	setupscene();
	}




function showj7()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north or west.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "w");

	}






function j7Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 12;
			break;


		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 6;
			break;


		}

	setupscene();
	}




function showj6()
	{
	msg = "";

	if(justentered)
		{


		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "though a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north, south or east.</p>";

		if(!enteredjunglebefore)
			{
			msg += "<p>Welcome to the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>... "
				+ "</p>";
			enteredjunglebefore = true;
			}
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "e");

	}






function j6Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 11;
			break;

		case "s":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 7;
			break;		

		}

	setupscene();
	}




function showFruitTrees()
	{
	//msg = "";

	beentofruittrees = true;  //this is used to know which sites you can jump to when you have the compass

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. ";

		
		msg += "<p>There are lots of fruit trees in this area. Not much fruit is left on the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "
 			+ "but there are "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rot\')\">rot</span>ten "
			+ "mangos all around on the ground. ";

		if(!hitbananas)
			{
			msg += "Also you can see a big bunch of bananas hanging from high up a tall banana tree.";
			}

		if(hitbananas && !checkInventory("bananas"))
			{
			msg += "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'amongst\')\">Amongst</span> "
				+ "Amongst the fallen fruit is a big bunch of bananas.";
			}

		msg += "<p>You can exit this area to the north or west.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";

	addoption("Look at the tall banana tree.", "lookatbananatree");
	addoption("Look at the mango trees.", "lookatmangotrees");
	addoption("Climb the tall banana tree.", "climbbananatree");
	addoption("Climb a mango tree.", "climbmangotree");

	if(hitbananas && !checkInventory("bananas"))
		{
		addoption("Pick up the fallen bunch of bananas.", "getbananas");
		}
	if(!checkInventory("rotten mango"))
		{
		addoption("Pick up a mango from the ground.", "getmango");
		}
	
	if(!hitbananas && checkInventory("rock"))
		{
		addoption("Throw your rock at the big bunch of bananas hanging in the tree.", "throwrockatbananas")
		}
	
	if(checkInventory("rock"))
		{
		addoption("Throw your rock at the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'ripe\')\">ripe</span> mangos hanging high up in the branches.", "throwrockatmangos");
		}	


	


	gotoBeach();

	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "w");

	}






function fruitTreesInteract(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 10;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 4;
			break;

		case "gotobeach":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			break;
		
		case "lookatbananatree":
			msg = "The <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trunk\')\">trunk</span> "
				+ "is wide, round and smooth. It doesn\'t have any lower "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es. "
				+ "<p><span class=\"hardvoc\" onmouseover=\"setwordhelp(\'carve\')\">Carve</span>d around "
				+ "the bottom you can see the words "
				+ "\"Herman Toothrot was here.\"</p>";
			break;

		case "lookatmangotrees":
			msg = "There are lots of mango trees but there are only a few "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'ripe\')\">ripe</span> "
				+ "mangos left in the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es. "
				+ "They are very small and high up and might be impossible to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'reach\')\">reach</span>. ";
			break;

		case "climbbananatree":
			msg = "The <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trunk\')\">trunk</span> "
				+ "is wide, round and smooth. There are no lower "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "
				+ "you could use to climb it.";
			break;

		case "climbmangotree":
			msg = "You might be able to climb a little way up into a mango tree but the "
				+ "only pieces of fruit are far out on "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'branch\')\">branch</span>es "
				+ "that are too thin to hold your weight. ";
			break;

		case "throwrockatmangos":
			msg = "You throw your rock at one of the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'ripe\')\">ripe</span> "
				+ "mangos up in the trees. Unfortunately your target is too small and you miss "
				+ "by a lot. Your rock disappears into the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'dense\')\">dense</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foliage\')\">foliage</span>. ";
			removeInventory("rock");
			break;

		case "getmango":
			msg = "You pick up a mango from the ground. It\'s too "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rot\')\">rot</span>ten "
				+ "to eat but maybe you\'ll change your mind if you get really hungry later...";
			inventory.push("rotten mango");
		
			break;
	

		case "throwrockatbananas":
			msg = "You throw your rock at the bunch of bananas. It hits them hard "
				+ "and they fall to the ground at your feet. You can\'t see where "
				+ "your rock went though. ";
			hitbananas = true;
			removeInventory("rock");
			break;

		case "getbananas":
			msg = "You now have lots of bananas. You happily eat one but save the "
				+ "rest for later.";
			inventory.push("bananas");
			break;

		}

	setupscene();
	}




function showj4()
	{
	//msg = "";

	if(justentered)
		{
		msg = "You are following animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>s "
			+ "through a thick, confusing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>From here you can go north or east.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	//addoption("Look around the top shelves.", "lookontopshelves");



	showmsg("inputarea", options);

	gotoBeach();



	//movement buttons
	showpaths("n", "e");

	}






function j4Interact(input)
	{
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 9;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 5;
			break;

		case "gotobeach":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			break;		

		}

	setupscene();
	}




function showCliffs()
	{
	//alert ("in showX()");
	//msg = "";

	if(justentered)
		{
		msg = "At this end of the beach the sand stops at the bottom of some "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>s. "
			+ "A lot of "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wreckage\')\">wreckage</span> "
			+ "from your boat has "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'washup\')\">washed up</span> "
			+ "and there are strong pieces of wood everywhere. "
			+ "<p>This could be really helpful. There might be enough parts of your boat here "
			+ "to make a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'raft\')\">raft</span> "
			+ "and escape the island!</p>";

		
		if(lookedthroughwreckage && !checkInventory("machete"))
			{
			msg += "<p>You can see a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span> "
				+ "half "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bury\')\">buried</span> "
				+ "in the sand "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'amongst\')\">amongst</span> "
				+ "the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wreckage\')\">wreckage</span>.</p>";
			}

		msg += "<p>The jungle to the north is too thick to enter and you cannot climb the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>s "
			+ "so the only place you can go from here is back along the beach to the west.</p>";
	
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	if(!lookedthroughwreckage)
		{
		addoption("Look through the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wreckage\')\">wreckage</span>.", "lookthroughwreckage");
		}

	if(lookedthroughwreckage && !checkInventory("machete"))
		{
		addoption("Pick up the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span>.", "getmachete");
		}

	addoption("Build a <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'raft\')\">raft</span>, sail away and escape the island!", "buildraft");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("w");

	}






function cliffsInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "w":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			break;

		case "lookthroughwreckage":
			msg = "Hoping to find lots of useful food and equipment you start "
				+ "lifting up "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'plank\')\">plank</span>s "
				+ "of wood and pushing aside pieces of broken boat. "
				+ "You spend a long time searching with no result and you are just about to "
				+ "give up when you find a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span> "
				+ "half "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bury\')\">buried</span> "
				+ "in the sand. ";
			lookedthroughwreckage = true;
			break;

		case "getmachete":
			msg = "You pick up the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span> "
				+ "with a smile. "
				+ "It\'s not "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rambo\')\">Rambo</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'survive\')\">survival</span> "
				+ "knife but it looks like it could be very useful to you on this island.";
			inventory.push("machete");
			break;
				
		case "buildraft":
			//alert("in buildraft in cliffsInteract()");
			msg = "You need to be "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'fully\')\">fully</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'prepared\')\">prepared</span> "
				+ "before you can "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sail\')\">sail</span> "
				+ "away and hope to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'survive\')\">survive</span>. ";


			canleave = true;  //you can leave island unless any of the below change this variable to false

			if(!checkInventory("vines"))
				{
				msg += "<p>There is plenty of wood but you will need some sort of rope to tie it all "
					+ "together.</p>";
				canleave = false;
				}

			if(!checkInventory("parachute"))
				{
				msg += "<p>You wish you had something you could use as a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sail\')\">sail</span>. ";
				canleave = false;
				}

			if(!checkInventory("compass"))
				{
				msg += "<p>You will need a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span> "
					+ "to help you "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span>.</p>";
				canleave = false;
				}

			if(!checkInventory("bananas") && !checkInventory("coconuts") && !checkInventory("cooked pork"))
				{
				msg += "<p>You will need some food to take with you.</p>"
				canleave = false;
				}

			if(checkInventory("bananas") && !checkInventory("coconuts") && !checkInventory("cooked pork"))
				{
				msg += "<p>You will need more food than just bananas.</p>";
				canleave = false;
				}

			if(checkInventory("bananas") && checkInventory("coconuts") && !checkInventory("cooked pork"))
				{
				msg += "<p>Bananas and coconuts are good for you but you want some more "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'protein\')\">protein</span> "
					+ "in your diet.</p>";
				canleave = false;
				}

			if(!checkInventory("bananas") && checkInventory("cooked pork"))
				{
				msg += "<p>See if you can find some fruit to go with your pork.</p>";
				canleave = false;
				}

			if(!checkInventory("coconuts full of water"))
				{
				msg += "<p>You will definitely need some water to take with you.</p>";
				canleave = false;
				}			
				
			if(checkInventory("compass") && checkInventory("vines") && checkInventory("parachute") && checkInventory("coconuts") && checkInventory("coconuts full of water") && checkInventory("bananas") && checkInventory("cooked pork"))
				{
				removeInventory("vines");
				removeInventory("parachute");  //used in construction of raft
				justentered = true;
				curScene = 29;  	//takes us to showEndScene() location
				}

			break;

		}

	setupscene();
	}







function showPebbleBeach()
	{
	//alert ("in showX()");
	//msg = "";

	if(justentered)
		{
		msg = "At this end of the beach there are many "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pebble\')\">pebble</span>s "
			+ "mixed in with the sand. Also there is a lot of "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'driftwood\')\">driftwood</span> "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scatter\')\">scatter</span>ed "
			+  "around. It looks "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> "
			+ "dry, unlike the wood in the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
			+ "<p>The beach ends here, running into the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'impenetrable\')\">impenetrable</span> wall of "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
			+ "to the north and west. The calm, blue ocean to your south is as pretty as a picture. "
			+ "However, it seems endless and you cannot see a boat or plane anywhere.</p>";

		if(fireburning)
			{
			msg += "<p>The fire you started is burning well. There is lots of wood to "
				+ "keep it going for a long time and it should be safe here "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'amongst\')\">amongst</span> "
				+ "the rocks and sand.</p>";
			}

		msg += "<p>The only way to go from here is back east towards the middle of the beach.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	if(!checkInventory("rock") && !lightingfire)
		{
		addoption("Pick up a rock.", "getrock");
		}

	if(!checkInventory("stick") && !lightingfire)
		{
		addoption("Pick up some <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'driftwood\')\">driftwood</span>.", "getdriftwood");
		}
	if(!lightingfire && !fireburning)
		{
		addoption("Light a fire on the beach with the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'driftwood\')\">driftwood</span>.", "lightfire");
		}

	if(lightingfire)
		{
		addoption("Light a fire by rubbing <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span>s together.", "rubsticks")
		}

	if(lightingfire)
		{
		addoption("Light a fire by hitting two rocks together.", "hitrocks")
		}

	if(lightingfire && checkInventory("glasses"))
		{
		addoption("Light a fire by using the pilot\'s glasses to <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'focus\')\">focus</span> light onto your dry grass.", "useglasses");
		}

	if(fireburning && checkInventory("dead pig") && !cookedpig)
		{
		addoption("Cook the dead pig on the fire.", "cookpig");
		}

	if(cookedpig && !resolvedporkissue)
		{
		addoption("Eat some delicious-smelling pork.", "getpork");
		addoption("I can\'t eat pork. I\'m a vegetarian!", "veggie");
		addoption("I can\'t eat pork. It\'s against my religion!", "religious");
		}

	showmsg("inputarea", options);



	//movement buttons
	showpaths("e");

	}






function pebbleBeachInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "e":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			break;

		case "getrock":
			msg = "You choose a smooth "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pebble\')\">pebble</span> "
				+ "from the beach and pick it up. It feels like it could be useful for throwing at things.";
			inventory.push("rock");
			break;		

		case "getdriftwood":
			msg = "You pick up a big "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span> "					
				+ "of "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'driftwood\')\">driftwood</span>. ";
				inventory.push("stick");
			break;

		case "lightfire":
			if(!checkInventory("dry grass"))
				{
				msg = "You will need something to use as "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tinder\')\">tinder</span> "
					+ "before you can try to light a fire. ";
				}
			else
				{
				msg = "Do you have any great ideas for making a fire without matches or a lighter?";
				lightingfire = true;
				}
			break;

		case "rubsticks":
			msg = "You spend a very long time trying to rub two pieces of wood together fast enough to "
				+ "start a fire. It doesn\'t work very well. The only "
				+ "result is to make you thirsty, tired and angry.";
			lightingfire = false;
			drunkwater = false;   //makes you thirsty enough to drink again at the waterfall
			break;

		case "hitrocks":
			msg = "You try hitting lots of different rocks together as hard as you can, but none of them "
				+ "make a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'spark\')\">spark</span>. "
				+ "No matter how many "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'obscenities\')\">obscenities</span> "
				+ "you scream. ";
			lightingfire = false;
			break;

		case "useglasses":
			msg = "You  "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'patient\')\">patiently</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'aim\')\">aim</span> "
				+ "a small point of sunlight at a piece of dry grass. "
				+ "The sunlight is bright and hot, soon a small flame has "
				+ "started to lick across the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tinder\')\">tinder</span>. "
				+ "Excitedly you place small, dry "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span>s "
				+ "in careful positions above the flame and soon you have made a real fire. ";
			fireburning = true;
			lightingfire = false;
			break;

		case "cookpig":
			msg = "You sit back and relax while the pig cooks on the fire. It smells delicious "
				+ "to your tired and hungry body.";
			cookedpig = true;
			removeInventory("dead pig");
			break;

		case "getpork":
			msg = "You eat some of the meat and keep the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rest2\')\">rest</span> "
				+ "for later.";
			resolvedporkissue = true;
			inventory.push("cooked pork");
			break;

		case "veggie":
			msg = "Are you crazy? I don\'t see any nuts or tofu on this island, do you? "
				+ "And anyway, if you don\'t eat it, the pig died for nothing! "
				+ "<p>...well, fine. You don\'t eat any of the pork right now, "
				+ "you\'ll see how you feel about it later.</p>";
			resolvedporkissue = true;
			inventory.push("cooked pork");
			break;

		case "religious":
			msg = "I\'m "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pretty\')\">pretty</span> "
				+ "sure "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'godwouldforgiveyou\')\">God would forgive you</span> "				
				+ "in this time of great need... "
				+ "<p>Well anyway, you\'re not dying of hunger just yet so you don\'t eat "
				+ "any pork. You do take it with you though. ";
			resolvedporkissue = true;
			inventory.push("cooked pork");
			break;

		}

	setupscene();
	}




function showBeach()
	{
	//alert ("in showX()");
	//msg = "";

	if(justentered)
		{
		msg = "You are on a beautiful but lonely beach. "
			+ "The clear, blue sky above and the smooth, white sand below "
			+ "help you forget your fears for your "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'survive\')\">survival</span>. "
			+ "<p>The beach continues to the west and east.</p>"
			+ "<p>To the north is a thick, "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tropical\')\">tropical</span> "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle.</span> "
			+ "The <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foliage\')\">foliage</span> is too "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'dense\')\">dense</span> "
			+ "to walk through but you can see an animal "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span> "
			+ "that you could use.</p>";
		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	if(!checkInventory("compass"))
		{
		addoption("Look at the entrance to the animal <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>.", "lookattrail");
		}

	if (!cutdownthornbush && lookedatthornbush)
		{
		addoption("Push your way through the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'thorn\')\">thorn</span> bush.", "pushthroughthorns");
		addoption("Pull the thorn bush down with your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bare\')\">bare</span> hands.", "pulldownthorns");
		}

	if (!cutdownthornbush && lookedatthornbush && checkInventory("stick"))
		{
		addoption("Knock the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'thorn\')\">thorn</span>s aside with your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span>.", "hitthornswithstick");
		}

	if (!cutdownthornbush && lookedatthornbush && checkInventory("machete"))
		{
		addoption("Cut the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'thorn\')\">thorn</span> bush down with your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'machete\')\">machete</span> .", "cutdownthorns");
		}

	if (checkInventory("compass"))
		{
		if(beentopilot)
			{
			addoption("Use your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span> to <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span> from the beach to the unlucky pilot.", "gotopilot");
			}

		if(beentofruittrees)
			{
			addoption("Use your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span> to <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span> from the beach to the fruit trees.", "gotofruittrees");
			}

		
		if(beentococonuttrees)
			{
			addoption("Use your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span> to <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span> from the beach to the coconut trees.", "gotococonuttrees");
			}

		if(beentowaterfall)
			{
			addoption("Use your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span> to <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span> from the beach to the waterfall.", "gotowaterfall");
			}

		if(beentovines)
			{
			addoption("Use your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span> to <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span> from the beach to the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'vine\')\">vine</span>s.", "gotovines");
			}

		if(beentoclearing)
			{
			addoption("Use your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'compass\')\">compass</span> to <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'navigate\')\">navigate</span> from the beach to the clearing at the top of the cliff.", "gotoclearing");
			}
		}


	showmsg("inputarea", options);



	//movement buttons
	if (cutdownthornbush)
		{
		showpaths("n", "w", "e");
		}
	else
		{
		showpaths("w", "e");
		}

	}






function beachInteract(input)
	{
	//alert("in beachInteract()");
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			lookedatthornbush = false;
			curScene = 6;
			break;

		case "w":			
			justentered = true; //reset global variable for next scene
			lookedatthornbush = false;
			curScene = 2;
			break;

		case "e":			
			justentered = true; //reset global variable for next scene
			lookedatthhornbush = false;
			curScene = 3;
			break;

		case "gotopilot":			
			justentered = true; //reset global variable for next scene
			curScene = 12;
			break;

		case "gotofruittrees":			
			justentered = true; //reset global variable for next scene
			curScene = 5;
			break;
		
		case "gotococonuttrees":			
			justentered = true; //reset global variable for next scene
			curScene = 19;
			break;

		case "gotowaterfall":			
			justentered = true; //reset global variable for next scene
			curScene = 16;
			break;

		
		case "gotovines":			
			justentered = true; //reset global variable for next scene
			curScene = 28;
			break;

		case "gotoclearing":			
			justentered = true; //reset global variable for next scene
			curScene = 24;
			break;

		case "lookattrail":
			if (cutdownthornbush)
				{
				msg = "The path leads deep into the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. "
					+ "You hope it wasn\'t made by anything too big and scary."
					+ "<p>It looks like it will be easy to get lost in there but if you want "
					+ "to try find things to help you leave the island, you must go in.</p>";
				}
			else
				{
				msg = "You can see a path leading into the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span> "
					+ "but the entrance is blocked by a dangerous-looking "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'thorn\')\">thorn</span> "
					+ "bush.";
				lookedatthornbush = true;
				}
			break;

		case "pushthroughthorns":
			msg = "Yes, that\'s a great idea! Let\'s start our "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'struggle\')\">struggle</span> "
				+ "to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'survive\')\">survive</span> "
				+ "with "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'heavy2\')\">heavy</span> "
				+ "blood loss!"
				+ "<p>Those "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'thorn\')\">thorn</span>s "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'havegottogo\')\">have got to go</span> "
				+ "before you can get to the animal "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>.</p>";
			break;

		case "pulldownthorns":
			msg = "Ouch! No way are you doing that with "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bare\')\">bare</span> "
				+ "hands.";

				if(!checkInventory("machete") && !checkInventory("stick"))
					{
					msg += "<p>Maybe there\'s something lying around the beach that can help you...</p>";
					}
			break;

		case "hitthornswithstick":
			msg = "You try and smash the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'thorn\')\">thorn</span> "
				+ "bush out of the way with your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span> "
				+ "of "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'driftwood\')\">driftwood</span>. "
				+ "However, the bush is really tough and soon your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stick\')\">stick</span> "
 				+ "breaks. "
				+ "<p>Lots of big, sharp "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bare\')\">thorn</span>s "
				+ "still block your way onto the animal "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span>.</p>";
			removeInventory("stick");
			break;

		case "cutdownthorns":
			msg = "You safely cut away the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'thorn\')\">thorn</span>s. "
				+ "The way is now clear for you to enter the animal "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trail\')\">trail</span> "
				+ "into the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jungle\')\">jungle</span>. ";
			cutdownthornbush = true;
			break;	

		}

	setupscene();
	}






function interact(input)
	{
	//alert("in interact(input) and curScene = " + curScene );
	msg = "";  // clear message ready to be updated in room interact functions

	switch (curScene)
		{
		case 0:
			break;
		case 1:
			beachInteract(input);
			break;
		case 2:
			pebbleBeachInteract(input);
			break;
		case 3:
			cliffsInteract(input);
			break;
		case 4:
			j4Interact(input);
			break;
		case 5:
			fruitTreesInteract(input);
			break;
		case 6:
			j6Interact(input);
			break;
		case 7:
			j7Interact(input);
			break;
		case 8:
			j8Interact(input);
			break;
		case 9:
			j9Interact(input);
			break;
		case 10:
			j10Interact(input);
			break;
		case 11:
			j11Interact(input);
			break;
		case 12:
			crashSiteInteract(input);
			break;
		case 13:
			j13Interact(input);
			break;
		case 14:
			j14Interact(input);
			break;
		case 15:
			j15Interact(input);
			break;
		case 16:
			waterfallInteract(input);
			break;
		case 17:
			j17Interact(input);
			break;
		case 18:
			j18Interact(input);
			break;
		case 19:
			coconutTreesInteract(input);
			break;
		case 20:
			j20Interact(input);
			break;
		case 21:
			j21Interact(input);
			break;
		case 22:
			j22Interact(input);
			break;
		case 23:
			j23Interact(input);
			break;
		case 24:
			clearingInteract(input);
			break;
		case 25:
			j25Interact(input);
			break;
		case 26:
			j26Interact(input);
			break;
		case 27:
			j27Interact(input);
			break;
		case 28:
			vinesInteract(input);
			break;


		}		
	}


function setupscene()
	{
	//alert("in setupscene()" + "curScene = " + curScene);	

	showInventory();

	switch (curScene)
		{
		case 0:
			break;		
		case 1:
			showBeach();
			break;
		case 2:
			showPebbleBeach();
			break;
		case 3:
			showCliffs();
			break;
		case 4:
			showj4();
			break;
		case 5:
			showFruitTrees();
			break;
		case 6:
			showj6();
			break;
		case 7:
			showj7();
			break;
		case 8:
			showj8();
			break;
		case 9:
			showj9();
			break;
		case 10:
			showj10();
			break;
		case 11:
			showj11();
			break;
		case 12:
			showCrashSite();
			break;
		case 13:
			showj13();
			break;
		case 14:
			showj14();
			break;
		case 15:
			showj15();
			break;
		case 16:
			showWaterfall();
			break;
		case 17:
			showj17();
			break;
		case 18:
			showj18();
			break;
		case 19:
			showCoconutTrees();
			break;
		case 20:
			showj20();
			break;
		case 21:
			showj21();
			break;
		case 22:
			showj22();
			break;
		case 23:
			showj23();
			break;
		case 24:
			showClearing();
			break;
		case 25:
			showj25();
			break;
		case 26:
			showj26();
			break;
		case 27:
			showj27();
			break;
		case 28:
			showVines();
			break;
		case 29:
			showEndScene();
			break;
		}
	}

