// Any track designation.
anyName = "Use any track";
anyID   = "_A_";

// Preference track designation.
preferencesName = "Use your Track Preferences";
preferencesID   = "_P_";

// JBC- Got rid of the hard coded track names. Now the track names will be pulled from the drf_pref_track table.
// The pages that need to use the track list will have to populate a javascript array with the track data.
// See drfwebTrackPreferences.jsp for details.

// Populates whichObject with the enumeration identified by whichType and,
// optionally selects the instance associate with the ID in whichInstance.
function fnGetTrack(whichType, whichObject, whichInstance)
{
	var i = 0;
   var index = 0;

	if (whichType == "any") {
		whichObject.options[0].id=anyID;
		whichObject.options[0].text=anyName;
		whichObject.options[0].value=anyID;

		fnBackFill(1, whichObject.options.length, whichObject);
		}
	else if (whichType == "preferences") {
		whichObject.options[0].id=preferencesID;
		whichObject.options[0].text=preferencesName;
		whichObject.options[0].value=preferencesID;

		fnBackFill(1, whichObject.options.length, whichObject);
		}
	else if (whichType == "circuit") {
		for (i = 0; i < circuitArr.length; i++) {
			whichObject.options[i].id=circuitArr[i].value;
			whichObject.options[i].text=circuitArr[i].description;
			whichObject.options[i].value=circuitArr[i].value;

			if (circuitArr[i].value == whichInstance) {
				index = i;
				}
			}

		fnBackFill(i, whichObject.options.length, whichObject);
		}
	else {
		for (i = 0; i < trackArr.length; i++) {
			whichObject.options[i].id=trackArr[i].trackId;
			whichObject.options[i].text=trackArr[i].trackName;
			whichObject.options[i].value=trackArr[i].trackId;

			if (trackArr[i].trackId == whichInstance) {
				index = i;
				}
			}

		fnBackFill(i, whichObject.options.length, whichObject);
		}

	whichObject.selectedIndex = index;
}

// Populates empty control entries
function fnBackFill(startPos, endPos, whichObject)
{
	var i = startPos;

	while (i < endPos) {
		whichObject.options[i].id="";
		whichObject.options[i].text=" ";
		whichObject.options[i].value=" ";

		i++;
		}
}

