// pre-load the rollover buttons
imgOne = new Image();
imgOne.src = "images/bOne.jpg";
imgTwo = new Image();
imgTwo.src = "images/bTwo.jpg";
imgThree = new Image();
imgThree.src = "images/bThree.jpg";
imgFour = new Image();
imgFour.src = "images/bFour.jpg";
imgFive = new Image();
imgFive.src = "images/bFive.jpg";
imgSix = new Image();
imgSix.src = "images/bSix.jpg";
imgSeven = new Image();
imgSeven.src = "images/bSeven.jpg";
imgEight = new Image();
imgEight.src = "images/bEight.jpg";
// mNum is the variable used to determine which of the three pop-up menus
// are active
var mNum = 0;
var mOpen = null;
var meID = null;
var idTemp = null;
var menuOff = null;
// eID - element ID : hexVal - hexidecimal value
function bkgrnd(eID, hexVal, onOff, menu, menuNum)
{
	// stop any active timer
	clearTimeout(menuOff);
	
	// close any open or pending menus and reset the text
	if(0 != mNum && menuNum != mNum)
	{
		document.getElementById(mOpen).style.visibility = "hidden";
		if("yellowCell" == meID)
		{
			//idTemp = meID;
			// switch the background color
			document.getElementById(meID).style.background = "#eacb1d";
			meID = null;
		}
		else if("greenCell" == meID)
		{
			//idTemp = meID;
			// switch the background color
			document.getElementById(meID).style.background = "#258b3f";
			meID = null;
		}
		else if("blueCell" == meID)
		{
			//idTemp = meID;
			// switch the background color
			document.getElementById(meID).style.background = "#0035ad";
			meID = null;
		}
	}
	// set the menu flag
	mNum = menuNum;
	mOpen = menu;
	meID = eID;
	if(null != menu) 
	{ 
		document.getElementById(menu).style.visibility = "visible";
	}
	// switch the cell and text colors
	if(1 == onOff)
	{
		// switch the background color
		document.getElementById(eID).style.background = hexVal;
	}
	else if(0 == onOff)
	{
		menuOff = setTimeout("show_menu('" + menu + "',0)", 1000);
	}
}
function mBkgrnd(eID, hexVal, onOff, menuNum, menu)
{
	if(0 != onOff && null != menuNum && menuNum == mNum)
	{
		clearTimeout(menuOff);
	}
	
	// switch the cell and text colors
	if(1 == onOff)
	{
		// switch the background color
		document.getElementById(eID).style.background = hexVal;
		// rename eID to match the text id
		eID = eID + "A";
		document.getElementById(eID).style.color = "#000000";
	}
	else if(0 == onOff)
	{
		// switch the background color
		document.getElementById(eID).style.background = hexVal;
		// rename eID to match the text id
		eID = eID + "A";
		document.getElementById(eID).style.color = "#ffffff";
		menuOff = setTimeout("show_menu('" + menu + "',0)", 1000);
	}
}
function spaceOver(eID, onOff)
{
	// a timer setting for empty spaces in the menus
	if(1 == onOff)
	{
		clearTimeout(menuOff);
	}
	else if(0 == onOff)
	{
		menuOff = setTimeout("show_menu('" + eID + "',0)", 1000);
	}
}
function show_menu(eID, onOff)
{	
	if(1 == onOff)
	{
		document.getElementById(eID).style.visibility = "visible";
	}
	else if(0 == onOff)
	{
		document.getElementById(eID).style.visibility = "hidden";

		if("yellowCell" == meID)
		{
			// switch the background color
			document.getElementById(meID).style.background = "#eacb1d";
			meID = null;
		}
		else if("greenCell" == meID)
		{
			// switch the background color
			document.getElementById(meID).style.background = "#258b3f";
			meID = null;
		}
		else if("blueCell" == meID)
		{
			// switch the background color
			document.getElementById(meID).style.background = "#0035ad";
			meID = null;
		}

		mNum = 0;
	}
}
function rollBtn(img,onOff)
{
	if(1 == onOff)
	{
		document.getElementById(img).src = "images/" + img + "_over.jpg";
	}
	else if(0 == onOff)
	{
		document.getElementById(img).src = "images/" + img + ".jpg";
	}
}
