/*
+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pile\')\">pile</span> "
*/

var curScene = 1;
var msg = "";
var options = "";
var inventory = new Array();

var justentered = true;


/*event global monitors - to get rid of these need an event handler function or object - next ver perhaps?*/

var donewashingup = false;    //kitchen
var setwesttables = false;
var seteasttables = false;
var broughtfoodup = false;
var toldjessaboutgeoffrey = false;

var pickedupveggies = false;   //cellar
var knowaboutcider = false;
var gotcider = false;

var promoted = false;          //servants quarters
var knowaboutdress = false;

var advisorpresent = false;     //westdininghall
var givencidertoadvisor = false;
var dressnoticedbyadvisor = false;
var advisoraskedforcider = false;

var queenpresent = false; //east dining hall
var foodtasterpresent = false;

var portcullisup = false;  //central courtyard
var talkedtoguards = false;
var carlmadecrudecomments = false;
var flirtedwithcarl = false;
var rebukedcarl = false;
var helpedgeoffrey = false;
var helpinggeoffrey = false;








function setwordhelp(word)
	{
	//alert("in wordhelp");

	var definition = "";	

	switch (word)
		{
		case "address":
			definition = "The verb \"address\" means \"talk to\".";
			break;

		case "adorn":
			definition = "Decorate.";
			break;

		case "alarming":
			definition = "Surprising/worrying.";
			break;

		case "alteration":
			definition = "An alteration is a <em>change</em> made to something, often to fix or improve it.";
			break;

		case "aptto":
			definition = "Likely to, has a tendency to.";
			break;

		case "array":
			definition = "A mixed group of objects. Often organised in some way, like in rows and columns.";
			break;

		case "attendto":
			definition = "To attend to something means \"to do\" or \"take care of\".";
			break; 

		case "attire":
			definition = "Clothes, dress.";
			break;
		
		case "barely":
			definition = "Hardly, just, only a little.";
			break;

		case "barracks":
			definition = "A living and training area for soldiers.";
			break;

		case "boisterous":
			definition = "Boisterous is loud, merry and happy.";
			break;

		case "brazen":
			definition = "The adjective \"brazen\" means <em>bold</em> or <em>very direct</em>.";
			break;

		case "bunkbeds":
			definition = "A set of two (or more) beds that is built so one bed is above another.";
			break;

		case "buxom":
			definition = "A very old-style adjective that means \"big breasted\".";
			break;

		case "campaign":
			definition = "A military mission over an extended period of time.";
			break;

		case "chambermaid":
			definition = "A chamber maid takes care of bedrooms.";
			break;

		case "chastened":
			definition = "When someone is feeling chastened, they are sorry and apologetic after being rebuked for "
				+ "doing something wrong.";
			break;
		
		case "coarsecommunicativestyle":
			definition = "Rough, very casual way of speaking.";
			break;

		case "competent":
			definition = "Capable. Can do things well.";
			break;

		case "conspiratorial":
			definition = "A conspiracy is a group of people keeping a (usually big) secret from everyone else. "
				+ "In this context the advisor is suggesting he is sharing a secret with you in a friendly, joking way.";
			break;

		case "content":
			definition = "Satisfied. Happy with the way things are.";
			break;

		case "cordial":
			definition = "Cordial means <em>polite and friendly</em>.";
			break;

		case "crass":
			definition = "Crude, impolite, insensitive.";
			break;

		case "cutlery":
			definition = "Knives, forks, spoons etc.";
			break;

		case "depict":
			definition = "Show, illustrate.";
			break;

		case "dignitary":
			definition = "A dignitary is a person of high rank. This word is often used to refer to the important "
				+ "people at an event or meeting.";
			break;

		case "discreet":
			definition = "To be discreet is to be <em>careful and secretive</em>. Indiscreet is the opposite and is often used "
				+ "to describe someone who says or does something they shouldn\'t.";
			break;

		case "dowdy":
			definition = "Lacking in style or fashionable appeal.";
			break;

		case "drape":
			definition = "To put or lay something in a way that it is over or across something else."; 
			break;

		case "draw":
			definition = "Draw can be used with a preposition to show continued movement in the indicated direction. "
				+ "If you \"draw near\" or \"draw close to\" something, you go towards it.";
			break;

		case "earnestly":
			definition = "Seriously.";
			break;

		case "endeavour":
			definition = "To try to do something. \"Endeavour\" implies a grand task that involves time or effort and "
				+ "can also be used as a noun.";
			break;

		case "fancy":
			definition = "To fancy is a very English way of saying \"to <em>like</em>\".";
			break;

		case "feeble":
			definition = "Weak.";
			break;

		case "fetching":
			definition = "Attractive. Fetching clothes suit the wearer.";
			break;
		
		case "flighty":
			definition = "Likely to do something unpredictable. Random, unreliable, always changing in mood and maybe "
				+ "a little bit crazy.";
			break;

		case "flirt":
			definition = "To communicate with someone such a way as to make yourself appear friendly and attractive.";
			break;

		case "foodtaster":
			definition = "A King\'s food-taster eats a little of a meal first, to check if it is poisoned.";
			break;

		case "getstuckinto":
			definition = "To get stuck into something is a casual way of saying "
				+ "someone attempts a (usually) big task with reasonable effort. "
				+ "It can also mean \"to scold\" or \"tell off\" in some casual "
				+ "Australian English.";
			break;
		
		case "gist":
			definition = "The main points, the general idea.";
			break;

		case "grubby":
			definition = "Grubby means <em>dirty</em>.";
			break;

		case "havethenerve":
			definition = "Be brave enough.";
			break;

		case "hismajesty":
			definition = "His Majesty is used to refer to a king. Her Majesty is used to refer to a queen.";
			break;
		
		case "hitch":
			definition = "Hitch is a verb that means to <em>tie</em> or <em>connect</em> something to something else.";
			break;
	
		case "inlightof":
			definition = "\"In light of\" is used when some information shows something about another situation. "
				+ "For example: \"In light of the outcome of World War II, Hitler perhaps made a tactical mistake "
				+ "in attacking Russia after the invasion of England failed.\"";
			break; 

		case "innit":
			definition = "Innit? is a casual contraction of \"isn\'t it?\", itself coming from the full \"is it not?\".";
			break;

		case "itinerant":
			definition = "Always travelling from place to place. Not staying in a fixed home.";
			break;

		case "jovial":
			definition = "Friendly, unthreatening.";
			break;

		case "keep":
			definition = "The noun \"keep\" refers to the inner building of a castle. Attacking enemies would sometimes have to "
				+ "get past several layers of outer walls to access it.";
			break;		

		case "lad":
			definition = "Lad is an old style English word meaning <em>boy</em> or <em>young man</em>. It is still used a lot"
				+ " in the British Isles.";
			break;

		case "lass":
			definition = "Lass is an old style English word meaning <em>girl</em> or <em>young woman</em>. It is still used a lot"
				+ " in the British Isles.";
			break;
		
		case "longshot":
			definition = "A long shot has only a small chance of succeeding.";
			break;
		
		case "magnificent":
			definition = "An adjective meaning <em>grand</em> or <em>impressive</em>.";
			break;


		case "massive":
			definition = "Big. Very big.";
			break;

		case "mindyou":
			definition = "A phrase that means <em>though</em> or <em>however</em>.";
			break;

		case "morethanyourlifeisworth":
			definition = "An act that is \"more than -something- is worth\" means that doing it will negate -something-. "
				+ "For example, if you do something that is \"more than your job is worth\" you could lose your job doing it.";
			break;

		case "nestle":
			definition = "The verb \"nestle\" means to put yourself somewhere comfortably. A baby nestles closer "
				+ "to it\'s mother. A small building can be nestled against a larger building. Nestle does NOT "
				+ "have anything to do with chocolate or coffee, and is pronounced to rhyme with \"castle\".";
			break;

		case "noncommittaltone":
			definition = "Speaking without showing a personal opinion one way or another.";
			break; 

		case "overwhelming":
			definition = "An over-whelming amount is too many to understand or deal with.";
			break;

		case "peasant":
			definition = "A peasant was of the lowest ranked medieval farming/working class.";
			break;

		case "portal": //removed
			definition = "Portal = door. Couldn\'t you guess this one?";
			break;

		case "portcullis":
			definition = "A type of <em>medieval gate</em> used to protect the entrance to castles. "
				+ "It looks a little like a big, flat, metal \"net\" made of vertical and horizontal iron bars."
				+ "The bottom of the vertical bars were often pointed, similar to a row of spears aimed at the ground.";
			break;

		case "pile":		
			definition = "A pile is a <em>stack</em> or <em>heap</em>. "
				+ "Many similar objects put on top of each other.";
			break;

		case "putinagoodword":
			definition = "To \"put in a good word\" for someone means to talk positively about them to someone else. "
				+ "For example: \"I\'ll put in a good word for you to the boss.\"";
			break;

		case "quarters":
			definition = "Living or sleeping area.";
			break;
		
		case "rebuke":
			definition = "Tell-off, scold, admonish.";
			break;

		case "scramble":
			definition = "To <em>climb</em> or <em>crawl</em>. Often in an undignified manner.";
			break;

		case "scullerymaid":
			definition = "A scullery is a section of the pantry or kitchen in old-style houses where food preparation "
				+ "took place. A scullery maid worked as a kitchen hand, chopping and cleaning food or washing up.";
			break;

		case "settable":
			definition = "Setting a table means preparing it for the arrival of the meal "
				+ "by laying out plates and knives and forks etc.";
			break;

		case "stallion":
			definition = "A stallion is a <em>male horse</em>.";
			break;	

		case "stint":
			definition = "At stint is a period of time spent doing something.";
			break;

		case "stuckup":
			definition = "A stuck up person often doesn't like to talk to people they think are lower than themselves, socially.";
			break;

		case "takeashineto":
			definition = "Taking a shine to something means \"taking a liking to\" or \"taking an interest in\" it.";
			break;

		case "takein":
			definition = "In this case \"take in\" means \"look at\". When you take something in you properly pay attention "
				+ "and appreciate it.";
			break;
		
		case "traipse":
			definition = "To traipse is to wander/walk/travel around. It implies a slight meaninglessness.";
			break;

		case "trough":
			definition = "A container: a big, long drinking or feeding \"bowl\" for animals that many can use at once.";
			break;

		case "tub":
			definition = "A large bowl for temporarily storing water.";
			break;
	
		case "tuttut":
			definition = "A term used to gently scold or show disapproval.";
			break;

		case "warrant":
			definition = "People don\'t use \"warrant\" much in this way nowadays but it means \"I think it\'s likely\" "
				+ "or \"I bet\".";
			break;
		
		case "wench":
			definition = "A casual medieval term for \"woman\". It can be disrespectful used in the wrong way.";
			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 = "#B2DFEE";  //lightblue2
		setTimeout ('document.getElementById("maintext").style.backgroundColor = "#dcf5fe"', 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 = "Congratulations! You made it from "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scullerymaid\')\">scullery maid</span> "
		+ "to upstairs "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'chambermaid\')\">chamber maid</span>. "
		+ "<p>You are happy with how quickly you\'ve improved your fortunes here in the castle but you can\'t "
		+ "help thinking about how much further you could rise. But for now you are "
		+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'content\')\">content</span>.</p>"
		+ "THE END .... ?";

	showmsg("maintext", msg);
	
	options = "";
	
	showmsg("inputarea", options);

	showpaths("");

	document.getElementById("look").disabled = true;	

	}



function showCentralCourtyard()
	{
	//alert ("in showCentralCourtyard()");
	//msg = "";

	portcullisup = false;

	if(justentered)
		{

		msg = "This is the <strong>central courtyard</strong>. Everybody accessing the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'keep\')\">keep</span> "
			+ "has to come through here so there are always guards present. ";
		msg += "Inside the courtyard there is one guard standing to each side of the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'massive\')\">massive</span> "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'portcullis\')\">portcullis</span> "
			+ "which is currently ";
		if(!portcullisup)
			{
			msg += "lowered. Even if it were not, you doubt you\'d be allowed past without official business.";
			}
		else
			{
			msg += "raised.";
			}

		

		msg += "<p>"
			+ "There is the main dining hall entrance to the east and "
			+ "you can also walk into the northern or southern parts of the courtyard.</p>";

		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	if(!talkedtoguards)
		{
		addoption("Talk to the guards.", "talktoguards");
		}

	if(talkedtoguards && carlmadecrudecomments && !flirtedwithcarl &&!rebukedcarl)
		{	
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'flirt\')\">Flirt</span> with Carl.", "flirtwithcarl");
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'rebuke\')\">Rebuke</span> Carl for his <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'crass\')\">crass</span> remarks.", "rebukecarl");
		}

	if(talkedtoguards)
		{
		addoption("Talk to Carl.", "talktocarl");
		addoption("Talk to Geoffrey.", "talktogeoffrey");		
		}
 

	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "w", "e");

	}






function centralCourtyardInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "north":			
			if(!promoted)
				{
				msg += "As you start north one of the guards yells out "					
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'jovial\')\">jovial</span>ly "
					+ "yet with authority, \"Hey you! Scullery "	
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'wench\')\">wench</span>! "
					+ "Shouldn\'t you be preparing dinner in the kitchen instead of wandering around the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'barracks\')\">barracks</span>? "
					+ "Not that all of the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lad\')\">lad</span>s "
					+ "would mind, "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'mindyou\')\">mind you</span>,\" "
					+ "he adds with a wink at his companion. ";
				}
			break;

		case "south":
			justentered = true; //reset global variable for next scene
			curScene = 6;
			break;
				

		case "west":
			msg += "Your place is here in the castle, not "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'traipse\')\">traipsing</span> "
				+ "around the countryside like an "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'itinerant\')\">itinerant</span> "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'peasant\')\">peasant</span>. ";
			break;

		case "east":
			justentered = true; //reset global variable for next scene
			curScene = 4;
			break;

		case "talktoguards":
			if(checkInventory("on a nice dress"))
				{
				msg += "\"Well, hello there!\" One of the guards "
	 				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'boisterous\')\">boisterous</span>ly "
					+ "greets you while "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'takein\')\">taking in</span> "
					+ "your figure top-to-toe in an "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'alarming\')\">alarming</span>ly "				
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'discreet\')\">indiscreet</span> manner. "
					+ "He turns to his comrade, \"Here, Geoffrey! I <em>told</em> you today was going to be interesting "
					+ "and I\'ll "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'warrant\')\">warrant</span> "
					+ "this "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'buxom\')\">buxom</span> "
					+ "young "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lass\')\">lass</span> "
					+ "has more on her mind than the dishes in the kitchen.\""
					+ "<p>\"My name is Carl.\" The guard introduces himself, at last making an attempt at manners. "
					+ "He finishes with a polite,\"I\'m pleased to meet you.\" But you are not entirely comforted "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'inlightof\')\">in light of</span> "
					+ "his very recent comments.</p>"

				talkedtoguards = true;
				carlmadecrudecomments = true;
				}

			if(!checkInventory("on a nice dress"))
				{
				msg += "\"Hello miss, my name is Carl and this Geoffrey,\" one of the guards greets you and introduces "
					+ "his companion.";
				talkedtoguards = true;

 
				}
			break;

		case "talktocarl":
			{
			if(checkInventory("on a nice dress") &&!rebukedcarl)
				{
				msg+= "Carl looks at you with mischief in his eyes and "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'brazen\')\">brazen</span>ly "
					+ "declares, \"You look like the sort of "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lass\')\">lass</span> "
					+ "who\'s "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'aptto\')\">apt to</span> "
					+ "bring some fun to this place.\"";
				carlmadecrudecomments = true;
				}


			if(!checkInventory("on a nice dress") || rebukedcarl)
				{
				msg += "\"Good day to you miss.\" Carl "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cordial\')\">cordial</span>ly "
					+ "greets you.";
				}
			}
			break;

		case "flirtwithcarl":
			if(checkInventory("on a nice dress"))
				{
				msg += "\"Good day to you, worthy man-at-arms.\" You greet the soldier with a sweet smile. "
					+ "\"I trust you\'re doing a good job keeping us safe here in the castle?\""
					+ "<p>\"A job I\'ll work even harder at now I know there are "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lass\')\">lass</span>es "
					+ "like you around. \'Tis good to see you ain\'t as "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stuckup\')\">stuck up</span> "
					+ "as some.\" Carl seems quite pleased that someone has chosen to brighten up his day "
					+ "in spite of his somewhat "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'coarsecommunicativestyle\')\">coarse communicative style</span>.</p>"; 
				flirtedwithcarl=true;
				}
			if(!checkInventory("on a nice dress"))
				{
				msg += "Carl is friendly enough when you chat to him, but it\'s obvious you're not making "
					+ "much of an impression on him.";
				}
			break;

		case "rebukecarl":
			msg += "\"I\'m sorry to disappoint you sir, \" you address Carl coldly. \"I have many duties at this castle "
				+ "but I can assure you that none involve entertaining "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'feeble\')\">feeble</span>-minded "
				+ "foot-soldiers such as yourself!\""
				+ "<p>Carl seems suitably "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'chastened\')\">chastened</span> "
				+ "so you add, \"I\'m sure we can be friends, <em>if</em> and <em>only if</em> you learn to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'address\')\">address</span> "
				+ "people with a little more respect.\"</p>";
			rebukedcarl = true;
			break;

		case "talktogeoffrey":
			//alert("in talk to geoffrey");
			if(!helpedgeoffrey && !toldjessaboutgeoffrey)
				{
				msg += "\"Excuse me miss, it\'s \'Penny\', isn\'t it?\" Geoffrey begins. "
					+ "\"If you\'re friends with Jess in the kitchen, could you do me a big favour "
					+ "and find out what time she finishes work tonight? I, er, have some matters I "
					+ "would like to discuss with her but the captain\'s got me on the gate here until midnight!\""
					+ "<p>\"And....er...\" he adds, looking a little embarrassed. \"If it\'s not asking too much, "
					+ "could you possibly "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'putinagoodword\')\">put in a good word </span> "
					+ "for me with her?</p>";
				helpinggeoffrey = true;
				}

			if(helpedgeoffrey)
				{	
				msg += "\"Good day to you Penny, thanks again for helping me,\" says Geoffrey happily.";
				}

			if(toldjessaboutgeoffrey &&!helpedgeoffrey)
				{
				msg += "You let Geoffrey know the "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'gist\')\">gist</span> "
					+ "of what Jess said. Even though you don\'t go into the enthusiasm of her response, "
					+ "the young guard seems very pleased.";
				if(!promoted)
					{
					msg += "<p>\"Thank you so much Penny! If <em>I</em> could be of any help to <em>you</em> "
						+ "it might be worth mentioning I came across a bottle of the Dorset Cider when the "
						+ "matron had us down in the cellar after those "
						+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'massive\')\">massive</span> "
						+ "rats that were too big for your traps. It was on the top shelves "
						+ "at the very back, behind a box with \'carrots\' written on it. I\'m sure " 
						+ "someone\'s wondering where it is.\"";
					knowaboutcider = true;
					}
				helpedgeoffrey = true;
				helpinggeoffrey = false;
				}

			
			break;

		}

	setupscene();
	}







