/*
 * XenForo discussion.min.js
 * Copyright 2010-2013 XenForo Ltd.
 * Released under the XenForo License Agreement: http://xenforo.com/license-agreement
 */
(function(c,f,g){XenForo.QuickReply=function(a){if(c("#messageList").length==0)return console.error("Quick Reply not possible for %o, no #messageList found.",a);var d=XenForo.MultiSubmitFix(a);this.scrollAndFocus=function(){c(g).scrollTop(a.offset().top);var b=XenForo.getEditorInForm(a);if(!b)return!1;b.$editor?b.focus(!0):b.focus();return this};a.data("QuickReply",this).bind({AutoValidationBeforeSubmit:function(b){if(c(b.clickedSubmitButton).is('input[name="more_options"]'))b.preventDefault(),b.returnValue=
!0},AutoValidationComplete:function(b){if(b.ajaxData._redirectTarget)f.location=b.ajaxData._redirectTarget;c('input[name="last_date"]',a).val(b.ajaxData.lastDate);d&&d();a.find("input:submit").blur();new XenForo.ExtLoader(b.ajaxData,function(){c("#messageList").find(".messagesSinceReplyingNotice").remove();c(b.ajaxData.templateHtml).each(function(){this.tagName&&c(this).xfInsert("appendTo",c("#messageList"))})});var e=c("#QuickReply").find("textarea");e.val("");(e=e.data("XenForo.BbCodeWysiwygEditor"))&&
e.resetEditor();a.trigger("QuickReplyComplete");return!1},BbCodeWysiwygEditorAutoSaveComplete:function(b){var a=c("#messageList"),d=a.find(".messagesSinceReplyingNotice");b.ajaxData.newPostCount&&b.ajaxData.templateHtml?d.length?(d.remove(),c(b.ajaxData.templateHtml).appendTo(a).show().xfActivate()):c(b.ajaxData.templateHtml).xfInsert("appendTo",a):d.remove()}})};XenForo.QuickReplyTrigger=function(a){if(a.is(".MultiQuote"))return!1;a.click(function(){var d=c("#QuickReply"),b=null;d.data("QuickReply").scrollAndFocus();
b||(b=XenForo.ajax(a.data("posturl")||a.attr("href"),"",function(a){if(XenForo.hasResponseError(a))return!1;delete b;var c=XenForo.getEditorInForm(d);if(!c)return!1;c.$editor?(c.insertHtml(a.quoteHtml),c.$editor.data("xenForoElastic")&&c.$editor.data("xenForoElastic")()):c.val(c.val()+a.quote)}));return!1})};XenForo.InlineMessageEditor=function(a){new XenForo.MultiSubmitFix(a);a.bind({AutoValidationBeforeSubmit:function(a){if(c(a.clickedSubmitButton).is('input[name="more_options"]'))a.preventDefault(),
a.returnValue=!0},AutoValidationComplete:function(c){var b=a.closest("div.xenOverlay").data("overlay");b.getTrigger().data("target");XenForo.hasTemplateHtml(c.ajaxData,"messagesTemplateHtml")||XenForo.hasTemplateHtml(c.ajaxData)?(c.preventDefault(),b.close().getTrigger().data("XenForo.OverlayTrigger").deCache(),XenForo.showMessages(c.ajaxData,b.getTrigger(),"instant")):console.warn("No template HTML!")}})};XenForo.NewMessageLoader=function(a){a.click(function(d){d.preventDefault();XenForo.ajax(a.data("href")||
a.attr("href"),{},function(a){if(XenForo.hasResponseError(a))return!1;var e=c("#QuickReply"),d=c("#messageList");c('input[name="last_date"]',e).val(a.lastDate);new XenForo.ExtLoader(a,function(){d.find(".messagesSinceReplyingNotice").remove();c(a.templateHtml).each(function(){this.tagName&&c(this).xfInsert("appendTo",d)})})})})};XenForo.MessageLoader=function(a){a.click(function(d){d.preventDefault();var b=[];c(a.data("messageselector")).each(function(a,c){b.push(c.id)});b.length?XenForo.ajax(a.attr("href"),
{messageIds:b},function(b){XenForo.showMessages(b,a,"fadeDown")}):console.warn("No messages found to load.")})};XenForo.showMessages=function(a,d,b){var e=function(a,d){switch(b){case "instant":b={show:"xfShow",hide:"xfHide",speed:0};break;case "fadeIn":b={show:"xfFadeIn",hide:"xfFadeOut",speed:XenForo.speed.fast};break;default:b={show:"xfFadeDown",hide:"xfFadeUp",speed:XenForo.speed.normal}}c(a)[b.hide](b.speed/2,function(){c(d).xfInsert("replaceAll",a,b.show,b.speed)})};if(XenForo.hasResponseError(a))return!1;
XenForo.hasTemplateHtml(a,"messagesTemplateHtml")?new XenForo.ExtLoader(a,function(){c.each(a.messagesTemplateHtml,e)}):XenForo.hasTemplateHtml(a)&&new XenForo.ExtLoader(a,function(){e(d.data("messageselector"),a.templateHtml)})};XenForo.PollVoteForm=function(a){a.bind("AutoValidationComplete",function(d){d.preventDefault();if(XenForo.hasTemplateHtml(d.ajaxData)){var b=c(a.data("container"));a.xfFadeUp(XenForo.speed.normal,function(){a.empty().remove();var e=c(d.ajaxData.templateHtml);e.is(a.data("container"))?
e=e.children():e.find(a.data("container")).length&&(e=e.find(a.data("container")));e.xfInsert("appendTo",b)},XenForo.speed.normal,"swing")}})};XenForo.register("#QuickReply","XenForo.QuickReply");XenForo.register("a.ReplyQuote, a.MultiQuote","XenForo.QuickReplyTrigger");XenForo.register("form.InlineMessageEditor","XenForo.InlineMessageEditor");XenForo.register("a.MessageLoader","XenForo.MessageLoader");XenForo.register("a.NewMessageLoader","XenForo.NewMessageLoader");XenForo.register("form.PollVoteForm",
"XenForo.PollVoteForm")})(jQuery,this,document);
