jQuery(document).ready(function($){function fecharAnuncio(){console.log('fecharAnuncio chamado');var anuncio=$(this).closest('.close_ads');if(anuncio.closest('.ads_header_fixed, .ads_footer_fixed').length){anuncio.fadeOut('slow');}}
$('.ads_header_fixed, .ads_footer_fixed').on('click','.fechar_anuncio',fecharAnuncio);$('.anuncio-adsninja a').on('click',function(e){e.preventDefault();var postId=$(this).data('id');var url=$(this).attr('href');window.open(url,'_blank');$.ajax({url:ads_ninja_ajax_data.ajax_url,type:'POST',data:{action:'ads_ninja_wp_update_clicks',post_id:postId},success:function(response){console.log(response);},error:function(xhr,status,error){console.log('Ocorreu um erro na requisição Ajax: '+error);var response=JSON.parse(xhr.responseText);if(response&&response.data&&response.data.message){console.log('Erro: '+response.data.message);}}});});function showPopup(){$('#popup, #popup-overlay').fadeIn('slow');}
function closePopup(){$('#popup, #popup-overlay').fadeOut('slow');}
function checkPopup(){var shouldShow=getCookie('popupClosed');if(!shouldShow){showPopup();setCookie('popupClosed','true',1/24/60);}}
function setCookie(name,value,hours){var expires='';if(hours){var date=new Date();date.setTime(date.getTime()+hours*60*60*1000);expires='; expires='+date.toUTCString();}
document.cookie=name+'='+(value||'')+expires+'; path=/';}
function getCookie(name){var nameEQ=name+'=';var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)===' '){c=c.substring(1,c.length);}
if(c.indexOf(nameEQ)===0){return c.substring(nameEQ.length,c.length);}}
return null;}
checkPopup();$('#popup-close').on('click',function(){closePopup();setCookie('popupClosed','true',1);});});