function showSouthCourtyard()
	{
	//alert ("in showCellar()");
	//msg = "";

	if(justentered)
		{

		msg = "You are outside at the <strong>southern</strong> end of a long, spacious <strong>courtyard</strong>. "
			+ "This is an open area that separates the inner "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'keep\')\">keep</span> "
			+ "from the strong, outer castle walls. "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'nestle\')\">Nestle</span>d "
			+ "against the southern wall are the inner castle stables."
			+ "<p>Roderick the stable-boy is attending to a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'magnificent\')\">magnificent</span> but "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'flighty\')\">flighty</span>-"
			+ "looking "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stallion\')\">stallion</span> "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'hitch\')\">hitch</span>ed up "
			+ "to a large drinking "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'trough\')\">trough</span>.</p>";
		

		msg += "<p>You can walk north to the central courtyard or east inside to the kitchen.</p>";

		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	addoption("Talk to Roderick.", "talktoroderick");



	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "e");

	}






function southCourtyardInteract(input)
	{
	//alert("in southCourtyardInteract()");
	msg = "";

	switch (input)
		{
		case "north":			
			justentered = true; //reset global variable for next scene
			curScene = 7;
			//alert ("leaving southcourtyard");
			break;

		case "east":
			justentered = true;
			curScene = 1;
			break;

		case "talktoroderick":
			msg += "Roderick attempts to look down his nose as he talks to you. \"Go away! I\'m busy doing "
				+ "<em>important</em> things, like looking after Lord Somerset\'s horse. I don\'t need "
				+ "an annoying little "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scullerymaid\')\">scullery maid</span> "
				+ "getting in the way!\""
				+ "<p>Roderick is always complaining about his low-ranking job in the castle and you guess he is trying "
				+ "to make himself feel better by insulting you, possibly the only person with officially "
				+ "lower status. </p>";
			break;		

		}

	setupscene();
	}






