var ddexitpop=function(e){function t(e){var t=new RegExp(e+"=[^;]+","i");return document.cookie.match(t)?document.cookie.match(t)[0].split("=")[1]:null}function n(e,t,n){var s="",i=new Date;if("undefined"!=typeof n){var o=parseInt(n)*(/hr/i.test(n)?60:/day/i.test(n)?1440:1);i.setMinutes(i.getMinutes()+o),s="; expires="+i.toUTCString()}document.cookie=e+"="+t+"; path=/"+s}function s(e){if(/^http/i.test(e)){var t=document.createElement("a");return t.href=e,t.href.replace(RegExp(t.hostname,"i"),location.hostname)}return e}var i={delayregister:0,delayshow:200,hideaftershow:!0,displayfreq:"always",persistcookie:"ddexitpop_shown",fxclass:"rubberBand",mobileshowafter:3e3,onddexitpop:function(){}},o=["bounce","flash","pulse","rubberBand","shake","swing","tada","wobble","jello","bounceIn","bounceInDown","bounceInLeft","bounceInRight","bounceInUp","fadeIn","fadeInDown","fadeInDownBig","fadeInLeft","fadeInLeftBig","fadeInRight","fadeInRightBig","fadeInUp","fadeInUpBig","flipInX","flipInY","lightSpeedIn","rotateIn","rotateInDownLeft","rotateInDownRight","rotateInUpLeft","rotateInUpRight","slideInUp","slideInDown","slideInLeft","slideInRight","zoomIn","zoomInDown","zoomInLeft","zoomInRight","zoomInUp","rollIn"],r="ontouchstart"in window||navigator.msMaxTouchPoints>0,a=r?"touchstart":"click",p={wrappermarkup:'
',$wrapperref:null,$contentref:null,displaypopup:!0,delayshowtimer:null,settings:null,ajaxrequest:function(t){var n=s(t);e.ajax({url:n,dataType:"html",error:function(e){alert("Error fetching content.
Server Response: "+e.responseText)},success:function(t){p.$contentref=e(t).appendTo(document.body),p.setup(p.$contentref)}})},detectexit:function(e){e.clientY<60&&(this.delayshowtimer=setTimeout(function(){p.showpopup(),p.settings.onddexitpop(p.$contentref)},this.settings.delayshow))},detectenter:function(e){e.clientY<60&&clearTimeout(this.delayshowtimer)},showpopup:function(){null!=this.$contentref&&1==this.displaypopup&&(this.settings.randomizefxclass===!0&&(this.settings.fxclass=o[Math.floor(Math.random()*o.length)]),this.$wrapperref.addClass("open"),this.$contentref.addClass(this.settings.fxclass),this.displaypopup=!1,this.settings.hideaftershow&&e(document).off("mouseleave.registerexit"))},hidepopup:function(){this.$wrapperref.removeClass("open"),this.$contentref.removeClass(this.settings.fxclass),this.displaypopup=!0},setup:function(){this.$contentref.addClass("animated"),this.$wrapperref=e(this.wrappermarkup).appendTo(document.body),this.$wrapperref.append(this.$contentref),this.$wrapperref.find(".veil").on(a,function(){p.hidepopup()}),"always"!=this.settings.displayfreq&&("session"==this.settings.displayfreq?n(this.settings.persistcookie,"yes"):/\d+(hr|day)/i.test(this.settings.displayfreq)&&(n(this.settings.persistcookie,"yes",this.settings.displayfreq),n(this.settings.persistcookie+"_duration",this.settings.displayfreq,this.settings.displayfreq)))},init:function(s){var o=e.extend({},i,s),r=t(o.persistcookie+"_duration");!r||"session"!=o.displayfreq&&o.displayfreq==r||(n(o.persistcookie,"yes",-1),n(o.persistcookie+"_duration","",-1)),"always"!=o.displayfreq&&t(o.persistcookie)||("random"==o.fxclass&&(o.randomizefxclass=!0),this.settings=o,"ajax"==o.contentsource[0]?this.ajaxrequest(o.contentsource[1]):"id"==o.contentsource[0]?(this.$contentref=e("#"+o.contentsource[1]).appendTo(document.body),this.setup(this.$contentref)):"inline"==o.contentsource[0]&&(this.$contentref=e(o.contentsource[1]).appendTo(document.body),this.setup(this.$contentref)),setTimeout(function(){e(document).on("mouseleave.registerexit",function(e){p.detectexit(e)}),e(document).on("mouseenter.registerenter",function(e){p.detectenter(e)})},o.delayregister),o.mobileshowafter>0&&e(document).one("touchstart",function(){setTimeout(function(){p.showpopup()},o.mobileshowafter)}))}};return p}(jQuery);