var media="large",mqmedium=1200,mqsmall=780,mqxsmall=600,mqxxsmall=420,mqxxxsmall=240;
function mediaCheck(){Modernizr.mq("(min-width: "+(mqmedium+1)+"px)")?media="large":Modernizr.mq("(min-width: "+(mqsmall+1)+"px) and (max-width: "+mqmedium+"px)")?media="medium":Modernizr.mq("(min-width: "+(mqxsmall+1)+"px) and (max-width: "+mqsmall+"px)")?media="small":Modernizr.mq("(min-width: "+(mqxxsmall+1)+"px) and (max-width: "+mqxsmall+"px)")?media="xsmall":Modernizr.mq("(min-width: "+(mqxxxsmall+1)+"px) and (max-width: "+mqxxsmall+"px)")?media="xxsmall":Modernizr.mq("(min-width: 0px) and (max-width: "+
mqxxxsmall+"px)")&&(media="xxxsmall")}function resppic(){$(".resppic").each(function(){var a="";if("large"==media||"medium"==media)a=$(this).attr("data-dtpic");else if("small"==media||"xsmall"==media)a=$(this).attr("data-tabpic");else if("xxsmall"==media||"xxxsmall"==media)a=$(this).attr("data-mobpic");""!==a&&($(this).hasClass("respbg")?$(this).css("background-image","url("+a+")"):$(this).attr("src",a))})}$(window).resize(function(a){mediaCheck();resppic()});mediaCheck();resppic();
$(".togglenav").on("click",function(){if($("#wrapper, html").hasClass("active"))a=$(".mobmenu").outerWidth(),$("html, body").animate({scrollLeft:-+a},400,function(){$("#wrapper, html").removeClass("active")});else{$("#wrapper, html").addClass("active");var a=$(".mobmenu").outerWidth();$("html, body").animate({scrollLeft:a},400)}});$(".formtoggle").on("click",function(){$(".generic-form").toggleClass("active")});$(".addtobutton").on("click",function(){$(this).addClass("active")});
$(".addtobutton li").on("click",function(){$(this).toggleClass("active")});$(document).on("click",".addtobox li",function(){$(this).siblings().removeClass("active");$(this).addClass("active");$(this).find("input:radio").prop("checked",!0)});$(".addtobutton .addtobox .closepop").on("click",function(a){a.stopPropagation();$(this).parent(".addtobox").parent(".addtobutton").removeClass("active")});var $container=$(".packlist");$container.packery({itemSelector:".packitem",gutter:0});var imageCount=$(".packitem img").length;
$(".packitem img").one("load",function(){imageCount--;(1>=imageCount||0==imageCount%50)&&$container.packery()}).each(function(){this.complete&&$(this).load()});$("#submitcomment").on("submit",function(a){a.preventDefault();$.ajax({type:"POST",url:$(this).attr("action"),data:$(this).serialize(),dataType:"json",success:function(a){$("#response-message").empty();$("#response-message").append(a.response);!0===a.success&&$("#comment").val("")}})});
$(document).on("submit",".addrecipe",function(a){a.preventDefault();$.ajax({type:"POST",url:$(this).attr("action"),data:$(this).serialize(),dataType:"json",success:function(a){!0===a.success&&$(".addtoboxid"+a.recipeid).fadeOut(200,function(){$(this).empty().append(a.message).fadeIn().delay(2E3).fadeOut(500,function(){$(a.html).hide().appendTo(".hoverbox"+a.recipeid).fadeIn(200)})})}})});$(document).on("click",".popuploginbtn",function(){$(".curtain, .login-popup").removeAttr("style")});
$(document).on("click",".popupcreatebtn",function(){$(".curtain, .signup-popup").removeAttr("style")});$(document).on("click",".closepop, .curtain",function(){$(".curtain, .login-popup, .signup-popup").css("display","none")});$(document).on("click",".popupsavebtn",function(a){a.preventDefault();recipeid=$(this).data("recipeid");$.ajax({type:"POST",url:"/save-recipe-popup",data:{data:recipeid},dataType:"json",success:function(a){$(".hoverbox"+recipeid).empty();$(".hoverbox"+recipeid).append(a.html)}})});
$(document).on("click",".deleterecipe",function(a){a.preventDefault();recipeid=$(this).data("recipeid");$.ajax({type:"POST",url:"/cookbook-member?a=deletechapter",data:{data:recipeid},dataType:"json",success:function(a){$(".cookbookrecipe"+a.recipeid).remove()}})});
$(document).on("submit",".login-popup-form",function(a){a.preventDefault();$.ajax({type:"POST",url:$(this).attr("action"),data:$(this).serialize(),dataType:"json",success:function(a){!1===a.success?$(".response-message").append(a.message):window.location.reload(!0)}})});$(document).on("click",".logout",function(a){a.preventDefault();data="";$.ajax({type:"POST",url:"/logout",data:data,dataType:"json",success:function(a){window.location.reload(!0)}})});
$(document).on("click",".recipelist li",function(){recipeid=$(this).data("recipeid");$.ajax({type:"POST",url:"/feature-recipe",data:{data:recipeid},dataType:"json",success:function(a){$(".recipelist li").removeClass("active");$('[data-recipeid="'+a.recipeid+'"]').addClass("active");$(".mainrecipe").empty();$(".mainrecipe").append(a.html)}})});
$(document).on("submit",".newsletter-signup",function(a){a.preventDefault();$.ajax({type:"POST",url:$(this).attr("action"),data:$(this).serialize(),dataType:"json",success:function(a){$('input[name="__email"]').val(a.message)}})});$("#product-content").infinitescroll({loading:{finishedMsg:"<p>Sorry, no more articles</p>"},navSelector:".paginationwrap",nextSelector:".next",itemSelector:"#product-content a.articleitem",debug:!1,dataType:"html"},function(a){addElementsToPackery(a)});
$("#tip-content").infinitescroll({loading:{finishedMsg:"<p>Sorry, no more tips</p>"},navSelector:".paginationwrap",nextSelector:".next",itemSelector:"#tip-content li.tipitem",debug:!1,dataType:"html"},function(a){addElementsToPackery(a)});
function addElementsToPackery(a){var b=$(".packlist");b.packery({itemSelector:".packitem",gutter:0});var c=$(".packitem img").length;$(".packitem img").one("load",function(){c--;(1>=c||0==c%50)&&b.packery()}).each(function(){this.complete&&$(this).load()});b.append(a);b.packery("appended",a)};