


//remember if we've found the object
var havefound = false;



//view change callback
function viewchange(x, y, dir, inst)
{
	//if we've already found the object, do nothing
	// if(havefound) { return; }

	//if the found object element is currently present, remove it
	var obj = document.getElementById('foundobject');
	if(obj) { obj.parentNode.removeChild(obj); }
	
	
	
	var xArr = [0,0,0,0,0,6,6];
	var yArr = [4,16,14,14,14,4,12];
	var dirArr = [0,0,0,1,3,1,2];
	var picArr = ['dots.gif','undefined','undefined','img1.gif','img2.gif','undefined','dots.gif'];
	var wordsArr = ['first words','Look left and right at your next step','You\'re here.   Look right and left.', 'On the Right, they thought ...','On the Left, they thought ...','second words', 'third words third words  third words  third words  third words  third words  third words third words  third words  third words  third words  third words   third words third words  third words  third words  third words  third words    ']

	//if we reach the end position
	for(z=0;z<xArr.length;z++)
	{
	if(x == xArr[z] && dir == dirArr[z])
	{
		//standing in front of the object
		if((y == yArr[z]))
		{
			//get a reference to the dungeon view's parent element
			if(picArr[z] != 'undefined')
			{
			var parent = inst.dungeon.parentNode;

			//create the found object, inside the parent,
			//superimposed on top of everything else
			//(and so that in source order this will also come out after the caption)
			obj = parent.appendChild(inst.tools.createElement('div', {
					'id' : 'foundobject'
					
					}));
			
			var myImg = document.createElement("img");
			myImg.setAttribute("src", picArr[z]);
			myImg.setAttribute("height",200);
			myImg.setAttribute("width",300);
			obj.appendChild(myImg);

			//move it to center position and show it
			obj.style.left = (parent.offsetWidth / 2) - (obj.offsetWidth / 2) - 0 + 'px';
			obj.style.top = (parent.offsetHeight / 2) - (obj.offsetHeight / 2) - 70 + 'px';
			obj.style.visibility = 'visible';
			}
			//add to the captiontext
			var caption = inst.captiontext.appendChild(inst.tools.createElement('strong'));
			caption.appendChild(document.createTextNode(wordsArr[z]));
		}

		
		
	}
	}
}

