/*
Function for use in conjunction with Autocomplete
@param txt : the textbox being updated - must begin with "_"
@param li : the <li> that was selected in the autocomplete
@notes : excepts txt to be named like "field_name" and to find a hidden field named like "field_id" whose value will be set to the retrieved key 
*/
function updateHidden(txt, li)
{
	var singular = true;
	var hiddenName = "";
	if (!txt.form[hiddenName] || hiddenName == txt.name) {
		hiddenName = txt.name.replace(/_names/, "_ids");
		singular = false;
	}

	if(!txt.form[hiddenName] || hiddenName == txt.name) {
    	hiddenName = txt.name.replace(/_name/,"_id");
		singular = true;
	}

	//this is possibly a bad idea, if "name" is a sub-string of txt
	if (!txt.form[hiddenName] || hiddenName == txt.name) {
		hiddenName = txt.name.replace(/_name/, "");
		singular = false;
	}

    id = li.id.replace("auto_","");
    if(txt.form[hiddenName].value == "" || singular) { txt.form[hiddenName].value = id; }
    else { txt.form[hiddenName].value = txt.form[hiddenName].value + "," + id; }
}