var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

//sets the MenuItem_depth2 to invisible
if (document.getElementById)
{
	document.write('<style type="text/css">\n')
	document.write('.MenuItem_depth2{display: none;}\n')
	document.write('.MenuItem_depth3{display: none;}\n')
	document.write('.MenuItem_depth4{display: none;}\n')
	document.write('.MenuItem_depth5{display: none;}\n')

	document.write('</style>\n')
	
}

function SlideMenu(obj)
{
	if(document.getElementById)
	{
		var el = document.getElementById(obj); //retrieves the variable obj from php page
		var ar = document.getElementById("slidedown_menu").getElementsByTagName("span"); //gets the span tag for the slide
		// make the span tag visible
		if(el.style.display != "block")
		{ 
			// foreach span tag in links page
			for (var i=0; i<ar.length; i++)
			{
				if (ar[i].className=="MenuItem_depth2" || ar[i].className=="MenuItem_depth3" || ar[i].className=="MenuItem_depth4" || ar[i].className=="MenuItem_depth5") //sets the class MenuItem_Depth2 to invisibile
				{
					ar[i].style.display = "none";
				}
				savemenustate('sub1');
				savemenustate('sub2');
				savemenustate('sub3');
				savemenustate('sub4');
			}
			el.style.display = "block";
		}
		// make the span tag invisible
		else
		{
			el.style.display = "none";
		}
	}
	savemenustate(obj);
}
function SlideMenuInside(obj)
{
/*	if(document.getElementById)
	{
		var el = document.getElementById(obj); //retrieves the variable obj from php page
		var ar = document.getElementById("slidedown_menu").getElementsByTagName("span"); //gets the span tag for the slide
		// make the span tag visible
		if(el.style.display != "block")
		{ 
			// foreach span tag in links page
			for (var i=0; i<ar.length; i++)
			{
				if (ar[i].className=="MenuItem_depth3") //sets the class MenuItem_Depth2 to invisibile
				{
					ar[i].style.display = "none";
				}
			}
			el.style.display = "block";
		}
		// make the span tag invisible
		else
		{
			el.style.display = "none";
		}
	}
*/}


function get_cookie(Name) 
{ 
	var search = Name + "=";
	var returnvalue = "";
	if (document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search)
		if (offset != -1) 
		{ 
			offset += search.length
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
			{
				end = document.cookie.length;
			}
			returnvalue=unescape(document.cookie.substring(offset, end));
		}
	}
	return returnvalue;
}

function onloadfunction()
{
	var inc=1, blockid="", blockid2="";
	while (document.getElementById("sub"+inc))
	{
		blockid="sub"+inc;
		var cookievalue=get_cookie(blockid);
		if (cookievalue != "" && cookievalue != "OFF")
		{
			document.getElementById(cookievalue).style.display="block";
		}
		inc++;
	}
}

function savemenustate(obj)
{
	if (document.getElementById(obj).style.display=="block")
	{
		document.cookie=obj+"="+obj;
	}
	else if (document.getElementById(obj).style.display=="none")
	{
		document.cookie= obj+'=; expires=Thu, 01-Jan-1970 00:00:01 GMT;';
	}
	else
	{
		document.cookie= obj+'=; expires=Thu, 01-Jan-1970 00:00:01 GMT;';
	}
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false);
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction);
else if (document.getElementById)
window.onload=onloadfunction;

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate;

