(function(a){function f(g,d){if(!d.groupsData)return;var h=this,f={groupsBoxContainer:a(d.groupsBoxContainer),isExpanded:"isExpanded"};a.extend(h,{getGroupBox:function(){return g},init:function(){e(d,f);var b=g.siblings().find(d.expandAllElement);if(d.expandAllElement!=null){this.expandAll();b.data("isexpanded",true)}else b.data("isexpanded",false);d.checkAllElement!=null&&this.checkAll();d.displayExpand==false&&a.each(a(f.groupsBoxContainer).children("ul"),function(){a(this).children().first("li").children("div:eq(2)").hide()});f.groupsBoxContainer.find("ul > li > div.checkbox-head.check75").size()==f.groupsBoxContainer.find("ul").size()&&f.groupsBoxContainer.parents().find(d.checkAllElement).html(d.checkAllTitles[1])},expandAll:function(){d.changeTitles&&a(d.expandAllElement).html(d.expandOnLoad?d.expandAllTitles[1]:d.expandAllTitles[0]);var b=g.siblings().find(d.expandAllElement);jQuery(b).click(function(){var b=a(this).html()==d.expandAllTitles[1];a.each(a(f.groupsBoxContainer).children("ul"),function(){c(b,a(this).children().first("li"))});if(b){a(this).html(d.expandAllTitles[0]);a(this).data("isexpanded",true)}else{a(this).html(d.expandAllTitles[1]);a(this).data("isexpanded",false)}})},checkAll:function(){d.changeTitles&&a(d.checkAllElement).html(d.checkAllTitles[0]);var c=g.siblings().find(d.checkAllElement);c.click(function(){var c=a(this).html()==d.checkAllTitles[1];a.each(a(f.groupsBoxContainer).children("ul"),function(){b(d,true,a(this).children().first("li").children("div:eq(0)"),!c)});if(c)a(this).html(d.checkAllTitles[0]);else a(this).html(d.checkAllTitles[1]);d.onChange()})},getCheckedItems:function(){var b=[];a.each(f.groupsBoxContainer.find("li"),function(){var c=false;if(a(this).data("raw"))c=typeof a(this).data("raw").isCalendar=="undefined"?true:a(this).data("raw").isCalendar;a(this).data("raw")&&a(this).data("raw").checked&&c&&b.push(a(this).data("raw"))});return b}});h.init();a.prototype.groupBox.getCheckedItems=function(){return h.getCheckedItems()}}function e(d,e){a.each(d.groupsData,function(k){var g=a("
").appendTo(e.groupsBoxContainer),f=a("").addClass(d.headerClass).appendTo(g),j=typeof groupingTxt==="undefined"?"Grouping":groupingTxt,h=typeof expandCollapseTxt==="undefined"?"Expand/Collapse":expandCollapseTxt,l=this.text+" "+j,i=k===0?d.headerCheckBoxClass+" modalFirstInput":d.headerCheckBoxClass;f.append(''+l+''+this.text+'
'+h+'');!this.checked&&f.children("div:eq(0)").removeClass(d.headerCheckClassToogle+" icon");f.children("div:lt(2)").click(function(){b(d,true,f.children("div:eq(0)"));var a=e.groupsBoxContainer.siblings().find(d.checkAllElement),c=a.html()==d.checkAllTitles[1];if(c){a.html(d.checkAllTitles[0]);f.data("groupProcessed",true)}d.onChange()});f.children("div:lt(2)").keypress(function(c){if(c.which===13||c.which===32){b(d,true,f.children("div:eq(0)"));var a=e.groupsBoxContainer.siblings().find(d.checkAllElement),g=a.html()==d.checkAllTitles[1];if(g){a.html(d.checkAllTitles[0]);f.data("groupProcessed",true)}d.onChange()}});f.data(e.isExpanded,this.expanded);f.children("div:eq(2)").click(function(){c(f.data(e.isExpanded),f)});f.children("div:eq(2)").keypress(function(a){(a.which===13||a.which===32)&&c(f.data(e.isExpanded),f)});a.each(this.items,function(j,e){var c=a("").addClass(d.itemClass).appendTo(g),h=c.parent().children().first().children().first()[0]?c.parent().children().first().children().first()[0].id:"",i=typeof externalLinkTxt==="undefined"?"External Link":externalLinkTxt;c.parent().data("groupProcessed",false);c.data("raw",e);if(e.isCalendar||typeof e.isCalendar=="undefined")c.append(a(''+e.text+'').addClass(d.itemCheckBoxClass)).append(a("").html(e.text).css({width:"140px","float":"left"})).keypress(function(h){if(h.which===13||h.which===32){b(d,null,c.children("div:eq(0)"));var i=a(d.checkAllElement).html()==d.checkAllTitles[1],e=c.parent().children("li").children("div:gt(0)."+d.headerCheckClassToogle).size(),g=c.parent().children("li").children("div:gt(0).checkbox").size();if(e==g){var j=c.parent().data("groupProcessed");if(!j){b(d,false,f.children("div:eq(0)"));c.parent().data("groupProcessed",true)}i&&a(d.checkAllElement).html(d.checkAllTitles[0])}else if(e'+i+" "+e.text+"").addClass(d.itemExternalLinkClass).attr({"aria-labelledby":"GroupBoxHeader "+h+" groupBoxExternalLabel"+e.id,tabindex:0,role:"button"})).append(a("").html(e.text).css({width:"140px","float":"left","text-decoration":"underline"}).attr("title",e.link)).click(function(){var a=e.link;if(a.indexOf("http")==-1)a="http://"+a;window.open(a,"externalWindow")}).keydown(function(c){var a=e.link,b=c.keyCode;if(b!==13&&b!==32)return;if(a.indexOf("http")==-1)a="http://"+a;window.open(a,"externalWindow")});!e.checked&&c.children("div:eq(0)").removeClass(d.headerCheckClassToogle+" icon")});c(!this.expanded,f)})}function b(b,f,c,e){var g={init:function(){if(!f)this.checkItem();else this.checkAllItems()},checkItem:function(){if(c.hasClass(b.headerCheckClassToogle)){if(e)return;c.removeClass(b.headerCheckClassToogle+" icon").attr("aria-checked",false);d(c,false)}else{c.addClass(b.headerCheckClassToogle+" icon").attr("aria-checked",true);d(c,true)}},checkAllItems:function(){this.checkItem();var f=c.hasClass(b.headerCheckClassToogle),e=c.parent().parent().children("li").children("div:gt(0).checkbox").removeClass(b.headerCheckClassToogle+" icon");if(f)e.addClass(b.headerCheckClassToogle+" icon").attr("aria-checked",true);else e.removeClass(b.headerCheckClassToogle+" icon").attr("aria-checked",false);a.each(e,function(){d(a(this),f)})}};g.init()}function d(a,b){if(typeof a.parent().data("raw")!="undefined")a.parent().data("raw").checked=b}function c(b,a){if(b){a.siblings().hide();a.children("div:eq(2)").addClass("up").removeClass("down").attr("aria-expanded",false)}else{a.siblings().show();a.children("div:eq(2)").addClass("down").removeClass("up").attr("aria-expanded",true)}a.data("isExpanded",!b)}a.fn.groupBox=function(c){if(this.data("groupbox"))return this.data("groupbox");var d=a.extend({},a.fn.groupBox.defaults,c),b;this.each(function(){var e=new f(a(this),d),c=e.getGroupBox().data("groupbox",e);b=b?b.add(c):c});return b?b:this};a.fn.groupBox.defaults={groupsData:null,groupsBoxContainer:null,headerClass:null,headerCheckBoxClass:null,headerCheckClassToogle:null,headerUpDowClass:null,itemClass:null,itemCheckBoxClass:null,itemExternalLinkClass:null,expandAllElement:null,expandAllTitles:[null,null],checkAllElement:null,checkAllTitles:[null,null],expandOnLoad:true,onChange:function(){return null},displayExpand:null,changeTitles:true}})(jQuery)