var needPopup=function(){var a={};return a.html=document.documentElement,a.body=document.body,a.window=window,a.target=0,a.scrollTopVal=0,a.scrollHeight=a.body.scrollHeight>a.html.scrollHeight?a.body.scrollHeight:a.html.scrollHeight,a.openHtmlClass=a.scrollHeight>a.window.innerHeight?"needpopup-opened needpopup-scrolled":"needpopup-opened",{init:function(){a.options=needPopup.config["default"],$(a.body).on("click","[data-needpopup-show]",function(a){a.preventDefault(),needPopup.show($(this).data("needpopupShow"),$(this))}),$(a.body).on("click",".needpopup_wrapper .remove, .needpopup_remover",function(a){a.preventDefault(),needPopup.hide()}),$(a.body).on("click",".needpopup_wrapper",function(b){console.log($(b.target).is(".needpopup_wrapper")),$(b.target).is(".needpopup_wrapper")&&(b.preventDefault(),a.options.closeOnOutside&&($(b.target).closest(".needpopup").length||$(b.target).is(".needpopup, .remove, .needpopup_remover")||needPopup.hide()))}),$(document).keydown(function(a){27==a.which&&needPopup.hide()}),a.resizeTimeout=0,a.resizeAllowed=!0,$(a.window).on("resize",function(){clearTimeout(a.resizeTimeout),a.resizeAllowed&&(a.resizeAllowed=!1,needPopup.centrify(),a.scrollHeight=a.body.scrollHeight>a.html.scrollHeight?a.body.scrollHeight:a.html.scrollHeight,a.openHtmlClass=a.scrollHeight>a.window.innerHeight?"needpopup-opened needpopup-scrolled":"needpopup-opened"),a.resizeTimeout=setTimeout(function(){a.resizeAllowed=!0},100)}),a.wrapper=document.createElement("div"),a.wrapper.className="needpopup_wrapper",a.body.appendChild(a.wrapper),a.wrapper=$(a.wrapper)},show:function(b,c){c?a.trigger=c:a.trigger=0,a.target?needPopup.hide(!0):(a.scrollTopVal=a.window.pageYOffset,$(a.body).css({top:-a.scrollTopVal}),$(a.html).addClass(a.openHtmlClass)),a.target=$(b),a.options=needPopup.config["default"],a.target.data("needpopupOptions")&&$.extend(a.options,needPopup.config[a.target.data("needpopupOptions")]),a.minWidth=a.target.outerWidth(),a.wrapper.append(a.target),"outside"==a.options.removerPlace?a.wrapper.after(''):"inside"==a.options.removerPlace&&a.target.append(''),a.options.onBeforeShow.call(a,a.target),a.target.show(),needPopup.centrify(),setTimeout(function(){a.target.addClass("opened"),a.options.onShow.call(a,a.target)},10)},hide:function(b){a.target.hide().removeClass("opened"),$(".needpopup_remover").remove(),b||($(a.html).removeClass(a.openHtmlClass).removeClass("needpopup-overflow"),$(a.body).css({top:0}).scrollTop(a.scrollTopVal),$(a.html).scrollTop(a.scrollTopVal)),a.options.onHide.call(a,a.target),a.target=0},centrify:function(){a.target&&(a.target.outerHeight()>a.window.innerHeight?a.target.addClass("stacked"):a.target.removeClass("stacked").css({"margin-top":-a.target.outerHeight()/2,top:"50%"}),a.minWidth=$(a.html).hasClass("needpopup-overflow")?a.minWidth:a.target.outerWidth(),a.minWidth+30>=a.window.innerWidth?$(a.html).addClass("needpopup-overflow"):$(a.html).removeClass("needpopup-overflow"))},config:{"default":{removerPlace:"inside",closeOnOutside:!0,onShow:function(){},onBeforeShow:function(){},onHide:function(){}}}}}();