﻿function Selections(options) { this.ElementCache = []; this.getSelectionElement = function(id) { if (!this.ElementCache["cache_" + id]) this.ElementCache["cache_" + id] = document.getElementById(id); return this.ElementCache["cache_" + id] }; if (!options.Variable || options.Variable == "") throw "No variable specified"; if (!options.Container || options.Container == "") throw "No container specified"; this.options = options; this.Container = this.getSelectionElement(this.options.Container); this.Properties = []; this.Selections = []; this.Items = []; this.ItemProperties = []; this.DisplayCache = []; this.PropertiesLength = 0; this.SelectionsLength = 0; this.ItemsLength = 0; this.GetPropertyByPropertyId = function(i) { return this.Properties[this.options.Variable + '_Property_' + i] }; this.GetSelectionBySelectionId = function(i) { return this.Selections[this.options.Variable + '_Selection_' + i] }; this.GetItemByItemId = function(id) { for (var i = 0; i < this.options.Items.length; i++) { if (this.options.Items[i].i == id) return this.options.Items[i] } }; if (this.options.Properties) { for (var p = 0; p < this.options.Properties.length; p++) { this.Properties[this.options.Variable + '_Property_' + this.options.Properties[p].i] = this.options.Properties[p]; for (var s = 0; s < this.options.Properties[p].s.length; s++) { this.Selections[this.options.Variable + '_Selection_' + this.options.Properties[p].s[s].i] = this.options.Properties[p].s[s]; this.SelectionsLength++ } } this.PropertiesLength = this.options.Properties.length; for (var i = 0; i < this.options.Items.length; i++) { this.Items[this.options.Variable + '_Item_' + this.options.Items[i].s.toString()] = this.options.Items[i] } this.ItemsLength = this.options.Items.length } if (!this.Container) throw "Container not found"; var Suffix = (this.options.Suffix ? this.options.Suffix : ''); this.ItemProperties['IP_ItemName'] = { Type: 'SINGLE', Target: '#hdngItemName' + Suffix }; this.ItemProperties['IP_SKU'] = { Type: 'SINGLE', Target: '#spanSKU' + Suffix }; this.ItemProperties['IP_Price'] = { Type: 'SINGLE', Target: '#spanPrice' + Suffix }; this.ItemProperties['IP_ShortDesc'] = { Type: 'SINGLE', Target: '#pShortDesc' + Suffix }; this.ItemProperties['IP_LongDesc'] = { Type: 'SINGLE', Target: '#longDescription' + Suffix }; this.ItemProperties['IP_Callouts'] = { Type: 'SINGLE', Target: '#itemCallouts' + Suffix }; this.ItemProperties['IP_Images'] = { Type: 'SINGLE', Target: '#altImages' + Suffix, OnHover: true }; this.ItemProperties['IP_ImagesViewer'] = { Type: 'SINGLE', Target: '#altImagesViewer' + Suffix, OnHover: true }; this.ItemProperties['IP_Image'] = { Type: 'IMAGE', Target: '.productImage .mainImage' + Suffix, OnHover: true }; this.ItemProperties['IP_ImageLarge'] = { Type: 'IMAGE', Target: '.imageViewer .mainImage img' + Suffix, OnHover: true }; this.ItemProperties['IP_Pricing'] = { Type: 'SINGLE', Target: '#itemPricing' + Suffix }; this.ItemProperties['IP_Link'] = { Type: 'HREF', Target: '.itemAnchor' + Suffix }; this.Create = function() { var str = '<input type="hidden" id="hdnItem_' + this.options.Variable + '" name="hdnItem_' + this.options.Variable + '" ' + (this.options.SelectedItem ? 'value="' + this.options.SelectedItem + '"' : '') + ' />'; var CurrentItem = null; if (this.options.SelectedItem) CurrentItem = this.GetItemByItemId(this.options.SelectedItem); str += '<div class="productDetails"><div class="detailsRow">'; for (var p = 0; p < this.PropertiesLength; p++) { var Property = this.options.Properties[p]; str += '<input type="hidden" id="hdnProperty_' + this.options.Variable + '_' + Property.i + '" name="hdnProperty_' + this.options.Variable + '_' + Property.i + '" ' + (CurrentItem ? 'value="' + CurrentItem.s[p] + '"' : '') + ' />'; if (!Property.m || Property.m == '') { str += '<div class="rowLabel floatLeft"><span title="' + Property.n + '">' + Property.n + '</span> <span class="selectedName" id="span_' + this.options.Variable + '_p_' + Property.i + '"></span></div>' } else { str += '<div class="rowLabel floatLeft"><span title="' + Property.n + '"><img src="/assets/property/' + Property.m + '" alt="' + Property.n + '" /></span> <span class="selectedName" id="span_' + this.options.Variable + '_p_' + Property.i + '"></span></div>' } var clear = '<div class="floatLeft" style="display:none;margin-left:10px;" id="divClear_' + this.options.Variable + '_' + Property.i + '"><a href="javascript:void(0);" class="smaller" onclick="window[\'' + this.options.Variable + '\'].Clear(' + Property.i + ');' + this.options.Variable + '.UpdateDisplay(true);">Clear</a></div>'; switch (Property.t) { case "SWATCH": str += clear; str += '<div class="clear">&nbsp;</div><ul class="swatchList">\n'; for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; str += '<li><a href="#" id="' + this.options.Variable + '_l_' + Selection.i + '"><img src="/assets/item/swatch/' + Selection.m + '" alt="' + Selection.a + '" /></a></li>\n' } str += '</ul><div class="clear">&nbsp;</div>'; break; case "TEXTLINK": str += clear; str += '<div class="clear">&nbsp;</div><ul class="textLink">\n'; for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; str += '<li><a href="#" id="' + this.options.Variable + '_l_' + Selection.i + '">' + Selection.s + '</a></li>\n' } str += '</ul><div class="clear">&nbsp;</div>'; break; case "DROPDOWN": str += '<div class="clear">&nbsp;</div><select id="' + this.options.Variable + '_p_' + Property.i + '" onchange="' + this.options.Variable + '.Select(' + Property.i + ',this.value,true);"><option value="">' + Property.a + '</option>'; for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; str += '<option value="' + Selection.i + '" ' + (CurrentItem && CurrentItem.s[p] == Selection.i ? "selected" : "") + '>' + Selection.s + '</option>' } str += '</select><div class="clear">&nbsp;</div>'; break; case "RADIO": str += clear; str += '<div class="clear">&nbsp;</div>'; for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; str += '<span style="white-space:nowrap;"><label style="margin-right:10px;"><input type="radio" id="' + this.options.Variable + '_r_' + Selection.i + '" name="' + this.options.Variable + '_p_' + Property.i + '" onmouseover="" onmouseout="" />' + Selection.s + '</label></span> ' } str += '<div class="clear">&nbsp;</div>'; break } } str += '</div></div>'; this.Container.innerHTML = str; var btn = this.getSelectionElement(this.options.AddToCartBtn); if (btn) btn.onclick = new Function("window['" + this.options.Variable + "'].AddToCart();return false;"); btn = this.getSelectionElement(this.options.AddToWishlistBtn); if (btn) btn.onclick = new Function("window['" + this.options.Variable + "'].AddToWishlist();return false;"); if (CurrentItem) { if (this.PropertiesLength > 0) { for (var p = 0; p < this.PropertiesLength; p++) { var Property = this.options.Properties[p]; this.Select(Property.i, CurrentItem.s[p], true) } } else { this.UpdateAvailability() } } else if (this.options.Properties && this.PropertiesLength > 0) { this.Select(this.options.Properties[0].i, "", true) } }; this.Select = function(p, id, clicked) { var Property = this.GetPropertyByPropertyId(p); var h = this.getSelectionElement("hdnProperty_" + this.options.Variable + "_" + p); var prev = h.value; this.Clear(p); h.value = id; if (id == "") { this.UpdateDisplay(true); return } var Selection = this.GetSelectionBySelectionId(id); switch (Property.t) { case "SWATCH": this.getSelectionElement(this.options.Variable + '_l_' + Selection.i).className = "active"; break; case "TEXTLINK": this.getSelectionElement(this.options.Variable + '_l_' + Selection.i).className = "active"; break; case "DROPDOWN": break; case "RADIO": this.getSelectionElement(this.options.Variable + '_r_' + Selection.i).checked = true; break } this.getSelectionElement("span_" + this.options.Variable + "_p_" + Property.i).innerHTML = Selection.s; var clr = this.getSelectionElement("divClear_" + this.options.Variable + "_" + Property.i); if (clr) clr.style.display = ""; this.UpdateDisplay(clicked, Property) }; this.UpdateDisplay = function(clicked, objProperty) { var v = this.options.Variable; var str = ''; var conn = ''; var arr = new Array; var SelectedCount = 0; for (var p = 0; p < this.PropertiesLength; p++) { var Property = this.options.Properties[p]; h = this.getSelectionElement("hdnProperty_" + v + "_" + Property.i); str += conn + h.value; if (h.value == "") { arr[arr.length] = 0 } else { arr[arr.length] = parseInt(h.value); SelectedCount++ } conn = ',' } var CurrentItem = this.Items[v + '_Item_' + str]; var origClicked = clicked; if (!CurrentItem && objProperty && objProperty.u && this.getSelectionElement("hdnProperty_" + v + "_" + objProperty.i).value != "") { var val = parseInt(this.getSelectionElement("hdnProperty_" + v + "_" + objProperty.i).value); for (var x = 0; x < this.ItemsLength; x++) { if ($.inArray(val, this.options.Items[x].s) > -1) { clicked = true; CurrentItem = this.options.Items[x]; break } } } if (clicked && (CurrentItem || SelectedCount == 0)) { clicked = origClicked; var o = window['ItemInfo_' + (CurrentItem ? CurrentItem.i : "")]; if (o) { this.HandleItemInfo(o, clicked, CurrentItem) } else { $.getJSON('/ajax.aspx?F=GetSelectionItemInfo' + (this.options.IsQuickBuy ? "&IsQuickBuy=Y" : "") + (CurrentItem ? "" : "&IsParent=Y") + '&ItemId=' + (CurrentItem ? CurrentItem.i : this.options.Items[0].i), function(o) { window['ItemInfo_' + (CurrentItem ? CurrentItem.i : "")] = o; window[v].HandleItemInfo(o, clicked, CurrentItem) }) } } this.UpdateAvailability(); var validSelections = this.DisplayCache[arr.toString()]; if (!validSelections) { validSelections = []; var indicies = []; for (var c = 0; c < arr.length; c++) { if (arr[c] != 0) { indicies[indicies.length] = { "Index": c, "Value": arr[c]} } } if (indicies.length == 0) { for (var s in this.Selections) { validSelections[validSelections.length] = this.Selections[s].i } } else { for (var i = 0; i < this.ItemsLength; i++) { var Item = this.options.Items[i]; var cDiff = []; for (var s = 0; s < Item.s.length; s++) { if (arr[s] != 0 && Item.s[s] != arr[s]) cDiff[cDiff.length] = Item.s[s]; if (cDiff.length > 1) break } if (cDiff.length <= 1) { if (cDiff.length == 0) { for (var s = 0; s < Item.s.length; s++) { if ($.inArray(Item.s[s], validSelections) == -1) validSelections[validSelections.length] = Item.s[s] } } else { if ($.inArray(cDiff[0], validSelections) == -1) validSelections[validSelections.length] = cDiff[0] } } } } this.DisplayCache[arr.toString()] = validSelections } for (var p = 0; p < this.PropertiesLength; p++) { var Property = this.options.Properties[p]; var h = this.getSelectionElement("hdnProperty_" + v + "_" + Property.i); var prev = h.value; switch (Property.t) { case "SWATCH": for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; var elem = this.getSelectionElement(v + '_l_' + Property.s[s].i); var tags = elem.getElementsByTagName('IMG'); for (var img = 0; img < tags.length; img++) { parseInt(h.value) == Property.s[s].i ? tags[img].className = "active" : tags[img].className = "" } if (SelectedCount > 0 && $.inArray(Property.s[s].i, validSelections) == -1) { elem.onclick = function() { return false }; elem.onmouseover = null; elem.onmouseout = null; for (var img = 0; img < tags.length; img++) { tags[img].className = 'disabled' } elem.getElementsByTagName('IMG').className = 'disabled' } else { elem.onclick = new Function("window['" + v + "'].Select(" + Property.i + ", " + Selection.i + ", true); return false;"); if (clicked) { elem.onmouseover = new Function("window['" + v + "'].Select(" + Property.i + ", " + Selection.i + ", false);"); elem.onmouseout = new Function("window['" + v + "'].Select(" + Property.i + ", " + (prev == "" ? "'" + prev + "'" : prev) + ", false);") } } } break; case "TEXTLINK": for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; var elem = this.getSelectionElement(v + '_l_' + Property.s[s].i); parseInt(h.value) == Property.s[s].i ? elem.className = "active" : elem.className = ""; if (SelectedCount > 0 && $.inArray(Property.s[s].i, validSelections) == -1) { elem.onclick = function() { return false }; elem.onmouseover = null; elem.onmouseout = null; elem.className = 'disabled' } else { elem.onclick = new Function("window['" + v + "'].Select(" + Property.i + ", " + Selection.i + ", true); return false;"); if (clicked) { elem.onmouseover = new Function("window['" + v + "'].Select(" + Property.i + ", " + Selection.i + ", false);"); elem.onmouseout = new Function("window['" + v + "'].Select(" + Property.i + ", " + (prev == "" ? "'" + prev + "'" : prev) + ", false);") } } } break; case "DROPDOWN": var d = $("#" + v + "_p_" + Property.i); var val = d.val(); var html = '<option value="">' + Property.a + '</option>'; for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; if (SelectedCount > 0 && $.inArray(Property.s[s].i, validSelections) == -1) { html += '<option value="' + Selection.i + '" disabled="disabled" onclick="return false;" style="color:#ccc;">' + Selection.s + '</option>' } else { html += '<option value="' + Selection.i + '"' + (parseInt(h.value) == Property.s[s].i ? ' selected' : '') + '>' + Selection.s + '</option>' } } d.html(html); d.val(val); break; case "RADIO": for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; var elem = this.getSelectionElement(v + '_r_' + Property.s[s].i); parseInt(h.value) == Property.s[s].i ? elem.checked = true : elem.checked = false; elem.disabled = false; if (SelectedCount > 0 && $.inArray(Property.s[s].i, validSelections) == -1) { elem.onclick = function() { return false }; elem.disabled = true } else { elem.onclick = new Function("window['" + v + "'].Select(" + Property.i + ", " + Selection.i + ", true);") } } break } } }; this.HandleItemInfo = function(o, clicked, CurrentItem) { if (!o.Success) return; var properties = this.ItemProperties; for (var x = 0; x < o.ItemProperties.length; x++) { var p = o.ItemProperties[x]; var ip = properties['IP_' + p.N]; if (ip && (clicked || ip.OnHover)) { if (!ip.T) ip.T = $(ip.Target); switch (ip.Type) { case "SINGLE": if (ip.Target == '#spanPrice') { if (CurrentItem) { if (!CurrentItem.r) { ip.T.html(p.V) } else { ip.T.html('N/A') } } else { ip.T.html('') } } else { ip.T.html(p.V) } break; case "IMAGE": ip.T.attr('src', p.V).attr('alt', p.Alt); break; case "HREF": ip.T.attr('href', "javascript:void(0);"); ip.T.unbind("click").click(new Function("window.location = \"" + p.V + "\";return false;")); break } } } }; this.UpdateAvailability = function() { var v = this.options.Variable; var str = ''; var conn = ''; var arr = new Array; var SelectedCount = 0; var CurrentItem = null; if (this.PropertiesLength > 0) { for (var p = 0; p < this.PropertiesLength; p++) { var Property = this.options.Properties[p]; h = this.getSelectionElement("hdnProperty_" + v + "_" + Property.i); str += conn + h.value; if (h.value == "") { arr[arr.length] = 0 } else { arr[arr.length] = parseInt(h.value); SelectedCount++ } conn = ',' } CurrentItem = this.Items[v + '_Item_' + str]; var ctrl = this.getSelectionElement(this.options.AddToCartBtn).parentNode; var ctrlPrice = this.getSelectionElement("spanPrice"); ctrl.style.display = "none" } else if (this.options.Items.length > 0) { CurrentItem = this.options.Items[0] } if (CurrentItem) { this.getSelectionElement("hdnItem_" + v).value = CurrentItem.i; var email = (this.Email ? this.Email : ""); var ctrlRQ = this.getSelectionElement(this.options.RequestQuoteBtn).parentNode; var ctrl = this.getSelectionElement(this.options.AddToCartBtn).parentNode; ctrl.style.display = ""; var em = this.getSelectionElement(this.options.EmailContainerId); em.style.display = "none"; if (CurrentItem.r) { ctrl.style.display = "none"; ctrlRQ.style.display = ""; btnRQ = this.getSelectionElement(this.options.RequestQuoteBtn); if (btnRQ) btnRQ.onclick = new Function("window['" + this.options.Variable + "'].RequestQuote();return false;") } else { ctrlRQ.style.display = "none"; if (this.options.EnableInventory) { if (CurrentItem.q <= CurrentItem.h) { if (CurrentItem.c != 'Backorder') { ctrl.style.display = "none"; em.innerHTML = '<div style="margin-bottom:10px;"><strong>Sorry, this item is currently out of stock.</strong><br />Enter your email address below to receive notification when it becomes available.<div style="margin-top:4px;"><input type="text" id="' + v + '_txtEmailMe" maxlength="100" style="width:150px;" value="' + email + '" onkeypress="var e = event; var code = (e.which ? e.which : e.keyCode); if (code == 13) {window[\'' + v + '\'].EmailMe(); return false; } window[\'' + v + '\'].Email = this.value;" onkeyup="window[\'' + v + '\'].Email = this.value;" /> <span class="btnWrapper"><input type="button" class="btn" value="GO" onclick="window[\'' + v + '\'].EmailMe();" /></span></div></div>'; em.style.display = "" } else { var bdate = ''; if (CurrentItem.b) bdate = '<br />Estimated Ship Date: ' + CurrentItem.b; em.innerHTML = '<div style="margin-bottom:10px;"><strong>This item is currently on backorder.</strong>' + bdate + '</div>'; em.style.display = "" } } } } } }; this.Clear = function(p) { var Property = this.GetPropertyByPropertyId(p); this.getSelectionElement("hdnItem_" + this.options.Variable).value = ""; var h = this.getSelectionElement("hdnProperty_" + this.options.Variable + "_" + Property.i); if (h.value == "") return; h.value = ""; this.getSelectionElement("span_" + this.options.Variable + "_p_" + Property.i).innerHTML = ""; var clr = this.getSelectionElement("divClear_" + this.options.Variable + "_" + Property.i); if (clr) clr.style.display = "none"; switch (Property.t) { case "SWATCH": for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; var elem = this.getSelectionElement(this.options.Variable + '_l_' + Property.s[s].i); elem.className = ''; var tags = elem.getElementsByTagName('IMG'); for (var img = 0; img < tags.length; img++) { tags[img].className = '' } } break; case "TEXTLINK": for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; var elem = this.getSelectionElement(this.options.Variable + '_l_' + Property.s[s].i); elem.className = '' } break; case "DROPDOWN": break; case "RADIO": for (var s = 0; s < Property.s.length; s++) { var Selection = Property.s[s]; var elem = this.getSelectionElement(this.options.Variable + '_r_' + Property.s[s].i); elem.checked = false; elem.disabled = false } break } }; this.AddToCart = function() { if (!this.ValidateSelections()) return; var id = this.getSelectionElement("hdnItem_" + this.options.Variable).value; var Quantity = $('#' + this.options.QuantityTextBox); var qty = 1; if (Quantity.length > 0) qty = Quantity.val(); if (!parseInt(qty) || parseInt(qty) < 1) { alert("Please enter a valid numeric quantity"); cqty.focus(); return } qty = parseInt(qty); var drp = $('#' + this.options.RecipientDropDown); var txt = $('#' + this.options.RecipientTextBox); var rec = 'Myself'; if (drp.length > 0) rec = drp.val(); if (rec == 'OtherSpecify' && txt.length > 0) { rec = txt.val(); if (isEmpty(rec)) { alert('Please enter the recipient name.'); txt.focus(); return } } if (rec == '' || rec == 'OtherSpecify') rec = 'Myself'; $.getJSON('/ajax.aspx?F=Add2Cart&ItemId=' + id + '&OrderItemId=' + (this.options.CurrentOrderItemId ? this.options.CurrentOrderItemId : 0) + '&Qty=' + qty + '&Recipient=' + rec + '&DepartmentId=' + (this.options.CurrentDepartmentId ? this.options.CurrentDepartmentId : 0), function(o) { if (!o.Success) { alert((o.Error ? o.Error : 'An error occurred while trying to add the item to your cart.')); return } $('#divItemAdded').html(o.Html); $('#spanCartTotal').html(o.Quantity + (parseInt(o.Quantity) == 1 ? ' Item ' : ' Items ') + o.SubTotal); showRecentCart() }) }; this.RequestQuote = function() { if (!this.ValidateSelections()) return; var id = this.getSelectionElement("hdnItem_" + this.options.Variable).value; window.location = "/service/contact.aspx?ItemId=" + id }; this.AddToWishlist = function() { if (!this.ValidateSelections()) return; var id = this.getSelectionElement("hdnItem_" + this.options.Variable).value; var cqty = $('#' + this.options.QuantityTextBox); var qty = 1; if (cqty.length > 0) qty = cqty.val(); if (!parseInt(qty) || parseInt(qty) < 1) { alert("Please enter a valid numeric quantity"); cqty.focus(); return } qty = parseInt(qty); var drp = $('#' + this.options.RecipientDropDown); var txt = $('#' + this.options.RecipientTextBox); var rec = 'Myself'; if (drp.length > 0) rec = drp.val(); if (rec == 'OtherSpecify' && txt.length > 0) { rec = txt.val(); if (isEmpty(rec)) { alert('Please enter the recipient name.'); txt.focus(); return } } if (rec == '' || rec == 'OtherSpecify') rec = 'Myself'; $.getJSON('/ajax.aspx?F=Add2Wishlist&ItemId=' + id + '&OrderItemId=' + (this.options.CurrentOrderItemId ? this.options.CurrentOrderItemId : 0) + '&Qty=' + qty + '&Recipient=' + rec + '&DepartmentId=' + (this.options.CurrentDepartmentId ? this.options.CurrentDepartmentId : 0), function(o) { if (!o.Success) { if (o.Error) alert(o.Error); return } window.location = o.Url }) }; this.ValidateSelections = function() { var id = this.getSelectionElement("hdnItem_" + this.options.Variable).value; if (!parseInt(id) || parseInt(id) == 0) { var str = ""; var count = 0; var conn = ""; for (var p = 0; p < this.PropertiesLength; p++) { var Property = this.options.Properties[p]; var h = this.getSelectionElement("hdnProperty_" + this.options.Variable + "_" + Property.i); if (h.value == "") { str += conn + Property.n; count++; conn = "\n" } } count == 1 ? alert("Please make a selection for attribute \"" + str + "\"") : alert("Please make selections for the following attributes:\n\n" + str); return false } return true }; this.EmailMe = function(Cancel, Email) { if (!this.ValidateSelections()) return; var v = this.options.Variable; var c = this.options.EmailContainerId; var t = this.getSelectionElement(v + "_txtEmailMe"); if (!Email) Email = t.value; $.getJSON('/ajax.aspx?F=EmailMe&Email=' + Email + '&ItemId=' + this.getSelectionElement("hdnItem_" + v).value + '&Cancel=' + (Cancel ? Cancel : ""), function(o) { if (o.Response == 1) { $('#' + c).html('<div style="margin-bottom:10px;"><b>Thank you, we have received your request.</b><br />You will be notified when this product becomes available.</div>') } else if (o.Response == 2) { $('#' + c).html('<div style="margin-bottom:10px;"><b>The email address provided has already been submitted for notification.</b><br /><a href="#" onclick="window[\'' + v + '\'].EmailMe(\'Y\', \'' + Email + '\');return false;">Click here</a> to cancel this notification.</div>') } else if (o.Response == 3) { alert('Please enter a valid email address.'); $('#' + t).focus() } else if (o.Response == 4) { $('#' + c).html('<div style="margin-bottom:10px;"><b>Your email address has been removed.</b><br /><a href="#" onclick="window[\'' + v + '\'].UpdateAvailability(); return false;">Click here</a> to add your email address again.</div>') } else { alert('An error occurred. Please try again.') } }) }; this.HandleKeyPress = function(e) { var code = (e.which ? e.which : e.keyCode); if (code == 13) { this.AddToCart(); return false } return true } };
