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