!function(a,b,c,d){a.fn.chatroom=function(b){return a(this).each(function(){var c,e,f,g,h,i,j,k=a.extend(!0,{},a.fn.chatroom.settings,b),l=k.className,m=k.namespace,n=k.selector,o=k.error,p=a(this),q=p.find(n.expandButton),r=p.find(n.userListButton),s=p.find(n.userList),t=(p.find(n.room),p.find(n.userCount)),u=p.find(n.log),v=(p.find(n.message),p.find(n.messageInput)),w=p.find(n.messageButton),x=p.data("module"),y="",z={};j={width:{log:u.width(),userList:s.outerWidth()},initialize:function(){return Pusher===d&&j.error(o.pusher),k.key===d||k.channelName===d?(j.error(o.key),!1):k.endpoint.message||k.endpoint.authentication?(i=new Pusher(k.key),Pusher.channel_auth_endpoint=k.endpoint.authentication,c=i.subscribe(k.channelName),c.bind("pusher:subscription_succeeded",j.user.list.create),c.bind("pusher:subscription_error",j.error),c.bind("pusher:member_added",j.user.joined),c.bind("pusher:member_removed",j.user.left),c.bind("update_messages",j.message.receive),a.each(k.customEvents,function(a,b){c.bind(a,b)}),r.on("click."+m,j.event.toggleUserList),q.on("click."+m,j.event.toggleExpand),v.on("keydown."+m,j.event.input.keydown).on("keyup."+m,j.event.input.keyup),w.on("mouseenter."+m,j.event.hover).on("mouseleave."+m,j.event.hover).on("click."+m,j.event.submit),u.animate({scrollTop:u.prop("scrollHeight")},400),p.data("module",j).addClass(l.loading),void 0):(j.error(o.endpoint),!1)},refresh:function(){r.removeClass(l.active),j.width={log:u.width(),userList:s.outerWidth()},r.hasClass(l.active)&&j.user.list.hide(),p.data("module",j)},user:{updateCount:function(){k.userCount&&(z=p.data("users"),g=0,a.each(z,function(){g++}),t.html(k.templates.userCount(g)))},joined:function(b){z=p.data("users"),"anonymous"!=b.id&&z[b.id]===d&&(z[b.id]=b.info,k.randomColor&&b.info.color===d&&(b.info.color=k.templates.color(b.id)),y=k.templates.userList(b.info),b.info.isAdmin?a(y).prependTo(s):a(y).appendTo(s),k.partingMessages&&(u.append(k.templates.joined(b.info)),j.message.scroll.test()),j.user.updateCount())},left:function(a){z=p.data("users"),a!==d&&"anonymous"!==a.id&&(delete z[a.id],p.data("users",z),s.find("[data-id="+a.id+"]").remove(),k.partingMessages&&(u.append(k.templates.left(a.info)),j.message.scroll.test()),j.user.updateCount())},list:{create:function(b){z={},b.each(function(a){"anonymous"!==a.id&&"undefined"!==a.id&&(k.randomColor&&a.info.color===d&&(a.info.color=k.templates.color(a.id)),y=a.info.isAdmin?k.templates.userList(a.info)+y:y+k.templates.userList(a.info),z[a.id]=a.info)}),p.data("users",z).data("user",z[b.me.id]).removeClass(l.loading),s.html(y),j.user.updateCount(),a.proxy(k.onJoin,s.children())()},show:function(){u.animate({width:j.width.log-j.width.userList},{duration:k.speed,easing:k.easing,complete:j.message.scroll.move})},hide:function(){u.stop().animate({width:j.width.log},{duration:k.speed,easing:k.easing,complete:j.message.scroll.move})}}},message:{scroll:{test:function(){h=u.prop("scrollHeight")-u.height(),Math.abs(u.scrollTop()-h)0&&(console.groupCollapsed(b),console.table?console.table(performance):a.each(performance,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),performance=[]}},invoke:function(b,c,e){var f,g;return c=c||queryArguments,e=element||e,"string"==typeof b&&x!==d&&(b=b.split(/[\. ]/),f=b.length-1,a.each(b,function(b,c){a.isPlainObject(x[c])&&b!=f?x=x[c]:x[c]!==d?g=x[c]:j.error(o.method)})),a.isFunction(g)?g.apply(e,c):g||!1}},methodInvoked?(x===d&&j.initialize(),j.invoke(query)):(x!==d&&j.destroy(),j.initialize())}),returnedValue?returnedValue:this},a.fn.chatroom.settings={name:"Chat",debug:!1,namespace:"chat",channel:"present-chat",onJoin:function(){},onMessage:function(){},onExpand:function(){},onContract:function(){},customEvents:{},partingMessages:!1,userCount:!0,randomColor:!0,speed:300,easing:"easeOutQuint",scrollArea:9999,endpoint:{message:!1,authentication:!1},error:{method:"The method you called is not defined",endpoint:"Please define a message and authentication endpoint.",key:"You must specify a pusher key and channel.",pusher:"You must include the Pusher library."},className:{expand:"expand",active:"active",hover:"hover",down:"down",loading:"loading"},selector:{userCount:".actions .message",userListButton:".actions .list.button",expandButton:".actions .expand.button",room:".room",userList:".room .list",log:".room .log",message:".room .log .message",author:".room log .message .author",messageInput:".talk input",messageButton:".talk .send.button"},templates:{userCount:function(a){return a+" users in chat"},color:function(){var a=["#000000","#333333","#666666","#999999","#CC9999","#CC6666","#CC3333","#993333","#663333","#CC6633","#CC9966","#CC9933","#999966","#CCCC66","#99CC66","#669933","#669966","#33A3CC","#336633","#33CCCC","#339999","#336666","#336699","#6666CC","#9966CC","#333399","#663366","#996699","#993366","#CC6699"];return a[Math.floor(Math.random()*a.length)]},message:function(a){var b="";return a.user.isAdmin?(a.user.color="#55356A",b+='
',b+=''):b+='
',b+="

",b+=a.user.color!==d?''+a.user.name+": ":''+a.user.name+": ",b+=""+a.text+"

"+"
"},joined:function(a){return typeof a.name!==d?'
'+a.name+" has joined the chat.
":!1},left:function(a){return typeof a.name!==d?'
'+a.name+" has left the chat.
":!1},userList:function(a){var b="";return a.isAdmin&&(a.color="#55356A"),b+='
'+'
'+' '+"
",b+=a.color!==d?'

'+a.name+"

":'

'+a.name+"

",b+="
"}}}}(jQuery,window,document);