// JavaScript Document
// Author: Danny Mavromatis
// Version: 3.00.2
// Created: 10/29/2001
// Updated: 7/5/2006
// FLASH detection system
	var cId = 0;
	var aV = 0;
	var swVersion;
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	if(isIE && isWin){
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('Function VBGetSwfVer(i) \n');
		document.write('on error resume next \n');
		document.write('Dim swControl, swVersion \n');
		document.write('swVersion = 0 \n');
		document.write('set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i)) \n');
		document.write('if (IsObject(swControl)) then \n');
		document.write('swVersion = 0 \n');
		document.write('swVersion = swControl.GetVariable("$version") \n');
		document.write('end if \n');
		document.write('VBGetSwfVer = swVersion \n');
		document.write('End Function \n');
		document.write('</SCR' + 'IPT\> \n');
	} else {
		var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
		function JSGetSwfVer(i){
		      if (navigator.plugins != null && navigator.plugins.length > 0) {
		            if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
		                  var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		                        var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
		                        descArray = flashDescription.split(" ");
		                        tempArrayMajor = descArray[2].split(".");
		                        versionMajor = tempArrayMajor[0];
		                  if ( descArray[3] != "" ) {
		                        tempArrayMinor = descArray[3].split("r");
		                  } else {
		                        tempArrayMinor = descArray[4].split("r");
		                  }
		                        versionMinor = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
		                        flashVer = parseFloat(versionMajor + "." + versionMinor);
		            } else {
		                  flashVer = -1;
		            }
		      }
		      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
		      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
		      else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
		      else {
		            flashVer = -1;
		      }
		      return flashVer;
		}
	}
function checkFlash(rV){	
	var ua=navigator.userAgent.toLowerCase();
	this.webtv = (ua.indexOf("webtv")>-1);
	this.ie = (parseFloat(ua.slice(ua.indexOf("msie")+5)));
	this.nn = (parseFloat(ua.slice(ua.indexOf("mozilla/")+8)));
	var browser = navigator.appName.toLowerCase();
	if (browser=="netscape"){
	this.netscape = true;
	}else{
	this.netscape = false;
	}
	this.mac = (ua.indexOf("mac")>-1);
	this.flash = false;

	if (isIE && isWin){
		
		aV = VBGetSwfVer(rV);
		
		if (aV != 0){
			var cVArray = VBGetSwfVer(rV).split(" ");
			cVArray = cVArray[1].split(",");
			aV = cVArray[0];
		}
		
	} else {
		aV = JSGetSwfVer(rV);
	}
	
	if (aV >= rV) {
		if (this.netscape && this.IEonly == 'TRUE' || this.mac && this.IEonly == 'TRUE'){
			this.flash = false;
		} else {
			this.flash = true;
		}
	}
}

