// Flash Detect & Renderer

var VBS_Result = false;

function CNN_FlashDetect() { }

CNN_FlashDetect.prototype.maxVersionToDetect = 9;
CNN_FlashDetect.prototype.minVersionToDetect = 3;

CNN_FlashDetect.prototype.hasPlugin = ( navigator.mimeTypes &&
		navigator.mimeTypes.length &&
		navigator.mimeTypes["application/x-shockwave-flash"] &&
		navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin );

CNN_FlashDetect.prototype.hasActiveX = window.ActiveXObject;

CNN_FlashDetect.prototype.hasWinIE = ( navigator.userAgent &&
		( navigator.userAgent.indexOf( "MSIE" ) != -1 ) &&
		navigator.appVersion &&
		( navigator.appVersion.indexOf( "Win" ) != -1 ) );

CNN_FlashDetect.prototype.getVersion = function () {
	var versionNum = 0;
	var i = 0;

	if ( this.hasActiveX ) {
		var activeXObject = false;
		for ( i = this.maxVersionToDetect; i >= this.minVersionToDetect && !activeXObject; versionNum = ( activeXObject ? i : versionNum ), i-- ) {
			try {
				activeXObject = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
			} catch( e ) {
				// do nothing
			}
		}
	} else if ( this.hasWinIE ) {
		VBS_Result = false;
		for ( i = this.maxVersionToDetect; i >= this.minVersionToDetect && !VBS_Result; versionNum = ( VBS_Result ? i : versionNum ), i-- ) {
			execScript( 'on error resume next: VBS_Result = IsObject( CreateObject( "ShockwaveFlash.ShockwaveFlash.' + i + '" ) )', 'VBScript' );
		}
	} else if ( this.hasPlugin ) {
		if ( navigator.plugins && navigator.plugins.length && navigator.plugins["Shockwave Flash"] ) {
			var words = navigator.plugins["Shockwave Flash"].description.split( " " );
			for ( i = 0; i < words.length; ++i ) {
				if ( isNaN( parseInt( words[i] ) ) )
					continue;
				versionNum = words[i];
			}
		}
	}

	return ( versionNum );
}

CNN_FlashDetect.prototype.detectVersion = function ( num ) {
	var isVersionSupported = false;

	if ( ! isNaN( num ) ) {
		isVersionSupported = ( this.getVersion() >= parseInt( num ) );
	}

	return ( isVersionSupported );
}


function CNN_FlashObject( p_name, p_src, p_width, p_height, p_parameters, p_flashVars ) {
	this.m_name			= p_name;
	this.m_src			= p_src;
	this.m_width		= p_width;
	this.m_height		= p_height;
	this.m_flashVars	= p_flashVars;

// constructor
	if ( p_parameters )
	{
		this.setParams( p_parameters );
	}
}

// Declare member properties
CNN_FlashObject.prototype.m_name = '';
CNN_FlashObject.prototype.m_src = '';
CNN_FlashObject.prototype.m_width = '';
CNN_FlashObject.prototype.m_height = '';
CNN_FlashObject.prototype.m_flashVars = '';

CNN_FlashObject.prototype.m_params = {
	menu:		"false",
	quality:	"high",
	wmode:		"transparent"
};

CNN_FlashObject.prototype.setParam = function ( p_name, p_value ) {
	this.m_params[ p_name.toLowerCase() ] = p_value;
}

CNN_FlashObject.prototype.setParams = function ( p_paramHash ) {
	if ( typeof p_paramHash == "object" ) {
		for ( var param in p_paramHash ) {
			if ( p_paramHash[param] ) {
				this.setParam( param, p_paramHash[param] );
			}
		}
	}
}

CNN_FlashObject.prototype.getParam = function ( p_name ) {
	return ( this.m_params[ p_name.toLowerCase() ] );
}

CNN_FlashObject.prototype.getParams = function () {
	return ( this.m_params );
}

CNN_FlashObject.prototype.getFlashVarsString = function () {
	var flashVarsString = '';

	if ( typeof this.m_flashVars == "string" ) {
		flashVarsString = this.m_flashVars;
	} else if ( typeof this.m_flashVars == "object" ) {
		for ( var flashVar in this.m_flashVars ) {
			if ( flashVarsString != '' ) {
				flashVarsString += "&";
			}
			flashVarsString += flashVar + "=" + escape( this.m_flashVars[flashVar] );
		}
	}

	return ( flashVarsString );
}

CNN_FlashObject.prototype.getAttributeString = function ( p_attr, p_value ) {
	return ( p_value ? ' ' + p_attr + '="' + p_value + '"' : '' );
}

CNN_FlashObject.prototype.getParamTag = function ( p_name, p_value ) {
	return ( p_value ? '<param name="' + p_name + '" value="' + p_value + '">' : '' );
}