function showEastDiningHall()
	{
	//alert ("in showCellar()");
	//msg = "";

	queenpresent = true;
	foodtasterpresent = true;

	if(justentered)
		{

		msg = "You are in the <strong>eastern</strong> end of the <strong>great dining hall</strong>. "
			+ "There is a balcony overhead that is part of the second floor of the "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'keep\')\">keep</span>. "
			+ "The rows of tables lead up to the king's table which is on a slightly raised section of floor "
			+ "at the far east end of the room."

		if(queenpresent && foodtasterpresent)
			{
			msg += "<p>On a bench in front of the king\'s table you can see seated casually but talking "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'earnestly\')\">earnestly</span>, "
				+ "the queen and Jeremy, the royal "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foodtaster\')\">food-taster</span>.</p>"

			}

		msg += "<p>There are no doors at this end of the hall.</p>";

		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";


	if(queenpresent)
		{
		addoption("Talk to the queen.", "talktoqueen");
		}

	if(foodtasterpresent)
		{
		addoption("Talk to the <span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foodtaster\')\">food-taster</span>.", "talktofoodtaster");
		}


	if(!seteasttables)
		{
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'settable\')\">Set the tables.</span>", "seteasttables");
		}

	showmsg("inputarea", options);



	//movement buttons
	showpaths("w");

	}






function eastDiningHallInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		
		case "west":			
			justentered = true; //reset global variable for next scene
			curScene = 4;
			break;


		case "talktoqueen":			
			msg += "The queen smiles sweetly at you. \"Thank you for doing an excellent job here at the castle. "
				+ "Keep up the good work!\"";
			break;

		case "talktofoodtaster":
			msg += "Jeremy obviously doesn\'t want to stop paying attention to the queen in order to talk to you.";
			break;

		case "seteasttables":
			msg += "You quietly set to work on the tables at this end of the dining hall. "
				+ "As you "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'draw\')\">draw</span> "
				+ "near the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'foodtaster\')\">food-taster</span> "
				+ "and the queen, their conversation falls silent, but they don\'t "
				+ "interrupt you in your work.";
		
			seteasttables = true;
			break;
		}

	setupscene();
	}





