var FRJournalArticle=function(){function g(){$(window).on("hashchange",function(){v()});$(document).on("click",".ui-accordion",function(n){$(n.target).toggleClass("closed").next(".ui-accordion-content").slideToggle()});$(document).on("click","#supplementary_view",function(){h(!1),s()});$(document).on("click",function(n){if($(n.target).parents().andSelf().is(".popover, .popover-trigger")){var i=t.find(".popover");i.length>1&&i.each(function(){$(this).parent().has(n.target).length||$(this).prev(".popover-trigger").popover("hide")})}else $(t.find("a.popover-trigger")).popover("hide")});$(document).on("click",'a[href^="#"]',function(){var n=$(this).attr("href");n.length&&(n==="#impact"||n.indexOf("-tab")>=0||f(!0,n))});n.on("click","button[data-href]",function(){var n=$(this).data("href");n&&n.length&&(window.location.href=n)});n.find(".table-of-contents ul li a").on("click",function(){var n=$(this).attr("href");n&&n.length&&(window.location.href=n)});r.find("#open-crossmark").on("click",function(){});y(),b()}function v(){var n=window.location.hash.replace("#","").toLowerCase();if(n.length&&n=="supplementary-material")s();else{l.modal("hide");return}}function ut(){t.find(".side-article-impact .impact-data").tooltip({placement:"bottom",delay:{show:400}}),$.getJSON("/articles/getarticleimpactviewscount?articleId="+window.FRArticle.ArticleId).done(function(n){t.find(".impact-data span.title-number").text(n)})}function it(){$.post("/articles/recommendedarticle/insertarticlerecommendations",{articleId:window.FRArticle.ArticleId})}function tt(){$.getJSON("/articles/getrelatedarticlebyarticleId?articleId="+window.FRArticle.ArticleId).done(function(n){d(n)})}function h(n,t){var i=t||1;setTimeout(function(){var t=$(".page-container a.open-supplemental-data");n?t.removeClass("disabled"):t.addClass("disabled")},i)}function s(){var n=FRTemplate.bind("template-supplementary-files-modal",{});l.html(n).modal("show"),a=$("#localFiles"),i=document.getElementById("loader"),h(!0,800),i.style.display="block",$.ajax({type:"POST",url:FRArticle.FigShareApiUrl,data:JSON.stringify({doi:FRArticle.DOI}),dataType:"json",contentType:"application/json; charset=utf-8",timeout:FRArticle.FigShareTimeOut,success:function(n){n&&n.length!=0?nt():c()},error:function(){c()}})}function d(n){var t,i,r,f;n!=null&&(t=u.find(".widget-listing.original-article"),i=u.find(".widget-listing.commentary-article"),n.IsCommentaryVisible&&(r=o(n.CommentaryArticle),i.append(r).removeClass("hidden")),n.IsOriginalArticleVisible&&(f=o(n.OriginalArticle),t.append(f).removeClass("hidden")))}function o(n){var t="";return $.each(n,function(n,i){t=t+'<div class="teaser"><div class="heading-container"><h2 class="teaser-heading"><a href="'+i.ArticleUrl+'" >'+formatTextContent(i.ArticleTitle)+"</a></h2>",t=t+'<p class="teaser-authors">'+e(i.AuthorDetails)+"</p></div></div>"}),t}function rt(){$.getJSON("/articles/recommendedarticle/getrecommendedarticledetails?articleId="+window.FRArticle.ArticleId).done(function(n){k(n)})}function k(n){if(n&&n.RecommendedArticleDetails&&n.RecommendedArticleDetails.length){var t=u.find(".widget-listing.people-also-looked-at");$.each(n.RecommendedArticleDetails,function(n,i){var r=$(['<div class="teaser"><div class="heading-container"><h2 class="teaser-heading"><a></a></h2>','<p class="teaser-authors"></p></div></div>'].join(""));r.find("a").attr("href",i.ArticleUrl).html(formatTextContent(i.ArticleTitle)),r.find("p.teaser-authors").html(e(i.AuthorDetails)),t.append(r)}),t.removeClass("hidden")}}function e(n){if(!n||!n.length)return"";var i=0,t="",r=n.length;return $.each(n,function(n,u){(i++,t=u.WhosWhoUrl.length?t+'<a href="'+u.WhosWhoUrl+'">'+u.FullName+"</a>":t+u.FullName,r!==1)&&(i==r-1?t=t+" and ":i!=r&&(t=t+", "))}),t}function b(){var n=t.find("div.altmetric-icon");n.on("click",".altmetric-embed>a",function(){})}function w(){r.find('a[id^="h"]').addClass("reset-hash-position")}function f(n,t){var i,u,f;t&&t.length&&(i=t.indexOf("/"),i>0&&(t=t.substring(0,i)),u=function(){var n=r.find(t),i;n&&n.length&&(n.hasClass("reset-hash-position")||(i=parseInt(n.offset().top)-parseInt($("body").css("padding-top")),$("html, body").animate({scrollTop:i},100)))},f=n?50:500,setTimeout(u,f))}function p(){n.find("#top-impact-factor").circleProgress({value:1,size:50,thickness:5,fill:{color:"rgba(0, 0, 0, 0.3)"}}).on("circle-animation-progress",function(){});n.find("#top-impact-factor .counter").counterUp()}function y(){var r;n.find("#anchors").find("a[href*=#]:not([href=#], .nav-tabs a)").click(function(){if(location.pathname.replace(/^\//,"")!=this.pathname.replace(/^\//,"")||location.hostname!=this.hostname)return!1;var n=$(this.hash);return(n=n.length?n:$("[name="+this.hash.slice(1)+"]"),!n.length)?!1:($("html,body").animate({scrollTop:n.offset().top},1e3),!1)}),n.find("#anchors").stick_in_parent();var t=200,i=!1,u=new Date(1,1,2e3,12,0,0);$(window).resize(function(){u=new Date,i===!1&&(i=!0,setTimeout(r,t))}),r=function(){new Date-u<t?setTimeout(r,t):(i=!1,$(document.body).trigger("sticky_kit:recalc"))}}function nt(){window.figshare.load("frontiers",function(n){var r=document.getElementById("figshare-widget-container"),t=new n({resourceDOI:window.FRArticle.DOI,showStats:!1});t.initialize(),t.mount(r),window.widget=t,i.style.display="none"})}function c(){$.getJSON("/articles/GetSupplementaryFilesByArticleId?articleId="+window.FRArticle.ArticleId).done(function(n){var t=n.SupplimentalFileDetails,r=FRTemplate.bind("template-local-files-modal",{supplimentalFileDetails:t});a.html(r),i.style.display="none",t.FileDetails==null?($(".supplementary-content").hide(),$(".supplementary-empty-message").show()):($(".supplementary-content").show(),$(".supplementary-empty-message").hide())})}var n=$(".page-container"),t=n.find(".right-container"),r=n.find(".article-container"),ft=n.find(".abstract-container"),u=n.find(".right-container-articles"),l=$(".supplementary-modal-container"),a=null,i=null;$(function(){ut(),tt(),rt(),it(),g(),w(),f(!1,window.location.hash),FRNetworkUserFollow.fillJournalFollow(),p(),v()})}(),FRAddThis=function(){function w(){window.addthis&&window.addthis.addEventListener&&window.addthis.addEventListener("addthis.menu.share",p)}function p(n){return n.type=="addthis.menu.share"&&l(n.data.service),!0}function a(){var n=t.find(".addthis_button_facebook");i.on("click",function(){if(n.length)n.click();else return});u.on("click",function(){var n=t.find(".addthis_button_google");if(n.length)n.click();else return});r.on("click",function(){var n=t.find(".addthis_button_twitter");if(n.length)n.click();else return});f.on("click",function(){var n=t.find(".addthis_button_linkedin");if(n.length)n.click();else return});e.on("click",function(){var n=t.find(".addthis_button_more");if(n.length)n.click();else return})}function y(){window.FRSocial.pageType==1?v():window.FRSocial.pageType==2&&b()}function v(){$.getJSON("/articles/social/getsocialcountbyarticleId?articleid="+window.FRArticle.ArticleId).done(function(n){s(n)})}function b(){$.getJSON("/research-topics/"+window.FRResearchTopic.Id+"/socialcounts").done(function(n){s(n)})}function s(n){typeof n!="undefined"&&n!=null&&(typeof n.Facebook=="undefined"?(i.html(0),i.data("count",0)):(i.html(n.Facebook),i.data("count",n.Facebook)),typeof n.Twitter=="undefined"?(r.html(0),r.data("count",0)):(r.html(n.Twitter),r.data("count",n.Twitter)),typeof n.GooglePlus=="undefined"?(u.html(0),u.data("count",0)):(u.html(n.GooglePlus),u.data("count",n.GooglePlus)),typeof n.LinkedIn=="undefined"?(f.html(0),f.data("count",0)):(f.html(n.LinkedIn),f.data("count",n.LinkedIn)),typeof n.Total=="undefined"||n.Total==0?(e.html("New"),e.data("count",0)):(e.html(n.Total),e.data("count",n.Total)))}function l(t){var i;t!="more"&&(t=="facebook"?(i=n.find(".facebook_count"),o(i)):t=="twitter"?(i=n.find(".twitter_count"),o(i)):t=="google"||t=="google_plusone_share"?(t="google",i=n.find(".googleplus_count"),o(i)):t=="linkedin"?(i=n.find(".linkedin_count"),o(i)):k(),window.FRSocial.pageType==1?c(t):window.FRSocial.pageType==2&&h(t))}function c(n){$.post("/Social/TrackCurrentSocialCounts?id="+window.FRArticle.ArticleId+"&provider="+n)}function h(n){$.post("/ResearchTopic/TrackCurrentSocialCounts?id="+window.FRResearchTopic.Id+"&provider="+n)}function o(t){var u=$(t).data("count"),i=parseInt(u)+parseInt(1),f=n.find(".total_count").data("count"),r=parseInt(f)+parseInt(1);$(t).html(i),n.find(".total_count").html(r),$(t).data("count",i),n.find(".total_count").data("count",r)}function k(){var i=n.find(".total_count").data("count"),t=parseInt(i)+parseInt(1);n.find(".total_count").html(t),n.find(".total_count").data("count",t)}var n=$(".share-media"),t=n.find(".social_block"),i=t.find(".facebook_count"),r=t.find(".twitter_count"),u=t.find(".googleplus_count"),f=t.find(".linkedin_count"),e=t.find(".total_count");$(function(){w(),y(),a()})}(),onloadCallback=function(){grecaptcha.render("recaptcha",{sitekey:window.FRArticleRecaptchaSettings.RecaptchaSiteKey,callback:function(){FRArticleNotification.SetNotifyVisibility()},"expired-callback":function(){FRArticleNotification.SetNotifyVisibility()}})},FRArticleNotification=function(){function e(){(function(n,t,i,r,u,f,e){f=t.createElement(i),e=t.getElementsByTagName(i)[0],f.async=1,f.defer=1,f.src=r,e.parentNode.insertBefore(f,e)})(window,document,"script","https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit")}function o(i){var r=i.currentTarget;r.innerHTML="",$.get("/api/articles/getloggedinuser").done(function(i){if(i>0)$.get("/api/articles/"+i+"/getuseremaillist").done(function(r){if(r.length>1){var u=FRTemplate.bind("template-notifyme-mailselection-modal",{userEmailList:r});n.html(u).modal("show"),$('input[name="notify_Emailcollection"]').first().prop("checked",!0)}else $.post("/api/articles/notifyme",{ArticleId:window.FRArticle.ArticleId,EmailId:r[0],UserId:i}).done(function(n){n?$(".provisional-text").text("We'll notify you at publication."):t()})});else{var r=FRTemplate.bind("template-notify-me-modal",{login:FRConfiguration,currentPage:location.pathname});n.html(r).modal("show"),e()}})}function t(t){t=t||f;var i=FRTemplate.bind("template_notifyme_error_modal",{message:t});n.modal("hide"),setTimeout(function(){n.html(i).modal("show")},500)}function i(n,i,u){var f=n.currentTarget;f.innerHTML='<i class="fa fa-spin fa-circle-o-notch"></i>',u?$.post("/api/articles/notifyme/",{ArticleId:window.FRArticle.ArticleId,EmailId:i,UserId:FRArticle.LoginUserId}).done(function(n){r(n,f)}).fail(function(){t()}):$.post("/api/articles/notification/security/verification/",{ArticleId:window.FRArticle.ArticleId,EmailId:i,UserId:FRArticle.LoginUserId,RecaptchaToken:grecaptcha.getResponse()}).done(function(n){r(n,f)}).fail(function(){var i="Your Captcha response was incorrect. Please try again.";t(i)})}function r(i,r){i?(r.innerHTML='<i class="fa fa-check" aria-hidden="true"></i>',n.modal("hide"),FRArticle.LoginUserId>0&&$(".provisional-text").text("We'll notify you at publication.")):t()}function s(){var n=!1;return typeof grecaptcha!="undefined"&&grecaptcha.getResponse()&&(n=!0),n}function u(){var n=s(),t=n?"visible":"hidden";$("#article_notify_non_registered_user").css("visibility",t)}var n=$(".notifyme-modal-container"),h=$("#article_notify_loggedin_user"),f="An error occured. Please try again later.",c="";$(function(){u()});$(document).on("click","#article_notifyme",function(n){o(n)});$(document).on("click","#article_notify_non_registered_user",function(n){if($("#modalnotifyme").valid()){var t=$("#txt_notification_email_id").val();i(n,t,!1)}});$(document).on("click","#article_notify_loggedin_user",function(n){email=$("input[name='notify_Emailcollection']:checked").val(),i(n,email,!0)});n.on("hidden.bs.modal",function(){$("#article_notifyme").html('<i class="fa fa-envelope"></i> Notify me')});return{SetNotifyVisibility:u}}()