/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.1.9 Patch Level 4
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2016 vBulletin Solutions Inc. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,["action","active","ad_list_description","add_modules","add_subforum","adding_multiple_modules_not_allowed","all","applying_new_template","are_you_sure_want_to_delete_ad_x","cancel","cannot_add_system_module","cannot_convert_channel","cannot_remove_system_module","channels","check_to_hide_module","choose_base_module","choose_options_site_logo","click_text_edit_title","confirm_deletion_gcpglobal","confirm_deletion_x","confirm_remove_page_desc","create_new_custom_module","delete","display_order","do_you_want_to_cancel_editing_search_module","do_you_want_to_exit_without_saving_page","do_you_want_to_remove_channel","do_you_want_to_remove_forum","do_you_want_to_remove_module","drag_and_drop_module_here","drop_page_here","dropping_container_module_into_container_module_not_allowed","edit","edit_blog_categories","edit_custom_html_module","edit_locationx_ad","edit_navigation_item","edit_search_module","edit_site_logo","error_adding_widgets","error_cloning_widget","error_deleting_page","error_deleting_page","error_fetching_channels","error_loading_search_config_script","error_processing_site_logo","error_processing_site_logo_image_hosting","error_renaming_module_title","error_retrieving_cloned_widget_template","error_retrieving_configuration","error_retrieving_list_user_groups","error_retrieving_modules","error_retrieving_navigation_bar_configuration","error_retrieving_page_map","error_retrieving_templates","error_saving_configuration_module","error_saving_forums","error_saving_forums_code","error_saving_navigation_bar_configuration","error_saving_page","error_saving_search_config","error_saving_search_config_code","error_saving_site_logo","error_saving_site_logo_code","error_uploading_logo","exit_without_saving_page","expand","forum_changes_will_be_lost","input_navigation_item_name","input_target_url","invalid_image_url","main_navigation_bar","make_category","make_forum","module_configuration","module_icon","move_not_allowed","moving_main_nav_to_own_sub_nav_error","moving_main_nav_with_sub_nav_error","my_custom_modules","new_navigation_item","new_subnavigation_item","next","no","no_ad_added","no_configurations_found","no_modules","no_permission","none","overwrite_template_continue","page_template_title_cannot_be_empty","page_title_cannot_be_empty","please_choose_overwrite_template_options","please_enter_channel_title","please_enter_new_module_title","please_enter_new_template_name","please_enter_page_name","previous","remove_channel","remove_channel_q","remove_forum","remove_forum_q","remove_module_q","rename","rename_custom_module","reset","save","save_new_page","save_page","search_results","select_edit_link_header","special_options","sub_navigation_bar","subchannels_will_be_deleted","switch_template","template_changes_will_be_lost","this_url_is_already_used","title","unable_to_delete_widget_instances","uncheck_to_unhide_module","url_too_long","user_group_settings","warning_gcpuser","yes","you_are_here","you_can_also_drag_and_drop_modules_here","you_must_specify_a_screen_layout"]);(function(g){var y,AC,AE,k=[],z,n,l,v=[],AI,m,o=false,Y=false,G={},R=false,c=false,V=false,d=false,X=false,S=false,AB=false,q=false,AF={},N={};function O(){var AS=g("#edit-page-dropdown .panel .panel-main-content:visible");if(AS.length>0){var AT=parseFloat(AS.css("margin-left"))+parseFloat(AS.css("margin-right"))+parseFloat(AS.css("border-left-width"))+parseFloat(AS.css("border-right-width"))+parseFloat(AS.css("padding-left"))+parseFloat(AS.css("padding-right"));g("#edit-page-dropdown .panel .panel-main-content").width(g("#edit-page-dropdown .panel:visible").width()-g("#edit-page-dropdown .panel .panel-header-text:visible").outerWidth(true)-AT-1);g("#edit-page-dropdown form .form-gutter-right").width(Math.ceil((g("#edit-page-dropdown form:visible").width()-g("#edit-page-dropdown .panel:visible").outerWidth(true))/2));if(k.length){var AQ=k[y.tabs("option","selected")];if(AQ){AQ.tinyscrollbar_update();var AR=g("#edit-content > .tabs > .ui-tabs-panel:not(.ui-tabs-hide)");var AM=AR.find("input:checked").closest(".list-item");if(AM.length>0&&!AR.find(".scrollbar").hasClass("disable")){var AL=AM.offset().left;var AP=AR.find(".scroller");var AU=AP.offset().left+parseInt(AM.css("margin-left"),10);var AN=AL-AU;var AO=AR.find(".overview").width()-AP.width();if(AN>AO){AN=AO}AQ.tinyscrollbar_update(AN)}}}}}function U(AM,AO){var AN=AM.find(".js-admin-widget-list"),AL=false;g.each(AO,function(){AN.append(this.rendered_template);AL=true});if(AL){AN.closest(".js-widget-content").removeClass("h-hide")}AN.closest(".js-widget-content").css({minHeight:"35px"});AN.css({minHeight:"0",height:"auto",paddingBottom:"10px"})}function B(AM,AN){var AL=g(".js-canvas-layout-container > .canvas-layout").attr("id");if(!vBulletin.sitebuilder.tempModuleHTMLCache){vBulletin.sitebuilder.tempModuleHTMLCache={};g(".js-canvas-layout-container .canvas-widget").each(function(){var AO=g(this).data("widget-instance-id");vBulletin.sitebuilder.tempModuleHTMLCache["widgetinstance_"+AO]=this.outerHTML})}g(".js-canvas-layout-container").text("");vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/get-layouts-for-sitebuilder",data:{pagetemplateid:pageData.pagetemplateid,channelid:pageData.channelid},success:function(AO){console.log("ajax/get-layouts-for-sitebuilder result:");console.dir(AO);var AP=g(".js-canvas-layout-container");AP.html(AO.screenlayoutlist);if(AO.widgets&&AO.widgets.length>0){var AQ=g("#"+AL);g.each(AO.widgets,function(AR,AS){var AT=AQ.find(".canvas-widget-list.section-"+AR);g.each(AS,function(AU,AW){AT.append(AW.rendered_template);if(typeof AW.subModules!="undefined"){var AV=AT.find(".canvas-widget").filter(function(){return g(this).data("widget-instance-id")==AW.widgetinstanceid});U(AV,AW.subModules)}})})}if(vBulletin.inlinemod&&vBulletin.inlinemod.initModMenuHover){vBulletin.inlinemod.initModMenuHover()}if(typeof AN=="function"){AN()}},title_phrase:"sitebuilder",error_phrase:"unable_to_load_layouts"})}function E(){if(!g(this).hasClass("selected")&&!g(document.body).hasClass("edit-mode")){g("#main-navbar .main-nav a").removeClass("selected").closest("li").addClass("h-disabled");g(this).addClass("selected").closest("li").removeClass("h-disabled");g(document.body).addClass("edit-mode "+this.id).removeClass("view-mode");g("#main-navbar ul.secondary-nav").addClass("h-disabled")}return false}function f(AN,AM){var AL=g("<div />").append(AN.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,'<span class="axd-placeholder">{0}'.format(vBulletin.phrase.get("x_will_show_up_here_when_saved",AM))).replace(/<vb\:/g,"&lt;vb:").replace(/<\/vb\:/g,"&lt;/vb:"));AL.find("span.axd-placeholder").not(":first").remove();AL.find("iframe").remove();return AL.html()}function e(){var AO=null;var AM=null;var Ab=null;var Ac="";var AY="";var AW="";var AR="";var Aa=function(Ad){if(!Ad){return false}if(Ad.match(/^https?:\/\//i)){return Ad}if(Ad.substr(0,1)=="/"){return pageData.baseurl+Ad}return pageData.baseurl+"/"+Ad};var AN=function(Aj,Af,Ag,Ai,Ad,Ae){Ad=Ad||[];console.log("createNavbarItem... Name: "+Af+" Url: "+Ag+" NewWindow: "+Ai+" UserGroups: "+Ad+" itemAttr: "+Ae);Af=JShtmlEncode(Af);var Ah=g("<li />").append("<label>{0}</label>".format(Af)).append(g("<div />").addClass("nav-item-controls h-right").append('<i>|</i><span class="navbar-item-delete" title="{0}"></span>'.format(vBulletin.phrase.get("delete"))).append('<i>|</i><span class="navbar-item-edit" title="{0}"></span>'.format(vBulletin.phrase.get("edit"))).append('<i>|</i><span class="navbar-item-opensubnav" title="{0}"></span>'.format(vBulletin.phrase.get("expand")))).data({"item-phrase":Aj,"item-name":Af,"item-url":Ag,"item-newwindow":Ai,"item-usergroups":Ad,"item-attr":Ae});return Ah};var AQ=function(Ad){return Ad.prevAll("li").size()};var AU=function(Af,Ah,Ai){return ;if(Ah=="add"){var Ak=Af.data("item-newwindow")?' target="_blank"':"";g("#channel-tabbar ul").append("<li><a"+Ak+' href="'+Aa(Af.data("item-url"))+'">'+Af.data("item-name")+"</a></li>")}else{if(Ah=="update"){var Ak=Af.data("item-newwindow")?' target="_blank"':"";var Al=AQ(Af);var Ag=g("#channel-tabbar ul li");Ag.eq(Al).replaceWith("<li><a"+Ak+' href="'+Aa(Af.data("item-url"))+'">'+Af.data("item-name")+"</a></li>")}else{if(Ah=="remove"){var Al=AQ(Af);var Ag=g("#channel-tabbar ul li");Ag.eq(Al).remove()}else{if(Ah=="move"){var Ag=g("#channel-tabbar ul li");var Ad=Ag.eq(Ai.from);Ad.remove();if(Ai.to>0){var Aj=(Ai.to>Ai.from)?(Ai.to):(Ai.to-1);var Ae=Ag.eq(Aj);Ad.insertAfter(Ae)}else{Ad.prependTo("#channel-tabbar ul")}}}}}};var AX=function(){console.log("generateNavbarDisplay");var Ad=(AR=="navbar")?g("#channel-tabbar ul"):g("#footer-tabbar ul.nav-list");var Ae=(AR=="navbar")?g("#channel-subtabbar ul"):g();Ad.html("");Ae.html("");g("#edit-navbar .navbar-ui-wrapper ul li").each(function(){var Ag=g(this);var Af=Ag.data("item-newwindow")?' target="_blank"':"";var Ah=Ag.hasClass("selected")&&AR!="footer"?' class="current"':"";Ad.append('<li{0}><a href="{1}"{2}>{3}</a></li>'.format(Ah,Aa(Ag.data("item-url")),Af,Ag.data("item-name")));if(Ag.hasClass("selected")){console.log(Ag.data("subnav-element"));g(Ag.data("subnav-element")).find("li").each(function(){var Aj=g(this);console.log(Aj.data("item-url"));var Ai=Aj.data("item-newwindow")?' target="_blank"':"";var Ak=Aj.hasClass("selected")?' class="current"':"";Ae.append('<li{0}><a href="{1}"{2}>{3}</a></li>'.format(Ak,Aa(Aj.data("item-url")),Ai,Aj.data("item-name")))})}})};var AP=function(Aj,Al,Ae,Af,Ah,Ak,Ag){var Ad=AN(Aj,Al,Ae,Af,Ah,Ag);console.log("insertNavbarItem... Name: "+Ad.data("item-name")+" Url: "+Ad.data("item-url")+" NewWindow: "+Ad.data("item-newwindow")+" UserGroups: "+Ad.data("item-usergroups")+" itemAttr: "+Ad.data("item-attr"));Ad.appendTo(AM);AU(Ad,"add");var Ai=g("<ul />").addClass("sub-navbar-list navbar-list sortable");g(Ak).each(function(){var As=this.phrase?this.phrase:"",An=this.title?this.title:"",Aq=this.url?this.url:"",Ar=this.newWindow?this.newWindow:false,Am=this.usergroups?this.usergroups:[],Ap=this.attr?this.attr:"";var Ao=AN(As,An,Aq,Ar,Am,Ap);Ao.appendTo(Ai)});(function(){var Am=null;Ai.sortable({start:function(An,Ao){Ao.placeholder.html(vBulletin.phrase.get("drop_page_here")).height(Ao.item.height()-2)},stop:function(An,Ao){AX()},receive:function(An,Ao){var Ap=Ao.item.data("subnav-element")||g();if(Ap.is(":visible")){Ao.sender.sortable("cancel");openAlertDialog({title:vBulletin.phrase.get("move_not_allowed"),message:vBulletin.phrase.get("moving_main_nav_to_own_sub_nav_error"),iconType:"warning"})}else{if(Ap.find("li").length>0){Ao.sender.sortable("cancel");openAlertDialog({title:vBulletin.phrase.get("move_not_allowed"),message:vBulletin.phrase.get("moving_main_nav_with_sub_nav_error"),iconType:"warning"})}}},connectWith:".sortable",placeholder:"sortable-highlight",forcePlaceholderSize:true}).disableSelection()})();Ai.hide();Ai.appendTo("#navbar-ui-container .subnavbar-list-container");Ad.data("subnav-element",Ai);AX()};var AT=function(Ae,Ag,Ah,Ai,Ad,Af){$newItem=AN(Ae.data("item-phrase"),Ag,Ah,Ai,Ad,Af);console.log("updateNavbarItem... Name: "+$newItem.data("item-name")+" Url: "+$newItem.data("item-url")+" NewWindow: "+$newItem.data("item-newwindow")+" itemAttr: "+$newItem.data("item-attr"));if(Ae.data("subnav-element")){$newItem.data("subnav-element",Ae.data("subnav-element"))}if(Ae.hasClass("selected")){$newItem.addClass("selected")}Ae.replaceWith($newItem);AX()};var AZ=function(Ad){AR=Ad;if(AR=="navbar"){Ac=g("#channel-tabbar ul").html();AY=g("#channel-subtabbar ul").html();AW=g("#channel-tabbar ul li.current a").attr("href");g("#channel-subtabbar.h-hide").toggleClass("h-hide default-hide")}else{Ac=g("#footer-tabbar ul.nav-list").html();AW=g("#footer-tabbar ul.nav-list li.current a").attr("href")}g("#admin-navbar-strip-gutter").removeClass().addClass("navbar-"+AR);g("#header").add("#header-axd").hide();g("#edit-navbar #navbar-ui-container .navbar-ui-wrapper").remove();g("#edit-navbar #navbar-ui-container .subnavbar-ui-wrapper").remove();g("#edit-navbar .panel-header-text").hide();g("#edit-navbar #panel-header-"+AR).show();g("#edit-navbar").slideDown("slow",function(){window.vBulletin.loadingIndicator.show();g("body").css("cursor","wait");var Ae=(AR=="navbar")?"loadHeaderNavbar":"loadFooterNavbar";g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/site/"+Ae,data:({siteId:1,edit:1}),type:"POST",dataType:"json",complete:function(){window.vBulletin.loadingIndicator.hide();g("body").css("cursor","auto")},success:function(Af){console.log(Ae+" successful! result:"+JSON.stringify(Af));var Ai=g("<ul />").addClass("main-navbar-list navbar-list sortable "+AR);var Ah=g("<div />").addClass("new-nav-item main-nav").html(vBulletin.phrase.get("new_navigation_item"));var Ag=g("<h4 />").text(vBulletin.phrase.get("main_navigation_bar"));g("<div />").addClass("navbar-ui-wrapper").append(Ag).append(Ai).append(Ah).appendTo("#navbar-ui-container");var Al=null;Ai.sortable({start:function(An,Ao){Ao.placeholder.html(vBulletin.phrase.get("drop_page_here")).height(Ao.item.height()-2)},stop:function(An,Ao){AX()},connectWith:".sortable",placeholder:"sortable-highlight",forcePlaceholderSize:true}).disableSelection();AM=Ai;var Am=g("<div />").addClass("subnavbar-list-container");var Ak=g("<div />").addClass("new-nav-item sub-nav").html(vBulletin.phrase.get("new_subnavigation_item"));var Aj=g("<h4 />").text(vBulletin.phrase.get("sub_navigation_bar"));g("<div />").addClass("subnavbar-ui-wrapper").append(Aj).append(Am).append(Ak).appendTo("#navbar-ui-container").hide();if(Af){console.log("result:",Af);g(Af).each(function(){var At=this.phrase?this.phrase:"",Ao=this.title?this.title:"",Ar=this.url?this.url:"",As=this.newWindow?true:false,An=this.usergroups?this.usergroups:[],Aq=this.subnav?this.subnav:[],Ap=this.attr?this.attr:"";AP(At,Ao,Ar,As,An,Aq,Ap)});console.log("Done adding items")}g("#edit-navbar .navbar-ui-wrapper ul li").first().find(".navbar-item-opensubnav").filter(":visible").click()},error:function(Ah,Ag,Af){console.log(Ae+" failed! error:"+Af);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_navigation_bar_configuration"),iconType:"error",onAfterClose:function(){g("#config-dialog").dialog("close")}});g("#config-dialog .loader").hide()}})})};g(document).on("click","#main-navbar .sb-menu:not(.h-disabled) #lnkNavBar",function(){var Ad=this;if(g("#edit-navbar").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",Ad,function(){E.apply(Ad);AZ("navbar")})}return false});g(document).on("click","#main-navbar .sb-menu:not(.h-disabled) #lnkFooter",function(){var Ad=this;if(g("#edit-navbar").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",Ad,function(){E.apply(Ad);AZ("footer")})}return false});var AL=function(Ad){g("#navbar-edit-item").dialog({autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:400,dialogClass:"dialog-container navbar-item-dialog-container",open:function(){g("#navbar-edit-name").focus()}}).dialog("option","title",Ad||vBulletin.phrase.get("edit_navigation_item")).dialog("open")};g("#edit-navbar").on("click",".new-nav-item",function(){AO=null;if(g(this).closest(".navbar-ui-wrapper").size()>0){AM=g(this).closest(".navbar-ui-wrapper").find("ul")}else{AM=g(this).closest(".subnavbar-ui-wrapper").find("ul").filter(":visible")}g("#navbar-edit-name").val("");g("#navbar-edit-url").val("");g("#navbar-edit-attr").val("");g("#navbar-edit-newwindow").prop("checked",false);AL(g(this).html());return false});g(document).on("click","#navbar-edit-save",function(){if(g("#navbar-edit-name").val()==""){openAlertDialog({title:vBulletin.phrase.get("edit_navigation_item"),message:vBulletin.phrase.get("input_navigation_item_name"),iconType:"warning",onAfterClose:function(){g("#navbar-edit-name").focus()}})}else{if(g("#navbar-edit-url").val()==""){openAlertDialog({title:vBulletin.phrase.get("edit_navigation_item"),message:vBulletin.phrase.get("input_target_url"),iconType:"warning",onAfterClose:function(){g("#navbar-edit-url").focus()}})}else{console.log("Saving new/edited navbar item");if(!AO){AP("",g("#navbar-edit-name").val(),g("#navbar-edit-url").val(),g("#navbar-edit-newwindow").prop("checked"),g("#navbar-edit-item").data("edit-usergroups"),[],g("#navbar-edit-attr").val())}else{AT(AO,g("#navbar-edit-name").val(),g("#navbar-edit-url").val(),g("#navbar-edit-newwindow").prop("checked"),g("#navbar-edit-item").data("edit-usergroups"),g("#navbar-edit-attr").val())}AO=null;AM=null;g("#navbar-edit-item").dialog("close");console.log("Done saving new/edited navbar item")}}return false});g(document).on("click","#navbar-edit-cancel",function(){g("#navbar-edit-item").dialog("close");return false});var AS=false;g(document).on("click","#navbar-edit-usergroups",function(){var Ae=function(){g("#navbar-edit-usergroups-dialog .dialog-body input[type=checkbox]").prop("checked",false);var Ah=g("#navbar-edit-usergroups-dialog .select_all");var Af=function(){if(g("#navbar-edit-usergroups-dialog .navbar-usergroup-checkbox:checked").length==g("#navbar-edit-usergroups-dialog .navbar-usergroup-checkbox").length&&g("#navbar-edit-usergroups-dialog .navbar-usergroup-checkbox").eq(0).is(":checked")){Ah.prop("checked",true)}else{Ah.prop("checked",false)}};g("#navbar-edit-usergroups-dialog .navbar-usergroup-checkbox").off("change").on("change",Af);Ah.off("change").on("change",function(){if(g(this).prop("checked")){g("#navbar-edit-usergroups-dialog .navbar-usergroup-checkbox").prop("checked",true)}else{g("#navbar-edit-usergroups-dialog .navbar-usergroup-checkbox").prop("checked",false)}});if(!AO){return false}console.log("Prefilling checked usergroups");console.log(AO.data("item-name"));console.log(AO.data("item-url"));console.log(AO.data("item-usergroups"));if(AO.data("item-usergroups-temp")){var Ag=AO.data("item-usergroups-temp")}else{var Ag=AO.data("item-usergroups")}console.log(Ag);g.each(Ag,function(Ai,Aj){g("#navbar-edit-usergroups-dialog .dialog-body #navbar-usergroup-checkbox-"+Aj).prop("checked",true)});Af()};var Ad=function(){var Af=[];g("#navbar-edit-usergroups-dialog .dialog-body input[type=checkbox]").each(function(){if(g(this).prop("checked")){Af.push(g(this).val())}});g("#navbar-edit-item").data("edit-usergroups",Af);if(AO){AO.data("item-usergroups-temp",Af)}console.log("Saving checked usergroups")};if(!AS){g("#navbar-edit-usergroups-dialog").dialog({title:vBulletin.phrase.get("user_group_settings"),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:500,dialogClass:"dialog-container pagemap-dialog-container input-dialog",create:function(){g("#navbar-edit-usergroups-dialog .cancel-button").on("click",function(){g("#navbar-edit-usergroups-dialog").dialog("close")});g("#navbar-edit-usergroups-dialog .save-button").on("click",function(){Ad();g("#navbar-edit-usergroups-dialog").dialog("close")});g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/usergroup/fetchUsergroupList",data:({siteId:1}),type:"POST",dataType:"json",complete:function(){g("body").css("cursor","auto")},success:function(Af){console.log("fetchUsergroupList successful! result:"+JSON.stringify(Af));if(Af){console.log("result:",Af);var Ag=[];g(Af).each(function(){Ag.push('<div class="blockrow"><label><input type="checkbox" class="navbar-usergroup-checkbox" id="navbar-usergroup-checkbox-{0}" value="{0}"><span>{1}</span></label></div>'.format(this.usergroupid,this.title))});g("#navbar-edit-usergroups-dialog .dialog-body").html(Ag.join(""));g("#navbar-edit-usergroups-dialog").dialog("option","position","center");console.log("Done adding usergroups")}Ae()},error:function(Ah,Ag,Af){console.log("fetchUsergroupList failed! error:"+Af);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_list_user_groups"),iconType:"error",onAfterClose:function(){g("#config-dialog").dialog("close")}});g("#config-dialog .loader").hide()}})},close:function(){},open:function(){Ae()}});AS=true}else{g("#navbar-edit-usergroups-dialog").dialog("open")}return false});g("#edit-navbar").on("click",".navbar-item-delete",function(){AU(g(this).closest("li"),"remove");g(this).closest("li").remove();AX();return false});g("#edit-navbar").on("click",".navbar-item-edit",function(){var Ad=g(this).closest("li");console.log("Click to edit item... Name: "+Ad.data("item-name")+" Url: "+Ad.data("item-url")+" NewWindow: "+Ad.data("item-newwindow")+" UserGroups: "+Ad.data("item-usergroups"));AO=Ad;AM=Ad.closest("ul");AO.data("item-usergroups-temp",null);g("#navbar-edit-name").val(Ad.data("item-name"));g("#navbar-edit-url").val(Ad.data("item-url"));g("#navbar-edit-attr").val(Ad.data("item-attr"));g("#navbar-edit-newwindow").prop("checked",Ad.data("item-newwindow"));AL(g(this).html());return false});g("#edit-navbar").on("click",".navbar-item-opensubnav",function(){var Ad=g(this).closest("li");console.log("Click to open item subnav ... Name: "+Ad.data("item-name")+" Url: "+Ad.data("item-url")+" NewWindow: "+Ad.data("item-newwindow")+" UserGroups: "+Ad.data("item-usergroups"));g("#edit-navbar li").removeClass("h-disabled selected");Ad.addClass("selected");g("#edit-navbar .subnavbar-ui-wrapper ul").hide();g(Ad.data("subnav-element")).show();g("#edit-navbar .subnavbar-ui-wrapper").show();AX();return false});g(document).on("click",".navbar-navbar #admin-navbar-strip .lnkExitWithoutSaving, .navbar-footer #admin-navbar-strip .lnkExitWithoutSaving",function(){g("#edit-navbar").slideUp();g("#header").add("#header-axd").show();if(AR=="navbar"){g("#channel-tabbar ul").html(Ac);g("#channel-subtabbar ul").html(AY).parent(".default-hide").toggleClass("h-hide default-hide")}else{g("#footer-tabbar ul.nav-list").html(Ac)}});var AV=function(){var Ad=[];g("#edit-navbar .navbar-ui-wrapper ul li").each(function(){var Ag=g(this);var Af=[];Ag.data("subnav-element").find("li").each(function(){$subLi=g(this);Af.push({phrase:$subLi.data("item-phrase"),title:$subLi.data("item-name"),url:$subLi.data("item-url"),newWindow:$subLi.data("item-newwindow"),usergroups:$subLi.data("item-usergroups"),attr:$subLi.data("item-attr")})});Ad.push({phrase:Ag.data("item-phrase"),title:Ag.data("item-name"),url:Ag.data("item-url"),newWindow:Ag.data("item-newwindow"),usergroups:Ag.data("item-usergroups"),subnav:Af,attr:Ag.data("item-attr")})});var Ae=(AR=="navbar")?"saveHeaderNavbar":"saveFooterNavbar";g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/site/"+Ae,data:({siteId:1,data:Ad}),type:"POST",dataType:"json",complete:function(){g("body").css("cursor","auto")},success:function(Ag){if(Ag.errors){console.log(Ae+" failed! error:"+JSON.stringify(Ag));openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_navigation_bar_configuration"),iconType:"error"});return }console.log(Ae+" successful! result:"+JSON.stringify(Ag));g("#edit-navbar").slideUp();g("#header").add("#header-axd").show();g("#main-navbar ul.main-nav li").removeClass("h-disabled").find("a").removeClass("selected");g("#admin-navbar-strip-gutter").addClass("h-hide");g(document.body).removeClass("edit-mode lnkEditPage lnkNewPage lnkHeader lnkNavBar lnkFooter").addClass("view-mode");g("#main-navbar ul.secondary-nav").removeClass("h-disabled");if(AR=="navbar"){var Af=false;g("#edit-navbar .navbar-ui-wrapper ul li").each(function(){var Ah=g(this);if(Aa(Ah.data("item-url"))==AW){Af=true;g("#edit-navbar .navbar-ui-wrapper ul li").removeClass("selected");Ah.addClass("selected");return false}});if(Af){AX()}else{g("#channel-tabbar ul li").removeClass("current");g("#channel-subtabbar ul").html("")}}else{g("#footer-tabbar ul.nav-list li").removeClass("current");g("#footer-tabbar ul.nav-list li").filter(function(){var Ah=g(this).find("a").attr("href");return(Ah==AW)}).addClass("current")}},error:function(Ah,Ag,Af){console.log(Ae+" failed! error:"+Af);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_navigation_bar_configuration"),iconType:"error",onAfterClose:function(){g("#config-dialog").dialog("close")}});g("#config-dialog .loader").hide()}})};g(document).on("click",".navbar-navbar #admin-navbar-strip .lnkSaveChanges",function(){AV()});g(document).on("click",".navbar-footer #admin-navbar-strip .lnkSaveChanges",function(){AV()})}function x(){bindFormReset("#edit-page-dropdown form").trigger("reset",function(){g("#save-content .template-name").addClass("h-hide");g("input[type=hidden]",this).each(function(){this.value=this.defaultValue})});g("#main-navbar .main-nav li").removeClass("h-disabled");g(document).on("focus click mousedown","#main-navbar li.h-disabled a, #main-navbar ul.secondary-nav.h-disabled li, #main-navbar ul.secondary-nav.h-disabled li a",function(AN){this.blur();AN.stopPropagation();return false});g(document).on("click","#sitebuilder-wrapper .lnkExitWithoutSaving",function(){if(g(this).closest("#edit-page-dropdown").length==0){g("#main-navbar ul.secondary-nav").removeClass("h-disabled")}});var AL=g("#main-navbar li.sb-menu:not(.h-disabled)");g(document).on("click","#main-navbar .sb-menu:not(.h-disabled) #lnkPageManager",function(){var AN=this;vBulletin.assertUserHasAdminPermission("canusesitebuilder",AN,function(){E.apply(AN);AH(false);g(".edit-mode .canvas-widget-list .canvas-widget").addClass("shadow");g("#header, #header-axd, #save-content").hide();g("#manage-page").show();g("#edit-page-dropdown .lnkDeletePage").removeClass("h-hide");g("#manage-page-dropdown").removeClass("h-hide").slideDown("slow",I)});return false});g(document).on("click","#main-navbar .sb-menu:not(.h-disabled) #lnkEditPage",function(){var AN=this;if(g("#edit-page-dropdown-gutter").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",AN,function(){function AO(){q=false;AP();a();AH(false,".container-widget");g(".edit-mode .canvas-widget-list .canvas-widget").addClass("shadow");y.tabs("select",0);g("#header, #header-axd, #save-content").hide();g("#edit-content").show();g("#edit-page-dropdown .lnkSaveChanges .label").text(vBulletin.phrase.get("save_page"));g("#edit-page-dropdown .lnkDeletePage").removeClass("h-hide");g("#edit-page-dropdown-gutter").removeClass("h-hide").slideDown("slow",T);g(".canvas-widget.axd-widget .widget-content").each(function(){g(this).html(f(g(this).html(),vBulletin.phrase.get("ad")))})}function AP(){var AQ=[];g(".hidden-widget-placeholder").each(function(){AQ.push(g(this).attr("data-widget-instance-id"))});if(AQ.length<1){return }g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/fetch-hidden-modules",data:({modules:AQ}),type:"POST",dataType:"json",complete:function(){console.log("fetch-hidden-modules complete.");AO()},success:function(AR){console.log("fetch-hidden-modules successful! result:"+JSON.stringify(AR));if(g.isArray(AR)){if(AR.length>0){g.each(AR,function(AS,AU){var AT=g(AU.template).addClass("hidden-widget");g('.hidden-widget-placeholder[data-widget-instance-id="'+AU.widgetinstanceid+'"]').replaceWith(AT)})}}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(AT,AS,AR){console.log("fetch-hidden-modules failed! error:"+AR);window.vBulletin.loadingIndicator.hide();openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_modules",AT.status),iconType:"error"})}})}E.apply(AN);B(false,AO)})}return false});g(document).on("click","#main-navbar .sb-menu:not(.h-disabled) #lnkNewPage",function(){var AN=this;if(g("#edit-page-dropdown-gutter").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",AN,function(){function AO(){q=true;g(".canvas-widget-list").empty();y.tabs("select",0);g("#change-layout .layout-border.selected").removeClass("selected");g("#layout-wide-narrow").prev().trigger("click");o=false;g("#header, #header-axd, #save-content").hide();g("#edit-content").show();g("#edit-page-dropdown .lnkSaveChanges .label").text(vBulletin.phrase.get("save_new_page"));g("#edit-page-dropdown .lnkDeletePage").addClass("h-hide");g("#edit-page-dropdown-gutter").removeClass("h-hide").slideDown("slow",T)}E.apply(AN);B(true,AO)})}return false});var AM=false;g(document).on("click","#main-navbar .sb-menu:not(.h-disabled) #lnkHeader",function(){var AN=this;if(g("#admin-navbar-strip-gutter").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",AN,function(){E.apply(AN);AM=false;g("#admin-navbar-strip-gutter").addClass("navbar-header").removeClass("h-hide").find(".prompt-text").text(vBulletin.phrase.get("select_edit_link_header"));var AO=g("#header"),AP=g(".header-cell",AO);$siteLogoEditStrip=g("> .admin-only",AP).addClass("h-hide-imp"),w=AP.outerWidth();g(".disable-overlay",AO).width(AO.innerWidth()-w).height(AO.innerHeight()).show();$siteLogoEditStrip.width(w-(parseInt($siteLogoEditStrip.css("padding-left"),10)+parseInt($siteLogoEditStrip.css("padding-right"),10))).removeClass("h-hide-imp");g(document).on("focus click mousedown",".edit-mode.lnkHeader #header .site-logo > a",function(AQ){this.blur();AQ.stopPropagation();return false})})}return false});e();g("#main-navbar .main-nav").removeClass("h-hide");g(document).on("click","#admin-navbar-strip .lnkSaveChanges",function(){});g(document).on("click",".lnkHeader #admin-navbar-strip .lnkSaveChanges",function(){g("body").css("cursor","wait");if(Number(g("#header .site-logo img").attr("data-fileid"))>0){var AN=AM?function(){location.reload(true)}:null;H(AN)}else{if(AM){location.reload(true)}else{g("body").css("cursor","auto");g("#main-navbar li").removeClass("h-disabled").find("a").removeClass("selected");g("#admin-navbar-strip-gutter").addClass("h-hide").find(".prompt-text").text("");g(document.body).removeClass("edit-mode lnkHeader").addClass("view-mode");g("#header .disable-overlay").hide();g("#main-navbar ul.secondary-nav").removeClass("h-disabled")}}});g(document).on("click",".lnkHeader #admin-navbar-strip .lnkExitWithoutSaving",function(AO){if(AM){AO.stopImmediatePropagation();location.reload(true);return false}else{var AN=g("#header .site-logo img");if(AN.attr("src")!=AN.attr("data-orig-src")){AN.attr("src",AN.attr("data-orig-src")).removeAttr("data-fileid")}g("#admin-navbar-strip-gutter").find(".prompt-text").text("");g("#header .disable-overlay").hide()}});g(document).on("click","#admin-navbar-strip .lnkExitWithoutSaving",function(){g("#main-navbar li").removeClass("h-disabled").find("a").removeClass("selected");g("#admin-navbar-strip-gutter").addClass("h-hide");g(document.body).removeClass("edit-mode lnkEditPage lnkNewPage lnkHeader lnkNavBar lnkFooter").addClass("view-mode");g("#header").add("#header-axd").show();g("#edit-navbar").hide()});g("#header-axd .axdnum").change(function(){var AN=g(this),AO=parseInt(AN.val());window.vBulletin.loadingIndicator.show();g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/ad/saveNumberOfHeaderAds",type:"POST",data:{number:AO},dataType:"json",success:function(AP){if(AP!==null&&typeof AP.errors!=="undefined"){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get(AP.errors[0]),iconType:"error"})}else{if(AO==1){g("#header-axd").removeClass("axdnum_2").addClass("axdnum_1")}else{g("#header-axd").removeClass("axdnum_1").addClass("axdnum_2")}}},complete:function(){window.vBulletin.loadingIndicator.hide()}})});g(document).off("click",".axd-edit-button").on("click",".axd-edit-button",function(){var AN=g(this).attr("data-location"),AS=g(this).closest(".axd-container");if(AS.length==0){AS=g('.axd-container[data-widget-instance-id="'+AN+'"]')}AR();function AR(AT){AT=AT||false;g("body").css("cursor","wait");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/ad/listAdsByLocation",type:"POST",data:{adlocation:AN},dataType:"json",cache:false,success:function(AU){if(AU!==null&&typeof AU.errors!=="undefined"){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get(AU.errors[0]),iconType:"error"})}else{if(AU){AO(AU)}else{if(!AT){AP({adlocation:AN})}else{AO([])}}}},complete:function(){g("body").css("cursor","default")}})}function AO(AT){if(typeof AF.axd_list_dialog=="undefined"){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/render/dialog_axd_list",success:function(AU){AF.axd_list_dialog=AU;g("body").append(AU);AO(AT)},error_phrase:"error_fetching_dialog"});return }g("#axd-list-dialog").dialog({title:vBulletin.phrase.get("edit_locationx_ad",AN),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:600,dialogClass:"dialog-container ad-list-dialog-container input-dialog",open:function(){var AU=g(this);var AW=[];for(var AV in AT){AW.push([AT[AV].title,AT[AV].active,AT[AV].displayorder,AT[AV].adid])}g(".title",AU).text(vBulletin.phrase.get("ad_list_description",AN));g(".axdtable",AU).dataTable({bPaginate:false,bLengthChange:false,bInfo:false,bAutoWidth:false,bDestroy:true,aaSorting:[[2,"asc"]],aoColumns:[{sTitle:vBulletin.phrase.get("title")+"<span></span>",sClass:"axdtable-title axd-cell"},{sTitle:vBulletin.phrase.get("active"),sClass:"axdtable-active axd-cell",bSortable:false,bSearchable:false,fnRender:function(AY,AX){return'<input type="checkbox" class="isactive" data-id="{0}"{1} />'.format(AY.aData[3],((AX=="1")?' checked="checked"':""))}},{sTitle:vBulletin.phrase.get("display_order")+"<span></span>",sClass:"axdtable-display-order axd-cell",bSearchable:false,bUseRendered:false,fnRender:function(AY,AX){return'<input type="text" class="displayorder textbox" value="{0}" data-id="{1}" />'.format(AY.aData[2],AY.aData[3])}},{sTitle:vBulletin.phrase.get("action"),sClass:"axdtable-action axd-cell",bSearchable:false,bSortable:false,bUseRendered:false,fnRender:function(AY,AX){return'<a href="#" class="editlink" data-id="{0}" title="{1}"><span></span></a> <a href="#" class="deletelink" data-id="{0}" title="{2}"><span></span></a>'.format(AY.aData[3],vBulletin.phrase.get("edit"),vBulletin.phrase.get("delete"))}}],aaData:AW});g(".dataTables_filter input[type=text]",AU).addClass("axdfilter textbox").on("keyup",function(){g(this).next()[this.value!=""?"removeClass":"addClass"]("h-hide")}).after('<button type="button" class="axdSearchBtn button secondary h-hide">{0}</button>'.format(vBulletin.phrase.get("reset")));g(".axdSearchBtn",AU).on("click",function(){g(this).addClass("h-hide").prev().val("").trigger("keyup")});g(".axdtable .editlink",AU).off("click").on("click",function(){var AX=g(this).attr("data-id");AU.dialog("close");AU.dialog("destroy");AP(AT[AX]);return false});g(".axdtable .deletelink",AU).off("click").on("click",function(){var AX=g(this).attr("data-id"),AY=g(this).closest("tr").find(".isactive").prop("checked");AU.dialog("close");AU.dialog("destroy");openConfirmDialog({title:vBulletin.phrase.get("confirm_deletion_x",AT[AX].title),message:vBulletin.phrase.get("are_you_sure_want_to_delete_ad_x",AT[AX].title,"adid",AX),iconType:"warning",onClickYes:function(){g("body").css("cursor","wait");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/ad/delete",type:"POST",data:{adid:AX},dataType:"json",success:function(AZ){if(AZ.errors){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get(AZ.errors[0]),iconType:"error"})}else{AR(true);if(AY){AM=true}}}})},onClickNo:function(){AR()}});return false});g(".axdlist",AU).show();g(".btnAddAxd",AU).off("click").on("click",function(){AU.dialog("close");AU.dialog("destroy");AP({adlocation:AN});return false});g(".btnCancelAxd",AU).off("click").on("click",function(){AU.dialog("close");AU.dialog("destroy")});g(".btnSaveAxd",AU).off("click").on("click",function(){if(g(".isactive",AU).length==0){AU.dialog("close");AU.dialog("destroy");return false}g("body").css("cursor","wait");var AX={},AY=[];g(".isactive",AU).each(function(){var AZ=g(this).attr("data-id");AX[AZ]={};AX[AZ]["displayorder"]=g('.displayorder[data-id="'+AZ+'"]',AU).val();if(g(this).is(":checked")){AX[AZ]["active"]=1;var Aa=AX[AZ];Aa.snippet=AT[AZ].snippet;Aa.title=AT[AZ].title;AY.push(Aa)}else{AX[AZ]["active"]=0}});g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/ad/quickSave",type:"POST",data:{data:AX},dataType:"json",success:function(AZ){if(AZ.errors){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get(AZ.errors[0]),iconType:"error"})}else{var Aa=g(".axd_"+AN,AS);if(Aa.length==0){Aa=g(".widget-content",AS)}if(AY.length>0){AY.sort(function(Ae,Ad){return Ae.displayorder-Ad.displayorder});var Ac="",Ab="";g.map(AY,function(Ae,Ad){if(Ae.snippet){Ab+=f(Ae.snippet,Ae.title);Ac+=Ae.snippet}});Aa.html(Ab);AM=AQ(Ac)}else{Aa.html("")}Aa.show();AU.dialog("close");AU.dialog("destroy");g("html,body").animate({scrollTop:0},"slow")}},complete:function(){g("body").css("cursor","default")}})})}})}function AP(AU){var AT=AU.adlocation;if(typeof AF.axd_config_dialog=="undefined"){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/render/dialog_axd_config",success:function(AV){AF.axd_config_dialog=AV;g("body").append(AV);AP(AU)},error_phrase:"error_fetching_dialog"});return }g("#axd-config-dialog").dialog({title:vBulletin.phrase.get("edit_locationx_ad",AT),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:720,dialogClass:"dialog-container axd-dialog-container input-dialog",open:function(){var AV=g(this);if(AU.adid){g(".title",AV).val(AU.title);g(".axd_html",AV).val(AU.snippet);if(AU.active=="1"){g(".active",AV).prop("checked",true)}else{g(".active",AV).prop("checked",false)}g(".axdid",AV).val(AU.adid);for(var AW in AU.criterias){g("[name=data\\[criteria\\]\\["+AU.criterias[AW].criteriaid+"\\]\\[active\\]]",AV).prop("checked",true);g("[name=data\\[criteria\\]\\["+AU.criterias[AW].criteriaid+"\\]\\[condition1\\]]",AV).val(AU.criterias[AW].condition1);g("[name=data\\[criteria\\]\\["+AU.criterias[AW].criteriaid+"\\]\\[condition2\\]]",AV).val(AU.criterias[AW].condition2);g("[name=data\\[criteria\\]\\["+AU.criterias[AW].criteriaid+"\\]\\[condition3\\]]",AV).val(AU.criterias[AW].condition3)}}else{g(".axdid",AV).val(0);g(".configform",AV).trigger("reset")}g(".axd_location",AV).val(AT);g(".blockrow select.custom-dropdown",AV).selectBox();g(".blockrow a.custom-dropdown, .blockrow input[type=text]",AV).on("click",function(AY){return false});g(".btnAttachHtmlAxd",AV).off("click").on("click",function(){var AY=g(".configform",AV).serialize();g("body").css("cursor","wait");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/ad/save",type:"POST",data:AY,dataType:"json",success:function(AZ){if(AZ){if(AZ.errors){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get(AZ.errors[0]),iconType:"error"})}else{AX();AM=AQ(g(".configform .axd_html",AV).val())}}},complete:function(){g("body").css("cursor","default")}})});g(".btnCancelEditHtmlAxd",AV).off("click").on("click",function(){AX(true)});function AX(AY){AY=AY||false;g(":checkbox",AV).prop("checked",false);g("select",AV).val("");AV.dialog("close");AV.dialog("destory");AR(AY)}}})}function AQ(AV){var AU=g("<div>"+AV+"</div>");if(AU.filter("script").length>0){return true}else{var AT=AU.find("*").filter(function(){return(this.nodeName.toLowerCase().indexOf("vb:")==0)?this:null});return(AT.length>0||(/\{vb\s*\:\s*[a-z]+\s+.*\}/).test(AV))}}return false});g("#header .header-cell .edit.button").on("click",function(){g(".header-edit-box.selected").removeClass("selected");g(this).closest(".header-edit-box").addClass("selected");g("#edit-site-logo-dialog").dialog({title:vBulletin.phrase.get("edit_site_logo")+'<span class="dialog-subtitle">'+vBulletin.phrase.get("choose_options_site_logo")+"</span>",autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:520,dialogClass:"dialog-container site-logo-dialog-container input-dialog",create:function(){g("#btnCancelEditSiteLogo").on("click",function(){g("#edit-site-logo-dialog").dialog("close")});g("#btnSaveEditSiteLogo").on("click",function(){if(Number(g("#header .site-logo img").attr("data-fileid"))>0){H(function(){g("#edit-site-logo-dialog").dialog("close")})}else{g("#edit-site-logo-dialog").dialog("close")}});g("#edit-site-logo-dialog .styleselection").change(function(){g("#header .site-logo img").attr({"data-styleselection":g(this).val()})});g("#edit-site-logo-dialog").fileupload({dropZone:null,dataType:"json",add:function(AO,AN){g("body").css("cursor","wait");g(AO.target).find(".upload-progress-bar:first").removeClass("h-hide");AN.submit()},done:function(AO,AN){if(AN.result&&AN.result.filedataid){g("#header .site-logo img").attr({src:AN.result.imageUrl,"data-fileid":AN.result.filedataid,"data-styleselection":g("#edit-site-logo-dialog .styleselection:checked").val()})}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_uploading_logo"),iconType:"error"})}},fail:function(AO,AN){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_uploading_logo"),iconType:"error"})},always:function(AO,AN){g("body").css("cursor","auto");g(AO.target).find(".upload-progress-bar:first").addClass("h-hide")}});g("#edit-site-logo-dialog #btnAttachLogo").on("click",function(){var AN=g.trim(g("#edit-site-logo-dialog #imageUrl").val());if(AN){g("body").css("cursor","wait");g(this).closest(".dialog-content").find(".upload-progress-bar:last").removeClass("h-hide");g.ajax({url:vBulletin.getAjaxBaseurl()+"/uploader/Url",data:({urlupload:AN}),type:"POST",dataType:"json",complete:function(){console.log("uploader/url complete.");g("body").css("cursor","auto");g("#edit-site-logo-dialog .upload-progress-bar:last").addClass("h-hide")},success:function(AO){console.log("saving site logo successful! result:"+AO);if(AO&&!AO.error){g("#header .site-logo img").attr({src:AO.imageUrl,"data-fileid":AO.filedataid,"data-styleselection":g("#edit-site-logo-dialog .styleselection:checked").val()})}else{if(AO.error){openAlertDialog({title:vBulletin.phrase.get("edit_site_logo"),message:vBulletin.phrase.get("invalid_image_url"),iconType:"warning",onAfterClose:function(){g("#edit-site-logo-dialog #imageUrl").select().focus()}})}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_processing_site_logo"),iconType:"error",onAfterClose:function(){g("#edit-site-logo-dialog #imageUrl").focus()}})}}},error:function(AQ,AP,AO){console.log("remote url site logo failed! error:"+AO);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_processing_site_logo_image_hosting",AQ.status),iconType:"error",onAfterClose:function(){g("#edit-site-logo-dialog #imageUrl").focus()}})}})}else{g("#edit-site-logo-dialog #imageUrl").focus()}})}})});g(".admin-button-flat").disableSelection();y=g("#edit-content .tabs").tabs({show:function(AN,AO){Q(AO.index);O()},select:function(AO,AP){g("#save-content").hide();if(AP.index==1){if(d){g("#edit-page-dropdown .layout-list .layout-border.selected").removeClass("selected");var AN=g("#edit-page-dropdown .layout-list input[type=radio][value={0}]".format(g(".canvas-layout:visible").attr("data-layout-id")));AN.prev().addClass("selected");z="canvas-"+AN.attr("id")}}}});g("#lnkAddModules").on("click",function(){y.tabs("select",0);return false});AD();g(document).on("click",".module-buttons .hide-icon input",function(){var AO=g(this);AO.closest(".canvas-widget")[this.checked?"addClass":"removeClass"]("hidden-widget");var AN=AO.attr("title");AO.attr("title",AO.data("toggle-title")).data("toggle-title",AN)});g(".canvas-layout-container .canvas-layout").each(function(){v[this.id]=g("#"+this.id+' div[class*="section-"]').length});if(!q){z="canvas-"+g("#edit-page-dropdown .layout-list input[type=radio][value={0}]".format(g(".canvas-layout:visible").attr("data-layout-id"))).prop("checked",true).attr("id")}n=g("#edit-page-dropdown .layout-list input[type=radio]").thumbnailRadioCheckbox({thumbnailClass:"layout-border"});n.thumbnailRadioCheckbox("option","select",function(AO,AN){g(".canvas-layout").addClass("h-hide");g("#canvas-"+AN.attr("id")).removeClass("h-hide");i("canvas-"+AN.attr("id"));b();AJ();o=true})}function i(AO){if(!z){g(".canvas-layout.h-hide input[type=hidden]").prop("disabled",true);g("#"+AO+" input[type=hidden]").prop("disabled",false);z=AO;return }else{if(z==AO){return }else{g(".canvas-layout.h-hide input[type=hidden]").prop("disabled",true);g("#"+AO+" input[type=hidden]").prop("disabled",false);var AM=v[AO];var AL=false;var AN=0;g("#"+z+" > .canvas-layout-row > .canvas-widget-list").each(function(){var AT=g(this);AL=C(AT,g("#"+AO+" > .canvas-layout-row > .canvas-widget-list"));if(!AL.length){AN=Z(this);AL=g("#"+AO+" > .canvas-layout-row > div.section-"+AN)}if(!AL.length){var AP=AM;while(AP>=0&&g("#"+AO+" > .canvas-layout-row > div.section-"+AP).length==0){AP--}AL=g("#"+AO+" > .canvas-layout-row > div.section-"+AP)}var AR=AT.children(".canvas-widget");var AU=parseInt(Math.ceil(AR.length/AL.length),10);console.log("Moving {0} widgets to {1} sections; ChunkSize {2}".format(AR.length,AL.length,AU));if(AU>0){var AS=0,AQ=0;AR.each(function(){g(this).appendTo(AL.eq(AQ));++AS;if(AS>=AU){AS=0;++AQ}})}})}}z=AO}function C(AL,AN){var AP=["js-sectiontype-notice","js-sectiontype-primary","js-sectiontype-secondary","js-sectiontype-extra"],AM,AO;for(AM in AP){if(AL.is("."+AP[AM])){AO=AP[AM];break}}return AN.filter(function(){return g(this).is("."+AO)})}function Z(AN){var AM=/section-(\d+)/gi;var AL=null;g(g(AN).attr("class").split(" ")).each(function(AP,AQ){var AO=AM.exec(AQ);if(AO&&!isNaN(AO[1])){AL=AO[1]}});return AL}function D(AL){if(!g.isArray(AL)||AL.length==0){return }window.vBulletin.loadingIndicator.show();g("body").css("cursor","wait");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/admin-template/widget",data:({widgets:AL,pagetemplateid:g("#save-page-form #pagetemplateid-yes").val()}),type:"POST",dataType:"json",complete:function(){console.log("admin-template/widget complete. moduleLoaded="+c);if(c){window.vBulletin.loadingIndicator.hide()}g("body").css("cursor","auto")},success:function(AM){console.log("admin-template/widget successful! result:");console.dir(AM);V=true;if(AM&&g.isArray(AM.widgets)){g.each(AM.widgets,function(AN,AP){if(!AP.widgetid||Number(AP.widgetid)<1||!g.trim(AP.template)){return true}var AQ=(AP.displaysection&&Number(AP.displaysection)>0)?AP.displaysection:0;var AO=g(AP.template);AO.appendTo(g(".canvas-layout:not(.h-hide) .canvas-widget-list.section-"+AQ).height("auto")).filter(":not(.container-widget)").find(".toggle-button").trigger("click",[true]);AO.find(".tabs").tabs()})}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(AO,AN,AM){console.log("admin-template/widget failed! error:"+AM);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_adding_widgets",AO.status),iconType:"error"})}});return false}function AA(AL,AM){if(AL.text()=="<"){AL.text(">");AL.closest(".channel-item-container").children(".sub-channel-container").children(".channel-item-container").slideDown(150)}else{if(typeof (AM)==="undefined"||!AM){AL.text("<");AL.closest(".channel-item-container").children(".sub-channel-container").children(".channel-item-container").slideUp(150)}}}function W(){g(".channel-config-dialog .channel-list").sortable({placeholder:"main-channel-container-highlight drag-highlight h-clear",update:function(AL,AM){AM.item.css("z-index","0");G.forum=true;Y=true},sort:function(AL,AM){},start:function(AL,AM){if(g.browser.msie&&parseInt(g.browser.version,10)==8){AM.item.height(AM.item.height()-4)}AM.item.css("z-index","99999");AM.placeholder.height(AM.item.outerHeight())},over:function(AL,AM){},receive:function(AL,AM){},out:function(AL,AM){},handle:".grip-icon-main",items:".main-channel-container"})}function u(AL){AI=AL.find(".main-channel-container").sortable({connectWith:".sub-channel-container",placeholder:"channel-item-highlight drag-highlight",revert:true,update:function(AM,AN){var AO=AN.item.closest(".main-channel-container");if(AN.sender&&AN.sender.hasClass("main-channel-container")){if(g("> .channel-item-container",AN.sender).length==0){AN.sender.slideUp("fast",function(){g(this).remove()})}}G.forum=true;Y=true},sort:function(AM,AN){},activate:function(AM,AN){},start:function(AM,AN){},stop:function(AM,AN){g(".main-channel-container, .sub-channel-container").height("auto")},over:function(AM,AN){},receive:function(AM,AN){},out:function(AM,AN){},handle:".channel-item-inner > .grip-icon-item",items:".channel-item-container"})}function F(AL){m=AL.find(".sub-channel-container").sortable({connectWith:".sub-channel-container",revert:true,placeholder:"channel-item-highlight drag-highlight",update:function(AM,AN){if(AN.sender&&AN.sender.hasClass("main-channel-container")){if(g("> .channel-item-container",AN.sender).length==0){AN.sender.slideUp("fast",function(){g(this).remove()})}}G.forum=true;Y=true},sort:function(AM,AN){},start:function(AM,AN){},stop:function(AM,AN){g(".main-channel-container, .sub-channel-container").height("auto")},over:function(AN,AO){var AM=g(this).closest(".channel-item-container").children(".channel-item").find(".toggle-button");AA(AM,true)},receive:function(AM,AN){},out:function(AM,AN){},handle:".channel-item-inner > .grip-icon-item",items:".channel-item-container"})}function AK(AL,AO,AP,AQ,AT,AV,AS){var AR='<div class="'+(AT?"category-to-channel":"channel-to-category")+'"><a href="#">'+vBulletin.phrase.get((AT?"make_forum":"make_category"))+"</a></div>";var AU=g(('<div class="main-channel-container">				<div class="grip-icon grip-icon-main h-left"><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div></div>				<div class="channel-item-container">					<div class="channel-item shadow" data-channel-id="{0}" data-parent-id="{2}">						<div class="channel-item-inner">							<div class="grip-icon grip-icon-item h-left"><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div></div>							<div class="channel-title"><div title="'+vBulletin.phrase.get("click_text_edit_title")+'">{1}</div><input type="text" name="channeltitle" value="{1}" /></div>							<div class="close-button" title="'+vBulletin.phrase.get("remove_forum")+'">x</div>							<div class="toggle-button"><</div>							<div class="num-subchannels">'+AS+'</div>							<div class="add-subchannel-button h-right" title="'+vBulletin.phrase.get("add_subforum")+'"><a href="#">+</a></div>							'+AR+'							<div class="h-clear"></div>						</div>					</div>					<div class="sub-channel-container"></div>				</div>		 </div>').format(AO,AQ,AP)).appendTo(AL);if(AV){var AM=g("#top-level-forum .channel-config-dialog .channel-list");var AN=AM.find(".main-channel-container").last();g("html, body").animate({scrollTop:AN.offset().top},"fast")}G.forum=true;Y=true;return AU}function AG(AN,AO,AP,AS,AM,AR){var AQ='<div class="'+(AS?"category-to-channel":"channel-to-category")+'"><a href="#">'+vBulletin.phrase.get((AS?"make_forum":"make_category"))+"</a></div>";var AT=AM.hasClass("main-channel-container")?g("> .channel-item-container > .sub-channel-container",AM):g("> .sub-channel-container",AM);var AL=g(('<div class="channel-item-container">				<div class="channel-item shadow" data-channel-id="{0}" data-parent-id="{2}">					<div class="channel-item-inner">						<div class="grip-icon grip-icon-item h-left"><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div></div>						<div class="channel-title"><div title="Click text to edit title">{1}</div><input type="text" name="channeltitle" value="{1}" /></div>						<div class="close-button" title="'+vBulletin.phrase.get("remove_forum")+'">x</div>						<div class="toggle-button"><</div>						<div class="num-subchannels">'+AR+'</div>						<div class="add-subchannel-button h-right" title="'+vBulletin.phrase.get("add_subforum")+'"><a href="#">+</a></div>						'+AQ+'						<div class="h-clear"></div>					</div>			 </div>			 <div class="sub-channel-container"></div>			</div>').format(AN,AP,AO)).hide().appendTo(AT);G.forum=true;Y=true;return AL}function t(){window.vBulletin.loadingIndicator.show();g("body").css("cursor","wait");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/fetch-widget-admin-template-list",type:"POST",dataType:"json",complete:function(){console.log("fetch-widget-admin-template-list complete. templatesLoaded="+R);if(R){window.vBulletin.loadingIndicator.hide()}g("body").css("cursor","auto");O();g(window).resize(O)},success:function(AN){console.log("fetch-widget-admin-template-list successful! result:");console.dir({result:AN});c=true;if(g.isArray(AN)){if(AN.length>0){var AO={},AS=0,AP=[];AO.customized_copy={count:0,title:vBulletin.phrase.get("my_custom_modules")};g.each(AN,function(AU,AV){if(!AV.widgetid||Number(AV.widgetid)<1){return true}AS++;if(!AO[AV.category]){AO[AV.category]={count:1,title:AV.category_title}}else{AO[AV.category].count++}var AT=g("#edit-page-dropdown .module-list .module-icon-template").clone();AT.attr("data-widget-id",AV.widgetid).attr("data-title",g.trim(AV.title).toLowerCase()).data("canbemultiple",AV.canbemultiple).removeClass("module-icon-template").addClass(("module-item list-item category-{0}"+(AV.cloneable=="1"?" module-cloneable":"")).format(AV.category));g(".module-icon",AT).html(g("<img />").attr("src",pageData.baseurl+"/admincp/img/"+g.trim(AV.icon)).attr("height",60).attr("width",60).attr("alt",vBulletin.phrase.get("module_icon")));g(".module-title .main-title",AT).html(g.trim(AV.title));AT.appendTo("#edit-page-dropdown .module-list").removeClass("h-hide");if(AV.category=="customized_copy"){AP.push(AV.widgetid)}});if(AO.customized_copy.count<1){delete AO.customized_copy}g(".canvas-layout-container .canvas-widget").filter(function(){var AT=g(this).attr("data-widget-id");return(g.inArray(AT,AP)!=-1)}).find(".module-buttons .edit-button").hide();g('<div class="custom-module-manage-links">							<a href="#" class="edit">'+vBulletin.phrase.get("edit")+'</a> 							<a href="#" class="rename">'+vBulletin.phrase.get("rename")+'</a> 							<a href="#" class="delete">'+vBulletin.phrase.get("delete")+"</a>						</div>").appendTo("#add-modules .module-list .category-customized_copy");g("#add-modules").on("click",".custom-module-manage-links a",function(AW){AW.preventDefault();var AY=g(this).attr("class");var AV=g(this).closest(".canvas-widget");if(AY=="edit"){AV.find(".module-buttons .admin-only .edit-button").click()}else{if(AY=="rename"){AV.draggable("disable");var AU=g(this);AU.hide();var AX=g(".main-title",AV);var AT=AX.text();AX.html('<input type="text" class="titleinput textbox" autocomplete="off" style="-moz-user-select:text;width:100%;" value="'+AT+'"> <a href="#" class="save">'+vBulletin.phrase.get("save")+'</a> <a href="#" class="cancel">'+vBulletin.phrase.get("cancel")+"</a>");g("a.save",AX).on("click",function(AZ){AZ.preventDefault();if(g(".titleinput",AX).val()==""){openAlertDialog({title:vBulletin.phrase.get("rename_custom_module"),message:vBulletin.phrase.get("please_enter_new_module_title"),iconType:"warning",onAfterClose:function(){g(".titleinput",AX).focus()}})}g("body").css("cursor","wait");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/widget/renameWidget",type:"POST",data:{widgetId:AV.attr("data-widget-id"),newtitle:g(".titleinput",AX).val()},dataType:"json",success:function(Aa){g("body").css("cursor","auto");if(Aa===true){AT=g(".titleinput",AX).val();AX.text(AT);AU.show()}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error",onAfterClose:function(){g("#config-dialog .action-buttons button").prop("disabled",false)}})}},error:function(Ac,Ab,Aa){g("body").css("cursor","auto");openAlertDialog({title:vBulletin.phrase.get("rename_custom_module"),message:vBulletin.phrase.get("error_renaming_module_title"),iconType:"error",onAfterClose:function(){g(".titleinput",AX).focus()}})},complete:function(Ab,Aa){AV.draggable("enable")}})});g("a.cancel",AX).on("click",function(AZ){AZ.preventDefault();AX.text(AT);AU.show();AV.draggable("enable")})}else{if(AY=="delete"){alert("Deleting is not yet implemented")}}}});g('<div id="create-custom-module" class="non-module-item canvas-widget module-item list-item category-customized_copy h-hide">							<div class="widget-header">								<div class="module-icon"><a href="#" title="'+vBulletin.phrase.get("create_new_custom_module")+'"><img width="60" height="60" alt="Create New Custom Module" src="'+pageData.baseurl+'/admincp/img/module-icon-create-new.png"></a></div>								<div class="module-title h-left"><a href="#" title="'+vBulletin.phrase.get("create_new_custom_module")+'">'+vBulletin.phrase.get("create_new_custom_module")+'</a></div>								<div class="h-clear"></div>							</div>						</div>').prependTo("#edit-page-dropdown .module-list");g("#create-custom-module a").on("click",function(){g("#create-new-module-dialog").dialog({title:vBulletin.phrase.get("choose_base_module"),autoOpen:true,modal:true,resizable:false,closeOnEscape:true,showCloseButton:true,width:950,dialogClass:"dialog-container pagemap-dialog-container input-dialog",create:function(){g("#create-new-module-dialog .cancel-button").on("click",function(){g("#create-new-module-dialog").dialog("close")});$modulelist=g(".module-list-container").clone();g("#create-new-module-dialog .dialog-body").append($modulelist);g("#create-new-module-dialog #create-custom-module").remove();g("#create-new-module-dialog .module-item").not(".module-cloneable").remove();g("#create-new-module-dialog .categories .category").each(function(){var AT=g(this).attr("id").substr("category-".length);var AU=g("#create-new-module-dialog .module-item").filter(".category-"+AT).size();if(AT=="all"){g(this).text("All ({0})".format(g("#create-new-module-dialog .module-item").size()))}else{if(AU<1){g(this).hide()}else{g(this).text((AO[AT].title+" ({0})").format(AU))}}});g("#create-new-module-dialog .module-list").css("width","800px");g("#create-new-module-dialog .module-item").css("cursor","pointer");g("#create-new-module-dialog .module-item").on("click",function(){window.vBulletin.loadingIndicator.show();var AT=g(this).attr("data-widget-id");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/widget/cloneWidget",data:({widgetId:AT}),type:"POST",dataType:"json",complete:function(){console.log("/ajax/api/widget/cloneWidget complete");g("body").css("cursor","auto")},success:function(AU){if(AU&&typeof AU.widget=="object"){console.log("/ajax/api/widget/cloneWidget successful");console.log(AU);g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/fetch-widget-admin-template-list",data:({widgetids:[AU.widget.widgetid]}),type:"POST",dataType:"json",success:function(AV){if(g.isArray(AV)&&AV.length==1){var AX=AV[0];console.log("/ajax/fetch-widget-admin-template-list successful");console.log(AX);++AO[AX.category].count;var AW=g("#edit-page-dropdown .module-list .module-icon-template").clone();AW.attr("data-widget-id",AX.widgetid).attr("data-title",g.trim(AX.title).toLowerCase()).data("canbemultiple",AX.canbemultiple).removeClass("module-icon-template").addClass(("module-item list-item category-{0}"+(AX.cloneable=="1"?" module-cloneable":"")).format(AX.category));g(".module-icon",AW).html(g("<img />").attr("src",pageData.baseurl+"/admincp/img/"+g.trim(AX.icon)).attr("height",60).attr("width",60).attr("alt",vBulletin.phrase.get("module_icon")));g(".module-title .main-title",AW).html(g.trim(AX.title));AW.insertAfter("#add-modules #create-custom-module").removeClass("h-hide");AW.draggable({connectToSortable:".canvas-layout-row > .canvas-widget-list:visible",helper:"clone",revert:"invalid",appendTo:"#add-modules .module-list-container",zIndex:2000,start:function(AZ,Aa){if(g(this).data("canbemultiple")=="0"&&g("#content .canvas-layout .canvas-widget[data-widget-id={0}]".format(g(this).attr("data-widget-id"))).length>0){openAlertDialog({title:vBulletin.phrase.get("move_not_allowed"),message:vBulletin.phrase.get("adding_multiple_modules_not_allowed",g(".main-title",this).html()),iconType:"warning"});return false}X=true},stop:function(AZ,Aa){X=false}}).disableSelection();var AY=g("#add-modules .module-item").filter(".category-customized_copy").not(".non-module-item").size();g("#add-modules #category-customized_copy").text((AO.customized_copy.title+" ({0})").format(AY));g("#add-modules #category-all").click();g("#add-modules #category-customized_copy").click();g('<div class="custom-module-manage-links">																	<a href="#" class="edit">'+vBulletin.phrase.get("edit")+'</a> 																	<a href="#" class="rename">'+vBulletin.phrase.get("rename")+'</a> 																	<a href="#" class="delete">'+vBulletin.phrase.get("delete")+"</a>																</div>").appendTo(AW);window.vBulletin.loadingIndicator.hide();AW.css("background-color","#2E3741");AW.effect("highlight",{color:"#FFFF00"},2000,function(){g(this).css("background-color","transparent")})}else{console.log("/ajax/fetch-widget-admin-template-list successful, but response was not an array");console.log(AV);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(AX,AW,AV){console.log("/ajax/fetch-widget-admin-template-list failed, error: "+AV);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_cloned_widget_template",AX.status),iconType:"error"})}});g("#create-new-module-dialog").dialog("close")}else{console.log("/ajax/api/widget/cloneWidget successful, but response was not an array");console.log(AU);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(AW,AV,AU){console.log("/ajax/api/widget/cloneWidget failed, error: "+AU);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_cloning_widget",AW.status),iconType:"error"})}})})},close:function(){g("#create-new-module-dialog .dialog-body").html("");g("#create-new-module-dialog").dialog("destroy")},open:function(){var AT=function(){var AU=g("#create-new-module-dialog .list-item");var AV=Math.max(AU.outerWidth(true)*AU.filter(":visible").length,parseFloat(AU.parent().css("min-width"),10));AU.parent().width(AV)};AT();k[3]=g("#create-new-module-dialog .module-list-container");k[3].tinyscrollbar({sizethumb:14,axis:"x",update:function(){}});k[3].tinyscrollbar_update();g("#create-new-module-dialog .categories .category").on("click",function(AW){AW.stopPropagation();var AU=g(this).closest(".module-list-container");var AX=g(".module-item",AU);g(".category.selected",AU).removeClass("selected");g(this).addClass("selected");AX.hide();g(".empty-module",AU).hide();var AV=this.id;if(AV=="category-all"){AX.show();g(".non-module-item",AU).hide();AT();k[3].tinyscrollbar_update()}else{if(AV=="category-result"){g("#search-module-keyword").triggerHandler("keyup",[true])}else{g(".module-item.{0}".format(AV),AU).show();AT();k[3].tinyscrollbar_update()}}return false}).disableSelection();g("#create-new-module-dialog #category-all").click()}});return false});g(('<div class="category-arrow-left h-left" title="'+vBulletin.phrase.get("previous")+'">&lsaquo;</div>							<div class="scroller category h-left">								<div class="categories h-left">									<div id="category-all" class="category selected">'+vBulletin.phrase.get("all")+' ({0})</div>									<div id="category-result" class="category h-hide">'+vBulletin.phrase.get("search_results")+' (<span></span>)</div>								</div>							</div>							<div class="category-arrow-right h-left" title="'+vBulletin.phrase.get("next")+'">&rsaquo;</div>							<div class="h-clear"></div>').format(AS)).insertBefore("#edit-page-dropdown .module-list-container .scroller");var AM=0;g.each(AO,function(AU,AV){var AT=g('<div id="category-{0}" class="category">{1} ({2})</div>'.format(AU,AV.title,AV.count)).insertBefore("#category-result");AM+=AT.outerWidth(true)});var AR=AM+g("#category-all").outerWidth(true);g(".categories").width(AR);if(g(".categories").width()<=g(".scroller.category").width()){g(".category-arrow-left, .category-arrow-right").css("visibility","hidden")}else{g(".category-arrow-right").css("visibility","visible")}Q(0);k[0]=g("#add-modules .module-list-container");k[0].tinyscrollbar({sizethumb:14,axis:"x",update:function(){if(g("#add-modules .module-list-container").innerHeight()<g("#add-modules .panel-header-text").height()){g("#add-modules .panel-header-text").height(g("#add-modules .module-list-container").innerHeight())}}});g("#edit-page-dropdown .module-list .module-item").not(".non-module-item").draggable({connectToSortable:".canvas-layout-row > .canvas-widget-list:visible",helper:"clone",revert:"invalid",appendTo:"#add-modules .module-list-container",zIndex:2000,start:function(AT,AU){if(g(this).data("canbemultiple")=="0"&&g("#content .canvas-layout .canvas-widget[data-widget-id={0}]".format(g(this).attr("data-widget-id"))).length>0){openAlertDialog({title:vBulletin.phrase.get("move_not_allowed"),message:vBulletin.phrase.get("adding_multiple_modules_not_allowed",g(".main-title",this).html()),iconType:"warning"});return false}X=true},stop:function(AT,AU){X=false}}).disableSelection();var AL=false;g("#search-module-keyword").on("keyup",function(AT,Ab){var Aa=g("#add-modules");var AX=g("#category-result");var AU=g(".categories",Aa);var AV=g(".scroller.category",Aa);var AW=false;g(".module-item",Aa).hide();if(!Ab){g(".category.selected",Aa).removeClass("selected")}var AZ=g.trim(this.value.toLowerCase());if(AZ){g('.module-item[data-title*="{0}"]'.format(AZ),Aa).show();AX.removeClass("h-hide").addClass("selected")}else{g(".module-item",Aa).show();g("#category-all").removeClass("h-hide").addClass("selected");AX.addClass("h-hide").removeClass("selected");AW=true}var Ac=g(".module-item:visible",Aa).length;g("span",AX).text(Ac);Q(0);k[0].tinyscrollbar_update();if(Ac==0){g(".empty-module",Aa).show()}else{g(".empty-module",Aa).hide()}if(AW){AU.width(AR)}else{AU.width(AR+AX.outerWidth(true))}if(AU.width()<=AV.width()){g(".category-arrow-left, .category-arrow-right",Aa).css("visibility","hidden");AV.scrollLeft(0)}else{if(AW){g(".category-arrow-left",Aa).css("visibility","hidden");g(".category-arrow-right",Aa).css("visibility","visible");AV.scrollLeft(0)}else{g(".category-arrow-left",Aa).css("visibility","visible");g(".category-arrow-right",Aa).css("visibility","hidden");var AY=AV.get(0);AV.scrollLeft(AY.scrollWidth-AY.clientWidth)}}return true});g("#add-modules .categories .category").on("click",function(AV){AV.stopPropagation();if(g(this).hasClass("selected")){return false}var AT=g(this).closest(".module-list-container");var AW=g(".module-item",AT);g(".category.selected",AT).removeClass("selected");g(this).addClass("selected");AW.hide();g(".empty-module",AT).hide();var AU=this.id;if(AU=="category-all"){AW.show();g(".non-module-item",AT).hide();Q(0);k[0].tinyscrollbar_update()}else{if(AU=="category-result"){g("#search-module-keyword").triggerHandler("keyup",[true])}else{g(".module-item.{0}".format(AU),AT).show();Q(0);k[0].tinyscrollbar_update()}}return false}).disableSelection();var AQ;g(".category-arrow-left").on({mousedown:function(){g(".category-arrow-right").css("visibility","visible");AQ=setInterval(function(){var AT=g(".scroller.category");AT.scrollLeft(AT.scrollLeft()-20);if(AT.scrollLeft()==0){g(".category-arrow-left").css("visibility","hidden");clearInterval(AQ)}},50)},mouseup:function(){clearInterval(AQ)}}).disableSelection();g(".category-arrow-right").on({mousedown:function(){g(".category-arrow-left").css("visibility","visible");AQ=setInterval(function(){var AU=g(".scroller.category");AU.scrollLeft(AU.scrollLeft()+20);var AT=AU.get(0);if(AU.scrollLeft()==AT.scrollWidth-AT.clientWidth){g(".category-arrow-right").css("visibility","hidden");clearInterval(AQ)}},50)},mouseup:function(){clearInterval(AQ)}}).disableSelection()}else{g('<div class="empty-module">'+vBulletin.phrase.get("no_modules")+"</div>").appendTo("#edit-page-dropdown .module-list")}}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(AN,AM,AL){console.log("fetch-widget-admin-template-list failed! error:"+AL);window.vBulletin.loadingIndicator.hide();openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_modules",AN.status),iconType:"error"})}})}function A(){window.vBulletin.loadingIndicator.show();g("body").css("cursor","wait");g("#edit-page-dropdown .template-list").empty();g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/pagetemplate/fetchPageTemplateList",dataType:"json",data:{pagetemplateid:g("#save-page-form #pagetemplateid-yes").val()},type:"POST",complete:function(){console.log("fetchPageTemplateList complete.");if(c){window.vBulletin.loadingIndicator.hide()}g("body").css("cursor","auto")},success:function(AM){console.log("fetchPageTemplateList successful! result:");console.dir({templates:AM});R=true;if(g.isArray(AM)&&AM.length>0){var AL=false;g.each(AM,function(AN,AO){g('<div class="template-item list-item h-left">								<input type="radio" id="pagetemplateid-{0}" name="pagetemplateid" value="{0}" data-thumbnail="{1}/{2}/img/template-icon-default.png"{3} />								<label class="label">{4}</label>							</div>'.format(AO.pagetemplateid,pageData.baseurl,"admincp",(!q&&g("#save-page-form #pagetemplateid-yes").val()==AO.pagetemplateid)?' checked="checked"':"",AO.title)).appendTo("#edit-page-dropdown .template-list").data({screenlayoutid:AO.screenlayoutid,widgetinstances:AO.widgetinstances});if(g("#save-page-form #pagetemplateid-yes").val()==AO.pagetemplateid){AL=true;if(AO.title==""){window.console.warn("The page template for this page does not have a title.")}}});if(!q&&!AL){window.console.error("The page template for this page was not in the list returned by fetchPageTemplateList! Expected pagetemplateid: {0}. Please ensure that this page template has a title.".format(g("#save-page-form #pagetemplateid-yes").val()))}g(".template-item",g("#edit-page-dropdown .template-list")).each(function(AN){g(this).attr("data-title",g(".label",g(this)).text().toLowerCase())});g("#search-template-keyword").on("keyup",function(AR){if(AR.keyCode==13){AR.preventDefault();return false}var AO=g("#select-template");var AS=g(".scroller",AO);var AQ=false;g(".template-item",AO).hide();var AN=g.trim(this.value.toLowerCase());if(AN){g('.template-item[data-title*="{0}"]'.format(AN),AO).show()}else{g(".template-item",AO).show();AQ=true}var AP=g(".template-item:visible",AO).length;Q(2);k[2].tinyscrollbar_update();if(AP==0){g(".empty-template",AO).show()}else{g(".empty-template",AO).hide()}return true});g("#search-template-keyword").on("keydown",function(AN){if(AN.keyCode==13){AN.preventDefault();return false}});l=g("#edit-page-dropdown .template-list .template-item input[type=radio]").thumbnailRadioCheckbox({thumbnailClass:"template-border",preselect:function(AO,AN){if(AN.is(":checked")){return false}if(o||Y){openConfirmDialog({title:vBulletin.phrase.get("switch_template"),message:vBulletin.phrase.get("template_changes_will_be_lost"),iconType:"warning",onClickYes:function(){o=false;Y=false;d=true;l.thumbnailRadioCheckbox("check",AN,true)}});return false}d=true;return true},select:function(AR,AN){g(".canvas-layout").addClass("h-hide");var AP=AN.closest(".template-item").data("screenlayoutid");g(".canvas-layout[data-layout-id="+AP+"]").removeClass("h-hide");b();AJ();g("#save-page-form #pagetemplateid-yes, #config_pagetemplateid").val(AN.val());g("#save-page-form .page-template-name").html(vBulletin.phrase.get("page_template_name_id",AN.closest(".template-item").find(".label").html(),AN.val()));if(d){g(".canvas-widget-list").empty();var AO=AN.closest(".template-item").data("widgetinstances");if(g.isArray(AO)&&AO.length>0){V=false;var AQ=[];g.each(AO,function(AS,AT){AQ.push({widgetid:AT.widgetid,widgetinstanceid:AT.widgetinstanceid})});D(AQ,true);a()}else{window.vBulletin.loadingIndicator.hide()}}g("body").removeClass("lnkNewPage").addClass("lnkEditPage");g("#save-page-form .new-page-template input").prop("disabled",true);g("#save-page-form .edit-page-template input").prop("disabled",false);d=true},unselect:function(){}});Q(2);k[2]=g("#select-template .template-list-container");k[2].tinyscrollbar({sizethumb:14,axis:"x",update:function(){if(g("#select-template .template-list-container").innerHeight()<g("#select-template .panel-header-text").height()){g("#select-template .panel-header-text").height(g("#select-template .template-list-container").innerHeight())}}})}else{window.vBulletin.loadingIndicator.hide();openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_templates"),iconType:"error"})}},error:function(AN,AM,AL){console.log("fetchPageTemplateList failed! error:"+AL);window.vBulletin.loadingIndicator.hide();openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_modules",AN.status),iconType:"error"})}})}function H(AL,AN,AM){g.ajax({url:vBulletin.getAjaxBaseurl()+"/uploader/set_logo",data:({filedataid:g("#header .site-logo img").attr("data-fileid"),styleselection:g("#header .site-logo img").attr("data-styleselection")}),type:"POST",dataType:"text",complete:function(){console.log("uploader/set_logo complete.");g("body").css("cursor","auto")},success:function(AO){console.log("saving site logo successful! result:"+AO);if(g.trim(AO)==="true"){g("#header .site-logo img").removeAttr("data-styleselection").removeAttr("data-fileid").attr("data-orig-src",g("#header .site-logo img").attr("src"));g("#main-navbar li").removeClass("h-disabled").find("a").removeClass("selected");g("#admin-navbar-strip-gutter").addClass("h-hide").find(".prompt-text").text("");g(document.body).removeClass("edit-mode lnkHeader").addClass("view-mode");g("#header .disable-overlay").hide();g("#main-navbar ul.secondary-nav").removeClass("h-disabled");if(typeof AL=="function"){AL()}}else{console.log("saving site logo failed!");openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_site_logo"),iconType:"error"});if(typeof AN=="function"){AN()}}},error:function(AQ,AP,AO){console.log("saving site logo failed! error:"+AO);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_site_logo_code",AQ.status),iconType:"error"});if(typeof AM=="function"){AM()}}})}function L(AL,AM){g.each(AL,function(AO,AN){var AP=g(('<div class="sub-channel channel" data-channel-id="{0}" data-parent-id="{6}">				<div class="avatar h-left"></div>				<div class="title"><a href="{1}{2}">{3}</a></div>				<div class="info">					<span class="label">'+vBulletin.phrase.get("last_post")+':</span>					<span class="title">{4}</span>				</div>				<div class="h-clear"></div>').format(AN.nodeid,pageData.baseurl,AN.url,AN.title,(AN.lastPostTitle?AN.lastPostTitle:"<em>"+vBulletin.phrase.get("none")+"</em>"),pageData.baseurl_core,AN.parentid)).appendTo(AM);L(AL[AO].subchannels,AP.eq(0))})}function j(AM,AL){g.each(AM,function(AN,AP){var AO=g.map(AP.subchannels,function(AS,AR){return AR}).length;var AQ=AG(AP.nodeid,AP.parentid,AP.title,AP.category,AL,AO);j(AP.subchannels,AQ)})}function M(){y.tabs("select",0);var AR=g("#add-modules").height();y.tabs("select",1);var AL=g("#change-layout").height();y.tabs("select",2);var AM=g("#select-template").height();g("#edit-page-dropdown .lnkSaveChanges").trigger("click");var AO=g("#save-page-form").height();y.tabs("select",0);var AQ=Math.max(AR,AL,AM,AO);var AN=g("#edit-page-dropdown .panel-header-text");AN.each(function(){var AS=g(this);AS.css("min-height",AQ-parseFloat(AS.css("margin-top"))-parseFloat(AS.css("margin-bottom"))-parseFloat(AS.css("padding-top"))-parseFloat(AS.css("padding-bottom")))});var AP=g("#edit-page-dropdown .panel-main-content");AP.each(function(){var AS=g(this);AS.css("min-height",AQ-parseFloat(AS.css("margin-top"))-parseFloat(AS.css("margin-bottom"))-parseFloat(AS.css("padding-top"))-parseFloat(AS.css("padding-bottom")))})}function Q(AL){var AM=g("#edit-page-dropdown #edit-content > .tabs > .tab:eq({0}) .list > .list-item".format(AL));AM.parent().width(Math.max(AM.outerWidth(true)*AM.filter(":visible").length),parseFloat(AM.parent().css("min-width")))}function AH(AL,AM){var AN=(AM&&AM.length>0)?g(".canvas-layout .canvas-widget").not(AM).find(".widget-content"):g(".canvas-layout .canvas-widget .widget-content");if(AL){AN.each(function(){if(g(this).is(":hidden")){g(this).closest(".canvas-widget").find(".widget-header .toggle-button").trigger("click",[true])}})}else{AN.each(function(){if(!g(this).is(":hidden")){g(this).closest(".canvas-widget").find(".widget-header .toggle-button").trigger("click",[true])}})}}function P(AM,AL){if(AL){if(AM.find(".widget-content").is(":hidden")){AM.find(".toggle-button").trigger("click",[true])}}else{if(!AM.find(".widget-content").is(":hidden")){AM.find(".toggle-button").trigger("click",[true])}}}function a(){if(!q){var AL=g(".canvas-layout:visible .canvas-widget.subchannel-widget");if(AL.length==1){AL.find(".close-button").hide()}else{AL.find(".close-button").show()}}}function J(AN,AL){var AM=AN.attr("data-widget-id");if(N[AM]==null){window.vBulletin.loadingIndicator.show();g("body").css("cursor","wait");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/fetch-widget-template",data:({widgetid:AM}),type:"POST",dataType:"json",complete:function(){window.vBulletin.loadingIndicator.hide();g("body").css("cursor","auto")},success:function(AO){console.log("Fetching module admin template successful");var AQ=g.trim(AO);if(AQ){var AP=g(AQ.replace(/\<\s*script[^\>]*\>(.*?)\<\s*\/\s*script\>/g,""));AP.attr("data-title",function(){var AR=g(".module-title",AP).clone();AR.find(".hide-on-viewmode").children().unwrap();AR.find("*:hidden").remove();return g.trim(AR.text()).toLowerCase()});N[AM]=AP;if(typeof AL=="function"){AL(AP.clone(true))}}},error:function(AQ,AP,AO){console.log("Fetching module admin template failed, error: "+AO);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_cloned_widget_template",AQ.status),iconType:"error"})}})}else{if(typeof AL=="function"){AL(N[AM].clone(true))}}}function K(AL,AM){g(".edit-mode .canvas-widget.youtube-widget .widget-content").css("visibility",AL);if(AM){AM.find(".widget-content").css("visibility",(AL=="hidden"?"visible":"hidden"))}}function AD(){g(document).off("click",".canvas-widget.default-widget:not(.js-search-widget) .edit-button").on("click",".canvas-widget.default-widget:not(.js-search-widget) .edit-button",function(){var AQ=g(this).closest(".canvas-widget");var AM=g("> .widget-header .module-title",AQ);(function(){var AR=AQ.data("widget-instance-id");if(vBulletin.sitebuilder.tempModuleHTMLCache["widgetinstance_"+AR]){if(g("#sb-temp-module-cache").length==0){g('<div id="sb-temp-module-cache" class="h-hide"></div>').appendTo("body")}var AS=g(vBulletin.sitebuilder.tempModuleHTMLCache["widgetinstance_"+AR]);if(AS.find(".widget-tabs").length>0||AS.is(".widget-tabs")){g("#sb-temp-module-cache").append(AS);delete vBulletin.sitebuilder.tempModuleHTMLCache["widgetinstance_"+AR]}}var AT=g("#sb-temp-module-cache .canvas-widget").filter(function(){return g(this).data("widget-instance-id")==AR});if(AT.length==1&&(AT.find(".widget-tabs").length>0||AT.is(".widget-tabs"))){AQ=AT}})();if(AQ.is(".js-search-widget")){return }g("body").css("cursor","wait");var AO=AQ.attr("data-widget-id");var AN;if(g("span.admin-only",AM).length>0){AN=g("span.admin-only",AM).text()}else{AN=g(".hide-on-viewmode",AM).length>0?g(".hide-on-viewmode",AM).text():AM.text()}var AP=AQ.data("widget-type")||"";g("#config-dialog .loader").show();g("#config-dialog .widget-name h1").html(AN);g("#config-dialog .dialog-content .widget-config-container").hide().empty().removeClass("error notice");g("#config-dialog").data("selected-module",AQ);K("hidden");g("#config-dialog").dialog("open");g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/widget/fetchConfigSchema",data:({widgetid:AO,widgetinstanceid:AQ.attr("data-widget-instance-id")||"",pagetemplateid:g("#config_pagetemplateid").val()||g("#select-template input[type=radio]:checked").val()||"",configtype:"admin"}),type:"POST",dataType:"json",complete:function(){g("body").css("cursor","auto")},success:function(Ah){console.log("fetchConfigSchema successful! result:"+JSON.stringify(Ah));if(Ah){g("#config_widgetid").val(Ah.widgetid);g("#config_widgetinstanceid").val(Ah.widgetinstanceid);g("#config_pagetemplateid, #save-page-form #pagetemplateid-yes, #save-page-form #pagetemplateid-new").val(Ah.pagetemplateid);AQ.attr("data-widget-instance-id",Ah.widgetinstanceid);if(!Ah.configs||Ah.configs.length==0){g("#config-dialog .widget-config-container").html(vBulletin.phrase.get("no_configurations_found")).addClass("notice");g("#btnSaveConfig").prop("disabled",true);g("#btnCloseConfig").focus()}else{var Ac=0;var AZ=g("#config-dialog .dialog-content .widget-config-container");g('<input type="hidden" name="data[widget_type]" />').addClass("widget-type").val(AP).appendTo(AZ);var Ag=false,Af=false,AV=false,Ae=false,AW,Ad=false,AR=(g("#debug-information").length==1);g.each(Ah.configs,function(Ao,Ak){var Aj;switch(Ak.type){case"ChannelSetup":g("#config-dialog .dialog-content .channel-config-dialog").css("display","block");return true;break;case"Text":Aj=g('<input type="text" name="data[{0}]" id="data[{0}]" tabindex="1" />'.format(Ak.name)).addClass("textbox config-textbox").val(Ak.defaultvalue||"");break;case"LongText":Aj=g('<textarea name="data[{0}]" id="data[{0}]" rows="3" tabindex="1" />'.format(Ak.name)).addClass("textbox config-textbox").val(Ak.defaultvalue||"");break;case"YesNo":var An={option_1:g('<input type="radio" value="1" name="data[{0}]" id="data[{0}_1]" tabindex="1" />'.format(Ak.name)),label_1:g("<label />").attr({"for":"data["+Ak.name+"_1]"}).text(vBulletin.phrase.get("yes")),option_0:g('<input type="radio" value="0" name="data[{0}]" id="data[{0}_0]" tabindex="1" />'.format(Ak.name)),label_0:g("<label />").attr({"for":"data["+Ak.name+"_0]"}).text(vBulletin.phrase.get("no"))};var As=An["option_"+Ak.defaultvalue];if(As){As.prop("checked",true)}Aj=g("<div />").append(An.option_1,An.label_1,An.option_0,An.label_0);break;case"Checkboxes":Aj=g("<div />");g.each(Ak.data,function(At,Av){var Au="";if(Ak.defaultvalue&&typeof Ak.defaultvalue[At]!="undefined"&&Ak.defaultvalue[At]==1){Au=' checked="checked"'}var Aw=g('<div><label><input type="checkbox" name="data[{0}][{1}]"{2} value="1" tabindex="1" class="js-checkbox-always-send" /> {3}</label></div>'.format(Ak.name,At,Au,Av));Aj.append(Aw)});break;case"Select":Ad=true;Aj=g('<select name="data[{0}]" tabindex="1" />'.format(Ak.name));var Am;if(Ak.data!=""){for(Am in Ak.data){if(Ak.defaultvalue==Am){g("<option />").attr("value",Am).attr("selected","selected").text(Ak.data[Am]).appendTo(Aj)}else{g("<option />").attr("value",Am).text(Ak.data[Am]).appendTo(Aj)}}}break;case"ChannelSelect":Ad=true;Aj=g('<select name="data[{0}]" tabindex="1" />'.format(Ak.name));var Aq=g('<optgroup label="{0}" />'.format(vBulletin.phrase.get("special_options"))),Al=g('<optgroup label="{0}" />'.format(vBulletin.phrase.get("channels"))),Ap=false,Ar=false;if(Ak.data){g.each(Ak.data,function(At,Au){var Av=null;if(Ak.defaultvalue==Au.nodeid){Av=g("<option />").attr("value",Au.nodeid).attr("selected","selected").html(Au.text)}else{Av=g("<option />").attr("value",Au.nodeid).html(Au.text)}if(Au.nodeid<1){Av.appendTo(Aq);Ap=true}else{Av.appendTo(Al);Ar=true}});if(Ap){Aq.appendTo(Aj)}if(Ar){Al.appendTo(Aj)}}break;case"ProfileFieldSelect":Ad=true;Aj=g('<select name="data[{0}]" tabindex="1" />'.format(Ak.name));if(Ak.data){g.each(Ak.data,function(At,Av){var Au=null;if(Ak.defaultvalue==Av.field){Au=g("<option />").attr("value",Av.field).attr("selected","selected").html(Av.title)}else{Au=g("<option />").attr("value",Av.field).html(Av.title)}Au.appendTo(Aj)})}break}$requiredMark=g("<div />").addClass("config-required-mark h-left").append(function(){return(Ak.isRequired==1)?"*":"&nbsp;"});if(Ak.isEditable==0){Aj.find("input").prop("disabled",false);Aj.prop("disabled",false)}var Ai=g("<div />").addClass("config-label h-left").addClass(Ak.name).html(Ak.label);if(AR){Ai.prop("title",Ak.name)}AZ.append(g("<div></div>").addClass(function(){return"h-clearfix config-row"+(((++Ac)%2!=0)?" odd":"")}).append(Ai,$requiredMark,g("<div></div>").addClass("config-value h-left").addClass(Ak.name).append(Aj)));if(Ak.name=="default_tab"){Ag=true}if(Ak.name=="display_tabs"){Af=true}if(Ak.name=="tab_order"){AV=true}if(Ak.name=="axd"){Ae=true}});var AS=null;var Ab=function(){AW=AL(AQ);var Al=AQ.attr("data-widget-default-tab"),Aj=g('select[name="data[default_tab]"]',AZ),Ak;Aj.empty();for(var Ai in AW){if(Af){if(!g('input:checkbox[value="'+AW[Ai].selector+'"]',AX).is(":checked")){continue}}else{if(!AW[Ai].displayed){continue}}Ak=g('<option value="'+AW[Ai].selector+'">'+AW[Ai].label+"</option>");if(AS&&AS==AW[Ai].selector){Ak.attr("selected","selected")}else{if(Al==AW[Ai].selector){Ak.attr("selected","selected")}}Aj.append(Ak)}};var AY=function(){AW=AL(AQ);var Aj=g(".config-value.tab_order",AZ),Ak,Al;Aj.empty().append("<ul>");for(var Ai in AW){if(Af){if(!g('input:checkbox[value="'+AW[Ai].selector+'"]',AX).is(":checked")){continue}}else{if(!AW[Ai].displayed){continue}}Ak=g('<li id="'+AW[Ai].selector+'">'+AW[Ai].label+"</li>");g("ul",Aj).append(Ak);Al=g('<input name="data[tab_order]['+AW[Ai].selector.substring(1)+']" value="'+Ai+'" type="hidden">');Aj.append(Al)}g("ul",Aj).sortable({stop:function(){var Am=g(this).sortable("toArray");Aj.find("input:hidden").remove();for(Ai in Am){Al=g('<input name="data[tab_order]['+Am[Ai].substring(1)+']" value="'+Ai+'" type="hidden">');Aj.append(Al)}}});g("ul",Aj).disableSelection()};if(Af){AW=AL(AQ);var AX=g(".config-value.display_tabs",AZ),Aa;for(var AU in AW){Aa=g('<label><input type="checkbox" name="data[display_tabs][]" value="'+AW[AU].selector+'" tabindex="1">'+AW[AU].label+"</label>");if(AW[AU].displayed){Aa.find("input:checkbox").attr("checked","checked")}AX.append(Aa)}if(Ag){g("input:checkbox",AX).on("click",function(){Ab();AY()})}}if(AV){AY();g('select[name="data[default_tab]"]',AZ).change(function(){AS=g(this).val()})}if(Ag){Ab()}if(Ae){var AT=g(".config-value.axd",AZ);AT.append('<button class="axd-edit-button button secondary" data-location="'+Ah.widgetinstanceid+'" tabindex="1">'+vBulletin.phrase.get("edit")+"</button>")}}}g("#config-dialog .dialog-content .widget-config-container").show();g("#config-dialog .loader").hide();if(Ad){g("#config-dialog .dialog-content .widget-config-container select").selectBox()}(function(){function Ai(){var Aj=g(this),Ak=Aj.next(".js-checkbox-always-send-hidden");if(Ak.length==0&&!Aj.prop("checked")){g('<input type="hidden" name="{0}" class="js-checkbox-always-send-hidden" value="0" />'.format(Aj.prop("name"))).insertAfter(Aj)}else{Ak.remove()}}g(".js-checkbox-always-send").off("click").on("click",Ai);g(".js-checkbox-always-send").each(Ai)})();g("#config-dialog .dialog-content .widget-config-container input,						#config-dialog .dialog-content .widget-config-container textarea,						#config-dialog .dialog-content .widget-config-container select,						#config-dialog .dialog-content .widget-config-container button").filter(function(){return g(this).is(":visible")}).first().focus()},error:function(AT,AS,AR){console.log("fetchConfigSchema failed! error:"+AR);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_configuration",AN),iconType:"error",onAfterClose:function(){g("#config-dialog").dialog("close")}});g("#config-dialog .loader").hide()}});return false});function AL(AN){var AM=[];g("ul.widget-tabs-nav li a, .widget-header ul.ui-tabs-nav li a, .widget-tabs-nav ul.ui-tabs-nav li a",AN).each(function(){var AO=g(this),AP;if(g(this).closest("li").hasClass("h-hide")){AP=false}else{AP=true}AM.push({selector:AO.attr("href"),label:AO.text(),displayed:AP})});return AM}}function b(){g(".edit-mode .canvas-layout:visible > .canvas-widget-list").width("").each(function(){g(this).width(g(this).width())})}function AJ(){if(g.browser.msie&&parseInt(g.browser.version,10)==8){var AL=g(".edit-mode .canvas-layout:visible > .canvas-widget-list");AL.each(function(){var AM=g(".canvas-widget",this),AS=g(this);var AN=AM.outerHeight(true)||50;var AO=AM.length*AM.outerHeight(true);var AR=AS.height()-AO;console.log("offset:",AR);if(AR>=0&&AR<AN){var AQ=g(window);var AP=AQ.scrollTop();AS.height(AS.height()+(AN-AR));AQ.scrollTop(AP);return false}else{if((AR>AN&&AS.height()>parseInt(AS.css("min-height"),10))||AR<0){var AQ=g(window);var AP=AQ.scrollTop();AS.height(AO+AN);AQ.scrollTop(AP);return false}}})}}function h(){window.console.log("Fetching page manager forums (initializeForumEditor)");vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/widget/fetchPageManagerForums",complete:function(){g("#config-dialog .loader").hide();g("body").css("cursor","auto")},success:function(AL){window.console.log("Successfully fetched page manager forums (initializeForumEditor)");s=true;var AN=g("<div>").addClass("channel-list");g.each(AL,function(AP,AR){var AQ=g.map(AR.subchannels,function(AT,AS){return AS}).length;var AO=AK(AN,AR.nodeid,AR.parentid,AR.title,AR.category,false,AQ);j(AR.subchannels,AO)});var AM=g("#top-level-forum .channel-config-dialog");AM.find(".channel-list").remove();u(AN);F(AN);AM.append(AN);g(document).on("mousedown",".main-channel-container > .channel-item-container > .channel-item .grip-icon",function(){g(this).closest(".main-channel-container").height(g(this).closest(".main-channel-container").height())});g(document).on("mousedown",".sub-channel-container > .channel-item-container > .channel-item .grip-icon",function(){g(this).closest(".sub-channel-container").height(g(this).closest(".sub-channel-container").height())});Y=false;W()},error_phrase:"error_fetching_channels"});g(document).on("click keydown",".channel-config-dialog .add-channel-fieldset .add-button, .channel-config-dialog .add-channel-fieldset input",function(AL){if(((AL.type=="click"||AL.which!=13)&&this.type=="text")||(AL.type=="keydown"&&this.type=="button"&&AL.which!=13)){return true}var AO=(this.type=="text")?g(this):g(this).prev();var AM=g.trim(AO.val());if(AM&&AM!=AO.prop("defaultValue")){var AN=g("#top-level-forum .channel-config-dialog .channel-list");AK(AN,"","",vBulletin.htmlEntities(AM),0,true,0);u(AN);W();AO.val("");if(this.type=="button"){AO.focus()}}else{openAlertDialog({title:vBulletin.phrase.get("warning_gcpuser"),message:vBulletin.phrase.get("please_enter_channel_title"),iconType:"warning",onAfterClose:function(){AO.focus()}})}});g(document).on("click",".channel-config-dialog .main-channel-container .channel-item .channel-title div",function(){g(this).hide();var AL=g(this).next();AL.show();AL.select();AL.focus()});g(document).on("keydown blur",".channel-config-dialog .main-channel-container .channel-item .channel-title input",function(AL){if(AL.type=="focusout"||(AL.type=="keydown"&&AL.which==13)){if(!g.trim(this.value)&&AL.type=="focusout"){this.value=this.defaultValue}if(g.trim(this.value)){g(this).hide();g(this).prev().html(vBulletin.htmlEntities(this.value));g(this).prev().show()}}});g(document).on("click",".channel-config-dialog .channel-item .category-to-channel a",function(){var AL=g(this).closest(".channel-item");AL.attr("data-switch-category",0);g(this).parent().removeClass("category-to-channel").addClass("channel-to-category");g(this).html(vBulletin.phrase.get("make_category"));return false});g(document).on("click",".channel-config-dialog .channel-item .channel-to-category a",function(){var AL=g(this).closest(".channel-item");AL.attr("data-switch-category",1);g(this).parent().removeClass("channel-to-category").addClass("category-to-channel");g(this).html(vBulletin.phrase.get("make_forum"));return false});g(document).on("click",".channel-config-dialog .channel-item .toggle-button",function(){AA(g(this));return false});g(document).on("click",".channel-config-dialog .channel-item .add-subchannel-button a",function(){var AL=g(this).parent().siblings(".toggle-button");AA(AL,true);var AN=g(this).closest(".channel-item-container");var AM=AG("","",vBulletin.phrase.get("new_channel"),0,AN,0);F(AN);AM.slideDown(100,function(){var AO=AN.find(".channel-item-inner").first().find(".num-subchannels");AO.text(parseInt(AO.text())+1);g(".channel-title div",AM).click();g(".channel-title input",AM).get(0).scrollIntoView(false);W()});return false});g(document).on("click",".channel-config-dialog .channel-list .channel-item .close-button",function(){var AL=g(this);var AM=g("> .sub-channel-container > .channel-item-container",AL.closest(".channel-item-container")).length>0;openConfirmDialog({title:vBulletin.phrase.get("remove_forum_q"),message:vBulletin.phrase.get("do_you_want_to_remove_forum",g(this).prev().text(),(AM)?" "+vBulletin.phrase.get("subchannels_will_be_deleted"):""),iconType:"warning",onClickYes:function(){var AR=AL.closest(".channel-item-container");var AP=AR.parent();var AO=AL.closest(".channel-item").attr("data-channel-id");g("body").css("cursor","wait");var AN=function(){AR.remove();if(AP.hasClass("main-channel-container")){AP.slideUp("fast",function(){g(this).remove()})}};var AQ=function(){g("body").css("cursor","auto")};if(AO){g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/content_channel/delete",data:{nodeid:AO},type:"POST",dataType:"json",complete:AQ,success:function(AS){console.log("Delete channel successful! result:"+JSON.stringify(AS));if(AS.errors){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get(AS.errors[0]),iconType:"error"})}else{AN()}},error:function(AU,AT,AS){console.log("Delete channel failed! result:"+AS);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_deleting_page",AU.status),iconType:"error"})}})}else{AN();AQ()}}})})}function r(AM){function AL(AO,AP,AN){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+("/ajax/render/{0}_list").format(AO),data:{page:AP},complete:function(){g("#config-dialog .loader").hide();g("body").css("cursor","auto")},success:function(AQ){g(("#top-level-{0} .channel-config-dialog").format(AO)).html(AQ);if(AN){vBulletin.pagination({context:("#top-level-{0} .channel-config-dialog").format(AO),onPageChanged:function(AR,AS){AL(AO,AR)}})}},error_phrase:"error_fetching_channels"})}AL(AM,1,true);g(document).on("click",".page_manager_table .channel_name div",function(){g(this).hide();var AN=g(this).next();AN.show();AN.select();AN.focus()});g(document).on("keydown blur",".page_manager_table .channel_name input",function(AP){if(AP.type=="focusout"||(AP.type=="keydown"&&AP.which==13)){if(!g.trim(this.value)&&AP.type=="focusout"){this.value=this.defaultValue}var AO=g.trim(this.value);var AN=g(this);if(AO&&AN.prev().html()!=AO){g("body").css("cursor","wait");vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/Content_Channel/update",data:{nodeid:AN.parents(".channel_row").data("nodeid"),data:{title:AO}},complete:function(){g("#config-dialog .loader").hide();g("body").css("cursor","auto")},success:function(AQ){AN.hide();AN.prev().html(AO);AN.prev().show()},error_phrase:"error_saving_page"})}}});g(document).on("click",".page_manager_table .delete",function(){var AN=g(this);openConfirmDialog({title:vBulletin.phrase.get("remove_channel_q"),message:vBulletin.phrase.get("do_you_want_to_remove_channel",AN.parents(".channel_row").find(".channel_name_val").text()),iconType:"warning",onClickYes:function(){g("body").css("cursor","wait");vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/content_channel/delete",data:{nodeid:AN.parents(".channel_row").data("nodeid")},complete:function(){g("body").css("cursor","auto")},success:function(AO){AN.parents(".channel_row").remove()}})}})})}var s=false;function I(){g("body").css("cursor","wait");AC=g("#manage-page .tabs").tabs({show:function(AL,AM){if(AM.index==0&&!s){h()}if(AM.index!=0&&Y){openConfirmDialog({title:vBulletin.phrase.get("exit_without_saving_page"),message:vBulletin.phrase.get("forum_changes_will_be_lost"),iconType:"warning",onClickYes:function(){Y=false}});return false}},select:function(AL,AM){}});AC.tabs("select",0);AE=g("#manage-pages").tabs({show:function(AL,AM){if((AM.index==1||AM.index==2)){r(g(AM.tab).data("top-level"))}}});AE.tabs("select",0);g("#manage-page-dropdown .lnkSaveChanges").on("click",function(){console.log("Saving forum/channel data");var AL=g(this);if(AL.hasClass("h-disabled")){console.log("We're busy saving already. Try again later.");return }AL.addClass("h-disabled");vBulletin.loadingIndicator.show();g("body").css("cursor","wait");var AM=[];function AN(AQ,AO,AP){var AR=g("> .channel-item-container",AQ);if(AR.length>0){AR.each(function(AT){var AS=g("> .channel-item",this);var AU=AS.attr("data-channel-id");var AV=AS.attr("data-parent-id");subchannelObj={nodeid:AU||"0",previousParentId:AV,title:g(".channel-title div",AS).html(),displayorder:AT+1,parentid:AP||"0",subchannels:[]};if(AS.attr("data-switch-category")!=null){subchannelObj.switchCategory=AS.attr("data-switch-category")}AO.subchannels.push(subchannelObj);AN(AS.next(".sub-channel-container"),AO.subchannels[AT],AU)})}}if(G.forum){g(".channel-config-dialog .channel-list .main-channel-container").each(function(AQ){var AP=g("> .channel-item-container > .channel-item",this);var AR=AP.attr("data-channel-id");var AS=AP.attr("data-parent-id");var AO={nodeid:AR,previousParentId:AS,title:g(".channel-title div",AP).html(),displayorder:AQ+1,subchannels:[]};if(AP.attr("data-switch-category")!=null){AO.switchCategory=AP.attr("data-switch-category")}AN(AP.next(".sub-channel-container"),AO,AR);AM.push(AO)});vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/widget/saveForums",data:{data:JSON.stringify(AM)},complete:function(){g("body").css("cursor","auto");vBulletin.loadingIndicator.hide();AL.removeClass("h-disabled")},success:function(AO){console.log("Forum/channel changes successfully saved");if(AO&&AO.forums&&AO.forums.length>0){Y=false;G.forum=false;location.reload(true)}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_forums"),iconType:"error"});return false}},error_phrase:"error_saving_channels_code"})}else{console.log("No forum/channel changes to save");vBulletin.loadingIndicator.hide();g("body").css("cursor","auto");AL.removeClass("h-disabled")}});g(document).on("click","#manage-page-dropdown .lnkExitWithoutSaving",function(){if(Y){openConfirmDialog({title:vBulletin.phrase.get("exit_without_saving_page"),message:vBulletin.phrase.get("do_you_want_to_exit_without_saving_page"),iconType:"warning",onClickYes:function(){location.reload(true)}})}else{location.reload(true)}})}function T(){g(document).on("focus click",".edit-mode .widget-content a, .edit-mode #channel-tabbar a, .edit-mode #btnSearch, .edit-mode #q",function(AS){this.blur();return false});if(!c){t()}if(!R){A()}else{l.thumbnailRadioCheckbox("check",g("#select-template .template-border.selected").next("input"),false);if(!q){g("#select-template .template-item input[value={0}]".format(g("#pagetemplateid-yes").val())).prev().trigger("click")}}k[1]=g("#change-layout .layout-list-container");k[1].tinyscrollbar({sizethumb:14,axis:"x",update:function(){if(g("#change-layout .layout-list-container").innerHeight()<g("#change-layout .panel-header-text").height()){g("#change-layout .panel-header-text").height(g("#change-layout .layout-list-container").innerHeight())}}});g("#config_pagetemplateid").val("");if(q){g("#save-page-form #pagetitle").val("");g("#save-page-form #pageurl").val("");g("#save-page-form #pagetemplateid").val("0");g("#save-page-form #pageid").val("0")}g("#edit-page-dropdown .lnkDeletePage").on("click",function(){openConfirmDialog({title:vBulletin.phrase.get("confirm_deletion_gcpglobal"),message:vBulletin.phrase.get("confirm_remove_page_desc"),buttonLabel:{yesLabel:vBulletin.phrase.get("delete_page"),noLabel:vBulletin.phrase.get("cancel")},iconType:"warning",onClickYes:function(){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/page/delete",data:{pageid:pageData.pageid},dataType:"json",complete:function(){g("body").css("cursor","auto")},success:function(AS){console.log("deleted page "+pageData.pageid);window.location.href=pageData.baseurl},error:function(AU,AT,AS){console.log("page delete  failed! result:"+AS);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_deleting_page",AU.status),iconType:"error"})}})}})});g("#edit-page-dropdown .lnkSaveChanges").on("click",function(){g("#edit-page-dropdown .tabs li").removeClass("ui-tabs-selected ui-state-active");g("#edit-page-dropdown .tabs .tab").addClass("ui-tabs-hide");g("#save-content").show();g("#save-page-form .edit-page-template").css("display","");g("#save-page-form .edit-page-template").prev("label").css("display","");if(g("body").hasClass("lnkNewPage")){g("#save-page-form .new-page-template input").prop("disabled",false);g("#save-page-form .edit-page-template input").prop("disabled",true)}else{if(!g("#pagetemplateid-yes").prop("checked")&&!g("#pagetemplateid-no").prop("checked")){g("#pagetemplateid-yes").prop("checked",true)}g("#save-page-form .edit-page-template input").prop("disabled",false);g("#save-page-form .new-page-template input").prop("disabled",true);if(q&&(!o&&!Y)){g("#save-page-form .edit-page-template").css("display","none");g("#save-page-form .edit-page-template").prev("label").css("display","none")}if(g("#pagetemplateid-yes").prop("checked")){g("#save-page-form #templatetitle").prop("disabled",false);g("#save-page-form #templatetitle-edit").prop("disabled",true);g("#save-page-form .page-template-name").removeClass("h-hide")}else{g("#save-page-form #templatetitle").prop("disabled",true);g("#save-page-form #templatetitle-edit").prop("disabled",false);g("#save-page-form .page-template-name").addClass("h-hide")}}});g(document).on("click","#edit-page-dropdown .lnkExitWithoutSaving",function(){if(o||Y||d||(!q&&(g("#pagetitle").val()!=g("#pagetitle").prop("defaultValue")||g("#pageurl").val()!=g("#pageurl").prop("defaultValue")))||(q&&(g("#pagetitle").val()!=""||g("#pageurl").val()!=""))){openConfirmDialog({title:vBulletin.phrase.get("exit_without_saving_page"),message:vBulletin.phrase.get("do_you_want_to_exit_without_saving_page"),iconType:"warning",onClickYes:function(){location.reload(true)}})}else{location.reload(true)}});var AL=0;g(window).on("resize.canvas",function(){clearTimeout(AL);AL=setTimeout(b,200)});var AO=function(AS){return'<label class="hide-icon module-button-item"><input type="checkbox" title="{0}" data-toggle-title="{1}"{2} /></label>'.format(vBulletin.phrase.get("check_to_hide_module"),vBulletin.phrase.get("uncheck_to_unhide_module"),AS?' checked="checked"':"")};g(".canvas-widget.container-widget .canvas-widget:not(.dummy-widget)").each(function(){var AS=g(this).hasClass("hidden-widget");g(".module-buttons .admin-only",this).prepend(AO(AS));if(AS){g(".module-buttons .admin-only .hide-icon input",this).trigger("click").prop("checked",true)}});var AR=function(AU,AV,AX){var AW=AV.item,AX=AV.item.hasClass("module-item");var AS=g("> .canvas-widget.container-widget {0}".format(AX?".module-item":".canvas-widget.container-widget"),this);if(AS.length>0){var AT=AS.closest(".canvas-widget.container-widget");if(AT.attr("data-widget-id")==AS.attr("data-widget-id")){if(AX){AS.remove()}else{if(AV.sender){AV.sender.sortable("cancel")}else{g(this).sortable("cancel")}}AP=true;openAlertDialog({title:vBulletin.phrase.get("move_not_allowed"),message:vBulletin.phrase.get("dropping_container_module_into_container_module_not_allowed"),iconType:"warning"});return true}return false}return false};var AN=function(AS){if(AS.parents(".canvas-widget.container-widget").length>0){if(g(".module-buttons .admin-only .hide-icon",AS).length==0){g(".module-buttons .admin-only",AS).prepend(AO())}}else{AS.removeClass("hidden-widget").find("> .widget-header .module-buttons .admin-only .hide-icon").remove()}};var AP=false;g(".edit-mode .canvas-layout .canvas-widget-list").sortable({revert:true,tolerance:"pointer",connectWith:".edit-mode .canvas-layout:visible .canvas-widget-list",placeholder:"canvas-widget canvas-widget-highlight drag-highlight h-clear",create:function(){b();AJ()},update:function(AS,AT){var AU=this;if(S){if(!AP){J(AT.item,function(AV){AT.item.replaceWith(AV);AV.filter(":not(.container-widget)").find(".toggle-button").trigger("click",[true]);if(!AR.apply(AU,[AS,AT])){AN(AV);AV.addClass("shadow").find(".widget-tabs").andSelf().filter(".widget-tabs").tabs();a();AV.parents(".canvas-widget.container-widget").find(".canvas-widget.dummy-widget").remove();var AW=AV.parents(".canvas-widget.container-widget");if(AW.length==1){AW.find(".canvas-widget-highlight").remove();AW.find(".module-item").remove()}}})}}else{if(!AR.apply(AU,[AS,AT])){AN(AT.item);a()}}o=true},out:function(AS,AT){},sort:function(AS,AT){if(X){S=true}var AU=AT.placeholder.closest(".canvas-widget.container-widget");if(AU.length==1&&AU.find(".canvas-widget:last-child").hasClass("canvas-widget-highlight")){AT.placeholder.css({"margin-bottom":0,"margin-top":-3})}else{AT.placeholder.css({"margin-bottom":"","margin-top":""})}},start:function(AS,AT){K("hidden",AT.item)},over:function(AS,AT){},stop:function(AT,AU){AP=false;AJ();S=false;AU.item.height("auto");K("visible");g(".canvas-layout .canvas-widget-list .canvas-widget-highlight").remove();var AS=g(".canvas-layout > .canvas-layout-row .canvas-widget-list > .canvas-widget.container-widget");g(".canvas-layout > .canvas-layout-row .canvas-widget-list > .canvas-widget.container-widget").each(function(){var AV=g(".canvas-widget-list",this);if(AV.children().length==0){AV.append('<div class="canvas-widget dummy-widget"><span>{0}</span></div>'.format(vBulletin.phrase.get("you_can_also_drag_and_drop_modules_here")))}else{if(AV.find(".canvas-widget.dummy-widget").length>0&&AV.find(".canvas-widget:not(.dummy-widget,.canvas-widget-highlight)").length>0){AV.find(".canvas-widget.dummy-widget").remove()}}})},receive:function(AS,AT){if(AT.item.hasClass("module-item")){AR.apply(this,[AS,AT,true])}},handle:".move-icon",items:".canvas-widget"}).find(".canvas-widget .widget-header").disableSelection();g(document).on("click",".edit-mode .canvas-widget .close-button",function(){var AS=g(this);openConfirmDialog({title:vBulletin.phrase.get("remove_module_q"),message:vBulletin.phrase.get("do_you_want_to_remove_module",AS.closest(".widget-header").find(".module-title").text()),iconType:"warning",onClickYes:function(){var AU=AS.closest(".canvas-widget"),AT=AU.parents(".canvas-widget.container-widget");AU.remove();AJ();a();o=true;if(AT.find(".canvas-widget").length==0){AT.find(".canvas-widget-list").append('<div class="canvas-widget dummy-widget"><span>{0}</span></div>'.format(vBulletin.phrase.get("you_can_also_drag_and_drop_modules_here")))}}})});g(document).on("click",".edit-mode .js-search-widget .edit-button",function(){K("hidden");AM(g(this).closest(".js-search-widget"));g("#search-config-dialog").dialog("open");return false});function AQ(AZ,AY){var AS=g("#edit-page-dropdown .lnkSaveChanges .label").text();if(!AY){if(!g.trim(g("#save-page-form #pagetitle").val())){openAlertDialog({title:AS,message:vBulletin.phrase.get("please_enter_page_name"),iconType:"warning",onAfterClose:function(){g("#save-page-form #pagetitle").focus()}});return false}if(g("body").hasClass("lnkEditPage")){var AX=g("#save-page-form #pagetemplateid-yes");var AT=g("#save-page-form #pagetemplateid-no");if(!AX.prop("checked")&&!AT.prop("checked")){openAlertDialog({title:AS,message:vBulletin.phrase.get("please_choose_overwrite_template_options"),iconType:"warning",onAfterClose:function(){g("#save-page-form #pagetemplateid-yes").focus()}});return false}else{if(AT.prop("checked")){var AU=g("#save-page-form #templatetitle-edit");var Ac=g.trim(AU.val());if(!Ac||Ac==AU.prop("defaultValue")){openAlertDialog({title:AS,message:vBulletin.phrase.get("please_enter_new_template_name"),iconType:"warning",onAfterClose:function(){g("#save-page-form #templatetitle-edit").focus()}});return false}openConfirmDialog({title:AS,message:vBulletin.phrase.get("applying_new_template",g("#save-page-form #templatetitle-edit").val()),buttonLabel:{yesLabel:vBulletin.phrase.get("save_page"),noLabel:vBulletin.phrase.get("cancel")},iconType:"warning",onClickYes:function(){g("#save-page-form #btnOK").trigger("click",true)}});return false}else{if(AX.prop("checked")){if(q&&(!o&&!Y)){g("#save-page-form #btnOK").trigger("click",true)}else{openConfirmDialog({title:AS,message:vBulletin.phrase.get("overwrite_template_continue"),buttonLabel:{yesLabel:vBulletin.phrase.get("save_page"),noLabel:vBulletin.phrase.get("cancel")},iconType:"warning",onClickYes:function(){g("#save-page-form #btnOK").trigger("click",true)}})}return false}}}}else{var AU=g("#save-page-form #templatetitle-new");var Ac=g.trim(AU.val());if(!Ac||Ac==AU.prop("defaultValue")){openAlertDialog({title:AS,message:vBulletin.phrase.get("please_enter_new_template_name"),iconType:"warning",onAfterClose:function(){g("#save-page-form #templatetitle-new").focus()}});return false}}}var Ab=g(".canvas-layout:visible");z=Ab.attr("id");g("#save-page-form #screenlayoutid").val(Ab.attr("data-layout-id"));function AV(Af){var Ag={widgetId:Af.attr("data-widget-id"),widgetInstanceId:(Af.attr("data-widget-instance-id")||"0")};if(Af.hasClass("container-widget")){var Ad=[];var Ae=[];g("div.canvas-widget-list > div.canvas-widget",Af).each(function(Ah){if(!g(this).hasClass("hidden-widget")){Ae.push(g(this).attr("data-widget-instance-id"))}Ad.push(AV(g(this)))});Ag.subModules=Ad;Ag.displaySubModules=Ae}return Ag}g('input[type=hidden][name*="displaysections"]',Ab).clone().appendTo(g("#moduleData").empty());g("#"+z+" > .canvas-layout-row > div.canvas-widget-list").each(function(){var Ad=[];var Ae=Z(this);g(this).children("div.canvas-widget").each(function(){Ad.push(AV(g(this)))});g('#save-page-form input[name="displaysections['+Ae+']"]').val(JSON.stringify(Ad))});var Aa={};var AW=g("#save-page-form").serializeArray();g.each(AW,function(Ad,Ae){Aa[Ae.name]=Ae.value});g.ajax({url:vBulletin.getAjaxBaseurl()+"/admin/savepage",data:{input:Aa,url:window.location.href},type:"POST",dataType:"json",complete:function(){g("body").css("cursor","auto")},success:function(Ad){console.log("savePage successful! result:"+JSON.stringify(Ad));if(Ad&&Ad.url!=null){window.location.href=pageData.baseurl+Ad.url}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get(Ad.errors[0]),iconType:"error"})}},error:function(Af,Ae,Ad){console.log("saveChannelWidgetConfig failed! result:"+Ad);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_page",Af.status),iconType:"error"})}})}g(document).on("click","#save-page-form #btnOK",AQ);g("#config-dialog").dialog({title:vBulletin.phrase.get("module_configuration"),autoOpen:false,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,height:500,width:800,dialogClass:"dialog-container config-dialog-container input-dialog",open:function(){g("#config-dialog .loader").show();g("body").css("cursor","wait")},create:function(){g(document).on("submit",".sitebuilder-widget-form",function(){function AT(AX){g("body").css("cursor","wait");g("#config-dialog .action-buttons button").prop("disabled",true);var AY=g("#config-dialog").data("selected-module");var AV=g(AX).find("#config_widgetid");var AU=AY.hasClass("category-customized_copy");var AW=AU?AX.action.replace(/saveAdminConfig/,"saveDefaultConfig"):AX.action;g.ajax({url:AW,type:AX.method,data:(g(AX).serializeArray()),dataType:"json",success:function(Aa){console.log("saveAdminConfig successful!");g("body").css("cursor","auto");if(Aa&&Aa.data){var Ae=g("#config-dialog").data("selected-module");var AZ=Aa.data.title||Aa.data.searchResultTitle||Aa.data.searchTitle;if(AZ){Ae.find(".module-title .admin-only").text(vBulletin.phrase.get("x_module",AZ))}switch(Aa.data.widget_type){case"custom-html-widget":Ae.find(".widget-content").html(Aa.data.html);P(Ae,true);break;case"video-widget":var Ab=Aa.data.embed_data;if(Ab){var Af=Ae.find(".widget-content .videocontainer");if(Af.length==0){Af=g("<div />").addClass("videocontainer").appendTo(Ae.find(".widget-content"))}var Ad={code:Ab.code,provider:Ab.provider,width:"100%",height:260};g.post(vBulletin.getAjaxBaseurl()+"/ajax/render/bbcode_video",Ad,function(Ag){if(Ag){Af.empty().append(Ag);P(Ae,true)}},"json");Ae.find(".widget-content").find(".note").addClass("h-hide")}break}var Ac=g('select[name="data[default_tab]"]',g(AX));if(Ac.length>0){Ae.attr("data-widget-default-tab",Ac.val())}Y=true}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error",onAfterClose:function(){g("#config-dialog .action-buttons button").prop("disabled",false)}});g("#config-dialog .loader").hide()}g("#config-dialog").dialog("close")},error:function(Ab,Aa,AZ){console.log("saveAdminConfig failed! error:"+AZ);g("body").css("cursor","auto");openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_configuration_module",g("#config-dialog .widget-name h1").text()),iconType:"error",onAfterClose:function(){g("#config-dialog .action-buttons button").prop("disabled",false)}});g("#config-dialog .loader").hide()}})}var AS=this;AT(AS);return false});g("#btnCloseConfig").on("click",function(){g(".channel-config-dialog .channel-list").empty();g("#config-dialog").dialog("close")})},close:function(){K("visible");g("#config-dialog .dialog-content .channel-config-dialog").css("display","none");g("#config-dialog .action-buttons button").prop("disabled",false)}});g("#pagetitle").on("keyup blur",function(AS){if(q){g("#pageurl").val(this.value.replace(/[^\w-]+/g,""))}return true});g("#save-page-form #pagetemplateid-yes").on("click",function(){g("#save-page-form .template-name").addClass("h-hide");g("#save-page-form #templatetitle").prop("disabled",false);g("#save-page-form #templatetitle-edit").prop("disabled",true);g("#save-page-form .page-template-name").removeClass("h-hide")});g("#save-page-form #pagetemplateid-no").on("click",function(){g("#save-page-form .template-name").removeClass("h-hide");g("#save-page-form #templatetitle").prop("disabled",true);g("#save-page-form #templatetitle-edit").prop("disabled",false);g("#save-page-form .page-template-name").addClass("h-hide")});function AM(AS){if(typeof AF.search_config_dialog=="undefined"){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/render/dialog_search_config",success:function(AT){AF.search_config_dialog=AT;g("body").append(AT);AM(AS)},error_phrase:"error_fetching_dialog"});return }if(AS){g("#search-config-dialog").data("search-widget",AS)}g("#search-config-dialog").dialog({title:vBulletin.phrase.get("edit_search_module"),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:800,dialogClass:"dialog-container search-config-dialog-container input-dialog",close:function(){K("visible")},open:function(){var AT=this;g("#customSearchDialog",AT).addClass("h-invisible");g("body").css("cursor","wait");setTimeout(function(){vBulletin.search=vBulletin.search||{};var AW=function(){AB=new vBulletin.search.SearchControl("#customSearchDialog");p(AB)};var AV=g("#search-config-dialog").data("search-widget");var AY={id:AV.attr("data-widget-id"),instanceid:AV.attr("data-widget-instance-id")};if(typeof vBulletin.search.SearchControl=="undefined"){var AX=["/js/jquery/jquery.qtip.min.js","/js/tag-editor.js","/js/sb_search.js"];var AU=function(){if(AX.length==0){g("body").css("cursor","auto");g("#customSearchDialog",AT).removeClass("h-invisible");AW();return }var AZ=AX.shift();g.getScript(vBulletin.getAjaxBaseurl()+AZ+"?"+pageData.simpleversion,AU).error(function(Ad,Ac,Aa){var Ab=(Aa&&Aa.message)?"{0}: {1}".format(vBulletin.phrase.get("error"),Aa.message):"HTTP {0}: {1}".format(Ad.status,Ad.statusText);g("#search-config-dialog").dialog("close");openAlertDialog({title:vBulletin.phrase.get("error"),message:"{0}<br /><br />({1})".format(vBulletin.phrase.get("error_loading_search_config_script"),Ab),iconType:"error"})}).complete(function(){})};AU()}else{g("#customSearchDialog",AT).removeClass("h-invisible");AW()}},1);Y=false},create:function(){g("#btnSaveSearchConfig").on("click",function(){g("body").css("cursor","wait");var AU=g("#search-config-dialog").data("search-widget");var AZ={id:AU.attr("data-widget-id"),instanceid:AU.attr("data-widget-instance-id")};var AW={pageid:pageData.pageid,widgetid:AZ.id,widgetinstanceid:AZ.instanceid,pagetemplateid:g("#select-template input[type=radio]:checked").val(),searchJSON:{}};var AX=g("#searchTitle");if(AX.length>0&&g.trim(AX.val()).length>0){AW.searchTitle=g.trim(AX.val());AX.data("defaultValue",AW.searchTitle)}var AT=g("#resultsPerPage");if(AT.length>0&&g.trim(AT.val()).length>0){AW.resultsPerPage=g.trim(AT.val());AT.data("defaultValue",AW.resultsPerPage)}var AV=g("#searchconfig_hide_avatars_yes");if(AV.length>0&&AV.prop("checked")){AW.hide_avatars="1";AV.data("defaultValue","1")}else{AW.hide_avatars="0";AV.data("defaultValue","0")}var AY=g(".js-searchmodule-show-at-breakpoints");if(AY.length>0){AW.show_at_breakpoints={desktop:1,small:1,xsmall:1};AY.find("input").each(function(){var Aa=g(this);switch(Aa.prop("name")){case"show_at_breakpoints[desktop]":AW.show_at_breakpoints.desktop=Aa.prop("checked")?1:0;break;case"show_at_breakpoints[small]":AW.show_at_breakpoints.small=Aa.prop("checked")?1:0;break;case"show_at_breakpoints[xsmall]":AW.show_at_breakpoints.xsmall=Aa.prop("checked")?1:0;break}});AY.data("defaultValue",AW.show_at_breakpoints)}AW.searchJSON=AB.load();g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/widget/saveSearchWidgetConfig",data:{data:JSON.stringify(AW)},type:"POST",dataType:"json",complete:function(){g("body").css("cursor","auto")},success:function(Aa){console.log("savesearchWidgetConfig successful! result:"+JSON.stringify(Aa));if(Aa&&Aa.widgetinstanceid>0&&Aa.searchJSON){AU.attr("data-widget-instance-id",Aa.widgetinstanceid);AU.find(".main-title").text(AW.searchTitle);g("#config_widgetinstanceid").val(Aa.widgetinstanceid);g("#config_pagetemplateid").val(Aa.pagetemplateid);g("#pagetemplateid-new").val(Aa.pagetemplateid);g("#search-config-dialog").dialog("close");P(AU,true);Y=true}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_search_config"),iconType:"error"})}},error:function(Ac,Ab,Aa){console.log("saveSearchWidgetConfig failed! result:"+Aa);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_search_config_code",Ac.status),iconType:"error"})}})});g("#btnCancelSearchConfig").on("click",function(){function AT(){g("#search-config-dialog").dialog("close");AB.set("{}");var AY=g("#search-config-dialog #searchTitle");AY.val(AY.data("defaultValue"));var AV=g("#search-config-dialog #resultsPerPage");AV.val(AV.data("defaultValue"));var AW=g("#search-config-dialog #searchconfig_hide_avatars_yes");if(AW.data("defaultValue")=="1"){AW.prop("checked",true)}else{g("#search-config-dialog #searchconfig_hide_avatars_no").prop("checked",true)}var AZ=g("#search-config-dialog .js-searchmodule-show-at-breakpoints");if(AZ.length>0){var AX=AZ.data("defaultValue");AZ.find("input").each(function(){var Aa=g(this);switch(Aa.prop("name")){case"show_at_breakpoints[desktop]":Aa.prop("checked",AX.desktop?"checked":"");break;case"show_at_breakpoints[small]":Aa.prop("checked",AX.small?"checked":"");break;case"show_at_breakpoints[xsmall]":Aa.prop("checked",AX.xsmall?"checked":"");break}})}}if(Y){var AU=g(this);openConfirmDialog({title:vBulletin.phrase.get("cancel_edit"),message:vBulletin.phrase.get("do_you_want_to_cancel_editing_search_module"),iconType:"warning",onClickYes:AT})}else{AT()}})}})}g("#blog-category-dialog").dialog({title:vBulletin.phrase.get("edit_blog_categories"),autoOpen:false,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:800,dialogClass:"dialog-container blog-category-dialog-container input-dialog",close:function(){K("visible")},open:function(){var AS=this;Y=false},create:function(){g("#blog-category-dialog #btnSaveCategories").on("click",function(){g("body").css("cursor","wait");g("#blog-category-dialog dialog-content loader").show();var AS=g("#search-config-dialog").data("blog-category-widget");var AT={id:AS.attr("data-widget-id"),instanceid:AS.attr("data-widget-instance-id")};vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/widget/saveBlogCategories",data:{},complete:function(){g("body").css("cursor","auto");g("#blog-category-dialog dialog-content loader").hide()},success:function(AU){g("#blog-category-dialog dialog-content widget-config-container").html(AU)},error_phrase:"error_saving_blog_categories"})});g("#blog-category-dialog #btnNewCategory").on("click",function(){});g("#blog-category-dialog #btnCloseCategories").on("click",function(){if(Y){var AS=g(this);openConfirmDialog({title:vBulletin.phrase.get("cancel_edit"),message:vBulletin.phrase.get("do_you_want_to_cancel_editing_blog_categories_module"),iconType:"warning",onClickYes:g("#blog-category-dialog").dialog("close")})}else{g("#blog-category-dialog").dialog("close")}})}})}function p(AL){var AN=g(this).closest(".canvas-widget");var AM=g("#search-config-dialog").data("search-widget");var AO={id:AM.attr("data-widget-id"),instanceid:AM.attr("data-widget-instance-id")};g.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/widget/fetchSearchConfig",data:({widgetid:AO.id,widgetinstanceid:AO.instanceid||"",pagetemplateid:g("#config_pagetemplateid").val()||g("#select-template input[type=radio]:checked").val()||"",configtype:"admin"}),type:"POST",dataType:"json",complete:function(){g("body").css("cursor","auto")},success:function(AP){console.log("fetchConfig successful! result:"+JSON.stringify(AP));if(AP.searchTitle){var AS=g("#searchTitle");if(AS.length>0){AS.val(AP.searchTitle)}}if(AP.resultsPerPage){var AQ=g("#resultsPerPage");if(AQ.length>0){AQ.val(AP.resultsPerPage)}}if(AP.hide_avatars&&parseInt(AP.hide_avatars,10)==1){var AR=g("#searchconfig_hide_avatars_yes");if(AR.length>0){AR.prop("checked",true)}}else{g("#searchconfig_hide_avatars_no").prop("checked",true)}if(AP.show_at_breakpoints){var AT=g("#search-config-dialog .js-searchmodule-show-at-breakpoints");if(AT.length>0){AT.find("input").each(function(){var AU=g(this);switch(AU.prop("name")){case"show_at_breakpoints[desktop]":AU.prop("checked",AP.show_at_breakpoints.desktop?"checked":"");break;case"show_at_breakpoints[small]":AU.prop("checked",AP.show_at_breakpoints.small?"checked":"");break;case"show_at_breakpoints[xsmall]":AU.prop("checked",AP.show_at_breakpoints.xsmall?"checked":"");break}})}}AL.set(AP.searchJSON||{},AP.contentTypes||{},AP.channels||{});g("#config-dialog .dialog-content .widget-config-container").show();g("#search-config-dialog .form_layout .form_row .field_column select").selectBox();g("#config-dialog .loader").hide()},error:function(AR,AQ,AP){console.log("fetchConfigSchema failed! error:"+AP);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_retrieving_configuration",widgetName),iconType:"error",onAfterClose:function(){g("#config-dialog").dialog("close")}});g("#config-dialog .loader").hide()}})}g(document).ready(function(){x()})})(jQuery);