function showWestDiningHall()
	{
	//alert ("in showCellar()");
	//msg = "";

	if(!givencidertoadvisor && !promoted)
		{
		advisorpresent = true;
		}

	if(justentered)
		{

		msg = "You are in the <strong>western</strong> half of the <strong>great dining hall</strong>. Rows of tables stretch from here into the eastern section. "
			+ "The walls are "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'adorn\')\">adorn</span>ed "
			+ "with paintings "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'depict\')\">depict</span>ing "
			+ "great historical events.";

		if(advisorpresent)
			{
			msg += "<p>The King\'s chief advisor, Ignatius, is here. He seems to be looking for something.</p>";
			}		

		msg += "<p>Doors lead north to the audience room and west to the central courtyard. You can also walk east to the other "
			+ "end of the hall or south into the kitchen.</p>";

		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	

	if(advisorpresent)
		{
		addoption("Talk to the advisor.", "talktoadvisor");
		}

	if(checkInventory("cider") && advisoraskedforcider)
		{
		addoption("Give the cider to the advisor.", "giveadvisorcider")
		}

	if(!setwesttables)
		{
		addoption("<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'settable\')\">Set the tables.</span>", "setwesttables");
		}

	addoption("Look at the pictures.", "lookatpictures");  //initally useless til you know more from the historian

	showmsg("inputarea", options);



	//movement buttons
	showpaths("n", "s", "w", "e");

	}






function westDiningHallInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "north":
			if(!promoted) //ie the advisor is in the room
				{
				msg += "The King is holding an audience with some important "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'dignitary\')\">dignitaries</span> " 
					+ "in the next room. Everyone knows you are supposed to be working in the kitchen preparing for tonight and it\'s "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'morethanyourlifeisworth\')\">more than your job - and possibly your life - is worth</span> "
					+ " to interrupt!";
				break;
				}	
			justentered = true; //reset global variable for next scene
			curScene = 9;
			break;

		case "west":			
			justentered = true; //reset global variable for next scene
			curScene = 7;
			break;

		case "east":			
			justentered = true; //reset global variable for next scene
			curScene = 5;
			break;

		case "south":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			break;

		case "setwesttables":
			msg += "You work long and hard setting up plates, cups, "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'cutlery\')\">cutlery</span> "
				+ "and generally arranging everything to look nice.";
			setwesttables = true;
			break;

		case "talktoadvisor":
			if(checkInventory("on a nice dress") && !dressnoticedbyadvisor)
				{
				msg += "The advisor notes your "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'attire\')\">attire</span> "
					+ "and says, \"I must say miss, you <em>are</em> one of our more "
					+ "presentable staff! I shall "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'endeavour\')\">endeavour</span> "
					+ "to mention it to the King.<br /><br />";
				dressnoticedbyadvisor = true;
				}

			msg += "\"Perhaps <em>you</em> could help me, young "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scullerymaid\')\">scullery maid</span>,\" "
				+ "says Ignatius. \"It\'s "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'longshot\')\">a long shot</span> "
				+ "but I was having a bit of a hunt around for any of the cider left over from "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'hismajesty\')\">His Majesty</span>\'s "
				+ "Dorset "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'campaign\')\">campaign</span>. "
				+ "I am aware that was some time ago, but if you find a bottle anywhere, be sure to let me know.\" "
				+ "<p>The advisor leans forward with a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'conspiratorial\')\">conspiratorial</span> "
				+ "wink. \"I do believe the King would like to use it "
				+ "as a talking point with his guests tonight.\"</p>";
			advisoraskedforcider = true;
			break;

		case "giveadvisorcider":
			msg += "\"Why, that\'s a bottle of the Dorset Cider!\" Ignatius happily exclaims. "
				+ "\"The King will be so pleased, and I\'ll be sure to "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'putinagoodword\')\">put in a good word</span> "
				+ "for you with Matron Maude.\""
				+ "<p>The advisor thanks you and leaves the room to the south.</p>";
			
			advisorpresent = false;
			removeInventory("cider");
			givencidertoadvisor = true;
			break;
			
				

		case "lookatpictures":
			msg += "You recognise the King in at least one of them. He appears to be leading an army to victory in a grand battle "
			+ "at the foot of a mountain somewhere."; //add to this later
			
		}

	setupscene();
	}




