/* restored this function from the deleted prologue.js */
function menuCookieTest()
{
	var TEST_STRING = "test=test";
	var found = false

    if( document.cookie.length > 0 ) {
        return true;
    }
    else {    	
	    document.cookie = TEST_STRING; // create a dummy cookie
	    var cookies = document.cookie.split("; ");
	    for (var i = 0; i < cookies.length; i++)
	    {
		    if (cookies[i] == TEST_STRING)
		    {
			    found = true;
			    break;
		    } // if
	    } // for
    	
	    return found;
	}
} // cookieTest

function Inline(menu, menuPos)
{
	document.getElementById(menu + menuPos).style.display = 'inline';
	// document.getElementById(menu + "Image" + menuPos).src = 'images/' + menu + 'Expand.gif';
} // Inline

function SetMenuCookie(menu, menuList)
{
	document.cookie = menu + "=" + menuList.join(",");
} // SetMenuCookie

function Expand(menuItem, menu, menuPos, hasChildren, count)
{

   //retract all menus
   var mPos = count;
   var mItem = document.getElementById(menu+mPos);
   while(mPos > 0) {
      if(mItem) {
         mItem.style.display = 'none';
         }
      mPos--;
      mItem = document.getElementById(menu+mPos);
      }
	// menu is not expanded, so expand it
	//var index = menuList.length;
	//menuList[index] = menuItem;
	Inline(menu, menuPos);
	//SetMenuCookie(menu, menuList);
	//document.cookie = menu + "=" + menuItem;
	//going to change this to false 
	//so it doesn't reload the page..could be made to 
	//true if we want it to reload the dashboard
	if (hasChildren == 'no') {
		return true;
	}
	else {
		return false;
	}
//	// returns true if page link should be downloaded, false if not
//	if ( menuCookieTest() == true )
//	{
//		var cookies = document.cookie.split("; ");
//		var found = false;
//		for (var i = 0; i < cookies.length; i++)
//		{
//			if (cookies[i].search(menu + "=.*") > -1)
//			{
//				found=true;
//				break;
//			} // if
//		} // for
//		if (!found)
//		{
//			// there is no menu cookie, so just add this item to a new one
//			document.cookie = menu + "=" + menuItem;
//			Inline(menu, menuPos);
//			if (hasChildren == 'no') {
//				return true;
//			}
//			else {
//				return false;
//			}
//		} // if
//		var menuCookie = cookies[i];
//		var menuCookieValues = menuCookie.split("=");
//		var menuList = menuCookieValues[1].split(",");
//		found = false;
//		for (i = 0; i < menuList.length; i++)
//		{
//			if (menuList[i] == menuItem)
//			{
//				found = true;
//				spot = i;
//				break;
//			} // if
//		} // for
//		if (!found)
//		{
//		   //retract all menus
//		   var mPos = count;
//		   var mItem = document.getElementById(menu+mPos);
//		   while(mPos > 0) {
//		      if(mItem) {
//		         mItem.style.display = 'none';
//		         }
//		      mPos--;
//		      mItem = document.getElementById(menu+mPos);
//		      }
//			// menu is not expanded, so expand it
//			var index = menuList.length;
//			menuList[index] = menuItem;
//			Inline(menu, menuPos);
//			//SetMenuCookie(menu, menuList);
//			document.cookie = menu + "=" + menuItem;
//			//going to change this to false 
//			//so it doesn't reload the page..could be made to 
//			//true if we want it to reload the dashboard
//			if (hasChildren == 'no') {
//				return true;
//			}
//			else {
//				return false;
//			}
//		} // if
//		else	
//		{
//			// menu is expanded, so retract it
//			if (menuList.length > 1)
//				for (i = spot; i < menuList.length - 1; i++)
//					menuList[i] = menuList[i + 1];
//			menuList = menuList.slice(0, menuList.length - 1);
//			document.getElementById(menu + menuPos).style.display = 'none';
//			// document.getElementById(menu + "Image" + menuPos).src = 'images/' + menu + 'Retract.gif';
//			SetMenuCookie(menu, menuList);
//			//if there aren't children below this node then we don't 
//			//want it to return true so it calls the page and doesn't just collapse
//			if (hasChildren == 'no') {
//				return true;
//			}
//			else
//			{
//				return false;
//			}
//		} // else
//	} // if
//	else
//		return true;
} // Expand
