document.write(''); var currentOffset = 0; var latestProcessTime = 0; var hideSearchSuggestion = true; var c; function DisplayHTMLResult(responseHTML) { // Get xslt xml transfrom display = document.getElementById('qSearch'); display.innerHTML = responseHTML; if (responseHTML) { ShowHTMLResult(); } else { HideHTMLResult(); } } function HideHTMLResult() { display = document.getElementById('qSearch') display.style.visibility = "hidden"; if (window.attachEvent && navigator.appVersion.substr(22,3)!="5.0") { if (display.childNodes.length) display.removeChild(display.childNodes[0]); } } function ShowHTMLResult() { display = document.getElementById('qSearch') if (display.innerHTML) { // Only for IE if (window.attachEvent && navigator.appVersion.substr(22,3)!="5.0") { var ieMat=document.createElement('iframe'); if(document.location.protocol == "https:") ieMat.src="//0"; else if(window.opera != "undefined") ieMat.src=""; else ieMat.src="javascript:false"; ieMat.scrolling="no"; ieMat.frameBorder="0"; ieMat.style.width=display.offsetWidth+"px"; ieMat.style.height=display.offsetHeight+"px"; ieMat.style.zIndex="-1"; display.insertBefore(ieMat, display.childNodes[0]); display.style.zIndex="100"; } display.style.visibility = "visible"; } } function processReqChange() { var status; if (c) { // only if req shows "complete" if (c.readyState == 4) { try { status = c.status; } catch (err) { //alert(err); status = ''; } if (status == 200) // Numeric code returned from server. 200 means "OK". { DisplayHTMLResult(c.responseText); } else { //alert("There was a problem retrieving the HTML data:\n" + c.statusText); } } } } function ProcessKey(e) { // Proceed only if the key pressed is alphnumeric or the backspace key var key = e.keyCode; // Keycodes 48 through 90 are the numbers and character keys. Keycodes 96 through 105 are the keys on the number pad. // 109 and 189 is - if ((48 <= key && key <= 90) || (96 <= key && key <= 105) || (key==8 || key==40 || key==38 || key==13 || key==109 || key==189)) { switch(key) { case 38: // Up arrow key PreviousProduct(); break; case 40: // Down arror key NextProduct(); break; case 13: // Enter key return SelectCurrentResult(); break; default: currentOffset=0; DelaySearch(); } } } function GetRealOffset() { currentOffset + displayOffset } function PreviousProduct() { if(currentOffset>0) { UnHighlightAll(); currentOffset--; HighlightResult(currentOffset); //GetProducts(); } } function NextProduct() { // Get the value in the search text box. var f = document.searchbar; var productName = f.search.value; resultTotal = 1; while (searchResultDiv = document.getElementById("qSrchBox_" + resultTotal)) { resultTotal++; } if (currentOffset < resultTotal - 1 ) { currentOffset++; } UnHighlightAll(); HighlightResult(currentOffset); //GetProducts(); } function DelaySearch() { var currentDateObj = new Date(); var processStartTime = currentDateObj.getTime(); latestProcessTime = processStartTime; setTimeout("StartSearch(" + processStartTime + ")", 300); } function StartSearch(processStartTime) { var currentDateObj = new Date(); var currentTime = currentDateObj.getTime(); var f = document.searchbar; var productName = f.search.value; if (processStartTime == latestProcessTime) { GetProducts(); } } function GetProducts() { // Get the value in the search text box. var f = document.searchbar; var productName = f.search.value; var zipUrl; // Create the XMLHttpRequest object. c = CreateHTMLRequestor(); // if the XMLHttpRequest object is in any state other than 0 (unitialized), then stop the current request. if (c && c.readyState!=0) { c.abort(); } // Set the function that handles changes in state. c.onreadystatechange = processReqChange; zipUrl = window.location.href; zipUrl = escape(zipUrl.replace(/setZip=\d{5}/, "")); productName = escape(productName); // Send the request. c.open("GET", "/search/getSearchResultHTML.php?metaCode=&q=" + productName + "&start=" + currentOffset + "&zipUrl=" + zipUrl, true); c.send(null); } function HighlightResult(resultNumber) { currentOffset = resultNumber; searchResultDiv = document.getElementById("qSrchBox_" + resultNumber); if (searchResultDiv) { divChildrenArray = searchResultDiv.getElementsByTagName("div"); searchBodyDiv = divChildrenArray[0]; if ( searchBodyDiv.className.search(" over\\b") == -1 ) searchBodyDiv.className += " over"; } } function UnHighlightAll() { result = 1; while (searchResultDiv = document.getElementById("qSrchBox_" + result)) { UnHighlightResultDiv(result); result++; } } function UnHighlightResultDiv(resultNumber) { searchResultDiv = document.getElementById("qSrchBox_" + resultNumber); divChildrenArray = searchResultDiv.getElementsByTagName("div"); searchBodyDiv = divChildrenArray[0]; searchBodyDiv.className = searchBodyDiv.className.replace(new RegExp(" over\\b"), ""); } function SelectCurrentResult() { if (currentOffset) { searchResultDiv = document.getElementById("qSrchBox_" + currentOffset); if (searchResultDiv) { anchorElement = GetAnchorElement(searchResultDiv); if (anchorElement) { window.location = anchorElement.href; } return false; } } else { var f = document.searchbar; var productName = f.search.value; document.location = "/search.htm?search=" + productName; return false; } } function DeactivateKey(e) { var key = e.keyCode; var keyChar = String.fromCharCode(key); keyChar = keyChar.toLowerCase(); if (key == 13 && currentOffset) { return true; } return false; } function GetAnchorElement(element) { anchorElement = element.getElementsByTagName("a"); return anchorElement[0]; } function BrowserHeight() { return document.documentElement != null? document.documentElement.clientHeight:null; } document.onclick = function() { if (hideSearchSuggestion) HideHTMLResult(); }