function showServantsQuarters()
	{
	//alert("in showServantsQuarters()");

	if(justentered)
		{
		//msg = "<p><strong>Servants' Quarters</strong></p>";
		
		msg += "You are in the <strong>servants\' "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quarters\')\">quarters</span></strong>. "
			+ "Rows of "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'bunkbeds\')\">bunk beds</span> "
			+ "make this room feel quite cramped. ";
 
		if(checkInventory("on a nice dress"))
			{			
			msg += "Your work dress is "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'drape\')\">drape</span>d "			
				+ "over your bed.";
			}
		
		if(!checkInventory("on a nice dress"))
			{			
			msg += "A nice dress is "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'drape\')\">drape</span>d "			
				+ "over your bed.";
			}

		msg += " In the south-east corner there are stairs leading upwards.</p>"
			+ "<p>The head servant, Matron Maude, is sitting at a table doing some sewing. "
			+ "She looks up at you briefly but doesn't pause in her work.</p>";

		msg += "<p>From this room you can either go west to the kitchen or climb the stairs to the second floor.</p>";


		}

	
	showmsg("maintext", msg);
	justentered = false;


	//showoptions part of function
	options = "";
	
	addoption("Talk to Matron Maude.", "talktomatron");

	addoption("Change into the clothes that are on your bed.", "changeclothes");

	showmsg("inputarea", options);



	//movement buttons
	showpaths("w", "u");



	}




function servantsQuartersInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "up":
			if (!promoted)
				{
				msg += "The Matron pauses in her sewing and says sternly, \""
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tuttut\')\">Tut tut</span> "
					+ "Penny, you know you've no business up there. You should be working here on the "
					+ "ground floor.\"";
				}
			
			if (promoted && checkInventory("on a nice dress"))
				{		
				msg += "You\'d better change out of the dress the Matron\'s working on before going upstairs.";		
				}

			if (promoted && !checkInventory("on a nice dress"))
				{		
				justentered = true; //reset global variable for next scene
				curScene = 11;
				}
			break;

		case "west":
			justentered = true;
			curScene = 1;
			break;

		case "talktomatron":
			//alert("in talk to matron");
			if(donewashingup && seteasttables && setwesttables && broughtfoodup && givencidertoadvisor)
				{
				//alert("In matron promoting you.");
				msg += "The Matron looks at you thoughtfully. \"You know lass, you\'ve been doing an "
					+ "excellent job as a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scullerymaid\')\">scullery maid</span>. "					
					+ "I\'m especially impressed that you managed to find "
					+ "another bottle of the king\'s favourite cider. We need a new chamber maid and you have "
					+ "proven yourself more than "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'competent\')\">competent</span> "
					+ "so I would like you start your new duties immediately. Please check on the state of the " 
					+ "bedrooms upstairs.";

				if(checkInventory("on a nice dress"))
					{
					msg += "<p>\"Oh, one more thing,\" Maude adds. \"I\'ll have that new dress back now. "
						+ "I still have to make some "
						+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'alteration\')\">alteration</span>s "
						+ "to it. You can\'t wear it all day!</p>";
					}
				promoted = true;
				break;
				}
			
			if(dressnoticedbyadvisor && flirtedwithcarl)
				{
				msg += "\"Your work here so far has been satisfactory.\" Matron Maude "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'address\')\">address</span>es "
					+ "you with a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'noncommittaltone\')\">non-committal tone</span>. "	
					+ "\"I\'m not especially impressed but "
					+ "word has got back to me that your general attitude is one the King appreciates. "
					+ "I think it\'s time you started work as a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'chambermaid\')\">chamber maid</span>. "
					+ "Please start "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'attendto\')\">attending to</span> "
					+ "to your new duties upstairs.\"";
				
				if(checkInventory("on a nice dress"))
					{
					msg += "<p>\"Oh, one more thing,\" Maude adds. \"I\'ll have that new dress back now. "
						+ "I still have to make some "
						+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'alteration\')\">alteration</span>s "
						+ "to it. You can\'t wear it all day!</p>";
					}
				promoted = true;
				break;
				}


			if(!knowaboutdress && !checkInventory("on a nice dress") )
				{
				msg += "\"Hello Penny.\" The Matron greets you. \"The King wants me to make some clothes that "
					+ "staff can wear on special occasions to look more presentable. One of my new designs "
					+ "is on your bed. It\'s not completely finished but feel free to try it on for a bit now, "
					+ "if you like.\"<br /><br />";
				knowaboutdress = true;
				}  
			msg += "\"If you're interested in fowarding your career here in the "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'keep\')\">keep</span> "
				+ "you will have to continue to prove yourself working hard as a "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scullerymaid\')\">scullery maid</span>"
				+ ",\" says Matron Maude."; 	
			break;

		case "changeclothes":
			if(checkInventory("on a nice dress"))
				{
				msg += "You quickly slip back into your comfortable and practical, but perhaps a little "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'dowdy\')\">dowdy</span>, "
					+ "old work clothes. You carefully fold up the nice dress and place it back on your bed.";
				removeInventory("on a nice dress");
				}
			else
				{
				msg += "You put on the nice new dress. It is somewhat low-cut and perhaps a little impractical for "
					+ "scullery work but you have to admit it <em>is</em> rather "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'fetching\')\">fetching</span>"
					+ ". You fold up your work dress and place it on your bed.";
				inventory.push("on a nice dress");
				}
			break;
		}

	setupscene();
	}

	



