!function(a,b,c,d){a.fn.tabNavigation=function(c){var e,f,g,h,i,j=a.extend(!0,{},a.fn.tabNavigation.settings,c),k=a(this),l=a(j.context).find(j.selector.tabs),m=!0,n={},o=0,p=this,q=(new Date).getTime(),r=[],s=k.selector||"",t=j.className,u=j.metadata,v=j.namespace,w=j.errors,x=k.data("module"),y=arguments[0],z=x!==d&&"string"==typeof y;return[].slice.call(arguments,1),h={initialize:function(){if(h.debug("Initializing Tabs",k),j.history){if(a.address===d)return h.error(w.state),!1;if(j.path===!1)return h.error(w.path),!1;h.verbose("Address library found adding state change event"),a.address.state(j.path).change(h.event.history.change)}a.isWindow(k.get(0))||k.on("click."+v,h.event.click),k.data("module",h)},destroy:function(){h.debug("Destroying tabs",k),k.off("."+v)},event:{click:function(){h.debug("Navigation clicked");var b=a(this).data(u.tab);b!==d?b!==e&&(j.history?a.address.value(b):h.change(b)):h.debug("No tab specified")},history:{change:function(b){var c=b.pathNames.join("/")||h.get.initialPath(),e=j.templates.determineTitle(c)||!1;h.debug("History change event",c,b),g=b,c!==d&&h.change(c),e&&a.address.title(e)}}},refresh:function(){e&&(h.debug("Refreshing tab",e),h.change(e))},cache:{read:function(a){return a!==d?n[a]:n},add:function(a,b){a=a||e,h.debug("Adding cached content for",a),n[a]=b},remove:function(a){a=a||e,h.debug("Removing cached content for",a),delete n[a]}},change:function(c){var d=h.get.defaultPathArray(c);h.deactivate.all(),a.each(d,function(i,k){var l=d.slice(0,i+1),o=h.utils.arrayToPath(l),p=h.utils.last(d)==o,q=h.is.tab(o),r=!q,s=b.history&&b.history.pushState,t=s&&j.ignoreFirstLoad&&m,u=a.isPlainObject(j.apiSettings),v=h.get.tabElement(o);return h.verbose("Looking for tab",k),r?(h.verbose("Tab is not found, assuming it is a parameter",k),!0):(q&&(h.verbose("Tab was found",k),e=o,f=h.utils.filterArray(d,l),p&&u?t?(h.debug("Ignoring remote content on first tab load",o),m=!1,n[c]=v.html(),h.activate.all(o),a.proxy(j.onTabInit,v)(o,f,g)):(h.activate.navigation(o),h.content.fetch(o,j.onTabLoad)):(h.debug("Opened tab",o),h.activate.all(o),a.proxy(j.onTabLoad,v)(o,f,g))),void 0)})},content:{fetch:function(b){var c=h.get.tabElement(b),i=n[b]||!1,k={dataType:"html",stateContext:c,success:function(d){n[b]=d,h.content.update(b,d),b==e?(h.debug("Content loaded",b),h.activate.tab(b)):h.debug("Content loaded in background",b),a.proxy(j.onTabInit,c)(b,f,g)},urlData:{tab:b}},l=c.data(u.promise)||!1,m=l&&"pending"===l.state();j.cache&&i?(h.debug("Showing existing content",b),h.activate.tab(b),a.proxy(j.onTabLoad,c)(b,f,g)):m?(h.debug("Content is already loading",b),c.addClass(t.loading)):a.api!==d?(h.debug("Retrieving content",b),a.api(a.extend(!0,{},j.apiSettings,k))):h.error(w.api)},update:function(a,b){h.debug("Updating html for",a);var c=h.get.tabElement(a);c.html(b)}},activate:{all:function(a){h.activate.tab(a),h.activate.navigation(a)},tab:function(a){var b=h.get.tabElement(a);h.verbose("Showing tab content for",b),b.addClass(t.active)},navigation:function(a){var b=h.get.navElement(a);h.verbose("Activating tab navigation for",b),b.addClass(t.active)}},deactivate:{all:function(){h.deactivate.navigation(),h.deactivate.tabs()},navigation:function(){k.removeClass(t.active)},tabs:function(){l.removeClass(t.active+" "+t.loading)}},is:{tab:function(a){return h.get.tabElement(a).size()>0}},get:{initialPath:function(){return k.eq(0).data(u.tab)||l.eq(0).data(u.tab)},defaultPathArray:function(a){return h.utils.pathToArray(h.get.defaultPath(a))},defaultPath:function(a){var b=k.filter("[data-"+u.tab+'^="'+a+'/"]').eq(0),c=b.data(u.tab)||!1;if(c){if(h.debug("Found default tab",c),o0?b:c},tab:function(){return e}},utils:{filterArray:function(b,c){return a.grep(b,function(b){return-1==a.inArray(b,c)})},last:function(b){return a.isArray(b)?b[b.length-1]:!1},pathToArray:function(a){return a===d&&(a=e),"string"==typeof a?a.split("/"):[a]},arrayToPath:function(b){return a.isArray(b)?b.join("/"):!1}},setting:function(b,c){return h.debug("Changing setting",b,c),c===d?j[b]:(a.isPlainObject(b)?a.extend(!0,j,b):j[b]=c,void 0)},internal:function(b,c){return h.debug("Changing internal",b,c),c===d?h[b]:(a.isPlainObject(b)?a.extend(!0,h,b):h[b]=c,void 0)},verbose:function(){j.verbose&&j.debug&&(h.performance.log(arguments[0]),h.verbose=Function.prototype.bind.call(console.info,console,j.moduleName+":"))},debug:function(){j.debug&&(h.performance.log(arguments[0]),h.debug=Function.prototype.bind.call(console.info,console,j.moduleName+":"))},error:function(){console.log!==d&&(h.error=Function.prototype.bind.call(console.error,console,j.moduleName+":"))},performance:{log:function(a){var b,c,d;j.performance&&(b=(new Date).getTime(),d=q||b,c=b-d,q=b,r.push({Element:p,Name:a[0],Arguments:a[1]||"","Execution Time":c})),clearTimeout(h.performance.timer),h.performance.timer=setTimeout(h.performance.display,100)},display:function(){var b=j.moduleName+":",c=0;q=!1,a.each(r,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",s&&(b+=" '"+s+"'"),(console.group!==d||console.table!==d)&&r.length>0&&(console.groupCollapsed(b),console.table?console.table(r):a.each(r,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),r=[]}},invoke:function(b,c,e){var f,g;return e=e||[].slice.call(arguments,2),"string"==typeof b&&x!==d&&(b=b.split("."),f=b.length-1,a.each(b,function(b,c){return a.isPlainObject(x[c])&&b!=f?(x=x[c],!0):x[c]!==d?(g=x[c],!0):(h.error(j.errors.method),!1)})),a.isFunction(g)?g.apply(c,e):g}},z?(x===d&&h.initialize(),i=h.invoke(y)):(x!==d&&h.destroy(),h.initialize()),i!==d?i:this},a.tabNavigation=function(c){a(b).tabNavigation(c)},a.fn.tabNavigation.settings={moduleName:"Tab Module",verbose:!1,debug:!0,namespace:"tab",onTabInit:function(){},onTabLoad:function(){},templates:{determineTitle:function(){}},history:!1,path:!1,context:"body",maxDepth:25,ignoreFirstLoad:!0,alwaysRefresh:!1,cache:!0,apiSettings:!1,errors:{api:"You attempted to load content without API module",noContent:"The tab you specified is missing a content url.",method:"The method you called is not defined",state:"The state library has not been initialized",missingTab:"Missing tab: ",path:"History enabled, but no path was specified",recursion:"Max recursive depth reached"},metadata:{tab:"tab",loaded:"loaded",promise:"promise"},className:{loading:"loading",active:"active"},selector:{tabs:".tab"}}}(jQuery,window,document);