(function(g){function o(e,c){function m(){var a=f.val(),d;d=a?a.replace(/[^\x00-\xff]/g,"**"):"";f.width(d==""?1:d.length*7+10);f.val(a)}function q(a){var d=a[c.paramVal];a=a[c.paramTxt];if(v.indexOf(d)!==-1)I(d);else{if(c.single){A.find(">a").remove();s.uncheck();v=[];B.val("")}var j=g('<a name="'+d+'" class="'+b.selectedItem+'"><b>'+a+"</b></a>");a=g('<span class="'+b.closer+'" title="'+n.removeItem+'">'+n.removeItem+"</span>").click(function(t){t.preventDefault();C(j)});f.before(j.append(a));v.push(d);
B.val(v.join(","));s.check(d)}}function p(){var a={},d=f.val();a[c.paramVal]="`"+d+"`";a[c.paramTxt]=d;q(a);f.hasClass(b.active)&&f.blur();setTimeout(function(){f.focus()},0)}function I(a){var d=A.find('a[name="'+a+'"]');d.addClass(b.blink);var j=0,t=setInterval(function(){d.hasClass(b.blink)?d.removeClass(b.blink):d.addClass(b.blink);if(++j>2){clearInterval(t);t=null}},300)}function C(a){var d;if(a.jquery)d=a.attr("name");else{d=a;a=A.find('a[name="'+d+'"]')}a.remove();a=v.indexOf(d);if(a!=-1){v.splice(a,
1);B.val(v.join(","))}s.uncheck(d)}function J(){var a=f.prev("a");if(a.length){f.width(1).insertBefore(a);setTimeout(function(){f.focus()},0)}}function K(){var a=f.next("a");if(a.length){f.width(1).insertAfter(a);setTimeout(function(){f.focus()},0)}}function F(a,d,j){var t=c.getExtraData();g.ajax({url:a,type:"POST",dataType:"json",data:t,success:d,error:j})}function L(){f.val()?F(c.url.replace("%s",encodeURIComponent(f.val())),function(a){u.empty();if(a.length){for(var d=0,j;j=a[d++];M(j));a=u.find(">a:first");
a.length&&w(a);a=f.offset();u.css({left:a.left,top:a.top+f.outerHeight(true),display:"block"});y=!!u.find(">a").length}}):G()}function G(){y=false;u.hide()}function M(a){var d=a[c.paramVal],j=g('<a class="'+b.dropItem+'" title="'+d+'" name="'+d+'">'+a[c.paramTxt]+"</a>").mousedown(function(){q(a);f.hasClass(b.active)&&f.blur();setTimeout(function(){f.focus()},0)}).mouseover(function(){w(j)}).click(function(t){t.preventDefault()});u.append(j)}function w(a){r&&r.removeClass(b.active);r=a;a.addClass(b.active)}
function H(){var a=D.offset();s.show({left:a.left,top:a.top+x.outerHeight(true),width:D.width()})}c=g.extend({},k,c||{});var z={};for(var E in c)if(E.substr(0,4)=="list"){var N=E.substr(4,1).toLowerCase()+E.substr(5);z[N]=c[E]}var D=g('<div class="'+b.container+'"></div>').insertAfter(e).width(parseInt(c.width)||300),B=g(e).hide(),v=[],r=null,y=0,x=g('<span class="'+b.listBtn+'"></span>').click(function(){s.visible()?s.hide():H()}).prependTo(D),s=new h(g.extend(z,{hide:function(){x.removeClass(b.active)},
show:function(){x.addClass(b.active)},click:function(a,d,j){a?q(j):C(j[c.paramVal])},single:c.single,paramVal:c.paramVal,paramTxt:c.paramTxt,btn:x}));z=D.width()-x.outerWidth(true);var A=g('<div class="'+b.selectedContainer+'"></div>').click(function(){f.focus()}).dblclick(function(){s.visible()||H()}).insertAfter(x).width(z||100),f=g('<input type="text" style="width:20px" />').keyup(function(a){if(a.keyCode==13)if(y)r&&r.mousedown();else this.value&&c.anytext&&p();else if(!(a.keyCode>36&&a.keyCode<
41)){m();L()}}).keydown(function(a){if(a.keyCode==13)return false;if(this.value=="")switch(a.keyCode){case 37:J();return;case 39:K();return;case 8:a=f.prev("a");a.length&&C(a);return;case 46:a=f.next("a");a.length&&C(a);return}if(!(a.keyCode==37||a.keyCode==39))if(a.keyCode==8||a.keyCode==46)m();else if(a.keyCode==40){if(y){a=null;if(r&&(a=r.next("a")).length)w(a);else{a=u.find(">a:first");a.length&&w(a)}}}else if(a.keyCode==38){if(y){a=null;if(r&&(a=r.prev("a")).length)w(a);else{a=u.find(">a:last");
a.length&&w(a)}}}else setTimeout(m,0)}).focus(function(){this.value="";m();s.hide();f.addClass(b.active)}).blur(function(){f.removeClass(b.active);setTimeout(G,10)}).prependTo(A).css("max-width",z||100),u=g('<div class="'+b.dropContainer+'"></div>').appendTo(document.body);c.initUrl&&F(c.initUrl.replace("%s",encodeURIComponent(B.val())),function(a){if(a.length)for(var d=0,j;j=a[d++];q(j));})}var n={removeItem:"\u79fb\u9664\u6b64\u9879",noSuggestItem:"\u672a\u53d1\u73b0\u5339\u914d\u9879"},k={single:false,
width:300,url:"keyword=%s",paramVal:"value",paramTxt:"text",anytext:false,initUrl:"",listBridge:"scroll",listUrl:"",listExpanded:false,listParamHaschild:"hasChildren",getExtraData:function(){}},b={active:"active",blink:"blink",container:"suggestContainer",selectedItem:"selectedItem",closer:"closer",selectedContainer:"selectedContainer",listBtn:"listAllBtn",dropContainer:"dropContainer",dropItem:"dropItem",dropInfo:"dropInfo",listPanel:"listPanel"},l={};o.registerBridge=function(e,c){l[e]=c};var h=
function(e){var c=this;c.inited=false;c.options=e;c.panel=g('<div class="'+b.listPanel+'"></div>').appendTo(document.body);c.checked=[];var m=l[c.options.bridge];c.init=function(){if(!c.inited){m(c);c.inited=true}return c}},i=g();h.prototype={uncheck:function(e){if(e==undefined){this.checked=[];this.inited&&this.panel.find("input").attr("checked",false)}else{var c=this.checked.indexOf(e);c!=-1&&this.checked.splice(c,1);this.inited&&this.panel.find("input[value="+e+"]").attr("checked",false)}},check:function(e){this.checked.indexOf(e)==
-1&&this.checked.push(e);this.inited&&this.panel.find("input[value="+e+"]").attr("checked",true)},hide:function(){this.inited&&this.panel.hide();i.unbind("mousedown.suggest");this.options.hide();return this},show:function(e){var c=this,m=c.panel,q=c.options;btn=q.btn;c.init();setTimeout(function(){i.bind("mousedown.suggest",function(p){p=p.target;p==m[0]||btn&&btn.index(p)!=-1||m.find(p.tagName||"*").index(p)!=-1||c.hide()})},0);e&&m.css(e);m.show();q.show();return c},visible:function(){return this.inited&&
this.panel.is(":visible")}};g.suggest=o;g.fn.suggest=function(e){this.each(function(){var c={},m=g(this);for(var q in k){var p=m.attr(q);p&&(c[q]=p)}o(this,g.extend({},c,e||{}))});return this}})(jQuery);
(function(g){function o(b){var l=b.options;b._lock=true;g.ajax({url:l.url.replace("%s",++b._page),success:function(h){var i;if(h.data&&(i=h.data.length)){b._total||(b._total=parseInt(h.total));b._count+=i;b._pageinfo.text(b._count+" / "+b._total);for(var e=0;e<i;e++)n(h.data[e],b)}},complete:function(){b._lock=false},dataType:"json"})}function n(b,l){var h=l.options,i=b[h.paramVal],e=g('<label><input type="'+(h.single?"radio":"checkbox")+'" value="'+i+'" /><span title="'+i+'">'+b[h.paramTxt]+"</span></label>");
e.find("input").click(function(){h.click(this.checked,i,b);this.checked?l.check(i):l.uncheck(i)}).attr("checked",l.checked.indexOf(i)!=-1);l._container.append(e)}var k={container:"scrollContainer",pageinfo:"pageInfo",closer:"listCloser"};g.suggest.registerBridge("scroll",function(b){b._lock=false;b._count=0;b._total=0;b._page=0;var l=b.panel;l.append('\t<h3>\t\t<span class="'+k.closer+'">close</span>\t\t<span class="'+k.pageinfo+'">0 / 0</span>\t</h3>\t<div class="'+k.container+'" title="\u6eda\u52a8\u7ffb\u9875"></div>');
b._pageinfo=l.find("span."+k.pageinfo);l.find("span."+k.closer).click(function(){b.hide()});var h=l.find("div."+k.container).mousewheel(function(i,e){e<0&&!b._lock&&b._count<b._total&&h.scrollTop()+h.height()>h[0].scrollHeight-20&&o(b)});b._container=h;o(b)})})(jQuery);
(function(g){var o={container:"treeContainer",closer:"listCloser"};g.suggest.registerBridge("tree",function(n){var k=n.options,b=n.panel;b.append('\t<h3>\t\t<span class="'+o.closer+'">close</span>\t</h3>\t<div class="'+o.container+'" idv="tree"></div>');b.find("span."+o.closer).click(function(){n.hide()});var l=k.single?"radio":"checkbox";b.find("div."+o.container).tree({paramId:k.paramVal,paramHaschild:k.paramHaschild,expanded:k.expanded,url:k.url,renderTxt:function(h,i,e){h=g('<label><input type="'+
l+'" value="'+i+'" /><span title="'+i+'">'+e[k.paramTxt]+"</span></label>");h.find("input").click(function(){k.click(this.checked,this.value,e);this.checked?n.check(i):n.uncheck(i)}).attr("checked",n.checked.indexOf(i)!=-1);return h}});return n})})(jQuery);