function showCellar()
	{
	//alert ("in showCellar()");
	//msg = "";

	if(justentered)
		{

		msg = "You are in a well-kept <strong>cellar</strong>. There is an "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'overwhelming\')\">over-whelming</span> "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'array\')\">array</span> "
			+ "of goods and foodstuffs stored in and on a variety of shelves, crates, racks and barrels.";

		if(!pickedupveggies)
			{
			msg += "<p>Close at hand on the bottom shelves you can see a number of vegetables that would be of use to Jess in her food preparation.";
			}

		msg += "<p>The only exit from the cellar is the stairs leading back up to the kitchen.</p>";

		}

	showmsg("maintext", msg);
	justentered = false;
	

	
	//showoptions part of function
	options = "";
	
	if(!pickedupveggies)
		{
		addoption("Pick up vegetables.", "getveggies");
		}

	if(!gotcider)
		{
		addoption("Look around the top shelves.", "lookontopshelves");
		}



	showmsg("inputarea", options);



	//movement buttons
	showpaths("u");

	}






function cellarInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "up":			
			justentered = true; //reset global variable for next scene
			curScene = 1;
			break;

		case "getveggies":
			msg += "You gather up several types of vegetables useful for cooking.";
			pickedupveggies = true;
			inventory.push("vegetables");  //one statement doesn't warrrant a whole function, like removeInventory, checkInventory
			break;
		
		case "lookontopshelves":
			if(checkInventory("on a nice dress"))
				{
				msg += "You would have to climb up and search really deeply to see if anything\'s up there. "
					+ "There\'s no way you could do that without getting Matron\'s precious new dress dirty.";
				}
			if(!checkInventory("on a nice dress") && knowaboutcider)
				{
				msg += "You "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scramble\')\">scramble</span> "
				+ "up to the top of the shelves and search around right at the back. Finally you find a bottle of "
				+ "cider behind an empty box marked \"carrots\", just like the guard said. "
				+ "You are a little "				
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'grubby\')\">grubbier</span> "
				+ "than before but it\'s "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'barely\')\">barely</span> "
				+ "noticable on your everyday work clothes.";
				inventory.push("cider");
				gotcider = true;
				}
			if(!checkInventory("on a nice dress") && !knowaboutcider)
				{
				msg += "You "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scramble\')\">scramble</span> "
				+ "up to the top of the shelves and search around. Even though you spend a lot of time and accidentally "
				+ "add a few scuff marks to your clothes, there\'s too much confusing junk to find anything useful.";
				}
		}

	setupscene();
	}

	


function showKitchen()
	{
	//alert ("in showKitchen()");
	//var msg = "";
	
	if (justentered)
		{
		msg = "You are in the castle's <strong>kitchen</strong>. As a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'scullerymaid\')\">scullery maid</span> "
			+ "this is where you spend most of your time working. ";
		

		if(!donewashingup)
			{
			msg += "There is a big "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'pile\')\">pile</span> "
			+ "of washing-up in a "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'tub\')\">tub</span> " 
			+ "on the left. ";
			}

		if(!setwesttables || !seteasttables || !broughtfoodup)
			{
			msg += "Your friend Jess is working busily at a bench on the right, ";
			msg += "preparing food. ";
			}

		msg += "<p>A door to the west leads into the open courtyard, one to the north leads to the dining hall and a third "
			+ "to the east leads to the servants\' "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'quarters\')\">quarters</span>. "
			+ "There are also some stairs leading down to the cellar.</p>";

		}


	showmsg("maintext", msg);
	justentered = false;

	
	//old showKitchenOptions function integrated
	options = "";
	
	if(!donewashingup)
		{
		addoption("Do the washing up.", "dowashingup"); 
		}

	addoption("Talk to Jess.", "talktojess");


	if(checkInventory("vegetables") && !broughtfoodup)
		{
		addoption("Give the vegetables to Jess.", "giveveggiestojess");
		}

	if(helpinggeoffrey && setwesttables && seteasttables && broughtfoodup &&!toldjessaboutgeoffrey)
		{
		addoption("Tell Jess that the guard, Geoffrey is interested in what time she\'s finishing.", "telljessaboutgeoffrey");
		}

	//alert(options);
	
	showmsg("inputarea", options);


	//movement buttons
	showpaths("n", "w", "e", "d");

	
	
	}


