/**
 * @author Adam Shricker
 * @revision Arianna Winters <arianna.winters@nfl.com>
 * @copyright 2007 NFL
 * @version 1.0
 */
nfl.namespace("ui.menubar");
nfl.ui.menubar = Class.create();
nfl.ui.menubar.prototype = {
	initialize: function(){
		try{
			var sfEls = document.getElementById("nav").getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onmouseover=nfl.ui.menubar.onRollOver;
				sfEls[i].onmouseout=nfl.ui.menubar.onRollOut;
			}
		}catch(err){}
	}
}
nfl.ui.menubar.onRollOver	= function(e){
	if(!($(this).hasClassName("sfhover"))){ $(this).addClassName("sfhover"); }
	if((navigator.appVersion.indexOf('MSIE 6.0')!=-1) && (this.parentNode.id=="nav") && (this.getElementsByTagName("UL").length != 0) ){ ie6CoverDropDowns(this, 'mouseover'); }
}
nfl.ui.menubar.onRollOut	= function(e){
	if($(this).hasClassName("sfhover")){ $(this).removeClassName("sfhover"); }
	if((navigator.appVersion.indexOf('MSIE 6.0')!=-1) && (this.parentNode.id=="nav") && (this.getElementsByTagName("UL").length != 0) ){ ie6CoverDropDowns(this, 'mouseout'); }
}

function ie6CoverDropDowns(menuButton, newState) 
{
	if(newState == 'mouseover')
	{
	   var DivRef = menuButton.getElementsByTagName("UL")[0];
	   var IfrRef = document.getElementById('DivShim');
	    DivRef.style.display = "block";
	    IfrRef.style.top = DivRef.offsetTop;
	    IfrRef.style.left = DivRef.offsetLeft;
	    IfrRef.style.width = DivRef.offsetWidth;
	    IfrRef.style.height = DivRef.offsetHeight;
	    IfrRef.style.zIndex = DivRef.style.zIndex + 1;
	    IfrRef.style.display = "block";
		if ( menuButton.getElementsByTagName("UL").length > 1 ) //for the teams drop down which is two ULs
		{
		   var DivRef2 = menuButton.getElementsByTagName("UL")[1];
		    DivRef2.style.display = "block";
		    IfrRef.style.width = (DivRef.offsetWidth + DivRef2.offsetWidth) - 1;  // the second UL for teams overflaps the first one, so the -1 removes a not so pretty white line next to the that dropdown in ie6
		}

	} else {
	   var DivRef = menuButton.getElementsByTagName("UL")[0];
	   var IfrRef = document.getElementById('DivShim');
	    DivRef.style.display = "none";
	    IfrRef.style.display = "none";
		if ( menuButton.getElementsByTagName("UL").length > 1 ) //for the teams drop down which is two ULs
		{
		   var DivRef2 = menuButton.getElementsByTagName("UL")[1];
		    DivRef2.style.display = "none";
		}
	}
}

if(nfl.global.eventModel != "prototype"){
	nfl.events.observe("contentloaded", function(){ nfl.menubar = new nfl.ui.menubar();});
	nfl.events.notify('libHeaderLoaded');
}else{
	document.observe("contentloaded", function(){ nfl.menubar = new nfl.ui.menubar();});
	document.fire('libHeaderLoaded');
}
