// -------------------------------------------------------------------------------
// Called From: all of the pages that use the standard subnavigation
// Purpose: The page starts with two functions: SI_showSubNav and SI_hideSubNav.  Each 
//			function takes in the object name of the menu. 
//			Depending on the function called and the browser being used, 
//			the visibility state of the dropdown menu is altered using the 
//			appropriate DOM.
//
//			The page then preloads all of the images that will be used in the  
//			horizontal navigation bar.
//
//          The page then loads all of the subnavigation text into each dropdown menu.  
//			Each array consists of the array name, the location of the dropdown menu 
//			(pixels from the left), and the width of the menu.  This is followed by 
//			a varying number of text links and the address (URL) of each link.
//
//			The function SI_setUpMenus then creates the dropdown menu using the information  
//			from the arrays.  This function takes 5 parameters: the background color of 
//          the menu, the rollover background color of the menu, the text color of 
//          the menu, the rollover text color, and the color of the line separating 
//          each link in the menu.   
// --------------------------------------------------------------------------------

function SI_displaySelects( selectVisibility ) {
	for ( var i = 0; i < document.forms.length; i++ ) {
		for ( var j = 0; j < document.forms[i].elements.length; j++ ) {
			if ( document.forms[i].elements[j].type.indexOf( "select" ) != -1 ) {
				document.forms[i].elements[j].style.visibility = selectVisibility;
			}
		}
	}
}

function SI_showSubNav(SI_subnav){
			
			var SI_nav;
			var SI_complete;
			
			SI_imgOn(SI_subnav);
			
			if(document.getElementById){
				SI_complete = "document.getElementById('" + SI_subnav + "Menu')";
			}
			else if(document.all){
				SI_complete = "document.all['" + SI_subnav + "Menu']";
			}
			
			SI_nav = eval(SI_complete);
				
			if (SI_nav){
				SI_nav.style.visibility = 'visible';	
			}
			
			SI_displaySelects( 'hidden' );
}

function SI_hideSubNav(SI_subnav){
		
			var SI_nav;
			var SI_complete;
			
			SI_imgOff(SI_subnav);
			
			if(document.getElementById){
				SI_complete = "document.getElementById('" + SI_subnav + "Menu')";
			}
			else if(document.all){
				SI_complete = "document.all['" + SI_subnav + "Menu']";
			}
			
			SI_nav = eval(SI_complete);
				
			if (SI_nav){
				SI_nav.style.visibility = 'hidden';	
			}
			
			SI_displaySelects( 'visible' );
}


if (document.images) {
			
			SI_nflon = new Image();			 SI_nflon.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_nfl_on.jpg";
			SI_ncaafbon = new Image();		 SI_ncaafbon.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_ncaafootball_on.jpg";
			SI_mlbon = new Image();			 SI_mlbon.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_mlb_on.jpg";
			SI_nbaon = new Image();			 SI_nbaon.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_nba_on.jpg";
			SI_ncaabbon = new Image();		 SI_ncaabbon.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_ncaabasketball_on.jpg";
			SI_golfon = new Image();		 SI_golfon.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_golf_on.jpg";
			SI_nhlon = new Image();			 SI_nhlon.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_nhl_on.jpg";
			SI_nascaron = new Image();		 SI_nascaron.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_racing_on.jpg";
			SI_socceron = new Image();		 SI_socceron.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_soccer_on.jpg";
			SI_tennison = new Image();		 SI_tennison.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_tennis_on.jpg";
			SI_moresportson = new Image();	 SI_moresportson.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_more_on.jpg";
			SI_fantasyon = new Image();  SI_fantasyon.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_fantasy_on.jpg";
			SI_scoreson = new Image();	 SI_scoreson.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_scores_on.jpg";
			
			SI_nfloff = new Image();		 SI_nfloff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_nfl_off.jpg";
			SI_ncaafboff = new Image();		 SI_ncaafboff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_ncaafootball_off.jpg";
			SI_mlboff = new Image();		 SI_mlboff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_mlb_off.jpg";
			SI_nbaoff = new Image();		 SI_nbaoff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_nba_off.jpg";
			SI_ncaabboff = new Image();		 SI_ncaabboff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_ncaabasketball_off.jpg";
			SI_golfoff = new Image();		 SI_golfoff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_golf_off.jpg";
			SI_nhloff = new Image();		 SI_nhloff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_nhl_off.jpg";
			SI_nascaroff = new Image();		 SI_nascaroff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_racing_off.jpg";
			SI_socceroff = new Image();		 SI_socceroff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_soccer_off.jpg";
			SI_tennisoff = new Image();		 SI_tennisoff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_tennis_off.jpg";
			SI_moresportsoff = new Image();  SI_moresportsoff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_more_off.jpg";
			SI_fantasyoff = new Image();  SI_fantasyoff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_fantasy_off.jpg";
			SI_scoresoff = new Image();  SI_scoresoff.src="http://i.cnn.net/si/.element/img/1.0/nav/main/nav_scores_off.jpg";
		} 


		<!-- Adds a suffix onto the image name so that the program calls the on state of the image -->
		function SI_imgOn(iname) {
			if (document.images) {
				document[iname].src = eval(iname + "on.src");
			}
		}

		<!-- Adds a suffix onto the image name so that the program calls the off state of the image -->
		function SI_imgOff(iname) {
			if (document.images) {
				document[iname].src = eval(iname + "off.src");
			}
		}
		



