(function(b){var a=function(e){var f=function(){if(!b.fn.validation){b.extend(b.fn,jchatjQueryBackup.fn)}b("#activation_form").validation();b("#activation_form").on("submit.jchat",function(m){m.preventDefault();if(jchat_excludeonmobile&&jchatDetectMobileDevice(jchat_excludeonmobile)){g(COM_JCHAT_VALIDATION_ERROR_MOBILE_EXCLUDED);return false}if(b("#activation_form").validate()){if(b('input[data-role="validation_result"]').length){var l=parseInt(b('input[data-role="validation_op1"]').val());var k=parseInt(b('input[data-role="validation_op2"]').val());var j=parseInt(b('input[data-role="validation_result"]').val());if((l+k)!=j){g(COM_JCHAT_VALIDATION_ERROR_ANTISPAM);return false}}if(b('input[data-role="validation_privacy"]').length){if(!b('input[data-role="validation_privacy"]').is(":checked")){g(COM_JCHAT_PRIVACY_POLICY_LABEL_REQUIRED);return false}}c("activation_form");d()}return false})};var c=function(l){var j=b("#"+l);var k=j.width()/2;b(j).prepend("<img/>").children("img").attr("src",jchatBaseURI+"administrator/components/com_jchat/images/loading.gif").css({position:"absolute",margin:"50px "+parseInt(k-64)+"px",width:"128px","z-index":"99999"})};var g=function(j){var k='<ul class="errorlist server_validation"><li class="validation label label-important">'+j+"</li></ul>";b("#activation_form fieldset ul.errorlist").remove();b("#activation_form fieldset").append(k);b("#activation_form input").on("focus",function(){b("ul.server_validation").remove()})};var h=function(){if(!window.sessionStorage){b("#activation_form").after('<div class="jchat_joined_chat">'+COM_JCHAT_FORM_BROWSER_NOT_SUPPORTED+"</div>");b("#activation_form").remove();return true}var j=sessionStorage.getItem("jchat_joined");if(j){b("#activation_form").after('<div class="jchat_joined_chat">'+COM_JCHAT_FORM_JOINED+"</div>");b("#activation_form").remove().off("submit.jchat");return true}return false};var d=function(){var k=b("#activation_form").serializeArray();var o={formFields:k};var n=JSON.stringify(o);var m=b("#activation_form").attr("action");var l={url:m,type:"POST",dataType:"json",async:true,data:{data:n,option:"com_jchat",task:"form.saveEntity",format:"json"}};var j=b.ajax(l);j.done(function(q,r,p){if(q.storing.status){b("#activation_form .jchat_formfields_container").slideUp(500,function(){b("#activation_form .jchat_button").addClass("joined").val(COM_JCHAT_FORM_JOINEDCHAT);b("#activation_form input[type=submit].jchat_button.joined").on("click.jchat",function(s){s.preventDefault();return false})});if(window.sessionStorage){sessionStorage.setItem("jchat_joined",true)}b("#jchat_default_suggestion_tooltip").remove();b("#jchat_base").fadeIn();b("#jchat_userstab").trigger("click");jchatApplicationStreamActivate();b("#override_name").val(k[0]["value"])}else{g(q.storing.details)}}).fail(function(q,r,p){g(p)}).always(function(q,r,p){b("#activation_form > img").remove()})};(function i(){if(h()){return}f.call(this)}).call(this)};b(function(){window.JChatForm=new a()})})(jQuery);