/* begin nav */
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];
			if (theElem.type.substr(0,6) == "select") {
				hideElements.push(theElem);
			}
		}
	}
}

function initnav(obj) {

	var av = navigator.appVersion.toLowerCase();
	var platform;
	// check platform
	if (av.indexOf("mac") != -1) {
		platform = "mac";
	} else if (av.indexOf("windows") != -1) {
		platform = "win";
	}

	var isIE = (navigator.appName == "Microsoft Internet Explorer");

	if (document.getElementById && document.getElementById(obj)) {
		navRoot = document.getElementById(obj);
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			// make sure drop downs don't extend past 990
			// 694 comes from supporting a double menu near the end
			if (node.offsetLeft > 694) {
				var adjust = 694-node.offsetLeft;
				for (var j=0; j<node.childNodes.length; j++) {
					if (node.childNodes[j].nodeName.toUpperCase() == 'UL') {
						
						if(node.childNodes[j].className.indexOf("double")!=-1) {
							// double menu
							node.childNodes[j].style.left = adjust+'px';
						}else if(node.offsetLeft>775) {
							// 81 is to compensate for a double
							node.childNodes[j].style.left = adjust+81+'px'
						}
					}
				}
			}
			node.onmouseover = function() {
				if (this.className.indexOf('lo') != -1) {
					if (this.className.indexOf('solid') != -1) {
						this.className = 'hi solid';
					} else {
						this.className = 'hi';
					}
					
					if (isIE) {
						for (e=0; e<hideElements.length; e++) {
							var formElem = document.getElementById(hideElements[e].id);
							if (formElem != null) {
								formElem.style.visibility = 'hidden';
							}
						}
						
					}
				}
			}
			node.onmouseout = function() {
				if (this.className.indexOf('hi') != -1) {
					if (this.className.indexOf('solid') != -1) {
						this.className = 'lo solid';
					} else {
						this.className = 'lo'
					}
					
					if (isIE) {
						for (e=0; e<hideElements.length; e++) {
							var formElem = document.getElementById(hideElements[e].id);
							if (formElem != null) {
								formElem.style.visibility = 'visible';
							}
						}
						
					}
				}
			}
		}
	}
	
	if (navigator.appName == "Microsoft Internet Explorer" && platform != "mac") {
		isIE = true;
		window.attachEvent("onload", findForm);
		//window.onload = findForm;
	}
}
/* end nav */

/* begin cookie */
var cookies = document.cookie.split("; ");
function getCookie(name) {
	for (var i=0; i < cookies.length; i++) {
	  cookie = cookies[i].split("=");
	  if (cookie[0] == name)
		return cookie[1];
	  }
	  return null;
}
/* end cookie */

/* begin CJ JS For Search Box 1/22/07*/
function swapSearch(type) {
	if (type != null) {
		// Set form action
		document.searchBox.page.value = getSearchAction(type);
		
		// New multimedia action url
		if (type == "Video") {
			document.searchBox.searchStr.name = "queryString";
			document.searchBox.action = "http://sports.espn.go.com/broadband/video/search";
		}

		// Clear CSS styles
		document.getElementById('searchBox-ESPN').className="none";
		document.getElementById('searchBox-Photos').className="none";
		document.getElementById('searchBox-Video').className="none";

		// Highlight what user clicked
		setTimeout(function(){document.getElementById('searchBox-'+type).className="realm";},100);
	}
}
function getSearchAction(type) {
	action="espn";
	if (type == "Photos") {
		action = "images"
	}
	else if (type == "Video") {
		action = "multimedia";
	}
	return action;
}
/* end CJ JS For Search Box 1/22/07*/

function gotosite(loc) {
	if(loc != null && loc != '') {
		location.href = loc;
		//window.location = loc;
	}
}

/* used for fantasy popup code generated by player linker tool */
var subWindow = null
function newWin(url)    {
if (url.indexOf('http')<0){
	url = "http://games.espn.go.com"+url
}
if (!subWindow || subWindow.closed) {
    subWindow = window.open(url,"newWin",'width=800,height=525,resizable=yes,scrollbars=yes,location=yes,status=yes,toolbar=yes,menubar=yes,directories=yes')
} else {
    subWindow.focus();
    subWindow = window.open(url,"newWin",'width=800,height=525,resizable=yes,scrollbars=yes,location=yes,status=yes,toolbar=yes,menubar=yes,directories=yes')
    }
}        
