/*
+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pile\')\">pile</span> "
*/

var curScene = 1;
var msg = "";
var options = "";
var inventory = new Array();
var score = 0;

var justentered = true;

var helpon = true;   //so there can be gameplay help initially

/*event global monitors - to get rid of these need an event handler function or object - next ver perhaps?*/

var invitedtoplay = false;    //Main beach
var foundwallet = false;

var givenmanwallet = false;  //West beach

var sunbathed = false;		//west shore
var sunburnt = false;
var thrownoctsafely = false;

var wentforaswim = false;	//main shore
var helpedkidsbuildsandcastle = false;	
var gotbucket = false;
var kidshasslingyou = false;
var givenkidsbucket = false;
var triedtosmackkids = false;

var thrownoctnearsurfer = false; 	//rockpools
var lookedinrockpool = false;
var caughtcrabs = false;


var savedboy = false;		//cliffs
var talkedtoboy = false;
var boyrefusedtogiveoct = false;







function setwordhelp(word)
	{
	//alert("in wordhelp");

	var definition = "";	

	switch (word)
		{
		case "accidentally":
			definition = "If you do something <em>accidentally</em> it means you did it without a plan. "
				+ "Like a mistake.";
			break;

		case "bodysurf":
			definition = "To surf without a surfboard. You just lie flat and ride the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wave2\')\">wave</span>. ";
			break;

		case "blueringedoct":
			definition = "An <em>octopus</em> is a soft-bodied sea animal with a round body and "
				+ "eight legs. A <em>blue-ringed octopus</em> is a special kind of octopus that "
				+ "lives in Australia. It is very small but very dangerous because it has powerful "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'venom\')\">venom</span>. " 
				+ "If it bites you, you stop breathing "
				+ "and can die. When this kind of octopus is happy it has no special colour but when it is "
				+ "angry it changes and has blue rings everywhere on it\'s body.";
			break;

		case "break":
			definition = "A rest.";
			break;
		
		case "breeze":
			definition = "A small wind.";
			break;

		case "bucket":
			definition = "<img src='images/bucket.png' alt='Picture of a bucket'/>";
			break;

		case "castle":
			definition = "<img src='images/castle.png' alt='Picture of a castle'/>";
			break;

		case "carry":
			definition = "To <em>carry</em> something means to hold it and take it somewhere.";
			break;

		case "claw":
			definition = "<img src='images/claw.png' alt='Picture of a crab claw'/>";
			break;

		case "cliff":
			definition = "<img src='images/cliff.png' alt='Diagram of a cliff'/>";
			break;

		case "close":
			definition = "Near.";
			break;

		case "cokehabit":
			definition = "You are not quite sure what he means. Maybe he likes to drink lots of "
				+ "Coca Cola?";
			break;

		case "crab":
			definition = "A <em>crab</em> is an animal that lives in the sea and walks sideways. "
				+ "It has eight main legs and also two "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'claw\')\">claw</span>s. ";
			break;

		case "crowded":
			definition = "<em>Crowded</em> is an adjective that means many people are in one place.";
			break;

		case "crunch":
			definition = "<em>Crunch</em> is the sound you hear when you walk on snow or dry leaves. "
				+ "<p>Or when you eat biscuits/chips/rice crackers.</p>";
			break;

		case "doze":
			definition = "<em>Doze</em> can be a verb or a noun. It means <em>small sleep</em>."
			break;

		case "embarrassed":
			definition = "This is the feeling you get when you think people are laughing or looking at you.";
			break;

		case "evil":
			definition = "<em>Evil</em> is the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'opposite\')\">opposite</span> "
				+ "of <em>good</em>. "
				+ "Adolf Hitler was evil. Darth Vader was evil. In this case you can\'t help but "
				+ "remember Damien from \"The Omen\" as an example of <em>evil</em>.";
			break;

		case "exchange":
			definition = "To give one thing so you can get another, often similar, thing.";
			break;

		case "finish":
			definition = "<em>Finish</em> can be a verb or a noun. It means <em>stop</em> "
				+ "or <em>end</em>.";
			break;

		case "flag":
			definition = "<img src='images/flag.png' alt='Picture of a flag'/>";
			break;

		case "forages":
			definition = "A long time.";
			break;

		case "grateful":
			definition = "This is an adjective for someone who is <em>happy</em> and <em>thankful</em> about a " 
				+"good thing that someone has done for them.";
			break;

		case "gentle":
			definition = "Soft, weak, kind.";
			break; 

		case "join":
			definition = "If some people are doing something and you <em>join</em> in, you start doing it "
				+ "together with them.";
			break;

		case "lap":
			definition = "In this case, <em>lap</em> is a verb and it is the action of the water from the "
				+ "sea "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'gentle\')\">gentl</span>y "
				+ " touching the sand.";
			break;

		case "near":
			definition = "Close.";
			break;

		case "opposite":
			definition = "Up is the opposite of down. Big is the opposite of small. Fast is the opposite of slow.";
			break;

		case "pleasant":
			definition = "This is an adjective used for things that feel good.";
			break;

		case "pretty":
			definition = "<em>Pretty</em> means \"middle level\". It is stronger than \"a little\" "
				+ "but weaker than \"very\"."
				+ "<p>The adjective that means <em>beautiful</em> is different from this meaning of "
				+ "<em>pretty</em>.</p>";
			break;

		case "poison":
			definition = "<em>Poison</em> is something that is dangerous or can kill you if it enters your "
				+ "body, usually by eating or drinking it.";
			break;

		case "polite":
			definition = "<em>Polite</em> people are nice to others and don\'t shout and always say "
				+ "\"please\" and \"thank you\".";
			break;	

		case "quite":
			definition = "<em>Quite</em> means \"middle level\". It is stronger than \"a little\" "
				+ "but weaker than \"very\".";
			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 "relieved":
			definition = "You feel <em>relieved</em> when you are safe AFTER something "
				+ "dangerous or worrying has "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'finish\')\">finish</span>ed.";
			break;

		case "rockpool":
			definition = "At the beach you can often find <em>rockpools</em>: holes in the rocks "
				+ "filled with water and often little plants and sea animals.";
			break;

		case "sandcastle":
			definition = "A sandcastle is a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'castle\')\">castle</span> "
				+ "made out of sand.";
			break;

		case "scream":
			definition = "<em>Scream</em> can be a noun or a verb. It means (to use) a very loud voice.";
			break;

		case "seagull":
			definition = "A kind of bird that lives by the sea.";
			break;

		case "seaweed":
			definition = "A plant that lives in the sea.";
			break;

		case "seem":
			definition = "It <em>seems</em> = it <em>looks like<em>.";
			break;

		case "shady":
			definition = "This is an adjective for an area where there is no sun.";
			break;

		case "shore":
			definition = "Where the sea meets the land.";
			break;
		
		case "smack":
			definition = "To hit with an open hand.";
			break;

		case "soccer":
			definition = "<em>Soccer</em> is the word people in Australia and the U.S. use for \"football\".";
			break;

		case "spade":
			definition = "<img src='images/spade.png' alt='picture of a spade'/>";
			break;

		case "squawk":
			definition = "A sound a bird makes.";
			break;

		case "stepon":
			definition = "To <em>step on</em> something means to stand on it with your foot.";
			break;

		case "still":
			definition = "Here <em>still</em> means <em>but</em> or <em>however</em>. <p>This is different from "
				+ "the adjective <em>still</em> that means <em>not moving</em>.</p>";
			break;

		case "sunbathe":
			definition = "This is a verb that means to lie down, relax and enjoy sunshine.";
			break;

		case "sunscreen":
			definition = "You put this on your skin to stop the sun from burning you. Other names are "
				+ "\"sunblock\" and \"sun tan lotion\".";
			break;

		case "tear":
			definition = "The noun <em>tear</em> means water that comes from your eyes when you cry.";
			break;

		case "tightly":
			definition = "Here, the adverb <em>tightly</em> means <em>strongly</em>.";
			break;

		case "wallet":
			definition = "A <em>wallet</em> is what men keep their money in. Women often use a purse.";
			break;

		case "wave1":
			definition = "A verb that means to move your hand to say \"hello\" or \"goodbye\" "
				+ "without speaking.";
			break;


		case "wave2":
			definition = "<img src='images/wave2.png' alt='Diagram of a wave'/>";
			break;

		case "wing":
			definition = "The side of the game area in a sport like rugby, soccer or basketball. "
				+ "Not the centre.";
			break;

		case "venom":
			definition = "<em>Venom</em> is a noun. It is "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'poison\')\">poison</span> "
				+ "that enters your body when an animal bites you. "
				+ "<p>The adjective form is <em>venomous</em>.<p>";
			break;

		case "yet":
			definition = "When <em>yet</em> is used in an English sentence, it shows that things will maybe "
				+ "change in the future.";
			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 = "#FFF68F";  //khaki1
		setTimeout ('document.getElementById("maintext").style.backgroundColor = "#fcfbe8"', 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 showEndScene()
	{
	msg = "You drive home in your car.";

	msg += "<p>Today at the beach you...</p>";
		if(foundwallet)
			{
			msg += "played beach "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'soccer\')\">soccer</span><br /> ";
			score += 1;
			}

		if(wentforaswim)
			{
			msg += "went for a swim<br /> ";
			score += 1;
			}

		if(sunbathed)
			{
			msg += "sunbathed<br /> ";
			score += 1;
			}

		if(!sunburnt && sunbathed)
			{
			msg += "didn\'t get sunburnt while "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">sunbath</span>ing<br /> ";
			score += 1;
			}

		if(givenmanwallet)
			{
			msg += "gave a man back his <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wallet\')\">wallet</span><br /> ";
			score += 1;
			}

		if(helpedkidsbuildsandcastle)
			{
			msg += "built a <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sandcastle\')\">sandcastle</span><br /> ";
			score += 1;
			}

		if(caughtcrabs)
			{
			msg += "caught <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s<br /> ";
			score += 1;
			}

		if(savedboy)
			{
			msg += "saved a boy from an angry, <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">blue-ringed octopus</span><br /> ";
			score += 1;
			}
	
		if(thrownoctsafely)
			{
			msg += "didn\'t "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'accidentally\')\">accidentally</span> "
				+ "kill a surfer with an angry, "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">blue-ringed octopus</span><br /> ";
			score += 1;
			}

		if(givenkidsbucket)
			{
			msg += "gave a <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
				+ "back to some kids even though they weren\'t very "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'polite\')\">polite</span><br /> ";
			score += 1;
			}

	if(score === 0)
		{
		msg += "did nothing. Try harder next time.";
		setwordhelp("");   //because it looks stupid if you drive home straight away with the initial text here
		}

	msg += "<p>You scored " + score + " out of 10.</p>";

	if( (score > 0) && (score < 5) )
		{
		msg += "<p>Is this your first try? You can do better next time!</p>";
		}

	if( (score > 4) && (score < 7) )
		{
		msg += "<p>That\'s an OK score, see if you can get higher next time.</p>";
		}

	if( (score > 6) && (score < 9) )
		{
		msg += "<p>Good work!</p>";
		}


	if(score === 9)
		{
		msg += "<p>Great going! Sooooo close to a perfect score...</p>";
		}



	if(score === 10)
		{
		msg += "<p>CONGRATULATIONS! You are a top-level text adventurer!</p>";
		}



	showmsg("maintext", msg);
	
	options = "";
	
	showmsg("inputarea", options);

	showpaths("");

	document.getElementById("look").disabled = true;	

	}



function showCliffs()
	{
	//alert ("in showCliffs()");


	if(justentered)
		{

		msg = "You arrive at the end of the beach. It is "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shady\')\">shady</span> "
			+ "here because of some tall "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>s. ";
		if (!savedboy)
			{
			msg += "<p>There is a boy of about 8 or 9 standing at the bottom of the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>s "
			+ "looking happily into a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> that he is "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'carry\')\">carry</span>ing. ";
			if(checkInventory("bucket") || checkInventory("three crabs in a bucket"))
				{
				msg += "It is small and white and looks just like yours. ";
				}
			msg += "</p> ";
			}
		msg += "<p> From here you can go north to the water or west back to the centre of the beach.</p>";		

		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	
	addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">Sunbathe</span>. ", "sunbathe");

	if(!talkedtoboy)
		{
		addoption("Talk to the boy.", "talktoboy");
		}

	if (talkedtoboy && !savedboy)
		{
		addoption("Take the angry, <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">blue-ringed octopus</span> from the boy.", "takeoctfromboy");
		}

	if (boyrefusedtogiveoct && checkInventory("three crabs in a bucket") && !savedboy)
		{
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'exchange\')\">Exchange</span> your <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s for the octopus.", "giveboycrabs");
		}

	showmsg("inputarea", options);


	//movement buttons
	showpaths("n", "w");

	}






function cliffsInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "north":
			justentered = true; //reset global variable for next scene
			curScene = 6;
			break;			

		case "west":
			justentered = true; //reset global variable for next scene
			curScene = 2;
			break;

		case "sunbathe":
			msg += "It is too "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shady\')\">shady</span> to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">sunbathe</span> "
				+ "here.";
			break;

		case "talktoboy":
			msg += "The boy shows you inside his "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span>. "
				+ "\"Look at what I found,\" he says with a big smile. "
				+ "<p>Inside the bucket you can	see an "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">octopus</span>.<p> "
				+ "It has bright, blue rings all over its body.</p>";
				talkedtoboy = true;
			break;

		case "takeoctfromboy":
			msg += "You try to tell the boy how dangerous the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">blue-ringed octopus</span> "
				+ "is but he won\'t listen. When you try to take the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
				+ "from him he just holds on more "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tightly\')\">tightly</span> "
				+ "and shouts, \"No! It\'s mine!\"";
			boyrefusedtogiveoct = true;
			break;

		case "giveboycrabs":
			msg += "You show your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
				+ "of "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s "		
				+ "to the boy. He "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'seem\')\">seem</span>s "
				+ "interested and looks closely. "
				+ "\"OK,\" he says. \"If you give me the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s, "
				+ "I\'ll give you the octopus. It\'s only "
				+ "a little baby octopus anyway.\""
				+ "<p>You "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'exchange\')\">exchange</span> "
				+ "your "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
				+ "for one with an angry, "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">blue-ringed octopus</span> "
				+ "in it. Great! You\'ve saved the boy, but now what are you going to do? If you leave the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
				+ "on the beach, some other kid will just come along and pick it up.</p>";
			removeInventory("three crabs in a bucket");
			inventory.push("an angry, blue-ringed octopus in a bucket");
			savedboy = true;
		break;
			

		}

	setupscene();
	}







function showRockpools()
	{
	//msg = "";

	if(justentered)
		{

		msg = "In this area you can see some "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rockpool\')\">rockpool</span>s "
			+ "at the bottom of the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>s "
			+ "at the end of the beach.";

		if(thrownoctnearsurfer)
			{
			msg += "<p>You can\'t see the surfer anymore. Maybe he came back to the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shore\')\">shore</span> "
				+ "safely when you weren\'t looking...?</p>";
			}

		if(!thrownoctnearsurfer)
			{
			msg += "<p>There are lots of big "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wave2\')\">wave</span>s "
				+ "in the sea here. You can see a surfer enjoying riding them.</p>"
			}


		msg += "<p>If you go west from here you will come to the middle of the beach. The "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>s "
			+ "continue up the beach to the south. </p>";
		



		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	
	addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">Sunbathe</span>. ", "sunbathe");

	addoption("Go for a swim.", "goforaswim");

	addoption("Look in the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rockpool\')\">rockpool</span>s. ", "lookinrockpools");

	if(lookedinrockpool && !caughtcrabs)
		{
		addoption("Pick up some of the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s.", "getcrabs");
		}

	if(checkInventory("an angry, blue-ringed octopus in a bucket"))
		{
		addoption("Throw the octopus from the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> out into the sea.", "throwoctnearsurfer");
		}


	showmsg("inputarea", options);

	//movement buttons
	showpaths("w", "s");

	}






function rockpoolsInteract(input)
	{
	msg = "";

	switch (input)
		{
		case "west":			
			justentered = true; //reset global variable for next scene
			curScene = 5;
			break;

		case "south":
			justentered = true;
			curScene = 7;
			break;

		case "sunbathe":
			msg += "It is too "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shady\')\">shady</span> to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">sunbathe</span> "
				+ "here.";
			break;

		case "goforaswim":
			msg += "It might not be safe here. You should swim in the middle of "
				+ "the beach between the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'flag\')\">flag</span>s. ";
			break;
		
		case "lookinrockpools":
			msg += "Looking closely into a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rockpool\')\">rockpool</span> "
				+ "you can see lots of little "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s "
				+ "trying to hide under some "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'seaweed\')\">seaweed</span>. ";

			lookedinrockpool = true;
			break;

		case "getcrabs":
			if (checkInventory("bucket"))
				{
			
				msg += "The "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s "
					+ "are small so they are not dangerous. However, you are careful of their "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'claw\')\">claw</span>s "					
					+ "as you "
					+ "put your hand in the pool and pick up three and put them in your "
					+ "(well, it\'s <em>yours</em> now ;) "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span>. ";
				
				removeInventory("bucket");
				inventory.push("three crabs in a bucket");
				caughtcrabs = true;
				}

			if (!checkInventory("bucket") && !caughtcrabs)
				{
				msg += "You have nothing to put the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s "
					+ "in even if you catch one.";
				}
			break;

		case "throwoctnearsurfer":
			msg += "You throw the octopus as far as you can into the ocean. It lands in the water near the surfer. "
				+ "Hmmm...";
			removeInventory("an angry, blue-ringed octopus in a bucket");
			inventory.push("bucket");
			thrownoctnearsurfer = true;
			break;
				

		}

	setupscene();
	}






function showMainShore()
	{
	//alert ("in showMainshore()");



	if(justentered)
		{
		if(checkInventory("an angry, blue-ringed octopus in a bucket") || checkInventory("bucket") || checkInventory("three crabs in a bucket"))
			{
			msg += "You are near the water in the middle of the beach. Suddenly the kids who you built the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sandcastle\')\">sandcastle</span> "
				+ "with run up to you and start jumping up and down and "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scream\')\">scream</span>ing, "
				+ "\"YOU TOOK OUR "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">BUCKET</span>! "
				+ "GIVE BACK "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">BUCKET</span> NOW!\""
				+ "<p>You can\'t think or do anything while they are shouting at you.</p>";
			kidshasslingyou = true;
			}

		else //if don't have any bucket on you
			{

			msg = "You are near the water in the middle of the beach. There are "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'flag\')\">flag</span>s "
				+ "showing that it is safe to swim here. Lots of people are having fun swimming "
				+ "and playing in the small "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wave2\')\">wave</span>s. "

			if(!helpedkidsbuildsandcastle)
				{
				msg += "<p>In the wet sand "			
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'near\')\">near</span> "
					+ "the water some little kids are building a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sandcastle\')\">sandcastle</span>. "
					+ "with a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
					+ "and "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'spade\')\">spade</span>. "
					+ "It is difficult for them and a little girl looks at you with "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tear\')\">tear</span>s "
					+ "in her eyes. \"Please help, I can\'t make good "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sandcastle\')\">sandcastle</span>,\" "
					+ "she cries.</p>";

				
				}
			}


		msg += "<p>To the west the beach looks quieter. To the east is a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shady\')\">shady</span> "
			+ "part of the beach near some "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>s "
			+ "and rocks. South is back towards the place where people are playing "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'soccer\')\">soccer</span>.</p> "





		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
		
	if(!kidshasslingyou)
		{

		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">Sunbathe</span>. ", "sunbathe");

		addoption("Go for a swim.", "goforaswim");

		if(!helpedkidsbuildsandcastle)
			{
			addoption("Help the kids build the sandcastle.", "helpkidsbuildsandcastle");
			}

		if(helpedkidsbuildsandcastle && !gotbucket)
			{
			addoption("Pick up the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> the little kids forgot.", "getbucket");
			}
		}

	if(kidshasslingyou && !givenkidsbucket)
		{
		addoption("Give the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> to the kids.", "givekidsbucket");
		if(savedboy)
			{		
			addoption("Tell the kids that it isn\'t their <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pile\')\">bucket</span>. ", "tellkidsaboutbucket");
			}
		if(!triedtosmackkids)
			{
			addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'smack\')\">Smack</span> one of the kids upside the head.", "smackkids");
			}
		}

	showmsg("inputarea", options);



	//movement buttons
	showpaths("s", "w", "e" );

	}






function mainShoreInteract(input)
	{
	//alert("in mainShoreInteract()");
	msg = "";

	switch (input)
		{
		
		case "west":			
			justentered = true; //reset global variable for next scene
			curScene = 4;
			break;


		case "east":			
			justentered = true;
			curScene = 6;
			break;

		case "south":			
			justentered = true; //reset global variable for next scene
			curScene = 2;
			break;
		
		case "sunbathe":
			msg += "It is a little noisy here. You want to lie down and relax "
				+ "somewhere quiet.";
			break;


		case "goforaswim":
			msg += "It is a little bit cold but after you are in the water and "
				+ "swimming around you feel great. You get some good exercise "
				+ "swimming between the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wave2\')\">wave</span>s "
				+ "before you finally "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bodysurf\')\">body surf</span> "
				+ "back to the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shore\')\">shore</span>. ";
			wentforaswim = true;
			if(checkInventory("sunscreen on"))
				{
				removeInventory("sunscreen on");
				}
			break;

		case "helpkidsbuildsandcastle":
			msg += "You sit down and spend some time helping the kids to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'finish\')\">finish</span> "
				+ "the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sandcastle\')\">sandcastle</span>. "
				+ "It\'s actually "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> "
				+ "fun but when you are "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'finish\')\">finish</span>ed "
	 			+ "the kids don\'t thank you. \""
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sandcastle\')\">Sandcastle</span> "
				+ "is boring,\" one of them says. Then they all run off down the beach, laughing."
				+ "<p>You stand up, feeling a little "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'embarrassed\')\">embarrassed</span>. "
				+ "Then you see the children forgot to take their little white "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
				+ "with them.</p>";

				helpedkidsbuildsandcastle = true;
			break;

		case "getbucket":
			msg += "You take the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span>. "
				+ "Maybe you can give it back to them you see them again. "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'still\')\">Still</span>, "				
				+ "they forgot about "
				+ "the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sandcastle\')\">sandcastle</span> "
				+ "you helped them with "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pretty\')\">pretty</span> "
				+ "quickly, maybe they\'ve forgotten about the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
				+ "too.";
			inventory.push("bucket");
			gotbucket = true;
			break;

		case "givekidsbucket":
			if(checkInventory("bucket"))
				{
				msg += "You give the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
					+ "back to the children. Again they don\'t say a word of thanks but "
					+ "they do stop "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scream\')\">scream</span>ing "
					+ "and run away laughing "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'evil\')\">evil</span>ly. "
					+ "As they go they "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stepon\')\">step on</span> "
					+ "the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sandcastle\')\">sandcastle</span> "
					+ "you made.";
				removeInventory("bucket");
				givenkidsbucket = true;
				kidshasslingyou = false;
				}

			if(checkInventory("three crabs in a bucket"))
				{
				msg += "You give the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
					+ "back to the children. One of them looks inside and sees the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crab\')\">crab</span>s. "
					+ "\"Ooo, delicious!\" she says. "
					+ "Again they don\'t say a word of thanks but "
					+ "they do stop "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scream\')\">scream</span>ing "
					+ "and run away laughing "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'evil\')\">evil</span>ly. "
					+ "<p>As they go, you can\'t see what they are doing but you think you hear a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crunch\')\">crunch</span>ing "
					+ "sound coming from the group.</p>";
				removeInventory("three crabs in a bucket");
				givenkidsbucket = true;
				kidshasslingyou = false;
				}

			if(checkInventory("an angry, blue-ringed octopus in a bucket"))
				{
				msg += "You just saved one kid from the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">blue-ringed octopus</span>. "
					+ "You can\'t give it to some other ones!";
				}
					
			break;
		
		case "tellkidsaboutbucket":
			msg += "You try to say that this "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> "
				+ "is a different one, but it doesn\'t work."
				+ "<p>\"IS OURS! IT\'S WHITE! YOU TOOK OUR "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">BUCKET!</span> "
				+ "GIVE BACK NOW!!!\"</p>";
			break;

		case "smackkids":
			msg += "What\'s wrong with you? I can\'t believe you chose that option! "
				+ "I\'m deleting it right now!";
			triedtosmackkids = true;
			break;





		}

	setupscene();
	}





function showWestShore()
	{


	if(justentered)
		{

		msg = "This is a quiet part of the beach. The water is "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'close\')\">close</span> "			
			+ "but there aren\'t any big "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wave2\')\">wave</span>s "
			+ "and you only hear a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'gentle\')\">gentle</span> "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lap\')\">lap</span>ping "
			+ "sound from the ocean. "
			+ "There are some "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'seagull\')\">seagull</span>s "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'squawk\')\">squawk</span>ing "
			+ "as they fly around but this is the most peaceful area of the beach you have seen. "
			+ "<p>From here you can go south up the beach or walk along the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shore\')\">shore</span> "
			+ "to the east.</p>";

		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";

	addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">Sunbathe</span>. ", "sunbathe");

	addoption("Go for a swim.", "goforaswim");

	if(checkInventory("an angry, blue-ringed octopus in a bucket"))
		{
		addoption("Throw the octopus from the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bucket\')\">bucket</span> out into the sea.", "throwoctsafely");
		}
	

	showmsg("inputarea", options);



	//movement buttons
	showpaths("e", "s");

	}






function westShoreInteract(input)
	{
	//alert("in westShoreInteract()");
	msg = "";

	switch (input)
		{

		case "east":			
			justentered = true; //reset global variable for next scene
			curScene = 5;
			break;

		case "south":			
			justentered = true; //reset global variable for next scene
			curScene = 3;
			break;

		case "goforaswim":
			if(thrownoctsafely)
				{
				msg += "What? With an angry "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">blue-ringed octopus</span> "
					+ "in the water? Are you crazy?";
				}
			else
				{
			
				msg += "There are rocks in the water here. You should swim in the middle of "
					+ "the beach between the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'flag\')\">flag</span>s. ";
				}
			break;

		case "sunbathe":
			msg += "You lie down, close your eyes and relax as you enjoy the "
				+ "warm sun on your body. Everything is so "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pleasant\')\">pleasant</span> "
				+ "that you "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'doze\')\">doze</span> "
				+ " off."
				+ "<p>After about half an hour you wake up, feeling "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quite\')\">quite</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'refreshed\')\">refreshed</span>.</p>";
				sunbathed = true;
				if(!checkInventory("sunscreen on"))
					{
					sunburnt = true;
					}
			break;

			setwesttables = true;
			break;

		case "throwoctsafely":
			msg += "You throw the octopus as far out to sea as you can. It lands safely with no one near it.";
			removeInventory("an angry, blue-ringed octopus in a bucket");
			inventory.push("bucket");
			thrownoctsafely = true;
			
			break;


			
		}

	setupscene();
	}




function showWestBeach()
	{
	//alert("in showWestBeach()");

	if(justentered)
		{
		
		msg = "This is the end of the beach. It is a popular area though. The sky is blue, "
			+ "The sun is shining and there is a warm, "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pleasant\')\">pleasant</span>, "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'breeze\')\">breeze</span>. "
			+ "<p>There are lots of people "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">sunbath</span>ing "
			+ "here. "

		if(!givenmanwallet)
			{
			msg += "One man is not relaxing. He is walking around, looking at the sand. Maybe "
				+ "he has lost something?";
			}
		if(givenmanwallet)
			{
			msg += "The man you gave the wallet to is lying down on a towel. He looks up at you, smiles and "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wave1\')\">waves</span>. ";
			}

		msg += "</p>";

		msg += "<p>To the east is the middle of the beach where lots of people are running and walking around. "
			+ "To the north, close to the water, the beach doesn't look so "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crowded\')\">crowded</span>.</p>";

		}

	
	showmsg("maintext", msg);
	justentered = false;


	//showoptions part of function
	options = "";
	
	addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">Sunbathe</span>. ", "sunbathe");

	if(!givenmanwallet)
		{
		addoption("Talk to the man.", "talktoman");
		}

	if(!givenmanwallet && checkInventory("wallet"))
		{	
		addoption("Give the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wallet\')\">wallet</span> to the man.", "givemanwallet");
		}

	if(givenmanwallet)
		{
		addoption("Put on <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunscreen\')\">sunscreen</span>.", "putonsunscreen");
		}



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "e");



	}