var SI_arMenu = new Array();
		
		SI_arMenu[0] = new Array(
			"SI_nfl",
			0,  // pixels from left
			116, // width of menu
			"Super Bowl","/football/nfl/specials/playoffs/2003/",
			"News","/football/nfl/specials/playoffs/2003/", 
			"Scores","/football/nfl/scoreboards/today/",
			"Teams","/football/nfl/teams/",
			"Players","/football/nfl/players/",
			"Standings","/football/nfl/standings/",
			"Schedules","/football/nfl/schedules/",
			"Stats","/football/nfl/stats/",
			"Transactions","/transactions/today.html",
			"Injuries","/football/nfl/injuries/"
			);
			
		SI_arMenu[1] = new Array(
			"SI_ncaafb", 
			41, // pixels from left
			116, // width of menu
			"News","/football/ncaa/",
			"Scores","/football/ncaa/scoreboards/divia/today/",
			"Teams","/football/ncaa/teams/",
			"Conferences","/football/ncaa/conferences/",
			"Players","/football/ncaa/rosters/",
			"Standings","/football/ncaa/standings/",
			"Rankings","/football/ncaa/polls/2003/ap/",
			"Schedules","/football/ncaa/schedules/",
			"Stats","/football/ncaa/stats/"
			);
		
		SI_arMenu[2] = new Array(
			"SI_mlb",
			139, // pixels from left
			130, // width of menu
			"News","/baseball/mlb/",
			"Scores","/baseball/mlb/scoreboards/today/",
			"Teams","/baseball/mlb/teams/",
			"Players","/baseball/mlb/players/",
			"Standings","/baseball/mlb/standings/",
			"Probables","/baseball/mlb/probables/today/",
			"Schedules","/2003/baseball/mlb/specials/postseason/2003/postseason.schedule/",
			"Stats","/baseball/mlb/stats/",
			"Transactions","/transactions/today.html",
			"Injuries","/baseball/mlb/injuries/"
			);
			
		SI_arMenu[3] = new Array(
			"SI_nba",
			182, // pixels from left
			116, // width of menu
			"News","/basketball/nba/",
			"Scores","/basketball/nba/scoreboards/today/",
			"Teams","/basketball/nba/teams/",
			"Players","/basketball/nba/players/",
			"Standings","/basketball/nba/standings/",
			"Schedules","/basketball/nba/schedules/",
			"Stats","/basketball/nba/stats/",
			"Transactions","/transactions/today.html",
			"Injuries","/basketball/nba/injuries/"
			);
		
		SI_arMenu[4] = new Array(
			"SI_ncaabb",
			225, // pixels from left
			116, // width of menu
			"News","/basketball/ncaa/",
			"Scores","/basketball/ncaa/men/scoreboards/top25/today/",
			"Teams","/basketball/ncaa/men/teams/",
			"Conferences","/basketball/ncaa/men/conferences/",
			"Players","/basketball/ncaa/men/rosters/",
			"Standings","/basketball/ncaa/men/standings/",
			"Rankings","/basketball/ncaa/men/polls/2003/ap/",
			"Schedules","/basketball/ncaa/men/schedules/",
			"Stats","/basketball/ncaa/men/stats/"
			);
		
		SI_arMenu[5] = new Array(
			"SI_golf",
			337, // pixels from left
			116, // width of menu
			"News","/golf/",
			"Leaderboards","/2003/golf/leaderboards/",
			"Players","/golf/players/",
			"Rankings","/golf/stats/",
			"Schedules","/golf/stats/",
			"Stats","/golf/stats/",
			"Courses","http://www.golfcourse.com"
			);
		
		SI_arMenu[6] = new Array(
			"SI_nhl",
			383, // pixels from left
			116, // width of menu
			"News","/hockey/nhl/",
			"Scores","/hockey/nhl/scoreboards/today/",
			"Teams","/hockey/nhl/teams/",
			"Players","/hockey/nhl/players/",
			"Standings","/hockey/nhl/standings/",
			"Schedules","/hockey/nhl/schedules/",
			"Stats","/hockey/nhl/stats/",
			"Transactions","/transactions/today.html",
			"Injuries","/hockey/nhl/injuries/"
			);
		
		SI_arMenu[7] = new Array(
			"SI_nascar",
			429, // pixels from left
			116, // width of menu
			"News","/racing/",
			"Results","/racing/results/",
			"Standings","/racing/standings/",
			"Schedules","/racing/schedules/",
			"Drivers","/racing/drivers/",
			"Tracks","/racing/tracks/"
			);
		
		SI_arMenu[8] = new Array(
			"SI_soccer",
			485, // pixels from left
			116, // width of menu
			"News","/soccer/",
			"Scores","/soccer/scoreboards/",
			"Teams","/soccer/teams/",
			"Leagues","/soccer/leagues/",
			"Standings","/soccer/standings/",
			"Schedules","/soccer/schedules/",
			"Stats","/soccer/stats/"
			);
		
		SI_arMenu[9] = new Array(
			"SI_tennis",
			541, // pixels from left
			116, // width of menu
			"News","/tennis/",
			"Results","/2003/tennis/results/",
			"Players","/tennis/players/",
			"Rankings","/tennis/stats/",
			"Schedules","/tennis/stats/",
			"Stats","/tennis/stats/"
			);
		
		SI_arMenu[10] = new Array(
			"SI_moresports",
			597, // pixels from left
			116, // width of menu
			"<div class=\"cnn5pxT2pxB\">Boxing</div><div class=\"cnn2pxTB\">Olympics</div><div class=\"cnn2pxTB\">Horse Racing</div><div class=\"cnn2pxTB\">Cricket</div><div class=\"cnn2pxTB\">Cycling</div><div class=\"cnn2pxTB\">Winter</div><div class=\"cnn2pxTB\">Rugby</div><div class=\"cnn2pxT5pxB\">Track & Field</div>","/more/",
			"World Sport","http://edition.cnn.com/SPORT/"
			);
			
		SI_arMenu[11] = new Array(
			"SI_fantasy",
			645, // pixels from left
			116, // width of menu
			"News","/fantasy/",
			"Football","/fantasy/",
			"Baseball","/fantasy/",
			"Basketball","https://games.si.cnn.com/signup/signup.asp?game_id=9",
			"Kids Games","http://www.sikids.com/fantasy/index.html"
			);
			
		SI_arMenu[12] = new Array(
			"SI_scores",
			654, // pixels from left
			116, // width of menu
			"NFL","/football/nfl/scoreboards/today/",
			"NCAA Football","/football/ncaa/scoreboards/divia/today/",
			"MLB","/baseball/mlb/scoreboards/today/",
			"NBA","/basketball/nba/scoreboards/today/",
			"NCAA Basketball","/basketball/ncaa/men/scoreboards/top25/today/",
			"Golf","/2003/golf/leaderboards/",
			"NHL","/hockey/nhl/scoreboards/today.html",
			"Tennis","/2003/tennis/results/",
			"Soccer","/soccer/scoreboards/",
			"More Scores","/scoreboards/"
			);
			

