var nav = new Object();

nav.init = function() {	
  try {	
    // this class used in the ff_dw_ function for team name and team alias to apply the boldness
   // document.write('<style>.teamId' + fucfb.teamId + '{font-weight:bold}</style>');
    var pathName = window.location.pathname;
    var queryString = window.location.search;
    queryString = queryString.substring(1);          
    document.getElementById(navOnId).className = "mainOn";
    document.getElementById(navOnId).setAttribute("originalClass", "mainOn");    
   // document.getElementById(navOnId + "NavSub").style.display = "block";
    
    var subnav = document.getElementById(navOnId + "NavSub");
    if(subnav){     
       subnav.style.display = "block";           
       var aTags = subnav.getElementsByTagName("A");
        var args = GetArgs();
    		
        for (var i=0; i < aTags.length; i++) {
          	
    					var aTagHref = aTags[i].href;
    					if (navSubOnId == aTags[i].id) {
    						aTags[i].className = 'on';
    						break;
    					}
    			
        }
    }    

  }
  catch(e) {
    ////////// ignore error
  }
  
}

var widgetNav = {};

widgetNav.init = function() {
	$$("#navBar .navBarList li.main").each(function(node){   
	   if (node.getElementsByTagName('ul').length > 0) {             
	        fim.events.addEvent(node, 'mouseover', widgetNav.getMoverFor(node), false);
	        fim.events.addEvent(node, 'mouseout', widgetNav.getMoutFor(node), false);
	   }
	});
}

widgetNav.showSelects = function(type) {
	  // this is only a problem in IE6 and lower.  let's not hide the selects unless we have since it is a little jarring to the user
	  if (!IE) return;
	  if (IE7) return;
	  var selects = document.getElementsByTagName('select');
	  for (var i = 0; i < selects.length; i++) {
	    selectNode = selects[i];
	    if (type) {
	      selectNode.style.visibility = "visible";
	    }
	    else {
	      selectNode.style.visibility = "hidden";
	    }
	  }
	}

fim.events.addEvent(window, 'load', widgetNav.init, false);

widgetNav.getMoverFor = function(node) {
  return function(e) { widgetNav.mover(e, node); };
}

widgetNav.getMoutFor = function(node) {
  return function(e) { widgetNav.mout(e, node); };
}

widgetNav.mover = function(e, targetElement) {  
  var el = window.event ? targetElement : e ? e.currentTarget : null;   
  if (!el) return;
  clearTimeout(el.outTimeout);  
  el.className = "mainOver";  
  var nextNav = $(el).next(0);   
  if(nextNav && $(nextNav).readAttribute("originalclass") && $(nextNav).readAttribute("originalclass") == "mainOn"){  
    nextNav.className = 'mainOnBorder';   
  }    
  el.down("ul",0).style.display = 'block';    
  hideSelectForNav(el);
}

widgetNav.mout = function(e, targetElement) {  
  var el = window.event ? targetElement : e ? e.currentTarget : null;
  if (!el) return;
  el.outTimeout = setTimeout(function() { widgetNav.mout2(el); }, 300);  
}

widgetNav.mout2 = function(el) {  
  var originalClass = "main";
  var elOriginalClass = el.getAttribute("originalclass"); // this gets set in the nav.init function
  if (elOriginalClass == "mainOn") {
    originalClass = elOriginalClass;
  }
  el.className = originalClass; 
  var nextNav = $(el).next(0);  
  if(nextNav && $(nextNav).readAttribute("originalclass") && $(nextNav).readAttribute("originalclass") ==  "mainOn") {
     nextNav.className = 'mainOn';
  } 
    
  el.down("ul",0).style.display = 'none';  
  unhideSelectForNav(el);
}

// Hide all select boxes
function hideSelectForNav(el) {
  var listTag  = el.getElementsByTagName("UL")[0]; 
   
  if (document.all && (navigator.appVersion.substr(22,3)=="5.0" || navigator.appVersion.substr(22,3)=="6.0")) {   
   var iFrame = document.getElementById(el.id+"Iframe");                      
   var menuItems = listTag.getElementsByTagName("LI");         
   var height = 0;
   var width = 0;
   
   for(var i=0; i< menuItems.length;i++){   
     height += menuItems[i].offsetHeight;//+0.8;//0.8              
   } 
     
   var coords =  calculatePosition(el);
   iFrame.style.top = (parseInt(coords[1])-201)+"px"; 
   iFrame.style.height = (parseInt(height)-2)+"px";     
   iFrame.style.left = document.getElementById("navBarList").style.left;   
   iFrame.style.backgroundColor = "transparent";    
   iFrame.style.visibility ="visible";
  
  }     
}

// Unhide all select boxes
function unhideSelectForNav(el) {
  if (document.all && (navigator.appVersion.substr(22,3)=="5.0" || navigator.appVersion.substr(22,3)=="6.0")) {  
  document.getElementById(el.id+"Iframe").style.visibility = "hidden";  
  document.getElementById(el.id+"Iframe").style.height = "0px";
  }
}


