/*********************************************************************************
 * Cycling of #Features
 *********************************************************************************/
 
var arrayOfFeatures = new Array();

function assembleArrayOfFeatures() {
	if( arrayOfFeatures.length > 0 ) return; // already assembled
	var featureContainer = document.getElementById('Feature');
	if( !featureContainer ) return; // could not find feature container
	
	// Find all features within container
	var featureIdx = 0;
	for(var i = 0; i < featureContainer.childNodes.length; i++) {
		var feature = featureContainer.childNodes[i];
		var featureClassNames = ("" + feature.className).split(" ");
		for(var j = 0; j < featureClassNames.length; j++)
			if( featureClassNames[j] == 'feature' ) break;
		if( j == featureClassNames.length ) continue; // not a feature
		arrayOfFeatures[featureIdx++] = feature;
	}
}

function indexOfVisibleFeature() {
	if(arrayOfFeatures.length == 0 ) return null; // cannot find in an empty array
	for(var i = 0; i < arrayOfFeatures.length; i++) {
		var feature = arrayOfFeatures[i];
		if( feature.className.indexOf('hidden') == -1 ) return i;
	}
	return 0; // default to first one if one could not be determined.
}

function hideFeatureNavigationIfAppropriate() {
	var nav = document.getElementById('FeatureNavigation');
	if( !nav ) return;
	var navAnchors = getImmediateChildrenByTagName(nav, 'A');
	if( !navAnchors.length ) return;
	if( navAnchors[0].href.substring(0,11) != 'javascript:' ) return; // not default setup
	if( arrayOfFeatures.length < 2 ) nav.style.display = 'none';
}

function hideFeature(idx) {
	arrayOfFeatures[idx].className = 'feature hidden';
}

function showFeature(idx) {
	arrayOfFeatures[idx].className = 'feature';
}

function nextFeature() {
	var idx = indexOfVisibleFeature();
	if(idx != null){
		hideFeature(idx);
		showFeature((idx+1)%arrayOfFeatures.length);
	}
}

function previousFeature() {
	var idx = indexOfVisibleFeature();
	if(idx != null){
		hideFeature(idx);
		showFeature((idx + arrayOfFeatures.length - 1) % arrayOfFeatures.length);
	}
}

function getRandom(low, high) { 
	return Math.floor(Math.random() * (1 + high - low) + low); 
}

function showRandomFeature() {
	var idx = indexOfVisibleFeature();
	if(idx != null){
		hideFeature(idx);
		showFeature(getRandom(0,arrayOfFeatures.length-1));
	}
}

function featureInitialize() {
	assembleArrayOfFeatures();
	hideFeatureNavigationIfAppropriate();
	showRandomFeature();
}

/*********************************************************************************
 * Layering of the #MenuTabs.
 *********************************************************************************/

function swapLeftSide(tabAnchor, layerId) {
	var leftHalf = document.getElementById('LeftHalf');
	var tabs = document.getElementById('Tabs');
	var clickedTab = tabAnchor.parentNode;
	
	// unselect all tabs, and select the appropriate one.
	var eachTab = getImmediateChildrenByTagName(tabs, 'LI');
	for( var i = 0; i < eachTab.length; i++ ) {
		var tab = eachTab[i];
		tab.className = (tab == clickedTab) ? 'current' : null;
	}
	
	// first hide all layers
	for( var i = 0; i < leftHalf.childNodes.length; i++ ) {
		var layer = leftHalf.childNodes[i];
		if( layer.id == layerId ) continue; // avoid flicker by not hiding the one we want to show
		
		if( layer.style ) layer.style.display = 'none';
		if( layer.className == 'visible' )
			layer.className = '';
	}
	
	// show just the one layer
	var layer = document.getElementById(layerId);
	if( !layer ) return; // layer id is probably wrong.
	layer.style.display = 'block';
	if( layer.className.length == 0 )
		layer.className = 'visible';

	// Look for input boxes on new tab, and select the first one if found
	var inputFields = layer.getElementsByTagName("input");
	for( var i = 0; i < inputFields.length; i++ ) {
		if( inputFields[i].type != 'hidden' ) {
			inputFields[i].focus();
			break;
		}
	}
}

/*********************************************************************************
 * Convert the pretty outline bulleted list of menus into the ugly HTML of yonder-year
 *********************************************************************************/

