//pureDOMnav2.js

// Adapted from:
// pureDOM navigator
// written by Christian Heilmann http://www.onlinetools.org/
// Version 1.0
// 05.11.2003

/* Changes  pureDOM navigator to fit our site, murdockna.org,
have been too extensive to note with comments on the original. The original was
almost rewritten completely. Please see
the original at the URL above. This  script is used by the site map page.

Changes to the original by Sigrid Illes, http://www.murdockna.org, include:
1. Images preceding list items are made stubbed links only when the list item 
   has a child sublist...which speeds tabbing through links (original
   turned all preceding images into stubbed links).
2. Interior list items with no child sublists are preceded by a different
   image than the outermost list items with no child sublist. The interior
   images have a vertical line in them which lends a visual point of 
   reference.
   (original used the same blank image to precede these interior and
   exterior list items.).
3. Removed the onkeypress event handler from the image-links. This event handler
   isn't necessary here as there is complete keyboard accessibility without it.
   Keeping this event handler actually removes keyboard accessibility for some
   browsers. Removal of this event handler allowed tabbing through all links on
   the page in Foxfire, Navigator, and Opera.
   (The original permitted tabbing through all links only for IE, the
     other browsers stopped progressive tabbing at the first minus/plus image).
4. All list items, whethor links or not, have preceding images. The original
   did not insert any image if the list item was not a link. This site sometimes
   may have list items which are not links and no preceding image would alter
   visual alignment of the item.
5. This script uses a different testing process for the strong element which
   is used as a indicator of non-collapse of a sublist for the initial display.
   The original test would always be positive if the parental li of the sublist
   had a strong element itself. Before the change by SI there were some situations where a dummy li had to
   be created to bear the strong tag so that the parental li didn't have to
   bear the strong element. This script's testing process for the strong element
   is not affected by presence of a strong element in the parental li.

   Aug 7, 2005: changed strong element to span as indicator of non-collapse
   since strong implies emphasis. */


// Predefined variables...
var onpic='media/plus_b.gif';
var offpic='media/minus_b.gif';

var canDOM=false;

// Checking for DOM compatibility	
if (document.getElementById && document.createTextNode && document.createElement){canDOM=true}

function expinit()
{
    // Predefined variables...
    var blankpic='media/white.gif';
    var blank_ln_pic='media/gold_ln.gif';
    var picmargin=5;
    var picx=10;
    var picy=10;
    var picalt='Collapsed or Expanded indicator';
    var pictitle='Click to expand or collapse -or- tab to arrow and press Enter.';
    var parentID='collapse_list'; //id of parent div enclosing list

    var alllis;

    if (canDOM)
    {
        if(parentID && document.getElementById(parentID))
        {
	    alllis=document.getElementById(parentID).getElementsByTagName('LI');
	}
        else
        {
	    alllis=document.getElementsByTagName('LI');
	}
	for(var i=0;i<alllis.length;i++)
        {
            var addimg;
            var cola;
            var highlight;
            var disp;
            var pic;
                                 
            // Test for current li being a node of a UL that is itself
            // a sublist...
            var issubli=alllis[i].parentNode.parentNode.tagName=='LI'?true:false;
            // Test for presence of child sublist...
            var hasSubUL = alllis[i].getElementsByTagName('UL')[0];
                        
	    addimg = document.createElement('img');
	    addimg.style.border='none';
	    addimg.style.width=picx+'px';
	    addimg.style.height=picy+'px';
	    addimg.style.marginRight=picmargin+'px';

            /* If the li has a child sublist, insert a plus or minus image and
               make the image a link...*/
            if( hasSubUL )
            {
	        addimg.alt=picalt;
                addimg.title=pictitle;

		/* Do not collapse sublist when there is a span element in the
                   sublist and use the minus image. Otherwise, collapse sublist and
                   use the plus image...*/
                highlight=hasSubUL.getElementsByTagName('span').length==0?true:false;
		disp=highlight?'none':'block';
		pic=highlight?onpic:offpic;
                hasSubUL.style.display=disp;
                addimg.src=pic;

                // Create a link...
		cola = document.createElement('A');
		cola.setAttribute('href','#');
		cola.onclick=function() {ex(this);return false;};
		cola.appendChild(addimg);
	        alllis[i].insertBefore(cola,alllis[i].firstChild);
            }
            else
            {
            /* If li has no sublist, don't turn the image into a link. Insert
               totally blank image if li is in the outer list
               (to preserve spacing). Insert image with vertical line,
               if the li is in an interior sublist...*/

	        addimg.alt='';
                if(issubli)
                {
	            addimg.src=blank_ln_pic;
                }
                else
                {
                    addimg.src=blankpic;
                }
                alllis[i].insertBefore( addimg, alllis[i].firstChild );
            }
	}
    }
}

// Collapse and Expand node.
function ex(n)
{
    var u;
    var img;
              
    if(canDOM)
    {
        u=n.parentNode.getElementsByTagName("UL")[0];
	if(u)
        {
	    u.style.display=u.style.display=='none'||u.style.display==''?'block':'none';
	    img=n.getElementsByTagName('img')[0];
	    img.src=img.src.indexOf(offpic)!=-1?onpic:offpic;		
	}
    }			
}

function cleanUp2()
{
    onpic = null;
    offpic = null;
    canDOM = null;
}

window.onload=expinit;
