menu = new Object();
menu.imgid = 99;
menu.mname = " ";
menu.id = "200";  //default first level menu item id
menu.subname = " ";
menu.menuType = " ";

subs = new Object();
subs.defaultid = "3200"; //default submenu item id this element  needs to exist
subs.id = subs.defaultid; 
subs.mname = " ";
subs.menuType = " ";

var isNav, isIE, isNN6, isMac;
var bubghigh, bubg, butext, busubbg, busubtext;
var corpobghigh, corpbg, corptext, corpsubbg, corpsubtext;
var menuWidth, corpMenuWidth, menuHeight;
var sub1, sub2, sub3, sub4, sub5, sub7, sub8;
var menuStartBU, menuStartCorp;

function setupMenuVars()  {
	
	isNav = false;
	isIE = false;
	isNN6 = false;
	isMac = false;
	
	// Browser Detection Code
	if (document.layers)
	    isNav = true;
	if (document.getElementById)
	    isNN6 = true;
	if (document.all) {
	    isIE = true;
	    isNN6 = false;
	}
	if (navigator.platform.indexOf("Mac") != -1)
	    isMac = true;
	    
	bubghigh = "#004BEE"; //main/sub nav highlighted bg  
	bubg = "#0081F0"; //main nav bg and text highlight colour  - match bunavItem in navigation.css
	butext = "#FFFFFF"; //text colour - match bunavLink in navigation.css
	busubbg = "#0081F0"; //sub nav bg  - match busubnavItem in navigation.css
	busubtext = "#FFFFFF"; //sub nav text colour - match busubnavLink in navigation.css
	
	corpbghigh = "#004BEE"; //main/sub nav for corp menu
	corpbg = "#0081F0"; //main nav bg and text highlight colour   - match corpnavItem in navigation.css
	corptext = "#FFFFFF"; //text colour - match corpnavLink in navigation.css
	corpsubbg = "#0081F0"; //sub nav bg  - match corpsubnavItem in navigation.css
	corpsubtext = "#FFFFFF"; //sub nav text colour - match corpsubnavLink in navigation.css
	
	// setup menu variables  -- must match the asp variable of the same name in navigation.asp
	menuWidth = 130;  // width of each menu item
	corpMenuWidth = 150; // width of each menu item in the corporate navbar
	menuHeight = 21;  // height of each menu item
	
	//the specified numbers for the sub## values must match the left value for this element in global.css
	//*no current submenu* sub1 = 240 + menuWidth; //distance of the 1st (my account) sub-menu level from the left 
	sub2 = 243 + menuWidth; //distance of the second (play now) sub-menu level from the left
	sub3 = 321 + menuWidth; //distance of the third (lottery) sub-menu level from the left
	//*no current submenu* sub4 = 416 + menuWidth; //distance of the fourth (casino) sub-menu level from the left
	//*no current submenu* sub5 = 509 + menuWidth; //distance of the fifth (bingo) sub-menu level from the left
	
	sub6 = 270 + corpMenuWidth; // distance of the sixth (did you win) sub-menu level from the left
	sub7 = 367 + corpMenuWidth; // distance of the seventh (how to play) sub-menu level from the left
	
	sub8 = 410 + corpMenuWidth; // distance of the eight (about bclc) sub-menu level from the left
	//*no current submenu* sub9 = 529 + corpMenuWidth; // distance of the nine (ben bc) sub-menu level from the left
	//*no current submenu* sub10 = 529 + corpMenuWidth; // distance of the ten (play responsibly) sub-menu level from the left
	
	//the specified numbers for the *InitialY values must match the top value for the elements in global.css
	var buInitialY = 79;  // space from the top of the browser to the first menu item
	var corpInitialY = 18;  // space from the top of the browser to the first menu item
	
	//the specified numbers added to *InitialY values must match the height of main menu graphical elements
	menuStartBU = buInitialY + 26;  //top reference point for second level bu sub-menus
	menuStartCorp = corpInitialY + 10;  //top reference point for second level corp sub-menus
}



