/*
 * REQUIRES: cookie.js, list.js
 * based off menucontent.js and menuarw.js
 */
 
/*
 * Creates the main list variable.
 * It has to be seeded as JavaScript tends to 
 * be useless at dealing with empty arrays.
 * Seeding it reduces the chances of errors.
 */
var manExpandList=Array("seed");


if (document.images)
{
	var manExpClosed=new Image;
	manExpClosed.src="/images/manual/manExpClosed.gif";
	
	var manExpOpen=new Image;
	manExpOpen.src="/images/manual/manExpOpen.gif";
}

function manExpToUp(id)
{
	if (manExpIsImage("manExpImg"+id))
	{
		im=eval("manExpImg"+id);
		im.src=manExpClosed.src;
	}
}

function manExpToDown(id)
{
	if (manExpIsImage("manExpImg"+id))
	{
		im=eval("manExpImg"+id);
		im.src=manExpOpen.src;
	}
}

function manExpIsImage(obj)
{
	im=eval("document.images."+obj);
	return (typeof im!="undefined");
}


/*
 * Attempts to read in the manexpand cookie for the site
 * If it does exist and is valid, it then attempts to hide
 * any objects listed within it.
 */
function initmanExpand()
{
	if (document.all)
	{
		cookiestring=ndgetCookie("eqmac_manexpand");
		if (typeof cookiestring=="string")
		{
			if (cookiestring.length>0)
			{
				manExpandList=cookiestring.split("|");
				for (count=0; count<manExpandList.length; count++)
				{
					if (manExpandList[count]!="seed")
					{
						hideManExpand(manExpandList[count]);
					}
				}
			}
		}
	}
}



/*
 * Sets an object to visible (block display style)
 */
function showManExpand(id)
{
	if (document.all)
	{
		obj=eval("document.all.manExpBlock"+id);
		if (obj)
		{
			obj.style.display="block";
		}
		manExpToDown(id);
	}
}

/*
 * Sets an object to hidden (none display style)
 */
function hideManExpand(id)
{
	if (document.all)
	{
		obj=eval("document.all.manExpBlock"+id);
		if (obj)
		{
			obj.style.display="none";
		}
		manExpToUp(id);
	}
}

/*
 * Attempts to toggle the visibility of an object.
 *
 * It checks for "none" as defining a display value via a stylesheet seems
 * to leave IE with a blank string, not the value you've actually set. As
 * that then screws up the first check, you have to search for none instead.
 *
 * Once the displaying is handled, any hidden objects are added to the list
 * and any visible objects are removed from the list - if they were already there.
 *
 * The list is then stored out to a cookie so the next page to need it can read it.
 */

function toggleManExpand(id)
{
	if (document.all)
	{
		obj=eval("document.all.manExpBlock"+id+".style");
		if (obj.display.indexOf("none")==-1)
		{
			hideManExpand(id);
			manExpandList=addToList(manExpandList, id);
		}
		else
		{
			showManExpand(id);
			manExpandList=removeFromList(manExpandList, id);
		}
		stringversion=unsplit("|", manExpandList);
		ndsetCookie("eqmac_manexpand", stringversion, "never");
	}
}