
/**
* Changes a dynamically generated list
* @param string The name of the list to change
* @param array A javascript array of list options in the form [key,value,text]
* @param string The key to display
* @param string The original key that was selected
* @param string The original item value that was selected
*/
function changeDynaList( listname, source, key, orig_key, orig_val ) {
	var list = eval( 'document.catSearch.' + listname );

	// empty the list
	for (i in list.options.length) {
		list.options[i] = null;
	}
	i = 0;
	for (x in source) {
		if (source[x][0] == key) {
			opt = new Option();
			opt.value = source[x][1];
			opt.text = source[x][2];
			
			if (i%2==0) opt.className = 'list_select_1';
			
			
			//alert ('key: '+orig_key+' '+key+'  value: '+orig_val+' '+opt.value);
			
			if ((orig_key == key && orig_val == opt.value) || i == 0) {
				opt.selected = true;
			}
			
			
			list.options[i++] = opt;
		}
	}
	list.length = i;
	document.catSearch.listModel.disabled = false;
}

function updateDynaList( listname, source, key ,catModel) {
	var list = eval( 'document.catSearch.' + listname );

	// empty the list
	for (i in list.options.length) {
		list.options[i] = null;
	}
	
	if (key == 0) {
		opt = new Option();
		opt.value = source[0][1];
		opt.text = source[0][2];
		opt.selected = true;
	}
	else {
		i = 0;
		for (x in source) {
			if (source[x][0] == key) {
				opt = new Option();
				opt.value = source[x][1];
				opt.text = source[x][2];
				
				if (source[x][3] != 0 && source[x][1] == catModel) {
					opt.selected = true;
				//	alert ('ok');
				}
				
				list.options[i++] = opt;
			}
		}
		list.length = i;
	}
}