"].join("");e(o).html(r),i.axis&&"x"===i.axis?(n=parseInt(e(o).find(".aops-scroll-outer").height()),e(o).find(".aops-scroll-inner").height(n+i.adjust_container)):(n=parseInt(e(o).find(".aops-scroll-outer").width()),e(o).find(".aops-scroll-inner").width(n+i.adjust_container)),i.$scrollbar=e(o),i.$content=e(o).find(".aops-scroll-content"),AoPS.Ui.buildAopsScrollbar(i)}e.fn.aopsscroll=function(t,s){return this.each((function(){e.data(this,"plugin_aopsscroll")||e.data(this,"plugin_aopsscroll",new o(this,t,s))}))}}(jQuery),AoPS.Ui.ui_main_loaded=!0);
;AoPS.GoToHash=function(e){var s=e.substring(1).replace(/^([a-zA-Z0-9\-]*).*/,"$1");if(s){var n=$("#"+s).length?$("#"+s):$("a[name="+s+"]");if(canNavResize&&n.offset()){var a=n.offset().top;$("#header").hasClass("shrunken-header")?a-=$("#header").height():a-=2*$("#header").height(),$("body,html").animate({scrollTop:a},300,"swing")}}};var canNavResize=!1,getWindowWidth=function(){return window.innerWidth},isMobile=function(){return window.matchMedia("(max-width: 700px)").matches};$(document).ready((function(){var e=getWindowWidth();$(".menubar-label-link-outer").on("click",(function(e){var s,n,a,i,o,t;isMobile()&&(s=this,n=$(s).next().find(".dropdown-content"),a=$(s).parent(),i=$(a).height(),o=$(n).height(),t=i,t=i>o+12?i-o-6:i+o+6,$(a).height(t))})),$(window).on("resize",(function(s){if(getWindowWidth()!==e)if(e=getWindowWidth(),isMobile()){$(".menubar-labels").css({display:"none"});var n=$("body").height(),a=$("#header-wrapper").height();$(".menubar-labels").height(n-a),$(".menubar-label").each((function(e){$(this).height("auto")}))}else $(".menubar-label").each((function(e){$(this).height(16)})),$(".menubar-labels").css({display:"flex",minHeight:0}),$(".menubar-labels").height("auto")})),$(".menubar-hamburger").on("click",(function(e){var s=$("body").height(),n=$("#header-wrapper").height();"none"===$(".menubar-labels").css("display")?($(".menubar-labels").css({display:"block"}),$(".menubar-labels").css({height:"auto",minHeight:s-n+"px"})):$(".menubar-labels").css({display:"none"})})),$("#mobile-search-icon").on("click",(function(e){var s=$("body").height(),n=$("#header-wrapper").height();"none"===$(".menubar-labels").css("display")&&($(".menubar-labels").css({display:"block"}),$(".menubar-labels").css({height:"auto",minHeight:s-n+"px"})),$("#mobile-search-input").focus()})),$(".dropdown-content a").on("click",(function(e){isMobile()&&$(".menubar-labels").css({display:"none"})})),$(".superuser").on("click",(function(e){$.post("/ajax.php",{action:"toggle-superuser"},(function(e){e.response&&e.response.success?(AoPS.Ui.Flyout.display("Sucessfully "+(e.response.superuser?"enabled":"disabled")+" superuser permissions."),$(".superuser").text(e.response.superuser?"Disable Superuser":"Enable Superuser")):AoPS.Ui.Flyout.display(e.error_msg)}))}));var s=!1,n=!1,a=_.throttle(_.bind((function(e){n&&(s=!1,n=!1,$("body,html").stop().animate()),$(window).scrollTop()>5?$("#header").addClass("shrunken-header"):$("#header").removeClass("shrunken-header")}),this),200),i=$("body"),o=i.hasClass("community")||i.hasClass("school-class-page")||i.hasClass("mediawiki")||i.hasClass("cart")||i.hasClass("ebooks")||i.hasClass("dashboard")||i.hasClass("resources")||i.hasClass("small-header")||i.hasClass("no-nav-resize");isMobile()||o||(canNavResize=!0,window.location.hash&&AoPS.GoToHash(window.location.hash),a(),$(window).on("scroll",a)),$("div.slide-button").on("click",(function(){if(!s){s=!0,n=!1;var e=$(".callouts-container").offset().top;isMobile()||(e-=2*$("#main-menubar").height()),$("body,html").animate({scrollTop:e},1200,"swing",(function(){s=!1}))}})),document.body.addEventListener("wheel",(function(){n=!0})),$(window).on("resize",(function(e){isMobile()||canNavResize||o?isMobile()&&canNavResize&&(canNavResize=!1,$("#header").removeClass("shrunken-header"),$(window).off("scroll",a)):(canNavResize=!0,$(window).on("scroll",a))})),window.addEventListener("hashchange",(function(){setTimeout((function(){AoPS.GoToHash(window.location.hash)}),10)})),$(".menubar-label").on("click",(function(e){if($(document).width()<=700){var s=$(e.currentTarget);s.height()<50&&$([document.documentElement,document.body]).animate({scrollTop:s.offset().top-15},500)}}))}));
;AoPS.Utils=function(r){var t;return r.getKeyChain=function(r,t){if(_.isObject(r))return _.isArray(t)||(t=_.toArray(arguments).slice(1)),_.reduce(t,(function(r,t){if(!(!r||!r.hasOwnProperty(t)))return r[t]}),r)},r.hasKeyChain=function(){var t=r.getKeyChain.apply(this,arguments);return!_.isUndefined(t)},r.initKeyChain=function(r,t,e){return _.isArray(t)?_.isUndefined(e)&&(e={}):(t=_.toArray(arguments).slice(1),e={}),_.reduce(t,(function(r,n,o){var i=o===t.length-1?e:{};return r.hasOwnProperty(n)||(r[n]=i),r[n]}),r)},r.natSortBy=function(r,t,e){var n=new Intl.Collator("en",{numeric:!0});return r.sort((function(r,o){return(e?-1:1)*n.compare(""+t(r),""+t(o))}))},r.natSort=function(t,e){return r.natSortBy(t,(function(r){return r}),e)},r.Class=((t=function(){}).extend=function r(t){return function(e){var n,o,i;return(o=function(){}).prototype=t.prototype,n=new o,_.extend(n,e),i=function(){this.initialize&&this.initialize.apply(this,arguments)},i.prototype=n,i.extend=r(i),i}}(t),t),r}(AoPS.Utils||{});var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(r){var t,e,n,o,i,a,h,c="",f=0;for(r=Base64._utf8_encode(r);f>2,i=(3&t)<<4|(e=r.charCodeAt(f++))>>4,a=(15&e)<<2|(n=r.charCodeAt(f++))>>6,h=63&n,isNaN(e)?a=h=64:isNaN(n)&&(h=64),c=c+this._keyStr.charAt(o)+this._keyStr.charAt(i)+this._keyStr.charAt(a)+this._keyStr.charAt(h);return c},decode:function(r){var t,e,n,o,i,a,h="",c=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");c>4,e=(15&o)<<4|(i=this._keyStr.indexOf(r.charAt(c++)))>>2,n=(3&i)<<6|(a=this._keyStr.indexOf(r.charAt(c++))),h+=String.fromCharCode(t),64!==i&&(h+=String.fromCharCode(e)),64!==a&&(h+=String.fromCharCode(n));return h=Base64._utf8_decode(h)},_utf8_encode:function(r){r=r.replace(/\r\n/g,"\n");for(var t="",e=0;e127&&n<2048?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t},_utf8_decode:function(r){for(var t="",e=0,n=0,o=0,i=0;e191&&n<224?(o=r.charCodeAt(e+1),t+=String.fromCharCode((31&n)<<6|63&o),e+=2):(o=r.charCodeAt(e+1),i=r.charCodeAt(e+2),t+=String.fromCharCode((15&n)<<12|(63&o)<<6|63&i),e+=3);return t}};
;AoPS.Utils.initKeyChain(AoPS,"Ajax"),AoPS.Ajax=function(e){var t,i,s=AoPS.Utils;function n(t,i,s){var n=i.ajax_data,o=i.callback,r=i.timeout||t.timeout;return i.action&&(n.a=i.action),AoPS.session&&(n.aops_logged_in=AoPS.session.logged_in,n.aops_user_id=AoPS.session.user_id,n.aops_session_id=AoPS.session.id),s||(s={checkQueue:function(){},signalComplete:function(){}}),$.ajax({url:t.script_path,data:n,dataType:"json",type:"POST",timeout:r,error:function(t,i){s.checkQueue(),s.signalComplete(),e.handleError(o,t,i)},success:function(e){s.checkQueue(),s.signalComplete();var i=!e.hasOwnProperty("error_code");o(i,e),_.each(t.global_handlers,(function(t){t(i,e)}))}})}return e.handleError=function(e,t,i){var s=parseInt(t.status);200!==s||t.responseText.length?"abort"===i?e(!1,{response:{},error_code:"E_AJAX_CANCEL",error_msg:"The request was cancelled by the calling code."}):"timeout"===i?e(!1,{response:{},error_code:"E_AJAX_TIMEOUT",error_msg:"Something took too long to happen, and your browser gave up. Please check your internet connection, then try again."}):"parsererror"===i?(console.log(t.responseText),e(!1,{response:{},error_code:"E_AJAX_BADRETURN",error_msg:"You have come across a temporary error with our website. Please try again in an hour, and let us know if you continue to experience problems."})):e(!1,404===s?{response:{},error_code:"E_AJAX_404",error_msg:"The requested script does not exist."}:{response:{},error_code:"E_AJAX_UNKNOWN",error_msg:"Something went wrong. Please check your internet connection, then try again."}):e(!0,{response:{}})},t=s.Class.extend({initialize:function(e){this.processing_id=0,this.processing_xhr=null,this.next_id=1,this.window_size=!e||e<1?1:e,this.processing_size=0,this.queue_id_list=[],this.queue_table={}},getRunningId:function(){return this.processing_id},checkQueue:function(){if(this.processing_id=this.queue_id_list.pop(),this.processing_xhr=null,this.processing_id){var e=this.queue_table[this.processing_id];if(!e)return this.checkQueue();delete this.queue_table[this.processing_id],this.processing_xhr=e.processFunction(e.data,this)}else this.processing_id=0},signalComplete:function(){this.processing_size-=1},cancelId:function(e){var t;return this.queue_table[e]?((t=this.queue_table[e])&&t.data.callback(!1,{response:{},error_code:"E_AJAX_CANCEL",error_msg:"The request was cancelled by the calling code."}),delete this.queue_table[e],!0):!(this.processing_id!==e||!this.processing_xhr||!this.processing_xhr.abort)&&(this.processing_xhr.abort(),!0)},addToQueue:function(e,t,i){var s=this.next_id;return this.next_id+=1,this.queue_table[s]={data:e,processFunction:t},i?this.queue_id_list.push(s):this.queue_id_list=[s].concat(this.queue_id_list),this.processing_size0&&(this.timeout=n.timeout),o=500,_.isFinite(n.filter_interval)&&(o=n.filter_interval),o>0&&(this.filter_object=new e.RepetitionFilter(o)),this.last_queue_id=0,this.queue_object=i,this.use_queue=!n.hasOwnProperty("use_queue")||!!n.use_queue,this.use_queue&&n.separate_queue&&(this.queue_object=new t(n.window_size))},addGlobalHandler:function(e){return!!_.isFunction(e)&&(this.global_handlers.push(e),!0)},removeGlobalHandler:function(e){var t=this.global_handlers.length;return this.global_handlers=_.reject(this.global_handlers,(function(t){return t===e}),this),this.global_handlers.length',new Handlebars.SafeString(i)}return Handlebars.registerHelper("equals",(function(e,t,i){return e==t?i.fn(this):i.inverse(this)})),e.AutocreateMixin={setCreateFunction:function(e){this.createFunction=e},getOrCreate:function(e,t){t=t||{};var i=_.omit(t,["delay_add"]),s=this.get(e);if(s||_.isFunction(this.createFunction))return s||(s=this.createFunction(e))&&!t.delay_add&&this.add(s,i),s}},e.TemplateMixin={setTemplate:function(e,t){"#"!==e[0]&&(e="#"+e),this.compiledTemplate=AoPS.View.compileTemplate(e),this.compiledTemplate||console.log("WARNING: Template ID "+e+" not found"),this.use_root_el=!!t,this.rendered_tpl_before=!1},setTemplateAndUseRootEl:function(e){this.setTemplate(e,!0)},renderTopOnly:function(){var e,t;this.compiledTemplate?""===(e=$.trim(this.compiledTemplate({})))||(this.use_root_el?this.rendered_tpl_before||(t=$($.parseHTML(e)).empty(),this.$el.replaceWith(t),this.setElement(t),this.rendered_tpl_before=!0):this.rendered_tpl_before=!0):this.$el.empty()},renderTemplate:function(e){var t,i;this.compiledTemplate?""===(t=$.trim(this.compiledTemplate(e)))||(this.use_root_el?this.rendered_tpl_before?(this.$el.empty(),this.$el.append($($.parseHTML(t)).contents())):(i=this.$el.html(t).contents(),this.$el.replaceWith(i),this.setElement(i),this.rendered_tpl_before=!0):(this.$el.html(t),this.rendered_tpl_before=!0)):this.$el.empty()}},Handlebars.registerHelper("SUBVIEWLOC",i),Handlebars.registerHelper("subviewloc",i),e.SubviewMixin={reorderAtLocation:function(e,i,s){t.initKeyChain(this,["subviews",e],[]);var n=this.subviews[e].length;if(n){var o=this.subviews[e][n-1];i=_.bind(i,this);var a=_.map(this.subviews[e],(function(e){return{cmp:i(e),view:e}}),this);if(a.sort((function(e,t){return e.cmp',AoPS.Page.$loader=$($.parseHTML(AoPS.Page.loader_html)),AoPS.Page.buildLoader=function(){return AoPS.Page.$loader.clone()},AoPS.Page.Model=Backbone.Model.extend({initialize:function(){this.set("elements",{}),this.set("active_elements",[]),this.set("locations",[]),this.set("active_locations",[])},fetchElement:function(e){var t=e.hasOwnProperty("id")?this.findExistingElement(e.id):null;return _.isUndefined(t)||_.isNull(t)?t=this.createElement(e):"backbone"===t.type&&(t.dom_element=t.view.$el),t},findExistingElement:function(e){var t=this.get("elements");return t.hasOwnProperty(e)?t[e]:null},createElement:function(e){var t,o;return e.hasOwnProperty("type")&&"backbone"!==e.type?"jQuery_object"===e.type&&(e.hasOwnProperty("jQuery_object")||(console.log("You tried to initiate a jQuery_object element without sending the object!"),console.log("The id is "+e.id)),t={id:e.id,dom_element:e.jQuery_object,type:"jQuery_object",no_save:!!e.no_save,onAddToPage:e.hasOwnProperty("onAddToPage")?e.onAddToPage:function(){},onRemoveFromPage:e.hasOwnProperty("onRemoveFromPage")?e.onRemoveFromPage:function(){}}):(o=e.constructor(),t={id:e.id,dom_element:o.$el,type:"backbone",view:o,no_save:!!e.no_save,onAddToPage:"function"==typeof o.onAddToPage?function(e){o.onAddToPage(e)}:function(){},onRemoveFromPage:"function"==typeof o.onRemoveFromPage?function(){o.onRemoveFromPage()}:function(){}}),e.no_save||this.insertElement(t),t},insertElement:function(e){this.get("elements")[e.id]=e},activateElement:function(e){var t=this.fetchElement(e);return this.get("active_elements").push(t),t},fetchLocation:function(e){var t=_.find(this.get("locations"),(function(t){return t.id===e}));return _.isUndefined(t)&&(t=this.createLocation(e)),t},createLocation:function(e){var t={id:e,dom_element:$($.parseHTML('')),is_active:!1};return this.get("locations").push(t),t},activateLocation:function(e){e.is_active=!0,this.get("active_locations").push(e)},clearActiveArrays:function(){this.set("active_elements",[]),this.set("active_locations",[])}}),AoPS.Page.View=Backbone.View.extend({classes:[],$breadcrumbs_wrapper:$("#breadcrumbs-wrapper"),$breadcrumbs_bar:$("#breadcrumbs .crumb-wrapper"),initialize:function(){this.$subheader=$("#subheader"),0===this.$subheader.length&&(this.$subheader=$('').css({width:"100%","text-align":"center"}),$("#header").after(this.$subheader)),this.$error_window=$("#page_error_window"),0===this.$error_window.length&&(this.$error_window=$('').css({width:"100%","text-align":"left"})),this.$loader=AoPS.Page.buildLoader()},findActiveElement:function(e){return _.find(this.model.get("active_elements"),(function(t){return t.id===e}))},showElement:function(e){var t,o=this.model.activateElement(e);return e.hasOwnProperty("location")?"subheader"===e.location?this.$subheader.append(o.dom_element):((t=this.model.fetchLocation(e.location)).is_active||(this.model.activateLocation(t),this.$el.append(t.dom_element)),t.dom_element.append(o.dom_element)):this.$el.append(o.dom_element),o.dom_element.trigger("added_to_page",e.hasOwnProperty("on_add_settings")?e.on_add_settings:{}),o.onAddToPage(e.hasOwnProperty("on_add_settings")?e.on_add_settings:{}),_.clone(o)},showElements:function(e){var t=[];return _.each(e,_.bind((function(e){t.push(this.showElement(e))}),this)),t},hideElement:function(e){e&&(e.dom_element.detach(),"backbone"===e.type&&e.view.$el.detach(),e.onRemoveFromPage(),e.no_save&&"backbone"===e.type&&e.view.close&&e.view.close())},clearPage:function(e){var t=_.extend({remove_modals:!0,hide_loader:!0,remove_all:!0,remove_classes:!0},e);t.remove_modals&&AoPS.Ui.Modal.closeAllModals(),t.hide_loader&&this.hideLoader(),t.remove_classes&&this.clearClasses(),t.remove_all&&(_.each(this.model.get("active_elements"),this.hideElement,this),_.each(this.model.get("active_locations"),(function(e){e.is_active=!1,e.dom_element.detach()})),this.model.clearActiveArrays()),this.showBreadcrumbs()},removeElement:function(e){var t;0!==e.length&&(t=this.model.findExistingElement(e),this.hideElement(t),this.model.set("active_elements",_.without(this.model.get("active_elements"),t)))},forgetElement:function(e){var t;0!==e.length&&(t=this.model.findExistingElement(e),_.isUndefined(t)||(this.hideElement(t),this.model.set("active_elements",_.without(this.model.get("active_elements"),t)),this.model.set("elements",_.without(this.model.get("elements"),t))))},addClass:function(e){this.$el.addClass(e),this.classes.push(e)},removeClass:function(e){this.$el.removeClass(e),this.classes=_.without(this.classes,e)},setClass:function(e){this.clearClasses(),this.addClass(e)},clearClasses:function(){_.each(this.classes,_.bind((function(e){this.$el.removeClass(e)}),this)),this.classes=[]},throwError:function(e){var t;switch(this.clearPage(),e.error_type){case"unregistered":t="You must be signed in to view this page.";break;case"custom":t=e.error_msg}this.$error_window.html(t),this.showElement({id:"page-error-window-"+this.cid,type:"jQuery_object",jQuery_object:this.$error_window})},hideBreadcrumbs:function(){this.$breadcrumbs_wrapper.hide()},showBreadcrumbs:function(){this.$breadcrumbs_wrapper.show()},showLoader:function(){this.$loader.is(":visible")||this.$el.append(this.$loader)},hideLoader:function(){this.$loader.detach()},setBreadcrumbs:function(e,t){var o=_.map(e||[],(function(e,o){var i=e.text,n=e.no_stay?"":" "+(t||"data-stay");return e.url&&(i='"+i+""),''+i+""}));this.$breadcrumbs_bar.html($.parseHTML(o.join(' ')))},setTitle:function(e){document.title=e}}),AoPS.Page.setBreadcrumbs=function(e,t){var o=_.map(e||[],(function(e,o){var i=e.text,n=e.no_stay?"":" "+(t||"data-stay");return e.url&&(i=""+i+""),''+i+""}));$("#breadcrumbs .crumb-wrapper").html($.parseHTML(o.join(' ')))},AoPS.Page.showBreadcrumbs=function(){$("#breadcrumbs-wrapper").show()},AoPS.Page.hideBreadcrumbs=function(){$("#breadcrumbs-wrapper").hide()},AoPS.Page.constructPage=function(e){return new AoPS.Page.View({model:new AoPS.Page.Model,id:e})};
;AoPS.AskAoPS=AoPS.AskAops={display:function(a){var o=['
','
',"
Ask AoPS
","I have a question about: ",'
','','','','','','','',"
","
",'
','
Have a general question about Art of Problem Solving? Let us know below.
','','','','','','','','','
','',"
","
","
"];o=o.join("\n"),AoPS.Ui.Modal.showPlain({body:o,width:"75%",onClose:this.onClose,scrollable:!1,frame_class:"askaops-modal",height:"",max_height:""}),$(".askaops-modal").parent(".aops-modal-wrapper").addClass("askaops-modal-wrapper"),void 0!==a&&setTimeout((function(){"class"===a?($(".askaops input[name='askaops-category'][value=class]").prop("checked",!0),AoPS.AskAoPS.onChange()):"book"===a&&($(".askaops input[name='askaops-category'][value=book]").prop("checked",!0),AoPS.AskAoPS.onChange())}),1),this.onShow()},onChange:function(a){var o=$(".askaops input[name='askaops-category']:checked").val(),s=["Have a general question about Art of Problem Solving?","Let us know below.","View our Privacy Policy."].join(" "),e=["Please tell us about your student's math background, including","their grade level, recent math classes, and contest experience","(if any), as well as your goals for choosing books. You can also","find suggestions on our ",'Recommendations page.',"View our Privacy Policy."].join(" "),r=["Please tell us about your student's math background, including","their grade level, recent math classes, and contest experience","(if any), as well as your goals for choosing a course. You can","also find suggestions on our",'Recommendations page.',"Visit ","Frequently Asked Questions for quick answers to common class questions.","View our Privacy Policy."].join(" "),n=["Have a question about an order? Let us know below.","View our Privacy Policy."].join(" "),t=["Have a question about your current class? Let us know below.",'Visit Frequently Asked Questions',"for quick answers to common class questions.","
Specific questions about homework problems or assignments","should be posted to your course's message board.","Extension requests can be made from your class homepage.
","View our Privacy Policy."].join(" ");switch($("#askaops-username").hide(),$("#askaops-ordernumber").hide(),$("#askaops-course").hide(),o){case"general":$("#askaops-blurb").html(s);break;case"book":$("#askaops-blurb").html(e);break;case"class":$("#askaops-blurb").html(r);break;case"order":$("#askaops-blurb").html(n),$("#askaops-ordernumber").show();break;case"myclass":$("#askaops-blurb").html(t),$("#askaops-username").show(),$("#askaops-course").show();break;case"technical":$("#askaops-username").show(),$("#askaops-blurb").html(["Please include a detailed description of the error or issue you ","are experiencing.","View our Privacy Policy."]);break;case"other":$("#askaops-blurb").html("View our Privacy Policy.")}},onSubmit:function(){$("#askaops-submit").off("click",AoPS.AskAoPS.onSubmit);var a=$(".askaops input[name='askaops-category']:checked").val();$.post("/m/contact/ajax.php",{action:"email",type:a,username:$("#askaops-username").val(),email:$("#askaops-email").val(),name:$("#askaops-name").val(),subject:$("#askaops-subject").val(),message:$("#askaops-message").val(),orderid:$("#askaops-ordernumber").val(),course:$("#askaops-course").val(),url:window.location.href},(function(a){if(a.error_msg)$("#askaops-error").html(a.error_msg).show(),$("#askaops-submit").on("click",AoPS.AskAoPS.onSubmit);else{AoPS.Ui.Modal.closeTopModal();AoPS.Ui.Modal.showAlertQuick(["
Thank you. We have received your comment or question.
","
One of our staff members will respond to you within two","business days.