function updateRelatedList( list1, list2, selInList2, allList, incAll ){
	/* Given two HTML Select lists, determine which item in list
		one is selected and populate list 2 based on a global var
		of the same name (as the selected item in one).  Also select
		any items in list two which are in the selInList2 parameter.
		If incAll is true, add an 'All' component to the top of list
		2 with a blank value.  Select this if no items are selected
		in selInList2
	*/
	
	var varName = list1.options[list1.selectedIndex].value;
	varName = varName.replace(" ","_");
	varName = varName.replace("-","_");
	var gVarName = "g" + varName;
	
	var list2Options;
	
	if ( varName == '' ) {
		list2Options = allList;
	} else if ( isSet(gVarName) ){
		list2Options = eval(gVarName);
	} else if ( isSet(varName) ) {
		list2Options = eval(varName);
	} else {
		return 0;
	}
	
	/* empty the list...start from scratch */
	list2.options.length = 0;
	
	/* syntax: Option("text","value",isDefaultSelected,isSelected); */
	
	if ( incAll ){
		if (! selInList2.length || selInList2[0] == ''){ sel = true; } else { sel = false; }
		list2.options[0] = new Option("All","All",true,sel);
		startRow = 1;
	} else {
		startRow = 0;
	}
	
	if ((! typeof(selInList2) == 'object') ||
		(selInList2.constructor.toString().indexOf("Array") == -1)) {
		selInList2 = new Array(' ');
	}
	
	if ( ! selInList2.indexOf ){ selInList2.indexOf = inArray; }
	for ( var i = 0; i < list2Options.length; i++ ){
		if ( selInList2.indexOf(list2Options[i]) != -1 ){ sel = true; } else { sel = false; }
		// Decode entities
		//list2Options[i] = decodeEntities(list2Options[i]);
		list2.options[i+startRow] = new Option(list2Options[i],list2Options[i],false,sel);
	}
	
	return 1;
}

function isSet( variable ) {
	return( typeof variable != 'undefined' );
}

/* IE does not have an 'indexOf' method for arrays, so we have our own here */
function inArray(needle,startAt){
	if ( ! startAt ){ startAt = 0; }
	for ( var i = startAt; i < this.length; i++ ){
		if ( this[i] == needle ){ return i; }
	}
	return -1;
}
function decodeEntities(string){
	alert(string);
	if (string == ""){ return string; }

	var matches = string.match(/&#\d+;?/g);

	if ( typeof(matches) != "undefined" && matches.length > 0 ){
		for(var i = 0; i < matches.length; i++){
			var replacement = String.fromCharCode((matches[i]).replace(/\D/g,""));
			string = string.replace(/&#\d+;?/,replacement);
		}
	}

	return string;
}
