
var baseURL;
var targetObj;
var navMode = 'LNS';

function fixIE6(targObj){

	if (window.attachEvent){
		
		$("#" + targObj + " li").each(function(i){
											   
			$(this).mouseover(function(){
				$(this).addClass("sfhover");
			});
			$(this).mouseout(function(){
				$(this).removeClass("sfhover");
			});
		});
	}
}


function navInit(navObj){
	
	if(navMode != 'sitemap'){

		//first we rewrite the links in the navigation object to the baseURL we have set for the site
		$('div#' + navObj + ' a').each(function(){ 
			var rellink = $(this).attr('href');
			if(rellink.indexOf('http://') == -1)$(this).attr('href', baseURL + rellink); 
		});
		
		if(targetObj != null){

			//we set the class of all li items as 'selected' or 'off'
			$('#' + navObj + ' ul li ul li').each(
				function(){
					if($(this).attr('class') != 'selected'){
						$(this).attr('class', 'off');
						$(this).children("ul").hide();
					}
					else
						$(this).parents('li').attr('class', 'selected');	
				}
			);
			//let's make sure an item is selected in the sub menu
			var selectedItems = $('#' + navObj + ' ul li.selected ul li.selected');
			//none are selected
			if(selectedItems.length == 0){
				//let's try to match the URL of the selected GNS item with a sub nav URL
				var selectedLink = $('#' + navObj + ' ul li.selected a').attr('href');
				//get the subnavs
				var subnavs = $('#' + navObj + ' ul li.selected ul li a');
	
				$(subnavs).each(
					//if there's a match then select the subnav
					function(){ if($(this).attr('href') == selectedLink){ $(this).parent().attr('class','selected'); } }							
				);
			}
			//we populate a subnav object with the section menu from the navigation object
			var NavMenu = $('#' + navObj + ' ul li.selected');
			if(NavMenu.length > 0)
				$("#" + targetObj).append($(NavMenu[0]).children('ul').clone());
		}
	}
	else{
		var NavMenu = $('#' + navObj + ' ul');
		$("#" + targetObj).append($(NavMenu[0]).children('li').clone());
	}
}