var maxLevels = 3; // this isn't as variable as it looks
// This is some of the skeletal HTML required to make the menus work.
var cellInternals = ['', 
'	<div id="secpd" style="visibility: hidden;">'+
'		<table cellpadding="0" cellspacing="0" align="left">'+
'			<tr>'+
'				<td><span style="background-position: bottom" class="popupMenusHorizLine"/></td>'+
'			</tr>'+
'			<tr>'+
'				<td id="secct" valign="top" class="mb" height="200"></td>'+
'			</tr>'+
'			<tr>'+
'				<td><span style="background-position: top" class="popupMenusHorizLine"/></td>'+
'			</tr>'+
'		</table>'+
'	</div>',
'	<div id="thrpd" style="visibility: hidden;">'+
'		<table cellpadding="0" cellspacing="0" align="left">'+
'			<tr>'+
'				<td><span style="background-position: bottom" class="popupMenusHorizLine"/></td>'+
'			</tr>'+
'			<tr>'+
'				<td id="thrct" valign="top" class="mb" height="200"></td>'+
'			</tr>'+
'			<tr>'+
'				<td><span style="background-position: top" class="popupMenusHorizLine"/></td>'+
'			</tr>'+
'		</table>'+
'	</div>'];
var cellInternals2 = ['', 
'	<div id="secpd" style="visibility: hidden;">'+
'		<table cellpadding="0" cellspacing="0" align="left">'+
'			<tr>'+
'				<td><span style="background-position: bottom" class="popupMenusHorizLine"/></td>'+
'			</tr>'+
'			<tr>'+
'				<td id="secct" valign="top" class="mb" height="200"></td>'+
'			</tr>'+
'			<tr>'+
'				<td><span style="background-position: top" class="popupMenusHorizLine"/></td>'+
'			</tr>'+
'		</table>'+
'	</div>',
'	<div id="thrpd" style="visibility: hidden;">'+
'		<table cellpadding="0" cellspacing="0" align="left">'+
'			<tr>'+
'				<td><span style="background-position: bottom" class="popupMenusHorizLine"/></td>'+
'			</tr>'+
'			<tr>'+
'				<td id="thrct" valign="top" class="mb" height="200"></td>'+
'			</tr>'+
'			<tr>'+
'				<td><span style="background-position: top" class="popupMenusHorizLine"/></td>'+
'			</tr>'+
'		</table>'+
'	</div>'];

var firstMenuSetArea; // first level menus get placed in created table
var subMenuSetArea; // the rest of the menus get placed after the table
// These class names and ids have significance in popMenu.js and the stylesheet.
var cellClasses = new Array("bm", "htd", "htd"); // each of 3 cells gets a class name
var cellIds = new Array("", "second", "third"); // each cell gets a unique id
var classNamesForLinksToPopUpMenus = new Array("ll", "l2");
var subMenuCount = 0; // this is a static counter, since menu 1.5 is "fifth", and 2.1 is "sixth"
var tabIndexCount = 50; // this is a static counter, since no anchor tag should share a tabindex with another

function getUniqueSubmenuName(index) {
	return 'submenu' + index;
}

// Builds the skeletal table to store the popup menus in
function buildMenuTable()
{
	var tbl, tbody, tr, td;
	tbl = document.createElement('table');
	tbody = tbl.getElementsByTagName("tbody")[0];
	tbl.cellPadding = 0;
	tbl.cellSpacing = 0;
	tr = tbl.insertRow(0);
	for( var i = 0; i < maxLevels; i++ )
	{
		tr.appendChild( td = document.createElement('td') );
		td.className = cellClasses[i];
		if( cellIds[i] ) td.id = cellIds[i];
		td.innerHTML = cellInternals[i];
		//document.write("here");
		if( i == 0 ) firstMenuSetArea = td;
	}
	return tbl;
}
function buildMenuTable2()
{
	var tbl, tbody, tr, td;
	tbl = document.createElement('table');
	tbody = tbl.getElementsByTagName("tbody")[0];
	tbl.cellPadding = 0;
	tbl.cellSpacing = 0;
	tr = tbl.insertRow(0);
	for( var i = 0; i < maxLevels; i++ )
	{
		tr.appendChild( td = document.createElement('td') );
		td.className = cellClasses[i];
		if( cellIds[i] ) td.id = cellIds[i];
		td.innerHTML = cellInternals[i];
		//document.write("here");
		if( i == 0 ) firstMenuSetArea = td;
	}
	return tbl;
}






