var previewActive=false;function kPreviewHelper(a){if(jQuery("#editor").val()!=null){jQuery.ajax({type:"POST",url:jQuery("#kpreview_url").val(),async:false,dataType:"json",data:{body:jQuery("#editor").val()},success:function(b){jQuery("#kbbcode-preview").html(b.preview);}});}}jQuery(document).ready(function(c){c("#tabs_kunena_editor a:first").tab("show");c("#tabs_kunena_editor a:last").click(function(i){i.preventDefault();var h=c("#kbbcode-preview");var g=c("#editor");h.css("display","block");g.hide();kPreviewHelper();h.attr("class","kbbcode-preview-bottom controls");var f=g.css("height");h.css("height",g.css("height"));});c("#tabs_kunena_editor a:not(:last)").click(function(f){c("#kbbcode-preview").hide();c("#editor").css("display","inline-block");c("#markItUpeditor").css("display","inline-block");});c("#tabs_kunena_editor a:last").click(function(f){c("#editor").hide();c("#markItUpeditor").hide();});if(c("#kemojis_allowed").val()==1){var b="";if(c("#editor").length>0&&c(".qreply").length==0){b="#editor";}else{if(c(".qreply").length>0){b=".qreply";}}if(c("#wysibb-body").length>0){b="#wysibb-body";}if(b!=undefined){c(b).atwho({at:":",displayTpl:"<li data-value='${key}'>${name} <img src='${url}' height='20' width='20' /></li>",insertTpl:"${name}",callbacks:{remoteFilter:function(e,f){if(e.length>0){c.ajax({url:c("#kurl_emojis").val(),data:{search:e},success:function(g){f(g.emojis);}});}}}});}}if(b!=undefined){var d=c("#kurl_users").val();c(b).atwho({at:"@",data:d,limit:5});}if(c.fn.sisyphus!=undefined){c("#postform").sisyphus({locationBased:true,timeout:5});}c("#kshow_attach_form").click(function(){if(c("#kattach_form").is(":visible")){c("#kattach_form").hide();}else{c("#kattach_form").show();}});c("#form_submit_button").click(function(){c("#subject").attr("required","required");c("#editor").attr("required","required");});var a;c("#postcatid").change(function(){var f=c("select#postcatid option").filter(":selected").val();var g=c("#kurl_topicons_request").val();if(c("#kanynomous-check").length>0){var e=jQuery.parseJSON(Joomla.getOptions("com_kunena.arrayanynomousbox"));if(e[f]!==undefined){c("#kanynomous-check").show();c("#kanonymous").prop("checked",true);}else{c("#kanynomous-check").hide();c("#kanonymous").prop("checked",false);}}c.ajax({type:"POST",url:g,async:false,dataType:"json",data:{catid:f},success:function(i){c("#iconset_topic_list").remove();var h=c("<div>",{id:"iconset_topic_list"});c("#iconset_inject").append(h);c.each(i,function(l,m){if(m.type!="system"){if(m.id==0){var j=c("<input>",{type:"radio",id:"radio"+m.id,name:"topic_emoticon",value:m.id}).prop("checked",true);}else{var j=c("<input>",{type:"radio",id:"radio"+m.id,name:"topic_emoticon",value:m.id});}var n=c("<span>",{"class":"kiconsel"}).append(j);if(Joomla.getOptions("com_kunena.kunena_topicicontype")=="B2"){var k=c("<label>",{"class":"radio inline","for":"radio"+m.id}).append(c("<span>",{"class":"icon icon-topic icon-"+m.b2,border:"0",al:""}));}else{if(Joomla.getOptions("com_kunena.kunena_topicicontype")=="fa"){var k=c("<label>",{"class":"radio inline","for":"radio"+m.id}).append(c("<i>",{"class":"fa glyphicon-topic fa-2x fa-"+m.fa,border:"0",al:""}));}else{var k=c("<label>",{"class":"radio inline","for":"radio"+m.id}).append(c("<img>",{src:m.path,border:"0",al:""}));}}n.append(k);c("#iconset_topic_list").append(n);}});}});a=function(){var h=null;c.ajax({type:"POST",url:c("#kurl_category_template_text").val(),async:false,dataType:"json",data:{catid:f},success:function(i){if(c("#editor").val().length>1){if(c("#editor").val().length>1){c("#modal_confirm_template_category").modal("show");}else{c("#editor").val(a);}}else{if(i.length>1){c("#modal_confirm_template_category").modal("show");}else{c("#editor").val(i);}}h=i;}});return h;}();});c("#modal_confirm_erase").click(function(){c("#modal_confirm_template_category").modal("hide");var e=c("#editor").next();e.empty();c("#editor").val(a);});c("#modal_confirm_erase_keep_old").click(function(){c("#modal_confirm_template_category").modal("hide");var f=c("#editor").val();var e=c("#editor").next();e.empty();c("#editor").val(a+" "+f);});if(c.fn.datepicker!=undefined){c("#datepoll-container .input-append.date").datepicker({orientation:"top auto"});}if(document.getElementById("gotoeditor")!=undefined){document.getElementById("gotoeditor").addEventListener("click",function(){if(c(".qreply").length>0){var e=localStorage.setItem("copyKunenaeditor",c(".qreply").val());e;console.log(e);}},false);}});