﻿function HandleSearchSelection(a) { SetSearchTextValue(a); typeAheadContainer.hide(); btnSearchSubmit.click() } function GetSearchKeywordDisplay(a, b) { var c = new RegExp(a, "g"); var d = "<strong>" + a + "</strong>"; return b.replace(c, d) } function ShowTypeAheadHtml(a) { if (a.length <= 0) { typeAheadContainer.html(""); typeAheadContainer.hide(); return } var b = ""; var c = []; for (var d = 0; d < a.length; d++) { var e = "/browse/_/N-/Ntt-" + a[d].Keyword + "/results1.aspx"; var f = a[d].Keyword; var g = a[d].Brand; c.push('<li><a href="#" onclick="HandleSearchSelection(\'' + f + "');\">" + GetSearchKeywordDisplay(GetSearchTextValue(), a[d].Keyword) + "</a></li>"); if (d == 0) { for (var h = 0; h < a[d].Departments.length; h++) { var i = a[d].Departments[h]; var j = "in"; var k = ""; var l = true; if (i.Domain) { k = ("https:" == document.location.protocol ? "https://" : "http://") + i.Domain; j = "on"; l = false } var m = k + "/browse" + i.SearchUrl + "/results1.aspx"; if (i.DisplayOnTop == "True") c.push('<li class="InCategory"><a href="' + m + '">' + j + " " + i.Name + " (" + i.Count + ")" + "</a></li>"); else b += '<li class="InCategoryOnBottom"><a href="' + m + '">' + GetSearchKeywordDisplay(GetSearchTextValue(), a[d].Keyword) + " - " + j + " " + i.Name + " (" + i.Count + ")" + "</a></li>" } } } c.push(b); var n = "<ul class='ResultsList'>" + c.join("") + "</ul>"; typeAheadContainer.html(n); typeAheadContainer.show(); $(".TypeAheadContainer li").each(function(a, b) { $(b).mouseover(function() { SelectSuggestion(a, false) }) }) } function clearTypeAheadContainer() { typeAheadContainer.html(""); typeAheadContainer.hide(); if (!isTypeAheadSelectionHandler) { if (typeof hdnSearchUrl !== "undefined" && hdnSearchUrl != null) hdnSearchUrl.val("") } } function FetchAndDisplayTypeAheadData(a, b) { var c = false; var d = $(hdnBrand).val(); var e = $(".SearchBrand"); if (e && e.val() != "-") { d = e.val() } if (responseData == null || responseData.length == 0 || a.length < b.length) { c = true } else { for (i = 0; i < responseData.length; i++) { if (responseData[i].Keyword.indexOf(a) !== 0) { c = true; break } } } if (c) { var f = "/WebServices/TypeAhead.ashx?prefix=" + a + "&brand=" + d; AjaxCallHandler.Schedule(f, typeAheadDelay) } else ShowTypeAheadHtml(responseData) } function typeAheadRegistration() { searchBox = $(".SearchBox"); typeAheadContainer = $(".TypeAheadContainer"); searchBox.bind("textchange", function(a, b) { if (txtChangeIsProgramatic) { txtChangeIsProgramatic = false; return } var c = GetSearchTextValue(); if (typeof b == "undefined") b = ""; if (c != b) { searchResultIndex = -1; if (c.length > typeAheadMinLength && c != "") { originalPrefix = c; FetchAndDisplayTypeAheadData(c, b) } else { clearTypeAheadContainer() } } }); $("body").click(function() { clearTypeAheadContainer() }); typeAheadContainer.mouseout(function() { SetSearchTextValue(originalPrefix); if (!isTypeAheadSelectionHandler) { hdnSearchUrl.val("") } SelectSuggestion(-1) }); searchBox.keydown(function(a) { if (a.keyCode == 8 && searchBox.val() == "") { clearTypeAheadContainer() } else if (a.keyCode == 13 && hdnSearchUrl.val() != "") { isTypeAheadSelectionHandler = true } else if (a.keyCode == 38 || a.keyCode == 40) { if (searchResultIndex < searchResultMaxIndex - 1 && searchResultIndex >= -1 && a.keyCode == 40) { searchResultIndex++ } else if (searchResultIndex < searchResultMaxIndex && searchResultIndex >= 0 && a.keyCode == 38) { searchResultIndex-- } if (searchResultIndex == -1) { SetSearchTextValue(originalPrefix); hdnSearchUrl.val("") } SelectSuggestion(searchResultIndex, true) } }) } function SelectSuggestion(a, b) { $(".TypeAheadContainer li").each(function(c, d) { var e = $(d); if (e.hasClass("Selected")) { e.removeClass("Selected") } if (c == a) { e.addClass("Selected"); if (!e.hasClass("InCategory") && !e.hasClass("InCategoryOnBottom")) { var f = e.children(":first").text(); if (b) SetSearchTextValue(f); hdnSearchUrl.val("/browse/_/N-/Ntt-" + f + "/results1.aspx") } else { var f = $(".TypeAheadContainer").children(":first").children(":first").text(); var g = e.children(":first"); if (b) SetSearchTextValue(f); hdnSearchUrl.val(g.attr("href")) } } }); searchResultIndex = a } function GetSearchTextValue() { return jQuery.trim(searchBox.val()) } function SetSearchTextValue(a) { searchBox.val(a); txtChangeIsProgramatic = true } function ILoad_CustomAppearance_Browse_click(a) { Radactive.WebControls.ILoad.AddImage(a, false) } function addLoadEvent(a, b) { var c = window.onload; if (typeof window.onload != "function") { window.onload = function() { a(b) } } else { window.onload = function() { if (c) { c() } a(b) } } } function doPosLoop(a, b) { var c = a; var d = c["offset" + b]; while (c.tagName != "BODY") { c = c.offsetParent; if (c) { d += c["offset" + b] } else { break } } return d } function left_pos(a) { return doPosLoop(a, "Left") } function top_pos(a) { return doPosLoop(a, "Top") } function get_object(a) { if (document.getElementById) return document.getElementById(a); else if (document.layers) return document.layers[a]; else if (document.all) return document.all[a] } function makeInvisible(a) { get_object(a).className = "invisible" } function makeVisible(a, b) { get_object(a).className = b } function ratingsDisplayed(a, b, c, d) { if (a > 0) { get_object("hideBV").style.display = "block" } } function changeTabContents(a) { var b = a + "Tabs"; var c = a + "Content"; get_object("displayedTabBox").innerHTML = get_object(b).innerHTML; get_object("divTabContents").innerHTML = get_object(c).innerHTML } function displayFullReviews() { var a = get_object("fullReviews").className; get_object("fullReviews").className = shortReviews.className; get_object("summaryReviews").className = a } function makeAccessFlyoutVisible(a) { makeVisible(a, "AjaxRecAcBox") } function makeButtonVisible(a, b) { var c = get_object(a); if (c != null) { c.className = b; enablePostback() } } function closeNotification() { makeInvisible("popupOutOfStock") } function openNotification(a, b, c, d) { var e = get_object(get_object("hdnPopupProdIdClient").value); var f = get_object(get_object("hdnPopupVarIdClient").value); var g = get_object(get_object("hdnPopupProdNameClient").value); var h = get_object("hdnPopupTitle"); var i = get_object("hdnPopupImage"); var j = get_object("popupOutOfStock"); e.value = b; f.value = c; g.value = d; h.innerHTML = d; i.src = "http://images.celebrateexpress.com/mgen/merchandiser/" + b + ".jpg?is=200,200,0xffffff"; j.className = "AjaxOoSContainer"; j.style.left = left_pos(a) - j.offsetWidth - 10 + "px"; j.style.top = top_pos(a) - j.offsetHeight + 20 + "px" } function enablePostback() { enablePostbackWithName("hdnSubmitted") } function enablePostbackWithName(a) { get_object(a).value = "false" } function disablePostBack() { return disablePostBackWithName("hdnSubmitted") } function disablePostBackWithName(a) { var b = get_object(a).value; if (b == "false") { get_object(a).value = "true"; return true } return false } function confirmDelete(a) { if (a == "address") { return confirm("Are you sure you want to delete this Address from your profile?") } return true } function clickButton(a, b) { var c = a ? a : window.event; var d = document.getElementById(b); if (d) { if (c.keyCode == 13) { d.click(); return false } } } function decimalDisplay(a) { var b = new String; b = " " + a; if (b.indexOf(".") < 0) b += "."; var c = b.substring(b.indexOf(".")).length; while (c < 3) { b = b + "0"; c = b.substring(b.indexOf(".")).length } return b.replace(" ", "") } function RemoveCoupon(a) { setCookie("BuyCostumesRemoveCoupon", a, 30, "/", "", ""); window.location.href = unescape(window.location.pathname) } function copyAToB(a, b) { get_object(b).value = get_object(a).value } function eraseCookie(a) { createCookie(a, "", -1) } function readCookie(a) { var b = a + "="; var c = document.cookie.split(";"); for (var d = 0; d < c.length; d++) { var e = c[d]; while (e.charAt(0) == " ") e = e.substring(1, e.length); if (e.indexOf(b) == 0) return e.substring(b.length, e.length) } return null } function setCookie(a, b, c, d, e, f) { var g = new Date; g.setTime(g.getTime()); if (c) { c = c * 1e3 * 60 * 60 * 24 } var h = new Date(g.getTime() + c); document.cookie = a + "=" + escape(b) + (c ? ";expires=" + h.toGMTString() : "") + (d ? ";path=" + d : "") + (e ? ";domain=" + e : "") + (f ? ";secure" : "") } function createCookie(a, b, c) { var d = c / 24; setCookie(a, b, d, "/", "", "") } function replaceMainImage(a, b, c, d, e) { var f = "javascript:openwindowlink('http://izoom.celebrateexpress.com/merchandizer/zoom_rounded/zoomce.aspx?img={0}&ProductName={1}&ABTest={2}')"; var g = document.getElementsByName(b)[0]; var h = get_object("imgZoom1"); var i = get_object("imgZoom2"); h.href = f.replace("{0}", c).replace("{1}", d).replace("{2}", e); i.href = f.replace("{0}", c).replace("{1}", d).replace("{2}", e); g.src = a } function openvideoplayer(a) { var b = "http://images.celebrateexpress.com/video/cevidplayer/VideoPlayer.aspx?VFN=" + a; openWindow(b, "CelebrateExpressVideo", "directories=0,height=490,width=490,scrollbars=no") } function opensizechart(a) { openWindow("/Pages/Content/SizeChart.aspx?prodid=" + a, "Buycostumes", "directories=0,height=600,width=650,scrollbars=yes") } function openPage(a, b) { openWindow("/pages/Content/ContentDisplay.aspx?siteid=3&pageid=" + a, b, "width=800,height=800,scrollbars=yes") } function openwindowlink_outstock() { openWindow("/pages/popups/outofstock_pop.htm", "Details", "directories=0,height=175,width=300,scrollbars=no") } function openwindowlink(a) { openWindow(a, "Buycostumes", "directories=0,height=550,width=420,scrollbars=no") } function openWindow(a, b, c) { var d = window.open(a, b, c); d.focus() } function popUp(URL) { day = new Date; id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=600,left = 390,top = 212');") } $(document).ready(function() { typeAheadRegistration() }); var searchResultIndex = -1; var searchResultMaxIndex = 0; var originalPrefix = ""; var searchBox; var typeAheadContainer; var responseData; var txtChangeIsProgramatic = false; var isTypeAheadSelectionHandler = false; var AjaxCallHandler = { Schedule: function(a, b) { this.Cancel(); this.timeOutId = window.setTimeout(function() { $.ajax({ url: a, context: document.body, dataType: "json", success: function(a) { responseData = a; ShowTypeAheadHtml(a); searchResultMaxIndex = a.length; if (a.length > 0) { searchResultMaxIndex += a[0].Departments.length } } }) }, b) }, Cancel: function() { if (typeof this.timeOutId == "number") { window.clearTimeout(this.timeOutId); delete this.timeOutId } } }
