function fixAllLeves(b,a){var c=$("#"+b);c.find("tr").filter(function(){var b=$(this).attr("level");return null!=b&&b}).each(function(){var b=$(this).children("td.FltContentTd,td.FltRootContentTd,td.FltPaginatorTd").first(),c=$(this).attr("level"),c=a-c+1;b.attr("colspan")!=c&&b.attr("colspan",c)});var d=3;"1"==c.attr("issorting")&&d++;c.find("#"+b+"_HeaderSpacer").attr("colspan",a+d);c.find("#"+b+"_HeaderContent").attr("colspan",1);c.attr("depth",a);c=c.find("tr").filter(".Droppable");void 0!=c&&
c.each(function(){$(this).children("td").first().attr("colspan",a+d+1)})}function fixPreviousLevels(b,a,c){$("#"+b+" tr").filter(function(){var b=$(this).attr("level");return null!=b&&""!=b&&b<a}).each(function(){incrementColSpan($(this).children("td.FltContentTd,td.FltRootContentTd,td.FltPaginatorTd"))});incrementColSpan($("#"+c))}function removeFlatTreeRow(b){var a=$("#"+b);b=$("#"+b+"_Droppable");a.remove();void 0!=b&&b.remove()}
function checkChildren(b,a){$("#"+b);$('tr[parentid="'+b+'"]').each(function(){var b=$(this);b.find("input:checkbox").attr("checked",a);b.attr("id")&&checkChildren(b.attr("id"),a)})}function incrementColSpan(b){var a=b.attr("colspan");null==a||""==a||"1"==a?b.attr("colspan",2):b.attr("colspan",b.attr("colspan")+1)}
function showChildren(b,a){var c=$("#"+b),d=getFlatTreeDirectRows(c),e=d.filter("#"+a),f=e.data("RowFilter"),c=c.data("TreeFilter"),h=!0;if(void 0!==c&&0<c.length&&void 0!==f&&0<f.length)for(var g=0;g<f.length;g++)if(-1<$.inArray(f[g],c)){h=!1;break}h&&(showChildrenInternal(d,e,c),e.attr("exp","1"))}function shouldShowChildren(b,a){var c=!0;if(void 0!==a&&0<a.length){var d=b.data("RowFilter");if(void 0!==d&&0<d.length)for(var e=0;e<d.length;e++)if(-1<$.inArray(d[e],a)){c=!1;break}}return c}
function showChildrenInternal(b,a,c){b.filter('tr[parentid="'+a.attr("id")+'"]').each(function(){var a=$(this);shouldShowChildren(a,c)&&(a.hasClass("FltTr")&&(a.attr("hide","0"),a.show(),"1"==a.attr("exp")&&showChildrenInternal(b,a,c)),a.hasClass("FltDropable")&&a.attr("hide","0"))})}
function hideChildren(b,a){var c=$("#"+b),d=getFlatTreeDirectRows(c),c=d.filter("#"+a);d.filter('tr[parentid="'+a+'"]').each(function(){var b=$(this);b.hasClass("FltTr")&&(b.attr("hide","1"),hideInnerChildren(d,b));b.hasClass("FltDropable")&&b.attr("hide","1")}).hide();c.attr("exp","0")}
function hideInnerChildren(b,a){a.hide();a.hasClass("FltTr")&&a.attr("hide","1");a.hasClass("FltDropable")&&a.attr("hide","1");b.filter('tr[parentid="'+a.attr("id")+'"]').each(function(){hideInnerChildren(b,$(this))})}function removeChildren(b){var a=getFlatTreeDirectRows($("#"+b)).filter("tr[parentid]");removeChildrenInternal(b,a)}function removeChildren(b,a){var c=getFlatTreeDirectRows($("#"+b)).filter('tr[parentid="'+a+'"]');removeChildrenInternal(b,c)}
function removeChildrenInternal(b,a){if(void 0!=a&&0<a.length)for(var c,d,e=0;e<a.length;e++)c=$(a[e]),d=c.attr("id"),c.remove(),c=$("#"+b),c.data("TREEPAGINGDATA")&&c.flatTreeGradualPaging("removePagingRow",d),void 0!=d&&""!=d&&removeChildren(b,d)}function moveFlatTreeRow(b,a,c){c=$("#"+c);var d=$("#"+a),e=$("#"+a+"_Droppable");void 0!=e&&c.after(e);moveFlatTreeChildRows(b,a,c);c.after(d)}
function moveFlatTreeChildRows(b,a,c){a=getFlatTreeDirectRows($("#"+b)).filter('tr[parentid="'+a+'"]');if(void 0!=a&&0<a.length)for(var d,e,f=0;f<a.length;f++)d=$(a[f]),e=d.attr("id"),c.after(d),moveFlatTreeChildRows(b,e,d),c=d}function getFlatTreeDirectRows(b){return b.find("> table > tbody > tr")}
function enableFlatTreeRowDrag(b,a){var c=$("#"+a),d=b.parent("tr"),e=d.attr("parentid");enableDrag(b,d,flatTreeDragHelper,function(b){var a=getFlatTreeDirectRows(c).filter("tr[parentid="+e+"]");b=a.index(d);var g=$(this),a=a.index(g),k=g.attr("hide");return-1==a||(void 0==k||"0"==k)&&-1<a&&g.hasClass("FltDropable")&&a!=b-1&&a!=b+1})}function flatTreeDragHelper(b){b=$(b.target).parent("tr");var a=b.clone();a.width(b.width());a.addClass("FltDraging");return a}
function enableFlatTreeSort(b){var a=$("#"+b),c=$("#"+b+"_HeaderSpacer"),d=$("#"+b+' tr[id$="PaginatorRow"]'),e=a.find(".Droppable");if("1"==a.attr("issorting")){$(".FltActiveDraggable").draggable("destroy");var f=$(".FltDraggable"),h=f.length,g=0;f.fadeOut(function(){g++;h==g&&(c.attr("colspan",parseInt(c.attr("colspan"))-1),d.each(function(){var b=$(this);b.attr("colspan",parseInt(b.attr("colspan"))-1)}))});void 0!=e&&e.children("td").each(function(){var b=$(this);b.attr("colspan",parseInt(b.attr("colspan"))-
1)});a.attr("issorting","0")}else $(".FltDraggable").fadeIn().each(function(){var a=$(this);a.hasClass("FltActiveDraggable")&&enableFlatTreeRowDrag(a,b)}),void 0!=e&&e.children("td").each(function(){var b=$(this);b.attr("colspan",parseInt(b.attr("colspan"))+1)}),c.attr("colspan",parseInt(c.attr("colspan"))+1),d.each(function(){var b=$(this);b.attr("colspan",parseInt(b.attr("colspan"))+1)}),a.attr("issorting","1")}
function selectFlatTreeLine(b,a,c,d){$("#"+b).find("tr."+c).each(function(){$(this).removeClass(d);$(this).attr("id")==a&&$(this).addClass(d)})}function hideRow(b,a){var c=$("#"+b),c=getFlatTreeDirectRows(c),d=c.filter("#"+a);hideTreeRow(c,d)}
function hideTreeRow(b,a){var c=a.attr("id");a.attr("hide","1");a.hide();"1"==a.attr("exp")&&b.filter('tr[parentid="'+c+'"]').each(function(){var a=$(this);a.hasClass("FltTr")&&(a.attr("hide","1"),hideInnerChildren(b,a));a.hasClass("FltDropable")&&a.attr("hide","1")}).hide()}
function showTreeRow(b,a,c){var d=!0;"0"!=a.attr("level")&&(d=a.attr("parentid"),d=b.filter('tr[id="'+d+'"]'),d="0"==d.attr("hide")||void 0==d.attr("hide"));d&&(a.attr("hide","0"),a.show(),"1"==a.attr("exp")&&showChildrenInternal(b,a,c))}function shouldFilterRow(b,a){var c=!1;if(void 0!==a&&0<a.length){var d=b.data("RowFilter");if(void 0!==d&&0<d.length)for(var e=0;e<d.length;e++)if(-1<$.inArray(d[e],a)){c=!0;break}}return c}
function filterTrees(b,a){for(var c=0,d=b.length;c<d;c++){var e=$(b[c]),f=e.attr("parentid"),f=$('tr[id="'+f+'"]');shouldFilterRow(f,a)&&(e.hasClass("FltTr")&&(e.attr("hide","1"),e.hide()),e.hasClass("FltDropable")&&e.attr("hide","1"))}}
(function(b){b.fn.flatTreeFilter=function(a){function c(a,c){treeFilters=a.data(e);void 0===treeFilters&&(treeFilters=[]);-1==b.inArray(c,treeFilters)&&treeFilters.push(c);a.data(e,treeFilters);var d=getFlatTreeDirectRows(a),l=0;d.each(function(){var a=b(this);if("1"!==a.attr("hide")){var e=a.data(f);void 0!==e&&0<e.length&&-1<b.inArray(c,e)&&(hideTreeRow(d,a),l++)}});return l}function d(a,c){treeFilters=a.data(e);var d=0;if(void 0!==treeFilters&&0<treeFilters.length){var l=b.inArray(c,treeFilters);
if(-1<l){treeFilters.splice(l,1);a.data(e,treeFilters);var n=getFlatTreeDirectRows(a);n.each(function(){var a=b(this);if("1"===a.attr("hide")){var e=a.data(f);void 0!==e&&0<e.length&&-1<b.inArray(c,e)&&(showTreeRow(n,a,treeFilters),d++)}})}}return d}var e="TreeFilter",f="RowFilter",h={init:function(a){if(!this.data(e)){if(void 0!==a)if(b.isArray(a))this.data(e,a);else throw"ArgumentTypeMismatch : filters must be an array.";return this}},initrow:function(a,c){if(!this.data(f)){if(void 0!==a){if(!b.isArray(a))throw"ArgumentTypeMismatch : filters must be an array.";
if(void 0===c||""===c)throw"ArgumentNullException : flatTreeId.";this.data(f,a);var d=!1;if(void 0!==a&&0<a.length)if(-1<b.inArray("NONE",a))d=!0;else if(treeFilters=b("#"+c).data(e),void 0!==treeFilters&&0<treeFilters.length)for(var l=0;l<a.length;l++)if(-1<b.inArray(a[l],treeFilters)){d=!0;break}d&&hideRow(c,this.attr("id"))}return this}},addTreeFilter:function(a){if(void 0===a)throw"ArgumentNullException : filter.";if(""===a)throw"EmptyStringArgumentException : filter.";return c(this,a)},removeTreeFilter:function(a){if(void 0===
a)throw"ArgumentNullException : filter.";if(""===a)throw"EmptyStringArgumentException : filter.";return d(this,a)}};if(h[a])return h[a].apply(this,Array.prototype.slice.call(arguments,1));if("object"!==typeof a&&a)b.error("Method "+a+" does not exist on FlatTreeFilter plugin");else return h.init.apply(this,arguments)}})(jQuery);
function GradualPagingData(b,a){GradualPagingData.prototype.Defaults={FirstBottomId:"",PageSize:10,ContextRowIdentifier:"",CurrentTopBlock:1,MaxTopBlock:5};if(void 0===b||null===b||""===b)throw"ArgumentNullException : pagingElementId";if(void 0===a||null===a)throw"ArgumentNullException : _options";if(0===$("#"+b).length)throw'ElementNotFoundException : "#'+b+'"';this._pagingElementId=b;this.pagingDataOptions=$.extend({},GradualPagingData.prototype.Defaults,a);this.locked=!1;GradualPagingData.prototype.GetIdentifier=
function(){return this._pagingElementId};GradualPagingData.prototype.IsVisible=function(){var a=$("#"+this._pagingElementId),b=$(window),e=b.scrollTop(),b=e+b.height(),f=0,f=a.offset().top;a.height();return f>e&&f<=b};GradualPagingData.prototype.CreateEventArguments=function(){var a=[];a.push("&contextKey="+this.pagingDataOptions.ContextRowIdentifier);a.push("&rowIdentifier="+this.pagingDataOptions.FirstBottomId);return a.join("")};GradualPagingData.prototype.MustGetMoreItems=function(){var a=!1;
this.pagingDataOptions.CurrentTopBlock<this.pagingDataOptions.MaxTopBlock&&(a=!0);return a};GradualPagingData.prototype.ShouldGetMoreItems=function(){var a=!1;this.pagingDataOptions.CurrentTopBlock<this.pagingDataOptions.MaxTopBlock&&(a=!0);return a};GradualPagingData.prototype.UpdateData=function(a){if(void 0===a||null===a)throw"ArgumentNullException : options";this.pagingDataOptions=$.extend({},GradualPagingData.prototype.Defaults,a);this.locked&&(this.locked=!1,$("#"+this._pagingElementId).remove())};
GradualPagingData.prototype.IsLocked=function(){return this.locked};GradualPagingData.prototype.Lock=function(){this.locked=!0};GradualPagingData.prototype.Unlock=function(){this.locked=!1};GradualPagingData.prototype.toString=function(){return"[PagingElementId : "+this._pagingElementId+", Locked : "+this.locked+", ContextRowIdentifier : "+this.pagingDataOptions.ContextRowIdentifier+", FirstBottomId :"+this.pagingDataOptions.FirstBottomId+"]"}}
(function(b){b.fn.flatTreeGradualPaging=function(a){function c(a){var c=a.data(h);if(void 0!==c)if(b.isArray(c))for(var d=0;d<c.length;d++){var e=c[d],g=a;e.IsVisible()&&e.ShouldGetMoreItems()&&f(e,g)}else throw"TypeMismatch : treePagingData must be an array.";}function d(a,b){for(var c=-1,d=0;d<b.length;d++)if(b[d].GetIdentifier()===a){c=d;break}return c}function e(a,b){a.IsVisible()&&a.MustGetMoreItems()&&f(a,b)}function f(a,b){if(!a.IsLocked()){a.Lock();var c=b.data(g)+a.CreateEventArguments(),
d=function(){a.Unlock()},e=new NextWayAjaxActionConfig;e.Error=d;e.Sucess=d;getAction(c,!0,null,e)}}var h="TREEPAGINGDATA",g="TREEPAGINGBASEURLDATA",k=b(this).parents(".ws_scrollable"),m=null;0<k.length&&(m=k.first());k={init:function(a){if(void 0===a)throw"ArgumentNullException : options";this.data(h)||(this.data(h,[]),this.data(g,a[0]));if(null!=m){var c=b(this).attr("id");setTimeout(function(){b(window).trigger("flattree.newpage",[c])},100)}return this},addPagingRow:function(a,f){var g=this.data(h);
if(void 0===g||null===g)g=[];if(-1==d(a,g)){var k=new GradualPagingData(a,f);g.push(k);if(1==g.length){var p=this;null!=m?b(window).bind("scroll.split.scrolled",b.throttle(250,function(){c(p)})):(b.vortalScrollTracking.IsEnabled()||b.vortalScrollTracking.EnableScrollTracking(),b(window).bind("scroll.GradualPaging",b.throttle(250,function(){c(p)})))}this.data(h,g);e(k,this)}return this},updatePagingRow:function(a,c){var d=this.data(h);if(void 0!==d&&null!==d&&0<d.length){var f;f=-1;for(var g=0;g<d.length;g++){var k=
d[g];if(k.GetIdentifier()===a){f=k;break}}-1!==f&&(f.UpdateData(c),this.data(h,d),e(f,this),null!=m&&b(window).trigger("flattree.newpage",[b(this).attr("id")]))}return this},removePagingRow:function(a){var c=this.data(h);void 0!==c&&null!==c&&0<c.length&&(a=d(a,c),-1<a&&(c.splice(a,1),this.data(h,c),0==c.length&&(b(window).unbind("scroll.GradualPaging"),b.vortalScrollTracking.IsEnabled()&&b.vortalScrollTracking.DisableScrollTracking(),null!=m&&b(window).trigger("flattree.newpage",[b(this).attr("id")]))));
return this}};if(k[a])return k[a].apply(this,Array.prototype.slice.call(arguments,1));if("object"!==typeof a&&a)b.error("Method "+a+" does not exist on FlatTreeGradualPaging plugin");else return k.init.apply(this,arguments)}})(jQuery);
function addFlatTreeRowsAfter(b,a){for(var c=$("#"+a).data("TreeFilter"),d=null,e=document.createDocumentFragment(),d=$("#"+b+a),f=d.find("tbody"),d=0<f.length?f.first().children():d.first().children(),f=0,h=d.length;f<h;f++)e.appendChild(d[f]);$("#"+b).after(e);filterTrees(d,c)}
function addFlatTreeRowsBefore(b,a){for(var c=$("#"+a).data("TreeFilter"),d=null,e=document.createDocumentFragment(),d=$("#"+b+a),f=d.find("tbody"),d=0<f.length?f.first().children():d.first().children(),f=0,h=d.length;f<h;f++)e.appendChild(d[f]);$("#"+b).before(e);filterTrees(d,c)};
