var openDisplay			= "block";
var closedDisplay		= "none";
var controlName			= "lnav_";
var menuItemsIdPrefix	= controlName + "MenuItems";
var arrowIdPrefix		= controlName + "MenuArrow";

var loc = new String(window.location);

if(loc.search("seeker") > 0) {
	arrowDownSource = "/pma/arrow_down.gif";
	arrowRightSource = "/pma/arrow_right.gif";
} else {
	arrowDownSource = "../../../arrow_down.gif";
	arrowRightSource = "../../../arrow_right.gif";
}

function toggleMenu(menuIndex) {
	var menuItemsId	= menuItemsIdPrefix + menuIndex;
	var arrowId	= arrowIdPrefix + menuIndex;
	var menuItems;
	var arrow;

	menuItems	= document.getElementById(menuItemsId);
	arrow		= document.getElementById(arrowId);
    
    if (menuItems != null)
    {    
		if (menuItems.style.display == closedDisplay ||
			menuItems.style.display == "") 
		{
			arrow.src = arrowDownSource;
			arrow.alt = "Contract";
			menuItems.style.display = openDisplay;
		}
		else 
		{
			arrow.src = arrowRightSource;
			arrow.alt = "Expand";	
			menuItems.style.display = closedDisplay;		
		}
		
		saveState();
	}
}

function openMenu(menuIndex) {
	var menuItemsId	= menuItemsIdPrefix + menuIndex;
	var arrowId	= arrowIdPrefix + menuIndex;
	var menuItems;
	var arrow;

	menuItems	= document.getElementById(menuItemsId);
	arrow		= document.getElementById(arrowId);
    
    if (menuItems != null)
    {    
		arrow.src = arrowDownSource;
		arrow.alt = "Contract";
		menuItems.style.display = openDisplay;
		
		saveState();
	}
}

function viewState() {
	
	//////////////////////////////////////////////////////////////
	// this was added later, to open if linked into a subcategory
	//////////////////////////////////////////////////////////////
	var loc = new String(window.location);
	if(loc.search("openMenu=") > 0) {
		query = loc.split("?");
		menuId = query[1].split("=")[1];
		openMenu(menuId);
	}
	//////////////////////////////////////////////////////////////
	
	var sectionCookieName;
	var sectionMenuCount;
	var cookieValue;
	var docookie = false;
	var loc = new String(window.location);
	
	if(loc.search("initiate") > 0) {
		sectionCookieName = "pmaMenuInitiate";
		sectionMenuCount = 1;
		docookie = true;
	} else if(loc.search("plan") > 0) {
		sectionCookieName = "pmaMenuPlan";
		sectionMenuCount = 2;
		docookie = true;
	} else if(loc.search("execute") > 0) {
		sectionCookieName = "pmaMenuExecute";
		sectionMenuCount = 2;
		docookie = true;
	} else {
		docookie = false;
	}
	
	if(docookie) {
		
		cookieValue = readCookie(sectionCookieName);
		
		if(cookieValue) {		
			cookieValue = cookieValue.split('*');
			for (i = 0; i < cookieValue.length-1; i++) {
				if(cookieValue[i]==1) {
					document.getElementById("lnav_MenuItems"+i).style.display = 'block';
					document.getElementById(arrowIdPrefix+i).src = arrowDownSource;
					document.getElementById(arrowIdPrefix+i).alt = "Contract";
				} else {
					document.getElementById("lnav_MenuItems"+i).style.display = 'none';
					document.getElementById(arrowIdPrefix+i).src = arrowRightSource;
					document.getElementById(arrowIdPrefix+i).alt = "Expand";
				}
			}
		}
	}
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function saveState() 
{
	var sectionCookieName;
	var sectionMenuCount;
	var loc = new String(window.location);
	if(loc.search("initiate") > 0) {
		sectionCookieName = "pmaMenuInitiate";
		sectionMenuCount = 1;
		docookie = true;
	} else if(loc.search("plan") > 0) {
		sectionCookieName = "pmaMenuPlan";
		sectionMenuCount = 2;
		docookie = true;
	} else if(loc.search("execute") > 0) {
		sectionCookieName = "pmaMenuExecute";
		sectionMenuCount = 2;
		docookie = true;
	} else {
		docookie = false;
	}

	if(docookie) {
		var cookieInfo = "";
	
		for (i = 0; i < sectionMenuCount; i++) 
		{
			var menuItemsId = menuItemsIdPrefix + i;
			var menuItems;
			

			menuItems = document.getElementById(menuItemsId);
			
			if (menuItems != null)
			{
				if (menuItems.style.display == openDisplay)
				{
					cookieInfo = cookieInfo + "1*"; 		
				}
				else
				{
					cookieInfo = cookieInfo + "0*"; 		
				}
			}
			else
			{
				cookieInfo = cookieInfo + "0*"; 		
			}
		}
		
		if (cookieInfo == "")
		{
			cookieInfo = "*";
		}
			
		setCookie(sectionCookieName, cookieInfo);
	}
}

function setCookie(cookieName, value) 
{
	cookieInfo = cookieName + "=" + escape(value) + "; path=/;";
	document.cookie = cookieInfo; 
	return document.cookie;
}




/*******************************************************************/
/**************    Dreamweaver made these..    *********************/
/*******************************************************************/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
/*******************************************************************/
/*******************************************************************/
/*******************************************************************/


//These used to be used, and there are still references to them,
//so I just left them here rather than take out all the references.
function changeCol(id, style) {}
function changeCol2(id, style) {}
function changeCol3(id, style) {}
function show(id) {}