CNN_FlashObject.prototype.getHtml = function () {
	var htmlString = '';
	var eachParam = '';
	var flashUrl = 'http://www.macromedia.com/go/getflashplayer';

// open object
	htmlString += '<object type="application/x-shockwave-flash" \
					classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	htmlString += this.getAttributeString( 'pluginspage', flashUrl );
	htmlString += this.getAttributeString( 'id', this.m_name );
	htmlString += this.getAttributeString( 'data', this.m_src );
	htmlString += this.getAttributeString( 'width', this.m_width );
	htmlString += this.getAttributeString( 'height', this.m_height );
	htmlString += '>';
	htmlString += this.getParamTag( 'movie', this.m_src );
	for ( eachParam in this.getParams() ) {
		htmlString += this.getParamTag( eachParam, this.getParam( eachParam ) );
	}
	htmlString += this.getParamTag( 'flashVars', this.getFlashVarsString() );

// open embed
	htmlString += '<embed type="application/x-shockwave-flash"';
	htmlString += this.getAttributeString( 'pluginspage', flashUrl );
	htmlString += this.getAttributeString( 'name', this.m_name );
	htmlString += this.getAttributeString( 'src', this.m_src );
	htmlString += this.getAttributeString( 'width', this.m_width );
	htmlString += this.getAttributeString( 'height', this.m_height );
	for ( eachParam in this.getParams() ) {
		htmlString += this.getAttributeString( eachParam, this.getParam( eachParam ) );
	}
	htmlString += this.getAttributeString( 'flashVars', this.getFlashVarsString() );
	htmlString += '>';

// close embed
	htmlString += '<\/embed>';

// close object
	htmlString += '<\/object>';

	return ( htmlString );
}

CNN_FlashObject.prototype.writeHtml = function () {
	document.write( this.getHtml() );
}

var flashVersion=CNN_FlashDetect.prototype.getVersion();

// Homepage tabs
currentTab=1;
startTab=0;
htmlTabs=false;
function writeTabs(tab1,tab2,tab3,tab4,openTab) {
	var detect=navigator.userAgent.toLowerCase();
	var macIE=((detect.indexOf('mac')+1) && (detect.indexOf('msie')+1));
	if (openTab==0) openTab=Math.round((Math.random()*3)+1);
	startTab=openTab;
	if (new CNN_FlashDetect().detectVersion(6) && !macIE) {
		var cnn_tabs=new CNN_FlashObject("siFlashTabs","http://i.a.cnn.net/si/.element/ssi/misc/2.0/tabs/tabs.swf",134,86,null,{tabName1:tab1,tabName2:tab2,tabName3:tab3,tabName4:tab4,startTab:openTab});
		cnn_tabs.writeHtml();
	} 
	else {
		htmlTabs=true;
		document.write('<table width="134"  border="0" cellspacing="0" cellpadding="0"><tr valign="top"><td width="6"><img src="http://www.si.com/partners/redirects/homepage.tabs.noflash.gif" width="6" height="86"></td><td width="128" class="siTabDivHolder"><a href="javascript:switchTab(1);"><div class="siTabDivOver" id="siTabDiv1">'+tab1+'</div></a><div class="siTabDivider"><img src="http://i.cnn.net/si/images/1.gif" width="128" height="1" border="0"></div><a href="javascript:switchTab(2);"><div class="siTabDivUp" id="siTabDiv2">'+tab2+'</div></a><div class="siTabDivider"><img src="http://i.cnn.net/si/images/1.gif" width="128" height="1" border="0"></div><a href="javascript:switchTab(3);"><div class="siTabDivUp" id="siTabDiv3">'+tab3+'</div></a><div class="siTabDivider"><img src="http://i.cnn.net/si/images/1.gif" width="128" height="1" border="0"></div><a href="javascript:switchTab(4);"><div class="siTabDivUp" id="siTabDiv4" style="padding-bottom:4px;">'+tab4+'</div></a></td></tr></table>');
	}
}
function switchTab(tabNum) {
	if (tabNum!=currentTab) {
		document.getElementById('siTab'+currentTab).className='siHideTab';
		document.getElementById('siTab'+tabNum).className='siShowTab';
		if (htmlTabs) {
			document.getElementById('siTabDiv'+currentTab).className='siTabDivUp';
			document.getElementById('siTabDiv'+tabNum).className='siTabDivOver';
		}
		currentTab=tabNum;
	}
}



// Search

function CNNSI_writeSearchFields() {
	document.write('<input type="hidden" name=Coll value="si_xml">');
	document.write('<input type="hidden" name="QuerySubmit"  value="true" />');
	document.write('<input type="hidden" name="Page"  value="1" />');
	document.write('<input type="hidden" name="QueryText" value="">');
}