function westBeachInteract(input)
	{
	//alert("in westBeachInteract()");
	msg = "";

	switch (input)
		{
		case "north":
			justentered = true;
			curScene = 4;
			break;

		case "east":
			justentered = true;
			curScene = 2;
			break;

		case "sunbathe":
			msg += "It\'s too "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crowded\')\">crowded</span> "
				+ "here. There\'s no room to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">sunbathe</span>. ";
			break;

		case "talktoman":
			msg += "The man looks up at you for a second, \"I've lost my "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wallet\')\">wallet</span>. "
				+ "Have you seen one?\" "
				+ "He is very worried.";
			break;

		case "givemanwallet":
			msg += "You show the man the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wallet\')\">wallet</span> "
				+ "you found. \"Excuse me,\" you ask. \"Are you looking for this?\""
				+ "<p>He looks very "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'relieved\')\">relieved</span> "
				+ "as he takes the wallet from you. \"Thank you so much,\" he says. \"I\'ve been "
				+ "looking for this "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'forages\')\">for ages</span>!\""
				+ "<p>He is so "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'grateful\')\">grateful</span> "
				+ "that you feel very glad you found his "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wallet\')\">wallet</span> "
				+ "for him.</p> "
				+ "\"I need all the money for my "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cokehabit\')\">coke habit</span> "
				+ "but I wish I could give you something in return,\" he says. "
				+ "\"Hmmmm, the sun\'s really strong today. Maybe you could use some of my "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunscreen\')\">sunscreen</span>? "
				+ "Take as much as you like and come back anytime!\"";

			removeInventory("wallet");
			givenmanwallet = true; 
			break;

		case "putonsunscreen":
			if (checkInventory("sunscreen on"))
				{
				msg += "You still have lots of sunscreen on all over your body. You don\'t need anymore "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'yet\')\">yet</span>. ";
				}
			if (!checkInventory("sunscreen on"))
				{
				msg += "You rub "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunscreen\')\">sunscreen</span> "
					+ "all over your body. It takes some time, but you feel better knowing you are protected "
					+ "from the sun.";
				inventory.push("sunscreen on");
				}
			break;
				
		}

	setupscene();
	}

	