// Performs the transformation of the nice bulleted list
// into the ugly HTML tables that work the pop-up menus.
function popmenuInitialize()
{
	var layerMenus = document.getElementById('LayerMenus');
	//var layerMenus2 = document.getElementById('LayerMenus');
	
	var bl = getImmediateChildrenByTagName(layerMenus, 'UL')[0];
	//var bl2 = getImmediateChildrenByTagName(layerMenus2, 'UL')[0];
	if( !bl ){
		return false;
	}//document.write("yes1"); // If no bulleted list was found, skip out.
	//if( !bl2 ) return document.write("yes2"); // If no bulleted list was found, skip out.
	

	var targetArea = layerMenus.cloneNode(false);
	//var targetArea2 = layerMenus2.cloneNode(false);
	targetArea.appendChild( buildMenuTable() ); // build the skeletal table
	//targetArea2.appendChild( buildMenuTable2() ); // build the skeletal table
	subMenuSetArea = targetArea; // the hidden menus appear below the table
	

	transformHtml(bl, 0, new Array()); // transform html

	// Swap the bulleted list for the newly generated HTML.
	layerMenus.parentNode.replaceChild(targetArea, layerMenus);
	
	preloadmenus();
}


// Performs the grunge work of actually reading the bulleted list
// and producing the ugly html.
function transformHtml(ul, depth, path)
{
	// This could be the top-level of the bulleted list,
	// or an inner UL tag that signifies a hidden menu.  
	// The "ul" parameter reference the current UL tag being parsed.
	// The "depth" parameter tells us how deep we are in recursion.
	// The "path" parameter is an array of indexes in the menuing system
	// that tells us how we got to this hidden menu (if applicable).
	var targetArea;
	switch( depth )
	{
		case 0:
			targetArea = firstMenuSetArea;
			break;
		case 1:
			subMenuSetArea.appendChild( targetArea = document.createElement('div') );
			targetArea.className = 'hd';
			targetArea.id = getUniqueSubmenuName(path[0]) + '_menu';
			break;
		case 2:
			subMenuSetArea.appendChild( targetArea = document.createElement('div') );
			targetArea.className = 'hd';
			targetArea.id = getUniqueSubmenuName(subMenuCount++) + '_submenu';
			break;			
	}
	// Get all the immediate members of this particular menu
	var liList = getImmediateChildrenByTagName(ul, 'LI');
	var firstLinkEncountered = false;
	for( var i = 0; i < liList.length; i++ )
	{
		var li = liList[i];
		// Prepare to add this LI element's children to the appropriate
		// table cell or div area.
		var div = document.createElement('div');
		targetArea.appendChild( div );
		// Look for sub-menus of this menu item.  If one is found, mark it for
		// recursion later, and meanwhile copy all other nodes into the new location.
		var ulSub = null;
		for( var j = 0; j < li.childNodes.length; j++ )
		{
			var liChild = li.childNodes[j];
			if( liChild.nodeName == "UL" ) 
			{
				ulSub = liChild;
				continue; // skip this
			}
			div.appendChild( liChild.cloneNode(true) );
		}
		div.className = ulSub ? classNamesForLinksToPopUpMenus[depth] : 'lt';
		var anchors = div.getElementsByTagName('A');

		// Make sure an anchor tag exists.  Create it if it doesn't.
		var primaryAnchor;
		if( anchors.length == 0 )
		{
			primaryAnchor = document.createElement('a');
			primaryAnchor.href = "#";
			while( div.childNodes.length )
				primaryAnchor.appendChild( div.childNodes[0] );
			div.appendChild( primaryAnchor );
		} 
		else
			primaryAnchor = anchors[0];
		
		primaryAnchor.className = ulSub ? 'navBranch' : 'navLink';
		if( !ulSub && !firstLinkEncountered )
		{
			firstLinkEncountered = true;
			// Only add extra space if there were navBranch's above us
			if( i > 0 ) div.className += ' firstNavLink';
		}
		primaryAnchor.tabIndex = tabIndexCount++;
		// If this LI element had a child UL element, recurse into that
		if( ulSub ) 
		{
			if( depth == 0 )
				div.id = 'u' + getUniqueSubmenuName(i) + '_menu';
			else // assert debug == 1
				div.id = 'u' + getUniqueSubmenuName(path[0]) + '_menu.' + getUniqueSubmenuName(subMenuCount) + '_submenu';

			var param = div.id.substr(1);

			// Just setting the onclick attribute or the click event
			// seems to cause problems in various browsers.
			// This works every time.
			primaryAnchor.href = "javascript:toggleMenu('" + param + "');";
			
			path[depth] = i;
			transformHtml(ulSub, depth+1, path);
		}
	}
}