function CNNSI_validateSearchForm( theForm )
{
	var site = 'si';
	var queryString = theForm.query.value;

	if ( theForm.sites )
	{
		if ( theForm.sites.options ) {		//	"sites" should be a select
			site = theForm.sites.options[theForm.sites.selectedIndex].value;
		} else {
			if ( theForm.sites.length )
			{
				for ( i = 0; i < theForm.sites.length; i++ )
				{
					if ( theForm.sites[i].checked ) {
						site = theForm.sites[i].value;
					}
				}
			}
			else
			{
				site = theForm.sites.value;
			}
		}
	}

	if ( !queryString ) {
		return false;
	}

	switch ( site.toLowerCase() ) {
		case "google":
			theForm.action = "http://websearch.si.cnn.com/search/search";
			theForm.query.value = queryString;
			return true;
		case "web":
			theForm.action = "http://websearch.si.cnn.com/search/search";
			theForm.query.value = queryString;
			return true;
		case "si":
			theForm.action = "http://search.sportsillustrated.cnn.com/pages/search.jsp";
			theForm.action = "http://search.sportsillustrated.cnn.com/pages/search.jsp";
			theForm.Coll.value = 'si_xml';
			theForm.QuerySubmit.value = 'true';
			theForm.Page.value = '1';
			theForm.QueryText.value = queryString;
			return true;
		default:
			return true;						//	unsupported site?
	}
}

//Footer nav
function cnnFooterNavClick( url ) {
	window.location.href = url;
}

function cnnFooterChangeNavClass(whichSelector,whichClass) {
 whichSelector.className = whichClass;
}

// Nav Functions

var cnnCurrentVisibleNavId = ''; // The name of the current visible navbar
var cnnTimeOverNav = -1; // Amount of time over nav
var cnnCurrentDelayTimeOutPtr = ''; // The previous hidden timeout pointer


function cnnDelayedNavShow(navId, navLeftPos, navWidth)
{
	if(cnnCurrentDelayTimeOutPtr)
	{
		window.clearTimeout(cnnCurrentDelayTimeOutPtr);
	}
	cnnTimeOverNav = new Date().getTime();
	cnnCurrentDelayTimeOutPtr = window.setTimeout("cnnNavShow('"+navId+"')",250);
}

function cnnNodeContains(a, b)
{
// Return true if node a contains node b.
	while (b.parentNode)
		if ((b = b.parentNode) == a)
			return true;
	return false;
}

function cnnDetectNavPanelMouseOut(event, obj, navId)
{
	var current, related;
	if (window.event)
	{
		current = obj;
		related = window.event.toElement;
	}
	else
	{
		cnnNavHide(navId);
		//current = event.currentTarget;
		//related = event.relatedTarget;
	}
	if (current != related && !cnnNodeContains(current, related))
	{
		cnnNavHide(navId);
	}
}


function cnnNavShow(navId)
{
// Show the navbar
	if ( cnnCurrentVisibleNavId && (cnnCurrentVisibleNavId != navId) )
	{
		cnnNavHide( cnnCurrentVisibleNavId );
	}

	var menu = cnnMenuEntries[ navId ];
	if ( menu )
	{
		var navWidth = cnnGetDhtmlMenuWidth( menu );
		var navLeftPos = 0;
		if( document.cnnIsWideSite ) {
			navLeftPos = menu.posXWide;
		} else {
			navLeftPos = menu.posX;
		}
		var subnav = cnnGetObject( navId + 'SubNav' );

		if(subnav && subnav.style)
		{
			if( document.cnnIsWideSite ) {
				if((navLeftPos+navWidth)>1000) {navLeftPos=1000-navWidth;}
			} else {
				if((navLeftPos+navWidth)>770) {navLeftPos=770-navWidth;}
			}
			subnav.style.left = navLeftPos;
			subnav.style.width = navWidth;
			subnav.style.visibility = 'visible';
			cnnAlterAllSelects('hidden')
		}

		cnnCurrentVisibleNavId = navId;
	}
}

function cnnNavHide(navId)
{
// hide the navbar
	var subnav = cnnGetObject( navId + 'SubNav' );
	if(subnav)
	{
		subnav.style.visibility = 'hidden';
		subnav.style.width = '0px';
		cnnAlterAllSelects('visible')
	}

}

function cnnGetObject( id ) {
	var object = null;
	if ( document.getElementById )
	{
		object = document.getElementById( id );
	}
	else
	if ( document.all )
	{
		object = document.all[ id ];
	}
	return object;
}

// is this page hosted on a remote site?
document.cnnIsRemoteSite = false;
if ( location.hostname.indexOf( '.cnn.com' ) == -1 && location.hostname.indexOf( '.turner.com' ) == -1 )
{
	document.cnnIsRemoteSite = true;
}
// is this page on a wide template?
document.cnnIsWideSite = false;

