//Mouse coordinates and image popup code
//Important: Function is called using the onload (seen below) that can be found in the body of each adventure story
//window.onload = cordInit;

function cordInit() {
  if (window.Event) {
    document.captureEvents(Event.MOUSEMOVE);
  }
  document.onmousemove = getXY;
}

function getXY(e) {
	x = (window.Event) ? e.pageX : event.clientX;
	y = (window.Event) ? e.pageY : event.clientY;
	
}

function Xpand(imgURL,pos) {
	var imgName = 'http://www.thelivingsea.com/images/adventures/' + imgURL + '.jpg';
	document.getElementById('largeImg').src=imgName;
	
	var image = new Image();
	image.src = imgName;
	var imgWidth = image.width;
	var imgHeight = image.height;

	var app=navigator.appName
	if (pos=="l") { // Use for images positioned on the left
		document.getElementById('imgLayer').style.left= x + 'px';
		if (app.indexOf('Microsoft') != -1) // Browser sniffer
		{
			document.getElementById('imgLayer').style.top = (document.documentElement.scrollTop + y) - imgHeight - 40 + 'px';
		}
		else 
		{
			document.getElementById('imgLayer').style.top = y - imgHeight - 40 + 'px';
		}
	} 
	else // Use for images positioned on the right
	{
		document.getElementById('imgLayer').style.left= x - imgWidth + 'px';
		if (app.indexOf('Microsoft') != -1) // Browser sniffer
		{
			document.getElementById('imgLayer').style.top = (document.documentElement.scrollTop + y) - imgHeight - 40 + 'px';
		}
		else 
		{
			document.getElementById('imgLayer').style.top = y - imgHeight - 40 + 'px';
		}
	} 
	
	document.getElementById('imgLayer').style.visibility='visible';

}

function hideXpand() {
	document.getElementById('imgLayer').style.visibility='hidden';
}

function BrowserInfo()
{
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
}
var browser = new BrowserInfo();

//Toggle div
function toggleDiv(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

//Window PopUp  
//Pop using: onclick="return PopUp('url.html','window name','height=200,width=150')"
function PopUp(url,name,attrib) {
	newwindow=window.open(url,name,attrib);
	if (window.focus) {newwindow.focus()}
	return false;
}