function BindMastheadWaypoints(n){var t=new Waypoint({element:document.getElementById("inicio_masthead_waypoint"),handler:function(n){if(n=="down"){$(".masthead_styck").addClass("pinned");var t=$("#masthead").innerHeight();$("#inicio_masthead_waypoint").css("height",t);checkForPageLeap();this.destroy()}},offset:"96"}),i=new Waypoint({element:document.getElementById(n),handler:function(n){n=="down"&&$(".masthead_styck").hasClass("pinned")&&($(".masthead_styck").removeClass("pinned"),$("#inicio_masthead_waypoint").removeAttr("style"),this.destroy())},offset:endOffset}),r=new Waypoint({element:document.getElementById("begin_masthead_waypoint"),handler:function(n){$(".masthead_styck").hasClass("pinned")&&n=="up"&&($(".masthead_styck").removeClass("pinned"),$("#inicio_masthead_waypoint").removeAttr("style"))},offset:"-95"})}function checkForPageLeap(){setTimeout(function(){var n=$(window).scrollTop();n>endOffset&&($(".masthead_styck").removeClass("pinned"),$("#inicio_masthead_waypoint").removeAttr("style"))},700)}function getSubscription(){return navigator.serviceWorker.ready.then(function(n){return n.pushManager.getSubscription()})}var endOffset,pushNotifications;(function(n,t){"use strict";function u(t,u){this.element=t;this.settings=n.extend({},r,u);this._defaults=r;this._name=i;this.init()}var i="Styck",r={easing:"swing",duration:500,insteadParent:null,offsetTop:0,offsetBottom:0};n.extend(u.prototype,{init:function(){var i=this.settings,r=n(this.element),e=r.prop("id").replace("-","")||"Styck",u=i.insteadParent?r.closest(i.insteadParent):r.parent(),f=r.offset().top-u.offset().top-i.offsetTop;r.css("position","relative");n(t).on("scroll."+e,function(){n(t).scrollTop()>u.offset().top+f&&u.height()+u.position().top+i.offsetBottom>n(t).scrollTop()+r.height()?i.duration===0?r.css("top",n(t).scrollTop()-(u.offset().top+f)+"px"):r.animate({top:n(t).scrollTop()-(u.offset().top+f)+"px"},{easing:i.easing,duration:i.duration}):n(t).scrollTop()<u.offset().top&&r.animate({top:"0px"},{easing:i.easing,duration:i.duration})})}});n.fn[i]=function(t){return this.each(function(){n.data(this,"plugin_"+i)||n.data(this,"plugin_"+i,new u(this,t))})}})(jQuery,window,document);jRes.addFunc([{breakpoint:"mobile",enter:function(){},exit:function(){}},{breakpoint:"tablet",enter:function(){},exit:function(){}},{breakpoint:"pc",enter:function(){var n=$("#livestream");$(n).length>0&&($(window).scroll(function(){if($(n).attr("data-fixed")!=null){$(n).removeClass("LivestreamFixed");return}var t=$(this).scrollTop(),i=t>$("footer").offset().top-($(n).height()+100);if(!i&&t>$(n).height()&&t>$(n).offset().top-180){$(n).addClass("LivestreamFixed");$(n).removeClass("LivestreamFixedHidden");return}if(i){$(n).addClass("LivestreamFixedHidden");return}$(n).removeClass("LivestreamFixedHidden");$(n).removeClass("LivestreamFixed")}),$(".expand").click(function(){$(n).attr("data-fixed",1);$(n).removeClass("LivestreamFixed");$(this).hide()}))},exit:function(){}}]);endOffset="76";$("#hdnAreaName").length>0&&(endOffset="300");$(document).ready(function(){var n=/*@cc_on!@*/!1||!!document.documentMode;$(window).scrollTop()==0&&$("#inicio_masthead_waypoint").length>0&&in_version=="pc"&&($("#fim_masthead_waypoint01").length>0?BindMastheadWaypoints("fim_masthead_waypoint01"):$("#fim_masthead_waypoint02").length>0&&BindMastheadWaypoints("fim_masthead_waypoint02"))});window.onload=function(){if(location.protocol!="https:"){$("#pushContinue").attr("data-target","blank");$("#pushReRegister").attr("data-target","blank");$("#ic_notificacoes").attr("data-target","blank");var r=navigator.userAgent.toLowerCase().indexOf("chrome")>-1,t=COF.cookies.get("PushNotifications"),n=COF.cookies.get("SitePushNotifications"),i=COF.cookies.get("PushWarning");if(t=t!=null?COF.cookies.get("PushNotifications").toLowerCase():null,n=n!=null?COF.cookies.get("SitePushNotifications").toLowerCase():null,i=i!=null?COF.cookies.get("PushWarning").toLowerCase():null,r&&location.pathname=="/")if(i!="true"||i=="true"&&n=="true"){if(n=="true"){$("#ic_notificacoes").addClass("pushnotificationsfixed");$("#ic_notificacoes").attr("data-action","unsubscribe");$("#ic_notificacoes .msg-notification").text("Remover notificações");$("#ic_notificacoes").show();$(document).on("click","#removeNotification",function(){pushNotifications.unsubscribePushNotifications()});pushNotifications.bindPushNotificationsEvents();return}t!="true"?n!="true"?(setTimeout(function(){$(".registerPush").show()},2e3),$("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","subscribe"),$("#ic_notificacoes .msg-notification").text("Subscrever notificações")):($("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","unsubscribe"),$("#ic_notificacoes .msg-notification").text("Remover notificações")):(setTimeout(function(){$(".reregisterPush").show()},2e3),$("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","resubscribe"),$("#ic_notificacoes .msg-notification").text("ReSubscrever notificações"))}else t!="true"?($("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","subscribe"),$("#ic_notificacoes .msg-notification").text("Subscrever notificações"),$("#ic_notificacoes").show()):($("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","resubscribe"),$("#ic_notificacoes .msg-notification").text("ReSubscrever notificações"),$("#ic_notificacoes").show());else $("#ic_notificacoes").remove(),$(".notificacao").remove();pushNotifications.bindPushNotificationsEvents();return}$("#pushContinue").attr("data-target","self");$("#pushReRegister").attr("data-target","self");$("#ic_notificacoes").attr("data-target","self");"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(function(n){pushNotifications.reg=n;pushNotifications.init(n)})};pushNotifications=function(){function n(n,t,i,r){var u=window.screenLeft!=undefined?window.screenLeft:screen.left,f=window.screenTop!=undefined?window.screenTop:screen.top,e=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,o=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,s=e/2-i/2+u,h=o/2-r/2+f,c=window.open(n,t,"scrollbars=yes, width="+i+", height="+r+", top="+h+", left="+s);window.focus&&c.focus()}var t=function(n){pushNotifications._reg=n;pushNotifications.pushNotificationsCheck();pushNotifications.bindPushNotificationsEvents()},i=function(){var r=navigator.userAgent.toLowerCase().indexOf("chrome")>-1,n=COF.cookies.get("PushNotifications"),t=COF.cookies.get("SitePushNotifications"),i=COF.cookies.get("PushWarning");n=n!=null?COF.cookies.get("PushNotifications").toLowerCase():null;t=t!=null?COF.cookies.get("SitePushNotifications").toLowerCase():null;i=i!=null?COF.cookies.get("PushWarning").toLowerCase():null;r&&(location.pathname=="/"||$(".pop-notification").length>0)?i!="true"||i=="true"&&t=="true"?getSubscription().then(function(i){if(i){if($(".pop-notification").length>0)pushNotifications.unsubscribePushNotifications();else{$("#ic_notificacoes").addClass("pushnotificationsfixed");$("#ic_notificacoes").attr("data-action","unsubscribe");$("#ic_notificacoes .msg-notification").text("Remover notificações");$("#ic_notificacoes").show();$(document).on("click","#removeNotification",function(){pushNotifications.unsubscribePushNotifications()})}return}$(".pop-notification").length>0?n!="true"?pushNotifications.subscribePushNotifications(!0):pushNotifications.subscribePushNotifications(!0):n!="true"?t!="true"?(setTimeout(function(){$(".registerPush").show()},2e3),$("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","subscribe"),$("#ic_notificacoes .msg-notification").text("Subscrever notificações")):($("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","unsubscribe"),$("#ic_notificacoes .msg-notification").text("Remover notificações")):(setTimeout(function(){$(".reregisterPush").show()},2e3),$("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","resubscribe"),$("#ic_notificacoes .msg-notification").text("ReSubscrever notificações"))}):n!="true"?($("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","subscribe"),$("#ic_notificacoes .msg-notification").text("Subscrever notificações"),$("#ic_notificacoes").show()):$(".pop-notification").length>0?pushNotifications.subscribePushNotifications(!0):($("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","resubscribe"),$("#ic_notificacoes .msg-notification").text("ReSubscrever notificações"),$("#ic_notificacoes").show()):($("#ic_notificacoes").remove(),$(".notificacao").remove())},r=function(){$(document).on("mouseenter","#ic_notificacoes",function(){$(".msg-notification").fadeIn()});$(document).on("mouseleave","#ic_notificacoes",function(){$(".msg-notification").fadeOut()});$(document).on("click","#ic_notificacoes",function(){var t=$("#ic_notificacoes").attr("data-action"),i=$("#ic_notificacoes").attr("data-target");t=="subscribe"?i=="self"?pushNotifications.reSubscribePushNotifications():n(GlobalVariables.pushnotifications.push_notification_url,"Registo Notificações Jornal de Negócios",450,412):t=="resubscribe"?i=="self"?pushNotifications.reSubscribePushNotifications():n(GlobalVariables.pushnotifications.push_notification_url,"Registo Notificações Jornal de Negócios",450,412):t=="unsubscribe"&&(i=="self"?pushNotifications.unsubscribePushNotifications():n(GlobalVariables.pushnotifications.push_notification_url,"Registo Notificações Jornal de Negócios",450,412))});$(document).on("click","#pushContinue",function(){var t=$(this).attr("data-target");$(".notificacao").remove();t=="self"?pushNotifications.reSubscribePushNotifications():n(GlobalVariables.pushnotifications.push_notification_url,"Registo Notificações Jornal de Negócios",450,412)});$(document).on("click","#pushReRegister",function(){var t=$(this).attr("data-target");$(".notificacao").remove();t=="self"?pushNotifications.reSubscribePushNotifications():n(GlobalVariables.pushnotifications.push_notification_url,"Registo Notificações Jornal de Negócios",450,412,0)});$(document).on("click",".pushCancelRegister",function(){COF.cookies.set("PushWarning","true",1);$(".notificacao").remove();$("#ic_notificacoes").show()});$(document).on("click",".pushCancelReRegister",function(){COF.cookies.set("PushWarning","true",1);$(".notificacao").remove();$("#ic_notificacoes").show()})},u=function(n){pushNotifications._reg.pushManager.subscribe({userVisibleOnly:!0}).then(function(t){var u=t.endpoint.split("/"),i,r;u.length>0&&(i=u[u.length-1],i!==""&&i!==null&&i!==undefined&&(r=COF.cookies.get("cof_site_user"),r===null&&(r=""),fetch("/PushNotifications/Register",{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded; charset=UTF-8"},body:"registrationID="+i+"&loginToken="+r}).then(function(t){t.statusText==="OK"?(Notification.requestPermission(function(n){n==="granted"&&navigator.serviceWorker.ready.then(function(n){n.showNotification("Notificações Jornal de Negócios",{body:"Obrigado pela sua subscrição",icon:GlobalVariables.ENV_URL+"/i/pushnotifications/lg_n.png",badge:GlobalVariables.ENV_URL+"/i/pushnotifications/notification_neg.png"})})}),ga("send","event","PushChrome","Register"),COF.cookies.set("SitePushNotifications","true",2038),$(".pop-notification").length==0?($("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","unsubscribe"),$("#ic_notificacoes .msg-notification").text("Remover notificações"),$("#ic_notificacoes").show()):n?(COF.cookies.set("PushNotifications","",-1),window.location=GlobalVariables.pushnotifications.deleteOldRegister_push_notification_url):(COF.cookies.set("PushNotifications","",-1),window.close())):$(".titulo").html("<span class='titulo'>Erro ao remover subscrição. Tente novamente<\/span>")})))})},f=function(){n(GlobalVariables.pushnotifications.deleteOldRegister_push_notification_url,"Registo Notificações Jornal de Negócios",450,412,0);pushNotifications.subscribePushNotifications();COF.cookies.set("PushNotifications","",-1)},e=function(){pushNotifications._reg.pushManager.getSubscription().then(function(n){return n.unsubscribe().then(function(){var t=n.endpoint.slice(n.endpoint.lastIndexOf("/")+1);fetch("/PushNotifications/Unregister",{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded; charset=UTF-8"},body:"registrationID="+t}).then(function(n){n.statusText==="OK"?(ga("send","event","PushChrome","Unregister"),COF.cookies.set("SitePushNotifications","",-1),$(".pop-notification").length==0?($("#ic_notificacoes").addClass("pushnotificationsfixed"),$("#ic_notificacoes").attr("data-action","subscribe"),$("#ic_notificacoes .msg-notification").text("Subscrever notificações"),$("#ic_notificacoes").show()):window.close()):$(".titulo").html("<span class='titulo'>Erro ao remover subscrição. Tente novamente<\/span>")})})})};return{init:t,pushNotificationsCheck:i,bindPushNotificationsEvents:r,subscribePushNotifications:u,reSubscribePushNotifications:f,unsubscribePushNotifications:e}}()