function transformHtml2(ul, depth, path)
{
	// This could be the top-level of the bulleted list,
	// or an inner UL tag that signifies a hidden menu.  
	// The "ul" parameter reference the current UL tag being parsed.
	// The "depth" parameter tells us how deep we are in recursion.
	// The "path" parameter is an array of indexes in the menuing system
	// that tells us how we got to this hidden menu (if applicable).
	var targetArea;
	switch( depth )
	{
		case 0:
			targetArea = firstMenuSetArea;
			break;
		case 1:
			subMenuSetArea.appendChild( targetArea = document.createElement('div') );
			targetArea.className = 'hd';
			targetArea.id = getUniqueSubmenuName(path[0]) + '_menu';
			break;
		case 2:
			subMenuSetArea.appendChild( targetArea = document.createElement('div') );
			targetArea.className = 'hd';
			targetArea.id = getUniqueSubmenuName(subMenuCount++) + '_submenu';
			break;			
	}
	// Get all the immediate members of this particular menu
	var liList = getImmediateChildrenByTagName(ul, 'LI');
	var firstLinkEncountered = false;
	for( var i = 0; i < liList.length; i++ )
	{
		var li = liList[i];
		// Prepare to add this LI element's children to the appropriate
		// table cell or div area.
		var div = document.createElement('div');
		targetArea.appendChild( div );
		// Look for sub-menus of this menu item.  If one is found, mark it for
		// recursion later, and meanwhile copy all other nodes into the new location.
		var ulSub = null;
		for( var j = 0; j < li.childNodes.length; j++ )
		{
			var liChild = li.childNodes[j];
			if( liChild.nodeName == "UL" ) 
			{
				ulSub = liChild;
				continue; // skip this
			}
			div.appendChild( liChild.cloneNode(true) );
		}
		div.className = ulSub ? classNamesForLinksToPopUpMenus[depth] : 'lt';
		var anchors = div.getElementsByTagName('A');

		// Make sure an anchor tag exists.  Create it if it doesn't.
		var primaryAnchor;
		if( anchors.length == 0 )
		{
			primaryAnchor = document.createElement('a');
			primaryAnchor.href = "#";
			while( div.childNodes.length )
				primaryAnchor.appendChild( div.childNodes[0] );
			div.appendChild( primaryAnchor );
		} 
		else
			primaryAnchor = anchors[0];
		
		primaryAnchor.className = ulSub ? 'navBranch' : 'navLink';
		if( !ulSub && !firstLinkEncountered )
		{
			firstLinkEncountered = true;
			// Only add extra space if there were navBranch's above us
			if( i > 0 ) div.className += ' firstNavLink';
		}
		primaryAnchor.tabIndex = tabIndexCount++;
		// If this LI element had a child UL element, recurse into that
		if( ulSub ) 
		{
			if( depth == 0 )
				div.id = 'u' + getUniqueSubmenuName(i) + '_menu';
			else // assert debug == 1
				div.id = 'u' + getUniqueSubmenuName(path[0]) + '_menu.' + getUniqueSubmenuName(subMenuCount) + '_submenu';

			var param = div.id.substr(1);

			// Just setting the onclick attribute or the click event
			// seems to cause problems in various browsers.
			// This works every time.
			primaryAnchor.href = "javascript:toggleMenu('" + param + "');";
			
			path[depth] = i;
			transformHtml2(ulSub, depth+1, path);
		}
	}
}


/*********************************************************************************
 * Popup menu navigation system
 *********************************************************************************/

var sd, td, sc, tc, m1, m2, u1, u2, wn, s, t;

function preloadmenus() {
	sd = MM_findObj('secpd'); td = MM_findObj('thrpd'); sc = MM_findObj('secct'); tc = MM_findObj('thrct');
	wn = MM_findObj('whatLayer'); s = MM_findObj('second'); t = MM_findObj('third');
	m1 = m2 = u1 = u2 = null;
	var menuId = getCookie('mid');
	if (menuId != null && menuId != '')
		showMenu(menuId);
	else
		showMenu(getUniqueSubmenuName(0)+'_menu');
}