function SI_setUpMenus(SI_backcolor, SI_overcolor, SI_textcolor, SI_overtextcolor, SI_linecolor){
	if ((document.all) || (document.getElementById)){

	var SI_subnav = "";
			
			for (j = 0; j < SI_arMenu.length; j++){
				SI_subnav += "<div id=\"" + SI_arMenu[j][0] + "Menu\" style=\"z-index:999;position: absolute; left: " + SI_arMenu[j][1] + "; width: " + SI_arMenu[j][2] + ";  visibility: hidden\" onmouseover=\"SI_showSubNav('" + SI_arMenu[j][0] + "');\" onmouseout=\"SI_hideSubNav('" + SI_arMenu[j][0] + "');\">";
					SI_subnav += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"" + SI_arMenu[j][2] + "\">";
						
						for (i=3; i < SI_arMenu[j].length-1; i=i+2){
							SI_subnav += "<tr>";
								SI_subnav += "<td width=\"1\" bgcolor=\"#000000\"><img src=\"http://i.cnn.net/si/images/1.gif\" width=\"1\" height=\"22\"></td>";
								SI_subnav += "<td width=\"6\" bgcolor=\"#7B5535\" class=\"siNavSide\"><img src=\"http://i.cnn.net/si/images/1.gif\" width=\"6\" height=\"22\"></td>";
								if( document.isRemoteHosted == 'local' ) {
									SI_subnav += "<td width=\"108\" bgcolor=\"" + SI_backcolor + "\" class=\"cnnNavMenu\" onClick=\"if (typeof P_popupoff != 'undefined') P_popupoff();document.location.href='" + SI_arMenu[j][i+1] + "'\" onmouseover=\"this.bgColor='" + SI_overcolor + "';this.style.color='" + SI_overtextcolor+ "';\" onmouseout=\"this.bgColor='" + SI_backcolor + "';this.style.color='" + SI_textcolor + "'\" style=\"color: " + SI_textcolor + "\"><div style=\"padding-left:12px;\">" + SI_arMenu[j][i] + "</a></div></td>";
								} else if ( !(IsRelativeURL( SI_arMenu[j][i+1] )) ) {
									SI_subnav += "<td width=\"108\" bgcolor=\"" + SI_backcolor + "\" class=\"cnnNavMenu\" onClick=\"if (typeof P_popupoff != 'undefined') P_popupoff();document.location.href='http://sportsillustrated.cnn.com" + SI_arMenu[j][i+1] + "'\" onmouseover=\"this.bgColor='" + SI_overcolor + "';this.style.color='" + SI_overtextcolor+ "';\" onmouseout=\"this.bgColor='" + SI_backcolor + "';this.style.color='" + SI_textcolor + "'\" style=\"color: " + SI_textcolor + "\"><div style=\"padding-left:12px;\">" + SI_arMenu[j][i] + "</a></div></td>";
								} else {
									SI_subnav += "<td width=\"108\" bgcolor=\"" + SI_backcolor + "\" class=\"cnnNavMenu\" onClick=\"if (typeof P_popupoff != 'undefined') P_popupoff();document.location.href='http://sportsillustrated.cnn.com" + SI_arMenu[j][i+1] + "'\" onmouseover=\"this.bgColor='" + SI_overcolor + "';this.style.color='" + SI_overtextcolor+ "';\" onmouseout=\"this.bgColor='" + SI_backcolor + "';this.style.color='" + SI_textcolor + "'\" style=\"color: " + SI_textcolor + "\"><div style=\"padding-left:12px;\">" + SI_arMenu[j][i] + "</a></div></td>";
								}
								SI_subnav += "<td width=\"1\" bgcolor=\"#000000\"><img src=\"http://i.cnn.net/si/images/1.gif\" width=\"1\" height=\"22\"></td>";
							SI_subnav += "</tr>";
							SI_subnav += "<tr>";
								SI_subnav += "<td colspan=\"3\" bgcolor=\"" + SI_linecolor + "\" height=\"1\"><img src=\"http://i.cnn.net/si/images/1.gif\" width=\"1\" height=\"1\"></td>";
							SI_subnav += "</tr>";
						}
						
					SI_subnav += "</table>";
				SI_subnav += "</div>";
			}
			
	document.write(SI_subnav);

	}
}

