function getObject(objectId) {
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId);
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId);
	}
	return false;
}

function getStyleObject(objectId) {
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
	}
	return false;
} 

function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight=window.innerHeight;
	} else {
		if (document.documentElement&&document.documentElement.clientHeight) {
			windowHeight=document.documentElement.clientHeight;
		} else {
			if (document.body&&document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getWindowWidth() {
	var windowWidth=0;
	if (typeof(window.innerWidth)=='number') {
		windowWidth=window.innerWidth;
	} else {
		if (document.documentElement&&document.documentElement.clientWidth) {
			windowWidth=document.documentElement.clientWidth;
		} else {
			if (document.body&&document.body.clientWidth) {
				windowWidth=document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function setHeight()
{
	var mainStyle = getStyleObject( "mainTable" );
	// 26px for the purple hasbro bar
	var nTableHeight = getWindowHeight() - 26;
	mainStyle.height = nTableHeight + "px";

	var bgStyle = getStyleObject( "background2" );
	var nContentHeight = getObject("mainTable").clientHeight;
	// offset for bottom bg image
	var yOffset = 320;
	var yPosition = nTableHeight - yOffset;
	if ( nContentHeight > nTableHeight ) {
		yPosition = nContentHeight - yOffset;
	}

	var xOffset = 754;
	var xPosition = Math.round( getWindowWidth() / 2 ) - xOffset;
	bgStyle.backgroundPosition = xPosition + 'px ' + yPosition + 'px';

}

var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var iePos  = appVer.indexOf('msie');
var is_ie   = ((iePos!=-1));
var is_safari = (agt.indexOf("safari")!=-1);
var is_firefox = (agt.indexOf("firefox")!=-1);

function switchNav(obj, img, color) {
	
	if( color == undefined ) {
		color = '';
	}
	
	
	var objStyle = getStyleObject(obj);
	var image = getObject(img);	

	if ( objStyle.display == "block" || objStyle.display == "table" ) {
		objStyle.display = "none";
		image.src = "http://www.hasbro.com/games/kid-games/heroscape/images/plus" + color + ".jpg";
	}
	else {
		objStyle.display = "block";
		image.src = "http://www.hasbro.com/games/kid-games/heroscape/images/minus" + color + ".jpg";
	}

	setHeight();

}

function hideNav(obj, img, color)
{
	if( color == undefined ) {
		color = '';
	}
	
	var objStyle = getStyleObject(obj);
	var image = getObject(img);
	objStyle.display = "none";
	image.src = "http://www.hasbro.com/games/kid-games/heroscape/images/plus" + color + ".jpg";

	setHeight();
}

function showNav(obj, img, color)
{
	if( color == undefined ) {
		color = '';
	}
	
	var objStyle = getStyleObject(obj);
	var image = getObject(img);
	objStyle.display = "block";
	image.src = "http://www.hasbro.com/games/kid-games/heroscape/images/minus" + color + ".jpg";

	setHeight();
}