function showMainBeach()
	{
	//alert ("in showMainBeach()");
	//msg = "";

	if(justentered)
		{

		msg = "You are in the middle of the beach. You are far from the water and in this flat, open "
			+ "area some people are playing beach "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'soccer\')\">soccer</span>.";
		

		msg += "<p>To the west you can see some people "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">sunbath</span>ing. "
			+ "To the north there are people swimming in the sea. "
			+ "In the east there is a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'shady\')\">shady</span> "
			+ "area under some "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cliff\')\">cliff</span>s. "
			+ "If you want to go home, you can go south to the carpark.</p>";

		}


	if (helpon)
		{
		msg += "<span class=\"red\">"
			+ "<p>Click on "
			+ "\"<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">sunbathe</span>\" "
			+ "or "
			+ "\"talk to the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'soccer\')\">soccer</span> "
			+ "players\" at the bottom,</p>"
			+ "<p>OR</p>"
			+ "<p>click on the \"north\", \"south\", \"west\" or \"east\" buttons "
			+ "to go to a new place.</p>"
			+ "</span>";
		helpon = false;
		}


	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";

	addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'sunbathe\')\">Sunbathe</span>.", "sunbathe");
	
	if (!invitedtoplay)
		{
		addoption("Talk to the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'soccer\')\">soccer</span> players.", "talktosoccerplayer");
		}

	if (invitedtoplay)
		{
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'join\')\">Join</span> in the game.", "joingame");
		}

	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "w", "e");

	}