//added by jwester on 6/16/03 to test video popup
// this is for opening pop-up windows
function CNN_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	var popupWin = window.open( url, name, widgets );
	
	if ( popupWin.opener ) {
		if ( openerUrl )
		{
			popupWin.opener.location = openerUrl;
			popupWin.focus();
		}
		popupWin.opener.top.name = "opener";
	}
}

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 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 "si":
			theForm.action = "http://search.si.cnn.com/si/search";
			theForm.query.value = queryString;
			theForm.source.value = 'si';
			return true;
		default:
			return true;						//	unsupported site?
	}
}

// ________________________________________________________________ LaunchVideo

var agt		= navigator.userAgent.toLowerCase();
var is_aol	= (agt.indexOf("aol") != -1);

// _____________________________________________________________ WebMonkey code
/*
WM_setCookie(), WM_readCookie(), WM_killCookie()
A set of functions that eases the pain of using cookies.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
*/

// This next little bit of code tests whether the user accepts 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


// ______________________________________________________________________ Apple
// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;


function canDetectPlugins() {
	if ( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
		return true;
	}
	return false;
}

function detectFlash() {
	pluginFound = detectPlugin( 'Shockwave', 'Flash' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectActiveXControl( 'ShockwaveFlash.ShockwaveFlash.1' );
	}
	return pluginFound;
}

function detectDirector() {
	pluginFound = detectPlugin( 'Shockwave', 'Director' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectActiveXControl( 'SWCtl.SWCtl.1' );
	}
	return pluginFound;
}

