!function(o){function e(e){var t=e.title?'<div class="pop-title pop-center">'+e.title+"</div>":"",a=e.footer?'<footer class="pop-footer pop-center">'+(1==e.footer?'<a href="javascript:void(0);" class="pop-button" title="Закрыть окно" id="pop-close" >Закрыть</a>':e.footer)+"</footer>":"",s="animate-"+e.animate,p=function(){if(e.image&&o.isPlainObject(e.image))var n=o.map({"background-image":e.image.url?"url("+e.image.url+")":null,"background-position":(e.image.x||0)+" "+(e.image.y||0),height:e.image.height||l,"background-color":e.image.background?e.image.background:null,"background-size":e.image.zoom?0==c(e.image.zoom)?d:e.image.zoom:d,"background-repeat":e.image.pattern?"repeat":null},function(o,e){return o?e+":"+o:null}).join(";");return n?n:""},u=function(){var n=o('<div class="pop-all-content '+s+'"/></div>'),i=o("<div/>",{"class":"pop-header "+(e.image?"pop-image":"pop-noimage"),style:p(),html:e.hideClose?"":'<a href="javascript:void(0);" class="pop-close" id="pop-close" title="Закрыть окно" rel="nofollow"></a>'+t}),r=o("<div/>",{"class":"pop-content",style:e.contentHeight?"overflow:auto;height:"+e.contentHeight:"",html:e.content});return n.prepend(e.header?i:"",r,a)},f=o("<div/>",{id:e.id,"class":"pop-window show "+s,style:"z-index:"+(r+o(".pop-window").length)+(e.fixed?";position:fixed":""),click:function(t){e.backgroundClose&&0===o(t.target).closest(".pop-all-content").length&&n()}}).prepend(u());if(!o(".pop-background")[0]&&e.background){var g=o("<div />",{"class":"pop-background "+s,style:"z-index:"+(r-1)});g.prependTo(i).focus().addClass("show")}e.fixScroll&&(i.attr("data-overflowy",i.css("overflow-y")),i.css("overflow-y","hidden"),f.css({position:"fixed","overflow-y":"auto"})),f.prependTo(i).ready(function(){f.children(".pop-all-content").addClass("show")})}function n(e,n){var t=o(n?"#"+e:".pop-window"),r=i.attr("data-overflowy")||null;r&&i.css("overflow-y",i.attr("data-overflowy")),o(".pop-background").removeClass("show").one(a,function(){o(this).remove()}),t.children(".pop-all-content").removeClass("show").one(a,function(){t.remove()})}var t={id:null,title:null,content:"",animate:"fade_scale",background:1,backgroundClose:0,footer:1,header:1,image:null,fixed:0,hideClose:0,fixScroll:0,contentHeight:0},i=o("body"),a=(navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|Windows Phone|Tizen|Bada)/),"webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend"),r=1e4,l=140,d="auto",c=function(o,e){var n=o.match(/\d+/)[0];return n[0]?n[0]+(e?e:""):""},s=function(t,i){if(i)var a=o.isPlainObject(i)?i.id?i.id:Date.now():i,r=o(".pop-window#"+a);var l={add:function(){return r[0]?!1:e(i)},edit:function(){},remove:function(){return r[0]?n(a):!1}};return l[t]},p=function(){o(document.body).on("click",".pop-window #pop-close",function(o){o.preventDefault(),n()})};o(document.body).ready(function(){p()}),o.popWindow=function(e,n){var i=o.extend({},t,n);return s(e)?s(e,i).call(this):!1}}(window.jQuery);