$(window).load(function() {
var dfpElemPre = '#div-gpt-ad-',
dfpCatfishId = 'xxx1111-0', // catfish prod id
cfEl = $('.catfish-ads'),
dfpCatfishFullId = '.catfish-ads' + ' ' + dfpElemPre + dfpCatfishId,
cfClose = $('.catfish-ads .slide-close'),
cpDuration = 1440;
// var catfishMinute = 1440; 24 hr, 720: 12hr, 480: 8hr, 360: 6hr, 180: 3hr, 0
var expCfTime = new Date();
expCfTime.setTime(expCfTime.getTime() + (cpDuration * 60 * 1000));
$cfCookie = $.cookie('catfish-15may');
function ShowCatfish(){
setTimeout(function(){
$(cfEl).addClass('in');
},600);
$(cfEl).show();
}
function HideCatfish(){
// $(cfEl).removeClass('in');
setTimeout(function(){
$(cfEl).removeClass('in');
},600);
// $(cfEl).hide();
}
if(($(dfpCatfishFullId).css('display') == 'none')){
HideCatfish();
console.log('catfish display none');
}
// else {
// ShowCatfish();
// console.log('catfish here');
// }
else {
ShowCatfish();
if ($cfCookie == null) {
//do here
$(cfClose).on('click', function(){
$(this).parent().parent().removeClass('in');
$.cookie('catfish-15may', 'showed', { path: '/', expires: expCfTime });
HideCatfish();
});
}
else {
// cookie at work
HideCatfish();
console.log('cookies work - top');
}
}
$(cfClose).on('click', function(){
$(this).parent().parent().removeClass('in');
$.cookie('catfish-15may', 'showed', { path: '/', expires: expCfTime });
// HideCatfish();
console.log('cookies work - bottom');
});
});