
//  $Id: ChooseConnection.js,v 1.3 2003/10/28 08:01:43 scissors Exp $
//
//

var ConnType="56K";	// The original setting.  This button must be checked
			// by default.

function setConnType (newConnType) 
//  Sets connection speed used for MP3 playback in HymnMP3s.html and
//  FirstSetMP3s.html by changing the path to the MP3 file in the link.
//  Paths to sound files are "Audio/MP3/56K/" or "Audio/MP3/BBd/"
//  The original text should be "Audio/MP3/56K/".  The function
//  setConnType() rewrites these paths based on the radio button clicked
//  on the document.
//
{
	var i;

	// 
	//  Loop through the links in the document, changing any referrence
	//  to the previous ConnType in the path to the newConnType passed
	//  in
	//

	for (i = 0; i < document.links.length; i++)
	{
		if (document.links[i].href.search (ConnType) != -1)
		{
			document.links[i].href = 
				document.links[i].href.replace(ConnType, newConnType);
		}
	}

	ConnType = newConnType;

	return;
}

function checkDefaultConnType ()
// Loop through the radio buttons in the form 'ConnectionChoice'
// and check the default radio button.
// Why do this?  If the user hits the browser refresh button,
// the checked radio button is NOT necessarily rechecked
//
{
	var i;


	for (i = 0; i < document.ConnectionChoice.length; i++)
	{
		if (document.ConnectionChoice[i].defaultChecked)
		{
			document.ConnectionChoice[i].checked = true;
		}
	}
}

function displayWindowStatus (trackName)
// Instead of displaying the Godawful and confusing URL for the m3u
// file, we want to display something nicer, e.g., 
// "Listen to Hymn to Freedom (dialup connection)" or
// "Listen to Prolix 908 (DSL or cable connection)".  This function
// looks at the global (urgh...there's probably another way I could
// do this, but I can't think of it now) ConnType to figure out
// what goes in the parenthesis in the examples listed, slaps together
// the string to display, and sets window.status equal to it.
// 
{
	var connTypeText;

	if (ConnType == "56K")
	{
		connTypeText = " (dialup connection)";
	}
	else if (ConnType == "BBd")
	{
		connTypeText = " (Cable or DSL connection)";
	}

	window.status = "Listen to " + trackName + connTypeText;
	return true;
}