function DivSetVisible(state, mname, level)
{
	var DivRef = document.getElementById(mname);
	if (level == "sub")	{
		var IfrRef = document.getElementById('DivShimSub');
	} else {
 		var IfrRef = document.getElementById('DivShim');
	}
	if(state)
	{
		IfrRef.style.width = DivRef.offsetWidth;
		IfrRef.style.height = DivRef.offsetHeight;
		IfrRef.style.top = DivRef.currentStyle.top;
		IfrRef.style.left = DivRef.currentStyle.left;
		IfrRef.style.zIndex = 99;
		IfrRef.style.display = "block";
	}
	else
	{
		IfrRef.style.display = "none";
	}
}

function showMainMenu(imageID, mname, menuType)
{
	if (menu.mname != " ") 	{
		//reset previously selected items
		if (menu.menuType == "bu")	{
			colourChange('c' + menu.id,'t' + menu.id,bubg,butext);
			colourChange('c' + subs.id,'t' + subs.id,busubbg,busubtext);
		} else if (menu.menuType == "corp")  {
			colourChange('c' + menu.id,'t' + menu.id,corpbg,corptext);
			colourChange('c' + subs.id,'t' + subs.id,corpsubbg,corpsubtext);
		}
		hideMainMenu(menu.imgid, menu.mname);
	}

	menu.imgid = imageID;
	menu.mname = mname;
	menu.menuType = menuType;

	//show iframe in IE to 'hide' any select elements
	if (isIE)	{
		DivSetVisible(true, "Sub" + mname, "")
	}
	
	//show highlighted (mouseover) image
	document.getElementById("i" + imageID).src = "https://www.bclc.com/Stats/images/nav/topnav_0" + imageID + "_on.gif";
	//show first level flyout
	document.getElementById("Sub" + mname).style.visibility = "visible";
	//activate img element for hiding menus
	document.getElementById("menuOff").style.visibility = "visible";
}

function hideMainMenu(imageID, mname, menuType)
{
	if (mname != " ") {
		document.getElementById("i" + imageID).src = "https://www.bclc.com/Stats/images/nav/topnav_0" + imageID + ".gif";
		document.getElementById("Sub" + mname).style.visibility = "hidden";
		
		if (menu.subname != " ") {
			hideSub(menu.subname)
			menu.subname = " ";
		}
		
		menu.imgid = 99;
		menu.id = "200";
		menu.mname = " ";
		menu.menuType = " ";
		menu.subname = " ";
	}
	
	//hide iframe in IE 
	if (isIE)	{
		DivSetVisible(false, "", "")
	}

}

function mouseoverFirst(id, mitem, sname, menuType)
{
	//reset previously selected item
	if (menu.menuType == "bu")	{
		colourChange('c' + menu.id,'t' + menu.id,bubg,butext);
		colourChange('c' + subs.id,'t' + subs.id,busubbg,busubtext);
	} else if (menu.menuType == "corp")  {
		colourChange('c' + menu.id,'t' + menu.id,corpbg,corptext);
		colourChange('c' + subs.id,'t' + subs.id,corpsubbg,corpsubtext);
	}

	if (sname != menu.subname)	{
		hideSub(menu.subname);
	}

	menu.id = id;
	menu.menuType = menuType;
	menu.subname = sname;

	//if there is a submenu specified - show it
	if (sname != " ")  {
		showSub(sname, mitem, id, menuType);
	} 
	
	//highlight the current item
	if (menuType == "bu")	{
		colourChange('c' + id,'t' + id,bubghigh,bubg);
	} else if (menuType == "corp")  {
		colourChange('c' + id,'t' + id,corpbghigh,corpbg);
	}
}

