var oldvisible = "";



/* Opens and closes Nav Bar Topics.

   'o' is the ID of a div in nav.htm that you want to change. */ 

function toggle(o) {

   var visible;

   

   /* if we have anything open, close it */

   if (oldvisible != "") {

      document.getElementById(oldvisible).style.display = 'none';

	  document.getElementById(oldvisible + '_img').src = 'images/rightarrowaqua.gif';

   }



   /* if the new thing is different, open it, otherwise, leave nothing is open */

   if (oldvisible != o) {

	  document.getElementById( o ).style.display = 'block';

	  document.getElementById(o + '_img').src = 'images/downarrowaqua.gif';

   	  oldvisible = o;

   }

   else {

      oldvisible = "";

   }

}



/* Open the navbar to the proper location.

   Three parts:

    1. find the link whose text is equal to the argument passed to this function

	2. Set its style to navyouarehere (which adds the grey lines)

	3. Toggle the containing div (i.e., hit the plus sign

*/

function youarehere(x) {

   var i,j;

   var node = document.getElementById("navbar"); /* locate the navbar in the DOM */

   var children = node.childNodes;

   var msg = "nothing";

   var msg2 = "";

   var isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") != -1);

   var hasInnerText = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;

   var text;

   var para;

   for(i =0; i < children.length; i++) { /* for each child of the navbar */

       var div = children.item(i);

       if (div.nodeName != 'DIV') continue;  /* if it's not a DIV, ignore it */

       msg = msg + i + ": " + div.className + "|" + div.id +  "\n";

	   for(j=0; j< div.childNodes.length; j++) {  /* for each child of the DIV */

	      para = div.childNodes.item(j);

		  if (para.nodeName != 'P') continue; /* if it's not a P, ignore it */

		  if (isSafari) { /* safari is only DOM-level 2, so it doesn't have innerText or textContent.  This is a workaround. */

		     text = para.childNodes[0].innerHTML;

			 }

		  else if (hasInnerText)                   /* get the inner text of the P, which will be a link name */

		     text=para.innerText;

		  else

		     text = para.textContent;

		  if (text == x) {                   /* we found it */

		  	para.className = 'navyouarehere';   /* add the gray bars */

		    /* debugging: msg = msg + "***"; */

			toggle(div.id);                  /* toggle the containing div */

		  }

	   }

	}

}

