/* mainNavigationSelect()
*************************
Selects a tier-1 mainNavigation element.
*/
function mainNavigationSelect(tier1) {
   $('#'+tier1).addClass('selected');
}


/* subNavigationSelect()
************************
Selects a tier-3 subNavigation element based on the integer index
url parameter "subNav". The regex returns a string, but the 
accordion requires an integer and therefore we parseInt.

This can also selects a tier2 element.
*/
function subNavigationSelect(subNavigationId, tier2, tier3) {
	var tier2options = $('.subNavigationTier2');

	for (var i=0; i < tier2options.length; i++) {
		var children = $(tier2options[i]).children();
		
		for (var j=0; j < children.length; j++) {
			if ((tier2 != '') && (children[j].id == tier2)) {
				if (tier3 != false) {
   				$('#'+subNavigationId).accordion({active: i, autoHeight: false});
				}
				
				$('#'+tier2).addClass('selected');
			}
		}
	}

   if (tier3 != '') {
   	$('#'+tier3).addClass('selected');
	}
}

/*
function subNavigationSelectFromURL(subNavigationId) {
   var regex = new RegExp("(tier2=)([a-zA-Z0-9_]+)");
	var matches = regex.exec(location.href);

	if (matches != null) {
	   var tier2options = $('.subNavigationTier2');

		for (var i=0; i < tier2options.length; i++) {
		   var children = $(tier2options[i]).children();
			
         if (children[0].id == matches[2]) {
			   $(subNavigationId).accordion({active: i});
			}
		}
	}

   var regex = new RegExp("(tier3=)([a-zA-Z0-9_]+)");
	var matches = regex.exec(location.href);

	if (matches != null) {
	   var selector = '#' + matches[2];
		$(selector).addClass('selected');
	}
}
*/