(function($) { "use strict"; function openFancybox() { var exist=$('#modal-promo').length; var excludepage = !$("body").hasClass("edit-mode"); setTimeout( function() { if( ($('#modal-promo').length)){ $.fancybox.open({ src : '#modal-promo', type: "inline", clickSlide : 'close', clickOutside : 'close', opts : { beforeClose: function() { $.cookie('modalpromo', 'close', { expires: 3, path: '/' }); }, }, }).trigger("click"); } }, 2000); }; $(document).ready(function() { var visited = $.cookie('modalpromo'); if (visited == 'close') { return false; } else { openFancybox(); } $('#click-fancy').click(function () { $.cookie('modalpromo', 'close', { expires: 7, path: '/' }); }); }); })(jQuery);