document.cnnDhtmlNavSectionWidth = 130;
document.cnnDhtmlNavHeadlineWidth = 240;
document.cnnDhtmlNavPadding = 6;
function cnnGetDhtmlMenuWidth( menu )
{
	var sectionWidth = menu.sectionWidth || document.cnnDhtmlNavSectionWidth || 130;
	var headlineWidth = document.cnnDhtmlNavHeadlineWidth || 240;
	var navPadding = document.cnnDhtmlNavPadding || 6;
	var outerWidth = sectionWidth + headlineWidth + ( navPadding * 4 );
	var displayHeadlines = ( !document.cnnIsRemoteSite && menu.showHeadlines && !document.cnnIsRemotePartner ) ? true : false;
	var displayMenuItems = 0
	if( menu.menuItems )
	{
		displayMenuItems = 1;
	}
	if ( !displayHeadlines && !displayMenuItems )
	{	// no headlines, no menuItems = no menu
		outerWidth = 0;
	}
	else if ( !displayHeadlines )
	{	// no headlines = narrow menu
		outerWidth = sectionWidth + ( navPadding * 2 );
	}
	else if ( !displayMenuItems )
	{	// no menuItems = narrow menu
		outerWidth = headlineWidth + ( navPadding * 2 );
	}
	return outerWidth;
}

function cnnWriteMenuEntries( menuCollection )
{
// write out the dhtml panes
	var prependHost = '';
	if ( document.cnnIsRemoteSite || document.cnnIsRemotePartner ) { prependHost = 'http://si.com'; }
	for ( eachMenu in menuCollection )
	{
		var navId = eachMenu;
		var sectionWidth = menuCollection[eachMenu].sectionWidth || document.cnnDhtmlNavSectionWidth || 130;
		var headlineWidth = document.cnnDhtmlNavHeadlineWidth || 240;
		var navPadding = document.cnnDhtmlNavPadding || 6;
		var outerWidth = cnnGetDhtmlMenuWidth( menuCollection[eachMenu] );
		var displayHeadlines = ( !document.cnnIsRemoteSite && menuCollection[eachMenu].showHeadlines && !document.cnnIsRemotePartner ) ? true : false;
		var navLeftPos = 0;
		if( document.cnnIsWideSite ) {
			navLeftPos = menuCollection[eachMenu].posXWide;
			if ( (navLeftPos+outerWidth) > 1000 ) { navLeftPos = 1000 - outerWidth; }
		} else {
			navLeftPos = menuCollection[eachMenu].posX;
			if ( (navLeftPos+outerWidth) > 770 ) { navLeftPos = 770 - outerWidth; }
		}

		var navHtml = "";

		navHtml += '<div class="cnnDhtmlMenu" id="'+navId+'SubNav" style="width:'+outerWidth+'px;left:'+navLeftPos+';" onmouseover="cnnNavShow(\''+navId+'\');return false;" onmouseout="cnnDetectNavPanelMouseOut(event, this, \''+navId+'\');">';

		navHtml += '<table width="' + outerWidth + '" border="0" cellspacing="0" cellpadding="' + navPadding + '" onmouseout="cnnDetectNavPanelMouseOut(event, this, \''+navId+'\');">';
		navHtml += '<tr valign="top">';

		if(menuCollection[eachMenu].menuItems)
		{
			navHtml += '<td width="'+sectionWidth+'">';
			for ( var entryNo = 0; entryNo < menuCollection[eachMenu].menuItems.length; entryNo += 2 )
			{
				var menuPrependHost = prependHost;
				if(menuCollection[eachMenu].menuItems[entryNo+1].indexOf('http:/\/')>-1){ menuPrependHost='';}
				navHtml += '<div class="cnnDhtmlMenuSect" onMouseOver="cnnColorMenuItem(this,1)" onMouseOut="cnnColorMenuItem(this,0)" onclick="location.href=\''+menuPrependHost+menuCollection[eachMenu].menuItems[entryNo+1]+'\'">';
				navHtml += '<a href="'+menuPrependHost+menuCollection[eachMenu].menuItems[entryNo+1]+'">'+menuCollection[eachMenu].menuItems[entryNo].toUpperCase()+'</a>';
				navHtml += '</div>';
			}
			navHtml += '</td>';
		}

		if ( displayHeadlines )
		{
			navHtml += '<td width="'+headlineWidth+'">';
			navHtml += '<div id="cnnDhtmlMenuCSI'+navId+'" class="cnnDhtmlMenuHeadlines">Content is loading...</div>';
			if (menuCollection[eachMenu].sponsor) {navHtml+=menuCollection[eachMenu].sponsor;}
			navHtml += '</td>';
		}

		navHtml += '</tr></table>';
		navHtml += '</div>';

		document.write( navHtml );
	}

	if ( !document.cnnIsRemoteSite )
	{
		var prependCSIpath='';
		if((window.location.hostname.indexOf('.cnn.com')>-1) && (window.location.hostname!='sportsillustrated.cnn.com')) {prependCSIpath='http://sportsillustrated.cnn.com';}
		cnnAddCSI('cnnDhtmlMenuCSI',prependCSIpath+'/.element/ssi/nav/2.0/headlines.exclude.html');
	}
}

function cnnColorMenuItem( element, on )
{
	if ( navigator.userAgent.indexOf( "KHTML" ) == -1 )
	{
		if ( on )
		{
			element.className = "cnnDhtmlMenuSectHov";
		}
		else
		{
			element.className = "cnnDhtmlMenuSect";
		}
	}
}

