!function(a,b,c,d){a.fn.sidebar=function(b){var e,f=a(this),g=f.selector||"",h=(new Date).getTime(),i=[],j=arguments[0],k="string"==typeof j,l=[].slice.call(arguments,1);return f.each(function(){var m,n=a.isPlainObject(b)?a.extend(!0,{},a.fn.sidebar.settings,b):a.fn.sidebar.settings,o=(n.selector,n.className),p=n.namespace,q=n.error,r="."+p,s="module-"+p,t=a(this),u=a("body"),v=a("head"),w=a("style[title="+p+"]"),x=this,y=t.data(s);m={initialize:function(){m.debug("Initializing sidebar",t),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),y=m,t.data(s,m)},destroy:function(){m.verbose("Destroying previous module for",t),t.off(r).removeData(s)},refresh:function(){m.verbose("Refreshing selector cache"),w=a("style[title="+p+"]")},attachEvents:function(b,c){var d=a(b);c=a.isFunction(m[c])?m[c]:m.toggle,d.size()>0?(m.debug("Attaching sidebar events to element",b,c),d.off(r).on("click"+r,c)):m.error(q.notFound)},show:function(){m.debug("Showing sidebar"),m.is.closed()?(n.overlay||m.pushPage(),m.set.active()):m.debug("Sidebar is already visible")},hide:function(){m.is.open()&&(n.overlay||(m.pullPage(),m.remove.pushed()),m.remove.active())},toggle:function(){m.is.closed()?m.show():m.hide()},pushPage:function(){var a=m.get.direction(),b=m.is.vertical()?t.outerHeight():t.outerWidth();n.useCSS?(m.debug("Using CSS to animate body"),m.add.bodyCSS(a,b),m.set.pushed()):m.animatePage(a,b,m.set.pushed)},pullPage:function(){var a=m.get.direction();n.useCSS?(m.debug("Resetting body position css"),m.remove.bodyCSS()):(m.debug("Resetting body position using javascript"),m.animatePage(a,0)),m.remove.pushed()},animatePage:function(a,b){var c={};c["padding-"+a]=b,m.debug("Using javascript to animate body",c),u.animate(c,n.duration,m.set.pushed)},add:{bodyCSS:function(a,b){var c;a!==o.bottom&&(c='"),v.append(c),m.debug("Adding body css to head",w)}},remove:{bodyCSS:function(){m.debug("Removing body css styles",w),m.refresh(),w.remove()},active:function(){t.removeClass(o.active)},pushed:function(){m.verbose("Removing body push state",m.get.direction()),u.removeClass(o[m.get.direction()]).removeClass(o.pushed)}},set:{active:function(){t.addClass(o.active)},pushed:function(){m.verbose("Adding body push state",m.get.direction()),u.addClass(o[m.get.direction()]).addClass(o.pushed)}},get:{direction:function(){return t.hasClass(o.top)?o.top:t.hasClass(o.right)?o.right:t.hasClass(o.bottom)?o.bottom:o.left},transitionEvent:function(){var a,b=c.createElement("element"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(a in e)if(b.style[a]!==d)return e[a]}},is:{open:function(){return t.is(":animated")||t.hasClass(o.active)},closed:function(){return!m.is.open()},vertical:function(){return t.hasClass(o.top)}},setting:function(b,c){return c===d?n[b]:(a.isPlainObject(b)?a.extend(!0,n,b):n[b]=c,void 0)},internal:function(b,c){return c===d?m[b]:(a.isPlainObject(b)?a.extend(!0,m,b):m[b]=c,void 0)},debug:function(){n.debug&&(n.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,n.name+":"),m.debug.apply(console,arguments)))},verbose:function(){n.verbose&&n.debug&&(n.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,n.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,n.name+":"),m.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;n.performance&&(b=(new Date).getTime(),d=h||b,c=b-d,h=b,i.push({Element:x,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,100)},display:function(){var b=n.name+":",c=0;h=!1,clearTimeout(m.performance.timer),a.each(i,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",g&&(b+=" '"+g+"'"),f.size()>1&&(b+=" ("+f.size()+")"),(console.group!==d||console.table!==d)&&i.length>0&&(console.groupCollapsed(b),console.table?console.table(i):a.each(i,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),i=[]}},invoke:function(b,c,f){var g,h,i;return c=c||l,f=x||f,"string"==typeof b&&y!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(c,e){var f=c!=g?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(y[e])&&c!=g)y=y[e];else{if(!a.isPlainObject(y[f])||c==g)return y[e]!==d?(h=y[e],!1):y[f]!==d?(h=y[f],!1):(m.error(q.method),!1);y=y[f]}})),a.isFunction(h)?i=h.apply(f,c):h!==d&&(i=h),a.isArray(e)?e.push(i):"string"==typeof e?e=[e,i]:i!==d&&(e=i),h}},k?(y===d&&m.initialize(),m.invoke(j)):(y!==d&&m.destroy(),m.initialize())}),e!==d?e:this},a.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",verbose:!0,debug:!0,performance:!0,useCSS:!0,overlay:!1,duration:300,side:"left",onChange:function(){},onShow:function(){},onHide:function(){},className:{active:"active",pushed:"pushed",top:"top",left:"left",right:"right",bottom:"bottom"},error:{method:"The method you called is not defined.",notFound:"There were no elements that matched the specified selector"}}}(jQuery,window,document);