var fieldName;
var file;
var params;

function populateField(field,param) {
//	alert("For field I have " + field);
//  alert("For param: " + param);
  params = param.split(",");
  fieldName = field;
//*** On switching between current and all shows, there is no params[1] - need to catch that.
	file = "/include/external/build-xml.php?build=" + fieldName + "&" + params[0] + "=" + params[1];
	ajaxRead(file);
}

//*** Probably need an updated funtion here
function ajaxRead(file){
	var xmlObj = null;
	if(window.XMLHttpRequest){
    xmlObj = new XMLHttpRequest();
	} else if(window.ActiveXObject){
    xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
    return;
	}
	xmlObj.onreadystatechange = function(){
  	if(xmlObj.readyState == 4){
  		processXML(xmlObj.responseXML);
  	}
	}
	xmlObj.open ('GET', file, true);
	xmlObj.send ('');
}

function processXML(obj){
  var dataArray = obj.getElementsByTagName(fieldName);
  var dataArrayLen = dataArray.length;
  var numParams = params.length;
 	fieldArray = new Array();
	n = 0; // The number of values we actually use may be less than the length of the array. So, new var. Whee.
  for (var i=0; i<dataArrayLen; i++){
  	// If a single value is passed, this seems to work fine to return all values
  	// That makes sense, I think, as long as the value passed isn't an actual ... node ... thingy
  	// 'Cause it would be looking for "value" == "undefined", which would be true. Or something like that. I think.
		//*** We still need to setep through each item because current shows vs all shows still works that way. :) (9/28/07)
  	if (dataArray[i].getAttribute(params[0]) == params[1]) {
	  	var id = dataArray[i].getAttribute('id');
	  	var name = dataArray[i].getAttribute('name');
	  	fieldArray[n] = new Array(id,name);
	  	n++;
	  }
  }
  // Should probably reduce our number of vars in here - maybe. Or not. Dunno.
	var arrSize = fieldArray.length;
	var fieldOptions = document.forms['recaps'][fieldName].options;
	var fieldThang = document.forms['recaps'][fieldName];
	fieldOptions.length = arrSize + 1;
	// Make sure there are choices available. If so, set the field to enabled. If not, select option 0 and disable. (I think.)
	if (fieldOptions.length > 1) {
		fieldThang.disabled = false;
		for (var i = 0; i < arrSize; i++) {
			fieldOptions[i+1] = new Option(fieldArray[i][1],fieldArray[i][0]);
		}
	} else {
		fieldThang.selectedIndex = 0;
		fieldThang.disabled = true;
	}
}