var zipSupport={$submit:null,tickOriginal:!1,usesCredits:!1,proStatus:null,creditsCount:0,zipTempCollectionStorage:null,maxThatCanBeTicked:0,centerZipCollection:function(){var t,n;$("#zipCollection").height($(document).height());$("#zipCollectionInner").evenIfHidden(function(n){t=n.height()});n=($(window).height()-t)/2;n<30&&(n=30);$("#zipCollectionInner").css("margin-top",n+$(window).scrollTop())},listAdd:function(n){if($("#zipCollectionList .ZCLitem").length>=zipSupport.maxThatCanBeTicked)return zipSupport.displayMaxZipSizeMessage(!1),!1;var i=n.data("filename"),r=n.data("filesize"),t=n.closest(".assetSet");return zipSupport.addToList(i,r,t.data("sponsoror"),t.data("fromfeed"),n.closest(".thumbOptions").find(".ft").text().replace(/\u00a0/,"").replace(/\u00a0.*/,"").replace(/ .*/,""),n.attr("id"),""),!0},addToList:function(n,t,i,r,u,f,e){$("zipCollectionList"+f).length>0||($("#zipCollectionList").append("<div class='ZCLitem "+e+"' data-sponsoror=\""+i+'" data-fromfeed="'+r+'"><div class=ZCLname>'+n+'<\/div><div class=ZCLsize data-raw="'+t+'">'+u+'<\/div><div class=zipCollectionRemove id="zipCollectionList'+f+'"><\/div><\/div>'),zipSupport.updatefilenum(),zipSupport.updatefilesize())},batch:function(n){zipSupport.clear();var t="";$.each(n.Images,function(){zipSupport.addToList(this.Filename,this.FileSize,this.Sponsoror,this.FromFeed,this.FormattedFileSize,this.Id,"jq-batch");t+="&fileIds="+encodeURIComponent(this.RowGuid+"*False")});$("#ZCLshowLinkButton").data("files",t).data("zipNameHint",n.ZipNameHint);zipSupport.openPanel(!0)},listRemove:function(n){$("#zipCollectionList").find(".zipCollectionRemove#zipCollectionList"+n.attr("id")).parent().remove();zipSupport.updatefilenum();zipSupport.updatefilesize();zipSupport.displayMaxZipSizeMessage(!0)},updatefilenum:function(){var n=$(".tn input:checked");$(".filenum").text(n.length);n.length>0?$("#filedownload").removeClass("btn-default disabled").addClass("btn-primary"):$("#filedownload").removeClass("btn-primary").addClass("btn-default disabled")},updatefilesize:function(){var n=0;$(".ZCLsize").each(function(){n=n+$(this).data("raw")});n=n>12e5||n===0?(n/1048576).toFixed(1)+"MB":n>1024?(n/1024).toFixed(0)+"kB":"1kB";$("#zipCollectionSize").html(n)},bundleCopy:function(n){$("#ZCLlink input").val(n[0]);$(".jq-makePermanent:first").data("guid",n[1]);$("#ZCLclipboard").slideDown();$(".jq-expiryMessage:first").text(n[3]);$(".jq-siteUrl:first").text(n[4]);$("#ZCLSeoTitle").val(n[5]).data("packageOldSeo",n[5]);n[2].length>0&&$(".jq-ZCLlinkPassword").data("password",n[2]).text(n[6])},tickSavedTickedItems:function(){var t=amplify.store("tickedthumbs"),i,n;if(t)for(i=t.length,n=0;n<i;n++)$("#"+t[n]).prop("checked",!0).trigger("change");amplify.store("tickedthumbs",null)},saveTickedItems:function(n){var t=[];n.each(function(){t.push($(this).attr("id"))});amplify.store("tickedthumbs",t)},closeZCLlinkEditorContainer:function(){$(".jq-ZCLlinkEditorContainer, .jq-linkError").hide();$(".jq-ZCLlinkContainer").fadeIn()},openPanel:function(n){zipSupport.displayList($("#zipCollection"));$("#ZCLbutCreate").show();$("#zipCollectionHeading").trigger("focus");zipSupport.centerZipCollection();typeof n!="undefined"&&n&&($("#ZCLbutCreate").hide(),zipSupport.openLinkPanel())},openLinkPanel:function(){$("#ZCLclipboard").slideDown();zipSupport.centerZipCollection();$(".jq-nonLiveWarning").toggle(zipSupport.areAnyFilesNonLive())},clear:function(){$("#FileCollectionTabsForm, .jq-attachments").find(".thumbnailset input").attr("checked",!1).each(function(){zipSupport.listRemove($(this))}).parent().removeClass("untick");$("#FileCollectionTabsForm, .jq-attachments").find(".butTickAll").removeClass("untick");zipSupport.updatefilenum();zipSupport.updatefilesize()},init:function(n,t,i,r,u,f,e,o){var h;zipSupport.usesCredits=r||!1;zipSupport.proStatus=u;zipSupport.creditsCount=f||0;zipSupport.maxThatCanBeTicked=o||500;zipSupport.tickOriginal=typeof e=="undefined"?!0:e;$(".btn-download-container.floating").each(function(n,t){$(t).css("min-height",$(t).find(".actionBut").outerHeight(!0)+"px")});$("body").on("click","#filedownload",function(){var r=$(this).closest("form"),i=r.find(".thumbnailset input:checkbox:checked");return i.length===0?!1:t?(zipSupport.saveTickedItems(i),window.location=n,!1):(zipSupport.openPanel(),!1)});if(r)$("body").on("click",".jq-filedl",function(n){var t,i;if(zipSupport.zipTempCollectionStorage=$("#zipCollectionList").html(),t=$(this).closest(".tn").find("input:first"),t.is(":checked")||t.attr("checked",!0).trigger("change"),i=$("#zipCollection .ZCLitem"),i.length===1){if(i.filter("[data-sponsoror='']").length===0)return!0;zipSupport.openPanel()}return n.preventDefault(),!1});if($(".attachedAssets").length>0){var s=$("#filedownload"),l=$("#adminBar").outerHeight(),a=s.offset().top,c=20+l;$(".filedownloadcontainer").css({height:$(".filedownloadcontainer").outerHeight()});$(window).on("scroll",function(){$(window).scrollTop()>a-c?(s.css({top:c,left:$("#filedownload").offset().left}),s.addClass("fixed")):(s.removeClass("fixed"),s.css({top:"auto",left:"auto"}))})}if(!t){$("#ZCLclose").on("click",function(n){n.preventDefault();$("#zipCollection").fadeOut(function(){$("#zipCollectionPreZip, #jq-hiddenPackageFields").show();$("#zipCollectionPostZip, #zipCollectionContainer .jq-ZCLlinkContainer").hide();$(".ZCLitem.jq-batch").remove()});$("#ZCLclipboard input").val("");$("#ZCLclipboard, .jq-ZCLlinkEditorContainer").hide()});$("#ZCLbutDownload").on("click",function(n){var i,f,t,r,e,u;n.preventDefault();i=$("#FileCollectionTabsForm .assetSet");switch($("#zipCollectionList div.ZCLitem").length){case 0:return!1;case 1:if($(".jq-zipcred:visible:first").length===0&&(f=i.find(".thumbnailset input:checkbox:checked").closest(".thumbOptions").find(".jq-thumbdl:first"),f.length===1))return f.trigger("click"),!1}if($(".thumbnailset input:checked:first",i.filter(".ag")).length>0&&!MAIN.ageGateClick(n))return!1;i.has(".thumbnailset input:checked").find("input[name=FileCollectionIds]").prop("checked","checked");t=$("#filedownload");r=t.closest("form");$(this).addClass("butLoading");e=$(".tn div.thumbOptions"+(zipSupport.tickOriginal?".original":".jpgcopy")+" input:not(:checked)").length===0;$(".jq-keepZip",r).val(e?"True":"False");u=r.serialize();t[0].name!==""&&t[0].value!==""&&(u+=(u===""?"":"&")+t[0].name+"="+encodeURIComponent(t[0].value));$.ajax({url:typeof action!="string"?r.attr("action"):action,type:t.hasClass("get")?"GET":"POST",data:u,complete:function(n){MSG.removeButtonLoading();n&&n.responseText&&($("#zipCollectionPreZip").hide(),$("#zipCollectionPostZip").html(n.responseText).fadeIn("fast"))}})});$("#ZCLbutClear").on("click",function(n){n.preventDefault();zipSupport.clear();$("#zipCollection").fadeOut()});$("#ZCLshowLinkButton").on("click",function(n){n.preventDefault();var i=$(this),r=i.data("zipNameHint"),t=i.data("files");typeof t=="undefined"&&(t="",r=$(".thumbnailset input:checkbox:checked").each(function(){t+="&fileIds="+encodeURIComponent($(this).val())}).closest("form").find("input[name=ZipNameHint]").val());var u=$("#Password").val(),f=u.length>0,e=$("#ExpiryDays").val();t!==""&&($("#jq-hiddenPackageFields").fadeOut("fast",function(){$(".jq-ZCLlinkContainer","#zipCollectionContainer").fadeIn("fast")}),$.ajax({url:$(this).addClass("butLoading").data("submiturl"),type:"POST",data:"packageName="+encodeURIComponent(r)+t+"&passwordProtect="+f+"&password="+u+"&expiryDays="+e,complete:MSG.ajaxFormComplete}))});$("#ZCLupdateSeoButton").on("click",function(n){var u,i;n.preventDefault();var t=$("#ZCLSeoTitle").val(),f=new RegExp("[^A-Za-z0-9-]"),r=f.test(t);t!==""&&t.length<70&&!r?($(".jq-linkError").hide(),u=$("#ZCLSeoTitle").data("packageOldSeo"),$.ajax({url:$(this).data("submiturl-seo"),type:"POST",data:"oldSeo="+escape(u)+"&newSeo="+escape(t),success:function(n){switch(n.result){case"y":var i=$(".jq-siteUrl:first").text()+t+" "+$(".jq-ZCLlinkPassword:first").text();$("#ZCLlink input").val(i);$("#ZCLSeoTitle").data("packageOldSeo",t);zipSupport.closeZCLlinkEditorContainer();break;case"n":$(".jq-linkError").hide();$(".jq-linkError#ZCLserverError").text(n.errorMessage).show()}}})):t===""?($(".jq-linkError").hide(),$(".jq-linkError").hide(),$(".jq-linkError#ZCLemptyFieldError").show(),i=$("#ZCLSeoTitle"),i.val(i.data("packageOldSeo"))):r?($(".jq-linkError").hide(),$(".jq-linkError#ZCLnotPermitedCharactersError").show()):($(".jq-linkError").hide(),$(".jq-linkError#ZCLurlTooLongError").show())});$("#ZCLcancelSeoUpdateButton").on("click",function(n){n.preventDefault();$("#ZCLSeoTitle").val($("#ZCLSeoTitle").data("packageOldSeo"));zipSupport.closeZCLlinkEditorContainer()});$("#ZCLbutCreate").on("click",function(n){return n.preventDefault(),$(this).fadeOut(),zipSupport.openLinkPanel(),!1});$("#jq-ZCLbutEditSeoTitle").on("click",function(n){n.preventDefault();$(".jq-ZCLlinkContainer").fadeOut(function(){$(".jq-ZCLlinkEditorContainer").fadeIn()})});h=function(){$(window).one("resize",function(){zipSupport.centerZipCollection();setTimeout(h,100)})};h();$(".tn input:checked").each(function(){var n=$(this);zipSupport.listAdd(n);n.parent("label").addClass("untick")});zipSupport.updatefilenum();zipSupport.updatefilesize()}$("body").on("change",".tn input",function(){var n=$(this);n.is(":checked")?zipSupport.listAdd(n)&&n.parent("label").addClass("untick"):(zipSupport.listRemove(n),n.parent("label").removeClass("untick"))});$("body").on("click",".zipCollectionRemove",function(){var n=$(this).attr("id").replace("zipCollectionList","");$("#"+n).attr("checked",!1).parent().removeClass("untick");$(this).parent().animate({opacity:0},{duration:200}).slideUp(300,function(){$(this).remove();zipSupport.updatefilenum();zipSupport.updatefilesize();zipSupport.displayList($("#zipCollection"))});$("#ZCLclipboard input").val("");$("#jq-hiddenPackageFields").slideDown();$("#ZCLclipboard").slideUp();$(".jq-ZCLlinkContainer, .jq-linkError").hide();$("#ZCLbutCreate").fadeIn()});$("body").on("click",".jq-tickAll",function(n){return n.preventDefault(),zipSupport.tickAll($(this)),!1});$("body").on("click",".jq-tickAllTickAlls",function(n){return n.preventDefault(),zipSupport.tickAllTickAlls(!1),!1}).on("click",".jq-zipbatch",function(n){return n.preventDefault(),$.ajax({url:$(this).attr("href"),success:function(n){zipSupport.batch(n)}}),!1});i&&zipSupport.tickAllTickAlls(!0);$(function(){zipSupport.tickSavedTickedItems()})},displayMaxZipSizeMessage:function(n){n?$(".jq-maxzipmessage").fadeOut():($(".jq-maxzipmessage").fadeIn(),$("#filedownload").trigger("focus"))},tickAllTickAlls:function(n){var t=".jq-tickAll",i=$(".jq-tickAllTickAlls");i.data("state")!=="all"?(i.data("state","all").addClass("untick"),t+=":not(.untick)"):(i.data("state","none").removeClass("untick"),t+=".untick");$(t).each(function(){zipSupport.tickAll($(this),n)})},tickAll:function(n,t){typeof t=="undefined"&&(t=!1);n.data("state")!=="all"||t?n.data("state","all").addClass("untick").parents(".assetSet").find(".tn div.thumbOptions"+(zipSupport.tickOriginal?".original":".jpgcopy")).each(function(){$("input:checkbox:not(:checked)",$(this)).each(function(){var n=$(this);zipSupport.listAdd(n)&&n.prop("checked",!0).parent().addClass("untick")})}):n.data("state","none").removeClass("untick").parents(".assetSet").find(".tn input:checkbox:checked").prop("checked",!1).each(function(){zipSupport.listRemove($(this))}).parent().removeClass("untick");zipSupport.updatefilenum();zipSupport.updatefilesize()},areAnyFilesNonLive:function(){return $(".notlive .assetSet input[name=FileIds]:checked:first").length>0},displayList:function(n){var i,t,r,u,f,e;(n.fadeIn(),n.find(".jq-zippro").hide(),zipSupport.usesCredits)&&(i=n.find(".ZCLitem"),t=i.filter("[data-sponsoror='']").addClass("needs-credit"),t.length>0&&zipSupport.proStatus!=="Pro"&&($(".jq-creditsRequired",n).html(t.length),$(".jq-creditsCount",n).html(zipSupport.creditsCount),zipSupport.proStatus!=="Credits"?$(".jq-no-credits",n).show():t.length>zipSupport.creditsCount?$(".jq-credits-insufficient",n).show():$(".jq-credits",n).show()),r=i.filter("[data-fromfeed='True']").addClass("from-feed"),r.length>0&&(u=r.first().data("sponsoror"),u!==""&&($(".jq-feedsite",n).html(u),$(".jq-zipPP",n).show())),f=i.filter("[data-sponsoror!=''][data-fromfeed='False']").addClass("is-elite"),f.length>0&&(e=f.first().data("sponsoror"),e!==""&&($(".jq-sponsoror",n).html(e),$(".jq-zipElite",n).show())),t.length>0?zipSupport.proStatus!=="Pro"&&zipSupport.creditsCount<t.length?$("#ZCLbutDownload").hide():($(".jq-download-with",n).show(),$(".jq-zipNonPro",n).hide()):($(".jq-download-with",n).hide(),$(".jq-zipNonPro",n).show()))},updateCredits:function(n,t){$(".jq-creditsRemaining").html(n);zipSupport.creditsCount=t}}