
function showDetails(detailName, swapState)
{
	// This routine expands the NFL data under the given player. 

    var menu_element = document.getElementById(detailName);
    var gs_element   = document.getElementById(detailName + "_GS");
    var menu_state   = GetCookie(detailName + "State");
    var image_name   = eval("document." + detailName + "_Image")
	var poss_element = document.getElementById(detailName + "_PI");
	var poss_type = 0;
    	
    if (menu_state != null && menu_state == "open")
    {
        if (swapState)
        {
            menu_element.style.display  = "none";
			if (gs_element) gs_element.style.display = "none";
            SetCookie(detailName + "State", "closed");
            image_name.src = "http://www.rtsports.com/img/plus.gif";
			if (poss_element) {
				poss_type = poss_element.width;
				poss_element.width = 16;
				poss_element.height = 13;
				if (poss_type == 1) poss_element.src = "http://www.rtsports.com/img/possession.gif";
				else if (poss_type == 2) poss_element.src = "http://www.rtsports.com/img/possession-gray.gif";
				else if (poss_type == 3) poss_element.src = "http://www.rtsports.com/img/redzone.gif";
			}
        }
        else
        {
            menu_element.style.display = "block";
			if (gs_element) gs_element.style.display = "block";
            image_name.src = "http://www.rtsports.com/img/minus.gif";
			if (poss_element) {
				if (poss_element.src == "http://www.rtsports.com/img/possession.gif")
					poss_type = 1;
				else if (poss_element.src == "http://www.rtsports.com/img/possession-gray.gif")
					poss_type = 2;
				else if (poss_element.src == "http://www.rtsports.com/img/redzone.gif")
					poss_type = 3;
				else
					poss_type = 0;
				poss_element.src = "http://www.rtsports.com/img/spacer.gif";
				poss_element.width = poss_type;
				poss_element.height = 1;
			}
        }
    }
    else
    {
        if (swapState)
        {
            menu_element.style.display = "block";
			if (gs_element) gs_element.style.display = "block";
            SetCookie(detailName + "State", "open");
            image_name.src = "http://www.rtsports.com/img/minus.gif";
			if (poss_element) {
				if (poss_element.src == "http://www.rtsports.com/img/possession.gif")
					poss_type = 1;
				else if (poss_element.src == "http://www.rtsports.com/img/possession-gray.gif")
					poss_type = 2;
				else if (poss_element.src == "http://www.rtsports.com/img/redzone.gif")
					poss_type = 3;
				else
					poss_type = 0;
				poss_element.src = "http://www.rtsports.com/img/spacer.gif";
				poss_element.width = poss_type;
				poss_element.height = 1;
			}
        }
        else
        {
            menu_element.style.display = "none";
			if (gs_element) gs_element.style.display = "none";
            SetCookie(detailName + "State", "closed");
            image_name.src = "http://www.rtsports.com/img/plus.gif";
			if (poss_element) {
				poss_type = poss_element.width;
				poss_element.width = 16;
				poss_element.height = 13;
				if (poss_type == 1) poss_element.src = "http://www.rtsports.com/img/possession.gif";
				else if (poss_type == 2) poss_element.src = "http://www.rtsports.com/img/possession-gray.gif";
				else if (poss_type == 3) poss_element.src = "http://www.rtsports.com/img/redzone.gif";
			}
        }        

    }

}

function gameSelected(theForm)
{
	var URL, team1, team2;

	if (theForm.gameSelect.selectedIndex == 0)
		// The first item in the games list was selected, which is just "All Games"
		URL = "/cgi-bin/display_game_summaries?LN=" + theForm.LN.value + "&UID=" +
			  theForm.UID.value + "&TN=" + theForm.TN.value + "&Week=" +
			  theForm.Week.value + "&Junk=" + Math.round(Math.random() * 32768);
	else
	{
		games_string = theForm.gameSelect.options[theForm.gameSelect.selectedIndex].value;
		team1 = games_string.substring(0, games_string.indexOf(";"));
		team2 = games_string.substring(games_string.indexOf(";") + 1, games_string.length);
		
		if (team1 == team2)
			// If the first team = second team, then this is a league average game, so display the 
		    // scoring summary page for the one team.
 			URL = "/cgi-bin/display_scoring_log?LN=" + theForm.LN.value + "&UID=" +
			 	  theForm.UID.value + "&TN=" + theForm.TN.value + "&Week=" +
				  theForm.Week.value + "&Team=" + team1 + "&Junk=" + Math.round(Math.random() * 32768);
		else
			URL = "/cgi-bin/display_game_log?LN=" + theForm.LN.value + "&UID=" +
   		 	      theForm.UID.value + "&TN=" + theForm.TN.value + "&Week=" +
				  theForm.Week.value + "&Team1=" + team1 + "&Team2=" + team2 + "&Junk=" + Math.round(Math.random() * 32768);
	}
	
	window.open(URL, '_self');

}

function scoringLogSelected(theForm)
{
	var URL, team_number;

	if (theForm.scoringLogSelect.selectedIndex == 0)
		// The first item in the games list was selected, which is just "All Scores"
		URL = "/cgi-bin/display_scoring_summaries?LN=" + theForm.LN.value + "&UID=" +
			  theForm.UID.value + "&TN=" + theForm.TN.value + "&Week=" +
			  theForm.Week.value + "&Junk=" + Math.round(Math.random() * 32768);
	else
	{
		team_number = theForm.scoringLogSelect.options[theForm.scoringLogSelect.selectedIndex].value;
		
		URL = "/cgi-bin/display_scoring_log?LN=" + theForm.LN.value + "&UID=" +
			  theForm.UID.value + "&TN=" + theForm.TN.value + "&Week=" +
			  theForm.Week.value + "&Team=" + team_number + "&Junk=" + Math.round(Math.random() * 32768);
	}
	
	window.open(URL, '_self');

}

