(function(g){window.scrollFeed=function(f,c){f=g(f);c||(c={});var v=g.trim(c.template||""),s=c.pageSize||20,t=(c.baseUrl||"")+"&pagesize="+s,w=c.idPrefix||"item_",x=ct.func(c.rowReady)||function(){},y=ct.func(c.rowChecked)||function(){},z=ct.func(c.rowViewed)||function(){},A=ct.func(c.jsonLoaded)||function(){},n=ct.func(c.countRow)||function(){},B=c.descUrl||"",j=c.pageCtrl,h={},k=null,i=0,l=0,p=function(b){var a=v;for(var d in b)a=a.replace(RegExp("{"+d+"}","gm"),b[d]);a=g(a);var e=a[0].id.substr(w.length);
if(!(e in h)){h[e]=a;a.hover(function(){a.addClass("hover")},function(){a.removeClass("hover")});a.find(">h3").click(function(){a.trigger("check")});a.bind("check",function(){if(a.hasClass("expanded"))a.removeClass("expanded");else if(a.find(">div").length)a.addClass("expanded");else{g('<div class="item-desc"><img width="16" height="16" src="images/loading.gif" /></div>').appendTo(a.addClass("expanded")).load(B,a.attr("param"));z(e,a,b)}if(k!=a){y(a,b);a.addClass("focus");k&&k.trigger("unCheck");
k=a}}).bind("unCheck",function(){a.removeClass("focus expanded")});a.data("json",b);x(a,b);return a}},q="",m=0,u=1,r=0,o=false;this.load=function(b){b.nodeType&&(b=g(b));b&&(q=b.jquery?b.serialize():b);g.post(t,q,function(a){o=false;r=a.total;u=1;m=a.data.length;f.empty();h={};k=null;for(var d=0;d<m;d++){var e=p(a.data[d]);e&&f.append(e)}A(a);l=r;i=m;n(i+"/"+l)},"json")};this.addRow=function(b){(b=p(b))&&(f.prepend(b),n(++i+"/"+ ++l))};this.deleteRow=function(b){var a=h[b];if(a){a.remove();delete h[b];
n(--i+"/"+--l);f.find(">li").length<s&&j.scroll()}};this.getRow=function(b){return h[b]};this.allRow=function(){return h};j.scroll(function(){if(!o&&m<r&&f.is(":visible")&&j.scrollTop()+j.height()>j[0].scrollHeight-90){o=true;g.post(t+"&page="+ ++u,q,function(b){if(b.state){var a=b.data.length;m+=a;i+=a;n(i+"/"+l);for(var d=0;d<a;d++){var e=p(b.data[d]);e&&f.append(e)}o=false}},"json")}})}})(jQuery);
