var minCharCount = 2; var requestStack = []; var timer = null; jQuery(document).ready(function() { $(txtSearchID).onkeyup = function() { if (timer) window.clearTimeout(timer); timer = window.setTimeout(function() { var query = $(txtSearchID).value; if (query.length >= minCharCount) { executeSearch(query); } else { $("search_overlay").style.visibility = "hidden"; } }, 500); } }); function executeSearch(query) { BeWell.Web.Services.PoxSearchService.IsQueryMatch(query, onSuccess, onFailure); } function onSuccess(result, userContext, methodName) { if (result == true) { BeWell.Web.Services.PoxSearchService.ExecuteSearch($(txtSearchID).value, onSearchSuccess, onSearchFailure); } } function onFailure(exception, userContext, methodName) { } function onSearchSuccess(result, userContext, methodName) { if (result.ContentResults.length > 0) { jQuery("#search_overlay #search_experts_content").html(""); jQuery("#search_overlay #search_articles_content").html(""); jQuery("#search_overlay #search_blogs_content").html(""); jQuery("#search_overlay #search_forums_content").html(""); jQuery("#search_overlay #search_asktheexpert_content").html(""); jQuery("#search_overlay #search_books_content").html(""); jQuery("#search_overlay #search_videos_content").html(""); var x = 0; for (x = 0; x < result.ExpertResults.length; x++) { var line = String.format("{1}" + " {1}
", getExpertNameSeoPath(result.ExpertResults[x].UserID), result.ExpertResults[x].DisplayName, result.ExpertResults[x].Avatar); jQuery("#search_overlay #search_experts_content").append(line); } var articleFound = false; var blogFound = false; var conversationFound = false; x = 0; for (x = 0; x < result.ContentResults.length; x++) { var link = result.ContentResults[x].QuickLink; var fullTitle = result.ContentResults[x].Title; var shortTitle = result.ContentResults[x].AbridgedTitle; var itemType = result.ContentResults[x].ItemType; var line = String.format("{2}
", link, fullTitle, shortTitle); if (itemType == 0) { jQuery("#search_overlay #search_articles_content").append(line); articleFound = true; } else if (itemType == 1) { jQuery("#search_overlay #search_blogs_content").append(line); blogFound = true; } else if (itemType == 2) { jQuery("#search_overlay #search_forums_content").append(line); conversationFound = true; } } var notFoundTemplate = "No {0} found."; var notFoundLine = ""; if (result.ExpertResults.length == 0) { notFoundLine = String.format(notFoundTemplate, "expert(s)"); jQuery("#search_overlay #search_experts_content").append(notFoundLine); } if (!articleFound) { notFoundLine = String.format(notFoundTemplate, "article"); jQuery("#search_overlay #search_articles_content").append(notFoundLine); } if (!blogFound) { notFoundLine = String.format(notFoundTemplate, "blog"); jQuery("#search_overlay #search_blogs_content").append(notFoundLine); } if (!conversationFound) { notFoundLine = String.format(notFoundTemplate, "conversation"); jQuery("#search_overlay #search_forums_content").append(notFoundLine); } } if (result.IsDirectMatch == true) { $("search_footer").style.visibility = "visible"; } else { $("search_footer").style.visibility = "hidden"; } $("search_overlay").style.visibility = "visible"; } function onSearchFailure(exception, userContext, methodName) { } function getExpertNameSeoPath(userID) { var expertNameSeoPath = ""; switch (userID) { case 98: expertNameSeoPath = "Alice-D-Domar"; break; case 964: expertNameSeoPath = "Byllye-Y-Avery"; break; case 1172: expertNameSeoPath = "Christina-Economos"; break; case 1108: expertNameSeoPath = "David-Nash"; break; case 970: expertNameSeoPath = "Darshak-Sanghavi"; break; case 972: expertNameSeoPath = "M-Ellen-Mahoney"; break; case 756: expertNameSeoPath = "Hope-A-Ricciotti"; break; case 1026: expertNameSeoPath = "Joann-E-Manson"; break; case 988: expertNameSeoPath = "Jeri-Sedlar"; break; case 100: expertNameSeoPath = "Janet-E-Taylor"; break; case 974: expertNameSeoPath = "Laura-A-Jana"; break; case 976: expertNameSeoPath = "Loretta-Laroche"; break; case 15318: expertNameSeoPath = "Lynne-Perry-Bottinger"; break; case 110: expertNameSeoPath = "Marianne-J-Legato"; break; case 978: expertNameSeoPath = "Merville-C-Marshall"; break; case 102: expertNameSeoPath = "Miriam-E-Nelson"; break; case 984: expertNameSeoPath = "P-Michael-Peterson"; break; case 38: expertNameSeoPath = "Nancy-L-Snyderman"; break; case 104: expertNameSeoPath = "Pepper-Schwartz"; break; case 728: expertNameSeoPath = "Robert-Abel-Jr"; break; case 40: expertNameSeoPath = "Susan-M-Love"; break; case 980: expertNameSeoPath = "Saralyn-Mark"; break; case 16074: expertNameSeoPath = "Susan-Taylor"; break; case 982: expertNameSeoPath = "Susan-L-Troyan"; break; case 17232: expertNameSeoPath = "Lawrence-D-Lampert"; break; case 17596: expertNameSeoPath = "Teena-Cahill"; break; case 15778: expertNameSeoPath = "Paul-Offit"; break; } return expertNameSeoPath; }