(function(c){c.fn.cityrpc=function(d){return this.each(function(){c.fn.cityrpc.bindrpc(this,d)})};c.fn.cityrpc_onchange=function(d){return this.each(function(){c(this).keypress(function(f){if(f.which==32||(f.which>=65&&f.which<=(65+25))||(f.which>=97&&f.which<=(97+25))){d(f)}});c(this).change(function(f){d(f)})})};c.fn.cityrpc_ac=function(d){return this.each(function(){var g=c.extend({},c.fn.cityrpc.defaults,d);if(c.fn.metadata){c.extend(true,g,c(this).metadata())}var f={rpc_module:g.rpc_module,rpc_class:g.rpc_class,call:g.call};if(g.rpc_params){c.extend(f,g.rpc_params)}var e=c.extend({},c.fn.cityrpc.ac_defaults,g.ac_options);e.cb_cityrpc=function(h){if(g.rpc_sendform){c(g.rpc_sendform).each(function(){c.extend(f,c.fn.cityrpc.formToArray(this))})}if(g.rpc_attach){jQuery.each(g.rpc_attach,function(j,k){f[j]=c(k).val()})}if(g.val_as){f[g.val_as]=h.data.q}delete h.data.q;c.extend(h,{url:g.rpc_handler,data:c.extend(h.data,f),dataType:g.rpc_datatype,type:f.rpc_type});return h};c(this).autocomplete("egal",e)})};c.fn.cityrpc.bindrpc=function(e,d){var g=c(e);var h=c.extend({},c.fn.cityrpc.defaults,d);if(c.fn.metadata){c.extend(true,h,g.metadata())}var f={rpc_module:h.rpc_module,rpc_class:h.rpc_class,call:h.call};if(h.rpc_params){c.extend(f,h.rpc_params)}if(h.rpc_sendform){c(h.rpc_sendform+' input[type="submit"]').unbind("click").bind("click",function(i){f[c(this).attr("name")]=c(this).val();return true})}g.bind(h.event,function(i){if(h.eventcallback&&!h.eventcallback(i)){i.stopPropagation();return false}if(h.rpc_sendform){c(h.rpc_sendform).each(function(){c.extend(f,c.fn.cityrpc.formToArray(this));a={};a[e.name]=e.value;c.extend(f,a)})}if(h.rpc_params_callback){a=h.rpc_params_callback();c.extend(f,a)}if(h.rpc_attach){jQuery.each(h.rpc_attach,function(k,l){f[k]=c(l).val()})}if(h.rpc_attach_multi){jQuery.each(h.rpc_attach_multi,function(l,k){c(k).each(function(n,p){var m=p.name;if(!m){return}var o=c.fn.cityrpc.fieldValue(p,true);f[m]=o})})}if(h.val_as){f[h.val_as]=g.val()}if(h.attributes){jQuery.each(h.attributes,function(l,k){f[l]=e[k]})}c.fn.cityrpc.animate_out(h);if(h.superLoad){f.superLoad=c.toJSON(h.superLoad);c.superLoad({type:h.rpc_type,url:h.rpc_handler,data:f,dataType:h.rpc_datatype})}else{var j=function(k){h.on_show_result(k,h)};c.ajax({type:h.rpc_type,url:h.rpc_handler,data:f,dataType:h.rpc_datatype,success:j})}return h.stop_event?false:true});return g};c.fn.cityrpc.eventcallback=function(d){if(d.type=="keyup"){if(d.which<46&&d.which!=8){return false}}return true};c.fn.cityrpc.on_show=function(e,d){c(d.destination).html(e);c.fn.cityrpc.animate_in(d)};c.fn.cityrpc.animate_in=function(d){if(d.animate_in){jQuery(d.destination).animate(d.animate_in)}};c.fn.cityrpc.animate_out=function(d){if(d.animate_out){jQuery(d.destination).animate(d.animate_out)}};function b(f,d,e){if(window.console&&window.console.log){if(e){window.console.log(d+": "+f)}else{window.console.log(d+": "+c.toJSON(f))}}}c.fn.cityrpc.ac_defaults={type:"post"};c.fn.cityrpc.defaults={eventcallback:c.fn.cityrpc.eventcallback,event:"keyup",rpc_handler:"../rpc/default_ax_handler.php",rpc_class:"",rpc_module:"",call:"get_user_list",rpc_type:"POST",rpc_params:{},rpc_sendform:false,rpc_datatype:false,val_as:false,attribute:false,destination:"#echobox",on_show_result:c.fn.cityrpc.on_show,animate_out:false,animate_in:false,ac_options:c.fn.cityrpc.ac_defaults};c.fn.cityrpc.formToArray=function(d,m){var l={};if(this.length==0){return l}var g=c(d.getElementsByTagName("*")).filter("*[exclude!=true]");if(!g){return l}var h={};for(var j=0,k=g.length;j<k;j++){var e=g[j];var f=e.name;if(!f){continue}var o=c.fn.cityrpc.fieldValue(e,true);if(o===null||typeof o=="undefined"){continue}rx=/^(.*)\[(.*)\]$/;res=e.name.match(rx);if(res){if(typeof h[res[1]]=="undefined"){h[res[1]]={}}h[res[1]][res[2]]=o;continue}l[f]=o}c.extend(l,h);return l};c.fn.cityrpc.fieldValue=function(d,k){var f=d.name,q=d.type,r=d.tagName.toLowerCase();if(typeof k=="undefined"){k=true}if(k&&(!f||d.disabled||q=="reset"||q=="button"||(q=="checkbox"||q=="radio")&&!d.checked||(q=="submit"||q=="image")&&d.form&&d.form.clk!=d||r=="select"&&d.selectedIndex==-1)){return null}if(r=="select"){var l=d.selectedIndex;if(l<0){return null}var o=[],e=d.options;var h=(q=="select-one");var m=(h?l+1:e.length);for(var g=(h?l:0);g<m;g++){var j=e[g];if(j.selected){var p=j.value;if(!p){p=(j.attributes&&j.attributes.value&&!(j.attributes.value.specified))?j.text:j.value}if(h){return p}o.push(p)}}return o}return d.value}})(jQuery);