function preloadmenus2() {
	sd = MM_findObj('secpd'); td = MM_findObj('thrpd'); sc = MM_findObj('secct'); tc = MM_findObj('thrct');
	wn = MM_findObj('whatLayer'); s = MM_findObj('second'); t = MM_findObj('third');
	m1 = m2 = u1 = u2 = null;
	var menuId = getCookie('mid');
	if (menuId != null && menuId != '')
		showMenu2(menuId);
		
	else
		showMenu2(getUniqueSubmenuName(0)+'_menu');
}



function isMenuUp(menu_id) {
	var lastMenu = getCookie('mid');
	var menus = lastMenu.split('.');
	if( menu_id.indexOf('.') >= 0 )
		return lastMenu == menu_id;
	else
		return menus[0] == menu_id;
}

// This method must not return anything, as is required for being called from a 
// "javascript:" anchor link, in order to stay on the same page.
function toggleMenu(menu_id) {
	var menus = menu_id.split('.');
	if (menus.length == 1) {
		if( isMenuUp(menus[0]) ) {
			hideMenus();
			return;
		}
		hideMenus();
	} else {
		if( isMenuUp(menu_id) ) {
			hideThirdLevelMenu(menu_id);
			return;
		}
		hideThirdLevelMenu(menu_id);
	}
	showMenu(menu_id);
	keepMenuItemFocused(menu_id);
}

function keepMenuItemFocused(menu_id) {
	// For IE, ensure that the clicked menu item remains focused
	// for those keyboard enthusiasts and for accessibility requirements.
	var menuItem = document.getElementById('u' + menu_id);
	getImmediateChildrenByTagName(menuItem, 'A')[0].focus();
}

function showMenu(menu_id) {
	menus = menu_id.split('.');
	if ((m1 = MM_findObj(menus[0])) != null) {
		// 2nd level
		s.className = 'std';
		sd.style.visibility = 'visible';
		if( sc.innerHTML != m1.innerHTML ) sc.innerHTML = m1.innerHTML;
		u1 = MM_findObj('u' + menus[0]);
		if (u1 != null) u1.className = 'ls'; 
	}
	if (menus.length == 2 && (m2 = MM_findObj(menus[1])) != null) {
		// 3rd level
		t.className = 'ttd';
		td.style.visibility = 'visible';
		tc.innerHTML = m2.innerHTML;
		u2 = findNode('u' + menu_id, sc);
		if (u2 != null) u2.className = 'ls';
	}
	setCookie(menu_id, 'mid');
	return false;
}

function showMenu2(menu_id) {
	menus = menu_id.split('.');
	if ((m1 = MM_findObj(menus[0])) != null) {
		// 2nd level
		s.className = 'std';
		sd.style.visibility = 'visible';
		if( sc.innerHTML != m1.innerHTML ) sc.innerHTML = m1.innerHTML;
		u1 = MM_findObj('u' + menus[0]);
		if (u1 != null) u1.className = 'ls'; 
	}
	if (menus.length == 2 && (m2 = MM_findObj(menus[1])) != null) {
		// 3rd level
		t.className = 'ttd';
		td.style.visibility = 'visible';
		tc.innerHTML = m2.innerHTML;
		u2 = findNode('u' + menu_id, sc);
		if (u2 != null) u2.className = 'ls';
	}
	setCookie(menu_id, 'mid');
	return false;
}


function hideThirdLevelMenu(menu_id) {
	menus = menu_id.split('.');
	if( menus.length < 2 ) return;
	tc.innerHTML = ''; // hides text of third level
	td.style.visibility = 'hidden'; // hides vertical bar at left of third level
	t.className = 'htd'; // allows What's New box to resize
	
	if( u2 != null ) {
		var u2c = findNode(u2.id, sc);
		if( u2c ) u2c.className = 'l2';
	}
	m2 = null;

	setCookie(menus[0], 'mid');
}

function hideMenus() {
	sc.innerHTML = ''; tc.innerHTML = '';
	sd.style.visibility = 'hidden'; td.style.visibility = 'hidden';
	m1 = null; m2 = null;
	s.className = 'htd';
	t.className = 'htd';
	if (u1 != null) 
		u1.className = 'll';
	if (u2 != null) 
		u2.className = 'l2';
	unsetCookie('mid');
}

function setCookie(cValue, cookieID) {
	var NameOfCookie = cookieID;
	document.cookie = NameOfCookie + "=" + escape(cValue);
}

function unsetCookie(cookieID) {
	setCookie (null, cookieID);
}

