function trackHeap(n,t){t||(t={});window.heap&&window.heap.track(n,t)}function getSeriesIndex(){return"/Store/StoreFront/Index"}function getQueryStringParameterByName(n){n=n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var i=new RegExp("[\\?&]"+n+"=([^&#]*)"),t=i.exec(location.search);return t==null?"":decodeURIComponent(t[1].replace(/\+/g," "))}function queryStringCategoryIdVariable(){return"cat"}function queryStringCategoryId(){return getQueryStringParameterByName(queryStringCategoryIdVariable)}function queryStringAuthorIdVariable(){return"aut"}function queryStringAuthorId(){return GetQueryStringParameterByName(queryStringAuthorIdVariable)}function queryStringOrderByIdVariable(){return"orderBy"}function queryStringOrderById(){return getQueryStringParameterByName(queryStringOrderByIdVariable)}var Client;!function(n){var t=function(t,i){var r,u;this.element=n(t);this.picker=n('<div class="slider"><div class="slider-track"><div class="slider-selection"><\/div><div class="slider-handle"><\/div><div class="slider-handle"><\/div><\/div><div class="tooltip"><div class="tooltip-arrow"><\/div><div class="tooltip-inner"><\/div><\/div><\/div>').insertBefore(this.element).append(this.element);this.id=this.element.data("slider-id")||i.id;this.id&&(this.picker[0].id=this.id);r=this.element.data("slider-tooltip")||i.tooltip;this.tooltip=this.picker.find(".tooltip");this.tooltipInner=this.tooltip.find("div.tooltip-inner");this.orientation=this.element.data("slider-orientation")||i.orientation;switch(this.orientation){case"vertical":this.picker.addClass("slider-vertical");this.stylePos="top";this.mousePos="pageY";this.sizePos="offsetHeight";this.tooltip.addClass("right")[0].style.left="100%";break;default:this.picker.addClass("slider-horizontal").css("width",this.element.outerWidth());this.orientation="horizontal";this.stylePos="left";this.mousePos="pageX";this.sizePos="offsetWidth";this.tooltip.addClass("top")[0].style.top=-this.tooltip.outerHeight()-14+"px"}this.min=this.element.data("slider-min")||i.min;this.max=this.element.data("slider-max")||i.max;this.step=this.element.data("slider-step")||i.step;this.value=this.element.data("slider-value")||i.value;this.value[1]&&(this.range=!0);this.selection=this.element.data("slider-selection")||i.selection;this.selectionEl=this.picker.find(".slider-selection");this.selection==="none"&&this.selectionEl.addClass("hide");this.selectionElStyle=this.selectionEl[0].style;this.handle1=this.picker.find(".slider-handle:first");this.handle1Stype=this.handle1[0].style;this.handle2=this.picker.find(".slider-handle:last");this.handle2Stype=this.handle2[0].style;u=this.element.data("slider-handle")||i.handle;switch(u){case"round":this.handle1.addClass("round");this.handle2.addClass("round");break;case"triangle":this.handle1.addClass("triangle");this.handle2.addClass("triangle")}if(this.range?(this.value[0]=Math.max(this.min,Math.min(this.max,this.value[0])),this.value[1]=Math.max(this.min,Math.min(this.max,this.value[1]))):(this.value=[Math.max(this.min,Math.min(this.max,this.value))],this.handle2.addClass("hide"),this.value[1]=this.selection=="after"?this.max:this.min),this.diff=this.max-this.min,this.percentage=[(this.value[0]-this.min)*100/this.diff,(this.value[1]-this.min)*100/this.diff,this.step*100/this.diff],this.offset=this.picker.offset(),this.size=this.picker[0][this.sizePos],this.formater=i.formater,this.layout(),this.touchCapable)this.picker.on({touchstart:n.proxy(this.mousedown,this)});else this.picker.on({mousedown:n.proxy(this.mousedown,this)});if(r==="show")this.picker.on({mouseenter:n.proxy(this.showTooltip,this),mouseleave:n.proxy(this.hideTooltip,this)});else this.tooltip.addClass("hide")};t.prototype={constructor:t,over:!1,inDrag:!1,showTooltip:function(){this.tooltip.addClass("in");this.over=!0},hideTooltip:function(){this.inDrag===!1&&this.tooltip.removeClass("in");this.over=!1},layout:function(){this.handle1Stype[this.stylePos]=this.percentage[0]+"%";this.handle2Stype[this.stylePos]=this.percentage[1]+"%";this.orientation=="vertical"?(this.selectionElStyle.top=Math.min(this.percentage[0],this.percentage[1])+"%",this.selectionElStyle.height=Math.abs(this.percentage[0]-this.percentage[1])+"%"):(this.selectionElStyle.left=Math.min(this.percentage[0],this.percentage[1])+"%",this.selectionElStyle.width=Math.abs(this.percentage[0]-this.percentage[1])+"%");this.range?(this.tooltipInner.text(this.formater(this.value[0])+" : "+this.formater(this.value[1])),this.tooltip[0].style[this.stylePos]=this.size*(this.percentage[0]+(this.percentage[1]-this.percentage[0])/2)/100-(this.orientation==="vertical"?this.tooltip.outerHeight()/2:this.tooltip.outerWidth()/2)+"px"):(this.tooltipInner.text(this.formater(this.value[0])),this.tooltip[0].style[this.stylePos]=this.size*this.percentage[0]/100-(this.orientation==="vertical"?this.tooltip.outerHeight()/2:this.tooltip.outerWidth()/2)+"px")},mousedown:function(t){var i,u,f,r;if(this.touchCapable&&t.type==="touchstart"&&(t=t.originalEvent),this.offset=this.picker.offset(),this.size=this.picker[0][this.sizePos],i=this.getPercentage(t),this.range?(u=Math.abs(this.percentage[0]-i),f=Math.abs(this.percentage[1]-i),this.dragged=u<f?0:1):this.dragged=0,this.percentage[this.dragged]=i,this.layout(),this.touchCapable)n(document).on({touchmove:n.proxy(this.mousemove,this),touchend:n.proxy(this.mouseup,this)});else n(document).on({mousemove:n.proxy(this.mousemove,this),mouseup:n.proxy(this.mouseup,this)});return this.inDrag=!0,r=this.calculateValue(),this.element.trigger({type:"slideStart",value:r}).trigger({type:"slide",value:r}),!1},mousemove:function(n){var t,i;return this.touchCapable&&n.type==="touchmove"&&(n=n.originalEvent),t=this.getPercentage(n),this.range&&(this.dragged===0&&this.percentage[1]<t?(this.percentage[0]=this.percentage[1],this.dragged=1):this.dragged===1&&this.percentage[0]>t&&(this.percentage[1]=this.percentage[0],this.dragged=0)),this.percentage[this.dragged]=t,this.layout(),i=this.calculateValue(),this.element.trigger({type:"slide",value:i}).data("value",i).prop("value",i),!1},mouseup:function(){this.touchCapable?n(document).off({touchmove:this.mousemove,touchend:this.mouseup}):n(document).off({mousemove:this.mousemove,mouseup:this.mouseup});this.inDrag=!1;this.over==!1&&this.hideTooltip();this.element;var t=this.calculateValue();return this.element.trigger({type:"slideStop",value:t}).data("value",t).prop("value",t),!1},calculateValue:function(){var n;return this.range?(n=[this.min+Math.round(this.diff*this.percentage[0]/100/this.step)*this.step,this.min+Math.round(this.diff*this.percentage[1]/100/this.step)*this.step],this.value=n):(n=this.min+Math.round(this.diff*this.percentage[0]/100/this.step)*this.step,this.value=[n,this.value[1]]),n},getPercentage:function(n){this.touchCapable&&(n=n.touches[0]);var t=(n[this.mousePos]-this.offset[this.stylePos])*100/this.size;return t=Math.round(t/this.percentage[2])*this.percentage[2],Math.max(0,Math.min(100,t))},getValue:function(){return this.range?this.value:this.value[0]},setValue:function(n){this.value=n;this.range?(this.value[0]=Math.max(this.min,Math.min(this.max,this.value[0])),this.value[1]=Math.max(this.min,Math.min(this.max,this.value[1]))):(this.value=[Math.max(this.min,Math.min(this.max,this.value))],this.handle2.addClass("hide"),this.value[1]=this.selection=="after"?this.max:this.min);this.diff=this.max-this.min;this.percentage=[(this.value[0]-this.min)*100/this.diff,(this.value[1]-this.min)*100/this.diff,this.step*100/this.diff];this.layout()}};n.fn.slider=function(i,r){return this.each(function(){var f=n(this),u=f.data("slider"),e=typeof i=="object"&&i;u||f.data("slider",u=new t(this,n.extend({},n.fn.slider.defaults,e)));typeof i=="string"&&u[i](r)})};n.fn.slider.defaults={min:0,max:10,step:1,orientation:"horizontal",value:5,selection:"before",tooltip:"show",handle:"round",formater:function(n){return n}};n.fn.slider.Constructor=t}(window.jQuery);var ApprovalOfferPageForm=function(n){var t=this;n.Response===0&&(n.Response=undefined);ko.utils.extend(t,ko.mapping.fromJS(n))},ApprovalOfferPage=function(n,t){var i=this;console.log(n);ko.utils.extend(i,new Store(n,t,{}));i.ProductPreviews=ko.observableArray([]);i.showProductPreviews=function(t){var u=".product-preview-gallery-mobile",r=_.find(n.ApprovalOffer.Products,function(n){return n.Id===t}),f;if(r){if(!r.ProductPreviews||r.ProductPreviews.length===0){common.NotifyWithDuration("No previews available for this product",5e3);return}i.ProductPreviews(r.ProductPreviews);common.HeapEvent("ApprovalOffer.ProductPreview",{code:r.Code,name:r.Name});f={delegate:"a",type:"image",preload:[0,2],gallery:{enabled:!0},zoom:{enabled:!0}};$(u).magnificPopup(f);$(u).magnificPopup("open")}};i.AddAllToCart=function(){return i.AddMultipleProductPrices(n.ApprovalOffer.ProductPriceIds).then(function(){window.location=n.CartUrl})};i.Feedback=ko.observable(n.ApprovalOffer.Comment?n.ApprovalOffer.Comment:"");i.HasFeedback=ko.observable(!!n.ApprovalOffer.Comment);i.SubmitFeedback=function(){t.SaveApprovalOfferFeedback(n.ApprovalOffer.Id,i.Feedback()).then(function(){i.HasFeedback(!0);common.Notify("Your feedback has been submitted")})}},ApprovalPageForm=function(n){var t=this;n.Response===0&&(n.Response=undefined);ko.utils.extend(t,ko.mapping.fromJS(n));t.PasswordConfirm=ko.observable("");t.KeepingProducts=ko.computed(function(){return t.Response()=="1"?t.Products():_.filter(t.Products(),function(n){return n.IsKeepingBook()})});t.ReturningProducts=ko.computed(function(){return t.Response()=="2"?t.Products():_.filter(t.Products(),function(n){return!n.IsKeepingBook()})});t.ChangingProducts=ko.computed(function(){return _.filter(t.Products(),function(n){return n.IsAddingEbook()})});t.Response.subscribe(function(n){(n=="1"||n=="3"||n=="21")&&_.each(t.Products(),function(n){n.IsKeepingBook(!0);n.IsAddingEbook(!1)});n=="2"&&_.each(t.Products(),function(n){n.IsKeepingBook(!1);n.IsAddingEbook(!1)})});t.OrderHasParty=ko.computed(function(){return t.HasParty()||t.HasRespondingParty()});t.ShowRegistrationFlow=ko.computed(function(){return t.ChangingProducts().length>0&&!t.OrderHasParty()});t.ExpectedProductReturnDate(moment());t.ExpectedInvoicePaymentDate(moment(t.InvoiceDueDate()));t.ExtensionDate(moment().add(7,"days").format("YYYY-MM-DD"));t.CardExpiryMonth(undefined);t.CardExpiryYear(undefined);t.CalculateBookPriceDifference=function(n){return n.IsKeepingBook()&&!n.IsAddingEbook()?0:n.IsKeepingBook()&&n.IsAddingEbook()?n.ComboPrice()-n.OriginalPrice():!n.IsKeepingBook()&&n.IsAddingEbook()?n.EbookPrice()-n.OriginalPrice():!n.IsKeepingBook()&&!n.IsAddingEbook()?-n.OriginalPrice():0};t.UpdatedInvoiceTotal=ko.computed(function(){var n=_.map(t.Products(),function(n){return t.CalculateBookPriceDifference(n)});return t.OriginalInvoiceTotal()+_.sum(n)});t.InvoiceTotal=ko.computed(function(){var i=t.UpdatedInvoiceTotal(),n=t.OriginalInvoiceTotal();switch(t.Response()){case"1":case"3":case"21":n=i;break;case"2":n=0}return n});t.SetSchoolInvoicing=function(n){t.IsSchoolInvoicing(n)};t.ConfigureValidation=function(){ko.validation.init({registerExtenders:!0,insertMessages:!0,messagesOnModified:!0,errorElementClass:"has-error",errorMessageClass:"help-block",decorateElement:!0,decorateInputElement:!0,decorateElementOnModified:!0},!0);t.Response.extend({required:{message:"*"}});t.ResponderName.extend({required:{message:"Required"}});t.ExpectedInvoicePaymentDate.extend({required:{message:"Required",onlyIf:function(){return t.IsSchoolInvoicing()}}});t.ExpectedProductReturnDate.extend({required:{message:"Required",onlyIf:function(){return t.Response()=="2"||t.Response()=="3"}}});t.CardNumber.extend({required:{message:"Required",onlyIf:function(){return!t.IsSchoolInvoicing()}},minLength:15,maxLength:19});t.NameOnCard.extend({required:{message:"Required",onlyIf:function(){return!t.IsSchoolInvoicing()}}});t.CardExpiryMonth.extend({required:{message:"Required",onlyIf:function(){return!t.IsSchoolInvoicing()}},number:!0,minLength:1,maxLength:2,min:1,max:12});t.CardExpiryYear.extend({required:{message:"Required",onlyIf:function(){return!t.IsSchoolInvoicing()}},number:!0,minLength:1,maxLength:5,min:(new Date).getFullYear()});t.EmailAddress.extend({required:{message:"Required",onlyIf:function(){return t.ShowRegistrationFlow()}}});t.Password.extend({required:{message:"Required",onlyIf:function(){return t.ShowRegistrationFlow()}}});t.FirstName.extend({required:{message:"Required",onlyIf:function(){return t.ShowRegistrationFlow()&&!t.EmailExists()}}});t.LastName.extend({required:{message:"Required",onlyIf:function(){return t.ShowRegistrationFlow()&&!t.EmailExists()}}});t.PasswordConfirm.extend({required:{message:"Required",onlyIf:function(){return t.ShowRegistrationFlow()&&!t.EmailExists()}}});t.PasswordConfirm.extend({mustEqual:{params:t.Password,onlyIf:function(){return t.ShowRegistrationFlow()&&!t.EmailExists()}}})};t.GetObject=function(){var n=ko.mapping.toJS(t);return n.ExpectedInvoicePaymentDate=moment(n.ExpectedInvoicePaymentDate).format("YYYY-MM-DD"),n.ExpectedProductReturnDate=moment(n.ExpectedProductReturnDate).format("YYYY-MM-DD"),n.CardNumber&&(n.CardNumber=n.CardNumber.replace(/\s/g,"")),n}},ApprovalPage=function(n,t){var i=this;ko.utils.extend(i,new Store(n,t,{}));i.FormData=ko.validatedObservable(new ApprovalPageForm(n.ApprovalOrder));i.FormData().ConfigureValidation();i.ShowPaymentError=ko.observable(!1);i.PaymentErrorDetails=ko.observable("");i.Processing=ko.observable(!1);i.Submitted=ko.observable(!1);i.CanSubmit=ko.computed(function(){return i.FormData.errors().length===0});i.ScrollToTop=function(){$("#top").scrollintoview()};i.Submit=function(){if(i.ShowPaymentError(!1),i.FormData.errors&&i.FormData.errors().length>0){i.FormData.errors.showAllMessages();return}i.Processing(!0);i.ScrollToTop();var n=i.FormData().GetObject(),r=function(){i.Processing(!1);i.Submitted(!0)},u=function(n){if(console.log(n),i.Processing(!1),n.responseJSON){var t=n.responseJSON;console.log(t);t.HasError?(i.PaymentErrorDetails(t.ErrorMessage),i.ShowPaymentError(!0)):common.ProcessAjaxError(n)}else common.ProcessAjaxError(n)};t.SaveApprovalResponse(n).then(r,u)};i.ShowEmailError=ko.observable(!1);i.ShowLoginPanel=ko.observable(!1);i.ShowRegisterPanel=ko.observable(!1);i.CheckEmail=function(){var n=i.FormData().EmailAddress(),r=function(n){i.FormData().EmailExists(!!n);i.ShowLoginPanel(!!n);i.ShowRegisterPanel(!n)};t.UserSearch(n).then(r)}},Author=function(n){var t=this;ko.utils.extend(t,n);t.last=ko.observable(!1);t.Url=ko.computed(function(){return"/Store/Author/Detail/"+t.Code});t.DisplayName=ko.computed(function(){return t.FirstName+" "+t.LastName})},AuthorDetailPage=function(n,t,i){var r=this;ko.utils.extend(r,new Store(n,t,i))},AuthorDetails=function(n){var t=this;ko.utils.extend(t,new Author(n));t.PromotionTextParagraph=n.PromotionTextParagraph},AuthorList=function(n,t,i){var r=this;ko.utils.extend(r,new Store(n,t,i))},Basket=function(n,t,i){var r=this;ko.utils.extend(r,new Store(n,t,i));r.id=n.Id;r.basketLines=ko.observableArray();r.wishlist=ko.observable(null);r.BasketTotalsBreakdownModel=ko.observable(ko.mapping.fromJS(n.BasketTotalsBreakdownModel));r.DisplayQuickAdd=ko.observable(!0);r.QuickAddSearchTerm=ko.observable();r.QuickAddSearchRun=ko.observable(!1);r.QuickAddSearchResult=ko.observable(null);r.QuickAddMatchedOnCode=ko.observable(!1);r.QuickAddMatchedOnIsbn=ko.observable(!1);r.ToggleDisplayQuickAdd=function(){r.DisplayQuickAdd(!r.DisplayQuickAdd())};r.QuickAddSearch=function(){t.QuickAddSearch(r.QuickAddSearchTerm()).then(function(n){common.FacebookEvent("Search");r.QuickAddSearchRun(!0);r.QuickAddSearchResult(n)},common.ProcessAjaxError)};r.QuickAddToBasket=function(n){common.FacebookEvent("AddToCart");r.SaveBasketLineSpecific(n.Id,1);r.QuickAddSearchTerm(null);r.QuickAddSearchResult(null);r.QuickAddSearchRun(!1)};r.RefreshWishlist=function(){t.GetWishlist(r.storeSession().id).then(function(n){r.SetWishList(n)},common.ProcessAjaxError)};r.SetWishList=function(n){r.wishlist(new ProductListScroller(n,i.page,i.of,"Your Wishlist","wishlist"));r.SetWorkingWidth()};r.RefreshWishlist=function(){t.GetWishlist(r.storeSession().id).then(function(n){r.SetWishList(n)},common.ProcessAjaxError)};r.SetWorkingWidth=function(){r.wishlist()&&r.wishlist().SetWorkingWidth()};r.WishlistHasItemsWithNoPrices=ko.computed(function(){if(!r.wishlist()||r.wishlist().products().length===0)return!1;var n=ko.utils.arrayFilter(r.wishlist().products(),function(n){return n.ProductPrices().length>0});return n.length===0});r.PopulateBasketLines=function(n){var t,i;if(r.basketLines.removeAll(),n&&n.length!==0)for(t=0;t<n.length;t++)i=new BasketLine(n[t]),i.Basket=r,r.basketLines.push(i)};r.UpdateQuantity=function(n){r.SaveBasketLineSpecific(n.productPrice().Id,n.quantity());n.quantity()<=0&&r.DeleteBasketLineFromUI(n)};r.SubTotal=ko.computed(function(){for(var i,t=0,n=0;n<r.basketLines().length;n++)i=r.basketLines()[n],t+=i.subtotal();return t.toFixed(2)});r.TotalItems=ko.computed(function(){for(var i,t=0,n=0;n<r.basketLines().length;n++)i=r.basketLines()[n],t+=parseInt(i.quantity());return t});r.DeleteBasketLine=function(n){n.quantity(0)};r.DeleteBasketLineFromUI=function(n){r.basketLines.remove(n)};r.MoveBasketLine=function(n){r.SaveWishlistItem(n.product);n.quantity(0)};r.PopulateBasketLines(n.BasketLineViewModels);r.RefreshBasketLines=function(){console.log("REfreshBasketLines");t.GetBasket(r.storeSession().id).then(function(n){r.PopulateBasketLines(n)},common.ProcessAjaxError);t.GetPromoMessage(r.storeSession().id).then(function(n){r.storeSession().promoMessages(n)},common.ProcessAjaxError);r.RefreshPriceBreakdown()};r.RefreshPriceBreakdown=function(){t.GetPriceBreakdown(r.storeSession().id).then(function(n){r.BasketTotalsBreakdownModel(ko.mapping.fromJS(n))},common.ProcessAjaxError)};r.SetPostBasketChange(r.RefreshBasketLines);r.SetPostWishlistChange(r.RefreshWishlist);r.SetWishList(n.Wishlist);r.CheckoutStageManager=new CheckoutStageManager;r.CheckoutStageManager.SetStageBasket();r.RefreshPriceBreakdown=function(){t.GetPriceBreakdown(r.storeSession().id).then(function(n){r.BasketTotalsBreakdownModel(ko.mapping.fromJS(n))})};r.PromoCodeManager=new PromoCodeManager(t,r.storeSession,r.BasketTotalsBreakdownModel(),r.RefreshPriceBreakdown)},BasketLine=function(n){var t=this;t.id=n.Id;t.product=new Product(n.Product);t.productPrice=ko.observable(new ProductPrice(n.ProductPrice));t.quantity=ko.observable(n.Quantity);t.promotional=ko.observable(n.Promotional);t.promocode=ko.observable(n.PromoCode);t.allowQuantityEdit=ko.observable(!n.Product.IsSubscription);t.Basket=null;t.subtotal=ko.computed(function(){return t.productPrice().Price*parseInt("0"+t.quantity(),10)});t.quantity.subscribe(function(){t.Basket.UpdateQuantity(t)});n.ProductCode&&(t.product.Code=n.ProductCode)},BasketLineSetter=function(){var n=this;n.StoreSessionId=null;n.ProductPriceId=null;n.Quantity=null},BasketLogin=function(n,t,i,r){var u=this,f=Client.Common;ko.utils.extend(u,new Store(n,t,i));u.checking=ko.observable(!1);u.basketLines=ko.observableArray();u.BasketTotalsBreakdownModel=ko.observable(ko.mapping.fromJS(n.BasketTotalsBreakdownModel));u.CountryOptions=ko.observableArray(n.CountryOptions);u.PopulateBasketLines=function(n){var t,i;if(u.basketLines.removeAll(),n!==null&&n!==undefined&&n.length!==0)for(t=0;t<n.length;t++)i=new BasketLine(n[t]),i.Basket=u,u.basketLines.push(i)};u.SubTotal=ko.computed(function(){for(var i,t=0,n=0;n<u.basketLines().length;n++)i=u.basketLines()[n],t+=i.subtotal();return t.toFixed(2)});u.TotalItems=ko.computed(function(){for(var i,t=0,n=0;n<u.basketLines().length;n++)i=u.basketLines()[n],t+=parseInt(i.quantity());return t});u.PopulateBasketLines(n.BasketLineViewModels);u.ShowLoginPanel=ko.observable(!1);u.ShowRegisterPanel=ko.observable(!1);u.ShowEmailError=ko.observable(!1);u.EmailAddress=ko.observable("");u.LoginPassword=ko.observable("");u.FirstName=ko.observable("");u.LastName=ko.observable("");u.RegisterPassword=ko.observable("");u.ConfirmPassword=ko.observable("");u.CountryId=ko.observable(n.MarketCountryId);u.CanLogin=ko.computed(function(){return u.EmailAddress().length&&u.LoginPassword().length});u.CanRegister=ko.computed(function(){return u.FirstName().length>0&&u.LastName().length>0&&u.EmailAddress().length>0&&u.RegisterPassword().length>0&&u.ConfirmPassword().length>0});u.PasswordResetManager=new PasswordResetManager(t.urls.apiAccount,r);u.EmailAddress.subscribe(function(n){u.PasswordResetManager.EmailAddress(n)});u.CheckEmail=function(){u.UserSearch(u.EmailAddress())};u.UserSearch=function(n){u.ShowEmailError(!1);var i=f.validateEmail(u.EmailAddress());if(!i){u.ShowEmailError(!0);return}u.checking(!0);t.UserSearch(n).then(function(n){n?(u.ShowLoginPanel(!0),u.ShowRegisterPanel(!1)):(u.ShowLoginPanel(!1),u.ShowRegisterPanel(!0),f.facebookEvent("CompleteRegistration"));setTimeout(function(){u.checking(!1)},300)})};u.PopulateOnReload=function(){n.LoginData&&n.LoginData.LoginEmailAddress&&(u.EmailAddress(n.LoginData.LoginEmailAddress),u.ShowLoginPanel(!0));n.RegisterData&&n.RegisterData.RegisterEmailAddress&&(u.EmailAddress(n.RegisterData.RegisterEmailAddress),u.FirstName(n.RegisterData.FirstName),u.LastName(n.RegisterData.LastName),u.ShowRegisterPanel(!0))};u.PopulateOnReload()};$(document).ready(function(){$(".CategoryMenuItemClickToggle").on("click",function(n){n.preventDefault();var t=$(n.target),i=t.closest(".CategoryMenuItem");return t.hasClass("glyphicon-chevron-down")?(t.removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up"),i.find(".CategoryMenuItemSubCategories").slideDown()):(t.removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down"),i.find(".CategoryMenuItemSubCategories").slideUp()),!1})});var CategoryByProductPage=function(n,t,i){var r=this;ko.utils.extend(r,new Store(n,t,i));this.StoreSearch.filterMode(!0);r.items=ko.observableArray();r.initialised=ko.observable(!1);r.allowFurtherLoad=ko.observable(!0);r.loadingFurther=ko.observable(!1);r.totalCount=ko.observable(n.QueryResult.TotalCount);r.skip=ko.observable(n.QueryResult.Skip);r.take=ko.observable(n.QueryResult.Take);r.scrolled=function(){};r.showing=ko.computed(function(){var n=r.totalCount(),t=r.items().length;return n===0?"No results":"Showing 1-"+t+" of "+n+" results"});r.PopulateNext=function(){r.loadingFurther(!0);r.PopulateProductList(!0)};r.PopulateProductList=function(i,u){i===!0&&r.skip(r.skip()+r.take());u===!0&&(r.skip(0),r.take(20));var f=r.GetBaseQuery();f.CategoryOrBelowId=n.QueryResult.Query.CategoryOrBelowId;f.CategoryExactId=n.QueryResult.Query.CategoryExactId;f.FilterProductTheme=r.StoreSearch.filterProductTheme();f.FilterProductTopic=r.StoreSearch.filterProductTopic();f.FilterProductResourceType=r.StoreSearch.filterProductResourceType();f.FromAge=r.StoreSearch.fromAge();f.ToAge=r.StoreSearch.toAge();t.PopulateProducts(f).then(function(n){u===!0&&r.items([]);r.PopulateProductData(n.QueryResult?n.QueryResult:n)},common.ProcessAjaxError)};r.PopulateProductData=function(n){var t=$.map(n.Results,function(n){return new Product(n)});r.AddProduct(t);r.UpdateForQueryResult(n);r.loadingFurther(!1);r.initialised(!0)};r.GetBaseQuery=function(){var n=new ProductQuery;return n.take=r.take(),n.skip=r.skip(),n};r.UpdateForQueryResult=function(n){r.totalCount(n.TotalCount);r.take(n.Take);r.skip(n.Skip);r.allowFurtherLoad(r.items().length<r.totalCount())};r.AddProduct=function(n){for(var i,t=0;t<n.length;t++)i=n[t],i.index=r.items().length+1,i.Hydrate(),r.items.push(i)};r.PopulateProductData(n.QueryResult);r.FilterProductList=function(){console.log("intercepted age.ranges.changed, in CategoryByProductPage.FilterProductList");r.PopulateProductList(!1,!0)};ko.postbox.subscribe("age.ranges.changed",r.FilterProductList);ko.postbox.subscribe("product.attributes.changed",r.FilterProductList)},CategoryBySeriesPage=function(n,t,i){var r=this;ko.utils.extend(r,new Store(n,t,i));r.series=ko.observableArray();r.expandedSeries=ko.observable();r.initialised=ko.observable(!1);r.allowFurtherLoad=ko.observable(!0);r.loadingFurther=ko.observable(!1);r.totalCount=ko.observable(n.QueryResult.TotalCount);r.skip=ko.observable(n.QueryResult.Skip);r.take=ko.observable(n.QueryResult.Take);r.scrolled=function(){};r.showing=ko.computed(function(){var n=r.totalCount(),t=r.series().length;return n===0?"No results":"Showing 1-"+t+" of "+n+" results"});r.PopulateProducts=function(){t.PopulateProducts(r.QueryStringCategoryId()).then(function(n){var t=$.map(n.Results,function(n){return new Product(n)});r.AddProducts(t)},common.ProcessAjaxError)};r.AddProducts=function(n){for(var i,t=0;t<n.length;t++)i=n[t],i.index=r.products().length+1,r.products.push(i)};r.PopulateSeriesNext=function(){r.loadingFurther(!0);r.PopulateSeries(!0)};r.PopulateSeries=function(i){i===!0&&r.skip(r.skip()+r.take());var u=r.GetBaseQuery();u.CategoryOrBelowId=n.QueryResult.Query.CategoryOrBelowId;u.CategoryExactId=n.QueryResult.Query.CategoryExactId;t.PopulateSeries(u).then(function(n){console.log(n);r.PopulateSeriesData(n)},common.ProcessAjaxError)};r.PopulateSeriesData=function(n){var t=$.map(n.Results,function(n){return new Series(n)});r.AddSeries(t);r.UpdateForQueryResult(n);r.loadingFurther(!1);r.initialised(!0)};r.GetBaseQuery=function(){var n=new SeriesQuery;return n.take=r.take(),n.skip=r.skip(),n};r.UpdateForQueryResult=function(n){r.totalCount(n.TotalCount);r.take(n.Take);r.skip(n.Skip);r.allowFurtherLoad(r.series().length<r.totalCount())};r.AddSeries=function(n){for(var i,t=0;t<n.length;t++)i=n[t],i.index=r.series().length+1,r.series.push(i)};r.ToggleSeries=function(n){r.expandedSeries()&&n.index!==r.expandedSeries().index&&r.expandedSeries().contractProducts();r.expandedSeries(n);n.IsHydrated()?n.toggleDisplayProducts():t.GetProductsForSeries(r.storeSession().id,n.Id).then(function(t){var r=new ProductListScroller(t,i.page,i.of,"Titles in Series",n.Id);n.PopulateProductsSliderAndExpand(r)},common.ProcessAjaxError)};r.PopulateSeriesData(n.QueryResult)},FilteredProductListPage=function(n,t,i){console.log(n);var r=this;ko.utils.extend(r,new Store(n,t,i));this.StoreSearch.filterMode(!0);n.QueryResult&&n.QueryResult.Query&&(n.QueryResult.Query.LearningAreaId||n.LearningArea&&n.LearningArea.Id)&&(this.StoreSearch.allowYearFilter(!0),this.StoreSearch.allowSubjectFilter(!0));n.QueryResult&&n.QueryResult.Query&&n.QueryResult.Query.ThemeId&&this.StoreSearch.allowYearFilter(!0);r.items=ko.observableArray();r.initialised=ko.observable(!1);r.allowFurtherLoad=ko.observable(!0);r.loading=ko.observable(!1);r.loadingFurther=ko.observable(!1);r.totalCount=ko.observable(n.QueryResult?n.QueryResult.TotalCount:0);r.skip=ko.observable(n.QueryResult?n.QueryResult.Skip:0);r.take=ko.observable(n.QueryResult?n.QueryResult.Take:20);r.scrolled=function(){};r.showing=ko.computed(function(){var n=r.totalCount(),t=r.items().length;return n===0?"No results":"Showing 1-"+t+" of "+n+" results"});r.PopulateNext=function(){r.loadingFurther(!0);r.PopulateProductList(!0)};r.PopulateProductList=function(i,u){i===!0&&r.skip(r.skip()+r.take());u===!0&&(r.skip(0),r.take(20));var f=r.GetBaseQuery();f.LearningAreaId=n.QueryResult.Query.LearningAreaId;f.ThemeId=n.QueryResult.Query.ThemeId;f.Year=n.QueryResult.Query.Year;f.FilterProductTheme=r.StoreSearch.filterProductTheme();f.FilterProductTopic=r.StoreSearch.filterProductTopic();f.FilterProductResourceType=r.StoreSearch.filterProductResourceType();f.FilterProductLevel=r.StoreSearch.filterProductLevel();f.FromAge=r.StoreSearch.fromAge();f.ToAge=r.StoreSearch.toAge();u&&r.loading(!0);t.PopulateProducts(f).then(function(n){u===!0&&(r.items([]),r.loading(!1));r.PopulateProductData(n)},common.ProcessAjaxError);r.SaveFilters(f)};r.PopulateProductData=function(n){if(r.loadingFurther(!1),r.initialised(!0),n&&n.Results&&n.Results.length>0){var t=$.map(n.Results,function(n){return new Product(n)});r.AddProduct(t);r.UpdateForQueryResult(n)}else r.UpdateForQueryResult(n),r.allowFurtherLoad(!1)};r.SaveFilters=function(i){t.SaveFilters(n.StoreSession.Id,i.FromAge,i.ToAge,i.FilterProductResourceType,i.FilterProductLevel,i.FilterProductTheme).then(function(){},function(){console.log("Error saving filters")})};r.GetBaseQuery=function(){var n=new ProductQuery;return n.take=r.take(),n.skip=r.skip(),n};r.UpdateForQueryResult=function(n){r.totalCount(n.TotalCount);r.take(n.Take);r.skip(n.Skip);r.allowFurtherLoad(r.items().length<r.totalCount())};r.AddProduct=function(n){for(var i,t=0;t<n.length;t++)i=n[t],i.index=r.items().length+1,i.Hydrate(),r.items.push(i)};r.hideYearFilter=function(){r.StoreSearch.allowYearFilter(!1)};r.allowSubjectFilter=function(){r.StoreSearch.allowSubjectFilter(!0)};r.PopulateProductData(n.QueryResult);r.FilterProductList=function(){console.log("filter product list");r.PopulateProductList(!1,!0)};ko.postbox.subscribe("age.ranges.changed",r.FilterProductList);ko.postbox.subscribe("product.attributes.changed",r.FilterProductList)},InvoicePageForm=function(n){var t=this;n.Response===0&&(n.Response=undefined);ko.utils.extend(t,ko.mapping.fromJS(n));t.OrderHasParty=ko.computed(function(){return t.HasParty()||t.HasRespondingParty()});t.CardExpiryMonth(undefined);t.CardExpiryYear(undefined);t.ConfigureValidation=function(){ko.validation.init({registerExtenders:!0,insertMessages:!0,messagesOnModified:!0,errorElementClass:"has-error",errorMessageClass:"help-block",decorateElement:!0,decorateInputElement:!0,decorateElementOnModified:!0},!0);t.ResponderName.extend({required:{message:"Required"}});t.CardNumber.extend({required:{message:"Required"},minLength:15,maxLength:19});t.NameOnCard.extend({required:{message:"Required"}});t.CardExpiryMonth.extend({required:{message:"Required"},number:!0,minLength:1,maxLength:2,min:1,max:12});t.CardExpiryYear.extend({required:{message:"Required"},number:!0,minLength:1,maxLength:5,min:(new Date).getFullYear()})};t.GetObject=function(){var n=ko.mapping.toJS(t);return n.CardNumber&&(n.CardNumber=n.CardNumber.replace(/\s/g,"")),n}},InvoicePage=function(n,t){var i=this;ko.utils.extend(i,new Store(n,t,{}));i.FormData=ko.validatedObservable(new InvoicePageForm(n.InvoiceOrder));i.FormData().ConfigureValidation();i.ShowPaymentError=ko.observable(!1);i.PaymentErrorDetails=ko.observable("");i.Processing=ko.observable(!1);i.Submitted=ko.observable(!1);i.CanSubmit=ko.computed(function(){return i.FormData.errors().length===0});i.ScrollToTop=function(){$("#top").scrollintoview()};i.Submit=function(){if(i.ShowPaymentError(!1),i.FormData.errors&&i.FormData.errors().length>0){i.FormData.errors.showAllMessages();return}i.Processing(!0);i.ScrollToTop();var n=i.FormData().GetObject(),r=function(){i.Processing(!1);i.Submitted(!0)},u=function(n){if(console.log(n),i.Processing(!1),n.responseJSON){var t=n.responseJSON;console.log(t);t.HasError?(i.PaymentErrorDetails(t.ErrorMessage),i.ShowPaymentError(!0)):common.ProcessAjaxError(n)}else common.ProcessAjaxError(n)};t.SaveInvoiceResponse(n).then(r,u)}},LandingPageData=function(n){var t=this;ko.utils.extend(t,new StoreBase(n));t.title=null;t.featured=ko.observable(new n(n.Featured));t.topSelling=ko.observable(new n(n.TopSelling));t.newReleases=ko.observable(new n(n.NewReleases))},Media=function(n){var t=this;t.id=n.Id;t.name=n.Name;t.description=n.Description},Product=function(n){var t=this;ko.utils.extend(t,new StoreItem(n));t.Authors=ko.observableArray();t.ProductPrices=ko.observableArray();t.IsInWishlist=ko.observable(t.IsInWishlist);t.IsHydrated=!1;t.HasSpecialPrice=ko.computed(function(){var n=ko.utils.arrayFilter(t.ProductPrices(),function(n){return n.IsSpecial});return n.length>0});t.PopulateAuthors=function(n){var i,r;if(n!=null&&n.length!==0)for(i=0;i<n.length;i++)r=new Author(n[i]),r.last(i===n.length-1),t.Authors.push(r)};t.PopulateAuthors(n.Authors);t.Hydrate=function(){t.IsHydrated!==!0&&(t.PopulateProductPrices(n.ProductPrices),t.IsHydrated=!0)};t.PopulateProductPrices=function(n){var i,r;if(n!=null&&n.length!==0)for(t.ProductPrices([]),i=0;i<n.length;i++)r=new ProductPrice(n[i]),t.ProductPrices.push(r)};t.LowestPrice=ko.computed(function(){var t=_.map(n.ProductPrices,function(n){return n.Price});return _.min(t)});t.Hydrate()},ProductDetail=function(n,t,i){var r=this,u;ko.utils.extend(r,new Store(n,t,i));console.log(n);r.Promotion=ko.observable(null);r.WholeProducts=ko.observableArray([]);r.PartProducts=ko.observableArray([]);r.KitsetComponents=ko.observableArray([]);r.KitsetParents=ko.observableArray([]);r.WholeProductsFormatted=ko.computed(function(){var n=[];return _.each(r.WholeProducts(),function(t){_.each(t.ProductPrices,function(i){n.push({Id:i.Id,Name:t.Name,Code:t.Code,Media:i.Name=="Ebook"?"Ebook (single file)":i.Name,IsSpecial:i.IsSpecial,RegularPrice:i.RegularPrice,Price:i.Price})})}),n});r.KitsetParentsFormatted=ko.computed(function(){var n=[];return _.each(r.KitsetParents(),function(t){_.each(t.ProductPrices,function(i){n.push({Id:i.Id,Name:t.Name,Code:t.Code,Media:i.Name=="eResource"?"eResource collection (multiple files)":i.Name,IsSpecial:i.IsSpecial,RegularPrice:i.RegularPrice,Price:i.Price})})}),n});r.YouMayLikeProducts=ko.computed(function(){return _.flatten([r.WholeProductsFormatted(),r.KitsetParentsFormatted()])});r.AddPromoBasketLine=function(){r.Promotion()&&(r.SaveBasketLineSpecific(r.Promotion().ProductPriceId,1),t.SetPromoCode(n.StoreSession.Id,r.Promotion().PromoCode,!0).then(function(){trackHeap("Product Detail Add Promo Code Success",{PromoCode:r.Promotion().PromoCode})}))};u=n.ProductModel.Id;t.GetPromotion(u).then(function(n){n&&r.Promotion(n)});r.LoadKitsetComponents=function(n){t.GetKitsetComponentModels(n.Id).then(function(n){n&&n.length&&_.each(n,function(n){r.KitsetComponents.push(n)})})};t.GetDetailsExtension(u).then(function(n){n&&(console.log(n),n.WholeProducts.length&&r.WholeProducts(n.WholeProducts),n.PartProducts.length&&r.PartProducts(n.PartProducts),n.KitsetComponents.length&&r.KitsetComponents(n.KitsetComponents),n.KitsetParents.length&&(r.KitsetParents(n.KitsetParents),_.each(n.KitsetParents,r.LoadKitsetComponents)))});r.SelectedProduct=ko.observable(new Client.KnockoutProductStoreItemModel(n.ProductModel));r.SelectProduct=function(n){console.log("selectProduct",n);r.SelectedProduct().fromJs(n);r.ProductPreviews(n.ProductPreviews?n.ProductPreviews:[])};r.ProductPreviews=ko.observableArray(n.ProductModel?n.ProductModel.ProductPreviews:[]);r.HasProductPreviews=ko.computed(function(){return r.ProductPreviews().length>0});r.FirstPreviewImageUrl=ko.computed(function(){if(r.HasProductPreviews()){var n=r.ProductPreviews()[0];return n?n.ImageUrl:""}return""});r.showProductPreviews=function(n){var r=".product-preview-gallery",i,t,u;if(n&&(r+="-mobile"),!n)for(i=$(r+" img[data-src]"),t=0;t<i.length;t++)i[t].src=i[t].dataset?i[t].dataset.src:i[t].getAttribute(attr);u={delegate:"a",type:"image",gallery:{enabled:!0},zoom:{enabled:!0}};n&&(u.preload=[0,2]);$(r).magnificPopup(u);n&&$(r).magnificPopup("open")}},ProductList=function(n){var t=this;t.products=ko.observableArray();t.PopulateProducts=function(n){var i,r;if(n!=null&&n.length!=0)for(i=0;i<n.length;i++)r=new Product(n[i]),r.index=t.products().length+1,r.Hydrate(),t.products.push(r)};t.PopulateProducts(n)},ProductListPage=function(n,t,i){var r=this;ko.utils.extend(r,new Store(n,t,i));r.products=ko.observableArray();r.currentCategory=ko.observable();r.ageRanges=ko.observableArray();r.fromAge=ko.observable(-1);r.toAge=ko.observable(-1);r.initialised=ko.observable(!1);r.totalCount=ko.observable(0);r.take=ko.observable(20);r.skip=ko.observable(0);r.showing=ko.observable();r.allowFurtherLoad=ko.observable(!0);r.loadingFurther=ko.observable(!1);r.keywordsString=ko.observable(r.QueryStringKeywords());r.searchCategory=ko.observable(null);r.searchCategories=ko.observableArray(null);r.productOrderByOptionId=ko.observable(r.QueryStringOrderBy()==null?0:r.QueryStringOrderBy());r.previousProductOrderByOptionId=ko.observable(0);r.scrolled=function(){};r.RefreshSearch=function(){$("form#search").submit()};r.SelectSearchCategory=function(n){r.searchCategory(n);r.RefreshSearch()};r.SetSearchCategories=function(){var t=_.map(n.Categories,function(n){return{id:n.Id,name:n.Name}});t.unshift({name:i.allCategories});r.searchCategories(t)};r.AgeRangesChanged=function(){var n=ko.utils.arrayFilter(r.ageRanges(),function(n){return n.selected()}),t=n[0],i;t?(i=n[n.length-1],ko.utils.arrayForEach(r.ageRanges(),function(n){n.from>t.from&&n.to<i.to&&n.selected(!0)}),r.fromAge(t.from),r.toAge(i.to)):(r.fromAge(-1),r.toAge(-1))};r.PopulateAgeRanges=function(){var t,i;for(n.QueryResult&&n.QueryResult.Query&&(r.fromAge(n.QueryResult.Query.FromAge),r.toAge(n.QueryResult.Query.ToAge)),t=[],t.push({from:0,to:5}),i=5;i<14;i++)t.push({from:i,to:i+1});t.push({from:14,to:18});ko.utils.arrayForEach(t,function(n){n.selected=ko.observable(n.from>=r.fromAge()&&n.to<=r.toAge());n.name=n.from+"-"+n.to;n.toggleSelected=function(){n.selected(!n.selected());r.AgeRangesChanged();r.RefreshSearch()}});t.push({from:-1,to:-1,name:"All Ages",selected:ko.observable(!1),toggleSelected:function(){ko.utils.arrayForEach(r.ageRanges(),function(n){n.selected(!1)});r.AgeRangesChanged();r.RefreshSearch()}});r.ageRanges(t)};r.hasAgeRangesSelected=ko.computed(function(){var n=ko.utils.arrayFilter(r.ageRanges(),function(n){return n.selected()});return n.length>0});r.selectedAgeRangeDescription=ko.computed(function(){return r.hasAgeRangesSelected()?"Ages "+r.fromAge()+"-"+r.toAge():"All ages"});r.AddProducts=function(n){_.each(n,function(n){n.index=r.products().length+1;var t=new Product(n);r.products.push(t)})};r.filteredProducts=ko.computed(function(){var n=r.products(),t,i,u,f;return r.keywordsString&&r.keywordsString()&&r.keywordsString().length>2&&(t=r.keywordsString().toLowerCase(),n=_.filter(n,function(n){return n.Name.toLowerCase().indexOf(t)>-1?!0:n.Subtitle.toLowerCase().indexOf(t)>-1?!0:n.Description.toLowerCase().indexOf(t)>-1?!0:!1})),r.toAge&&r.toAge()>-1&&r.fromAge&&r.fromAge()>-1&&(i=r.fromAge(),u=r.toAge(),n=_.filter(n,function(n){return n.FromAge<u&&n.ToAge>i})),r.searchCategory&&r.searchCategory()&&r.searchCategory().id&&(f=r.searchCategory(),n=_.filter(n,function(n){return _.includes(n.CategoryIds,f.id)})),n});r.PopulateAgeRanges();r.SetSearchCategories();r.AddProducts(n.QueryResult.Results)},ProductListScroller=function(n,t,i,r,u,f){var e=this,o;ko.utils.extend(e,new ProductList(n));e.Id=ko.observable(u);e.totalWidth=ko.observable(0);e.currentPage=ko.observable(1);e.workingWidthPx=ko.observable(0);e.title=r;e.url=f;e.hasUrl=!!f;o=170;e.GetProductScrollerWidth=function(){var t="productScroller"+e.Id(),n=document.getElementById(t);return n==null?null:n.offsetWidth};e.GetTallButtonContainerWidth=function(){var t="tallButton1Container"+e.Id(),n=document.getElementById(t);return n==null?null:n.offsetWidth};e.SetWorkingWidth=function(){var t=e.GetProductScrollerWidth(),n;t&&(n=e.GetTallButtonContainerWidth(),n)&&(e.workingWidthPx(Math.floor(t-n*2)-20),e.currentPage()>e.totalPages()&&e.currentPage(e.totalPages()))};e.Console=function(){var t="productScroller"+e.Id(),n=document.getElementById(t);console.log("GetProductScrollerWidth: "+e.GetProductScrollerWidth());console.log("productScroller.offsetWidth: "+(n?n.offsetWidth:"null"));console.log("workingWidthPx: "+e.workingWidthPx());console.log("itemsPerPage: "+e.itemsPerPage())};e.itemsPerPage=ko.computed(function(){var n=e.workingWidthPx()/o;return Math.floor(n)});e.totalPages=ko.computed(function(){var t=e.products().length/e.itemsPerPage(),n=Math.ceil(t);return n==0?1:n});e.currentIndex=ko.computed(function(){return(e.currentPage()-1)*e.itemsPerPage()});e.visibleProducts=ko.computed(function(){for(var r=e.itemsPerPage()>e.products().length?e.products().length:e.itemsPerPage(),t=[],n=e.currentIndex(),i=0;i<r;i++)n>=e.products().length||(t.push(e.products()[n]),n++);return t});e.pageDescription=ko.computed(function(){return t+" "+e.currentPage()+" "+i+" "+e.totalPages()});e.previousPage=function(){e.currentPage()===1?e.currentPage(e.totalPages()):e.currentPage(e.currentPage()-1)};e.nextPage=function(){e.currentPage()===e.totalPages()?e.currentPage(1):e.currentPage(e.currentPage()+1)};e.PopulateProducts=function(n){var t,i;if(n!=null&&n.length!=0)for(t=0;t<n.length;t++)i=new Product(n[t]),i.index=e.products().length+1,i.Hydrate(),e.products.push(i)}},ProductPrice=function(n){var t=this;ko.utils.extend(t,n);t.chosenQty=ko.observable(0)},ProductQuery=function(){var n=this;ko.utils.extend(n,new Query);n.ProductKeywords=null;n.ProductOrderByOptionId=0;n.FromAge=0;n.ToAge=0},ProductSearch=function(n,t,i){var r=this;ko.utils.extend(r,new Store(n,t,i));r.StoreSearch.searchMode(!0);r.products=ko.observableArray();r.initialised=ko.observable(!1);r.totalCount=ko.observable(n.QueryResult.TotalCount);r.take=ko.observable(n.QueryResult.Take);r.skip=ko.observable(n.QueryResult.Skip);r.allowFurtherLoad=ko.observable(!0);r.loadingFurther=ko.observable(!1);r.productOrderByOptionId=ko.observable(r.QueryStringOrderBy()==null?0:r.QueryStringOrderBy());r.previousProductOrderByOptionId=ko.observable(0);r.scrolled=function(){};r.showing=ko.computed(function(){var n=r.totalCount(),t=r.products().length;return n===0?"No results":"Showing 1-"+t+" of "+n+" results"});r.AddProducts=function(n){for(var i,t=0;t<n.length;t++)i=n[t],i.index=r.products().length+1,i.Hydrate(),r.products.push(i)};r.PopulateProductsNext=function(){r.loadingFurther(!0);r.PopulateProducts(!0)};r.PopulateProducts=function(i,u){u===!0&&(r.initialised(!1),r.products.removeAll(),r.skip(0));i===!0&&r.skip(r.skip()+r.take());var f=r.GetBaseQuery();f.CategoryOrBelowId=n.QueryResult.Query.CategoryOrBelowId;f.FromAge=n.QueryResult.Query.FromAge;f.ToAge=n.QueryResult.Query.ToAge;f.ProductKeywords=n.QueryResult.Query.ProductKeywords;f.ProductOrderByOptionId=r.productOrderByOptionId();t.PopulateProducts(f).then(function(n){r.PopulateProductData(n)},common.ProcessAjaxError)};r.PopulateProductData=function(n){console.log("queryResult",n);var t=$.map(n.Results,function(n){return new Product(n)});r.AddProducts(t);r.UpdateForQueryResult(n);r.loadingFurther(!1);r.initialised(!0)};r.GetBaseQuery=function(){var n=new ProductQuery;return n.take=r.take(),n.skip=r.skip(),n};r.UpdateForQueryResult=function(n){r.take(n.Take);r.skip(n.Skip);n.TotalCount>0&&r.totalCount(n.TotalCount);r.allowFurtherLoad(r.products().length<r.totalCount())};r.PopulateProductData(n.QueryResult);setTimeout(function(){r.productOrderByOptionId.subscribe(function(){r.productOrderByOptionId()!==r.previousProductOrderByOptionId()&&(r.previousProductOrderByOptionId(r.productOrderByOptionId()),r.PopulateProducts(!1,!0))})},300)},ProductSlider={lazyLoad:function(){for(var t=$("img[data-src]"),n=0;n<t.length;n++)t[n].src=t[n].dataset?t[n].dataset.src:t[n].getAttribute(attr);for(t=$("img[data-lazy]"),n=0;n<t.length;n++)t[n].src=t[n].dataset?t[n].dataset.lazy:t[n].getAttribute(attr)},start:function(){var n={lazyLoad:"ondemand",dots:!1,infinite:!0,speed:300,slidesToShow:5,slidesToScroll:5,responsive:[{breakpoint:1600,settings:{slidesToShow:4,slidesToScroll:4}},{breakpoint:1300,settings:{slidesToShow:3,slidesToScroll:3}},{breakpoint:992,settings:{slidesToShow:4,slidesToScroll:4}},{breakpoint:780,settings:{slidesToShow:3,slidesToScroll:3}},{breakpoint:590,settings:{slidesToShow:2,slidesToScroll:2}},{breakpoint:430,settings:{slidesToShow:1,slidesToScroll:1}}]};$.each($(".product-scroller-frame"),function(t,i){var r=$(i),f=r.find(".product-scroller2")[0],e=r.find(".prevPage")[0],o=r.find(".nextPage")[0],u=$.extend({},n);u.prevArrow=e;u.nextArrow=o;$(f).slick(u)})}},PromoCodeManager=function(n,t,i,r){function e(){r&&r()}function f(n){window.heap&&window.heap.track(n)}function o(){u.PromoCodes(ko.utils.arrayMap(i.PromoCodeDiscounts(),function(n){return n.Code()}))}var u=this;u.PromoCodes=ko.observableArray([]);u.PromoCodeEntry=ko.observable("");u.PromoMessages=t().promoMessages;u.PromoCodeErrorMessage=ko.observable(null);u.PromoCodeEntryVisible=ko.observable(!1);u.TogglePromoCodeEntryVisible=function(){u.PromoCodeEntryVisible(!u.PromoCodeEntryVisible())};u.PromoCodeEntryReady=ko.computed(function(){return u.PromoCodeEntry()!=null&&u.PromoCodeEntry().trim()!=""});u.PromoCodeAddAllowed=ko.computed(function(){return u.PromoCodes().length===0});u.ClearPromoCodeErrorMessage=function(){u.PromoCodeErrorMessage(null)};u.AddPromoCode=function(){if(u.PromoCodeEntryReady()){var i=function(){u.PromoCodes.push(u.PromoCodeEntry());u.PromoCodeErrorMessage(null);u.PromoCodeEntry("");e();f("Checkout Add Promo Code Success")},r=function(n){var t="Promo Code could not be added";n&&n.responseJSON&&n.responseJSON.ErrorMessage&&(t=n.responseJSON.ErrorMessage);u.PromoCodeErrorMessage(t);f("Checkout Add Promo Code Failure")};n.SetPromoCode(t().id,u.PromoCodeEntry()).then(i,r)}};u.RemovePromoCode=function(i){var r=function(){u.PromoCodes.remove(i.Code());e();f("Checkout Remove Promo Code Failure")},o=function(n){var t="Promo Code could not be removed";n&&n.responseJSON&&n.responseJSON.ErrorMessage&&(t=n.responseJSON.ErrorMessage);u.PromoCodeErrorMessage(t);f("Checkout Remove Promo Code Failure")};n.RemovePromoCode(t().id,i.PromoCodeId()).then(r,o)};o()},PromotionPage=function(n,t,i,r,u){var f=this;ko.utils.extend(f,new ProductListPage(n,t,i,r,u));f.PromoCodeMessageVisible=ko.observable(!1);f.PromoCodeMessage=ko.observable("");f.SetPostBasketChange(function(){var i=function(){f.PromoCodeMessageVisible(!1);trackHeap("Promotion Add Promo Code Success",{PromoCode:n.PromoCode})},r=function(n){if(n&&n.responseJSON&&n.responseJSON.ErrorMessage){var t=n.responseJSON.ErrorMessage;f.PromoCodeMessage(t);f.PromoCodeMessageVisible(!0)}};t.SetPromoCode(n.StoreSession.Id,n.PromoCode,!0).then(i,r)});f.filteredProducts=ko.computed(function(){var n=f.products(),t,i,r,u;return f.keywordsString&&f.keywordsString()&&f.keywordsString().length>2&&(t=f.keywordsString().trim().toLowerCase(),n=_.filter(n,function(n){var i=_.map(t.split(" "),function(t){return t.length<3?!0:n.Code.indexOf(t)>-1?!0:n.Name.toLowerCase().indexOf(t)>-1?!0:n.Subtitle.toLowerCase().indexOf(t)>-1?!0:n.Description.toLowerCase().indexOf(t)>-1?!0:!1});return _.some(i)})),f.toAge&&f.toAge()>-1&&f.fromAge&&f.fromAge()>-1&&(i=f.fromAge(),r=f.toAge(),n=_.filter(n,function(n){return n.FromAge<r&&n.ToAge>i})),f.searchCategory&&f.searchCategory()&&f.searchCategory().id&&(u=f.searchCategory(),n=_.filter(n,function(n){return _.includes(n.CategoryIds,u.id)})),n})},Query=function(){var n=this;n.CategoryExactId=null;n.CategoryOrBelowId=null;n.AuthorId=null},Series=function(n){var t=this,i,r;ko.utils.extend(t,new StoreItem(n));t.products=ko.observableArray();t.ProductCount=ko.observable(n.ProductCount);t.url=n.Url;t.code=n.Code;t.displayProducts=ko.observable(!1);i="visuallyhidden";r="productExpander";t.productsCssClass=ko.observable(i);t.cssClass=ko.computed(function(){return t.displayProducts()?"expanded":""});t.PopulateProducts=function(n){var i,r;if(console.log("Populating products"),n!=null&&n.length!==0)for(i=0;i<n.length;i++)r=new Product(n[i]),r.index=t.products().length+1,t.products.push(r)};t.ProductsSlider=ko.observable(null);t.PopulateProductsSliderAndExpand=function(n){t.ProductsSlider(n);t.setDisplayProducts(!0);n.SetWorkingWidth()};t.SetWorkingWidth=function(){};t.productsHeight=ko.observable(0);t.IsHydrated=ko.observable(!1);t.contractProducts=function(){t.setDisplayProducts(!1)};t.toggleDisplayProducts=function(){t.setDisplayProducts(!t.displayProducts())};t.setDisplayProducts=function(n){t.Hydrate();t.displayProducts(n);n?t.productsCssClass(r):t.productsCssClass(i);var u=document.getElementById("products"+t.index);n?t.productsHeight(u.offsetHeight+200+"px"):t.productsHeight("")};t.Hydrate=function(){if(!t.IsHydrated()){for(var n=0;n<t.products().length;n++)t.products()[n].Hydrate();t.IsHydrated(!0)}}},SeriesQuery=function(){var n=this;ko.utils.extend(n,new Query)},Store=function(n,t,i){var r=this;r.StoreSearch=new StoreSearch(n.Categories,n.Author,n.QueryResult,i,n);ko.utils.extend(r,new StoreBase(n));r.PostBasketChange=null;r.PostWishlistChange=null;r.AddBasketLine=function(n){r.SaveBasketLineSpecific(n,1);setTimeout(function(){var n=$(".dropdown.dropup.open");n.children("aria-expanded[true]").attr("aria-expanded",!1);n.removeClass("open")},4e3)};r.AddMultipleProductPrices=function(n){return t.AddMultipleToCart(r.storeSession().id,n)};r.SaveBasketLine=function(n){n.chosenQty()<0||r.SaveBasketLineSpecific(n.Id,n.chosenQty())};r.SaveBasketLineSpecific=function(n,i){if(i<0)return common.ResolvedPromise();var u=t.SaveBasketLineSpecific(r.storeSession().id,n,r.MarketId,i);return u.then(function(){common.FacebookEvent("AddToCart");r.RefreshStoreSession();r.PostBasketChange&&r.PostBasketChange();ko.postbox.publish("AddToCart")},common.ProcessAjaxError),u};r.DeleteBasket=function(){confirm(r.deletetionConfirmation)&&t.DeleteBasket(r.storeSession().id).then(function(){r.RefreshStoreSession();r.PostBasketChange&&r.PostBasketChange()},common.ProcessAjaxError)};r.ToggleWishlistItem=function(n){t.ToggleWishlistItem(r.storeSession().id,n).then(function(t){common.FacebookEvent("AddToWishlist");common.NotifyWithDuration(r.wishlistUpdated,3e3);r.RefreshStoreSession();r.PostWishlistChange&&r.PostWishlistChange();t.Data.IsInWishlist?$(".WishlistProduct-"+n).addClass("InWishlist"):$(".WishlistProduct-"+n).removeClass("InWishlist")},common.ProcessAjaxError)};r.SaveWishlistItem=function(n){t.SaveWishlistItem(r.storeSession().id,n.Id).then(function(){common.FacebookEvent("AddToWishlist");common.NotifyWithDuration(r.wishlistUpdated,3e3);r.RefreshStoreSession();r.PostWishlistChange&&r.PostWishlistChange()},common.ProcessAjaxError)};r.DeleteWishlistItem=function(n){console.log(n);t.DeleteWishlistItem(r.storeSession().id,n.Id).then(function(){r.RefreshStoreSession();r.PostWishlistChange&&r.PostWishlistChange()},common.ProcessAjaxError)};r.RefreshStoreSession=function(){t.RefreshStoreSession(r.storeSession().id).then(function(n){n.BasketLineCount!==r.storeSession().basketLineCount()&&(r.storeSession().basketLineCount(n.BasketLineCount),r.storeSession().basketLines(n.BasketLines));n.WishListCount!==r.storeSession().wishListCount()&&r.storeSession().wishListCount(n.WishListCount)},common.ProcessAjaxError)};r.SetPostBasketChange=function(n){r.PostBasketChange=n};r.SetPostWishlistChange=function(n){r.PostWishlistChange=n};r.qtyOptions=null;r.QtyOptions=ko.computed(function(){if(r.qtyOptions===null){r.qtyOptions=[];for(var n=1;n<=20;n++)r.qtyOptions.push(n)}return r.qtyOptions})};var StoreBase=function(n){var t=this;t.StoreNavigation=new StoreNavigation;t.phraseWorking="Working...";t.phraseAll="All";t.phraseShowing="Showing";t.phraseOf="of";t.phraseResults="Results";t.phraseNoResults="No Results";t.deletetionConfirmation="Are you sure that you want to clear your cart?";t.allCategories="All Categories";t.basketUpdated="Cart Updated";t.wishlistUpdated="Wishlist Updated";t.MarketId=n.MarketId;t.MarketName=n.MarketName;t.IsDefaultMarket=n.IsDefaultMarket;t.MarketAllowsSchoolInvoicing=n.MarketAllowsSchoolInvoicing;t.CurrencySymbol=n.Currency?n.Currency.Symbol:"$";t.CurrencyCode=n.Currency?n.Currency.Code:"NZD";t.MarketsVisible=ko.observable(!1);t.MarketSwitchModalVisible=ko.observable(!1);t.CategoryMenuVisible=ko.observable(!0);t.IsHomePage=ko.observable(!1);t.IsMobileSize=ko.observable(!1);t.CartAddedModalVisible=ko.observable(!1);t.ToggleMarketsVisible=function(){t.MarketsVisible(!t.MarketsVisible())};t.ToggleCategoryMenuVisible=function(){t.CategoryMenuVisible(!t.CategoryMenuVisible())};t.HideMarketOptions=function(){return t.MarketsVisible(!1),!1};t.MarketOptions=ko.computed(function(){return ko.utils.arrayFilter(n.MarketUrls,function(n){return n.Id!==t.MarketId})});t.ShowRestOfWorld=function(){t.MarketSwitchModalVisible(!0)};t.CompleteRestOfWorld=function(){var i=ko.utils.arrayFirst(n.MarketUrls,function(n){return n.IsDefault});!t.IsDefaultMarket&&i?window.location=i.Url:(t.MarketSwitchModalVisible(!1),t.MarketsVisible(!1))};t.storeSession=ko.observable(new StoreSession(n.StoreSession));t.QueryStringCategoryIdVariable="cat";t.QueryStringCategoryId=function(){return common.GetQueryStringParameterByName(t.QueryStringCategoryIdVariable)};t.QueryStringAuthorIdVariable="aut";t.QueryStringAuthorId=function(){return common.GetQueryStringParameterByName(t.QueryStringAuthorIdVariable)};t.QueryStringKeywordsVariable="keywords";t.QueryStringKeywords=function(){return common.GetQueryStringParameterByName(t.QueryStringKeywordsVariable)};t.QueryStringOrderByVariable="orderBy";t.QueryStringOrderBy=function(){return common.GetQueryStringParameterByName(t.QueryStringOrderByVariable)};t.QueryStringFromAgeVariable="fromAge";t.QueryStringFromAge=function(){return common.GetQueryStringParameterByName(t.QueryStringFromAgeVariable)};t.QueryStringToAgeVariable="toAge";t.QueryStringToAge=function(){return common.GetQueryStringParameterByName(t.QueryStringToAgeVariable)};t.SetWhetherMobile=function(){t.IsMobileSize($(window).width()<992)};t.Init=function(){t.SetWhetherMobile();setTimeout(function(){t.CategoryMenuVisible(!t.IsMobileSize()||t.IsHomePage())},300)};$(window).resize(function(){t.SetWhetherMobile();t.CategoryMenuVisible(!t.IsMobileSize())});t.Init();ko.postbox.subscribe("AddToCart",function(){t.IsMobileSize()?t.CartAddedModalVisible(!0):common.NotifyWithDuration(t.basketUpdated,4e3)})},StoreNavigation=function(){var n=this;n.expandLearningAreas=ko.observable(!1);n.expandYears=ko.observable(!1);n.expandThemes=ko.observable(!1);n.showLearningAreas=function(t){var i=t===!0?0:400;setTimeout(function(){n.expandLearningAreas(!0);n.expandYears(!1);n.expandThemes(!1);$(".dim").show()},i)};n.showYears=function(t){var i=t===!0?0:400;setTimeout(function(){n.expandLearningAreas(!1);n.expandYears(!0);n.expandThemes(!1);$(".dim").show()},i)};n.showThemes=function(t){var i=t===!0?0:400;setTimeout(function(){n.expandLearningAreas(!1);n.expandYears(!1);n.expandThemes(!0);$(".dim").show()},i)};n.closeAll=function(){n.expandLearningAreas(!1);n.expandYears(!1);n.expandThemes(!1);$(".dim").hide()}},StoreFront=function(n,t,i,r,u){var f=this;ko.utils.extend(f,new StoreQuery(n,t,i));f.series=ko.observableArray();f.expandedSeries=ko.observable();f.PopulateCategories=function(t){var r=$.map(t,function(n){return new Category(n)}),i;for(f.categories(r),i=0;i<f.categories().length;i++)f.categories()[i].SetPerentCategory(null);f.QueryStringCategoryId!==null?f.SetForSelectedCategory():f.SetForRoot();f.PopulateSeriesData(n.QueryResult)};f.PopulateProducts=function(){t.PopulateProducts(f.QueryStringCategoryId()).then(function(n){var t=$.map(n.Results,function(n){return new Product(n)});f.AddProducts(t)},common.ProcessAjaxError)};f.AddProducts=function(n){for(var i,t=0;t<n.length;t++)i=n[t],i.index=f.products().length+1,f.products.push(i)};f.PopulateSeriesNext=function(){f.loadingFurther(!0);f.PopulateSeries(!0)};f.PopulateSeries=function(n){var i,r,u;n===!0&&f.skip(f.skip()+f.take());i=f.GetBaseQuery();r=f.QueryStringCategoryId();r!==null?i.CategoryOrBelowId=r:(u=f.QueryStringAuthorId(),u!==null&&(i.AuthorId=u));t.PopulateSeries(i).then(function(n){f.PopulateSeriesData(n.QueryResult)},common.ProcessAjaxError)};f.PopulateSeriesData=function(n){var t=$.map(n.Results,function(n){return new Series(n)});f.AddSeries(t);f.UpdateForQueryResult(n);f.loadingFurther(!1);f.initialised(!0)};f.GetBaseQuery=function(){var n=new SeriesQuery;return n.take=f.take(),n.skip=f.skip(),n};f.UpdateForQueryResult=function(n){f.totalCount(n.TotalCount);f.take(n.Take);f.skip(n.Skip);f.allowFurtherLoad(f.series().length<f.totalCount());f.UpdateShowing()};f.UpdateShowing=function(){if(f.totalCount()==0)f.showing(f.phraseNoResults);else{var n=f.series().length;f.showing(f.phraseShowing+" 1-"+n+" "+f.phraseOf+" "+f.totalCount()+" "+f.phraseResults)}};f.AddSeries=function(n){for(var i,t=0;t<n.length;t++)i=n[t],i.index=f.series().length+1,f.series.push(i)};f.SetForRoot=function(){f.SetSubCategoryCrumbs(f.categories());f.title(f.phraseAll)};f.SetCurrentCategory=function(n){f.currentCategory(n);f.searchCategory(n)};f.SetForSelectedCategory=function(){var o=f.QueryStringCategoryId(),n=null,i,s,r,t,u,e;if(o!="")for(i=0;i<f.categories().length;i++)if(s=f.categories()[i],n=s.SearchForCategory(o),n!=null)break;if(n==null)f.SetForRoot();else{for(f.SetCurrentCategory(n),n.highlight(!0),n.ensureVisible(!0),f.title(n.name()),f.SetSubCategoryCrumbs(n.categories()),r=[],t=n;t!=null;)r.push(t),t=t.parentCategory();for(u=[],u.push(new Category({Name:f.phraseAll,Level:0})),e=r.length-1;e>=0;e--)u.push(r[e]);f.categoryCrumbs(u)}};f.SetSubCategoryCrumbs=function(n){for(var i,r=[],t=0;t<n.length;t++)i=n[t],i.first=t===0,r.push(i);f.subCategories(r)};f.ToggleSeries=function(n){f.expandedSeries()!=null&&n.index!==f.expandedSeries().index&&f.expandedSeries().contractProducts();f.expandedSeries(n);n.IsHydrated()?n.toggleDisplayProducts():t.GetProductsForSeries(f.storeSession().id,n.Id).then(function(t){var i=new ProductListScroller(t,r,u,"Titles in Series",n.Id);n.PopulateProductsSliderAndExpand(i)},common.ProcessAjaxError)};f.UpdateShowing();f.PopulateCategories(n.Categories);f.SetSearchCategories()},StoreItem=function(n){var t=this;ko.utils.extend(t,n);t.Url=ko.computed(function(){return"?prod="+t.Id})},StoreLandingPage=function(n,t,i){var r=this;ko.utils.extend(r,new Store(n,t,i));r.title=null;r.SiteSwitchModalVisible=ko.observable(!1);r.SiteSwitchCountry=ko.observable("");r.SiteSwitchUrl=ko.observable("");r.SiteSwitchDefault=ko.observable(!1);r.SiteSwitchDisplayUrl=ko.computed(function(){if(r.SiteSwitchUrl().length===0)return"";var n=r.SiteSwitchUrl();return n.substring(n.indexOf("://")+3,n.lastIndexOf("/"))});r.ShowSiteSwitchModal=function(){r.SiteSwitchModalVisible(!0)};r.PromptSwitchToMarket=function(n,t){console.log("MarketUrl",n);n&&(window.heap&&heap.track("Prompt Site Switch",{from:t,to:n.Name}),r.SiteSwitchCountry(n.Name),r.SiteSwitchUrl(n.Url),r.ShowSiteSwitchModal(!0))};r.GeolocateIP=function(){t.GeolocateIP().then(function(t){var i,u;console.log("Geolocation Data",t);t.Success?(i=ko.utils.arrayFirst(n.MarketUrls,function(n){return n.Id===t.MarketId}),i&&i.Id!=r.MarketId&&r.PromptSwitchToMarket(i,t.MarketName)):r.IsDefaultMarket||(u=ko.utils.arrayFirst(n.MarketUrls,function(n){return n.IsDefault}),u&&(r.SiteSwitchDefault(!0),r.PromptSwitchToMarket(u,"Rest of World")))})};r.GeolocateIP()},StoreSearch=function(n,t,i,r,u){var f=this;console.log("modelData",u);f.QueryStringCategoryIdVariable="cat";f.QueryStringCategoryId=function(){return common.GetQueryStringParameterByName(f.QueryStringCategoryIdVariable)};f.QueryStringKeywordsVariable="keywords";f.QueryStringKeywords=function(){return common.GetQueryStringParameterByName(f.QueryStringKeywordsVariable)};f.QueryStringOrderByVariable="orderBy";f.QueryStringOrderBy=function(){return common.GetQueryStringParameterByName(f.QueryStringOrderByVariable)};f.QueryStringFromAgeVariable="fromAge";f.QueryStringFromAge=function(){return common.GetQueryStringParameterByName(f.QueryStringFromAgeVariable)};f.QueryStringToAgeVariable="toAge";f.QueryStringToAge=function(){return common.GetQueryStringParameterByName(f.QueryStringToAgeVariable)};f.searchMode=ko.observable(!1);f.filterMode=ko.observable(!1);f.showFilters=ko.observable(!0);f.allowYearFilter=ko.observable(!1);f.allowSubjectFilter=ko.observable(!1);f.totalCount=ko.observable(0);f.take=ko.observable(20);f.skip=ko.observable(0);f.showing=ko.observable();f.author=ko.observable(t);f.ageRanges=ko.observableArray();f.allResourceTypes=ko.observableArray(u.AvailableResourceTypes);f.allThemes=ko.observableArray(u.AvailableThemes);f.allTopics=ko.observableArray(u.AvailableTopics);f.learningArea=ko.observable(u.LearningArea);f.learningAreaLevels=ko.observable(u.LearningArea?_.orderBy(_.filter(u.LearningArea.Levels,function(n){return n.Children==null||n.Children.length===0}),function(n){return n.Name}):[]);f.fromAge=ko.observable(0).extend({rateLimit:500});f.toAge=ko.observable(18).extend({rateLimit:500});f.fromYear=ko.observable(1).extend({rateLimit:500});f.toYear=ko.observable(13).extend({rateLimit:500});f.keywordsString=ko.observable(f.QueryStringKeywords());f.searchCategory=ko.observable(null);f.searchCategories=ko.observableArray(null);f.filterProductTheme=ko.observableArray([]);f.filterProductTopic=ko.observableArray([]);f.filterProductResourceType=ko.observableArray([]);f.filterProductLevel=ko.observableArray([]);f.expandFilterAge=ko.observable(!0);f.expandFilterTheme=ko.observable(!0);f.expandFilterTopic=ko.observable(!0);f.expandFilterResourceType=ko.observable(!0);f.expandFilterLevel=ko.observable(!0);f.expandFilterLearningArea=ko.observable(!1);f.toggleShowFilters=function(){f.showFilters(!f.showFilters())};f.filterAgeDisplay=ko.computed(function(){return u?f.fromAge()==0&&f.toAge()==18?[]:["Age "+f.fromAge()+"-"+f.toAge()]:[]});f.filterYearDisplay=ko.computed(function(){return u?f.fromAge()==0&&f.toAge()==18?[]:["Years "+f.fromYear()+"-"+f.toYear()]:[]});f.filterThemeDisplay=ko.computed(function(){return!u||!u.Themes?[]:_.compact(_.map(f.filterProductTheme(),function(n){var t=_.find(u.Themes,function(t){return t.Id==n});return t?{Id:n,Name:t.Name}:null}))});f.filterTopicDisplay=ko.computed(function(){return u?_.compact(_.map(f.filterProductTopic(),function(n){var t=_.find(u.Topics,function(t){return t.Id==n});return t?{Id:n,Name:t.Name}:null})):[]});f.filterResourceTypeDisplay=ko.computed(function(){return u?_.compact(_.map(f.filterProductResourceType(),function(n){var t=_.find(u.ResourceTypes,function(t){return t.Id==n});return t?{Id:n,Name:t.Name}:null})):[]});f.filterLevelDisplay=ko.computed(function(){return u?u.LearningArea?_.compact(_.map(f.filterProductLevel(),function(n){var t=_.find(u.LearningArea.Levels,function(t){return t.Id==n});return t?{Id:n,Name:t.Name}:null})):[]:[]});f.toggleFilter=function(n){n(!n())};f.clearAgeFilter=function(){f.fromYear(1);f.toYear(13);_.each(f.ageRanges(),function(n){n.selected(!1)})};f.clearThemeFilter=function(){f.filterProductTheme([])};f.clearTopicFilter=function(){f.filterProductTopic([])};f.clearResourceTypeFilter=function(){f.filterProductResourceType([])};f.clearLevelFilter=function(){f.filterProductLevel([])};f.hasFilters=ko.computed(function(){var n=f.filterAgeDisplay().length+f.filterThemeDisplay().length+f.filterTopicDisplay().length+f.filterResourceTypeDisplay().length+f.filterLevelDisplay().length;return n>0});f.productOrderByOptionId=ko.observable(f.QueryStringOrderBy()?f.QueryStringOrderBy():0);f.previousProductOrderByOptionId=ko.observable(0);f.TrackSearch=function(){common.FacebookEvent("Search")};f.RefreshSearch=function(){f.searchMode()&&(f.TrackSearch(),setTimeout(function(){$("form#search").submit()},500))};f.SubmitSearch=function(){return f.TrackSearch(),!0};f.SelectSearchCategory=function(n){f.searchCategory(n);f.RefreshSearch()};f.SetSearchCategories=function(){var i=_.map(n,function(n){return{id:n.Id,name:n.Name}}),t,u;i.unshift({name:r.allCategories});f.searchCategories(i);t=f.QueryStringCategoryId();t!==null&&t!==""&&(u=_.find(f.searchCategories(),function(n){return n.id===t}),f.searchCategory(u))};f.AgeRangesChanged=function(){var t=ko.utils.arrayFilter(f.ageRanges(),function(n){return n.selected()&&!n.all}),i=t[0],n=ko.utils.arrayFirst(f.ageRanges(),function(n){return n.all}),r,u;i?(r=t[t.length-1],ko.utils.arrayForEach(f.ageRanges(),function(n){n.from>i.from&&n.to<r.to&&!n.selected()&&n.selected(!0)}),f.fromAge(i.from),f.toAge(r.to),n.selected()&&n.selected(!1)):(f.fromAge(0),f.toAge(18),n.selected()||n.selected(!0));u={fromAge:f.fromAge(),toAge:f.toAge()};ko.postbox.publish("age.ranges.changed",u)};f.AgesChanged=function(){var n={fromAge:f.fromAge(),toAge:f.toAge()};ko.postbox.publish("age.ranges.changed",n)};f.PopulateFilters=function(){i&&i.Query&&(f.filterProductTheme(_.map(i.Query.FilterProductTheme,function(n){return n.toString()})),f.filterProductTopic(_.map(i.Query.FilterProductTopic,function(n){return n.toString()})),f.filterProductResourceType(_.map(i.Query.FilterProductResourceType,function(n){return n.toString()})),f.filterProductLevel(_.map(i.Query.FilterProductLevel,function(n){return n.toString()})))};f.CheckInvalidFilters=function(){var r,n,e,t,o,i;u.Themes?(r=_.map(u.Themes,function(n){return n.Id}),n=_.intersection(f.filterProductTheme(),r),n.length!=f.filterProductTheme().length&&f.filterProductTheme(n)):f.filterProductTheme().length>0&&f.filterProductTheme([]);u.LearningArea?(e=_.map(u.LearningArea.Levels,function(n){return n.Id}),t=_.intersection(f.filterProductLevel(),e),t.length!=f.filterProductLevel().length&&f.filterProductLevel(t)):f.filterProductLevel().length>0&&f.filterProductLevel([]);u.ResourceType?(o=_.map(u.ResourceType,function(n){return n.Id}),i=_.intersection(f.filterProductResourceType(),o),i.length!=f.filterProductResourceType().length&&f.filterProductResourceType(i)):f.filterProductLevel().length>0&&f.filterProductResourceType([])};f.PopulateAgeRanges=function(){var n,t,u;for(i&&i.Query&&(f.fromAge(i.Query.FromAge),f.toAge(i.Query.ToAge),f.fromYear(Math.max(i.Query.FromAge-4,1)),f.toYear(Math.max(i.Query.ToAge-4,1))),n=[],n.push({from:0,to:5}),t=5;t<14;t++)n.push({from:t,to:t+1});n.push({from:14,to:18});ko.utils.arrayForEach(n,function(n){n.selected=ko.observable(n.from>=f.fromAge()&&n.to<=f.toAge()&&!(f.fromAge()==0&&f.toAge()==18));n.name=n.from+"-"+n.to;n.toggleSelected=function(){n.selected(!n.selected())};n.selected.subscribe(function(){f.AgeRangesChanged();f.RefreshSearch()})});u={all:!0,from:0,to:18,name:r.allAges,selected:ko.observable(f.fromAge()===0&&f.toAge()===18)};u.toggleSelected=function(){u.selected(!0);ko.utils.arrayForEach(f.ageRanges(),function(n){n.all||n.selected(!1)});f.AgeRangesChanged();f.RefreshSearch()};n.push(u);f.ageRanges(n)};f.hasAgeRangesSelected=ko.computed(function(){var n=ko.utils.arrayFilter(f.ageRanges(),function(n){return n.selected()});return n.length>0});f.selectedAgeRangeDescription=ko.computed(function(){return f.hasAgeRangesSelected()?f.fromAge()===0&&f.toAge()===18?r.allAges:r.ages+" "+f.fromAge()+"-"+f.toAge():r.allAges});f.ProductAttributesChanged=function(){if(console.log("product Attributes changed"),f.searchMode())setTimeout(f.RefreshSearch,100);else{var n={theme:f.filterProductTheme(),topic:f.filterProductTopic(),resourceType:f.filterProductResourceType(),level:f.filterProductLevel()};ko.postbox.publish("product.attributes.changed",n)}};f.PopulateFilters();f.PopulateAgeRanges();f.filterProductTheme.subscribe(f.ProductAttributesChanged);f.filterProductResourceType.subscribe(f.ProductAttributesChanged);f.filterProductTopic.subscribe(f.ProductAttributesChanged);f.filterProductLevel.subscribe(f.ProductAttributesChanged);f.fromAge.subscribe(f.AgesChanged);f.toAge.subscribe(f.AgesChanged);f.fromYear.subscribe(function(n){f.fromAge(n==1?0:n+4)});f.toYear.subscribe(function(n){f.toAge(n==13?18:n+4)});f.SetSearchCategories();setTimeout(f.CheckInvalidFilters,100)},StoreSession=function(n){var t=this;t.id=n.Id;t.basketLines=ko.observable(n.BasketLines);t.basketLineCount=ko.observable(n.BasketLineCount);t.wishListCount=ko.observable(n.WishListCount);t.promoMessages=ko.observableArray(n.PromoMessage);t.specialOfferId=ko.observable(n.SpecialOfferId);t.specialOfferCount=ko.observable(n.SpecialOfferCount);t.hasStoreCredit=ko.observable(n.HasStoreCredit);t.storeCreditAvailable=ko.observable(n.StoreCreditAvailable)};var SubscriptionProductDetail=function(n){var i=this,t,r;for(ko.utils.extend(i,new ProductDetail(n)),t=0;t<i.Product().productPrices().length;t++)r=i.Product().productPrices()[t],r.requiresDelivery=!1,r.chosenQty(1)},SubscriptionsPage=function(n){var t=this;ko.utils.extend(t,new Store(n));t.title=null;t.id=n.Id;t.products=ko.observableArray();t.categories=ko.observableArray();t.PopulateProducts=function(n){var r,i,u,f;if(n!=null&&n.length!=0)for(r=0;r<n.length;r++){for(i=new Product(n[r]),i.index=t.products().length+1,i.Hydrate(),u=0;u<i.productPrices().length;u++)f=i.productPrices()[u],f.requiresDelivery=!1,f.chosenQty(1);t.products.push(i)}};t.PopulateCategories=function(n){var r=$.map(n,function(n){return new Category(n)}),i;for(t.categories(r),i=0;i<t.categories().length;i++)t.categories()[i].SetPerentCategory(null)};t.PopulateCategories(n.Categories);t.PopulateProducts(n.Subscriptions)},WishlistItem=function(n){var t=this;t.id=n.Id;t.product=new Product(n.Product)},WishListItemSetter=function(){var n=this;n.StoreSessionId=null;n.ProductId=null},StoreService=function(n){var t=this,i;t.urls=n;i=new AjaxService;t.SaveBasketLineSpecific=function(t,i,r,u){var f={StoreSessionId:t,ProductPriceId:i,Quantity:u,MarketId:r};return $.ajax(n.apiBasketLine,{data:JSON.stringify(f),type:"post",contentType:"application/json; charset=utf-8'"})};t.AddMultipleToCart=function(t,i){var r=n.apiBasketLine+"?storeSessionId="+t+"&productPriceIds="+i.join(",");return $.ajax(r,{type:"post",contentType:"application/json; charset=utf-8'"})};t.GetBasket=function(t){return $.ajax(n.apiBasket+"?storeSessionId="+t,{type:"get",cache:!1})};t.GetPriceBreakdown=function(t){return $.ajax(n.apiBasket+"/PriceBreakdown?storeSessionId="+t,{type:"get",cache:!1})};t.GetPromoMessage=function(t){return $.ajax(n.apiBasket+"/PromoMessage?storeSessionId="+t,{type:"get",cache:!1})};t.GetWishlist=function(t){return $.ajax(n.apiWishlist+"?storeSessionId="+t,{type:"get",cache:!1})};t.DeleteBasket=function(t){return $.ajax(n.apiBasket+"?storeSessionId="+t,{type:"delete"})};t.GetPromotion=function(t){return $.ajax(n.apiPromoCode+"/Product/"+t,{type:"get"})};t.GetDetailsExtension=function(t){return $.ajax(n.apiProductDetail+"?productId="+t,{type:"get"})};t.GetKitsetComponentModels=function(t){return $.ajax(n.apiProductDetail+"/KitsetComponentModels?productId="+t,{type:"get"})};t.ToggleWishlistItem=function(t,r){var u=n.apiWishlist+"?storeSessionId="+t+"&productId="+r;return i.post(u)};t.SaveWishlistItem=function(t,i){var r={StoreSessionId:t,ProductId:i};return $.ajax(n.apiWishlist,{data:JSON.stringify(r),type:"post",contentType:"application/json; charset=utf-8'"})};t.DeleteWishlistItem=function(t,i){var r={StoreSessionId:t,ProductId:i};return $.ajax(n.apiWishlist,{data:JSON.stringify(r),type:"delete",contentType:"application/json; charset=utf-8'"})};t.RefreshStoreSession=function(t){return $.ajax(n.apiStoreSession,{data:"id="+t,type:"get",cache:!1})};t.PopulateSeries=function(t){return $.ajax(n.apiSeriesSearch,{data:JSON.stringify(t),type:"post",contentType:"application/json; charset=utf-8'"})};t.QuickAddSearch=function(t){return $.ajax(n.apiProductSearch+"/QuickAddSearch?quickAddSearchTerm="+t,{type:"get",cache:!1})};t.GetProductsForSeries=function(t,i){return $.ajax(n.apiProductSearch+"/GetProductsForSeries?storeSessionId="+t+"&seriesId="+i,{type:"get",cache:!1})};t.PopulateProducts=function(t){return $.ajax(n.apiProductSearch,{data:JSON.stringify(t),type:"post",contentType:"application/json; charset=utf-8'"})};t.SaveFilters=function(t,i,r,u,f,e){var o=n.apiStoreSession+"?storeSessionId="+t+"&fromAge="+i+"&toAge="+r+"&resourceTypes="+u.join(",")+"&levels="+f.join(",")+"&themes="+e.join(",");return $.ajax(o,{type:"post",contentType:"application/json; charset=utf-8'"})};t.SchoolSearch=function(t,i){return $.ajax({type:"get",dataType:"json",url:n.apiSchool+"/Search",cache:!0,data:{query:t,marketId:i}})};t.SchoolSearchByLocation=function(t,i){return $.ajax({type:"get",dataType:"json",url:n.apiSchool+"/SearchByLocation?postcode="+t+"&city="+i,cache:!1})};t.GetSchool=function(t){return $.ajax({type:"get",dataType:"json",url:n.apiSchool+"/Search/"+t,cache:!0})};t.GetSchoolAddress=function(t){return $.ajax({type:"get",dataType:"json",url:n.apiSchoolAddress+"?schoolId="+t,cache:!0})};t.SetSchool=function(i,r){if(!r)return t.ClearSessionValue(i,"schoolId");var u=n.apiBasket+"?storeSessionId="+i+"&schoolId="+r;return $.ajax(u,{type:"post",error:common.ProcessAjaxError})};t.SetSchoolName=function(i,r){if(!r)return t.ClearSessionValue(i,"schoolName");var u=n.apiBasket+"?storeSessionId="+i+"&schoolName="+r;return $.ajax(u,{type:"post",error:common.ProcessAjaxError})};t.SetMarket=function(t,i){var r=n.apiBasket+"?storeSessionId="+t+"&marketId="+i;return $.ajax(r,{type:"post",error:common.ProcessAjaxError})};t.SetPromoCode=function(t,i,r){var u=n.apiBasket+"?storeSessionId="+t+"&promoCode="+i+"&force="+!!r;return $.ajax(u,{type:"post"})};t.RemovePromoCode=function(t,i){var r=n.apiBasket+"?storeSessionId="+t+"&promoCodeId="+i;return $.ajax(r,{type:"post"})};t.SaveApprovalResponse=function(t){var r=n.apiApprovalOrderResponse;return i.post(r,JSON.stringify(t))};t.SaveInvoiceResponse=function(t){var r=n.apiInvoiceOrderResponse;return i.post(r,JSON.stringify(t))};t.SaveApprovalOfferFeedback=function(t,r){var u=n.apiApprovalOffer+"?offerId="+t+"&feedback="+encodeURIComponent(r);return i.post(u,{})};t.UserSearch=function(t){return $.ajax({type:"get",dataType:"json",url:n.apiSignUp+"/Search",cache:!1,data:{email:t}})};t.GeolocateIP=function(){return $.ajax(n.apiGeolocation,{type:"get",cache:!1})}},Client;(function(n){var t=function(){function n(n){this.id=ko.observable();this.name=ko.observable();this.type=ko.observable();this.productCount=ko.observable();this.fromJs(n)}return n.prototype.fromJs=function(n){this.id(n.Id);this.name(n.Name);this.type(n.Type);this.productCount(n.ProductCount)},n.prototype.toJs=function(){return{Id:this.id(),Name:this.name(),Type:this.type(),ProductCount:this.productCount()}},n}();n.KnockoutProductAttribute=t})(Client||(Client={})),function(n){var t=function(){function n(n){this.id=ko.observable();this.code=ko.observable();this.firstName=ko.observable();this.lastName=ko.observable();this.promotionTextParagraph=ko.observable();this.imageId=ko.observable();this.imageUrl=ko.observable();this.name=ko.observable();this.hasBlurb=ko.observable();this.fromJs(n)}return n.prototype.fromJs=function(n){this.id(n.Id);this.code(n.Code);this.firstName(n.FirstName);this.lastName(n.LastName);this.promotionTextParagraph(n.PromotionTextParagraph);this.imageId(n.ImageId);this.imageUrl(n.ImageUrl);this.name(n.Name);this.hasBlurb(n.HasBlurb)},n.prototype.toJs=function(){return{Id:this.id(),Code:this.code(),FirstName:this.firstName(),LastName:this.lastName(),PromotionTextParagraph:this.promotionTextParagraph(),ImageId:this.imageId(),ImageUrl:this.imageUrl(),Name:this.name(),HasBlurb:this.hasBlurb()}},n}();n.KnockoutAuthorStoreItemModel=t}(Client||(Client={})),function(n){var t=function(){function n(n){this.id=ko.observable();this.name=ko.observable();this.description=ko.observable();this.mediaPrefix=ko.observable();this.order=ko.observable();this.priceWithoutGST=ko.observable();this.regularPriceWithoutGST=ko.observable();this.marketId=ko.observable();this.isDigital=ko.observable();this.requiresDelivery=ko.observable();this.isSpecial=ko.observable();this.schoolInvoicingAllowed=ko.observable();this.price=ko.observable();this.regularPrice=ko.observable();this.fromJs(n)}return n.prototype.fromJs=function(n){this.id(n.Id);this.name(n.Name);this.description(n.Description);this.mediaPrefix(n.MediaPrefix);this.order(n.Order);this.priceWithoutGST(n.PriceWithoutGST);this.regularPriceWithoutGST(n.RegularPriceWithoutGST);this.marketId(n.MarketId);this.isDigital(n.IsDigital);this.requiresDelivery(n.RequiresDelivery);this.isSpecial(n.IsSpecial);this.schoolInvoicingAllowed(n.SchoolInvoicingAllowed);this.price(n.Price);this.regularPrice(n.RegularPrice)},n.prototype.toJs=function(){return{Id:this.id(),Name:this.name(),Description:this.description(),MediaPrefix:this.mediaPrefix(),Order:this.order(),PriceWithoutGST:this.priceWithoutGST(),RegularPriceWithoutGST:this.regularPriceWithoutGST(),MarketId:this.marketId(),IsDigital:this.isDigital(),RequiresDelivery:this.requiresDelivery(),IsSpecial:this.isSpecial(),SchoolInvoicingAllowed:this.schoolInvoicingAllowed(),Price:this.price(),RegularPrice:this.regularPrice()}},n}();n.KnockoutProductPriceStoreItemModel=t}(Client||(Client={})),function(n){var t=function(){function t(n){this.id=ko.observable();this.marketId=ko.observable();this.code=ko.observable();this.name=ko.observable();this.isbn=ko.observable();this.subtitle=ko.observable();this.seriesDescription=ko.observable();this.description=ko.observable();this.imageUrl=ko.observable();this.smallImageUrl=ko.observable();this.largeImageUrl=ko.observable();this.authors=ko.observableArray([]);this.productPrices=ko.observableArray([]);this.categoryIds=ko.observableArray([]);this.fromAge=ko.observable();this.toAge=ko.observable();this.isInWishlist=ko.observable();this.isSubscription=ko.observable();this.seriesOrder=ko.observable();this.resourceTypes=ko.observableArray([]);this.themes=ko.observableArray([]);this.topics=ko.observableArray([]);this.numberOfPages=ko.observable();this.datePublished=ko.observable();this.fromYear=ko.observable();this.toYear=ko.observable();this.lowestPrice=ko.observable();this.isKitsetParent=ko.observable();this.isProductCatalogue=ko.observable();this.fromJs(n)}return t.prototype.fromJs=function(t){this.id(t.Id);this.marketId(t.MarketId);this.code(t.Code);this.name(t.Name);this.isbn(t.ISBN);this.subtitle(t.Subtitle);this.seriesDescription(t.SeriesDescription);this.description(t.Description);this.imageUrl(t.ImageUrl);this.smallImageUrl(t.SmallImageUrl);this.largeImageUrl(t.LargeImageUrl);this.categoryIds(t.CategoryIds);this.fromAge(t.FromAge);this.toAge(t.ToAge);this.isInWishlist(t.IsInWishlist);this.isSubscription(t.IsSubscription);this.seriesOrder(t.SeriesOrder);this.resourceTypes(t.ResourceTypes);this.themes(t.Themes);this.topics(t.Topics);this.numberOfPages(t.NumberOfPages);this.datePublished(t.DatePublished);this.fromYear(t.FromYear);this.toYear(t.ToYear);this.lowestPrice(t.LowestPrice);this.isKitsetParent(t.IsKitsetParent);this.isProductCatalogue(t.IsProductCatalogue);this.authors(t.Authors.map(function(t){return new n.KnockoutAuthorStoreItemModel(t)}));this.productPrices(t.ProductPrices.map(function(t){return new n.KnockoutProductPriceStoreItemModel(t)}))},t.prototype.toJs=function(){return{Id:this.id(),MarketId:this.marketId(),Code:this.code(),Name:this.name(),ISBN:this.isbn(),Subtitle:this.subtitle(),SeriesDescription:this.seriesDescription(),Description:this.description(),ImageUrl:this.imageUrl(),SmallImageUrl:this.smallImageUrl(),LargeImageUrl:this.largeImageUrl(),CategoryIds:this.categoryIds(),FromAge:this.fromAge(),ToAge:this.toAge(),IsInWishlist:this.isInWishlist(),IsSubscription:this.isSubscription(),SeriesOrder:this.seriesOrder(),ResourceTypes:this.resourceTypes(),Themes:this.themes(),Topics:this.topics(),NumberOfPages:this.numberOfPages(),DatePublished:this.datePublished(),FromYear:this.fromYear(),ToYear:this.toYear(),LowestPrice:this.lowestPrice(),IsKitsetParent:this.isKitsetParent(),IsProductCatalogue:this.isProductCatalogue(),Authors:this.authors().map(function(n){return n.toJs()}),ProductPrices:this.productPrices().map(function(n){return n.toJs()})}},t}();n.KnockoutProductStoreItemModel=t}(Client||(Client={})),function(n){var t=function(){function t(n){this.id=ko.observable();this.marketId=ko.observable();this.code=ko.observable();this.name=ko.observable();this.isbn=ko.observable();this.subtitle=ko.observable();this.seriesDescription=ko.observable();this.description=ko.observable();this.imageUrl=ko.observable();this.smallImageUrl=ko.observable();this.largeImageUrl=ko.observable();this.authors=ko.observableArray([]);this.productPrices=ko.observableArray([]);this.categoryIds=ko.observableArray([]);this.fromAge=ko.observable();this.toAge=ko.observable();this.isInWishlist=ko.observable();this.isSubscription=ko.observable();this.seriesOrder=ko.observable();this.resourceTypes=ko.observableArray([]);this.themes=ko.observableArray([]);this.topics=ko.observableArray([]);this.numberOfPages=ko.observable();this.datePublished=ko.observable();this.fromYear=ko.observable();this.toYear=ko.observable();this.lowestPrice=ko.observable();this.isKitsetParent=ko.observable();this.isProductCatalogue=ko.observable();this.title=ko.observable();this.authorNames=ko.observable();this.seriesStoreItemViewModels=ko.observableArray([]);this.relatedProducts=ko.observableArray([]);this.productPreviews=ko.observableArray([]);this.authorsToDisplay=ko.observableArray([]);this.fromJs(n)}return t.prototype.fromJs=function(t){this.id(t.Id);this.marketId(t.MarketId);this.code(t.Code);this.name(t.Name);this.isbn(t.ISBN);this.subtitle(t.Subtitle);this.seriesDescription(t.SeriesDescription);this.description(t.Description);this.imageUrl(t.ImageUrl);this.smallImageUrl(t.SmallImageUrl);this.largeImageUrl(t.LargeImageUrl);this.categoryIds(t.CategoryIds);this.fromAge(t.FromAge);this.toAge(t.ToAge);this.isInWishlist(t.IsInWishlist);this.isSubscription(t.IsSubscription);this.seriesOrder(t.SeriesOrder);this.resourceTypes(t.ResourceTypes);this.themes(t.Themes);this.topics(t.Topics);this.numberOfPages(t.NumberOfPages);this.datePublished(t.DatePublished);this.fromYear(t.FromYear);this.toYear(t.ToYear);this.lowestPrice(t.LowestPrice);this.isKitsetParent(t.IsKitsetParent);this.isProductCatalogue(t.IsProductCatalogue);this.authors(t.Authors.map(function(t){return new n.KnockoutAuthorStoreItemModel(t)}));this.productPrices(t.ProductPrices.map(function(t){return new n.KnockoutProductPriceStoreItemModel(t)}));this.title(t.Title);this.authorNames(t.AuthorNames);this.seriesStoreItemViewModels(t.SeriesStoreItemViewModels.map(function(t){return new n.KnockoutSeriesStoreItemModel(t)}));this.relatedProducts(t.RelatedProducts.map(function(t){return new n.KnockoutProductStoreItemModel(t)}));this.productPreviews(t.ProductPreviews.map(function(t){return new n.KnockoutProductPreviewStoreItemModel(t)}));this.authorsToDisplay(t.AuthorsToDisplay.map(function(t){return new n.KnockoutAuthorStoreItemModel(t)}))},t.prototype.toJs=function(){return{Id:this.id(),MarketId:this.marketId(),Code:this.code(),Name:this.name(),ISBN:this.isbn(),Subtitle:this.subtitle(),SeriesDescription:this.seriesDescription(),Description:this.description(),ImageUrl:this.imageUrl(),SmallImageUrl:this.smallImageUrl(),LargeImageUrl:this.largeImageUrl(),CategoryIds:this.categoryIds(),FromAge:this.fromAge(),ToAge:this.toAge(),IsInWishlist:this.isInWishlist(),IsSubscription:this.isSubscription(),SeriesOrder:this.seriesOrder(),ResourceTypes:this.resourceTypes(),Themes:this.themes(),Topics:this.topics(),NumberOfPages:this.numberOfPages(),DatePublished:this.datePublished(),FromYear:this.fromYear(),ToYear:this.toYear(),LowestPrice:this.lowestPrice(),IsKitsetParent:this.isKitsetParent(),IsProductCatalogue:this.isProductCatalogue(),Title:this.title(),AuthorNames:this.authorNames(),Authors:this.authors().map(function(n){return n.toJs()}),ProductPrices:this.productPrices().map(function(n){return n.toJs()}),SeriesStoreItemViewModels:this.seriesStoreItemViewModels().map(function(n){return n.toJs()}),RelatedProducts:this.relatedProducts().map(function(n){return n.toJs()}),ProductPreviews:this.productPreviews().map(function(n){return n.toJs()}),AuthorsToDisplay:this.authorsToDisplay().map(function(n){return n.toJs()})}},t}();n.KnockoutProductStoreItemDetailModel=t}(Client||(Client={})),function(n){var t=function(){function n(n){this.imageUrl=ko.observable();this.fromJs(n)}return n.prototype.fromJs=function(n){this.imageUrl(n.ImageUrl)},n.prototype.toJs=function(){return{ImageUrl:this.imageUrl()}},n}();n.KnockoutProductPreviewStoreItemModel=t}(Client||(Client={}))