function cnnAlterAllSelects(visibility)
{
	var allSelectObjs = document.getElementsByTagName('select');
	if(allSelectObjs)
	{
		for(var selectCounter = 0;selectCounter<allSelectObjs.length;selectCounter++)
		{
			var currentSelectObj = allSelectObjs.item(selectCounter);
			currentSelectObj.style.visibility=visibility;
		}
	}
}

var cnnMenuEntries = new Array();


//SI Writers pulldown
var cnnSIWriters = new Array();
function cnnPopulateWriters(selectObj)
{
	if(selectObj)
	{
		for(var optCounter=0;optCounter<cnnSIWriters.length;optCounter++)
		{
			selectObj.options[selectObj.options.length] = new Option( cnnSIWriters[ optCounter ][1], cnnSIWriters[ optCounter ][0] );
		}
	}
}


function cnnPageBodyMove()
{
}




//Onload
function cnnPageOnload()
{
	cnnPopulateWriters( cnnGetObject( 'cnnSIWriterSelect' ) );
	cnnHandleCSIs();
	cnnStartList();
}

//CSI Functions
var cnnCSIs = new Array();
var cnnUseDelayedCSI = 0;
var localUserAgent = navigator.userAgent.toLowerCase();
if((localUserAgent.indexOf('msie')>-1) && (localUserAgent.indexOf('mac')>-1)){cnnUseDelayedCSI = 1;}

function cnnAddCSI(id,source,args)
{
	if(!args) { args='';}
	if(cnnUseDelayedCSI)
	{
		var newCSI = new Object();
		newCSI.src = source;
		newCSI.id  = id;
		newCSI.args = args;
		cnnCSIs[cnnCSIs.length]=newCSI;
	}
	else
	{
		var today = new Date();
		var currTime = today.getTime();
		var iframeArgs = '&time='+currTime;
		if(!document.switchDocDomain) {iframeArgs=iframeArgs+'&disableDocDom=1';}
		if(args)
		{
			iframeArgs=iframeArgs+'&'+args;
		}
		var iframeHtmlSrc='<iframe src="'+source+'?domId='+id+iframeArgs+'" name="iframe'+id+'" id="iframe'+id+'" width="0" height="0" align="right" style="position:absolute;visibility:hidden;"></iframe>';
		document.write(iframeHtmlSrc);
	}
}

function cnnUpdateCSI(html, id)
{
	var htmlContainerObj = cnnGetObject( id );
	if(htmlContainerObj)
	{
		htmlContainerObj.innerHTML = html;
	}

// force a refresh of the content area
	var htmlContentArea = document.body;
	if(htmlContentArea)
	{
		var previousTopVal = htmlContentArea.style.top || '0px';
		htmlContentArea.style.top = '1px';
		htmlContentArea.style.top = previousTopVal;
	}
}

// this is for opening pop-up windows
function CNN_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	try {
		window.top.name = "opener";
	} catch (e) {}
	var popupWin = window.open( url, name, widgets );
	if(popupWin) {cnnHasOpenPopup = 1;}
	if ( popupWin && popupWin.opener ) {
		if ( openerUrl )
		{
			popupWin.opener.location = openerUrl;
		}
	}
	if ( popupWin) {
		popupWin.focus();
	}
}


function SI_popUrl( urlString ) {
	if ( urlString.indexOf( ';' ) != -1 ) {
		var urlArray = urlString.split( ';' );
		var url = urlArray[0];
		var width = urlArray[1];
		var height = urlArray[2];
		if ( url && width && height ) {
			CNN_openPopup( url, width + 'x' + height, 'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no' );
		}
	}
}

function cnnHandleCSIs()
{
	if(document.body && document.body.innerHTML && cnnUseDelayedCSI)
	{
		var iframeOwner = cnnGetObject( 'csiIframe' );
		var iframeHtmlSrc = '';

		for(var incCounter=0;incCounter<cnnCSIs.length;incCounter++)
		{
			var src = cnnCSIs[incCounter].src;
			var id = cnnCSIs[incCounter].id;
			var today = new Date();
			var currTime = today.getTime();
			var args = '&time='+currTime;
			if(!document.switchDocDomain) {args=args+'&disableDocDom=1';}
			if(cnnCSIs[incCounter].args)
			{
				args=args+'&'+cnnCSIs[incCounter].args;
			}

			iframeHtmlSrc+='<iframe src="'+src+'?domId='+id+args+'" name="iframe'+id+'" id="iframe'+id+'" width="0" height="0" align="right"></iframe>';
		}
		if(iframeOwner)
		{
			iframeOwner.innerHTML=iframeHtmlSrc;
		}
	}
}

// Survey
function SI_profileSurvey( popup, cookie, scope ) {
	var randomNum = MD_random(1, scope);
	if( randomNum == scope ) {
		if( WM_browserAcceptsCookies() ) {
			if( WM_readCookie( cookie ) == '') {
				window.open( popup, 'surveyInvite', 'scrollbars=no,resizable=no,width=250,height=250');
			}
		}
	}
}