function flashObj() {
	cId += 1;
	this.flashFile = "/flash/blank.swf";
	this.LiveConnect = "FALSE";
	this.IEonly = null;
	this.wmode = "opaque";
	this.redirect = null;
	this.DenyIEdl = "FALSE";
	this.altImg = "/blank.gif";
	this.bgcolor = null;
	this.altTxt = null;
	this.height = "400";
	this.width = "520";
	this.salign="lt";
	this.align="left";
	this.flashVars = null;
	this.ID = "flash"+ cId;
	this.name = "flash"+ cId;
	this.webTV = "true";
	this.quality = "best";
	this.scale = "exactfit";
	this.menu = "false";
	this.deviceFont = "false";
	this.FlashVer = 5;
	this.cabVersion = "5,0,0,0";
	this.render = writeFlashComponent;
}
function writeFlashComponent(val) {
	var Ticket=new checkFlash(this.FlashVer);
	var sCR = "";
	
	if (Ticket.flash) {
		if (Ticket.mac || Ticket.netscape) {
			sCR='<EMBED SRC="'+this.flashFile+'" swLiveConnect="'+this.LiveConnect+'" WIDTH="'+this.width+'" HEIGHT="'+this.height+'" QUALITY="'+this.quality+'" SCALE="'+this.scale+'" FlashVars="'+ this.flashVars +'" wmode="'+this.wmode+'" ID="'+this.ID+'" NAME="'+this.name+'" MENU="'+this.menu+'" DEVICEFONT="'+this.deviceFont + '"';
			if (this.bgcolor) {
				sCR += ' BGCOLOR="'+this.bgcolor + '"';
			}
			if (this.salign) {
				sCR += ' SALIGN="'+this.salign + '"';
			}
			sCR += ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>';
		} else if (this.DenyIEdl=='TRUE') {
			sCR="<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version="+this.FlashVer+",0,0,0\" ID=\""+this.ID+"\" WIDTH=\""+this.width+"\" HEIGHT=\""+this.height+"\">\n";
			sCR+="<PARAM NAME=movie VALUE=\""+this.flashFile+"\">\n";						
			sCR+="<PARAM NAME=quality VALUE=\""+this.quality+"\">\n";
			sCR+="<PARAM NAME=scale VALUE=\""+this.scale+"\">\n";
			sCR+="<PARAM NAME=menu VALUE=\""+this.menu+"\">\n";
			sCR+="<PARAM NAME=wmode VALUE=\""+this.wmode+"\">\n";
			if (this.bgcolor){
				sCR+="<PARAM NAME=bgcolor VALUE=\""+this.bgcolor+"\">\n";
			}
			if (this.flashVars){
				sCR+="<PARAM NAME=FlashVars VALUE=\""+this.flashVars+"\">\n";
			}
			if (this.salign) {
				sCR+="<PARAM NAME=salign VALUE=\""+this.salign+"\">\n";
			}
			sCR+="<PARAM NAME=devicefont VALUE=\""+this.deviceFont+"\">\n";
			if (this.bgcolor){
			sCR+="<EMBED SRC="+this.flashFile+" swLiveConnect="+this.LiveConnect+" WIDTH="+this.width+" HEIGHT="+this.height+" QUALITY="+this.quality+" SCALE="+this.scale+" wmode="+this.wmode+" ID="+this.ID+" NAME="+this.name+" MENU="+this.menu+" DEVICEFONT="+this.deviceFont+" FlashVars="+ this.flashVars +" BGCOLOR="+this.bgcolor+" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED></OBJECT>";
			} else {
			sCR+="<EMBED SRC="+this.flashFile+" swLiveConnect="+this.LiveConnect+" WIDTH="+this.width+" HEIGHT="+this.height+" QUALITY="+this.quality+" SCALE="+this.scale+" wmode="+this.wmode+" ID="+this.ID+" NAME="+this.name+" MENU="+this.menu+" DEVICEFONT="+this.deviceFont+" FlashVars="+ this.flashVars +" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED></OBJECT>";
			}
		} else if (Ticket.ie>=4 && this.DenyIEdl=='FALSE') {
			sCR="<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version="+this.cabVersion+"\" ID=\""+this.ID+"\" WIDTH=\""+this.width+"\" HEIGHT=\""+this.height+"\">\n";
			sCR+="<PARAM NAME=movie VALUE=\""+this.flashFile+"\">\n";						
			sCR+="<PARAM NAME=quality VALUE=\""+this.quality+"\">\n";
			sCR+="<PARAM NAME=scale VALUE=\""+this.scale+"\">\n";
			sCR+="<PARAM NAME=menu VALUE=\""+this.menu+"\">\n";
			sCR+="<PARAM NAME=wmode VALUE=\""+this.wmode+"\">\n";
			if (this.flashVars){
				sCR+="<PARAM NAME=FlashVars VALUE=\""+this.flashVars+"\">\n";
			}
			if (this.bgcolor){
				sCR+="<PARAM NAME=bgcolor VALUE=\""+this.bgcolor+"\">\n";
			}
			if (this.salign) {
				sCR+="<PARAM NAME=salign VALUE=\""+this.salign+"\">\n";
			}
			sCR+="<PARAM NAME=devicefont VALUE=\""+this.deviceFont+"\">\n";
			sCR+="</OBJECT>\n";
		} else if (Ticket.webtv) {
			sCR="<EMBED SRC="+this.flashFile+" swLiveConnect=TRUE WIDTH="+this.width+" HEIGHT="+this.height+" QUALITY="+this.quality+" SCALE="+this.scale+" wmode="+this.wmode+" ID="+this.ID+" NAME="+this.name+" MENU="+this.menu+" DEVICEFONT="+this.deviceFont+" FlashVars="+ this.flashVars +" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED>";
		}
	} else {
	if (this.redirect){
	 top.location.href = this.redirect;
	} else {
			if (this.altTxt){
			sCR = this.altTxt;
			} else {
			sCR="<IMG SRC="+this.altImg+" WIDTH="+this.width+" HEIGHT="+this.height+" BORDER=0>";
			}
		}
		}
		
		
	if (val == true) {
		document.write(sCR);
	} else{
		return sCR;
	}
}



