function getElem(elName)
{
	return document.getElementById?document.getElementById(elName):null;
}

function gotosite(loc)
{
	if(loc != null && loc != '')
	{
		location.href = loc;
	}
}

var navLoaded = false;
var navFirstRun = true;
var navTimer;
var navLoading = false;
function pollNav()
{
	var htmlRoot = getElem('gNav');
	var func;
	if(document.all && false)
	{
		func = function()
		{
			executeXML('/' + g_Sport + '/xml/xmlNav?sport=nba', 'nav', false, loadNav, []);
		}
		window.attachEvent('onload', func);
	}
	else
	{
		if(!htmlRoot && navFirstRun)
		{
			navTimer = setInterval('pollNav();',1000);
		}
		else if(htmlRoot)
		{
			clearInterval(navTimer);
			
			//if(!document.all)
			//{
				executeXML('/' + g_Sport + '/xml/xmlNav?sport=nba', 'nav', false, loadNav, []);
			//}
		}
	}
	navFirstRun = false;
}

function loadNav()
{
	var el = getElem('gNav');
	var doc = this.getXMLDoc();
	var node = doc.getElementsByTagName('nav')[0];
	var value = node.childNodes[0].nodeValue;
	value = value.replace(/#b#/g,'\'');
	el.innerHTML = value;
	navLoaded = true;
	setNav();
}

/*
ESPN.com Horizontal dropdown nav
Last Updated 08.01.2005
*/



hideElements = new Array();

// hides selectors when user rolls over horizontal dropdown
function findForm() {
	//alert('this is ie');
	//hideElements = new Array();
	for (var f=0; f<window.document.forms.length; f++) {
		var theForm = window.document.forms[f];
		for (var e=0; e<theForm.elements.length; e++) {
			var theElem = theForm.elements[e];
			// srielly added the length check because the orbot is being served w/ null id's
			//   and the script dies in ie because of it.  
			if ((theElem.type.substr(0,6) == "select") && trim(theElem.id).length>0) {
				hideElements.push(theElem);
			}
		}
	}
}


// set up month rollover scripts
function setNav() {

	// decide if dropdown should hide any flash objects on the page
	var av = navigator.appVersion.toLowerCase();
	var ua = navigator.userAgent.toLowerCase();
	var platform;
	var browser;
	var hideFlash = false;
	var hideAd = false;
	if (av.indexOf("mac") != -1) {
		platform = "mac";
	} else if (av.indexOf("windows") != -1) {
		platform = "win";
	}
	if (ua.indexOf("firefox") != -1) {
		browser = "firefox";
	}

	// if firefox...
	if (browser == "firefox") {
		//alert('user has firefox');
		hideFlash = true;
	}
	
	if (browser == "firefox" || ua.indexOf("safari") != -1) {
		hideAd = true;
	}



	// swfPresent will be defined if hiding swfs
	if (window.swfList) {
		swfPresent = true;
		//alert('hiding: '+swfsToHide);
		//alert(swfList.length);
	} else {
		swfPresent = false;
		//alert('nothing to hide');
	}
	


	// drop down
	if (document.getElementById && document.getElementById("topNav")) {
		navRoot = document.getElementById("topNav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.className == "collapsed") {
			
				node.onmouseover = function() {
					this.className = 'expanded';
					
					// testing form thing
					if (isIE) {
						for (e=0; e<hideElements.length; e++) {
							var formElem = document.getElementById(hideElements[e].id);
							if (formElem != null) {
								formElem.style.visibility = 'hidden';
							}
						}
						
					}
					
					// This hides the flash object(s)
					if (hideFlash && swfPresent) {
						for (var s=0; s<swfList.length; s++) {
							var flashobject = document.getElementById(swfList[s]);
							flashobject.style.visibility = 'hidden';
						}
					}
					
					/*
					// hides wide ad
					if (hideAd) {
						if (document.getElementById('adWrap') != null) {
							var adDiv = document.getElementById('hideThisDiv');
							var adWrap = document.getElementById('adWrap');
							adWrap.style.height = '46px';
							//adWrap.style.backgroundColor = '#48AF38';
							adDiv.style.display = 'none';
						}
					}
					*/
					
					// hides ad
					if (hideAd && this.childNodes[1] != null && this.childNodes[1].innerHTML == "More [+]") {
						if (document.getElementById('ad_InContent') != null) {
							document.getElementById('ad_InContent').style.height = '262px';
						} else if (document.getElementById('ad_Poster') != null) {
							document.getElementById('ad_Poster').style.height = '612px';
						}
						var adObj1 = document.getElementById('ad');
						var adObj2 = document.getElementById('adslug');
						if (adObj1 != null) {
							adObj1.style.display = 'none';
						}
						if (adObj2 != null) {
							adObj2.style.display = 'none';
						}
					}
				}
				
				node.onmouseout = function() {
				this.className = 'collapsed';
					
					// testing form thing
					if (isIE) {
						for (e=0; e<hideElements.length; e++) {
							var formElem = document.getElementById(hideElements[e].id);
							if (formElem != null) {
								formElem.style.visibility = 'visible';
							}
						}
						
					}
					
					// This unhides the flash object(s)
					if (hideFlash && swfPresent) {
						for (var s=0; s<swfList.length; s++) {
							var flashobject = document.getElementById(swfList[s]);
							flashobject.style.visibility = 'visible';
						}
					}
					
					/*
					// unhides wide ad
					if (hideAd) {
						if (document.getElementById('adWrap') != null) {
							var adDiv = document.getElementById('hideThisDiv');
							var adWrap = document.getElementById('adWrap');
							adWrap.style.height = '46px';
							adDiv.style.display = 'block';
						}
					}
					*/
					
					// unhides ad
					if (hideAd && this.childNodes[1] != null && this.childNodes[1].innerHTML == "More [+]") {
						var adObj1 = document.getElementById('ad');
						var adObj2 = document.getElementById('adslug');
						if (adObj1 != null) {
							adObj1.style.display = 'block';
						}
						if (adObj2 != null) {
							adObj2.style.display = 'block';
						}
					}
					
				}
				
				for (j=0; j<node.childNodes.length; j++) {
					if (node.childNodes[j].className == "dropContainer") {
						elem = node.childNodes[j];
						for (k=0; k<elem.childNodes.length; k++) {
						
							// find 1st tier dropdowns
							if (elem.childNodes[k].className == "dropMenu" || elem.childNodes[k].className == "anchorDropMenu") {
								menuElem = elem.childNodes[k];
						
								for (q=0; q<menuElem.childNodes.length; q++) {

						
									if (menuElem.childNodes[q].className == "dropItem") {
										dropElem = menuElem.childNodes[q];
										dropElem.onmouseover = function() {
											//
											this.className = 'dropItemHi';
										}
										dropElem.onmouseout = function() {
											//
											this.className = 'dropItem';
										}
									
										// find 1st tier drop items that are also 2nd tier dropdowns
										for (d=0; d<dropElem.childNodes.length; d++) {
											if (dropElem.childNodes[d].className == "dropMenu2") {
												// found one
												tier2Item = dropElem.childNodes[d];
												// assign rollovers
												for (r=0; r<tier2Item.childNodes.length; r++) {
													if (tier2Item.childNodes[r].className != "rule") {
														tier2Item.childNodes[r].onmouseover = function() {
															this.className = 'dropItemHi';
														
														}
														tier2Item.childNodes[r].onmouseout = function() {
															this.className = 'dropItem';
														}
													}
												}
											}
										}
									} else if (menuElem.childNodes[q].className == "dropItem_s") { // special drop item, i.e. partner sites
										dropElem = menuElem.childNodes[q];
										dropElem.onmouseover = function() {
											//
											this.className = 'dropItemHi_s';
										}
										dropElem.onmouseout = function() {
											//
											this.className = 'dropItem_s';
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	
	if (navigator.appName == "Microsoft Internet Explorer" && platform != "mac") {
		isIE = true;
		window.attachEvent("onload", findForm);
		//window.onload = findForm;
	}	
	
	
}


function goTo(where) {
	window.location = where;
}

function goToNew(where,winName,features) {
	window.open(where,winName,features);
}


// do it
window.onload = setNav;

// unrelated for html dropdowns
function gotosite(site) {
    if (site != "") {
        window.location=site;
    }
}

/* 2ndlnBar Swann-20050330*/




pollNav();
function getElem(elName)
{
	return document.getElementById?document.getElementById(elName):null;
}

function gotosite(loc)
{
	if(loc != null && loc != '')
	{
		location.href = loc;
	}
}
var requests = new Object();
var xmlReqInProgress = false;
function RequestFactory()
{
	this.createRequest = function(rID, url, needsLoading)
	{
		var r;
		if(!xmlReqInProgress)
		{
			xmlReqInProgress = true;
			if(!requests[rID])
			{
				if(window.XMLHttpRequest)
				{
					r = new XMLHttpRequest();
					requests[rID] = new XMLRequest(r, needsLoading);
	        		requests[rID].req.open('GET', url, true);
					requests[rID].req.send(null);
				}
				else if(window.ActiveXObject)
				{
					r = new ActiveXObject('Microsoft.XMLHTTP');
					if(r)
					{
						requests[rID] = new XMLRequest(r, needsLoading);
						requests[rID].req.open('GET', url, true);
						requests[rID].req.send();
					}
				}
				else
				{
					requests[rID] = null;
				}
			}
			return requests[rID];
		}
		else
		{
			return null;
		}
	}
}
function getOffSets()
{
	var x,y;
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	
	return new Array(x,y);
}
var selfXMLR;
function XMLRequest(req, needsLoading)
{
	selfXMLR = this;
	this.req = req;
	this.isInit = false;
	this.interval = 0;
	this.executing = false;
	this.isFirstRun = true;
	this.func = null;
	this.args = new Array();
	this.div = null;
	this.needsLoading = needsLoading;
	
	this.init = function()
	{
		if(this.req.readyState == 4)
		{
			if(this.req.status == 200)
			{
				this.isInit = true;
			}
		}
		
		if(!this.isInit)
		{
			if(this.isFirstRun)
			{
				this.interval = setInterval('selfXMLR.init()', 2);
			}
		}
		else
		{ 
			clearInterval(this.interval);
			if(this.executing)
			{
				this.execute();
			}
		}
		this.isFirstRun = false;
	}
	
	this.createLoadingHolder = function()
	{
		/*
		var body = document.getElementsByTagName('body')[0];
		var y = getOffSets()[1];
		this.div = document.createElement('div');
		this.div.setAttribute('id', 'loadingDiv');
		this.div.style.width = '100%';
		this.div.style.fontWeight = 'bold';
		this.div.style.backgroundColor = '#FFFFFF';
		this.div.style.color = '#000000';
		this.div.style.padding = '10px';
		this.div.style.display = 'none';
		this.div.style.position = 'absolute';
		this.div.style.top = y + 'px';
		this.div.style.left = '0px';
		this.div.style.zIndex = 100;
		this.div.appendChild(document.createTextNode('Loading...'));
		if(body)
		{
			body.appendChild(this.div);
		}
		*/
	}
	
	this.hideLoading = function()
	{
		//this.div.style.display = 'none';
	}
	
	this.showLoading = function()
	{
		//this.div.style.display = 'block';
	}
	
	this.createMethod = function(func, args)
	{
		this.func = func;
		this.args = args;
	}
	
	this.getXMLDoc = function()
	{
		return this.req.responseXML;
	}
	
	this.execute = function()
	{
		this.executing = true;
		if(this.needsLoading)
		{
			this.showLoading();
		}
		if(this.isInit)
		{
			clearInterval(this.interval);
			this.func.apply(this,this.args);
			this.hideLoading();
			xmlReqInProgress = false;
		}
		else
		{
			this.init();
		}
	}
	
	this.createLoadingHolder();
	this.init();
}
var rf = new RequestFactory();
var rque = new Array();
var ids = new Object();
var currentReq = null;

function proxyReq()
{
	this.url = null;
	this.id = null;
	this.nl = null;
	this.f = null;
	this.args = null;
}

function executeXML(url, id, needsLoading, func, args)
{
	var req = null;
	var newArgs;
	var success = false;
		
	if(id != null && id != '')
	{
		if(ids[id] == null)
		{
			ids[id] = new proxyReq();
			ids[id].url = url;
			ids[id].id = id;
			ids[id].nl = needsLoading;
			ids[id].f = func;		
			
			if(!args || typeof args != 'object')
			{
				newArgs = 'new Array(\'\')';
			}
			else
			{
				newArgs = 'new Array(';
				for(var i = 0; i < i.length; i++)
				{
					if(i < i.length -1)
					{
						newArgs += '\'' + args[i] + '\',';
					}
					else
					{
						newArgs += '\'' + args[i] + '\'';
					}
				}
				newArgs += ')';
			}
			ids[id].args = newArgs;
		}
		
		req = rf.createRequest(id, url, needsLoading);
		if(req != null)
		{
			req.createMethod(func,args);
			req.execute(req);
			success = true;
		}
		else if(ids[id] != null)
		{
			if(currentReq == ids[id] || currentReq == null)
			{
				setTimeout('executeXML(\'' + ids[id].url + '\',\'' + ids[id].id + '\',' + ids[id].nl + ',' + ids[id].f + ',' + ids[id].args + ');',2);
			}
		}
	}
	currentReq = ids[id];
	return success;
}