// @@@ api.js @@@
function RemoveChildren(elm){while(elm.hasChildNodes()){elm.removeChild(elm.firstChild);}}
function getoptions(field){var sel=document.forms['search'].elements[field];var list=new Array;for(var i=sel.options.length-1;i>=0;i-=1){if(sel.options[i].selected){list.push(sel.options[i].value);}}
return list.join(",");}
function setfield(id,fieldlist){var date=new Date();var time=date.getTime();var cb=time-(time%(5*60*1000));var args={_cmd:'select_list_data',field:id,'cb':cb};var length=fieldlist.length;var i;for(i=0;i<length;i++){var fieldname=fieldlist[i];args[fieldname]=getoptions(fieldname);}
jQuery.getJSON("/api/ajaxapi.wa2",args,function(j){var elm=document.forms['search'].elements[id];RemoveChildren(elm);length=j.length;for(i=0;i<length;i++){var opt=document.createElement('OPTION');opt.setAttribute('value',j[i].optValue);var text=document.createTextNode(j[i].optDisplay);opt.appendChild(text);if(j[i].optSelected){opt.setAttribute('selected',true);}
elm.appendChild(opt);}})}