// COOKIES.JS (PARTIAL)

var today = new Date();
var oneYear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
var oneMonth = new Date(today.getTime() + 30 * 24 * 60 *60 * 1000);
var oneWeek = new Date(today.getTime() + 7 * 24 * 60 *60 * 1000);
var oneDay = new Date(today.getTime() + 24 * 60 *60 * 1000);

function GetCookieUtil (name) {
	var result = null;
	var myCookie = " " + document.cookie + ";";
	var searchName = " " + name + "=";
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	if (startOfCookie != -1) {
		startOfCookie += searchName.length;
		endOfCookie = myCookie.indexOf(";", startOfCookie);
		result = unescape(myCookie.substring(startOfCookie, endOfCookie));
	}
	return result;
}

// MOTION.JS

function changeMotionImage (imageName) {
  document.getElementById('motionImage').src = imageName;
}

function playMotionLegacy(id,cat,subcat) {
	var catstr = "";
	if(cat!=null) 
		catstr = "&category="+cat;
	if(subcat!=null) 
		catstr = catstr+"&subcategory="+subcat;
	if(id!=null) {
		if(cat!=null && cat.toLowerCase()=="torino")
			window.open("http://sports.espn.go.com/broadband/motion/echo/oly?id="+id, "mWin", "width=737,height=410");
		else
			window.open("http://sports.espn.go.com/broadband/motion/echo/index?id="+id+catstr, "mWin", "width=737,height=410");
		var host = document.location.hostname;
		if(host=="espn.go.com" || host=="sports.espn.go.com") {
			if(frames['fsp']) 
				frames['fsp'].stop();
		}
	}	
}

function playMotion(id,cat,subcat) {
	playVideo(id);
}

function playVideo(id,cat) {
	var catstr = "";
	if(id==null)
		id = "";	
	if(cat!=null)
		catstr = "&catname="+cat;	
	window.open("http://sports.espn.go.com/broadband/ivp/index?id="+id+catstr, "mWin", "status=0,top=0,left=0,width=1014,height=620");
	var host = document.location.hostname;
	if(host=="espn.go.com" || host=="sports.espn.go.com" || host=="sports-att.espn.go.com") {
		if(frames['fsp']) 
			frames['fsp'].stop();
	}	
}

function playVideoDeportes(id) {
	var idpart = "";
	if(id!=null)
		idpart = "&id="+id;
	window.open("http://sports.espn.go.com/broadband/ivp/index?lang=es"+idpart, "mWin", "status=0,top=0,left=0,width=1014,height=620");
}	

// UNIVERSAL LOGIN JS
var swid = "";
var green = "";
var cookies = document.cookie.split("; ");
var regReq = null;
var regURL = 'http://r.espn.go.com/espn/preferences/passiveLogin?appRedirect=http%3A%2F%2Fespn-att.starwave.com%2Fi%2Fblank.gif';
var returnURL = document.location.href;
var xmlURL = 'http://sports-att.espn.go.com/espn/unilogin/loggedIn';
var debug;
var finalOutput;
var appRedirect = 'null';
if (appRedirect != '' && appRedirect != 'null')	{
	returnURL = appRedirect;
}
if (returnURL.indexOf("univLogin02", 0) == -1) {
	if (returnURL.indexOf("?",0) == -1)	{
		returnURL = returnURL + "?univLogin02=stateChanged";
	} else {
		returnURL = returnURL + "&univLogin02=stateChanged";	
	}
}
function getCookie(name) {
	for (var i=0; i < cookies.length; i++) {
	  cookie = cookies[i].split("=");
	  if (cookie[0] == name)
		return cookie[1];
	  }
	  return null;
}
swid = getCookie("SWID");
green = getCookie("GREEN");
if (green == "" || green == null) {
	green = null;  
}
if (swid == "" || swid == null) {
	swid = null;  
}

// HORIZ NAV JS
/*
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];
			if (theElem.type.substr(0,6) == "select") {
				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].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].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;
    }
}