function mainBeachInteract(input)
	{
	//alert("in mainBeachInteract()" + " input = " + input);
	msg = "";

	switch (input)
		{
		case "north":			
			justentered = true; //reset global variable for next scene
			curScene = 5;
			break;

		case "south":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			//alert("In S in mainBeachInteract()" + "curScene = " + curScene);
			break;

		case "west":			
			justentered = true; //reset global variable for next scene
			curScene = 3;
			break;

		case "east":			
			justentered = true; //reset global variable for next scene
			curScene = 7;
			break;

		case "sunbathe":
			msg += "People are playing "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'soccer\')\">soccer</span> "
				+ "here! Do you want them to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stepon\')\">step on</span> "
				+ "you!!?";
			break;
		
		case "talktosoccerplayer":
			msg += "You wait until one of the players isn\'t busy. He sees you and calls out. "
				+ "\"Hey, do you want to play too?\"";

			invitedtoplay = true;
			break;

		case "joingame":
			msg += "You choose a team and start running up and down the beach playing "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'soccer\')\">soccer</span>. "
				+ "It\'s lots of fun!";

			if (foundwallet)
				{
				msg += "<p>After a while you get hot and tired so you stop for a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'break\')\">break</span>.</p>";
				}

			if (!foundwallet)
				{
				msg += "<p>Suddenly you get the ball and start running down the right "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wing\')\">wing</span> with it. "
				+ "There is no one between you and the goal so you try for a long shot and kick the "
				+ "ball as hard as you can! You miss the goal but your foot hits something "
				+ "under the sand. You stop playing and search in the sand. Soon you find a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wallet\')\">wallet</span>. "
				+ "Someone must have dropped it.</p> "
				+ "<p>You ask the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'soccer\')\">soccer</span> "
				+ "players, but it is not theirs. Maybe the owner is still at the beach...</p>";

				inventory.push("wallet");
				foundwallet = true;
				}
			break;
				
				
		}

	setupscene();
	}

	