function getCookie(cookieID) {
	var dc = document.cookie, prefix = cookieID + "=", 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 findNode(id, parent) {
	if( parent.id == id ) return parent;
	for( var i = 0; i < parent.childNodes.length; i++ )
		if( parent.childNodes[i].id == id )
			return parent.childNodes[i];
		else {
			var found = findNode(id, parent.childNodes[i]);
			if( found ) return found;
		}
	return null;
}

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;
}

/*********************************************************************************
 * Automatic index generation
 *********************************************************************************/

function initializePopupIndex() {
	var layerMenus = document.getElementById('LayerMenus');
	var layerIndex = document.getElementById('LayerIndex');
	var bl = getImmediateChildrenByTagName(layerMenus, 'UL')[0];
	if( !bl || !layerIndex || !layerMenus || layerIndex.childNodes.length > 0 )
		return;
	
	var targetArea = document.createElement('ul');
	layerIndex.appendChild(targetArea);
	var arrayIndex = new Array();
	generateIndex(bl, arrayIndex);
	sortIndex(arrayIndex);
	indexToHtml(targetArea, arrayIndex);
}

function sortIndex(arrayIndex) {
	arrayIndex = arrayIndex.sort();
	for (var i = 0; i < arrayIndex.length; i++)
	{
		var loc = arrayIndex[i].indexOf("%$%");
		if (loc != -1)
		{
			arrayIndex[i] = arrayIndex[i].substr(loc + 3, arrayIndex[i].length - loc - 3);
		}
	}
}

function getInnerText(inputHtml)
{
	var outputHtml = "";
	var findClose = false;
	
	inputHtml = stripWhitespace(inputHtml);
	
	for (var i = 0; i < inputHtml.length; i++)
	{
		if (findClose == true)
		{
			if ( inputHtml.substr(i, 1) == ">" )
				findClose = false;
		}

		else if ( inputHtml.substr(i, 1) == "<" )
		{
			findClose = true;
		}

		else if ( isAlphanumeric(inputHtml.substr(i, 1)) )
			outputHtml = outputHtml + inputHtml.substr(i, 1);
	}
	
	return outputHtml;
}

function generateIndex(bl, arrayIndex, prefixText) {
	var origPrefix = prefixText;
	var liTags = getImmediateChildrenByTagName(bl, 'LI');
	for( var i = 0; i < liTags.length; i++ ) {
		prefixText = origPrefix;
		if( getImmediateChildrenByTagName(liTags[i], 'UL').length ) {
			// recurse deeper into tree
			if( prefixText && prefixText.length > 0 ) 
				prefixText += ', ';
			else
				prefixText = '';
			if( liTags[i].attributes['indexText'] ) {
				if( liTags[i].attributes['indexText'].value.length )
					prefixText += liTags[i].attributes['indexText'].value;
				else
					prefixText = prefixText.substr(0, prefixText.length-2); // trim comma
			} else {
				for( var j = 0; j < liTags[i].childNodes.length; j++ )
					if( liTags[i].childNodes[j].nodeName != 'UL' && liTags[i].childNodes[j].nodeValue )
						prefixText += liTags[i].childNodes[j].nodeValue.replace(/^\s*|\s*$/g,"");
			}
			generateIndex(getImmediateChildrenByTagName(liTags[i], 'UL')[0], arrayIndex, prefixText);
		} else { // leaf node
			// liTags[i].textContent + prefixText + "%$%"  was added for searching pourposes.
			// it appends the text name and context of the link onto the beginning making alphabetical serches
			// possible. The added text is removed in the sortIndex method. Christian.
			arrayIndex[arrayIndex.length] = getInnerText(liTags[i].innerHTML) + prefixText + "%$%" + liTags[i].innerHTML + (prefixText ? "<span class='navLink'> (" + prefixText + ")</span>" : "");
		}
	}
}

function indexToHtml(targetArea, arrayIndex) {
	for( var i = 0; i < arrayIndex.length; i++ ) {
		var indexLI = document.createElement('li');
		indexLI.innerHTML = arrayIndex[i];
		if( getImmediateChildrenByTagName(indexLI, 'A').length )
			getImmediateChildrenByTagName(indexLI, 'A')[0].className = 'navLink';
		targetArea.appendChild(indexLI);
	}
}

/*********************************************************************************
 * Register all methods that need onLoad event handling.
 *********************************************************************************/
 
registerOnLoadHandler(featureInitialize);
registerOnLoadHandler(initializePopupIndex); /* this one must appear above popmenuInitialize */
registerOnLoadHandler(popmenuInitialize);