function MD_random(r1, r2) {
	if (r2 > r1) return (Math.round(Math.random()*(r2-r1))+r1);
	else return (Math.round(Math.random()*(r1-r2))+r2);
}

// Cookies
function WM_browserAcceptsCookies() {
	var WM_acceptsCookies = false;
	if ( document.cookie == '' ) {
		document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
		if ( document.cookie.indexOf( 'WM_acceptsCookies=yes' ) != -1 ) {
			WM_acceptsCookies = true;
		} // If it succeeds, set variable
	} else { // there was already a cookie
		WM_acceptsCookies = true;
	}

	return ( WM_acceptsCookies );
}

function WM_setCookie( name, value, hours, path, domain, secure ) {
	if ( WM_browserAcceptsCookies() ) { // Don't waste your time if the browser doesn't accept cookies.
		var numHours = 0;
		var not_NN2 = ( navigator && navigator.appName
					&& (navigator.appName == 'Netscape')
					&& navigator.appVersion
					&& (parseInt(navigator.appVersion) == 2) ) ? false : true;

		if ( hours && not_NN2 ) { // NN2 cannot handle Dates, so skip this part
			if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
				numHours = hours;
			} else if ( typeof(hours) == 'number' ) { // calculate Date from number of hours
				numHours = ( new Date((new Date()).getTime() + hours*3600000) ).toGMTString();
			}
		}

		document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
	}
} // WM_setCookie