function mouseoverSub(id, mname, mi, menuType)
{
	if (subs.mname != mname)	{
		hideSub(subs.mname);
	}

	//reset previously selected items colour
	if ((subs.id - menu.id) > 800) {
		if (subs.menuType == "bu")	{
			colourChange('c' + subs.id,'t' + subs.id,busubbg,busubtext);
		} else if (subs.menuType == "corp")  {
			colourChange('c' + subs.id,'t' + subs.id,corpsubbg,corpsubtext);
		}
	}

	subs.id = id;
	subs.mname = mname;
	if (mname != " ") 	{
		showSub(mname, mi, id, menuType);
	}
	
	//highlight currently selected item
	if (menuType == "bu")	{
		colourChange('c' + id,'t' + id,bubghigh,bubg);
	} else if (menuType == "corp")  {
		colourChange('c' + id,'t' + id,corpbghigh,corpbg);
	}
}

function showSub(mname, navItem, mid, menuType)
{
	var menuid;
	menuid = Math.floor(mid/100);  //the main menu items determine where the left should line up
	if (menuid < 10)	{
		eval("var left = sub" + menuid);
		document.getElementById(mname).style.left = left + 'px';
		
		if (mname != " ")	{
			
			menu.subname = mname;
			subs.id = mid;
			subs.mname = mname;
			subs.menuType = menuType;
			
			if (menuType == "bu") {
				document.getElementById(mname).style.top = menuStartBU + (navItem * menuHeight) + 'px';			
			} else {
				document.getElementById(mname).style.top = menuStartCorp + (navItem * menuHeight) + 'px';
			}	
			document.getElementById(mname).style.visibility = "visible";
			
			//show iframe in IE to 'hide' any select elements
			if (isIE)	{
				DivSetVisible(true, mname, "sub")
			}
		}		
	}
}

function hideSub(mname)
{
	if (mname != " ") {
		document.getElementById(mname).style.visibility = "hidden";
		subs.id = subs.defaultid;  //this element  needs to exist
		subs.mname = " ";
		subs.menuType = " ";
	}
	
	//hide iframe in IE 
	if (isIE)	{
		DivSetVisible(false, "", "sub")
	}

}

function menuSwitch()
{
	//change the colour back to original colour
	if (menu.menuType == "bu")	{
		colourChange('c' + menu.id,'t' + menu.id,bubg,butext);
		colourChange('c' + subs.id,'t' + subs.id,busubbg,busubtext);
	} else if (menu.menuType == "corp")  {
		colourChange('c' + menu.id,'t' + menu.id,corpbg,corptext);
		colourChange('c' + subs.id,'t' + subs.id,corpsubbg,corpsubtext);
	}
	
	hideSub(menu.subname);
	hideMainMenu(menu.imgid, menu.mname, menu.menuType);
	
	document.getElementById("menuOff").style.visibility = "hidden";
}

function colourChange(cellID,textID,colorC,colorT)
{
	document.getElementById(cellID).style.background = colorC;
	//document.getElementById(textID).style.color = colorT;
}

function cp(page, target)
{
	if (target == "_self")  {
		location.href = page;
		return false;
	} else {
		newwin = window.open(page);
		newwin.Focus();
	}
}

function appendNewTags(){
	var menuElements = new Array();
	menuElements[0] = "t206"; //LOTTO MAX
	menuElements[1] = "t303"; //lotto max - lotteries menu
	menuElements[2] = "t21016"; //Inside Track
	menuElements[3] = "t21005"; //Boggle
	menuElements[4] = "t2903"; //Inside Track sports funder
	menuElements[5] = "t21008"; //FADS
	menuElements[6] = "t21013"; //HIRC
	menuElements[7] = "t602"; //watch draws	
	menuElements[8] = "t3703"; //Props
	menuElements[9] = "t21003"; //battleship
	
	
	for(var i=0;i<menuElements.length;i++){
		document.getElementById(menuElements[i]).innerHTML = document.getElementById(menuElements[i]).innerHTML + ' <span style="color: red;">new!</span>';
	}
}
