//Parse the menuState value into 4 bool values
var menu = new Array(0,0,0,0);

var menuState = QueryString("menustate"); 
if (menuState == "") menustate = 1;
else ParseMenuState();

function swapArrow(id)
{
	var object = document.getElementById("menuArrow" + id);

	if (menu[id - 1] == 1)
	{
		object.className = 'menu_arrow_right';	
		menu[id - 1] = 0;
	}
	else 
	{
		object.className = 'menu_arrow_down';	
		menu[id - 1] = 1;
	}
}

function ParseMenuState()
{
	if ((menuState % 2 == 0) || (QueryString("section") == "career")) menu[0] = 1;
	if ((menuState % 3 == 0) || (QueryString("section") == "learning")) menu[1] = 1;
	if ((menuState % 5 == 0) || (QueryString("section") == "people")) menu[2] = 1;
	if ((menuState % 7 == 0) || (QueryString("section") == "about")) menu[3] = 1;	
}

function GetMenuState()
{
	menuState = 1;
	if (menu[0] == 1) menuState *= 2;
	if (menu[1] == 1) menuState *= 3;
	if (menu[2] == 1) menuState *= 5;	
	if (menu[3] == 1) menuState *= 7;	

	return menuState;
}

function Link(url)
{
	//This will make the entire menu save state
	//url += "&menustate=" + GetMenuState();
	
	//This will allow only the section you are in to remain open when switching pages
	url += "&menustate=1";
	
	window.location = url;
}

function QueryString(ji) 
{
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) 
	{
		ft = gy[i].split("=");
		if (ft[0] == ji) 
		{
			return ft[1];
		}
	}
}