function WM_readCookie( name ) {
	if ( document.cookie == '' ) { // there's no cookie, so go no further
		return false;
	} else { // there is a cookie
		var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
		var NN2Hack = firstChar + name.length;
		if ( (firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=') ) { // if you found the cookie
			firstChar += name.length + 1; // skip 'name' and '='
			lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
			if (lastChar == -1) lastChar = theBigCookie.length;
			return unescape( theBigCookie.substring(firstChar, lastChar) );
		} else { // If there was no cookie of that name, return false.
			return false;
		}
	}
} // WM_readCookie

function WM_killCookie( name, path, domain ) {
	var theValue = WM_readCookie( name ); // We need the value to kill the cookie
	if ( theValue ) {
		document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
	}
} // WM_killCookie


var cnnEnableCL = false;
document.switchDocDomain = true;
if((window.location.pathname.indexOf('/')==window.location.pathname.lastIndexOf('/')) && (window.location.host == "sportsillustrated.cnn.com"))
{
	document.switchDocDomain = false;
}


// **************************************************************************
// VIDEO PLAYER CODE

var agt		= navigator.userAgent.toLowerCase();
var versInt	= parseInt(navigator.appVersion);
var is_aol	= (agt.indexOf("aol") != -1);
var cnnDomainArray = location.hostname.split( '.' );
var cnnSiteWideCurrDate = new Date();
var cnnHasOpenPopup = 0;

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;

function detectWindowsMedia() {
	pluginFound = detectPlugin( 'Windows Media' );
	// if not found, try to detect with VisualBasic
//	if ( !pluginFound && detectableWithVB ) {
//		pluginFound = detectActiveXControl( 'MediaPlayer.MediaPlayer.1' );
//	}
	if ( !pluginFound && detectWMPSupport() ) {
		pluginFound = true;
	}
	return pluginFound;
}

function detectWMPSupport(){

    var wmp64 = "MediaPlayer.MediaPlayer.1";
    var wmp7 = "WMPlayer.OCX.7";
    if((window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1) || window.GeckoActiveXObject)
    {
        if(createActiveXObject(wmp7)){ 
            return true;

        }else{
            if(createActiveXObject(wmp64)){
                return true;
            }else{
                return false;
            }
        }
    }else{ 
        return false;
    }
}

function createActiveXObject(id){
  var error;
  var control = null;

  try{
    if (window.ActiveXObject){
      control = new ActiveXObject(id);
    }else if (window.GeckoActiveXObject){
      control = new GeckoActiveXObject(id);
    }
  }
  catch (error){;}
  return control;
}

function detectPlugin() {
	// allow for multiple checks in a single pass
	var daPlugins = arguments;
	// consider pluginFound to be false until proven true
	var pluginFound = false;
	// if plugins array is there and not fake
	if ( navigator.plugins && navigator.plugins.length > 0 ) {
		var pluginsArrayLength = navigator.plugins.length;
		// for each plugin...
		for ( var pluginsArrayCounter = 0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
			// loop through all desired names and check each against the current plugin name
			var numFound = 0;
			for ( var namesCounter = 0; namesCounter < daPlugins.length; namesCounter++ ) {
				// if desired plugin name is found in either plugin name or description
				if ( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
					(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
					// this name was found
					numFound++;
				}
			}
			// now that we have checked all the required names against this one plugin,
			// if the number we found matches the total number provided then we were successful
			if ( numFound == daPlugins.length ) {
				pluginFound = true;
				// if we've found the plugin, we can stop looking through at the rest of the plugins
				break;
			}
		}
	}
	return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ( (navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1) ) {
	document.writeln( '<script language="VBscript">' );

	document.writeln( '\'do a one-time test for a version of VBScript that can handle this code' );
	document.writeln( 'detectableWithVB = False' );
	document.writeln( 'If ScriptEngineMajorVersion >= 2 then' );
	document.writeln( '  detectableWithVB = True' );
	document.writeln( 'End If' );

	document.writeln( '\'this next function will detect most plugins' );
	document.writeln( 'Function detectActiveXControl( activeXControlName )' );
	document.writeln( '  on error resume next' );
	document.writeln( '  detectActiveXControl = False' );
	document.writeln( '  If detectableWithVB Then' );
	document.writeln( '     detectActiveXControl = IsObject( CreateObject( activeXControlName ) )' );
	document.writeln( '  End If' );
	document.writeln( 'End Function' );

	document.writeln( '\'and the following function handles QuickTime' );
	document.writeln( 'Function detectQuickTimeActiveXControl()' );
	document.writeln( '  on error resume next' );
	document.writeln( '  detectQuickTimeActiveXControl = False' );
	document.writeln( '  If detectableWithVB Then' );
	document.writeln( '    detectQuickTimeActiveXControl = False' );
	document.writeln( '    hasQuickTimeChecker = false' );
	document.writeln( '    Set hasQuickTimeChecker = CreateObject( "QuickTimeCheckObject.QuickTimeCheck.1" )' );
	document.writeln( '    If IsObject( hasQuickTimeChecker ) Then' );
	document.writeln( '      If hasQuickTimeChecker.IsQuickTimeAvailable( 0 ) Then ' );
	document.writeln( '        detectQuickTimeActiveXControl = True' );
	document.writeln( '      End If' );
	document.writeln( '    End If' );
	document.writeln( '  End If' );
	document.writeln( 'End Function' );

	document.writeln( '\'and the following function handles RealOne' );
	document.writeln( 'Function detectRealOneActiveXControl()' );
	document.writeln( '  on error resume next' );
	document.writeln( '  detectRealOneActiveXControl = False' );
	document.writeln( '  If detectableWithVB Then' );
	document.writeln( '    detectRealOneActiveXControl = False' );
	document.writeln( '    hasRealOneVersionPlugin = false' );
	document.writeln( '    Set hasRealOneVersionPlugin = CreateObject( "IERPCtl.IERPCtl.1" )' );
	document.writeln( '    If IsObject( hasRealOneVersionPlugin ) Then' );
	document.writeln( '      If hasRealOneVersionPlugin.RealPlayerVersion Then ' );
	document.writeln( '        detectRealOneActiveXControl = True' );
	document.writeln( '      End If' );
	document.writeln( '    End If' );
	document.writeln( '  End If' );
	document.writeln( 'End Function' );

	document.writeln( '<\/scr' + 'ipt>' );
}



// ________________________________________________________________ LaunchVideo


function LaunchVideo( videoPath ) {
	var videoDate = "";
	var cnnVideoDatePathRegExp = /(\d{4})\/(\d{2})\/(\d{2})/;
	var cnnVideoDatePathArray = cnnVideoDatePathRegExp.exec( videoPath );
	
	if ( cnnVideoDatePathArray )
	{
		var originalDate = new Date( parseInt( cnnVideoDatePathArray[1] ), parseInt( cnnVideoDatePathArray[2] ) - 1, parseInt( cnnVideoDatePathArray[3] ) );
		var expireDate = new Date( originalDate.getTime() + ( 7 * 24 * 60 * 60 * 1000 ) );
		var expireYear = new String( expireDate.getFullYear() );
		var expireMonth = new String( expireDate.getMonth() + 1 );
		var expireDay = new String( expireDate.getDate() );
		
		if ( expireMonth.length < 2 ) {
			expireMonth = '0' + expireMonth;
		}
		
		if ( expireDay.length < 2 ) {
			expireDay = '0' + expireDay;
		}
		
		videoDate = expireYear + '/' + expireMonth + '/' + expireDay;
	}
	
	cnnVideo( 'play', '/video' + videoPath.substring( 0, ( videoPath.length - 1 ) ), videoDate );
}

function cnnVideo( mode, arg, expiration )
{
	var playerURL    = '/video/player/player.html';
	var detectURL    = '/video/player/detect.exclude.html';
	var predetectURL = '/video/player/predetect.exclude.html';
	var noplugURL    = '/video/player/pages/detection/noplugin.html';
	var expireURL    = '/video/player/player.html';
	var openURL      = detectURL;
	var cnnVideoArgs = '';
	
	if ( detectWindowsMedia() )
	{
		var cnnPassedDetection = new String( WM_readCookie( 'cnnVidPlug' ) ).toLowerCase();
		
		if ( cnnPassedDetection == "activex" || cnnPassedDetection == "native" )
		{
			openURL = playerURL;
		}
	}
	else
	{
		openURL = noplugURL;
	}

	switch ( mode )
	{
		case 'play':

			var cnnExpireDate = new Date( new Date().getTime() - 24*60*60*1000 );
			var dateStringRegExp = /^(\d{4})\/(\d{2})\/(\d{2})$/;
			var dateStringArray = dateStringRegExp.exec( expiration );
						
			if ( dateStringArray && expiration)
			{
				cnnExpireDate = new Date( dateStringArray[1], dateStringArray[2] - 1, dateStringArray[3] );
			} else {
				cnnExpireDate = cnnSiteWideCurrDate;
			}
					
			if ( cnnExpireDate.getTime() < cnnSiteWideCurrDate.getTime() )
			{
				if ( cnnPassedDetection == "activex" || cnnPassedDetection == "native" )
					{
						openURL = expireURL;
				} else {
						openURL = detectURL;
				}				
				cnnVideoArgs = 'url=/video/player/static/404';
			}
			else
			{
				cnnVideoArgs = 'url=' + arg;
			}
			
			break;
		
		case 'browse':
			cnnVideoArgs = 'section=' + arg;
			break;
			
		default:
			cnnVideoArgs = 'section=/ALL';
			break;
			
	}
	if(openURL.indexOf('http://')==-1)
	{
		openURL='http://sportsillustrated.cnn.com'+openURL;
	}	
	CNN_openPopup( openURL+'?'+cnnVideoArgs, 'CNNVideoPlayer', 'scrollbars=no,resizable=no,width=770,height=570' );

}

// END VIDEO PLAYER CODE ***********************

//ADDITIVE JS FOR NEW DROPDOWN NAV
// Drop-down 
function cnnStartList() {
	if (document.getElementById && document.getElementById("cnnDropNav")) {
		navRoot = document.getElementById("cnnDropNav").getElementsByTagName("LI");
		for (i=0; i<navRoot.length; i++) {
			node = navRoot[i];
			if (node.className == "cnnMenu") {
				node.onmouseover=function() {this.className = 'cnnMenuOver';}
				node.onmouseout=function() {this.className = 'cnnMenu';}
			}
		}
	}
}

// Hide selects from Dropdown on IE rollover
function cnnToggleSelect(state) {
	var dom = (document.getElementById) ? true : false;
	var windows = (navigator.userAgent.toLowerCase().indexOf("windows")>-1) ? true : false;
	var ie5 = ((navigator.userAgent.toLowerCase().indexOf("msie")>-1) && dom) ? true : false;
	var cnn_selects = document.getElementsByTagName("select");
	if (windows && ie5) {
		for (i=0; i<cnn_selects.length; i++) {
			cnn_selects[i].style.visibility = state;
		}
	}
}

function cnnIsScoreboardPage() {
	var retValue = false;
	if(location.pathname.indexOf('scoreboards')>0) {
		if(location.pathname.indexOf('/football/ncaa/scoreboards/')==0) {retValue = true;}
		if(location.pathname.indexOf('/football/nfl/scoreboards/')==0) {retValue = true;}
		if(location.pathname.indexOf('/basketball/ncaa/men/scoreboards/')==0) {retValue = true;}
		if(location.pathname.indexOf('/basketball/nba/scoreboards/')==0) {retValue = true;}
		if(location.pathname.indexOf('/hockey/nhl/scoreboards/')==0) {retValue = true;}
//		if(location.pathname.indexOf('/baseball/mlb/scoreboards/')==0) {retValue = true;}
	}
	return retValue;
}

/* Solbright */
document.write("<scr"+"ipt type=\"text/javascript\" language=\"JavaScript1.2\" src=\"http://i.a.cnn.net/si/.element/ssi/js/2.0/adcode.js\"><\/scr"+"ipt>");
/* Quigo */
document.write("<scr"+"ipt type=\"text/javascript\" language=\"JavaScript1.2\" src=\"http://i.a.cnn.net/si/.element/js/3.0/cnnSLads.js\"><\/scr"+"ipt>");
/* Tacoda */
if( cnnIsScoreboardPage() ) {
	/* tacoda plays havoc with our ajax scoreboard pages */
} else {
	document.write('<scr'+'ipt type="text/javascript" language="JavaScript1.2">var tcdacmd="dt";</scr'+'ipt>');
	document.write('<scr'+'ipt type="text/javascript" language="JavaScript1.2" src="http://an.tacoda.net/an/16651/slf.js"></scr'+'ipt>');
}
/* Dynamic Logic */
document.write('<scr'+'ipt type="text/javascript" language="JavaScript1.2" src="http://content.dl-rms.com/rms/mother/901/nodetag.js"></scr'+'ipt>');

//This must always be at the very bottom
var cnnDocDomain = '';
if(location.hostname.indexOf('cnn.com')>0) {cnnDocDomain='cnn.com';}
if(location.hostname.indexOf('turner.com')>0) {if(document.layers){cnnDocDomain='turner.com:'+location.port;}else{cnnDocDomain='turner.com';}}
if(cnnDocDomain && document.switchDocDomain) {document.domain = cnnDocDomain;}
//Nothing should go after this
