function doInfiniteScrolling(){function n(){t||(t=!0,window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,300))}function f(){i||(i=!0,window.requestAnimationFrame?window.requestAnimationFrame(o):setTimeout(o,300))}function l(){r||(r=!0,window.requestAnimationFrame?window.requestAnimationFrame(s):setTimeout(s,300))}function s(){if(windowHeight=$(window).height(),u=h(),$(window).off("scroll",n),$(window).off("scroll",f),u=="desktop"){$(window).on("scroll",n);$(window).on("scroll",f)}r=!1}function e(){var n=$(window).scrollTop();articles.each(function(){var u=$(this),i=u.offset().top,r=u.outerHeight(),t=articleSidebarLinks.eq($("article").index(this)).children("a"),f,e;u.is(":last-of-type")&&(r=r-windowHeight);i-50>n?t.removeClass("read reading"):n>=i-50&&i-50+r>n?(f=c*(1-(n-i)/r),t.addClass("reading").removeClass("read").find("circle").attr({"stroke-dashoffset":f}),e=t.attr("href"),a(t.attr("href"))):t.removeClass("reading").addClass("read")});t=!1;$(window).scroll(function(){})}function o(){if(articlesWrapperTop=articlesWrapper.offset().top,articlesWrapperHeight=articlesWrapper.outerHeight(),scrollTop=$(window).scrollTop(),headerHeight=$("header").height(),stickyHeight=$(".sponsorDuplicate").height(),sponsorHeight=$(".sponsorAsync").height(),$("#firstSC").length?showcaseHeight=$("#firstSC").height():(showcaseHeight=articlesWrapperTop,articlesWrapperHeight=articlesWrapperHeight-$($(".newsPointer")[0]).height()-$($(".dtlsSc")[0]).height()),scrollTop<articlesWrapperTop-(headerHeight+stickyHeight-parseInt($(".content-wrap").css("margin-top"))-showcaseHeight))aside.removeClass("fixed").attr("style","");else if(scrollTop>=articlesWrapperTop&&scrollTop<articlesWrapperTop+articlesWrapperHeight-windowHeight)aside.addClass("fixed").attr("style","");else if(Article.GetNextArticle(),Article.isLastArticle){var n=Number(articles.eq(1).css("padding-top").replace("px",""));aside.hasClass("fixed")&&aside.removeClass("fixed").css("top",articlesWrapperHeight+n-windowHeight-$("#firstSC").height()+headerHeight+stickyHeight+"px")}i=!1}function a(n){var i,t,r;n=n.toLowerCase();n=n.replace("interestingarticle","interestingInfiniteLoad");i=window.location.pathname.toLowerCase();i.indexOf("/masrawy/")!=-1&&(i=i.replace("/masrawy",""));t=n.replace(AppPath.toLowerCase(),"").toLowerCase();t.indexOf("/masrawy/")!=-1&&(t=t.split("/masrawy")[1]);var f=i.split("/"),e=i.split(f[7])[0]+f[7],u=t.split("/");t=t.split(u[7])[0]+u[7];e!=t&&history.pushState&&(r=decodeURIComponent(n.split(u[7])[1]).replace("/",""),document.title=r,window.history.pushState({path:n,title:r},r,n),Article.ChangeSocialMediaLink(r))}function h(){return window.getComputedStyle(articlesWrapper.get(0),"::before").getPropertyValue("content").replace(/'/g,"").replace(/"/g,"")}if(articlesWrapper.length>0){windowHeight=$(window).height();articles=articlesWrapper.find("article");aside=$(".cd-read-more");articleSidebarLinks=aside.find("li");var t=!1,i=!1,r=!1,u=h(),c=parseInt(Math.PI*articleSidebarLinks.eq(0).find("circle").attr("r")*2);if(u=="desktop"){$(window).on("scroll",n);$(window).on("scroll",f)}$(window).on("resize",l);e();o();aside.on("click","a",function(t){t.preventDefault();try{var i=articles.eq($(this).parent("li").index()),r=i.offset().top-60;$(window).off("scroll",n);$("body,html").animate({scrollTop:r+2},300,function(){n();$(window).on("scroll",n)})}catch(u){window.location=$(this).attr("href")}})}}function afterNextArticle(){if(articles=articlesWrapper.find("article"),Article.isLastArticle){var n=Number(articles.eq(1).css("padding-top").replace("px",""));aside.hasClass("fixed")&&aside.removeClass("fixed").css("top",articlesWrapperHeight+n-windowHeight-$("#firstSC").height()+50+"px")}}var articlesWrapper=$(".cd-articles"),aside,windowHeight,articlesWrapperTop,articlesWrapperHeight,Article={postId:0,templateId:0,isMobile:$("#hdIsMobile").val(),iframe:'<section class="showcaseDiv"><div class="showcaseCnts"><p class="adTtl"> إعلان<\/p><div class="showcase"><iframe width="300px" height="250px" scrolling="no" src="#iframeSrc"><\/iframe><\/div><\/div><\/section >',iframeSrc:"/General/Ishowcase",maxPlength:100,VideoTempId:0,SeriesTempId:11,VideoDiv:" .videoCntnr",VideoBody:" .body",divBody:" .details",rootCategory:$("article").attr("rootCat"),bodyKeywordLinkIsAllowed:!0,bodyKeywordLinkClass:"kwhd",bodyKeywordLinkHashtag:"#bodykeywords",bodyKeywordLinkTemplate:"https://www.masrawy.com/{rootcategory}/Tag/{keywordid}/{keywordname}#bodykeywords",isInfiniteScrollAllowed:!0,isLastArticle:!1,ulInterestingArticles:"#ulInterestingArticles",ThanaweyaClip:'<div class="cnts mobile seatNumber"><div class="ttl"><h2>نتيجة الثانوية العامة<\/h2><\/div><div class="labelDiv"><label class="col-md-2 control-label" for="Name">رقم الجلوس<\/label><span>*<\/span><\/div><input class="form-control" data-val="true" data-val-required="من فضلك أدخل الاسم" id="txtSeatingNumIndex" name="Name" type="text" value=""><div id="errorMsgIndex" class="errorMsg"><span>من فضلك أدخل رقم الجلوس بطريقة صحيحة<\/span><\/div><a id="btnSearchIndex"  >بحث<\/a><div class="thanawyaSponsor"><div class="cnts"><div class="spnsr">برعاية<\/div><a href="http://www.nub.edu.eg/apply/"><img src="/Images/nahdaUnv.png" /><\/a><\/div><\/div><\/div>',NategaLive:"",ViewsUpdated:"",divRelated:"#divRelated-",InterScrollerDiv:"#InterScroller",inBodyInjectionOrder:["showcase","related","interscroller"],Load:function(){Article.ViewsUpdated=="False"&&(console.log("views updated"),Article.AddView(Article.postId));Article.AddTagsLinks(Article.postId);(Article.templateId==Article.VideoTempId||window.location.href.toLowerCase().indexOf("video")!=-1)&&Article.FixVideoTemp(Article.postId);Article.FixImageSize(Article.postId);Article.InjectAds(Article.postId)},AddView:function(n){n>0&&$.ajax({type:"GET",dataType:"Json",contentType:"application/json; charset=utf-8",url:$(hdAppPathId).val()+"/Article/AddView",data:{postId:JSON.stringify(Article.postId)},success:function(t){console.log("Add view result is "+t.status+" for post id "+n)},error:function(){console.log("error: Add view for post Id "+n)}})},AddTagsLinks:function(n){var t="#articleId-"+n,i,r;Article.bodyKeywordLinkIsAllowed===!0&&(i=[],$(t+Article.divBody).find("a").each(function(){i.push($(this).html());$(this).text("");$(this).removeAttr("title")}),r=$(t+Article.divBody).html(),$(t+" .keywordsDiv a").each(function(){var n=new RegExp(" "+$(this).html().trim()+" ","g");r=r.replace(n,'<a class="'+Article.bodyKeywordLinkClass+'" href="'+Article.bodyKeywordLinkTemplate.replace("{keywordid}",$(this).attr("id")).replace("{rootcategory}",Article.rootCategory).replace("{keywordname}",$(this).html().trim().split(" ").join("-"))+'"> '+$(this).html().trim()+" <\/a>")}),$(t+Article.divBody).html(r),$(t+Article.divBody).find("a[class!='kwhd']").each(function(n){$(this).html(i[n]);$(this).attr("title",i[n])}))},FixImageSize:function(n){var t="#articleId-"+n,i=$(t+Article.divBody).html()},FixVideoTemp:function(n){var i="#articleId-"+n,t=$(i+Article.divBody).html(),f=$($(i+Article.divBody).html()).find("iframe"),e=t.indexOf("twitter-video"),r,u;e>-1?(r=$($(i+Article.divBody).html()).find("blockquote"),r=r.prevObject[0].outerHTML,u=$($(i+Article.divBody).html()).find("script"),u=u.prevObject[2].outerHTML,t=t.replace(u,""),t=t.replace(r,""),$(i+Article.VideoDiv).html(r+u)):f.length>0?($(f).each(function(n){n==0?(t=t.replace(this.outerHTML,""),$(i+Article.VideoDiv).html(this)):t=t.replace(this.outerHTML,'<div class="mediaBody">'+this.outerHTML+"<\/div>")}),$(i+Article.divBody).html(t)):$(i+Article.divBody).html(t);$(i+Article.VideoBody).show()},InjectAds:function(n){var t="#articleId-"+n,o,u,f,i,e;if(Article.isMobile=$("#hdIsMobile").val(),o=$(t).attr("templateId"),u=$(Article.InterScrollerDiv).html(),Article.isMobile=="true"){if($(t+Article.divBody).html()!=undefined&&$(t+Article.divBody).html()!=""){var s=$(t+Article.divBody).children("p").filter(function(){return $(this).html().length>Article.maxPlength}).length,h=$(t+Article.divBody).find("p:not(:empty)").length,r=!1;if(s>1?(f=0,i=1,$(t+Article.divBody).children("p").each(function(){if($(this).html().length>Article.maxPlength){if(i<=Article.inBodyInjectionOrder.length)if(Article.inBodyInjectionOrder[i-1]==="showcase")$(Article.iframe.replace("#iframeSrc",Article.iframeSrc)).insertAfter($(this)),i++,r=!0;else if(Article.inBodyInjectionOrder[i-1]==="interscroller")$(u).insertAfter($(this)),$(Article.InterScrollerDiv).remove(),i++,r=!0;else if(Article.inBodyInjectionOrder[i-1]==="related")$($(Article.divRelated+Article.postId).html()).insertAfter($(this)),$(Article.divRelated+Article.postId).remove(),i++,r=!0;else return!1;f++}})):$($(Article.divRelated+n)).show(),!r)return $(Article.iframe.replace("#iframeSrc",Article.iframeSrc)).insertAfter($(Article.divBody)),r=!0,!0}}else $(t+Article.divBody).html()!=undefined&&$(t+Article.divBody).html()!=""&&(e=$(t+Article.divBody).children("p").filter(function(){return $(this).html().length>Article.maxPlength}).length,e>=1?Article.templateId==11&&$(".WizImg").length?$($(Article.divRelated+n).html()).insertAfter(".WizImg"):$(Article.divRelated+Article.postId+" .pattern01").length>0?$($(Article.divRelated+n).html()).prependTo($(t+Article.divBody)[$(t+Article.divBody).length-1]):$(Article.divBody).children("p").each(function(){if($(this).html().length>130)return $($(Article.InterScrollerDiv).html()).insertAfter($(this)),!1}):$($(t+Article.divRelated+n)).show())},GetNextArticle:function(){if(Article.isInfiniteScrollAllowed){var n,i,t;Article.isInfiniteScrollAllowed=!1;i=$($(Article.ulInterestingArticles).children().last()).attr("postId");$(Article.ulInterestingArticles).children(".active").length>0?(n=$($(Article.ulInterestingArticles).children(".active").next()).attr("postId"),t=$($(Article.ulInterestingArticles).children(".active").next()).attr("postDate"),$(Article.ulInterestingArticles).children().removeClass("active"),$(Article.ulInterestingArticles).children('[postId="'+n+'"]').addClass("active")):($(Article.ulInterestingArticles).children().removeClass("active"),n=$($("#ulInterestingArticles").children()[0]).attr("postId"),t=$($("#ulInterestingArticles").children()[0]).attr("postDate"),$(Article.ulInterestingArticles).children('[postId="'+n+'"]').addClass("active"));n==i&&(isInfiniteScrollAllowed=!1,Article.isLastArticle=!0);n>0?$.ajax({type:"GET",dataType:"html",contentType:"application/html; charset=utf-8",url:$(hdAppPathId).val()+"/Article/Get?ajaxCount="+ajaxCount,data:{postId:n,postDate:t},success:function(t){var u,r,i,f;ajaxCount++;Article.isInfiniteScrollAllowed=!0;$(t).insertBefore($(".cd-articles").children().last());Article.AddTagsLinks(n);u=$("#articleId-"+n).attr("IsViewsUpdated");console.log("article id "+n+" property "+u);$("#articleId-"+n).attr("IsViewsUpdated")=="False"&&(Article.AddView(n),console.log("ajax add page views"));r=$("#articleId-"+n).attr("templateId");Article.templateId=r;r==Article.VideoTempId&&Article.FixVideoTemp(n);Article.FixImageSize(n);Article.InjectAds(n);LazyLoader();i=$('li[postId="'+n+'"]').find("a").attr("href");i.indexOf("#InterestingArticle")&&(i=i.replace("#InterestingArticle","#interestingInfiniteLoad"));r==Article.SeriesTempId&&(i+="?page=1");f=$('li[postId="'+n+'"]').find("a").attr("title");trackArticleView(i,f,n);$("#articleId-"+n).find(".fbComments").length>0&&(window.fbAsyncInit=function(){FB.init({appId:"your-app-id",xfbml:!0,version:"v2.1"})},FB.XFBML.parse());General.CollectBehavior(n);afterNextArticle()},error:function(){console.log("error: getting post")}}):$("#divLoadMore").hide()}},ChangeSocialMediaLink:function(n){var t=window.location.href;$(".icon-fb").attr("title",n);$(".icon-fb").click(function(i){return i.preventDefault(),window.open("https://www.facebook.com/sharer/sharer.php?u="+t+"&text="+n,"sharer","width=655,height=430"),!1});$(".icon-tw").attr("title",n);$(".icon-tw").click(function(i){return i.preventDefault(),window.open("https://twitter.com/share?url="+t+"&text="+n,"sharer","width=655,height=430"),!1});$(".icon-ggl").attr("title",n);$(".icon-ggl").click(function(i){return i.preventDefault(),window.open("https://plus.google.com/share?url="+t+"&text="+n,"sharer","width=655,height=430"),!1});$(".icon-msngr").attr("title",n);$(".icon-msngr").click(function(i){return i.preventDefault(),window.open("https://www.facebook.com/dialog/send?app_id=5483364177&link="+t+"&text="+n+"&redirect_uri=https://www.masrawy.com/","sharer","width=655,height=430"),!1});$(".icon-mail").attr("title",n);$(".icon-mail").attr("href","mailto:?subject="+n+" &body= Check out this article "+t)},CheckInterestingArticles:function(){$(Article.ulInterestingArticles).children('[postId="'+Article.postId+'"]').length>0?$(Article.ulInterestingArticles).children('[postId="'+Article.postId+'"]').remove():$(Article.ulInterestingArticles).children().last().remove();$(Article.ulInterestingArticles+" li:eq(0)").before($("#divFirstIntersting").html())},InjectAds0:function(){if(Article.isMobile=$("#hdIsMobile").val(),Article.isMobile=="true"&&$(Article.divBody).html()!=undefined&&$(Article.divBody).html()!=""){var n=$(Article.divBody).children("p").filter(function(){return $(this).html().length>Article.maxPlength}).length,t=$(Article.divBody).find("p:not(:empty)").length;n>1&&$(Article.divBody).children("p").each(function(){if($(this).html().length>Article.maxPlength)return $(Article.iframe.replace("#iframeSrc",Article.iframeSrc)).insertAfter($(this)),!1})}},FixVideoTemp0:function(){var n=$(Article.divBody).html(),t=$($(Article.divBody).html()).find("iframe");t.length>0&&$(t).each(function(t){t==0?(n=n.replace(this.outerHTML,""),$(Article.VideoDiv).html(this)):n=n.replace(this.outerHTML,'<div class="mediaBody">'+this.outerHTML+"<\/div>")});$(Article.divBody).html(n);$(Article.VideoBody).show()},FixImageSize0:function(){var n=$(Article.divBody).html(),i=$($(Article.divBody).html()).find("img"),t;$(i).each(function(){n=n.replace(this.outerHTML,'<div class="mediaBody">'+this.outerHTML+"<\/div>")});t=$($(Article.divBody).html()).find("iframe");t.length>0&&$(t).each(function(){n=n.replace(this.outerHTML,'<div class="mediaBody">'+this.outerHTML+"<\/div>")});$(Article.divBody).html(n)},ChangeKeyWords0:function(){var t,n;Article.bodyKeywordLinkIsAllowed===!0&&(t=[],$(Article.divBody).find("a").each(function(){t.push($(this).html());$(this).html("")}),n=$(Article.divBody).html(),$(".keywordsDiv a").each(function(){var t=new RegExp(" "+$(this).html().trim()+" ","g");n=n.replace(t,'<a class="'+Article.bodyKeywordLinkClass+'" href="'+Article.bodyKeywordLinkTemplate.replace("{keywordid}",$(this).attr("id")).replace("{rootcategory}",Article.rootCategory).replace("{keywordname}",$(this).html().trim().split(" ").join("-"))+'"> '+$(this).html().trim()+" <\/a>")}),$(Article.divBody).html(n),$(Article.divBody).find("a[class!='kwhd']").each(function(n){$(this).html(t[n])}))}}