function detectQuickTime() {
	pluginFound = detectPlugin( 'QuickTime' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectQuickTimeActiveXControl();
	}
	return pluginFound;
}

function detectReal() {
	pluginFound = detectPlugin( 'RealPlayer' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = ( detectActiveXControl('rmocx.RealPlayer G2 Control') ||
			detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
			detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)')
		);
	}
	return pluginFound;
}

function detectRealOne() {
	pluginFound = detectPlugin( 'RealOne Player Version Plugin' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectRealOneActiveXControl();
	}
	return pluginFound;
}

function detectWindowsMedia() {
	pluginFound = detectPlugin( 'Windows Media' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectActiveXControl( 'MediaPlayer.MediaPlayer.1' );
	}
	return pluginFound;
}

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>' );
}


// _______________________________________________________________________ Real

function LV_getRealOneStatus() {	// returns ('undetermined'|'installed'|'notinstalled'|'using')
	var RealOneInst = "undetermined";

	if ( canDetectPlugins() ) {
		if ( detectRealOne() ) {
			RealOneInst = "installed";
			if ( agt.indexOf( "(r1 " ) != -1 ) {
				RealOneInst = "using";
			}
		} else {
			RealOneInst = "notinstalled";
		}
	}

	return RealOneInst;
}

function LV_getVideoUrl( videoUrlPath, format, realOneStatus ) {
	var fullUrl;
	var premiumUrlPrefix = ( format == "public" ) ? "http://premium.si.cnn.com/video" : "http://premium.si.cnn.com/pr/video";
	
	switch( realOneStatus ) {
		case "using":
			fullUrl = premiumUrlPrefix + "/meta" + videoUrlPath + "r1.smil"; 
			break;
		case "installed":
			fullUrl = premiumUrlPrefix + "/meta" + videoUrlPath + "np.smil"; 
			break;
		case "notinstalled":
		default:
			fullUrl = premiumUrlPrefix + videoUrlPath + "exclude.html";
			break;
	}
	
	return ( fullUrl );
}

function LaunchVideo( videoPath, videoFormat ) {
	var VIDEO_POPUP_WIDTH = 730;
	var VIDEO_POPUP_HEIGHT = 515;
	var realOneStatus = LV_getRealOneStatus();
	var videoUrl;
	
	if ( realOneStatus != "using" ) {	// if you're not using RealOne...
		if ( is_aol ) {	// if you're using AOL, you're getting the popup
			realOneStatus = "notinstalled";
		} else {	// let's check your cookie
			var playerPref = WM_readCookie( "player" );
			if ( playerPref ) {
				switch ( playerPref.toUpperCase() ) {
					case "REALONE":
					case "REAL":
						if ( realOneStatus == "installed" ) {
							realOneStatus = "installed";
						} else {
							realOneStatus = "notinstalled";
						}
						break;
					case "WINDOWS MEDIA":
					case "QUICKTIME":
					default:
						realOneStatus = "notinstalled";
						break;
				}
			}
		}
	}
		
	videoUrl = LV_getVideoUrl( videoPath, videoFormat, realOneStatus );
	
	if ( videoUrl.indexOf( ".exclude.html" ) > 0 ) {
		CNN_openPopup( videoUrl, '' + VIDEO_POPUP_WIDTH + 'x' + VIDEO_POPUP_HEIGHT, 'width=' + VIDEO_POPUP_WIDTH + ',height=' + VIDEO_POPUP_HEIGHT + ',scrollbars=no,resizable=no' );
	} else {
		top.location.href = videoUrl;
	} 
}

/*
 * Trvia Promo
 */
function triviaPromo() {
	if (WM_browserAcceptsCookies() && (WM_readCookie("xTrivia") == '')) {
			WM_setCookie("xTrivia", "set", 24); // expire in 24 hours
			window.open('/advertisers/si/trivia/flashHolder.html','300x250','scrollbars=no,resizable=yes,width=300,height=250');
	}
}

function IsRelativeURL (url) {
	if (url.indexOf('http://') == 0) {
		return false;
	} else if (url.indexOf('https://') == 0) {
		return false;
	} else if (url.indexOf('ftp://') == 0) {
		return false;
	} else if (url.indexOf('mailto://') == 0) {
		return false;
	} else {
		return true;
	}
}

function SI_profileSurvey(scope) {
        var randomNum = MD_random(1, scope);
        if (randomNum == scope) {
                if (WM_browserAcceptsCookies() && (WM_readCookie("xGOLFsurvey") == '')) {
                        window.open('/survey/profiler/golf/surveyInvite.html', '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);
}

