function BaseModel(n,t){var i=this;if(n==undefined||typeof n!="function")throw new Error("createItemFn can't be undefined and it has to be function.");t==undefined&&(t="Please wait");i.Data=ko.observableArray([]);i.Data.subscribe(function(n){i.DataLoaded(n)});i.HasError=ko.observable(!1);i.ShowProgressBar=ko.observable(!0);i.ResultMessage=ko.observable("");i.CreateItemFn=n;i.WaitMessage=ko.observable(t);i.CreateFromArray=function(n){var r,t;if(n==undefined||n.length==undefined){alert("CreateFromArray expects an array. Please only pass array.");return}for(r=[],t=0;t<n.length;t++)r.push(new i.CreateItemFn(n[t]));return r};i.DataBlock=ko.observableArray([]);i.TotalRecords=ko.observable(0);i.CreateFromDataBlock=function(n){if(n.DataBlock().length){i.WaitMessage("Please wait. Loading ("+n.Data().length+"/"+n.TotalRecords()+")");var t=n.DataBlock.splice(0,chiConfig.Debug?25:25),r=n.CreateFromArray(t);setTimeout(function(){ko.utils.arrayPushAll(n.Data(),r);n.Data.valueHasMutated();n.CreateFromDataBlock(n)},0)}else i.WaitMessage(""),i.ShowProgressBar(!1),i.DataBlockLoaded()};i.DataLoaded=function(){};i.DataBlockLoaded=function(){};i.Reset=function(){i.HasError(!1);i.ResultMessage("");i.ShowProgressBar(!1)}}function ViewModel(){var n=this;n.IsAuthenticated=ko.observable(!1)}function PaperModel(n){var t=this;t.CHIReference=n.CHIReference;t.AuthorsAndYear=n.AuthorsAndYear;t.Authors=n.Authors;t.PaperTitle=n.PaperTitle;t.PublishedDate=n.PublishedDate;t.ThumbnailUrl=n.ThumbnailUrl;t.IsCarousel=n.IsCarousel;t.ContentID=n.ContentID;t.CarouselImageURL=n.CarouselImageURL;t.IsThumbnailAvailable=ko.computed(function(){return $.trim(t.ThumbnailUrl)!=""&&t.ThumbnailUrl!=null},this);t.Colspan=ko.computed(function(){return t.IsThumbnailAvailable()?0:2},this);t.Link=ko.computed(function(){return chiConfig.RootURL+t.CHIReference},this);t.BookmarkState=ko.observable("not-bookmarked");t.BookmarkState.subscribe(function(n){n=="not-bookmarked"?t.BookmarkVisibility(!1):t.BookmarkVisibility(!0)});t.BookmarkTooltip=ko.computed(function(){return t.BookmarkState()=="not-bookmarked"?"Bookmark this paper":"Clear bookmark"},this);t.BookmarkLink=ko.computed(function(){return"javascript:QuickAddRemoveBookmark('"+t.ContentID+"')"},this);t.BookmarkVisibility=ko.observable(!1);t.MouseOver=function(){t.BookmarkState()=="not-bookmarked"?t.BookmarkVisibility(!0):t.BookmarkVisibility(!0)};t.MouseOut=function(){t.BookmarkState()=="not-bookmarked"?t.BookmarkVisibility(!1):t.BookmarkVisibility(!0)}}function FileModel(n){var t=this;t.Extension=n.Extension;t.FileURL=n.FileURL;t.Name=n.Name;t.Link=ko.computed(function(){return chiConfig.RootURL+t.FileURL},this)}function TagModel(n){var t=this;t.TagID=n.ID;t.Title=n.Title;t.Type="tag-"+n.Type.toLowerCase();t.Link=ko.computed(function(){return chiConfig.RootURL+"Home/AdvancedSearch?source=tag&tags="+t.TagID},this)}function PaperAuthorModel(n){var t=this;t.Authors=CreatePaperAuthorModels(n.Authors,n.ContentID);t.PaperTitle=n.PaperTitle;t.CHIReference=n.CHIReference;t.ContentID=n.ContentID;t.Save=ko.observable(n.Save);t.AllAuthors=n.AllAuthors;t.RowNumber=n.RowNumber;t.Link=ko.computed(function(){return chiConfig.RootURL+"Content/Files/"+t.CHIReference+".pdf"},this);t.JournalPage=ko.computed(function(){return chiConfig.RootURL+t.CHIReference},this);t.EnableCheckBox=ko.computed(function(){var n,i;if(t.Authors.length){for(n=0;n<t.Authors.length;n++)if(i=t.Authors[n],ko.unwrap(i.AuthorID)==0||ko.unwrap(i.AutoUpdated)==!0)return t.Save(!1),!1;return t.Save(!0),!0}return t.Save(!1),!1},this);t.AutoUpdated=ko.computed(function(){var n,i;if(t.Authors.length){for(n=0;n<t.Authors.length;n++)if(i=t.Authors[n],ko.unwrap(i.AutoUpdated)==!0)return!0;return!1}return!1},this);t.ConfirmationRecieved=function(){var n,i;if(t.Authors.length){for(n=0;n<t.Authors.length;n++)i=t.Authors[n],i.AutoUpdated(!1);t.Save(t.EnableCheckBox())}}}function AuthorDetails(n,t){var i=this;i.AuthorID=ko.observable(n.AuthorID);i.ContentID=t;i.PaperAuthorID=n.PaperAuthorID;i.AuthorAffiliationID=ko.observable(n.AuthorAffiliationID);i.FirstName=n.FirstName;i.LastName=n.LastName;i.CompleteName=n.CompleteName;i.AutoUpdated=ko.observable(n.AutoUpdated);i.SelectedAuthor=ko.observable(n.SelectedAuthor);i.SelectedAuthor.subscribe(function(n){var t=n;i.AuthorID(t.split("|")[0]);i.AuthorAffiliationID(t.split("|")[1])},this)}function CreatePaperAuthorModels(n,t){for(var u=this,r=[],i=0;i<n.length;i++)r.push(new AuthorDetails(n[i],t));return r}function AuthorMangementModel(n,t,i,r,u,f){var e=this;e.ID=ko.observable(n||"");e.FirstName=ko.observable(t||"");e.LastName=ko.observable(i||"");e.Email=ko.observable(r||"");e.ContactID=ko.observable(u||"");e.Affiliations=ko.observable(f||[]);e.AddAffiliation=function(){e.Affiliations().push(new AuthorAffiliation);e.Affiliations.valueHasMutated()}}function AuthorAffiliation(n,t,i,r,u){var f=this;f.ID=ko.observable(n||"");f.Company=ko.observable(t||"");f.City=ko.observable(i||"");f.Region=ko.observable(r||"");f.Country=ko.observable(u||"")}function AdvancedSearchParameters(){var n=this;n.ContentID=ko.observable(0);n.CHIRefernceID=ko.observable("");n.JournalID=ko.observable("J001");n.Tags=ko.observableArray([]);n.AuthorID=ko.observable(-1);n.Query=ko.observable("");n.PublishedIn=ko.observable("");n.Source=ko.observable("");n.Duration=ko.computed(function(){return n.PublishedIn()=="-1"?"all":"year"},this);n.FilterStatus=ko.computed(function(){var e=document.getElementById("PapersauthorIs"),r=e.querySelector('option[value="'+n.AuthorID()+'"]'),u,t,f,i;if(r&&console.log(r.textContent),u="  filtered on {0}",t=[],n.Tags().length>0&&t.push("subject"),n.PublishedIn()!=-1&&t.push(n.PublishedIn()),n.AuthorID()!=-1&&n.AuthorID()!="Any"&&t.push(r.textContent),n.Query().trim()!=""&&t.push("containing words"),t.length==0)return"";if(t.length==1)return u.format(t[0]);for(f="",i=0;i<t.length;i++)f+=i==0?t[i]:i==t.length-1?" and "+t[i]:", "+t[i];return u.format(f)},this);n.Title=ko.computed(function(){return n.FilterStatus().trim()==""?"All papers":"Result"},this)}function ContactBookmarks(n){var t=this;t.CHIReference=n.CHIReference;t.PaperTitle=n.PaperTitle;t.ContentID=n.ContentID;t.Link=ko.computed(function(){return chiConfig.RootURL+t.CHIReference},this)}function NextActionItems(){}function GetPapersList(n,t,i){$.ajax({type:"POST",url:chiConfig.RootURL+n,async:!0,cache:!0,dataType:"json",data:{journalID:t,contentID:i,__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){UpdateModels(_model.Papers,n)})}function GetAdditionalData(n){$.ajax({type:"POST",url:chiConfig.RootURL+"Journals/GetAdditionalData",async:!0,cache:!0,dataType:"json",data:{CHIReferenceID:n,__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){UpdateModels(_model.Files,n)})}function GetTags(n){$.ajax({type:"POST",url:chiConfig.RootURL+"Journals/GetTags",async:!0,cache:!0,dataType:"json",data:{contentID:n,__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){UpdateModels(_model.Tags,n)})}function ResetPapers(){_model.Papers.ResultMessage("");_model.Papers.Data([]);_model.Papers.ShowProgressBar(!0)}function UpdateModels(n,t){if(n.HasError(!1),ResponseContainsError(t)){HandleErrorResponse(n,t);return}UpdateVisibility($("#"+n.ToggleControlName),t.NoRecordsFound);n.ShowProgressBar(!1);t.NoRecordsFound?t.NoRecordsFound&&n.ResultMessage(t.NoRecordsFoundMessage):n.Data(n.CreateFromArray(t.Data))}function UpdateModelInChunks(n,t){if(ResponseContainsError(t)){HandleErrorResponse(n,t);return}t.NoRecordsFound?t.NoRecordsFound&&(n.ShowProgressBar(!1),n.ResultMessage(t.NoRecordsFoundMessage)):(n.Data([]),n.DataBlock(t.Data),n.TotalRecords(n.DataBlock().length),n.CreateFromDataBlock(n))}function ResponseContainsError(n){return n.HasError==undefined||n.HasError==!0}function HandleErrorResponse(n,t){var i="Sorry, we are unable to process your request.";chiConfig.Debug&&(i=t.ErrorMessage!=undefined?i+" "+t.ErrorMessage:$(t.responseText).find(".error").html(),n.HasError(!0));n.ShowProgressBar(!1);n.ResultMessage(i)}function UpdateVisibility(n,t){var u=n.attr("name"),i=$.cookie(u),r=n.next(".togglerow").is(":visible");i==undefined?t==!0&&r&&n.trigger("click",!1):i!="true"&&r?n.trigger("click",!1):i!="true"||r||n.trigger("click",!1)}function ValidateUser(n,t){var i=!1;return $.ajax({type:"POST",url:chiConfig.RootURL+"Authorization/Validate",async:!1,cache:!1,dataType:"json",data:{username:n,password:t,__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){n.ValidUser!=undefined&&n.ValidUser==!0&&(i=!0)}),i}function GetPaperAuthors(){_model.PaperAuthors.ShowProgressBar(!0);_model.PaperAuthors.WaitMessage("Please wait while we retrieve data.");_model.PaperAuthors.Data([]);var n=$("#showall").prop("checked")==!0;_model.PaperAuthors.ResultMessage("");$.ajax({type:"POST",url:chiConfig.RootURL+"DataEntry/GetPaperAuthors",async:!0,cache:!0,dataType:"json",data:{showall:n,pageSize:$("#pagesize").val(),pageNumber:$("#currentpage").val()||1,__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){UpdateModelInChunks(_model.PaperAuthors,n)});GetPendingPapersRecordCount()}function GetPendingPapersRecordCount(){$.ajax({type:"POST",url:chiConfig.RootURL+"DataEntry/GetPendingPaperCount",async:!0,cache:!0,dataType:"json",data:{__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){var t;if(!ResponseContainsError(n)){_model.PaperAuthors.PendingPapersCount(n.Data.PendingPapersCount);_model.PaperAuthors.TotalPapersCount(n.Data.TotalPapersCount);var i=$("#showall").prop("checked")==!0,r=i?n.Data.TotalPapersCount:n.Data.PendingPapersCount,u=$("#pagesize").val(),f=Math.ceil(r/u),e=$("#currentpage").val()||1;for($("#currentpage").empty(),t=1;t<=f;t++)$("#currentpage").append($("<option>",{value:t,text:t}));$("#currentpage").val(e)}})}function SavePaperAuthorsMapping(){for(var i=_model.PaperAuthors.Data(),n=[],t=0;t<i.length;t++)i[t].Save()&&i[t].EnableCheckBox()&&n.push(i[t]);if(n.length==0){alert("Please select at least one record before clicking save.");return}_model.PaperAuthors.ShowProgressBar(!0);$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:chiConfig.RootURL+"DataEntry/EditPaperAuthorsMapping",async:!0,cache:!0,dataType:"json",data:ko.toJSON({paperMapping:n})}).always(function(t){if(t.HasError==!0)_model.PaperAuthors.ShowProgressBar(!1),_model.PaperAuthors.ResultMessage(t.ErrorMessage);else if(ResponseContainsError(t))HandleErrorResponse(_model.PaperAuthors,t);else{for(var i=0;i<n.length;i++)n[i].Save(!1);GetPaperAuthors();_model.PaperAuthors.ShowProgressBar(!1);_model.PaperAuthors.ResultMessage(t.Data)}})}function CreateNavigationLinks(){$("H1").each(function(n){$(this).wrap(GetWrapper(n,$(this).text()));$(this).addClass("anchoroffset")});var n=$("<div />"),i=$("H1").length,t=[];$("H1").each(function(n){t.push(GetNavigationLink($(this).text(),"#"+$(this).text().replace(" ","_"),i!=n+1))});n.html(t);$(".headername").append(n)}function GetWrapper(n,t){return $("<div />",{"class":"headername"}).html($("<a />",{"class":"nounderline  default-color",name:t.replace(" ","_")}))}function GetNavigationLink(n,t,i){var r=i?" | ":" ";return $("<a />",{"class":"nounderline",href:t,text:n+r})}function SaveAuthorManagment(){var t=_model.AuthorMangement.Data().ContactID(),n,i;if(t==""){alert("CRM Contact ID can't be empty. Please select record from the search results only.");$("#FirstName").focus();return}_model.AuthorMangement.ShowProgressBar(!0);n=$("#EditAuthor").val().toLowerCase()=="true";i=ko.toJSON({authorDetails:_model.AuthorMangement.Data,editAuthor:n});$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:chiConfig.RootURL+"DataEntry/AuthorManagement",async:!0,cache:!0,dataType:"json",data:i}).always(function(i){if(ResponseContainsError(i))HandleErrorResponse(_model.AuthorMangement,i);else if(i.RecordAlreadyExists){var r=confirm(i.RecordAlreadyExistsMessage);r&&(window.location=chiConfig.RootURL+"DataEntry/AuthorManagement?edit=true&crmid="+t)}else _model.AuthorMangement.Reset(),_model.AuthorMangement.ShowProgressBar(!1),_model.AuthorMangement.ResultMessage(i.Data),$("#Clear").trigger("click"),n&&_typeaheadSuggestionEngine.clearRemoteCache();$(".typeahead").focus()})}function LoadAuthor(){var n=$("#EditAuthor").val().toLowerCase()=="true",t=$("#CRMID").val();$.trim(t)!=""&&n!=!1&&$.ajax({type:"POST",url:chiConfig.RootURL+"DataEntry/SearchAuthor",async:!0,cache:!0,dataType:"json",data:{editAuthor:n,query:t}}).always(function(n){var t=_model.AuthorMangement.Data(),i=n[0];t.ID(i.ID);t.FirstName(i.FirstName);t.LastName(i.LastName);t.Email(i.Email);t.ContactID(i.ContactID);t.Affiliations(ko.utils.arrayMap(i.Affiliations,function(n){return new AuthorAffiliation(n.ID,n.Company,n.City,n.Region,n.Country)}));$("#AddAffiliation").focus()})}function AdvancedSearchParametersChanged(n){model.Query()!=n.T&&(model.Query(n.T),SubmitAdvancedSearch("Hint"))}function SubmitAdvancedSearch(n){var t,u,f,e;ResetPapers();t=_model.AdvancedSearchParameters;t.Source(n||"");var o=chiConfig.RootURL+"Home/AdvancedSearch",r="",i=null;if(r="duration="+t.Duration()+"&publishedin="+t.PublishedIn(),i=$.extend(i,{duration:t.Duration(),publishedin:t.PublishedIn()}),r+="&authorid="+t.AuthorID(),i=$.extend(i,{authorid:t.AuthorID()}),t.Tags().length!="0")for(u=0;u<t.Tags().length;u++)r+="&tags["+u+"]="+t.Tags()[u],i=$.extend(i,{tags:t.Tags()});r+="&query="+t.Query();i=$.extend(i,{query:t.Query()});i!=null&&(History.pushState(i,"Search","?"+r),f=escape(o+"?"+r+"&source=Link"),e="mailto:&subject=Link to search results&body=Link to search results <"+f+">",$(".shareusingemail").attr("href",e));$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:chiConfig.RootURL+"Home/PeformAdvancedSearch",async:!0,cache:!0,dataType:"json",data:ko.toJSON(t)}).always(function(n){var i,t;if(UpdateModels(_model.Papers,n),!ResponseContainsError(n)&&_model.CurrentBookmarks().length>0){for(i=[],t=0;t<_model.CurrentBookmarks().length;t++)i.push(_model.CurrentBookmarks()[t]);_model.CurrentBookmarks.removeAll();_model.CurrentBookmarks(i)}})}function GetHYDRO(){$.ajax({type:"POST",url:chiConfig.RootURL+"Home/GetSpecialIssuesContents",async:!0,cache:!0,dataType:"json",data:{CHIReference:"h%",__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){UpdateModels(_model.HYDRO,n)})}function GetSCNSU(){$.ajax({type:"POST",url:chiConfig.RootURL+"Home/GetSpecialIssuesContents",async:!0,cache:!0,dataType:"json",data:{CHIReference:"s%",__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){UpdateModels(_model.SCNSU,n)})}function GetETHIOPIA(){$.ajax({type:"POST",url:chiConfig.RootURL+"Home/GetSpecialIssuesContents",async:!0,cache:!0,dataType:"json",data:{CHIReference:"e%",__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){UpdateModels(_model.SCNSU,n)})}function GetAWaRe(){$.ajax({type:"POST",url:chiConfig.RootURL+"Home/GetSpecialIssuesContents",async:!0,cache:!0,dataType:"json",data:{CHIReference:"a%",__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){UpdateModels(_model.SCNSU,n)})}function GetNewArticles(n){n=getURLParameter("id");$.ajax({type:"POST",url:chiConfig.RootURL+"Home/GetHomePageContents",async:!0,cache:!0,dataType:"json",data:{journalID:n,__RequestVerificationToken:$("input[name='__RequestVerificationToken'][type='hidden']").val()}}).always(function(n){var i,t;if(UpdateModels(_model.Papers,n),!ResponseContainsError(n)&&_model.CurrentBookmarks().length>0){for(i=[],t=0;t<_model.CurrentBookmarks().length;t++)i.push(_model.CurrentBookmarks()[t]);_model.CurrentBookmarks.removeAll();_model.CurrentBookmarks(i)}})}function getURLParameter(n){return decodeURIComponent((new RegExp("[?|&]"+n+"=([^&;]+?)(&|#|;|$)").exec(location.search)||[,""])[1].replace(/\+/g,"%20"))||null}function UpdateQueryString(n,t,i){var u,f,r;return i||(i=window.location.href),u=new RegExp("([?&])"+n+"=.*?(&|#|$)(.*)","gi"),u.test(i)?typeof t!="undefined"&&t!==null?i.replace(u,"$1"+n+"="+t+"$2$3"):(r=i.split("#"),i=r[0].replace(u,"$1$3").replace(/(&|\?)$/,""),typeof r[1]!="undefined"&&r[1]!==null&&(i+="#"+r[1]),i):typeof t!="undefined"&&t!==null?(f=i.indexOf("?")!==-1?"&":"?",r=i.split("#"),i=r[0]+f+n+"="+t,typeof r[1]!="undefined"&&r[1]!==null&&(i+="#"+r[1]),i):i}function CreateCollapsibleSections(n){var i=$("<HR />",{"class":"h2-separator"}),t=$("<a />",{href:"javascript:void(0);","class":"toggle nounderline collapsible-paper-section"});n!=!1&&t.addClass("anchoroffset");t.attr({"data-toggle-between":"icon-expand-brown icon-collapse-brown","data-update-cookie":"false"});i.insertBefore($("#content H2:not(.modal-title)"));$("#content H2:not(.modal-title)").each(function(){var u,f;n!=!1&&$(this).text($(this).text().toUpperCase());var e=$("<span />",{"class":"sprite icon-collapse-brown toggleicon"}),r=SafeName($(this).text().toLowerCase()),i=t.clone();i.attr("name",r);i.attr("id",r);$(this).wrap(i);$(this).prepend(e);u=$(this).parent().nextUntil(".h2-separator");f=$("<div />",{"class":"togglerow primary-col-contents-padding"});u.wrapAll(f)})}function JumpTo(n){var t=$(n).next(".togglerow").is(":visible");return t||$(n).trigger("click"),!0}function RegisterToggleControls(){$(".toggle").click(function(n,t){var r,i;$(this).next(".togglerow").toggle();$(this).find(".toggleicon").toggleClass($(this).attr("data-toggle-between"));t=t||$(this).attr("data-update-cookie").toLowerCase()=="true";t!=!1&&(r=$(this).attr("name"),i=$(this).next(".togglerow").is(":visible"),$.cookie(r,i));i=$(this).next(".togglerow").is(":visible")})}function RegisterExpandCollapseAll(n){$(n).click(function(){var n=$(this).text().toLowerCase()=="expand all",t;$(this).text(n?"Collapse all":"Expand all");t=$(this).attr("data-action-on");$(t).each(function(){var t=$(this).next(".togglerow").is(":visible");(n==!0&&t==!1||n==!1&&t==!0)&&$(this).trigger("click")})})}function SafeName(n){return n.replace(/\||\s+/g,"")}function AboutCreateNavigationLinks(){var n=$("#content h2");$("#navigationlinks").append("<HR />");n.each(function(t){var i="#"+SafeName($(this).text().toLowerCase()),r=$("<a />",{href:i,"class":"nounderline default-color",onclick:'javascript:JumpTo("'+i+'")',text:$(this).text()}),u=$("<h3 />",{"class":"affix-sidebar-padding"}).append(r);$("#navigationlinks").append(u);t!=n.length-1&&$("#navigationlinks").append("<HR />")})}function UpateReferenceList(){$("h2:contains('References')").next("ol").addClass("reference-ol-list")}function UpdateH2(){$("#content H2:not(.modal-title)").each(function(){var n,i,t;if($(this).text($(this).text().toUpperCase()),n=$(this).text().split(" "),n.length>=2&&$.isNumeric(n[0])){for(i=n[0]+"<span class='paper-title-separator'>.<\/span>",t=1;t<n.length;t++)i+=" "+n[t];$(this).html($.parseHTML(i))}})}function UpdatePaperTables(){var n=$("#content table:not(.where):not(.equation)").wrap($("<div />",{"class":"table-container"}).on("scroll",function(){$(this).find(".enlarge-button").css({right:($(this).scrollLeft()-2)*-1})}));n.each(function(){$(this).addClass("table-formatting");var n=!1,t=1;$("tr:lt(2)",$(this)).each(function(i){var r=$("td.underline",$(this)).length!=0;n=n||r;r&&(t=i+1)});n&&$("tr:lt("+t+")",$(this)).addClass("table-header")})}function ResizeSubMenu(){var n=$(window).width();n<400?$("ul[aria-labelledby='smallMenu']").width(250):n>400&&n<500?$("ul[aria-labelledby='smallMenu']").width(300):$("ul[aria-labelledby='smallMenu']").width(400)}function ResizeAffixControlsBecauseOfScrolling(){var n=$(".affix-container"),h=parseInt($(window).width(),10),u,o,s;if(n.length!=0&&!(h<chiConfig.SCREEN_SM_MAX)){var e=90,f=$(".sidebar-col-affix").offset().top,i=f+$(".primary-col-with-sidebar").outerHeight()-1,r=n.offset().top,t=parseInt(n.css("max-height"),10);isNaN(t)&&(t=parseInt(n.height(),10));u=$("header").offset().top;o=$(window).scrollTop();r+t>=i?(s=i-t,n.offset({top:Math.max(s,70)})):o==0||r<f?n.offset({top:f}):u>r&&r+t<i&&t+u+e<i&&n.offset({top:u+e})}}function LogOff(){var n=$("#logoff");$.ajax({type:n.attr("method"),url:n.attr("action"),data:n.serialize()}).always(function(){location.href=[location.protocol,"//",location.host,location.pathname].join("")})}function AccountManagement(n,t){var e=t.substr(0,1)==="/",r,u,i,f;e&&(t=t.substr(1,t.length));r=t.indexOf("?");u="";r!=-1&&(u=t.substr(r+1,t.length),t=t.substr(0,r));i=UpdateQueryString("Email",$("#Email").val(),location.href.replace(/#/g,""));$.trim(u)!==""&&(i+="&"+u);f=chiConfig.RootURL+t+i.substr(i.indexOf("?"),i.length);location.href=f}function GetPartialForm(n,t,i){function e(){var n,t;requestConfig.IsMobile?n=r.find(".btn").first():(t=r.find(".has-error"),n=t.length!==0?t.find("input[type='text']").first():r.find("input[type='text']").first(),n.length!==1&&(n=r.find("input[type='password']").first()));n.length!==1?DebugAlert("Unable to set the focus, Length: "+n.length):n.focus()}var o=n.substr(0,1)==="/";o&&(n=n.substr(1,n.length));var u=$("#"+t),s=UpdateQueryString("Email",$("#Email",u).val(),n.replace(/#/g,"")),f=chiConfig.RootURL+s,r=u.closest(".modal");r.off("show.bs.modal");r.off("hidden.bs.modal");typeof i!="undefined"&&i===!1?$.get(f,{stamp:$.now()},function(n){u.html(n);r.modal("show");e()}):$.get(f,function(n){u.html(n);r.modal("show");e()})}function LoginSuccess(){var n=$("#NextAction").val(),t;typeof n!="undefined"&&n.trim()!=""&&(postAuthentication.NextAction=n,t=$("#NextActionValue").val(),t.trim()!=""&&(postAuthentication.NextActionValue=t));$(".account-management").modal("hide");postAuthentication.Execute();setTimeout(function(){HeaderHelperSupplement.Initialize()},750)}function LoginFailure(n){var t=$("#message",$(".account-management"));typeof n.ErrorMessage=="undefined"?(DebugAlert("This is a messed up case."),t.text("We are unable process your request. Please reload the page and try again.")):t.html(n.ErrorMessage);t.addClass("error")}function RegisterSuccess(){var n=$(".account-management"),t=$("#message",n),i=$("#progress",n);t.html("<p>We have sent you a confirmation email. Please click on the link provided in the email to activate your account.<\/p><p>If you don't see the email please check your spam folder.<\/p>");t.removeClass("error");$(".modal-body-controls",n).hide();$("h1",n).text("Check your email");$(".btn",n).hide();$("#account_reason",n).hide();$("#login_link",n).hide()}function RegisterFailure(n){LoginFailure(n)}function ForgotPasswordSuccess(){var n=$(".account-management"),t=$("#message",n),i=$("#progress",n);t.text("We have emailed you link to reset your password. Please check your email.");$(".modal-body-controls",n).hide();$("h1",n).text("Password reset");$(".btn",n).hide()}function ForgotPasswordFailure(n){LoginFailure(n)}function ResetPasswordSuccess(n){LoginSuccess(n)}function ResetPasswordFailure(n){LoginFailure(n)}function EditProfileSuccess(n){var t=$(".account-management"),r=$("#message",t),f=$("#progress",t),i,u;r.text("Your profile has been updated.");$("h1",t).text("Profile updated");$(".profile-picture","header").attr("src",n.ImageUrl+"?width=42");i=$("#NextAction",t).val();$.trim(i)==NextActionItems.AddComment?n.IsProfileComplete?($(".account-management").modal("hide"),postAuthentication.NextAction=i,GetCommentEditor()):r.text("Your profile has been updated. However since it is not complete you won't be able to post comments."):(u=$(".replaceable-comment-editor"),u.length>0&&GetCommentEditor())}function EditProfileFailure(n){LoginFailure(n)}function ChangePasswordSuccess(){var n=$(".account-management"),t=$("#message",n),i=$("#progress",n);t.text("Your password has been changed.");$(".modal-body-controls",n).hide();$("h1",n).text("Password changed");$("input[type='submit']",n).hide()}function ChangePasswordFailure(n){LoginFailure(n)}function EmailConfirmationSuccess(n,t){var i=$(".account-management"),r=$("#Email",i);r.val(n);$("#message",i).text(t);$("#createAccountLink",i).hide();i.on("shown.bs.modal",function(){r.length!==0&&r.val().trim()!==""&&setTimeout(function(){r.blur();$("#Password",i).focus()},50)});i.modal("show")}function EmailConfirmationFailure(n){var i=$(".account-management"),t=$("#message",i);t.text(n);t.closest(".form-group").addClass("error");$(".account-management").modal("show")}function InitFileUpload(n){$("#profilepicture").fileupload().on("fileuploadsubmit",function(t,i){var r=$("#message",$(".edit-profile-modal")),u=!0,f=i.files[0],o=new RegExp(".("+n+")","i"),e;return o.test(f.name)||(r.text("Please only select an image file. Allowed extensions include: "+n.split("|").join(", ")),r.closest(".form-group").addClass("error"),u=!1),u&&f.size>2e6&&(r.text("Please upload a smaller image, max allowed size is 2 MB"),r.closest(".form-group").addClass("error"),u=!1),u==!0?(r=$("#message",$(".edit-profile-modal")),e=$("#progress",$(".edit-profile-modal")),r.closest(".form-group").removeClass("error"),r.text(""),e.show(),!0):!1}).on("fileuploadalways",function(n,t){var i=t.result,r=$("#message",$(".edit-profile-modal")),u=$("#progress",$(".edit-profile-modal"));r.text("");u.hide();i.ErrorMessage==undefined||i.Succeeded==undefined||i.Succeeded===!1?(r.text(i.ErrorMessage),r.closest(".form-group").addClass("error")):i.Succeeded?($("#AvatarUrl").val("~"+i.ImageUrl),$(".profile-picture",$(".edit-profile-modal")).attr("src",i.ImageUrl+"?width=102")):(r.text(i.ErrorMessage),r.closest(".form-group").addClass("error"))})}function Share(n){var t=$("#frmShare");$("#surl").val(location.href);$("#c").val(n);try{$.ajax({type:t.attr("method"),url:t.attr("action"),data:t.serialize()}).always(function(n){ResponseContainsError(n)&&DebugAlert("Failed to log sharing request.")})}catch(i){DebugAlert("Failed to log sharing request. Error Details: "+i.message)}return!0}function AddRemoveBookmark(n){if(!requestConfig.IsAuthenticated){$("#NextAction").val(NextActionItems.AddRemoveBookmark);$(".account-management").modal("show");return}var r=$(".bookmark-tag"),i=$(".bookmark",".bookmark-tag"),u=n===!0?!0:i.hasClass("not-bookmarked"),t=$("#frmAddRemoveBookmark");if(t.length==0){DebugAlert("Error - frmAddRemoveBookmark not found");return}$("#AddBookmark",t).val(u);$("#ContentIDToBookmark",t).val($("#content-id").val());try{$.ajax({type:t.attr("method"),url:t.attr("action"),async:!0,cache:!1,dataType:"json",data:t.serialize()}).always(function(n){ResponseContainsError(n)?alert("Sorry we are unable to save your Bookmark, please re-login and try it again."):u?(i.removeClass("not-bookmarked").addClass("bookmarked"),r.attr("title","Clear bookmark")):(i.removeClass("bookmarked").addClass("not-bookmarked"),r.attr("title","Bookmark this paper"))})}catch(f){alert("Sorry we are unable to update your Bookmark, please re-login and try it again.")}}function RemoveBookmark(n){var t=$("#frmRemoveBookmark");if(t.length==0){DebugAlert("Fix this frmRemoveBookmark not found.");return}$("#ContentIDToBookmark",t).val(n);$.ajax({type:t.attr("method"),url:t.attr("action"),async:!0,cache:!1,dataType:"json",data:t.serialize()}).always(function(t){ManageBookmarkResponse(t,null,function(){$("li[data-content-id="+n+"]",".bookmark-list").remove();UpdateNoBookmarksMessageVisibility();UpdateBookmarksOrderNumber()})})}function UpdateBookmarkOrderID(){var n=$("#frmManageBookmarks");$.ajax({type:n.attr("method"),url:n.attr("action"),async:!0,cache:!1,dataType:"json",data:n.serialize()}).always(function(n){ManageBookmarkResponse(n,null,function(){UpdateBookmarksOrderNumber()})})}function ClearAllBookmarks(){var t=confirm("This will clear all your bookmarks.\r\nProceed and clear all the bookmarks?"),n;t&&(n=$("#frmClearAllBookmarks"),$.ajax({type:n.attr("method"),url:n.attr("action"),async:!0,cache:!1,dataType:"json",data:n.serialize()}).always(function(n){ManageBookmarkResponse(n,null,function(){$("li",".bookmark-list").remove();UpdateNoBookmarksMessageVisibility();UpdateBookmarksOrderNumber()})}))}function UpdateNoBookmarksMessageVisibility(){var n=".bookmark-list",t=$("li",n).size();t==0?($(".no-bookmarks-message").show(),$("li",n).hide(),$("#btnClearAllBookmarks").hide()):t==1?($(".no-bookmarks-message").hide(),$(n).removeClass("bookmark-sortable").addClass("bookmark-non-sortable"),$("#btnClearAllBookmarks").show()):($("li",n).show(),$(".no-bookmarks-message").hide(),$(n).removeClass("bookmark-non-sortable").addClass("bookmark-sortable"),$("#btnClearAllBookmarks").show())}function UpdateBookmarksOrderNumber(){$(".bookmark_serial_number").each(function(n){var t=String(n+1);n<9&&(t="0"+(n+1));$(this).text(t)})}function ManageBookmarkResponse(n,t,i){if(ResponseContainsError(n)){$(".alert").removeClass("alert-success").addClass("alert-danger");n.ErrorMessage!=undefined?$(".alert").text(n.ErrorMessage):$(".alert").text("Sorry we are unable to update your bookmark, please re-login and try it again.");$(".alert").show();var r=$(".alert:visible").first(),u=r.offset().top-$("header").outerHeight(!0);$(window).scrollTop(u)}else t!=null&&$(".alert").addClass("alert-success").text(t),i!=undefined&&i()}function QuickAddRemoveBookmark(n,t){var i=parseInt(n,10);if(!requestConfig.IsAuthenticated){$("#NextAction").val(NextActionItems.AddRemoveBookmark);$("#NextActionValue").val(i);$(".account-management").modal("show");return}var f=$("#Bookmark_Tag_"+n),e=$(".bookmark",f),u=t===!0?!0:e.hasClass("not-bookmarked"),r=$("#frmAddRemoveBookmark");if(r.length==0){DebugAlert("Error - frmAddRemoveBookmark not found");return}$("#ContentIDToBookmark").val(i);$("#AddBookmark").val(u);$.ajax({type:r.attr("method"),url:r.attr("action"),async:!0,cache:!1,dataType:"json",data:r.serialize()}).always(function(t){if(ResponseContainsError(t))return alert("Sorry we are unable to save your Bookmark, please re-login and try it again."),!1;GetMyBookmarks();var r=ko.utils.arrayFirst(_model.Papers.Data(),function(t){return t.ContentID==n});if(r==null){DebugAlert("Fix this issue. Match was not found in Papers list.");return}u==!0?(r.BookmarkState("bookmarked"),_model.CurrentBookmarks.push(i)):(r.BookmarkState("not-bookmarked"),_model.CurrentBookmarks.remove(i))})}function GetMyBookmarks(){if(!requestConfig.IsAuthenticated){DebugAlert("Unauthorized user.");return}if(typeof _model.MyBookmarks!="undefined"){var n=$("#frmMyBookmarks");if(n.length==0){DebugAlert("Fix this frmMyBookmarks is not available.");return}$.ajax({type:n.attr("method"),url:n.attr("action"),async:!0,cache:!1,dataType:"json",data:n.serialize()}).always(function(n){UpdateModels(_model.MyBookmarks,n)})}}function UpdateBookmarkCSS(){if(!requestConfig.IsAuthenticated){DebugAlert("Unauthorized user.");return}var n=$("#frmBookmarkContentIDs");if(n.length==0){DebugAlert("Fix this frmBookmarkContentIDs is not available.");return}$.ajax({type:n.attr("method"),url:n.attr("action"),async:!0,cache:!1,dataType:"json",data:n.serialize()}).always(function(n){if(!ResponseContainsError(n)){var t=parseInt($("#content-id").val(),10);$.inArray(t,n.Data)!=-1&&($(".bookmark").removeClass("not-bookmarked").addClass("bookmarked"),$("bookmark-tag").attr({title:"Clear bookmark"}));postAuthentication.NextAction==NextActionItems.AddRemoveBookmark&&AddRemoveBookmark(!0)}})}function GetLatestBookmarks(){if(!requestConfig.IsAuthenticated){DebugAlert("Unauthorized user.");return}var n=$("#frmBookmarkContentIDs");if(n.length==0){DebugAlert("Fix this frmBookmarkContentIDs is not available.");return}$.ajax({type:n.attr("method"),url:n.attr("action"),async:!0,cache:!1,dataType:"json",data:n.serialize()}).always(function(n){ResponseContainsError(n)?DebugAlert("Failed to retrieve latest Bookmarks."):_model.CurrentBookmarks(n.Data)})}function ExpandMyBookmarks(){ExpandToggleControl("most_popular",!1);ExpandToggleControl("my_bookmarks",!0)}function ExpandToggleControl(n,t){var i=$("#"+n),r=i.next(".togglerow").is(":visible");t&&r==!1?i.trigger("click"):t==!1&&r==!0&&i.trigger("click")}function AddBookmarkIfRequested(){postAuthentication.NextAction==NextActionItems.AddRemoveBookmark&&$.trim(postAuthentication.NextActionValue)!=""&&QuickAddRemoveBookmark(parseInt(postAuthentication.NextActionValue,10),!0)}function GetCommentEditor(){var n=$("#frmPapers");if(n.length==0){DebugAlert("frmPapers not found.");return}$("#PaperContentID",n).val($("#content-id").val());$("#CHIReference",n).val($("#chireference-number").val());$(".replaceable-comment-editor").html("Please wait...");$.ajax({type:n.attr("method"),url:chiConfig.RootURL+"Contribution/CommentEditor",async:!0,cache:!1,data:n.serialize()}).always(function(n){if($(".replaceable-comment-editor").html(n),postAuthentication.NextAction==NextActionItems.AddComment){var t=CKEDITOR.instances[CommentSystem.EditorControlName];if(t)t.on("instanceReady",function(){CommentSystem.ShowCommentEditor()});else GetPartialForm("/Account/ModalEditProfile?NextAction="+NextActionItems.AddComment,"profile-management-content",!1)}})}function GetComments(){alert("You can't get comments now.");return}function VoteIfRequested(){(postAuthentication.NextAction==NextActionItems.UpVote||postAuthentication.NextAction==NextActionItems.DownVote)&&$.trim(postAuthentication.NextActionValue)!=""&&(postAuthentication.NextAction==NextActionItems.UpVote?CastVote(parseInt(postAuthentication.NextActionValue,10),!0,!0):CastVote(parseInt(postAuthentication.NextActionValue,10),!1,!0))}function Voting(n){var t=$(n),i=t.attr("data-comment-id"),r=t.attr("data-vote-action");if(requestConfig.IsAuthenticated)CastVote(parseInt(i,10),r==NextActionItems.UpVote);else{$("#NextAction").val(r);$("#NextActionValue").val(i);$(".account-management").modal("show");return}}function CastVote(n,t,i){var r=$("#frmPapers"),f,u,e;if(r.length==0){DebugAlert("frmPapers not found.");return}f=$("#CommentContentID",r);f.length==0?$("<input />",{type:"hidden",name:"CommentContentID",id:"CommentContentID",value:n}).appendTo(r):f.val(n);u=$("#VoteUp",r);u.length==0?$("<input/>",{type:"hidden",name:"VoteUp",id:"VoteUp",value:t}).appendTo(r):u.val(t);e=$("#IfPresentDontChange",r);u.length==0?$("<input/>",{type:"hidden",name:"IfPresentDontChange",id:"IfPresentDontChange",value:i||!1}).appendTo(r):e.val(i||!1);$.ajax({type:r.attr("method"),url:chiConfig.RootURL+"Contribution/CastVote",async:!0,cache:!1,data:r.serialize()}).always(function(t){var i,r;ResponseContainsError(t)?t.ErrorMessage!=undefined?alert(t.ErrorMessage):alert("Sorry we are not able to cast your vote."):($("#count_"+n).text(t.NewCount),i=$("#up_"+n),i.removeClass("vote-up voted-up"),r=$("#down_"+n),$("#down_"+n).removeClass("vote-down voted-down"),t.HasUpVoted==!0?(i.addClass("voted-up"),i.attr({title:"Remove your previous vote"}),r.addClass("vote-down"),r.attr({title:"Vote down the comment"})):t.HasUpVoted==!1?(i.addClass("vote-up"),i.attr({title:"Vote up the comment"}),r.addClass("voted-down"),r.attr({title:"Remove your previous vote"})):t.HasUpVoted==null&&(i.addClass("vote-up"),i.attr({title:"Vote up the comment"}),r.addClass("vote-down"),r.attr({title:"Vote down the comment"})))})}function ReplyCommentIfRequested(){postAuthentication.NextAction==NextActionItems.ReplyComment&&$.trim(postAuthentication.NextActionValue)!=""&&$("#"+postAuthentication.NextActionValue).trigger("click")}function JumpToComments(){var n=$(".affix-container"),t;$(".toggle",n).each(function(){var n=$(this).attr("id");n.toLowerCase()!="comments"?ExpandToggleControl(n,!1):ExpandToggleControl(n,!0)});n.scrollTo("#comments",800,{offset:-20});t=$("#comments");t.focus()}function UpdateDebugValues(){if(chiConfig.Debug){var n=$("#debug_only");$("#debug_only").find(":not(.permanent)").remove();n.append($(".debug-only"));$("#hide_debug_only",n).on("click",function(){n.hide()})}}function ChangeExandCollapseText(){}function endsWith(n,t){return n.indexOf(t,n.length-t.length)!==-1}function replaceURLWithHTMLLinks(n){var t=/(\b(((https?):\/\/)|(www\.))[-A-Z0-9+&@@#\/%?=~_|!:,.;\)\(]*[-A-Z0-9+&@@#\/%&#8204;&#8203;=~_|])/ig,i=n.search(t);return n.replace(t,function(t){var i=t;return t.toLocaleLowerCase().substr(0,3)=="www"&&(i="http://"+t),n.toLocaleLowerCase().indexOf(t.toLocaleLowerCase()+"<\/a>")>-1?t:t.toLocaleLowerCase().indexOf("https://doi.org/10.14796/jwmm")>-1?t:"<a href='"+i+"' rel='nofollow' data-rel='auto' target='_blank'>"+t+"<\/a>"})}function PostAuthentication(){this.Actions=[];this.NextAction="";this.NextActionValue=-1}function InitPaper(){InitPaperList();_model=$.extend(_model,{Files:$.extend(new BaseModel(FileModel,"Please wait while we retrieve file list"),{ToggleControlName:"additional_data"})});_model=$.extend(_model,{Tags:$.extend(new BaseModel(TagModel,"Please wait while we retrieve tags"),{ToggleControlName:"tags"})});$(document).ready(function(){$(".table-hover").css({width:"100%"});UpateReferenceList();UpdateH2();CreateCollapsibleSections(!1);RegisterToggleControls();UpdatePaperTables();$("#bodycontent").css("min-height",566);$(".toggle").each(function(){UpdateVisibility($(this))});RegisterExpandCollapseAll("#toggleVisibility, #toggleAllSections, #toggleSideBarComponenetsVisibility");$(window).scroll(ResizeAffixControlsBecauseOfScrolling);$(".bookmark-tag").on("click",AddRemoveBookmark);$(".togglerow","#papercontent").css({"padding-bottom":"20px"});postAuthentication.Actions.push(UpdateBookmarkCSS);postAuthentication.Actions.push(GetCommentEditor);postAuthentication.Actions.push(VoteIfRequested);postAuthentication.Actions.push(ReplyCommentIfRequested);requestConfig.IsAuthenticated&&UpdateBookmarkCSS();$(".comment-count-link").click(JumpToComments);EnlargeHelper.Initialize();EnlargeHelper.MakeImagesEnlargable({imageSelector:"img:not([data-mathml]):not(.img-placeholder):not(.pdficon)",context:"#papercontent"});EnlargeHelper.MakeTablesEnlargable({containerSelector:".table-container",context:"#papercontent"})})}function InitPaperList(){_model=$.extend(_model,{Papers:$.extend(new BaseModel(PaperModel,"Please wait while we retrieve papers"),{ToggleControlName:"related_papers"}),HYDRO:$.extend(new BaseModel(PaperModel,"Please wait while we retrieve papers"),{ToggleControlName:"related_papers"}),SCNSU:$.extend(new BaseModel(PaperModel,"Please wait while we retrieve papers"),{ToggleControlName:"related_papers"}),ETHIOPIA:$.extend(new BaseModel(PaperModel,"Please wait while we retrieve papers"),{ToggleControlName:"related_papers"}),AWaRe:$.extend(new BaseModel(PaperModel,"Please wait while we retrieve papers"),{ToggleControlName:"related_papers"})})}function InitEditPaperAuthors(){_model=$.extend(_model,{PaperAuthors:$.extend(new BaseModel(PaperAuthorModel,"Please wait"),{AuthorsMasterData:ko.observableArray([])},{PendingPapersCount:ko.observable()},{NumberOfSelectedRecords:ko.observable()},{TotalPapersCount:ko.observable()},{CurrentPage:ko.observable(1)})});_model.PaperAuthors.NumberOfSelectedRecords=ko.computed(function(){for(var t=0,n=0;n<_model.PaperAuthors.Data().length;n++)_model.PaperAuthors.Data()[n].Save()==!0&&t++;return t++},this);_model.PaperAuthors.DataBlockLoaded=function(){$(".authorwithaffiliation").each(function(){$(this).select2()})};$(document).ready(function(){function n(n,t,i,r,u){this.CompleteName=ko.observable(n);this.Company=ko.observable(i);this.AID=ko.observable(t);this.CRMContactID=ko.observable(r);this.AuthorAffiliationID=ko.observable(u)}GetPaperAuthors();$("#reload,#showall").click(function(n){if(_model.PaperAuthors.NumberOfSelectedRecords()!=0){var t=confirm("You have not saved your changes. All your changes will be lost. Press OK Continue?");if(!t)return n.preventDefault()}GetPaperAuthors()});$("#save").click(function(){SavePaperAuthorsMapping()});$("#pagesize,#currentpage").change(function(n){if(_model.PaperAuthors.NumberOfSelectedRecords()!=0){var t=confirm("You have not saved your changes. All your changes will be lost. Press OK Continue?");if(!t)return n.preventDefault()}GetPaperAuthors()});var t=ko.utils.arrayMap(authorsMasterData,function(t){return new n(t.CompleteName,t.AID,t.Company,t.CRMContactID,t.AuthorAffiliationID)});_model.PaperAuthors.AuthorsMasterData(t)})}function InitAuthorManagment(n){_model=$.extend(_model,{AuthorMangement:new BaseModel(AuthorMangementModel,"Please wait")});_model.AuthorMangement.Data=ko.observable(new AuthorMangementModel);_model.AuthorMangement.ShowProgressBar(!1);$(document).ready(function(){$("#Save").click(function(){SaveAuthorManagment()});$("#Clear").click(function(){$(".typeahead").val("");var n=_model.AuthorMangement.Data();n.ID("");n.FirstName("");n.LastName("");n.Email("");n.ContactID("");n.Affiliations([])});_typeaheadSuggestionEngine=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("FirstName"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:chiConfig.RootURL+n,limit:200});_typeaheadSuggestionEngine.initialize();var t="<div>\n Apologies but we are not able to find any records matching your search criteria.\n<\/div>",i=Handlebars.compile("<p>{{FirstName}} {{LastName}}<\/p>");$(".typeahead").typeahead({hint:!0,highlight:!0,minLength:2},{name:"_typeaheadSuggestionEngine",displayKey:"FirstName",source:_typeaheadSuggestionEngine.ttAdapter(),templates:{empty:t,suggestion:i}}).on("typeahead:selected",function(n,t){var i=_model.AuthorMangement.Data();i.ID(t.ID);i.FirstName(t.FirstName);i.LastName(t.LastName);i.Email(t.Email);i.ContactID(t.ContactID);i.Affiliations(ko.utils.arrayMap(t.Affiliations,function(n){return new AuthorAffiliation(n.ID,n.Company,n.City,n.Region,n.Country)}));$("#Save").focus()}).on("typeahead:opened",function(){});$(".typeahead").focus()})}function InitAdvancedSearch(n){InitPaperList();_model=$.extend(_model,{AdvancedSearchParameters:new AdvancedSearchParameters});ExtendModelAddCurrentBookmarks();$(document).ready(function(){_typeaheadSuggestionEngine=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("T"),queryTokenizer:Bloodhound.tokenizers.whitespace,prefetch:chiConfig.RootURL+"scripts/json/"+n,remote:chiConfig.RootURL+"Home/SearchHints?query=%QUERY",dupDetector:function(n,t){return n.T===t.T},limit:chiConfig.Debug?10:10});_typeaheadSuggestionEngine.initialize();$(".typeahead").typeahead({hint:!0,highlight:!0,minLength:2},{name:"_typeaheadSuggestionEngine",displayKey:"T",source:_typeaheadSuggestionEngine.ttAdapter()}).on("typeahead:cursorchanged",function(n,t){AdvancedSearchParametersChanged(t)}).on("typeahead:selected",function(n,t){AdvancedSearchParametersChanged(t)}).on("typeahead:autocompleted",function(n,t){AdvancedSearchParametersChanged(t)}).on("typeahead:opened",function(){});$("input[name~='subject']").click(function(){SubmitAdvancedSearch()});$("#Paperspublishedin").change(function(){SubmitAdvancedSearch()});$("#PapersauthorIs").change(function(){SubmitAdvancedSearch()});$("#publishedin").change(function(){var e=document.getElementById("query"),n,i,t,u,f,r;g=document.createElement("input");g.setAttribute("id","fullquery");n=e.value;n===undefined&&(n="*");i=$("#authorIs option:selected").val();t=$("#publishedin option:selected").text();t!="Any Year"&&(u=" before:"+t+"-12-31",f=" after:"+t+"-01-01",n+=f+" "+u);i!="Any"&&(n+=' "'+i+'"');g.setAttribute("value",n);r=google.search.cse.element.getElement("searchresults-only0");g.value==""?r.execute("*"):r.execute(g.value)});$("#authorIs").change(function(){var e=document.getElementById("query"),n,i,t,u,f,r;g=document.createElement("input");g.setAttribute("id","fullquery");n=e.value;n===undefined&&(n="*");i=$("#authorIs option:selected").val();t=$("#publishedin option:selected").text();t!="Any Year"&&(u=" before:"+t+"-12-31",f=" after:"+t+"-01-01",n+=f+" "+u);i!="Any"&&(n+=' "'+i+'"');g.setAttribute("value",n);r=google.search.cse.element.getElement("searchresults-only0");g.value==""?r.execute("*"):r.execute(g.value)});$("#fromCHIJournal").submit(function(n){var o=document.getElementById("query"),t,r,i,f,e,u;return g=document.createElement("input"),g.setAttribute("id","fullquery"),t=o.value,t===undefined&&(t="*"),r=$("#authorIs option:selected").val(),i=$("#publishedin option:selected").text(),i!="Any Year"&&(f="before:"+i+"-12-31",e="after:"+i+"-01-01",t+=e+" "+f),r!="Any"&&(t+=' "'+r+'"'),g.setAttribute("value",t),u=google.search.cse.element.getElement("searchresults-only0"),g.value==""?u.execute("*"):u.execute(g.value),n.preventDefault()});$(".table-hover").css({width:"100%"});postAuthentication.Actions.push(GetLatestBookmarks);postAuthentication.Actions.push(AddBookmarkIfRequested);requestConfig.IsAuthenticated&&GetLatestBookmarks()})}function InitHome(n){InitPaperList();_model=$.extend(_model,{MyBookmarks:new BaseModel(ContactBookmarks,"Please wait while we retrieve bookmarks")});ExtendModelAddCurrentBookmarks();$(document).ready(function(){_typeaheadSuggestionEngine=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("T"),queryTokenizer:Bloodhound.tokenizers.whitespace,prefetch:chiConfig.RootURL+"scripts/json/"+n,remote:chiConfig.RootURL+"Home/SearchHints?query=%QUERY",dupDetector:function(n,t){return n.T===t.T},limit:10});_typeaheadSuggestionEngine.initialize();$(".typeahead").typeahead({hint:!0,highlight:!0,minLength:2},{name:"_typeaheadSuggestionEngine",displayKey:"T",source:_typeaheadSuggestionEngine.ttAdapter()}).on("typeahead:cursorchanged",function(){$("#go").trigger("click","Hint")}).on("typeahead:selected",function(){$("#go").trigger("click","Hint")}).on("typeahead:autocompleted",function(){$("#go").trigger("click","Hint")});$("#go").click(function(n,t){var r=t||"Home",u=escape($("#query").val()),i;chiConfig.Debug&&$(this).attr("href",chiConfig.RootURL+"Home/AdvancedSearch");i=$(this).attr("href")+"/?query="+u+"&source="+r;r=="Home"?$(this).attr("href",i):window.location.href=i});$(".table-hover").css({width:"100%"});$("#bodycontent").css({"margin-top":0});RegisterToggleControls();postAuthentication.Actions.push(GetLatestBookmarks);postAuthentication.Actions.push(GetMyBookmarks);postAuthentication.Actions.push(AddBookmarkIfRequested);requestConfig.IsAuthenticated&&(GetLatestBookmarks(),GetMyBookmarks())})}function InitAbout(){$(document).ready(function(){CreateCollapsibleSections();RegisterToggleControls();RegisterExpandCollapseAll("#toggleAll");AboutCreateNavigationLinks();$(".next-conference-box").css("width","100%");$(".bs-affix").affix({offset:{top:function(){return this.top=$("header").outerHeight(!0)+$(".next-conference-box").outerHeight(!0)},bottom:function(){return this.bottom=$("footer").outerHeight(!0)}}});requestConfig.IsMobile&&$(window).width()<chiConfig.SCREEN_SM_MAX&&$("#toggleAll").trigger("click")})}function InitForAuthors(){$(document).ready(function(){CreateCollapsibleSections();RegisterToggleControls();RegisterExpandCollapseAll("#toggleAll");AboutCreateNavigationLinks();$(".next-conference-box").css("width","100%");$(".bs-affix").affix({offset:{top:function(){return this.top=$("header").outerHeight(!0)+$(".next-conference-box").outerHeight(!0)},bottom:function(){return this.bottom=$("footer").outerHeight(!0)}}});requestConfig.IsMobile&&$(window).width()<chiConfig.SCREEN_SM_MAX&&$("#toggleAll").trigger("click")})}function InitForReviewers(){$(document).ready(function(){CreateCollapsibleSections();RegisterToggleControls();RegisterExpandCollapseAll("#toggleAll");AboutCreateNavigationLinks();$(".bs-affix").affix({offset:{top:function(){return this.top=$("header").outerHeight(!0)},bottom:function(){return this.bottom=$("footer").outerHeight(!0)}}});requestConfig.IsMobile&&$(window).width()<chiConfig.SCREEN_SM_MAX&&$("#toggleAll").trigger("click")})}function InitEditProfile(n,t){var i="has-error";$("form").submit(function(){if($(this).valid()){var n=$("#Region").val();n.trim()==""&&$("#Region").closest("div.form-group").addClass(i);$(this).find("div.form-group").each(function(){$(this).find(".field-validation-error").length==0&&$(this).removeClass(i)})}else $(this).find("div.form-group").each(function(){$(this).find(".field-validation-error").length>0&&$(this).addClass(i)})});$(document).ready(function(){$("form").addTriggersToJqueryValidate().triggerElementValidationsOnFormValidation();$("input, select, textarea").elementValidation(function(n,t){if(LogMessage("validation ran for form:"+n.id+" and the result was:"+t),t==!0){var r=$(n).closest("."+i);r.length!=0&&r.removeClass(i)}});$("#Country").on("change",populateState);initCountry(n,t)})}function InitAccountManagement(n,t){var r="has-error",u=$("#frmModalLogin"),i=$(".account-management");u.length==1&&$("#frmModalLogin").attr("action",$("#loginFrame").attr("src"));$("form",i).submit(function(u){var e;if($(this).valid()){$(this).find("div.form-group").each(function(){$(this).find(".field-validation-error").length==0&&$(this).removeClass(r)});var f=$(this),o=$("#message",i),s=$("#progress",i);o.closest(".form-group").removeClass("error");o.text("");s.show();e=$("#Fragment",i);e.length!=0&&e.val(location.hash.substring(1));$('input[type="submit"]',i).attr("disabled","disabled");var h=$(this).attr("id"),c="frmModalLogin",l=f.attr("action");h==c&&(l=f.attr("dataaction"));$.ajax({type:f.attr("method"),url:l,data:f.serialize()}).always(function(r){s.hide();$('input[type="submit"]',i).removeAttr("disabled");var u=$(".modal-close");u.length>0&&u.show();typeof r.ErrorMessage=="undefined"||typeof r.Succeeded=="undefined"?t(r):r.Succeeded?n(r):t(r)});h!=c&&u.preventDefault()}else $(this).find("div.form-group").each(function(){$(this).find(".field-validation-error").length>0&&$(this).addClass(r)})});$(document).ready(function(){var t=$("form",i),n;$.validator.unobtrusive.parse(t);$(t).addTriggersToJqueryValidate().triggerElementValidationsOnFormValidation();$("input, select, textarea",i).elementValidation(function(n,t){if(t==!0){var i=$(n).closest("."+r);i.length!=0&&i.removeClass(r)}});try{$("input, textarea").placeholder()}catch(u){}if(n=$(".modal-close"),n.length>0){n.on("click",function(){$(".modal").modal("hide")});n.hide()}})}function InitModalEditProfile(n){$(document).ready(function(){InitFileUpload(n);$("#frmEditProfile").keypress(function(n){LogMessage(n.keyCode);n.keyCode===13&&($("#btnSave").click(),n.preventDefault())});$("#btnUploadPicture").on("click",function(n){$("#profilepicture").click();n.preventDefault()});var t=$(".edit-profile-modal").closest(".account-management");t.on("show.bs.modal",function(){var n=$(this).find(".profile-management-modal-dialog");n.addClass("modal-lg");n.css({"margin-top":"7%"})});t.on("hidden.bs.modal",function(){var n=$(this).find(".profile-management-modal-dialog");n.removeClass("modal-lg");n.css({"margin-top":null});$(this).off("hidden.bs.modal");$(this).off("show.bs.modal")})})}function InitChangePassword(){$(document).ready(function(){var n=$(".change-password-modal").closest(".account-management");n.find(".profile-management-modal-dialog").removeClass("modal-lg").css({"margin-top":""})})}function InitBookmarks(){$(document).ready(function(){requestConfig.IsMobile||$("ol.bookmark-sortable").sortable({placeholder:"ui-state-highlight",update:function(){var n=$(this).sortable("toArray",{attribute:"data-bookmark-id"});$("#bookmarkIDs").val(n.join(","));UpdateBookmarkOrderID()}});$(".alert").hide();$(".table-hover").css({width:"100%"});UpdateNoBookmarksMessageVisibility();$("#btnClearAllBookmarks").click(ClearAllBookmarks)})}function ExtendModelAddCurrentBookmarks(){_model=$.extend(_model,{CurrentBookmarks:ko.observableArray([])});_model.CurrentBookmarks.subscribe(function(n){var t;if(_model.Papers.Data().length!=0)for(t=0;t<n.length;t++){var u=n[t].value,r=n[t].status,i=ko.utils.arrayFirst(_model.Papers.Data(),function(n){return n.ContentID==u});i!=null&&r=="added"?i.BookmarkState("bookmarked"):i!=null&&r=="deleted"&&i.BookmarkState("not-bookmarked")}},null,"arrayChange")}function InitPlaceHolder(){$("input, textarea").placeholder()}function ShowPasswordClick(){$(".show-password").on("click",function(){try{var n=["password","text"],t=$(this),i=t.is(":checked"),r=i?n[0]:n[1],u=i?n[1]:n[0],f=t.closest(".form-group").find("input[type='"+r+"']");f.attr({type:u,autocomplete:"off"})}catch(e){alert("Browser has rejected request to show password.")}})}var HeaderHelperSupplement;String.prototype.format=function(){var n=arguments;return this.replace(/\{(\d+)\}/g,function(t,i){return n[i]})};NextActionItems.AddRemoveBookmark="FE0D1DAF";NextActionItems.UpVote="5B7A8944";NextActionItems.DownVote="1C47E72F";NextActionItems.AddComment="8DC9E14C";NextActionItems.ReplyComment="369437D1";AJAXResponse=function(){};AJAXResponse.ContainsError=function(n){return n.responseJSON==undefined||n.responseJSON.HasError==!0};AJAXResponse.DispalyError=function(n,t){if(AJAXResponse.ContainsError(n)){var i=n.responseJSON!==undefined?n.responseJSON.ErrorMessage:"";i!=undefined&&(i+"").trim()!==""?alert(i):alert(t)}};HeaderHelperSupplement=function(){return{Initialize:function(){$(document).on("headerhelper.initialize",function(){var n=$("#subheader"),t;n.length===1&&(t=$("#bodycontent"),t.css({"margin-top":18+n.height()+12}))});HeaderHelper.Initialize()}}}();$(document).ready(function(){var i=$("h2:contains('References')").next("ol").find("li"),r;i!=null&&(r=new Autolinker({urls:{schemeMatches:!0,wwwMatches:!0,tldMatches:!0},email:!1,phone:!1,mention:!1,hashtag:!1,stripPrefix:!1,newWindow:!0,truncate:{length:0,location:"end"},className:"",replaceFn:function(n){switch(n.getType()){case"url":return n.matchedText.toLowerCase()==="m.sc"?!1:(console.log("url: ",n.getUrl()+" --> "+n.matchedText),!0);case"email":case"phone":case"mention":case"hashtag":default:return}}}),i.each(function(n,t){var o=$(this).html(),s=[],h=0,u,i,c;o=o.replace(/https?:\/\/[^\s&]*(?:&[^;]+;[^\s&]*)*/g,function(n){if(n.includes("&lt;")||n.includes("&gt;")||n.includes("&amp;")||n.includes("&")){var t=`__URL_PLACEHOLDER_${h}__`,i=`<a href="${n}" target="_blank">${n}</a>`;return s.push({placeholder:t,replacement:i}),h++,t}return n});u=r.link(o);s.forEach(function(n){u=u.replace(n.placeholder,n.replacement)});$(this).html(u);$(this).attr("id",parseInt(n)+1);var i=t.innerText,f="10.14796/JWMM.",e=i.indexOf(f);e>0&&i.substring(e-1,e)!=="/"&&(i=i.substring(e+f.length).trim(),i.endsWith(".")&&(i=i.substring(0,i.length-1)),c=$(this).html().replace(f+i,"<a target='_blank' href='https://doi.org/10.14796/JWMM."+i+"'>"+f+i+"<\/a>"),$(this).html(c))}));$(".reference").each(function(){var n=$(this).attr("rel"),t;n!=undefined&&n.trim()!=""&&(n.substring(0,1)!="#"&&$(this).attr("rel","#"+n),t=$(this).attr("href"),t==="#"&&$(this).removeAttr("href"))});var n=$(window).width()<=chiConfig.SCREEN_XS_MAX,t=(n?$(window).width()-30:450)+"px",u=n?"bottom":"",f=n?"Close":"",e=$("header").outerHeight(!0)+"px",o=n?"10px":"0px";$(".reference").cluetip({local:!0,hideLocal:!1,cluetipClass:"jtip",cursor:"pointer",showTitle:!1,width:t,arrows:!n,sticky:!0,topOffSet:e,positionBy:n?"bottomTop":"topBottom",snapToEdge:!0,mouseOutClose:"both",dropShadow:!0,closePosition:u,closeText:f,leftOffset:o,onShow:function(t){if(n){var i=parseInt($(t).css("left"),10);i<=10&&$(t).css("left",10)}}});t=n?290:392;$(".some-rights-reserved").cluetip({local:!0,hideLocal:!0,cluetipClass:"jtip",cursor:"pointer",showTitle:!1,width:t,arrows:!1,sticky:!0,topOffSet:e,positionBy:"topBottom",snapToEdge:!0,mouseOutClose:"both",dropShadow:!0,closePosition:u,closeText:f})});PostAuthentication.prototype.Execute=function(){requestConfig.IsAuthenticated=!0;_model.IsAuthenticated(!0);var n=this;$.ajax({type:"GET",url:chiConfig.RootURL+"Manage/Header",async:!0,cache:!1}).always(function(t){$("header").replaceWith(t);for(var i=0;i<n.Actions.length;i++)n.Actions[i](n)})};var _model=new ViewModel,_typeaheadSuggestionEngine,postAuthentication=new PostAuthentication,iPad=1;$(document).ready(function(){$("#bodycontent, #carouselcontent").show();chiConfig.Debug||($.cookie.defaults.secure=!0);ko.applyBindings(_model);var n=$(".socialmediasharing").clone();n.length>0&&($("ul[aria-labelledby='smallMenu']").insertAt(0,$("<li />",{role:"presentation","class":"divider"})),$("ul[aria-labelledby='smallMenu']").insertAt(0,$("<li />",{role:"presentation"}).append(n)));$(window).on("resize",ResizeSubMenu).resize();HeaderHelperSupplement.Initialize();_model.IsAuthenticated(requestConfig.IsAuthenticated)});jQuery.fn.insertAt=function(n,t){var i=this.children().size();return n<0&&(n=Math.max(0,i+1+n)),this.append(t),n<i&&this.children().eq(n).before(this.children().last()),this}