function kitchenInteract(input)
	{
	//alert("in kitchenInteract()");	
	//msg = "";

	switch (input)
		{
		case "north":
			justentered = true;
			curScene = 4;
			break;

		case "west":
			justentered = true;
			curScene = 6;
			break;

		case "east":
			justentered = true;
			curScene = 3;
			break;

		case "down":
			justentered = true; //reset global variable for next scene
			curScene = 2;
			//setupscene();
			break;

		case "dowashingup":
			msg += "You roll up your sleeves and ";
			msg += "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'getstuckinto\')\">get stuck into </span> ";
			msg += "the massive tower of dirty dishes, pots and pans. ";
			msg += "It takes quite some time but after all it ";
			msg += "<em>is</em> your job and you take some satisfaction in ";
			msg += "knowing you\'ve done it well.";
			donewashingup = true;
			break;

		case "talktojess":


			if(!setwesttables || !seteasttables || !broughtfoodup)
				{
				msg += "Jess doesn't even turn around from the chicken she\'s stuffing to address you.</p>"
					+ "<p>\"Look Penny, I\'d love to chat but I really am a bit behind here. I\'ve got to "
					+ "finish this chicken, ";
				if(!broughtfoodup)
					{
					msg += "bring some more vegetables up from the cellar, ";
					}
				if(setwesttables && seteasttables)
					{
					msg += "and cook the stew.\"";
					}
				if (!setwesttables || !seteasttables)
					{
					msg += "cook the stew and "
						+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'settable\')\">set the tables</span> "
						+ "in the main dining hall.\"";
					}
				msg +=  "<p>\"There\'s a lot to do before tonight you know!\"</p>";
		
				}
			
			else
				{
				msg += "Jess looks a little more relaxed now. She chats to you while stirring a big pot of stew.</p>"
					+ "<p>\"Whew, it\'s hard work down in the kitchen on days like these,"
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'innit\')\">innit</span>? "
					+ "I know you\'d maybe "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'fancy\')\">fancy</span> a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'stint\')\">stint</span> "
					+ "upstairs as a "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'chambermaid\')\">chamber maid</span> "
					+ "Well, the only way to that is to impress old Maude with "
					+ "a ton of hard work. Good luck to you there!\"</p>"
					+ "<p>Jess pauses for a second, as though recalling something then adds, "
					+ "\"still, there\'s no telling what could happen if the king "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'takeashineto\')\">takes a shine to</span> "
					+ " you. Not impossible for a pretty "
					+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'lass\')\">lass</span> "
					+ "like yourself,\" she concludes with a wink."; 
				}
			break;

		case "giveveggiestojess":
			msg += "You carefully place the vegetables on the bench next to your busy friend. She looks up and nods, grateful "
				+ "that she has one less task to perform.";
			broughtfoodup = true; 	
			removeInventory("vegetables");		
			break;

		case "telljessaboutgeoffrey":
			msg += "Jess is thrilled to hear about the guard. \"Oh, I was <em>wondering</em> when that handsome "
				+ "young man would "
				+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'havethenerve\')\">have the nerve</span> "
				+ "to say something to me! Still a little shy, it seems, but please let him know that I\'ll "
				+ "stop by the front gate tonight as soon as the Matron considers I'm finished with dinner duties.\""
				+ "<p>Jess returns to her stew with a smile on her face.</p>";
			toldjessaboutgeoffrey = true;
			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:
			kitchenInteract(input);
			break;
		case 2:
			cellarInteract(input);
			break;
		case 3:
			servantsQuartersInteract(input);
			break;
		case 4:
			westDiningHallInteract(input);
			break;
		case 5:
			eastDiningHallInteract(input);
			break;
		case 6:
			southCourtyardInteract(input);
			break;
		case 7:
			centralCourtyardInteract(input);
			break;

		}		
	}


function setupscene()
	{
	//alert("in setupscene()");	

	showInventory();

	switch (curScene)
		{
		case 0:
			break;
		
		case 1:
			showKitchen();
			break;
		
		case 2:
			showCellar();
			break;
		
		case 3:
			showServantsQuarters();
			break;

		case 4:
			showWestDiningHall();
			break;

		case 5:
			showEastDiningHall();
			break;

		case 6:
			showSouthCourtyard();
			break;

		case 7:
			showCentralCourtyard();
			break;

		case 11:
			showEndScene();
			break;
		}
	}

/*  use as a copy and paste template for new location functions
function showSouthCourtyard()
	{
	//alert ("in showCellar()");
	//msg = "";

	if(justentered)
		{

		msg = "You are outside at the <strong>southern</strong> end of a long, spacious <strong>courtyard</strong>. "
			+ "This is an open area that separates the inner "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'keep\')\">keep</span> "
			+ "from the strong, outer castle walls. "
			+ "<span class=\"hardvoc\" onmouseover=\"setwordhelp(\'nestle\')\">nestle</span>d "
			+ "against the southern wall are the inner castle stables."; 
		

		msg += "<p>You can walk north to the central courtyard or east inside to the kitchen.</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 southCourtyardInteract(input)
	{
	//alert("in cellarInteract()");
	msg = "";

	switch (input)
		{
		case "n":			
			justentered = true; //reset global variable for next scene
			curScene = 7;
			break;		

		}

	setupscene();
	}

*/
