!function(a,b,c,d){a.fn.dropdown=function(b){var e,f=a(this),g=a(c),h=a.isPlainObject(b)?a.extend(!0,{},a.fn.dropdown.settings,b):a.fn.dropdown.settings,i="."+h.namespace,j="module-"+h.namespace,k=f.selector||"",l=(new Date).getTime(),m=[],n=arguments[0],o="string"==typeof n,p=[].slice.call(arguments,1);return f.each(function(){var b,q=a(this),r=a(this).find(h.selector.menu),s=a(this).find(h.selector.item),t=a(this).find(h.selector.text),u=a(this).find(h.selector.input),v="ontouchstart"in c.documentElement,w=this,x=q.data(j),y=h.className,z=h.metadata,A=h.namespace,B=h.animation,C=h.errors;b={initialize:function(){b.debug("Initializing dropdown with bound events",q),v?q.on("touchstart"+i,b.event.test.toggle):"click"==h.on?q.on("click"+i,b.event.test.toggle):"hover"==h.on?q.on("mouseenter"+i,b.delay.show).on("mouseleave"+i,b.delay.hide):q.on(h.on+i,b.toggle),"form"==h.action&&b.set.selected(),s.on(b.get.selectEvent()+i,b.event.item.click),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),q.data(j,b)},destroy:function(){b.verbose("Destroying previous module for",q),q.off(A).removeData(j)},event:{stopPropagation:function(a){a.stopPropagation()},test:{toggle:function(a){b.intent.test(a,b.toggle),a.stopPropagation()},hide:function(a){b.intent.test(a,b.hide),a.stopPropagation()}},item:{click:function(c){var d=a(this),e=d.data(z.text)||d.text(),f=d.data(z.value)||e;b.verbose("Adding active state to selected item"),s.removeClass(y.active),d.addClass(y.active),b.action.determine(e,f),a.proxy(h.onChange,q.get())(f,e),c.stopPropagation()}},resetStyle:function(){a(this).removeAttr("style")}},intent:{test:function(c,d){b.debug("Determining whether event occurred in dropdown",c.target),d=d||function(){},0===a(c.target).closest(r).size()?(b.verbose("Triggering event",d),d()):b.verbose("Event occurred in dropdown, canceling callback")},bind:function(){b.verbose("Binding hide intent event to document"),g.on(b.get.selectEvent(),b.event.test.hide)},unbind:function(){b.verbose("Removing hide intent event from document"),g.off(b.get.selectEvent())}},action:{determine:function(c,d){a.isFunction(b.action[h.action])?(b.verbose("Triggering preset action",h.action),b.action[h.action](c,d)):a.isFunction(h.action)?(b.verbose("Triggering user action",h.action),h.action(c,d)):b.error(C.action)},none:function(){},hide:function(){b.hide()},changeText:function(a){b.set.text(a),b.hide()},form:function(a,c){b.set.text(a),b.set.value(c),b.hide()}},get:{selectEvent:function(){return v?"touchstart":"click"},text:function(){return t.text()},value:function(){return u.val()},item:function(b){var c;return b=b||u.val(),s.each(function(){a(this).data(z.value)==b&&(c=a(this))}),c||!1}},set:{text:function(a){b.debug("Changing text",a,t),t.removeClass(y.placeholder),t.text(a)},value:function(a){b.debug("Adding selected value to hidden input",a,u),u.val(a)},selected:function(a){var c,d=b.get.item(a);d&&(b.debug("Setting selected menu item to",d),c=d.data(z.text)||d.text(),s.removeClass(y.active),d.addClass(y.active),b.set.text(c))}},is:{visible:function(){return r.is(":visible")},hidden:function(){return r.is(":not(:visible)")}},can:{click:function(){return v||"click"==h.on},show:function(){return!q.hasClass(y.disabled)}},animate:{show:function(){b.verbose("Doing menu showing animation"),"none"==B.show?r.show():"fade"==B.show?r.hide().clearQueue().fadeIn(150,b.event.resetStyle):"slide"==B.show?r.hide().clearQueue().children().clearQueue().css("opacity",0).delay(50).animate({opacity:1},200,"easeOutQuad",b.event.resetStyle).end().slideDown(100,"easeOutQuad",b.event.resetStyle):b.error(C.animation)},hide:function(){b.verbose("Doing menu hiding animation"),"none"==B.hide?r.hide():"fade"==B.hide?r.show().clearQueue().fadeOut(150,b.event.resetStyle):"slide"==B.hide?r.show().clearQueue().children().clearQueue().css("opacity",1).animate({opacity:0},100,"easeOutQuad",b.event.resetStyle).end().delay(50).slideUp(100,"easeOutQuad",b.event.resetStyle):b.error(C.animation)}},show:function(){b.debug("Checking if dropdown can show"),b.is.visible()||(b.hideOthers(),q.addClass(y.visible),b.animate.show(),b.can.click()&&b.intent.bind(),a.proxy(h.onShow,q.get())())},hide:function(){b.is.hidden()||(b.debug("Hiding dropdown"),q.removeClass(y.visible),b.can.click()&&b.intent.unbind(),b.animate.hide(),a.proxy(h.onHide,q.get())())},delay:{show:function(){b.verbose("Delaying show event to ensure user intent"),clearTimeout(b.graceTimer),b.graceTimer=setTimeout(b.show,h.delay.show)},hide:function(){b.verbose("Delaying hide event to ensure user intent"),clearTimeout(b.graceTimer),b.graceTimer=setTimeout(b.hide,h.delay.hide)}},hideOthers:function(){b.verbose("Finding other dropdowns to hide"),f.not(q).has(h.selector.menu+":visible").dropdown("hide")},toggle:function(){b.verbose("Toggling menu visibility"),b.is.hidden()?b.show():b.hide()},setting:function(b,c){return c===d?h[b]:(a.isPlainObject(b)?a.extend(!0,h,b):h[b]=c,void 0)},internal:function(c,e){return e===d?b[c]:(a.isPlainObject(c)?a.extend(!0,b,c):b[c]=e,void 0)},debug:function(){h.debug&&(h.performance?b.performance.log(arguments):b.debug=Function.prototype.bind.call(console.info,console,h.moduleName+":"))},verbose:function(){h.verbose&&h.debug&&(h.performance?b.performance.log(arguments):b.verbose=Function.prototype.bind.call(console.info,console,h.moduleName+":"))},error:function(){b.error=Function.prototype.bind.call(console.log,console,h.moduleName+":")},performance:{log:function(a){var c,d,e;h.performance&&(c=(new Date).getTime(),e=l||c,d=c-e,l=c,m.push({Element:w,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":d})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,100)},display:function(){var b=h.moduleName+":",c=0;l=!1,a.each(m,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",k&&(b+=" '"+k+"'"),(console.group!==d||console.table!==d)&&m.length>0&&(console.groupCollapsed(b),console.table?console.table(m):a.each(m,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),m=[]}},invoke:function(c,e,f){var g,h;return e=e||p,f=w||f,"string"==typeof c&&x!==d&&(c=c.split(/[\. ]/),g=c.length-1,a.each(c,function(c,e){a.isPlainObject(x[e])&&c!=g?x=x[e]:x[e]!==d?h=x[e]:b.error(C.method)})),a.isFunction(h)?h.apply(f,e):h||!1}},o?(x===d&&b.initialize(),e=b.invoke(n)):(x!==d&&b.destroy(),b.initialize())}),e?e:this},a.fn.dropdown.settings={moduleName:"Dropdown",namespace:"dropdown",verbose:!0,debug:!0,performance:!0,on:"click",action:"hide",delay:{show:50,hide:300},animation:{show:"slide",hide:"slide"},onChange:function(){},onShow:function(){},onHide:function(){},errors:{action:"You called a dropdown action that was not defined",method:"The method you called is not defined.",animation:"The requested animation was not found"},metadata:{text:"text",value:"value"},selector:{menu:".menu",item:".menu > .item",text:"> .text",input:'> input[type="hidden"]'},className:{active:"active",placeholder:"default",disabled:"disabled",visible:"visible"}}}(jQuery,window,document);