function idev_search_banner_track(a, b) { a.href = "/banners.aspx?BannerId=" + b; a.mousedown = ""; return true } function setSelectedSpan(a, b) { var c = -1; var d; var e; var f = a.getElementsByTagName("div"); if (f) { for (var g = 0; g < f.length; g++) { if (f[g].className == "wrapper") { if (e == null) e = f[g]; if (++c == b) { _highlightResult(f[g]); d = f[g] } else { _unhighlightResult(f[g]) } } } } if (d == null) { _highlightResult(e); d = e } return d } function getSelectedSpanNum(a) { var b = -1; var c = a.getElementsByTagName("div"); if (c) { for (var d = 0; d < c.length; d++) { if (c[d].className == "wrapper") { b++; if (c[d].style.backgroundColor != a.style.backgroundColor) return b } } } return -1 } function keypressHandler(a) { var b = getDiv(divName); if (b.style.visibility == "hidden") return true; if (!a && window.event) { a = window.event } var c = a.keyCode; var d = 38; var e = 40; var f = 13; var g = 9; if (c != d && c != e && c != f && c != g) return true; var h = getSelectedSpanNum(b); var i = setSelectedSpan(b, h); if (c == f || c == g) { if (i && c == g) { _selectResult(i); a.cancelBubble = true; return false } else { hideDiv(); return true } } else { if (c == d) i = setSelectedSpan(b, h - 1); if (c == e) i = setSelectedSpan(b, h + 1) } showDiv(true); return true } function doRemoteQuery(a) { searching = true; var b = lookupURL; $.ajax({ type: "GET", contentType: "application/json; charset=utf-8", url: b + "&q=" + escape(a), data: "", dataType: "jsonp", success: function (a) { showQueryDiv(a); searching = false }, error: function (a) { try { clearQueryDiv() } catch (b) { } searching = false } }) } function adjustiFrame() { if (!document.getElementById(ifName)) { var a = document.createElement("iFrame"); a.setAttribute("id", ifName); a.setAttribute("src", "javascript:false;"); a.setAttribute("scrolling", "no"); a.setAttribute("frameborder", "0"); document.body.appendChild(a) } iFrameDiv = document.getElementById(ifName); var b = getDiv(divName); try { iFrameDiv.style.position = "absolute"; iFrameDiv.style.width = b.offsetWidth; iFrameDiv.style.height = b.offsetHeight; iFrameDiv.style.top = b.style.top; iFrameDiv.style.left = b.style.left; iFrameDiv.style.zIndex = b.style.zIndex - 1; iFrameDiv.style.visibility = b.style.visibility } catch (c) { } } function hideDiv() { showDiv(false) } function showDiv(a) { var b = getDiv(divName); if (a) b.style.visibility = "visible"; else b.style.visibility = "hidden"; adjustiFrame() } function _unhighlightResult(a) { a.style.backgroundColor = DIV_BG_COLOR; a.style.color = FONT_COLOR } function unhighlightResult() { _unhighlightResult(this) } function _highlightResult(a) { if (a == null) return; a.style.backgroundColor = DIV_HIGHLIGHT_COLOR; a.style.color = FONT_HOVER_COLOR } function highlightResult() { var a = -1; var b = globalDiv.getElementsByTagName("div"); if (b) { for (var c = 0; c < b.length; c++) { if (b[c].className == "wrapper") { a++; _unhighlightResult(b[c]) } } } _highlightResult(this) } function _selectResult(a) { window.location = a.getAttribute("url") } function selectResult() { _selectResult(this) } function showProducts(a, b, c, d) { for (var e = 0; e < b.length; e++) { var f = b[e]; var g = document.createElement("div"); g.style.position = "relative"; g.style.borderTop = "solid 1px " + DIV_BG_COLOR; g.style.borderBottom = "solid 1px " + DIV_BG_COLOR; var h = document.createElement("div"); h.className = "wrapper"; h.style.backgroundColor = DIV_BG_COLOR; h.onmouseover = highlightResult; h.onmouseout = unhighlightResult; h.style.cursor = "hand"; h.setAttribute("url", f.URL); h.style.height = "82px"; h.innerHTML = f.HTML; if (e == 0) { var i = document.createElement("div"); i.style.backgroundColor = "#d9d9d9"; i.style.fontWeight = "bold"; i.style.fontSize = "1.1em"; i.style.padding = "4px"; i.innerHTML = "Top " + b.length + " Product Match" + (b.length == 1 ? "" : "es"); a.appendChild(i) } g.appendChild(h); g.onmousedown = new Function("window.location = '" + f.URL + PreserverUrlParams() + "'"); a.appendChild(g); if (e == b.length - 1) { var j = document.createElement("div"); j.style.backgroundColor = "#d9d9d9"; j.style.padding = "4px"; j.innerHTML = '<a href="javascript:void(0);" onmousedown=\'window.location="' + d + "/?keyword=" + escape(queryField.value) + PreserverUrlParams() + "\"'>View All Matches</a>" + (parseInt(c) >= 0 ? '<div style="margin-top:3px;font-size:.85em;">' + c + " result(s)</span>" : ""); a.appendChild(j) } } } function showTerms(a, b, c) { for (var d = 0; d < b.length; d++) { var e = b[d]; if (e.Value == null) continue; var f = document.createElement("div"); f.style.position = "relative"; f.style.borderTop = "solid 1px " + DIV_BG_COLOR; f.style.borderBottom = "solid 1px " + DIV_BG_COLOR; var g = document.createElement("div"); g.style.position = "relative"; g.className = "wrapper"; g.style.backgroundColor = DIV_BG_COLOR; g.onmouseover = highlightResult; g.onmouseout = unhighlightResult; g.style.cursor = "hand"; g.style.height = "18px"; if (d == 0) { var h = document.createElement("div"); h.style.backgroundColor = "#d9d9d9"; h.style.fontWeight = "bold"; h.style.fontSize = "1.1em"; h.style.padding = "4px"; h.innerHTML = c; a.appendChild(h) } var i = document.createElement("div"); i.Id = b[d]; i.style.height = "16px"; i.style.position = "absolute"; i.style.overflow = "hidden"; i.style.top = "3px"; i.style.left = "5px"; i.style.textAlign = "left"; i.style.width = "320px"; i.innerHTML = e.Value; g.appendChild(i); g.setAttribute("url", e.URL + PreserverUrlParams()); f.appendChild(g); f.onmousedown = new Function("window.location = '" + e.URL + PreserverUrlParams() + "'"); a.appendChild(f) } } function showQueryDiv(a) { var b = getDiv(divName); if (a == null) { return } while (b.childNodes.length > 0) b.removeChild(b.childNodes[0]); var c = a.Categories; var d = a.Popular; var e = a.Products; showTerms(b, d, "Popular Searches"); showTerms(b, c, "Top Product Categories"); showProducts(b, e, a.Count, a.SearchWebsiteURL); showDiv(c.length > 0 || d.length > 0 || e.length > 0) } function clearQueryDiv() { var a = getDiv(divName); while (a.childNodes.length > 0) a.removeChild(a.childNodes[0]); hideDiv() } function getDiv(a) { if (!globalDiv) { if (!document.getElementById(a)) { var b = document.createElement("div"); b.setAttribute("id", a); document.body.appendChild(b) } globalDiv = document.getElementById(a); var c = queryField.offsetLeft; var d = queryField.offsetTop + queryField.offsetHeight; var e = queryField; while (e.offsetParent) { e = e.offsetParent; c += e.offsetLeft; d += e.offsetTop } if (!divFormatted) { globalDiv.style.backgroundColor = DIV_BG_COLOR; globalDiv.style.fontFamily = "Arial, Helvetica, sans-serif"; globalDiv.style.border = "1px solid #666666"; globalDiv.style.fontSize = "13px"; globalDiv.style.width = divWidth; globalDiv.style.position = "absolute"; globalDiv.style.left = c + "px"; globalDiv.style.top = d + "px"; globalDiv.style.visibility = "hidden"; globalDiv.style.zIndex = 1e4; divFormatted = true } } return globalDiv } function PreserverUrlParams() { var a = $.QS["prv"] + ""; var b = $.QS["adv"] + ""; var c = ""; if (a != undefined && a != "undefined" && a != "") c += "&prv=" + escape(a); if (b != undefined && b != "undefined" && b != "") c += "&adv=" + escape(b); return c } function idevInitQueryCode(a, b, c) { queryField = document.getElementById(a); queryField.onblur = hideDiv; queryField.onkeydown = keypressHandler; queryField.autocomplete = "off"; lookupURL = b; if (c) divName = c; else divName = "querydiv"; ifName = "queryiframe"; setTimeout("mainLoop()", 100) } var queryField; var lookupURL; var divName; var ifName; var lastVal = ""; var val = ""; var searching = false; var globalDiv; var divFormatted = false; var DIV_BG_COLOR = "#ffffff"; var DIV_HIGHLIGHT_COLOR = "#3366cc"; var FONT_COLOR = "#000000"; var FONT_HOVER_COLOR = "#ffffff"; var divWidth = "360px"; (function (a) { a.QS = function (a) { if (a == "") return {}; var b = {}; for (var c = 0; c < a.length; ++c) { var d = a[c].split("="); if (d.length != 2) continue; b[d[0]] = decodeURIComponent(d[1].replace(/\+/g, " ")) } return b } (window.location.search.substr(1).split("&")) })(jQuery); mainLoop = function () { val = queryField.value; if (lastVal != val && val != "Enter Keyword" && searching == false) { lastVal = val; doRemoteQuery(escape(val)) } setTimeout("mainLoop()", 100); return true }
