/*  navigation.js - 4/25/2005, David DeMello
	This javascript is used by the navigation menus on the FGSS site.
	It creates the dynamic drop-down menus in the top navigation, and it also changes the 
	style of the active link (i.e., the link to the current page) in the left-hand navigation.
	This code is tested and works in IE6+, Netscape 7, Mozilla, and Firefox on Mac and Windows 
	and Safari on Mac. Because it does not support the standards this code is based on, IE for Mac does
	not display the dynamic drop-down menus and just treats the top navigation choices as simple links.
*/

/**************  TOP NAVIGATION DROP-DOWN MENUS ******************
	The following 4 variables contain the lists of links that display as drop-down
	menus below the horizontal top navigation links.
	To add a new link, add a new list item to the group that follows the pattern, 
	including the single quote marks and plus sign.
	
	For example, to add a new link for "Study Abroad" to the Academics menu, you would add:
	
		'<li><a href="../beta/academics/studyabroad.html">Study Abroad</a></li>' +
	
	to the academicsSubNav block.
*/
	
// Academics menu
var academicsSubNav = '<ul>' +
	'<li><a href="../academics/undergraduate.html">Undergraduate</a></li>' +
	'<li><a href="../academics/graduate.html">Graduate Minor</a></li>' +
	'<li><a href="../academics/courseinfo.html">Course Info</a></li>' +
	'<li><a href="../academics/jointprograms.html">Joint Programs</a></li>' +
	'</ul>';

// People menu
var peopleSubNav = '<ul>' +
	'<li><a href="../people/corefaculty.html">Core Faculty</a></li>' +
	'<li><a href="../people/affiliatedfaculty.html">Affiliated Faculty</a></li>' +
	'</ul>';

// Research menu
var researchSubNav = '<ul>' +
	'<li><a href="../research/publications.html">Publications</a></li>' +
	'<li><a href="../research/workingpapers.html">Working Papers</a></li>' +
	'</ul>';

// Resource menu
var resourcesSubNav = '<ul>' +
	'<li><a href="../resources/fgsslibrary.html">FGSS Library</a></li>' +
	'</ul>';

// Events menu
var eventsSubNav = '';



/**************  FUNCTIONS AND MENU INITIALIZATION ******************
	Please DO NOT edit the following code.                         */ 
         

/*  dropDownMenu() gets called in the HTML page to output the drop-down menus by
	name - dropDownMenu("academicsSubNav"), dropDownMenu("peopleSubNav"), etc.  */
function dropDownMenu(menu) {
	if (document.bShowDropDowns) document.write(menu);
}

/*  markActiveNavLink() changes the class of the currently active link in the
	left-hand navigation so that it can be styled differently in the CSS.  */
function markActiveNavLink() {
	// Set menuLinkCount equal to the total number of links in the left navigation.
	var menuLinkCount = document.getElementById("menu").childNodes.length;
	
	// For each possible id, if a link exists with the id and that link's href
	// is the current page, then set the link's class to "currentpage".
	for (i=1; i<=menuLinkCount; i++) {			
		if (document.getElementById("menuLink" + i) && 
				document.getElementById("menuLink" + i).href == document.location.toString()) {
			document.getElementById("menuLink" + i).className="currentpage";
		}			
	}
}
	

/*  initializeMenus is a reference to a function to initialize both the top and
	left-hand navigation. Later in this file the current document's onLoad
	handler gets set to this function. */
initializeMenus = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
		markActiveNavLink();
	}
}

// Dynamic features in IE for Mac, so decide not to use them if that't the current browser.
var bShowDropDowns;

if (window.navigator.userAgent.indexOf('MSIE')>0 && 
		window.navigator.userAgent.indexOf('Mac') > 0) {
	document.bShowDropDowns = false;
} else {
	document.bShowDropDowns = true;
}

// Initialize the menus once the page is loaded unless we're on IE for Mac.
if (document.bShowDropDowns) window.onload=initializeMenus;

// Delete this and the following line to turn drop-down navigation back on.
document.bShowDropDowns = false;

