﻿menus_array = new Array ('ddPeople','ddForStudent', 'ddPublications');
mainArray = new Array ('ddPeople', 'ddForStudent', 'ddPublications')
menu_status = new Array();
img_close = 'images/fold.gif';
img_open = 'images/open.gif';

function getCookie(cookiename) {
  var dc = document.cookie;
  var prefix = cookiename + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;

  return unescape(dc.substring(begin + prefix.length, end));
}

function showHide(theid){
    if (document.getElementById) {
    	var switch_id = document.getElementById(theid);
    	var img_id = theid + 'Button';
    	var button_id = document.getElementById(img_id);

        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
           button_id.setAttribute('src',img_close);
           document.cookie = theid + "=show";
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
           button_id.setAttribute('src',img_open);
           document.cookie = theid + "=no";
        }
    }
}

function resetMenu()

{
for (var i=0; i<mainArray.length; i++)
{
  var cookiename = mainArray[i];
  var cook = getCookie(cookiename);
  if (cook == null)
    {
      document.cookie = mainArray[i] + "=show"
    }
    
}

for (var i=0; i<menus_array.length; i++)
  {
  var cookiename = menus_array[i];
  var cook = getCookie(cookiename);
  if (cook == 'show')
    {
    showHide(cookiename);
    }
  }
}
navRoot_array = new Array('navPeople','navForStudent', 'navPublications');

function startList()
  {
    if (document.all&&document.getElementById)
      {
        for (var s=0; s < navRoot_array.length; s++)
          {
            var navidname = navRoot_array[s];
            navRoot = document.getElementById(navidname);
            for (i=0; i < navRoot.childNodes.length; i++)
              {
                node = navRoot.childNodes[i];
                  if (node.nodeName=="LI"||"DT")
                    {
                      node.onmouseover=function()
                        {
                          this.className+=" over";
                        }
                      node.onmouseout=function()
                        {
                          this.className=this.className.replace(" over", "");
                        }
                    }
                
              }
          }
     }
  }


/* Functions used to determine state of flyout menu's parent onMouseOver of a flyout menu's list item */
function colorParentNode(n) {
	pLink = n.parentNode.getElementsByTagName('a');		//n is menu list item
	pLink[0].className = "parentBGColor";				//change css class assigned to parent link
}

function remcolorParentNode(n) {
	pLink = n.parentNode.getElementsByTagName('a');
	pLink[0].className = "";
}



