usingNamespace("Biz.Search")["AutoFilledKeywordsNew"] = {IframeKeyWordsEnable: null,json: null,xml: null,index: 0,key: "",nValue: 0,keywordsUrl: "Common/Ajax/AutoFilledKeywordsNew.aspx",keywordsCount: 0,brandsCount: 0,isKeywordBox: true,idstr: "line",lastIdStr: "line",enablelffunction: false,searchKeyword: "",adobeSentFlag:false,cmCached: {},url: function () {var afk = Biz.Search.AutoFilledKeywordsNew;var p = afk.keywordsUrl;var loc = document.location.toString().toLowerCase();switch (Web.Environment.Protocol()) {case Web.Enum.Protocol.http:if (loc.indexOf("secure") == -1) {return Web.UI.ResourceManager.Url.www(p);} else {return Web.UI.ResourceManager.Url.shopper(p);};case Web.Enum.Protocol.https:if (loc.indexOf("www") > -1) {return Web.UI.ResourceManager.Url.www(p);} else {return Web.UI.ResourceManager.Url.secure(p);}default:return p;};},clear: function () {var afk = Biz.Search.AutoFilledKeywordsNew;afk.abort();var o = Newegg$("autofilledview");if (o) {Web.UI.Control.replaceInnerHTML(o, "");afk.hide();};afk.index = 0;},abort: function () {var afk = Biz.Search.AutoFilledKeywordsNew;if (afk.xml) {afk.xml.abort();};},fill: function (data, status, key) {var $ = Newegg$;if (status) {var afk = Biz.Search.AutoFilledKeywordsNew;var o = $("autofilledview");if (data != null) {if (o && data != '') {if (key == $("haQuickSearchBox")["value"]) {Web.UI.Control.replaceInnerHTML(o, data);afk.show();afk.getLineCount();if (Biz.Search.AutoFilledKeywordsNew.CoremetricData) {afk.cmImpression(key, Biz.Search.AutoFilledKeywordsNew.CoremetricData);}}} else {afk.hide();};} else {afk.hide();};};},cmImpression: function (key, cmData) {if (cmData && !this.cmCached[key]) {var dataList = cmData.dataList;for (var j = 0; j < dataList.length; j++) {if (Web.Config.CoreMetrics && Web.Config.CoreMetrics.Enable) {cmCreateCustomTag("8888", dataList[j].cMData.replace("#DATE#", new Date().toISOString()));}if (Web.Config.SiteCatalyst && Web.Config.SiteCatalyst.Enable) {Biz.Common.SiteCatalyst.sendToCache({ 'list1': dataList[j].cMData.replace("#DATE#", new Date().toISOString()) });}}this.cmCached[key] = 1;Biz.Common.SiteCatalyst.sendCache("list1", "dynamic recommendation click");}},show: function () {var $ = Newegg$;var wuc = Web.UI.Control;var ov = $("autofilledview");wuc.setAttribute(ov, { "style.display": "block" });if (Web.Environment.Browser.isIE()) {var f = $("commonIframe");if (f) {wuc.setAttribute(f, { "style.zIndex": "100" });wuc.setAttribute(f, { "style.top": ov.offsetTop });wuc.setAttribute(f, { "style.left": ov.offsetLeft });wuc.setAttribute(f, { "style.width": ov.offsetWidth });wuc.setAttribute(f, { "style.height": ov.offsetHeight });wuc.setAttribute(f, { "style.filter": "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" });wuc.setAttribute(f, { "style.position": "absolute" });wuc.setAttribute(f, { "style.display": "none" });};};var $self = jQuery('#haQuickSearchBox');var $menu = jQuery('#autofilledview');var inputW = $self.parents('.search-bar-inner').width();var menuW = $menu.width();if (inputW < menuW) {$menu.css({"left": "auto","right": "0"});} else {$menu.css({"left": "0","right": "auto"});}},hide: function (o) {var $ = Newegg$;var wuc = Web.UI.Control;wuc.setAttribute($("autofilledview"), { "style.display": "none" });wuc.setAttribute($("commonIframe"), { "style.display": "none" });},search: function () {var $ = Newegg$;var afk = Biz.Search.AutoFilledKeywordsNew;var lihover = jQuery("#autofilledtable").find(".lihover").first();if (lihover && !afk.adobeSentFlag) {lihover.trigger("onclick");}if (Biz.Common.QuickSearch.submitPagehHeader2011()) {if ($("BRID") && $("BRID")["value"] != null && $("BRID")["value"] != "") {window.location.href = Web.UI.ResourceManager.Url.www("Store/Brand.aspx") + "?Brand=" + $("BRID")["value"];} else {document.haFormQuickSearch.action = Web.UI.ResourceManager.Url.www("Product/ProductList.aspx");Web.UI.Form.submit("haFormQuickSearch");}}},highlight: function (id, lastId) {var afk = Biz.Search.AutoFilledKeywordsNew;var wuc = Web.UI.Control;if (id) {var o = $(afk.idstr + "html" + id);if (o) {jQuery(o).addClass("lihover");};};if (lastId) {if (afk.idstr != afk.lastIdStr || lastId != id) {var lasto = $(afk.lastIdStr + "html" + lastId);if (lasto) {jQuery(lasto).removeClass("lihover");};}};},autoCompleteKeywords: function () {var afk = Biz.Search.AutoFilledKeywordsNew;var o = window.event.srcElement;if (o) {if (o.nodeName == "SPAN") {o = o.parentNode;};if (o.className == "newline") {afk.lastIdStr = afk.idstr;if (o["id"].indexOf("brandline") > -1) {afk.isKeywordBox = false;afk.idstr = "brandline";} else {afk.isKeywordBox = true;afk.idstr = "line";}var lastId = afk.index;afk.index = o["id"].replace(/[a-z]/ig, "");afk.highlight(afk.index, lastId);} else if (o.className.indexOf("lihover") > -1) {afk.lastIdStr = afk.idstr;if (o["id"].indexOf("brandline") > -1) {afk.isKeywordBox = false;afk.idstr = "brandline";} else {afk.isKeywordBox = true;afk.idstr = "line";}var lastId = afk.index;afk.index = o["id"].replace(/[a-z]/ig, "");}};},isSearchScop: function () {var o = window.event.srcElement;if (o) {if (o.nodeName == "SPAN") {o = o.parentNode;};if (o.className == "newline" || o.className.indexOf("lihover") > -1) {return true;}}return false;},getIFrameEnable: function (enable) {IframeKeyWordsEnable = enable;},WWWQuery: function (key) {var $ = Newegg$;var afk = Biz.Search.AutoFilledKeywordsNew;var p = afk.keywordsUrl;var reqUrl = Web.Config.Environment.Url.Content + p;var n = -1;if ($("haQuickSearchStore") && $("haQuickSearchStore") != null) {n = $("haQuickSearchStore")["value"];}var name = Web.Config.SiteCookieInfo.bizUnit;var script = $("autoFillKeywordAjaxJs");if (script && script != null) {document.getElementsByTagName('head')[0].removeChild(script);}script = document.createElement("script");script.type = "text/javascript";script.id = 'autoFillKeywordAjaxJs';script.src = reqUrl + "?q=" + key + "&sType=Outer&n=" + n + "&name=" + name;document.getElementsByTagName('head')[0].appendChild(script);},setKeywords: function (index) {var $ = Newegg$;if (index > 0) {var afk = Biz.Search.AutoFilledKeywordsNew;var selectkeyword = $(afk.idstr + index).children[0].innerHTML.decodeHtml().trim();$("haQuickSearchBox")["value"] = selectkeyword;var cline = document.getElementById(afk.idstr + "html" + index);var taginputs = cline.getElementsByTagName("input");var cinput = null;var binput = null;if (taginputs != null && taginputs.length > 0) {var classvalue = taginputs[0].className;if (classvalue != null && classvalue.trim() == "brandid") {binput = taginputs[0];} else {cinput = taginputs[0];}}var n = cinput != null ? cinput.value : -1;var bid = binput != null ? binput.value : "";if ($("N") && $("N") != null) {$("N")["value"] = n;}if ($("BRID") && $("BRID") != null) {$("BRID")["value"] = bid;}}},query: function () {var $ = Newegg$;var afk = Biz.Search.AutoFilledKeywordsNew;var o = window.event.srcElement;var keyCode = window.event.keyCode;switch (keyCode) {case 13:break;case 27:afk.clear();break;case 35:if ($("autofilledview").innerHTML.length > 0 && afk.index > 0) {afk.highlight(null, afk.index);};break;case 36:if ($("autofilledview").innerHTML.length > 0 && afk.index > 0) {afk.highlight(null, afk.index);};break;case 37:if ($("autofilledview").innerHTML.length > 0 && afk.index > 0) {if (!afk.isKeywordBox && afk.enablelffunction) {afk.isKeywordBox = true;afk.lastIdStr = afk.idstr;afk.idstr = "line";afk.show();var lastId = afk.index;var lineTotal = afk.keywordsCount;if (!afk.isKeywordBox) {lineTotal = afk.brandsCount;}if (lastId > lineTotal || lastId == lineTotal) {afk.index = lineTotal;}if ($(afk.idstr + afk.index) && $(afk.idstr + afk.index).children[0]) {var selectkeyword = $(afk.idstr + afk.index).children[0].innerHTML.decodeHtml().trim();$("haQuickSearchBox")["value"] = selectkeyword;afk.highlight(afk.index, lastId);if (selectkeyword != null && selectkeyword != '') {if ($("haQuickSearchBox").setSelectionRange) {$("haQuickSearchBox").setSelectionRange(afk.searchKeyword.length, selectkeyword.length);} else if ($("haQuickSearchBox").createTextRange) {var txt = $("haQuickSearchBox").createTextRange();txt.moveStart("character", afk.searchKeyword.length);txt.moveEnd("character", selectkeyword.length);txt.select();}}}} else {afk.enablelffunction = false;}};break;case 38:if ($("autofilledview").innerHTML.length > 0) {afk.enablelffunction = true;afk.show();afk.lastIdStr = afk.idstr;var lastId = afk.index;var lineTotal = afk.keywordsCount;if (!afk.isKeywordBox) {lineTotal = afk.brandsCount;}if (lastId < 1 || lastId == 1) {afk.index = lineTotal;afk.lastId = 1;} else {--afk.index;};if ($(afk.idstr + afk.index) && $(afk.idstr + afk.index).children[0]) {var selectkeyword = $(afk.idstr + afk.index).children[0].innerHTML.decodeHtml().trim();$("haQuickSearchBox")["value"] = selectkeyword;afk.highlight(afk.index, lastId);if (selectkeyword != null && selectkeyword != '') {if ($("haQuickSearchBox").setSelectionRange) {$("haQuickSearchBox").setSelectionRange(afk.searchKeyword.length, selectkeyword.length);} else if ($("haQuickSearchBox").createTextRange) {var txt = $("haQuickSearchBox").createTextRange();txt.moveStart("character", afk.searchKeyword.length);txt.moveEnd("character", selectkeyword.length);txt.select();}}}}break;case 39:if ($("autofilledview").innerHTML.length > 0 && afk.index > 0) {if (afk.isKeywordBox && afk.enablelffunction) {afk.isKeywordBox = false;afk.lastIdStr = afk.idstr;afk.idstr = "brandline";afk.show();var lastId = afk.index;var lineTotal = afk.keywordsCount;if (!afk.isKeywordBox) {lineTotal = afk.brandsCount;}if (lastId > lineTotal || lastId == lineTotal) {afk.index = lineTotal;}if ($(afk.idstr + afk.index) && $(afk.idstr + afk.index).children[0]) {var selectkeyword = $(afk.idstr + afk.index).children[0].innerHTML.decodeHtml().trim();$("haQuickSearchBox")["value"] = selectkeyword;afk.highlight(afk.index, lastId);if (selectkeyword != null && selectkeyword != '') {if ($("haQuickSearchBox").setSelectionRange) {$("haQuickSearchBox").setSelectionRange(afk.searchKeyword.length, selectkeyword.length);} else if ($("haQuickSearchBox").createTextRange) {var txt = $("haQuickSearchBox").createTextRange();txt.moveStart("character", afk.searchKeyword.length);txt.moveEnd("character", selectkeyword.length);txt.select();}}}} else {afk.enablelffunction = false;}};break;case 40:if ($("autofilledview").innerHTML.length > 0) {afk.enablelffunction = true;afk.show();var lastId = afk.index;afk.lastIdStr = afk.idstr;var lineTotal = afk.keywordsCount;if (!afk.isKeywordBox) {lineTotal = afk.brandsCount;}if (lastId > lineTotal || lastId == lineTotal) {afk.index = 1;afk.lastId = lineTotal;}else {++afk.index;}if ($(afk.idstr + afk.index) && $(afk.idstr + afk.index).children[0]) {var selectkeyword = $(afk.idstr + afk.index).children[0].innerHTML.decodeHtml().trim();$("haQuickSearchBox")["value"] = selectkeyword;afk.highlight(afk.index, lastId);if (selectkeyword != null && selectkeyword != '') {if ($("haQuickSearchBox").setSelectionRange) {$("haQuickSearchBox").setSelectionRange(afk.searchKeyword.length, selectkeyword.length);} else if ($("haQuickSearchBox").createTextRange) {var txt = $("haQuickSearchBox").createTextRange();txt.moveStart("character", afk.searchKeyword.length);txt.moveEnd("character", selectkeyword.length);txt.select();}}}};break;default:if (o) {var key = o["value"];afk.index = 0;var igonreKeys = [9, 16, 17, 19, 20, 33, 34, 35, 36, 37, 38, 39, 40, 45, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 144, 145];if (!igonreKeys.contains(keyCode)) {var n = -1;if ($("haQuickSearchStore") && $("haQuickSearchStore") != null) {n = $("haQuickSearchStore")["value"].trim();}var myRegExp = new RegExp("[`~!@#\\$%&\\^\\*\\(\\)\\+=\\\\|\\{\\[\\}\\]:;\"',<>/\\?_]", "g");afk.searchKeyword = key.replace(myRegExp, "").trim();if (Web.Config.Environment.AutoFillBold.UseContentPage) {afk.WWWQuery(key.encodeURI());} else {var requestUrl = afk.url() + "?q=" + key.encodeURI() + "&n=" + n + "&rdm=" + (new Date()).toString().encodeURI();afk.renderText(requestUrl, key.encodeURI());};};};};},renderText: function (encodeURL, key) {var url = Web.Config.Environment.Url.WWW;var afk = Biz.Search.AutoFilledKeywordsNew;afk.index = 0;afk.isKeywordBox = true;afk.idstr = "line";afk.lastIdStr = "line";var sr = window.event.srcElement;jQuery.ajax({url: encodeURL,processData: false,cache: true,async: true,success: function (data, textStatus) {var o = Newegg$("autofilledview");if (data != null) {if (o && data != '') {if (key == sr["value"].encodeURI()) {Web.UI.Control.replaceInnerHTML(o, data);afk.show();afk.getLineCount();}} else {afk.hide();};} else {afk.hide();};},error: function (xmlHttpRequest, error) {afk.hide();}});},getRecentQuery: function (max, isShow, fieldName) {NEG.run(function(require) {var storage = require("Biz.Storage");var tmpValue = storage.getItem("ItemInnerSearchKeywords");var keywords = [];if (tmpValue) {keywords = tmpValue.split("|");};var o = Newegg$("autofilledview");if (o && keywords != null && keywords.length > 1 && isShow && max > 0) {var cookieValue = keywords[1];if (cookieValue.length > 0) {var cookiearry = cookieValue.split(",");var len = cookiearry.length;len = len > max ? max : len;if (cookiearry.length > 0) {var htmlBody = "
" + searches + " ";htmlBody = htmlBody + innerbody;}htmlBody = htmlBody + " |
" + fieldName + " |