/** * @author Gproxy Design Inc. * @copyright (c) 2011, Gproxy Design Inc. All rights reserved. * @version 1.0 * * Gproxy doesn't allow to copy or change this code without Gproxy authorization. * See http://www.gproxy.com/licenses/license01.pdf for the full license governing this code. */ var intQioListTotal = 0; var intQioListCurrent = -1; var intQioDelay = 500; var strQioSearchId = null; var strQioResultsId = null; var objQioSearchField = null; var objQioResultsDiv = null; function qioSetAutoComplete(b, c, a,params) { strQioSearchId = "#" + b; strQioResultsId = "#" + c; $j("body").append('
'); objQioSearchField = $j(strQioSearchId); objQioResultsDiv = $j(strQioResultsId); qioRepositionResultsDiv(); objQioSearchField.blur(function () { setTimeout("qioClearAutoComplete()", 200) }); objQioSearchField.keyup(function (f) { var d = f.keyCode || window.event.keyCode; var g = objQioSearchField.val(); if (qioUpDown(d)) { return } if (d == 13 || d == 27) { qioClearAutoComplete(); return } setTimeout(function () { qioAutoComplete(g, a,params) }, intQioDelay) }) } function qioAutoComplete(a, b,params) { var c = objQioSearchField.val(); if (c == "") { qioClearAutoComplete(); return } if (a != c) { return } qioGetResults(c, b,params) } function qioClearAutoComplete() { objQioResultsDiv.html(""); objQioResultsDiv.css("display", "none") } function qioRepositionResultsDiv() { var a = objQioSearchField.offset(); var d = a.top; var b = a.left; var h = objQioSearchField.height(); var c = objQioSearchField.width(); var e = $j("body").height(); var i = objQioResultsDiv.height(); var f = (d + h + i + 4); if (f > e) { var g = (d - i - 4) } else { var g = d + h + 4 } objQioResultsDiv.css("position", "absolute"); objQioResultsDiv.css("left", b - 2); objQioResultsDiv.css("top", g); objQioResultsDiv.css("width", c + 200) } function qioUpDown(a) { if (a == 40 || a == 38) { if (a == 38) { if (intQioListCurrent == 0 || intQioListCurrent == -1) { intQioListCurrent = intQioListTotal - 1 } else { intQioListCurrent-- } } else { if (intQioListCurrent == intQioListTotal - 1) { intQioListCurrent = 0 } else { intQioListCurrent++ } } objQioResultsDiv.children().each(function (b) { if (b == intQioListCurrent) { objQioSearchField.val(this.childNodes[0].childNodes[0].nodeValue); this.className = "qio_selected" } else { this.className = "qio_unselected" } }); return true } else { intQioListCurrent = -1; return false } } function qioGetResults(b, a, params) { /* Precondition: params is undefined or an array of objects with the form {name: , value: } */ var d = "/app/site/hosting/scriptlet.nl?script=customscript_gpr_qio_getresults_ss&deploy=customdeploy_gpr_qio_getresults_ss&itemsearch=" + escape(b) + "&resultvar=objQioResultsDiv&itemscountvar=intQioListTotal&sitenumber=" + a; if (typeof params != "undefined"){ for (var i=0;i < params.length;i++){ d += "&" + params[i].name + "=" + params[i].value; } } var c = document.createElement("script"); c.setAttribute("type", "text/javascript"); if (c.readyState) { c.onreadystatechange = function () { if (c.readyState == "loaded" || c.readyState == "complete") { c.onreadystatechange = null; qioShowResults() } } } else { c.onload = function () { qioShowResults() } } document.getElementById("qio_search").style.background = "#fff url(/site/gpr/qio/qio_ajax_loader.gif) 100% 1px no-repeat"; c.setAttribute("src", d); document.getElementsByTagName("head")[0].appendChild(c) } function qioShowResults() { qioRepositionResultsDiv(); $j('#qio_search').css('background-image', 'none'); if (intQioListTotal > 0) { objQioResultsDiv.css("display", "block"); var a = $j(strQioResultsId + " > div"); a.mouseover(function () { a.each(function () { this.className = "qio_unselected" }); this.className = "qio_selected" }); a.click(function () { objQioSearchField.val(this.childNodes[0].childNodes[0].nodeValue); document.forms.form_qio.itemid.value = this.id; document.forms.form_qio.buyid.value = this.id; qioClearAutoComplete() }) } else { objQioResultsDiv.css("display", "block"); setTimeout("qioClearAutoComplete()", 3000) } } function qioAddToCart(a) { if (document.forms[a].qty.value > 0) { if (document.forms[a].itemid.value != "" && document.forms[a].itemid.value != null) { document.forms[a].submit() } else { alert("Please type the item SKU in the imput box.") } } else { document.forms[a].qty.value = "1"; alert("Invalid number (must be greater than 0).") } };