function showCarpark()
	{
	//alert ("in showCarpark()");
	//var msg = "";
	
	if (justentered)
		{
		msg = "You are in a carpark. Your car is here. "
			+ "<p>It is hot in the carpark "
			+ "but to the north you can see a beautiful beach.</p>";
		}

	if (helpon)
		{
		msg += "<span class=\"red\">"
			+ "<p>You can click on the \"north\" button (at the top) "
			+ "to go to the beach.</p>"
			+ "<p>You can click on \"Drive home in your car\" "
			+ "(at the bottom) to "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'finish\')\">finish</span> "
			+ "the game and see your score.</p>"
			+ "</span>";
		}

	else
		{
		msg += "<span class=\"red\">"
			+ "<p>If you drive home the game will "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'finish\')\">finish</span> "
			+ "and you will see your score.</p>"
			+ "</span>";
		}


	showmsg("maintext", msg);
	justentered = false;

	
	options = "";
	
	addoption("Drive home in your car.", "drivehome");

	
	showmsg("inputarea", options);


	//movement buttons
	showpaths("n");

	
	
	}


function carparkInteract(input)
	{
	//alert("in kitchenInteract()");	
	//msg = "";

	switch (input)
		{
		case "north":
			justentered = true;
			curScene = 2;
			break;


		case "drivehome":
			if (checkInventory("an angry, blue-ringed octopus in a bucket"))
				{
				msg += "You really don\'t want to drive home with a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'blueringedoct\')\">blue-ringed octopus</span>. ";
				}
			else
				{
				curScene = 8; //end scene!
				}
			break;

		}

	setupscene();
	//showmsg("maintext", msg);
	//showmsg("inputarea", options);

	}




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:
			carparkInteract(input);
			break;
		case 2:
			mainBeachInteract(input);
			break;
		case 3:
			westBeachInteract(input);
			break;
		case 4:
			westShoreInteract(input);
			break;
		case 5:
			mainShoreInteract(input);
			break;
		case 6:
			rockpoolsInteract(input);
			break;
		case 7:
			cliffsInteract(input);
			break;

		}		
	}


function setupscene()
	{
	//alert("in setupscene()" + "curScene = " + curScene);	

	showInventory();

	switch (curScene)
		{
		case 0:
			break;
		
		case 1:
			showCarpark();
			break;
		
		case 2:
			showMainBeach();
			break;
		
		case 3:
			showWestBeach();
			break;

		case 4:
			showWestShore();
			break;

		case 5:
			showMainShore();
			break;

		case 6:
			showRockpools();
			break;

		case 7:
			showCliffs();
			break;

		case 8:
			showEndScene();
			break;
		}
	}


